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;
|
||||||
|
|
||||||
|
|
@ -69,8 +72,15 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
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,
|
||||||
|
|
@ -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()) {
|
||||||
|
|
@ -131,7 +150,8 @@ 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) {
|
||||||
|
|
@ -143,7 +163,13 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
@ -261,6 +287,46 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
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");
|
||||||
|
|
@ -622,11 +688,62 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue