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

View File

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

View File

@ -1,12 +1,18 @@
package com.arsdigita.cms.publicpersonalprofile; package com.arsdigita.cms.publicpersonalprofile;
import com.arsdigita.bebop.PageState; 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.GenericPerson;
import com.arsdigita.cms.contenttypes.GenericPersonContactCollection;
import com.arsdigita.cms.contenttypes.SciProject; import com.arsdigita.cms.contenttypes.SciProject;
import com.arsdigita.domain.DomainObject; import com.arsdigita.domain.DomainObject;
import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.OID;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
@ -19,12 +25,18 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* *
* @author Jens Pelzetter (jensp) * @author Jens Pelzetter (jensp)
* @version $Id$ * @version $Id$
*/ */
public class PersonalProjects implements ContentGenerator { 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 CURRENT_PROJECTS = "currentProjects";
private final static String FINISHED_PROJECTS = "finishedProjects"; private final static String FINISHED_PROJECTS = "finishedProjects";
private final static PersonalProjectsConfig config = private final static PersonalProjectsConfig config =
@ -41,10 +53,11 @@ public class PersonalProjects implements ContentGenerator {
final PageState state) { final PageState state) {
final List<SciProject> projects = collectProjects(person); final List<SciProject> projects = collectProjects(person);
final Element personalProjectsElem = parent.newChildElement(
"personalProjects");
if ((projects == null) || projects.size() == 0) { if ((projects == null) || projects.isEmpty()) {
final Element projectsElem = parent.newChildElement("projects"); personalProjectsElem.newChildElement("noProjects");
projectsElem.newChildElement("noProjects");
return; return;
} else { } else {
@ -53,8 +66,8 @@ public class PersonalProjects implements ContentGenerator {
new ArrayList<SciProject>(); new ArrayList<SciProject>();
processProjects(projects, currentProjects, finishedProjects); processProjects(projects, currentProjects, finishedProjects);
generateGroupsXml(parent, currentProjects, finishedProjects); generateGroupsXml(personalProjectsElem, currentProjects, finishedProjects);
generateProjectsXml(parent, generateProjectsXml(personalProjectsElem,
currentProjects, currentProjects,
finishedProjects, finishedProjects,
state); state);
@ -105,8 +118,8 @@ public class PersonalProjects implements ContentGenerator {
final List<SciProject> currentProjects, final List<SciProject> currentProjects,
final List<SciProject> finishedProjects) { final List<SciProject> finishedProjects) {
final Calendar today = new GregorianCalendar(); final Calendar today = new GregorianCalendar();
final Date todayDate = today.getTime(); final Date todayDate = today.getTime();
for(SciProject project : projects) { for (SciProject project : projects) {
if (project.getEnd().before(todayDate)) { if (project.getEnd().before(todayDate)) {
finishedProjects.add(project); finishedProjects.add(project);
} else { } else {
@ -208,10 +221,389 @@ public class PersonalProjects implements ContentGenerator {
private void generateProjectXml(final Element projectGroupElem, private void generateProjectXml(final Element projectGroupElem,
final SciProject project, final SciProject project,
final PageState state) { final PageState state) {
final PublicPersonalProfileXmlGenerator generator = /*final PublicPersonalProfileXmlGenerator generator =
new PublicPersonalProfileXmlGenerator( new PublicPersonalProfileXmlGenerator(
project); 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> { private class ProjectComparator implements Comparator<SciProject> {

View File

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

View File

@ -4,6 +4,7 @@ import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.contenttypes.AuthorshipCollection; import com.arsdigita.cms.contenttypes.AuthorshipCollection;
import com.arsdigita.cms.contenttypes.GenericPerson; import com.arsdigita.cms.contenttypes.GenericPerson;
import com.arsdigita.cms.contenttypes.Publication; import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.contenttypes.ui.PublicationXmlHelper;
import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.DataObject;
@ -43,11 +44,12 @@ public class PersonalPublications implements ContentGenerator {
final GenericPerson person, final GenericPerson person,
final PageState state) { final PageState state) {
final List<DataObject> publications = collectPublications(person); final List<DataObject> publications = collectPublications(person);
if ((publications == null) || publications.size() == 0) { final Element personalPubsElem = parent.newChildElement(
final Element publicationsElem = parent.newChildElement( "personalPublications");
"publications");
publicationsElem.newChildElement("noPublications"); if ((publications == null) || publications.isEmpty()) {
personalPubsElem.newChildElement("noPublications");
return; return;
} else { } else {
@ -55,37 +57,39 @@ public class PersonalPublications implements ContentGenerator {
processPublications( processPublications(
publications); publications);
generateGroupsXml(parent, groupedPublications); generateGroupsXml(personalPubsElem, groupedPublications);
generatePublicationsXml(parent, groupedPublications, state); generatePublicationsXml(personalPubsElem, groupedPublications, state);
} }
} }
private List<DataObject> collectPublications(final GenericPerson person) { private List<DataObject> collectPublications(final GenericPerson person) {
final List<DataObject> publications = new ArrayList<DataObject>(); final List<DataObject> publications = new ArrayList<DataObject>();
final DataCollection collection = (DataCollection) person.get("publication"); final DataCollection collection = (DataCollection) person.get(
"publication");
while(collection.next()) {
while (collection.next()) {
publications.add(collection.getDataObject()); publications.add(collection.getDataObject());
} }
if (person.getAlias() != null) { if (person.getAlias() != null) {
collectPublications(person, publications); collectPublications(person, publications);
} }
return publications; return publications;
} }
private void collectPublications(final GenericPerson alias, private void collectPublications(final GenericPerson alias,
final List<DataObject> publications) { final List<DataObject> publications) {
final DataCollection collection = (DataCollection) alias.get("publication"); final DataCollection collection = (DataCollection) alias.get(
"publication");
while(collection.next()) {
while (collection.next()) {
publications.add(collection.getDataObject()); publications.add(collection.getDataObject());
} }
if (alias.getAlias() != null) { if (alias.getAlias() != null) {
collectPublications(alias, publications); collectPublications(alias, publications);
} }
} }
/** /**
@ -108,18 +112,21 @@ public class PersonalPublications implements ContentGenerator {
initalizePubGroupMap(pubGroups, group); initalizePubGroupMap(pubGroups, group);
} }
initalizePubGroupMap(pubGroups, MISC); initalizePubGroupMap(pubGroups, MISC);
Publication publication; Publication publication;
String type; String type;
String groupName; String groupName;
Boolean reviewed; Boolean reviewed;
List<Publication> group; List<Publication> group;
for(DataObject dobj : publications) { for (DataObject dobj : publications) {
publication = (Publication) DomainObjectFactory.newInstance(dobj); publication = (Publication) DomainObjectFactory.newInstance(dobj);
type = publication.getClass().getName(); type = publication.getClass().getName();
if (dobj.getObjectType().hasProperty("reviewed")) { if (dobj.getObjectType().hasProperty("reviewed")) {
reviewed = (Boolean) dobj.get("reviewed"); reviewed = (Boolean) dobj.get("reviewed");
if (reviewed == null) {
reviewed = Boolean.FALSE;
}
if (reviewed) { if (reviewed) {
groupName = groupConfig.getTypeGroupMap().get(String.format( groupName = groupConfig.getTypeGroupMap().get(String.format(
"%s_ref", type)); "%s_ref", type));
@ -252,10 +259,13 @@ public class PersonalPublications implements ContentGenerator {
private void generatePublicationXml(final Element publicationGroupElem, private void generatePublicationXml(final Element publicationGroupElem,
final Publication publication, final Publication publication,
final PageState state) { final PageState state) {
final PublicPersonalProfileXmlGenerator generator = /*final PublicPersonalProfileXmlGenerator generator =
new PublicPersonalProfileXmlGenerator( new PublicPersonalProfileXmlGenerator(
publication); 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 Element parent,
final PageState state) { final PageState state) {
Element projectElem = parent.newChildElement("project"); Element projectElem = parent.newChildElement("project");
projectElem.addAttribute("oid", project.toString()); projectElem.addAttribute("oid", project.getOID().toString());
Element title = projectElem.newChildElement("title"); Element title = projectElem.newChildElement("title");
title.setText(project.getTitle()); title.setText(project.getTitle());