diff --git a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfilesServlet.java b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfilesServlet.java
index 06af4e815..6e4270d77 100644
--- a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfilesServlet.java
+++ b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfilesServlet.java
@@ -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(
diff --git a/ccm-sci-personalprojects/src/ccm-sci-personalprojects.config b/ccm-sci-personalprojects/src/ccm-sci-personalprojects.config
index ac12feaf3..98642d03d 100644
--- a/ccm-sci-personalprojects/src/ccm-sci-personalprojects.config
+++ b/ccm-sci-personalprojects/src/ccm-sci-personalprojects.config
@@ -1,5 +1,5 @@
+ storage="ccm-cms-publicpersonalprofile/personalprojects.properties"/>
\ No newline at end of file
diff --git a/ccm-sci-personalprojects/src/com/arsdigita/cms/publicpersonalprofile/PersonalProjects.java b/ccm-sci-personalprojects/src/com/arsdigita/cms/publicpersonalprofile/PersonalProjects.java
index 4866ea0d3..dc1716536 100644
--- a/ccm-sci-personalprojects/src/com/arsdigita/cms/publicpersonalprofile/PersonalProjects.java
+++ b/ccm-sci-personalprojects/src/com/arsdigita/cms/publicpersonalprofile/PersonalProjects.java
@@ -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;
@@ -19,12 +25,18 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
/**
- *
+ *
* @author Jens Pelzetter (jensp)
* @version $Id$
*/
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 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();
processProjects(projects, currentProjects, finishedProjects);
- generateGroupsXml(parent, currentProjects, finishedProjects);
- generateProjectsXml(parent,
+ generateGroupsXml(personalProjectsElem, currentProjects, finishedProjects);
+ generateProjectsXml(personalProjectsElem,
currentProjects,
finishedProjects,
state);
@@ -105,8 +118,8 @@ public class PersonalProjects implements ContentGenerator {
final List currentProjects,
final List finishedProjects) {
final Calendar today = new GregorianCalendar();
- final Date todayDate = today.getTime();
- for(SciProject project : projects) {
+ final Date todayDate = today.getTime();
+ for (SciProject project : projects) {
if (project.getEnd().before(todayDate)) {
finishedProjects.add(project);
} else {
@@ -208,10 +221,389 @@ public class PersonalProjects implements ContentGenerator {
private void generateProjectXml(final Element projectGroupElem,
final SciProject project,
final PageState state) {
- final PublicPersonalProfileXmlGenerator generator =
- new PublicPersonalProfileXmlGenerator(
- project);
- generator.generateXML(state, projectGroupElem, "");
+ /*final PublicPersonalProfileXmlGenerator generator =
+ new PublicPersonalProfileXmlGenerator(
+ project);
+ 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 {
diff --git a/ccm-sci-personalpublications/src/ccm-sci-personalpublications.config b/ccm-sci-personalpublications/src/ccm-sci-personalpublications.config
index 0bfd7b0df..5a6735b32 100644
--- a/ccm-sci-personalpublications/src/ccm-sci-personalpublications.config
+++ b/ccm-sci-personalpublications/src/ccm-sci-personalpublications.config
@@ -1,5 +1,5 @@
+ storage="ccm-cms-publicpersonalprofile/personalpublications.properties"/>
\ No newline at end of file
diff --git a/ccm-sci-personalpublications/src/com/arsdigita/cms/publicpersonalprofile/PersonalPublications.java b/ccm-sci-personalpublications/src/com/arsdigita/cms/publicpersonalprofile/PersonalPublications.java
index 15c36651c..c931f96f4 100644
--- a/ccm-sci-personalpublications/src/com/arsdigita/cms/publicpersonalprofile/PersonalPublications.java
+++ b/ccm-sci-personalpublications/src/com/arsdigita/cms/publicpersonalprofile/PersonalPublications.java
@@ -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;
@@ -43,11 +44,12 @@ public class PersonalPublications implements ContentGenerator {
final GenericPerson person,
final PageState state) {
final List 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,37 +57,39 @@ public class PersonalPublications implements ContentGenerator {
processPublications(
publications);
- generateGroupsXml(parent, groupedPublications);
- generatePublicationsXml(parent, groupedPublications, state);
+ generateGroupsXml(personalPubsElem, groupedPublications);
+ generatePublicationsXml(personalPubsElem, groupedPublications, state);
}
}
-
+
private List collectPublications(final GenericPerson person) {
final List publications = new ArrayList();
- final DataCollection collection = (DataCollection) person.get("publication");
-
- while(collection.next()) {
+ final DataCollection collection = (DataCollection) person.get(
+ "publication");
+
+ while (collection.next()) {
publications.add(collection.getDataObject());
}
-
+
if (person.getAlias() != null) {
collectPublications(person, publications);
}
-
+
return publications;
}
-
+
private void collectPublications(final GenericPerson alias,
final List publications) {
- final DataCollection collection = (DataCollection) alias.get("publication");
-
- while(collection.next()) {
+ final DataCollection collection = (DataCollection) alias.get(
+ "publication");
+
+ while (collection.next()) {
publications.add(collection.getDataObject());
}
-
+
if (alias.getAlias() != null) {
collectPublications(alias, publications);
- }
+ }
}
/**
@@ -108,18 +112,21 @@ public class PersonalPublications implements ContentGenerator {
initalizePubGroupMap(pubGroups, group);
}
initalizePubGroupMap(pubGroups, MISC);
-
+
Publication publication;
String type;
String groupName;
Boolean reviewed;
List group;
- for(DataObject dobj : publications) {
+ for (DataObject dobj : publications) {
publication = (Publication) DomainObjectFactory.newInstance(dobj);
type = publication.getClass().getName();
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();
}
/**
diff --git a/ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationXmlHelper.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationXmlHelper.java
similarity index 100%
rename from ccm-sci-types-organizationwithpublications/src/com/arsdigita/cms/contenttypes/ui/PublicationXmlHelper.java
rename to ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationXmlHelper.java
diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationBasePanel.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationBasePanel.java
index 18d00421e..5c41927ad 100644
--- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationBasePanel.java
+++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationBasePanel.java
@@ -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());