Verschiedene BugFixes
git-svn-id: https://svn.libreccm.org/ccm/trunk@1321 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
1ec33ceaaf
commit
7768473712
|
|
@ -9,6 +9,7 @@ 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.GenericPersonContactCollection;
|
||||||
import com.arsdigita.cms.contenttypes.SciProject;
|
import com.arsdigita.cms.contenttypes.SciProject;
|
||||||
|
import com.arsdigita.cms.util.LanguageUtil;
|
||||||
import com.arsdigita.domain.DomainObject;
|
import com.arsdigita.domain.DomainObject;
|
||||||
import com.arsdigita.domain.DomainObjectFactory;
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
import com.arsdigita.globalization.GlobalizationHelper;
|
import com.arsdigita.globalization.GlobalizationHelper;
|
||||||
|
|
@ -18,6 +19,7 @@ import com.arsdigita.persistence.Filter;
|
||||||
import com.arsdigita.persistence.FilterFactory;
|
import com.arsdigita.persistence.FilterFactory;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
|
import java.text.DateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
@ -25,6 +27,7 @@ import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
@ -44,17 +47,17 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
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 =
|
||||||
new PersonalProjectsConfig();
|
new PersonalProjectsConfig();
|
||||||
private final static Logger logger =
|
private final static Logger logger =
|
||||||
Logger.getLogger(PersonalProjects.class);
|
Logger.getLogger(PersonalProjects.class);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
config.load();
|
config.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateContent(final Element parent,
|
public void generateContent(final Element parent,
|
||||||
final GenericPerson person,
|
final GenericPerson person,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final List<SciProject> projects = collectProjects(person);
|
final List<SciProject> projects = collectProjects(person);
|
||||||
|
|
||||||
final Element personalProjectsElem = parent.newChildElement(
|
final Element personalProjectsElem = parent.newChildElement(
|
||||||
|
|
@ -67,14 +70,21 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
} else {
|
} else {
|
||||||
final List<SciProject> currentProjects = new ArrayList<SciProject>();
|
final List<SciProject> currentProjects = new ArrayList<SciProject>();
|
||||||
final List<SciProject> finishedProjects =
|
final List<SciProject> finishedProjects =
|
||||||
new ArrayList<SciProject>();
|
new ArrayList<SciProject>();
|
||||||
|
|
||||||
processProjects(projects, currentProjects, finishedProjects);
|
String sortBy = config.getSortBy();
|
||||||
generateGroupsXml(personalProjectsElem, currentProjects, finishedProjects);
|
String sortByParam = state.getRequest().getParameter("sortBy");
|
||||||
|
if ((sortByParam != null) && !(sortByParam.trim().isEmpty())) {
|
||||||
|
sortBy = sortByParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
processProjects(projects, currentProjects, finishedProjects, sortBy);
|
||||||
|
generateGroupsXml(personalProjectsElem, currentProjects,
|
||||||
|
finishedProjects);
|
||||||
generateProjectsXml(personalProjectsElem,
|
generateProjectsXml(personalProjectsElem,
|
||||||
currentProjects,
|
currentProjects,
|
||||||
finishedProjects,
|
finishedProjects,
|
||||||
state);
|
state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,13 +96,22 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
if (Kernel.getConfig().languageIndependentItems()) {
|
if (Kernel.getConfig().languageIndependentItems()) {
|
||||||
FilterFactory ff = collection.getFilterFactory();
|
FilterFactory ff = collection.getFilterFactory();
|
||||||
Filter filter = ff.or().
|
Filter filter = ff.or().
|
||||||
addFilter(ff.equals("language", com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale().getLanguage())).
|
addFilter(ff.equals("language",
|
||||||
|
com.arsdigita.globalization.GlobalizationHelper.
|
||||||
|
getNegotiatedLocale().getLanguage())).
|
||||||
addFilter(ff.and().
|
addFilter(ff.and().
|
||||||
addFilter(ff.equals("language", GlobalizationHelper.LANG_INDEPENDENT)).
|
addFilter(ff.equals("language",
|
||||||
addFilter(ff.notIn("parent", "com.arsdigita.london.navigation.getParentIDsOfMatchedItems").set("language", com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale().getLanguage())));
|
GlobalizationHelper.LANG_INDEPENDENT)).
|
||||||
|
addFilter(ff.notIn("parent",
|
||||||
|
"com.arsdigita.london.navigation.getParentIDsOfMatchedItems").
|
||||||
|
set("language",
|
||||||
|
com.arsdigita.globalization.GlobalizationHelper.
|
||||||
|
getNegotiatedLocale().getLanguage())));
|
||||||
collection.addFilter(filter);
|
collection.addFilter(filter);
|
||||||
} else {
|
} else {
|
||||||
collection.addEqualsFilter("language", com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale().getLanguage());
|
collection.addEqualsFilter("language",
|
||||||
|
com.arsdigita.globalization.GlobalizationHelper.
|
||||||
|
getNegotiatedLocale().getLanguage());
|
||||||
}
|
}
|
||||||
DomainObject obj;
|
DomainObject obj;
|
||||||
while (collection.next()) {
|
while (collection.next()) {
|
||||||
|
|
@ -112,7 +131,7 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collectProjects(final GenericPerson alias,
|
private void collectProjects(final GenericPerson alias,
|
||||||
final List<SciProject> projects) {
|
final List<SciProject> projects) {
|
||||||
final DataCollection collection = (DataCollection) alias.get(
|
final DataCollection collection = (DataCollection) alias.get(
|
||||||
"organizationalunit");
|
"organizationalunit");
|
||||||
DomainObject obj;
|
DomainObject obj;
|
||||||
|
|
@ -130,27 +149,34 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processProjects(final List<SciProject> projects,
|
private void processProjects(final List<SciProject> projects,
|
||||||
final List<SciProject> currentProjects,
|
final List<SciProject> currentProjects,
|
||||||
final List<SciProject> finishedProjects) {
|
final List<SciProject> finishedProjects,
|
||||||
|
final String sortBy) {
|
||||||
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() != null)
|
if ((project.getEnd() != null)
|
||||||
&& project.getEnd().before(todayDate)) {
|
&& project.getEnd().before(todayDate)) {
|
||||||
finishedProjects.add(project);
|
finishedProjects.add(project);
|
||||||
} else {
|
} else {
|
||||||
currentProjects.add(project);
|
currentProjects.add(project);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final ProjectComparator comparator = new ProjectComparator();
|
Comparator<SciProject> comparator;
|
||||||
|
if ("date".equals(sortBy)) {
|
||||||
|
comparator = new ProjectByDateComparator();
|
||||||
|
} else {
|
||||||
|
comparator = new ProjectByTitleComparator();
|
||||||
|
|
||||||
|
}
|
||||||
Collections.sort(currentProjects, comparator);
|
Collections.sort(currentProjects, comparator);
|
||||||
Collections.sort(finishedProjects, comparator);
|
Collections.sort(finishedProjects, comparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateGroupsXml(final Element parent,
|
private void generateGroupsXml(final Element parent,
|
||||||
final List<SciProject> currentProjects,
|
final List<SciProject> currentProjects,
|
||||||
final List<SciProject> finishedProjects) {
|
final List<SciProject> finishedProjects) {
|
||||||
final Element availableGroups = parent.newChildElement(
|
final Element availableGroups = parent.newChildElement(
|
||||||
"availableProjectGroups");
|
"availableProjectGroups");
|
||||||
|
|
||||||
|
|
@ -164,32 +190,32 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createAvailableProjectGroupXml(final Element parent,
|
private void createAvailableProjectGroupXml(final Element parent,
|
||||||
final String name) {
|
final String name) {
|
||||||
final Element group = parent.newChildElement("availableProjectGroup");
|
final Element group = parent.newChildElement("availableProjectGroup");
|
||||||
group.addAttribute("name", name);
|
group.addAttribute("name", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateProjectsXml(final Element parent,
|
private void generateProjectsXml(final Element parent,
|
||||||
final List<SciProject> currentProjects,
|
final List<SciProject> currentProjects,
|
||||||
final List<SciProject> finishedProjects,
|
final List<SciProject> finishedProjects,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final Element projectsElem = parent.newChildElement("projects");
|
final Element projectsElem = parent.newChildElement("projects");
|
||||||
|
|
||||||
final int numberOfProjects = currentProjects.size()
|
final int numberOfProjects = currentProjects.size()
|
||||||
+ finishedProjects.size();
|
+ finishedProjects.size();
|
||||||
final int groupSplit = config.getGroupSplit();
|
final int groupSplit = config.getGroupSplit();
|
||||||
|
|
||||||
if (numberOfProjects < groupSplit) {
|
if (numberOfProjects < groupSplit) {
|
||||||
projectsElem.addAttribute("all", "all");
|
projectsElem.addAttribute("all", "all");
|
||||||
|
|
||||||
generateProjectsGroupXml(projectsElem,
|
generateProjectsGroupXml(projectsElem,
|
||||||
CURRENT_PROJECTS,
|
CURRENT_PROJECTS,
|
||||||
currentProjects,
|
currentProjects,
|
||||||
state);
|
state);
|
||||||
generateProjectsGroupXml(projectsElem,
|
generateProjectsGroupXml(projectsElem,
|
||||||
FINISHED_PROJECTS,
|
FINISHED_PROJECTS,
|
||||||
finishedProjects,
|
finishedProjects,
|
||||||
state);
|
state);
|
||||||
} else {
|
} else {
|
||||||
final HttpServletRequest request = state.getRequest();
|
final HttpServletRequest request = state.getRequest();
|
||||||
|
|
||||||
|
|
@ -199,29 +225,29 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentProjects.isEmpty()
|
if (currentProjects.isEmpty()
|
||||||
&& CURRENT_PROJECTS.equals(groupToShow)) {
|
&& CURRENT_PROJECTS.equals(groupToShow)) {
|
||||||
groupToShow = FINISHED_PROJECTS;
|
groupToShow = FINISHED_PROJECTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CURRENT_PROJECTS.equals(groupToShow)) {
|
if (CURRENT_PROJECTS.equals(groupToShow)) {
|
||||||
generateProjectsGroupXml(projectsElem,
|
generateProjectsGroupXml(projectsElem,
|
||||||
CURRENT_PROJECTS,
|
CURRENT_PROJECTS,
|
||||||
currentProjects,
|
currentProjects,
|
||||||
state);
|
state);
|
||||||
} else if (FINISHED_PROJECTS.equals(groupToShow)) {
|
} else if (FINISHED_PROJECTS.equals(groupToShow)) {
|
||||||
generateProjectsGroupXml(projectsElem,
|
generateProjectsGroupXml(projectsElem,
|
||||||
FINISHED_PROJECTS,
|
FINISHED_PROJECTS,
|
||||||
finishedProjects,
|
finishedProjects,
|
||||||
state);
|
state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateProjectsGroupXml(final Element projectsElem,
|
private void generateProjectsGroupXml(final Element projectsElem,
|
||||||
final String groupName,
|
final String groupName,
|
||||||
final List<SciProject> projects,
|
final List<SciProject> projects,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
if (projects == null) {
|
if (projects == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -235,8 +261,8 @@ 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);
|
||||||
|
|
@ -250,17 +276,57 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
//Element beginElem = projectElem.newChildElement("projectbegin");
|
//Element beginElem = projectElem.newChildElement("projectbegin");
|
||||||
|
|
||||||
if ((project.getAddendum() != null)
|
if ((project.getAddendum() != null)
|
||||||
&& !(project.getAddendum().isEmpty())) {
|
&& !(project.getAddendum().isEmpty())) {
|
||||||
Element addendum = projectElem.newChildElement("addendum");
|
Element addendum = projectElem.newChildElement("addendum");
|
||||||
addendum.setText(project.getAddendum());
|
addendum.setText(project.getAddendum());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((project.getProjectShortDescription() != null)
|
if ((project.getProjectShortDescription() != null)
|
||||||
&& !(project.getProjectShortDescription().isEmpty())) {
|
&& !(project.getProjectShortDescription().isEmpty())) {
|
||||||
Element shortDesc = projectElem.newChildElement("shortDescription");
|
Element shortDesc = projectElem.newChildElement("shortDescription");
|
||||||
shortDesc.setText(project.getProjectShortDescription());
|
shortDesc.setText(project.getProjectShortDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((project.getBegin() != null)) {
|
||||||
|
final Element durationElem = projectElem.newChildElement("duration");
|
||||||
|
final Element beginElem = durationElem.newChildElement("begin");
|
||||||
|
addDateAttributes(beginElem, project.getBegin());
|
||||||
|
final Element beginSkipDayElem = durationElem.newChildElement(
|
||||||
|
"beginSkipDay");
|
||||||
|
if (project.getBeginSkipDay()) {
|
||||||
|
beginSkipDayElem.setText("true");
|
||||||
|
} else {
|
||||||
|
beginSkipDayElem.setText("false");
|
||||||
|
}
|
||||||
|
final Element beginSkipMonthElem = durationElem.newChildElement(
|
||||||
|
"beginSkipMonth");
|
||||||
|
if (project.getBeginSkipMonth()) {
|
||||||
|
beginSkipMonthElem.setText("true");
|
||||||
|
} else {
|
||||||
|
beginSkipMonthElem.setText("false");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (project.getEnd() != null) {
|
||||||
|
final Element endElement = durationElem.newChildElement("end");
|
||||||
|
addDateAttributes(endElement, project.getEnd());
|
||||||
|
final Element endSkipDayElem = durationElem.newChildElement(
|
||||||
|
"endSkipDay");
|
||||||
|
if (project.getEndSkipDay()) {
|
||||||
|
endSkipDayElem.setText("true");
|
||||||
|
} else {
|
||||||
|
endSkipDayElem.setText("false");
|
||||||
|
}
|
||||||
|
final Element endSkipMonthElem = durationElem.newChildElement(
|
||||||
|
"endSkipMonth");
|
||||||
|
if (project.getEndSkipMonth()) {
|
||||||
|
endSkipMonthElem.setText("true");
|
||||||
|
} else {
|
||||||
|
endSkipMonthElem.setText("false");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GenericOrganizationalUnitPersonCollection members;
|
GenericOrganizationalUnitPersonCollection members;
|
||||||
members = project.getPersons();
|
members = project.getPersons();
|
||||||
members.addOrder("surname asc, givenname asc");
|
members.addOrder("surname asc, givenname asc");
|
||||||
|
|
@ -270,18 +336,18 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
|
|
||||||
while (members.next()) {
|
while (members.next()) {
|
||||||
generateMemberXML(new MemberListItem(members.getOID(),
|
generateMemberXML(new MemberListItem(members.getOID(),
|
||||||
members.getSurname(),
|
members.getSurname(),
|
||||||
members.getGivenName(),
|
members.getGivenName(),
|
||||||
members.getTitlePre(),
|
members.getTitlePre(),
|
||||||
members.getTitlePost(),
|
members.getTitlePost(),
|
||||||
members.getBirthdate(),
|
members.getBirthdate(),
|
||||||
members.getGender(),
|
members.getGender(),
|
||||||
null, members.getRoleName(),
|
null, members.getRoleName(),
|
||||||
members.getStatus()),
|
members.getStatus()),
|
||||||
membersElem,
|
membersElem,
|
||||||
members.getRoleName(),
|
members.getRoleName(),
|
||||||
members.getStatus(),
|
members.getStatus(),
|
||||||
state);
|
state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -293,22 +359,22 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
|
|
||||||
while (contacts.next()) {
|
while (contacts.next()) {
|
||||||
generateContactXML(contacts.getContactType(),
|
generateContactXML(contacts.getContactType(),
|
||||||
contacts.getPerson(),
|
contacts.getPerson(),
|
||||||
contacts.getContactEntries(),
|
contacts.getContactEntries(),
|
||||||
contacts.getAddress(),
|
contacts.getAddress(),
|
||||||
contactsElem,
|
contactsElem,
|
||||||
state,
|
state,
|
||||||
Integer.toString(contacts.getContactOrder()),
|
Integer.toString(contacts.getContactOrder()),
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void generateMemberXML(final MemberListItem person,
|
protected void generateMemberXML(final MemberListItem person,
|
||||||
final Element parent,
|
final Element parent,
|
||||||
final String roleName,
|
final String roleName,
|
||||||
final String status,
|
final String status,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
Element memberElem = parent.newChildElement("member");
|
Element memberElem = parent.newChildElement("member");
|
||||||
|
|
||||||
memberElem.addAttribute("role", roleName);
|
memberElem.addAttribute("role", roleName);
|
||||||
|
|
@ -319,7 +385,7 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
//title.setText(person.getTitle());
|
//title.setText(person.getTitle());
|
||||||
|
|
||||||
if ((person.getTitlePre() != null)
|
if ((person.getTitlePre() != null)
|
||||||
&& !person.getTitlePre().isEmpty()) {
|
&& !person.getTitlePre().isEmpty()) {
|
||||||
Element titlePre = memberElem.newChildElement("titlePre");
|
Element titlePre = memberElem.newChildElement("titlePre");
|
||||||
titlePre.setText(person.getTitlePre());
|
titlePre.setText(person.getTitlePre());
|
||||||
}
|
}
|
||||||
|
|
@ -331,13 +397,13 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
givenName.setText(person.getGivenName());
|
givenName.setText(person.getGivenName());
|
||||||
|
|
||||||
if ((person.getTitlePost() != null)
|
if ((person.getTitlePost() != null)
|
||||||
&& !person.getTitlePost().isEmpty()) {
|
&& !person.getTitlePost().isEmpty()) {
|
||||||
Element titlePost = memberElem.newChildElement("titlePost");
|
Element titlePost = memberElem.newChildElement("titlePost");
|
||||||
titlePost.setText(person.getTitlePost());
|
titlePost.setText(person.getTitlePost());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((person.getContacts() != null)
|
if ((person.getContacts() != null)
|
||||||
&& (person.getContacts().size() > 0)) {
|
&& (person.getContacts().size() > 0)) {
|
||||||
GenericPersonContactCollection contacts;
|
GenericPersonContactCollection contacts;
|
||||||
contacts = new GenericPersonContactCollection(person.getContacts());
|
contacts = new GenericPersonContactCollection(person.getContacts());
|
||||||
|
|
||||||
|
|
@ -393,7 +459,7 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
surname.setText(person.getSurname());
|
surname.setText(person.getSurname());
|
||||||
|
|
||||||
if ((person.getTitlePost() != null)
|
if ((person.getTitlePost() != null)
|
||||||
&& !person.getTitlePost().isEmpty()) {
|
&& !person.getTitlePost().isEmpty()) {
|
||||||
Element titlePost = contactElem.newChildElement(
|
Element titlePost = contactElem.newChildElement(
|
||||||
"titlePost");
|
"titlePost");
|
||||||
titlePost.setText(person.getTitlePost());
|
titlePost.setText(person.getTitlePost());
|
||||||
|
|
@ -402,23 +468,23 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((contactEntries != null)
|
if ((contactEntries != null)
|
||||||
&& (contactEntries.size() > 0)) {
|
&& (contactEntries.size() > 0)) {
|
||||||
Element contactEntriesElem =
|
Element contactEntriesElem =
|
||||||
contactElem.newChildElement("contactEntries");
|
contactElem.newChildElement("contactEntries");
|
||||||
while (contactEntries.next()) {
|
while (contactEntries.next()) {
|
||||||
GenericContactEntry contactEntry =
|
GenericContactEntry contactEntry =
|
||||||
contactEntries.getContactEntry();
|
contactEntries.getContactEntry();
|
||||||
Element contactEntryElem =
|
Element contactEntryElem =
|
||||||
contactEntriesElem.newChildElement(
|
contactEntriesElem.newChildElement(
|
||||||
"contactEntry");
|
"contactEntry");
|
||||||
contactEntryElem.addAttribute("key",
|
contactEntryElem.addAttribute("key",
|
||||||
contactEntry.getKey());
|
contactEntry.getKey());
|
||||||
Element valueElem = contactEntryElem.newChildElement(
|
Element valueElem = contactEntryElem.newChildElement(
|
||||||
"value");
|
"value");
|
||||||
valueElem.setText(contactEntry.getValue());
|
valueElem.setText(contactEntry.getValue());
|
||||||
|
|
||||||
if ((contactEntry.getDescription() != null)
|
if ((contactEntry.getDescription() != null)
|
||||||
&& !contactEntry.getDescription().isEmpty()) {
|
&& !contactEntry.getDescription().isEmpty()) {
|
||||||
Element descElem = contactEntryElem.newChildElement(
|
Element descElem = contactEntryElem.newChildElement(
|
||||||
"description");
|
"description");
|
||||||
descElem.setText(contactEntry.getDescription());
|
descElem.setText(contactEntry.getDescription());
|
||||||
|
|
@ -458,34 +524,34 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
public MemberListItem(final GenericPerson member,
|
public MemberListItem(final GenericPerson member,
|
||||||
final String role,
|
final String role,
|
||||||
final String status) {
|
final String status) {
|
||||||
/*this.member = member;
|
/*this.member = member;
|
||||||
this.role = role;
|
this.role = role;
|
||||||
this.status = status;*/
|
this.status = status;*/
|
||||||
this(member.getOID(),
|
this(member.getOID(),
|
||||||
member.getSurname(),
|
member.getSurname(),
|
||||||
member.getGivenName(),
|
member.getGivenName(),
|
||||||
member.getTitlePre(),
|
member.getTitlePre(),
|
||||||
member.getTitlePost(),
|
member.getTitlePost(),
|
||||||
member.getBirthdate(),
|
member.getBirthdate(),
|
||||||
member.getGender(),
|
member.getGender(),
|
||||||
null,
|
null,
|
||||||
role,
|
role,
|
||||||
status);
|
status);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MemberListItem(final OID oid,
|
public MemberListItem(final OID oid,
|
||||||
final String surname,
|
final String surname,
|
||||||
final String givenName,
|
final String givenName,
|
||||||
final String titlePre,
|
final String titlePre,
|
||||||
final String titlePost,
|
final String titlePost,
|
||||||
final Date birthdate,
|
final Date birthdate,
|
||||||
final String gender,
|
final String gender,
|
||||||
final DataCollection contacts,
|
final DataCollection contacts,
|
||||||
final String role,
|
final String role,
|
||||||
final String status) {
|
final String status) {
|
||||||
this.oid = oid;
|
this.oid = oid;
|
||||||
this.surname = surname;
|
this.surname = surname;
|
||||||
this.givenName = givenName;
|
this.givenName = givenName;
|
||||||
|
|
@ -561,36 +627,36 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
}
|
}
|
||||||
final MemberListItem other = (MemberListItem) obj;
|
final MemberListItem other = (MemberListItem) obj;
|
||||||
if ((this.surname == null) ? (other.surname != null)
|
if ((this.surname == null) ? (other.surname != null)
|
||||||
: !this.surname.equals(other.surname)) {
|
: !this.surname.equals(other.surname)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((this.givenName == null) ? (other.givenName != null)
|
if ((this.givenName == null) ? (other.givenName != null)
|
||||||
: !this.givenName.equals(other.givenName)) {
|
: !this.givenName.equals(other.givenName)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((this.titlePre == null) ? (other.titlePre != null)
|
if ((this.titlePre == null) ? (other.titlePre != null)
|
||||||
: !this.titlePre.equals(other.titlePre)) {
|
: !this.titlePre.equals(other.titlePre)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((this.titlePost == null) ? (other.titlePost != null)
|
if ((this.titlePost == null) ? (other.titlePost != null)
|
||||||
: !this.titlePost.equals(other.titlePost)) {
|
: !this.titlePost.equals(other.titlePost)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.birthdate != other.birthdate && (this.birthdate == null
|
if (this.birthdate != other.birthdate && (this.birthdate == null
|
||||||
|| !this.birthdate.equals(
|
|| !this.birthdate.equals(
|
||||||
other.birthdate))) {
|
other.birthdate))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((this.gender == null) ? (other.gender != null)
|
if ((this.gender == null) ? (other.gender != null)
|
||||||
: !this.gender.equals(other.gender)) {
|
: !this.gender.equals(other.gender)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((this.role == null) ? (other.role != null)
|
if ((this.role == null) ? (other.role != null)
|
||||||
: !this.role.equals(other.role)) {
|
: !this.role.equals(other.role)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((this.status == null) ? (other.status != null)
|
if ((this.status == null) ? (other.status != null)
|
||||||
: !this.status.equals(other.status)) {
|
: !this.status.equals(other.status)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -604,29 +670,80 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int hash = 3;
|
int hash = 3;
|
||||||
hash =
|
hash =
|
||||||
41 * hash + (this.surname != null ? this.surname.hashCode() : 0);
|
41 * hash + (this.surname != null ? this.surname.hashCode() : 0);
|
||||||
hash =
|
hash =
|
||||||
41 * hash + (this.givenName != null ? this.givenName.hashCode() : 0);
|
41 * hash + (this.givenName != null ? this.givenName.hashCode() : 0);
|
||||||
hash =
|
hash =
|
||||||
41 * hash + (this.titlePre != null ? this.titlePre.hashCode() : 0);
|
41 * hash + (this.titlePre != null ? this.titlePre.hashCode() : 0);
|
||||||
hash =
|
hash =
|
||||||
41 * hash + (this.titlePost != null ? this.titlePost.hashCode() : 0);
|
41 * hash + (this.titlePost != null ? this.titlePost.hashCode() : 0);
|
||||||
hash =
|
hash =
|
||||||
41 * hash + (this.birthdate != null ? this.birthdate.hashCode() : 0);
|
41 * hash + (this.birthdate != null ? this.birthdate.hashCode() : 0);
|
||||||
hash =
|
hash =
|
||||||
41 * hash + (this.gender != null ? this.gender.hashCode() : 0);
|
41 * hash + (this.gender != null ? this.gender.hashCode() : 0);
|
||||||
hash = 41 * hash + (this.role != null ? this.role.hashCode() : 0);
|
hash = 41 * hash + (this.role != null ? this.role.hashCode() : 0);
|
||||||
hash =
|
hash =
|
||||||
41 * hash + (this.status != null ? this.status.hashCode() : 0);
|
41 * hash + (this.status != null ? this.status.hashCode() : 0);
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ProjectComparator implements Comparator<SciProject> {
|
private class ProjectByTitleComparator implements Comparator<SciProject> {
|
||||||
|
|
||||||
public int compare(final SciProject project1,
|
public int compare(final SciProject project1,
|
||||||
final SciProject project2) {
|
final SciProject project2) {
|
||||||
return project1.getTitle().compareTo(project2.getTitle());
|
return project1.getTitle().compareTo(project2.getTitle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class ProjectByDateComparator implements Comparator<SciProject> {
|
||||||
|
|
||||||
|
public int compare(final SciProject project1,
|
||||||
|
final SciProject project2) {
|
||||||
|
int ret = project2.getBegin().compareTo(project1.getBegin());
|
||||||
|
if (ret == 0) {
|
||||||
|
ret = project2.getEnd().compareTo(project1.getBegin());
|
||||||
|
}
|
||||||
|
if (ret == 0) {
|
||||||
|
ret = project1.getTitle().compareTo(project2.getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addDateAttributes(final Element elem, final Date date) {
|
||||||
|
final Calendar cal = Calendar.getInstance();
|
||||||
|
cal.setTime(date);
|
||||||
|
|
||||||
|
elem.addAttribute("year",
|
||||||
|
Integer.toString(cal.get(
|
||||||
|
Calendar.YEAR)));
|
||||||
|
elem.addAttribute("month",
|
||||||
|
Integer.toString(cal.get(
|
||||||
|
Calendar.MONTH) + 1));
|
||||||
|
elem.addAttribute("day",
|
||||||
|
Integer.toString(cal.get(
|
||||||
|
Calendar.DAY_OF_MONTH)));
|
||||||
|
elem.addAttribute("hour",
|
||||||
|
Integer.toString(cal.get(
|
||||||
|
Calendar.HOUR_OF_DAY)));
|
||||||
|
elem.addAttribute("minute",
|
||||||
|
Integer.toString(cal.get(
|
||||||
|
Calendar.MINUTE)));
|
||||||
|
elem.addAttribute("second",
|
||||||
|
Integer.toString(cal.get(
|
||||||
|
Calendar.SECOND)));
|
||||||
|
|
||||||
|
final Locale negLocale = GlobalizationHelper.getNegotiatedLocale();
|
||||||
|
final DateFormat dateFormat = DateFormat.getDateInstance(
|
||||||
|
DateFormat.MEDIUM, negLocale);
|
||||||
|
final DateFormat longDateFormat = DateFormat.getDateInstance(
|
||||||
|
DateFormat.LONG, negLocale);
|
||||||
|
final DateFormat timeFormat = DateFormat.getDateInstance(
|
||||||
|
DateFormat.SHORT, negLocale);
|
||||||
|
elem.addAttribute("date", dateFormat.format(date));
|
||||||
|
elem.addAttribute("longDate", longDateFormat.format(date));
|
||||||
|
elem.addAttribute("time", timeFormat.format(date));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
|
|
||||||
package com.arsdigita.cms.publicpersonalprofile;
|
package com.arsdigita.cms.publicpersonalprofile;
|
||||||
|
|
||||||
import com.arsdigita.runtime.AbstractConfig;
|
import com.arsdigita.runtime.AbstractConfig;
|
||||||
import com.arsdigita.util.parameter.IntegerParameter;
|
import com.arsdigita.util.parameter.IntegerParameter;
|
||||||
import com.arsdigita.util.parameter.Parameter;
|
import com.arsdigita.util.parameter.Parameter;
|
||||||
|
import com.arsdigita.util.parameter.StringParameter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -13,6 +13,7 @@ import com.arsdigita.util.parameter.Parameter;
|
||||||
public class PersonalProjectsConfig extends AbstractConfig {
|
public class PersonalProjectsConfig extends AbstractConfig {
|
||||||
|
|
||||||
private final Parameter groupSplit;
|
private final Parameter groupSplit;
|
||||||
|
private final Parameter sortBy;
|
||||||
|
|
||||||
public PersonalProjectsConfig() {
|
public PersonalProjectsConfig() {
|
||||||
groupSplit = new IntegerParameter(
|
groupSplit = new IntegerParameter(
|
||||||
|
|
@ -20,7 +21,13 @@ public class PersonalProjectsConfig extends AbstractConfig {
|
||||||
Parameter.REQUIRED,
|
Parameter.REQUIRED,
|
||||||
16);
|
16);
|
||||||
|
|
||||||
|
sortBy = new StringParameter(
|
||||||
|
"com.arsdigita.cms.publicpersonalprofile.projects.sortBy",
|
||||||
|
Parameter.REQUIRED,
|
||||||
|
"date");
|
||||||
|
|
||||||
register(groupSplit);
|
register(groupSplit);
|
||||||
|
register(sortBy);
|
||||||
|
|
||||||
loadInfo();
|
loadInfo();
|
||||||
}
|
}
|
||||||
|
|
@ -29,4 +36,7 @@ public class PersonalProjectsConfig extends AbstractConfig {
|
||||||
return (Integer) get(groupSplit);
|
return (Integer) get(groupSplit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final String getSortBy() {
|
||||||
|
return (String) get(sortBy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,3 +3,7 @@ com.arsdigita.cms.publicpersonalprofile.projects.groupSplit.purpose = If a perso
|
||||||
com.arsdigita.cms.publicpersonalprofile.projects.groupSplit.example = 16
|
com.arsdigita.cms.publicpersonalprofile.projects.groupSplit.example = 16
|
||||||
com.arsdigita.cms.publicpersonalprofile.projects.groupSplit.format = [Integer]
|
com.arsdigita.cms.publicpersonalprofile.projects.groupSplit.format = [Integer]
|
||||||
|
|
||||||
|
com.arsdigita.cms.publicpersonalprofile.projects.sortBy.title = Sort projects by
|
||||||
|
com.arsdigita.cms.publicpersonalprofile.projects.sortBy.purpose = Sort projects by
|
||||||
|
com.arsdigita.cms.publicpersonalprofile.projects.sortBy.example = title
|
||||||
|
com.arsdigita.cms.publicpersonalprofile.projects.sortBy.format = [String]
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ public class SciDepartmentMembersTabConfig extends AbstractConfig {
|
||||||
pageSize =
|
pageSize =
|
||||||
new IntegerParameter(
|
new IntegerParameter(
|
||||||
"com.arsdigita.cms.contenttypes.scidepartment.tabs.members.page_size",
|
"com.arsdigita.cms.contenttypes.scidepartment.tabs.members.page_size",
|
||||||
Parameter.REQUIRED,
|
Parameter.REQUIRED,
|
||||||
30);
|
30);
|
||||||
|
|
||||||
enableSearchLimit =
|
enableSearchLimit =
|
||||||
new IntegerParameter(
|
new IntegerParameter(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue