- Korrekturen an den persönlichen Publikationslisten und Projektlisten

- PublicationDataXmlHelper in Modul ccm-sci-publications verschoben, da diese Klasse nicht nur in ccm-sci-types-organizationwithpublications nützlich ist (ccm-sci-personalpublications nutzt sie jetzt auch)


git-svn-id: https://svn.libreccm.org/ccm/trunk@1153 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2011-10-09 13:36:58 +00:00
parent 2dcca10ec0
commit e646cecbfd
7 changed files with 444 additions and 40 deletions

View File

@ -175,6 +175,7 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
PublicPersonalProfile profile =
(PublicPersonalProfile) DomainObjectFactory.
newInstance(profiles.getDataObject());
profiles.close();
if (config.getEmbedded()) {
final ContentSection section =
@ -293,7 +294,7 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
final ContentGenerator generator =
(ContentGenerator) generatorObj;
generator.generateContent(root,
generator.generateContent(profileElem,
owner,
state);
@ -329,6 +330,7 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
final RelatedLink link =
(RelatedLink) DomainObjectFactory.
newInstance(links.getDataObject());
links.close();
final ContentItem item = link.getTargetItem();
final PublicPersonalProfileXmlGenerator generator =
new PublicPersonalProfileXmlGenerator(

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<registry>
<config class="com.arsdigita.cms.publicpersonalprofile.PersonalProjectsConfig"
storage="ccm-sci-personalprojects/personalprojects.properties"/>
storage="ccm-cms-publicpersonalprofile/personalprojects.properties"/>
</registry>

View File

@ -1,12 +1,18 @@
package com.arsdigita.cms.publicpersonalprofile;
import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.contenttypes.GenericAddress;
import com.arsdigita.cms.contenttypes.GenericContactEntry;
import com.arsdigita.cms.contenttypes.GenericContactEntryCollection;
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitContactCollection;
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitPersonCollection;
import com.arsdigita.cms.contenttypes.GenericPerson;
import com.arsdigita.cms.contenttypes.GenericPersonContactCollection;
import com.arsdigita.cms.contenttypes.SciProject;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
import com.arsdigita.xml.Element;
import java.util.ArrayList;
import java.util.Calendar;
@ -25,6 +31,12 @@ import org.apache.log4j.Logger;
*/
public class PersonalProjects implements ContentGenerator {
/*
* Note 2011-10-09: This class contains some code which has been copied from
* SciOrganizationBasePanel and GenericOrganizationalUnitPanel. This copied
* code will be reworked after the ccm-sci-types-organization module has
* been refactored and split into independent content types.
*/
private final static String CURRENT_PROJECTS = "currentProjects";
private final static String FINISHED_PROJECTS = "finishedProjects";
private final static PersonalProjectsConfig config =
@ -41,10 +53,11 @@ public class PersonalProjects implements ContentGenerator {
final PageState state) {
final List<SciProject> projects = collectProjects(person);
final Element personalProjectsElem = parent.newChildElement(
"personalProjects");
if ((projects == null) || projects.size() == 0) {
final Element projectsElem = parent.newChildElement("projects");
projectsElem.newChildElement("noProjects");
if ((projects == null) || projects.isEmpty()) {
personalProjectsElem.newChildElement("noProjects");
return;
} else {
@ -53,8 +66,8 @@ public class PersonalProjects implements ContentGenerator {
new ArrayList<SciProject>();
processProjects(projects, currentProjects, finishedProjects);
generateGroupsXml(parent, currentProjects, finishedProjects);
generateProjectsXml(parent,
generateGroupsXml(personalProjectsElem, currentProjects, finishedProjects);
generateProjectsXml(personalProjectsElem,
currentProjects,
finishedProjects,
state);
@ -208,10 +221,389 @@ public class PersonalProjects implements ContentGenerator {
private void generateProjectXml(final Element projectGroupElem,
final SciProject project,
final PageState state) {
final PublicPersonalProfileXmlGenerator generator =
/*final PublicPersonalProfileXmlGenerator generator =
new PublicPersonalProfileXmlGenerator(
project);
generator.generateXML(state, projectGroupElem, "");
generator.generateXML(state, projectGroupElem, "");*/
Element projectElem = projectGroupElem.newChildElement("project");
projectElem.addAttribute("oid", project.getOID().toString());
Element title = projectElem.newChildElement("title");
title.setText(project.getTitle());
//Element beginElem = projectElem.newChildElement("projectbegin");
if ((project.getAddendum() != null)
&& !(project.getAddendum().isEmpty())) {
Element addendum = projectElem.newChildElement("addendum");
addendum.setText(project.getAddendum());
}
if ((project.getProjectShortDescription() != null)
&& !(project.getProjectShortDescription().isEmpty())) {
Element shortDesc = projectElem.newChildElement("shortDescription");
shortDesc.setText(project.getProjectShortDescription());
}
GenericOrganizationalUnitPersonCollection members;
members = project.getPersons();
members.addOrder("surname asc, givenname asc");
if (members.size() > 0) {
Element membersElem = projectElem.newChildElement("members");
while (members.next()) {
generateMemberXML(new MemberListItem(members.getOID(),
members.getSurname(),
members.getGivenName(),
members.getTitlePre(),
members.getTitlePost(),
members.getBirthdate(),
members.getGender(),
null, members.getRoleName(),
members.getStatus()),
membersElem,
members.getRoleName(),
members.getStatus(),
state);
}
}
GenericOrganizationalUnitContactCollection contacts;
contacts = project.getContacts();
if (contacts.size() > 0) {
Element contactsElem = projectElem.newChildElement("contacts");
while (contacts.next()) {
generateContactXML(contacts.getContactType(),
contacts.getPerson(),
contacts.getContactEntries(),
contacts.getAddress(),
contactsElem,
state,
Integer.toString(contacts.getContactOrder()),
true);
}
}
}
protected void generateMemberXML(final MemberListItem person,
final Element parent,
final String roleName,
final String status,
final PageState state) {
Element memberElem = parent.newChildElement("member");
memberElem.addAttribute("role", roleName);
memberElem.addAttribute("status", status);
memberElem.addAttribute("oid", person.getOID().toString());
//Element title = memberElem.newChildElement("title");
//title.setText(person.getTitle());
if ((person.getTitlePre() != null)
&& !person.getTitlePre().isEmpty()) {
Element titlePre = memberElem.newChildElement("titlePre");
titlePre.setText(person.getTitlePre());
}
Element surname = memberElem.newChildElement("surname");
surname.setText(person.getSurname());
Element givenName = memberElem.newChildElement("givenname");
givenName.setText(person.getGivenName());
if ((person.getTitlePost() != null)
&& !person.getTitlePost().isEmpty()) {
Element titlePost = memberElem.newChildElement("titlePost");
titlePost.setText(person.getTitlePost());
}
if ((person.getContacts() != null)
&& (person.getContacts().size() > 0)) {
GenericPersonContactCollection contacts;
contacts = new GenericPersonContactCollection(person.getContacts());
Element contactsElem =
memberElem.newChildElement("contacts");
while (contacts.next()) {
generateContactXML(
contacts.getContactType(),
contacts.getPerson(),
contacts.getContactEntries(),
contacts.getAddress(),
contactsElem,
state,
contacts.getContactOrder(),
false);
}
}
}
protected void generateContactXML(
final String contactType,
final GenericPerson person,
final GenericContactEntryCollection contactEntries,
final GenericAddress address,
final Element parent,
final PageState state,
final String order,
final boolean withPerson) {
Element contactElem = parent.newChildElement("contact");
contactElem.addAttribute("order", order);
//Element title = contactElem.newChildElement("title");
//title.setText(contact.getTitle());
Element typeElem = contactElem.newChildElement("type");
typeElem.setText(contactType);
if (withPerson) {
if (person != null) {
Element personElem = contactElem.newChildElement("person");
if ((person.getTitlePre() != null) && !person.getTitlePre().
isEmpty()) {
Element titlePre =
personElem.newChildElement("titlePre");
titlePre.setText(person.getTitlePre());
}
Element givenName = contactElem.newChildElement("givenname");
givenName.setText(person.getGivenName());
Element surname = contactElem.newChildElement("surname");
surname.setText(person.getSurname());
if ((person.getTitlePost() != null)
&& !person.getTitlePost().isEmpty()) {
Element titlePost = contactElem.newChildElement(
"titlePost");
titlePost.setText(person.getTitlePost());
}
}
}
if ((contactEntries != null)
&& (contactEntries.size() > 0)) {
Element contactEntriesElem =
contactElem.newChildElement("contactEntries");
while (contactEntries.next()) {
GenericContactEntry contactEntry =
contactEntries.getContactEntry();
Element contactEntryElem =
contactEntriesElem.newChildElement(
"contactEntry");
contactEntryElem.addAttribute("key",
contactEntry.getKey());
Element valueElem = contactEntryElem.newChildElement(
"value");
valueElem.setText(contactEntry.getValue());
if ((contactEntry.getDescription() != null)
&& !contactEntry.getDescription().isEmpty()) {
Element descElem = contactEntryElem.newChildElement(
"description");
descElem.setText(contactEntry.getDescription());
}
}
}
if (address != null) {
Element addressElem = contactElem.newChildElement(
"address");
Element postalCode = addressElem.newChildElement(
"postalCode");
postalCode.setText(address.getPostalCode());
Element city = addressElem.newChildElement("city");
city.setText(address.getCity());
Element data = addressElem.newChildElement("address");
data.setText(address.getAddress());
Element country = addressElem.newChildElement("country");
country.setText(address.getIsoCountryCode());
Element theState = addressElem.newChildElement("state");
theState.setText(address.getState());
}
}
protected class MemberListItem {
private OID oid;
private String surname;
private String givenName;
private String titlePre;
private String titlePost;
private Date birthdate;
private String gender;
private DataCollection contacts;
//private GenericPerson member;
private String role;
private String status;
public MemberListItem(final GenericPerson member,
final String role,
final String status) {
/*this.member = member;
this.role = role;
this.status = status;*/
this(member.getOID(),
member.getSurname(),
member.getGivenName(),
member.getTitlePre(),
member.getTitlePost(),
member.getBirthdate(),
member.getGender(),
null,
role,
status);
}
public MemberListItem(final OID oid,
final String surname,
final String givenName,
final String titlePre,
final String titlePost,
final Date birthdate,
final String gender,
final DataCollection contacts,
final String role,
final String status) {
this.oid = oid;
this.surname = surname;
this.givenName = givenName;
this.titlePre = titlePre;
this.titlePost = titlePost;
this.birthdate = birthdate;
this.gender = gender;
this.contacts = contacts;
this.role = role;
this.status = status;
}
/*public GenericPerson getMember() {
return member;
}*/
public OID getOID() {
return oid;
}
public Date getBirthdate() {
return birthdate;
}
public DataCollection getContacts() {
return contacts;
}
public String getGender() {
return gender;
}
public String getGivenName() {
return givenName;
}
public String getSurname() {
return surname;
}
public String getTitlePost() {
return titlePost;
}
public String getTitlePre() {
return titlePre;
}
public String getRole() {
return role;
}
public String getStatus() {
return status;
}
/*@Override
public boolean equals(Object obj) {
if (obj instanceof MemberListItem) {
MemberListItem other = (MemberListItem) obj;
return member.equals(other.getMember());
} else {
return false;
}
}*/
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final MemberListItem other = (MemberListItem) obj;
if ((this.surname == null) ? (other.surname != null)
: !this.surname.equals(other.surname)) {
return false;
}
if ((this.givenName == null) ? (other.givenName != null)
: !this.givenName.equals(other.givenName)) {
return false;
}
if ((this.titlePre == null) ? (other.titlePre != null)
: !this.titlePre.equals(other.titlePre)) {
return false;
}
if ((this.titlePost == null) ? (other.titlePost != null)
: !this.titlePost.equals(other.titlePost)) {
return false;
}
if (this.birthdate != other.birthdate && (this.birthdate == null
|| !this.birthdate.equals(
other.birthdate))) {
return false;
}
if ((this.gender == null) ? (other.gender != null)
: !this.gender.equals(other.gender)) {
return false;
}
if ((this.role == null) ? (other.role != null)
: !this.role.equals(other.role)) {
return false;
}
if ((this.status == null) ? (other.status != null)
: !this.status.equals(other.status)) {
return false;
}
return true;
}
/*@Override
public int hashCode() {
return member.hashCode();
}*/
@Override
public int hashCode() {
int hash = 3;
hash =
41 * hash + (this.surname != null ? this.surname.hashCode() : 0);
hash =
41 * hash + (this.givenName != null ? this.givenName.hashCode() : 0);
hash =
41 * hash + (this.titlePre != null ? this.titlePre.hashCode() : 0);
hash =
41 * hash + (this.titlePost != null ? this.titlePost.hashCode() : 0);
hash =
41 * hash + (this.birthdate != null ? this.birthdate.hashCode() : 0);
hash =
41 * hash + (this.gender != null ? this.gender.hashCode() : 0);
hash = 41 * hash + (this.role != null ? this.role.hashCode() : 0);
hash =
41 * hash + (this.status != null ? this.status.hashCode() : 0);
return hash;
}
}
private class ProjectComparator implements Comparator<SciProject> {

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<registry>
<config class="com.arsdigita.cms.publicpersonalprofile.PersonalPublicationsConfig"
storage="ccm-sci-personalpublications/personalpublications.properties"/>
storage="ccm-cms-publicpersonalprofile/personalpublications.properties"/>
</registry>

View File

@ -4,6 +4,7 @@ import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.contenttypes.AuthorshipCollection;
import com.arsdigita.cms.contenttypes.GenericPerson;
import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.contenttypes.ui.PublicationXmlHelper;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.DataObject;
@ -44,10 +45,11 @@ public class PersonalPublications implements ContentGenerator {
final PageState state) {
final List<DataObject> publications = collectPublications(person);
if ((publications == null) || publications.size() == 0) {
final Element publicationsElem = parent.newChildElement(
"publications");
publicationsElem.newChildElement("noPublications");
final Element personalPubsElem = parent.newChildElement(
"personalPublications");
if ((publications == null) || publications.isEmpty()) {
personalPubsElem.newChildElement("noPublications");
return;
} else {
@ -55,14 +57,15 @@ public class PersonalPublications implements ContentGenerator {
processPublications(
publications);
generateGroupsXml(parent, groupedPublications);
generatePublicationsXml(parent, groupedPublications, state);
generateGroupsXml(personalPubsElem, groupedPublications);
generatePublicationsXml(personalPubsElem, groupedPublications, state);
}
}
private List<DataObject> collectPublications(final GenericPerson person) {
final List<DataObject> publications = new ArrayList<DataObject>();
final DataCollection collection = (DataCollection) person.get("publication");
final DataCollection collection = (DataCollection) person.get(
"publication");
while (collection.next()) {
publications.add(collection.getDataObject());
@ -77,7 +80,8 @@ public class PersonalPublications implements ContentGenerator {
private void collectPublications(final GenericPerson alias,
final List<DataObject> publications) {
final DataCollection collection = (DataCollection) alias.get("publication");
final DataCollection collection = (DataCollection) alias.get(
"publication");
while (collection.next()) {
publications.add(collection.getDataObject());
@ -120,6 +124,9 @@ public class PersonalPublications implements ContentGenerator {
if (dobj.getObjectType().hasProperty("reviewed")) {
reviewed = (Boolean) dobj.get("reviewed");
if (reviewed == null) {
reviewed = Boolean.FALSE;
}
if (reviewed) {
groupName = groupConfig.getTypeGroupMap().get(String.format(
"%s_ref", type));
@ -252,10 +259,13 @@ public class PersonalPublications implements ContentGenerator {
private void generatePublicationXml(final Element publicationGroupElem,
final Publication publication,
final PageState state) {
final PublicPersonalProfileXmlGenerator generator =
/*final PublicPersonalProfileXmlGenerator generator =
new PublicPersonalProfileXmlGenerator(
publication);
generator.generateXML(state, publicationGroupElem, "");
generator.generateXML(state, publicationGroupElem, "");*/
final PublicationXmlHelper xmlHelper = new PublicationXmlHelper(
publicationGroupElem, publication);
xmlHelper.generateXml();
}
/**

View File

@ -608,7 +608,7 @@ public abstract class SciOrganizationBasePanel
final Element parent,
final PageState state) {
Element projectElem = parent.newChildElement("project");
projectElem.addAttribute("oid", project.toString());
projectElem.addAttribute("oid", project.getOID().toString());
Element title = projectElem.newChildElement("title");
title.setText(project.getTitle());