diff --git a/ccm-sci-types-department/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentProjectsTab.java b/ccm-sci-types-department/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentProjectsTab.java index 32d83ce3d..c2b981430 100644 --- a/ccm-sci-types-department/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentProjectsTab.java +++ b/ccm-sci-types-department/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentProjectsTab.java @@ -112,23 +112,26 @@ public class SciDepartmentProjectsTab implements GenericOrgaUnitTab { projects.addOrder("title asc"); if (((Globalization.decodeParameter(request, STATUS_PARAM) == null) - || Globalization.decodeParameter(request, STATUS_PARAM).trim().isEmpty() - || CompareFilter.NONE.equals(Globalization.decodeParameter(request, STATUS_PARAM))) + || Globalization.decodeParameter(request, STATUS_PARAM).trim(). + isEmpty() + || CompareFilter.NONE.equals( + Globalization.decodeParameter(request, STATUS_PARAM))) && ((Globalization.decodeParameter(request, TITLE_PARAM) == null) - || Globalization.decodeParameter(request, TITLE_PARAM).trim().isEmpty())) { + || Globalization.decodeParameter(request, TITLE_PARAM).trim(). + isEmpty())) { statusFilter.generateXml(filtersElem); depProjectsElem.newChildElement("greeting"); + + final Calendar now = new GregorianCalendar(); + final String today = String.format("%d-%02d-%02d", + now.get(Calendar.YEAR), + now.get(Calendar.MONTH) + 1, + now.get(Calendar.DAY_OF_MONTH)); - //projects.addOrder("projectEnd desc"); - //projects.addOrder("projectBegin desc"); - //projects.addOrder("projectEnd desc nulls last"); - //projects.addOrder("projectBegin desc nulls last"); - //projects.addOrderWithNull("projectEnd", new Date(0), false); - //projects.addOrderWithNull("projectBegin", new Date(0), false); - //projects.addOrder("title"); - + projects.addFilter(String.format( + "(projectEnd >= '%s') or (projectEnd is null)", today)); projects.setRange(1, config.getGreetingSize() + 1); titleFilter.generateXml(filtersElem); @@ -153,8 +156,10 @@ public class SciDepartmentProjectsTab implements GenericOrgaUnitTab { config.getPageSize()); if ((paginator.getPageCount() > config.getEnableSearchLimit()) - || ((Globalization.decodeParameter(request, TITLE_PARAM) != null) - || !(Globalization.decodeParameter(request, TITLE_PARAM).trim().isEmpty()))) { + || ((Globalization.decodeParameter(request, TITLE_PARAM) + != null) + || !(Globalization.decodeParameter(request, TITLE_PARAM). + trim().isEmpty()))) { titleFilter.generateXml(filtersElem); } @@ -230,7 +235,8 @@ public class SciDepartmentProjectsTab implements GenericOrgaUnitTab { private void applyStatusFilter(final DataQuery projects, final HttpServletRequest request) { - final String statusValue = Globalization.decodeParameter(request, STATUS_PARAM); + final String statusValue = Globalization.decodeParameter(request, + STATUS_PARAM); if ((statusValue != null) && !(statusValue.trim().isEmpty())) { statusFilter.setValue(statusValue); } @@ -243,7 +249,8 @@ public class SciDepartmentProjectsTab implements GenericOrgaUnitTab { private void applyTitleFilter(final DataQuery projects, final HttpServletRequest request) { - final String titleValue = Globalization.decodeParameter(request, TITLE_PARAM); + final String titleValue = Globalization.decodeParameter(request, + TITLE_PARAM); if ((titleValue != null) && !(titleValue.trim().isEmpty())) { titleFilter.setValue(titleValue); } diff --git a/ccm-sci-types-department/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSummaryTab.java b/ccm-sci-types-department/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSummaryTab.java index 0f9ea6488..df89db5aa 100644 --- a/ccm-sci-types-department/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSummaryTab.java +++ b/ccm-sci-types-department/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSummaryTab.java @@ -2,7 +2,9 @@ package com.arsdigita.cms.contenttypes.ui; import com.arsdigita.bebop.PageState; import com.arsdigita.cms.ContentItem; +import com.arsdigita.cms.contenttypes.GenericContact; import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit; +import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitContactCollection; import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitPersonCollection; import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitSubordinateCollection; import com.arsdigita.cms.contenttypes.GenericPerson; @@ -58,6 +60,10 @@ public class SciDepartmentSummaryTab implements GenericOrgaUnitTab { if (config.isShowingSubDepartment()) { generateSubDepartmentsXml(department, departmentSummaryElem, state); } + + if (config.isShowingContacts()) { + generateContactsXml(department, departmentSummaryElem, state); + } logger.debug(String.format("Generated XML for summary tab of department " + "'%s' in %d ms.", @@ -213,6 +219,41 @@ public class SciDepartmentSummaryTab implements GenericOrgaUnitTab { System.currentTimeMillis() - start)); } + protected void generateContactsXml(final SciDepartment department, + final Element parent, + final PageState state) { + final long start = System.currentTimeMillis(); + final GenericOrganizationalUnitContactCollection contacts = department. + getContacts(); + + if ((contacts == null) || contacts.isEmpty()) { + return; + } + + final Element contactsElem = parent.newChildElement("contacts"); + + while (contacts.next()) { + generateContactXml(contacts.getContact(), contactsElem, state); + } + logger.debug(String.format("Generated XML for contacts of project '%s'" + + " in %d ms.", + department.getName(), + System.currentTimeMillis() - start)); + } + + protected void generateContactXml(final GenericContact contact, + final Element parent, + final PageState state) { + final long start = System.currentTimeMillis(); + final XmlGenerator generator = new XmlGenerator(contact); + generator.setUseExtraXml(false); + generator.setItemElemName("contact", ""); + generator.generateXML(state, parent, ""); + logger.debug(String.format("Generated XML for contact '%s' in %d ms.", + contact.getName(), + System.currentTimeMillis() - start)); + } + private class XmlGenerator extends SimpleXMLGenerator { private final ContentItem item; diff --git a/ccm-sci-types-department/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSummaryTabConfig.java b/ccm-sci-types-department/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSummaryTabConfig.java index f1f4d1f2c..c188e99f7 100644 --- a/ccm-sci-types-department/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSummaryTabConfig.java +++ b/ccm-sci-types-department/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSummaryTabConfig.java @@ -16,6 +16,7 @@ public class SciDepartmentSummaryTabConfig extends AbstractConfig { private final Parameter headRole; private final Parameter activeStatus; private final Parameter showSubDepartments; + private final Parameter showContacts; public SciDepartmentSummaryTabConfig() { @@ -41,10 +42,16 @@ public class SciDepartmentSummaryTabConfig extends AbstractConfig { Parameter.REQUIRED, true); + showContacts = new BooleanParameter( + "com.arsdigita.cms.contenttypes.scidepartment.summarytab.contacts.show", + Parameter.REQUIRED, + true); + register(showHeads); register(headRole); register(activeStatus); register(showSubDepartments); + register(showContacts); loadInfo(); } @@ -64,4 +71,8 @@ public class SciDepartmentSummaryTabConfig extends AbstractConfig { public final boolean isShowingSubDepartment() { return (Boolean) get(showSubDepartments); } + + public final boolean isShowingContacts() { + return (Boolean) get(showContacts); + } } diff --git a/ccm-sci-types-department/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSummaryTabConfig_parameter.properties b/ccm-sci-types-department/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSummaryTabConfig_parameter.properties index 1e7784243..f5d37a724 100644 --- a/ccm-sci-types-department/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSummaryTabConfig_parameter.properties +++ b/ccm-sci-types-department/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSummaryTabConfig_parameter.properties @@ -3,12 +3,17 @@ com.arsdigita.cms.contenttypes.scidepartment.summarytab.heads.show.purpose = Sho com.arsdigita.cms.contenttypes.scidepartment.summarytab.heads.show.example = true com.arsdigita.cms.contenttypes.scidepartment.summarytab.heads.show.format = [Boolean] -com.arsdigita.cms.contenttypes.scidepartment.summarytab.heads.role = Role of the heads of the department -com.arsdigita.cms.contenttypes.scidepartment.summarytab.heads.role = Role of the heads of the department. This is an attribute of the association between GenericOrganizationalUnit and GenericPerson. This value may contains more than value, separated by ','. -com.arsdigita.cms.contenttypes.scidepartment.summarytab.heads.role = active,heading -com.arsdigita.cms.contenttypes.scidepartment.summarytab.heads.role = [String] +com.arsdigita.cms.contenttypes.scidepartment.summarytab.heads.role.title = Role of the heads of the department +com.arsdigita.cms.contenttypes.scidepartment.summarytab.heads.role.purpose = Role of the heads of the department. This is an attribute of the association between GenericOrganizationalUnit and GenericPerson. This value may contains more than value, separated by ','. +com.arsdigita.cms.contenttypes.scidepartment.summarytab.heads.role.example = active,heading +com.arsdigita.cms.contenttypes.scidepartment.summarytab.heads.role.format = [String] -com.arsdigita.cms.contenttypes.scidepartment.summarytab.heads.status.active = Status of active members -com.arsdigita.cms.contenttypes.scidepartment.summarytab.heads.status.active = Status of the active members of the department. Used to filter out former heads. This is an attribute of the association between GenericOrganizationalUnit and GenericPerson. This value may contains more than value, separated by ','. -com.arsdigita.cms.contenttypes.scidepartment.summarytab.heads.status.active = former,formerHead -com.arsdigita.cms.contenttypes.scidepartment.summarytab.heads.status.active = [String] \ No newline at end of file +com.arsdigita.cms.contenttypes.scidepartment.summarytab.heads.status.active.title = Status of active members +com.arsdigita.cms.contenttypes.scidepartment.summarytab.heads.status.active.purpose = Status of the active members of the department. Used to filter out former heads. This is an attribute of the association between GenericOrganizationalUnit and GenericPerson. This value may contains more than value, separated by ','. +com.arsdigita.cms.contenttypes.scidepartment.summarytab.heads.status.active.example = former,formerHead +com.arsdigita.cms.contenttypes.scidepartment.summarytab.heads.status.active.format = [String] + +com.arsdigita.cms.contenttypes.scidepartment.summarytab.contacts.show.title = Show contact? +com.arsdigita.cms.contenttypes.scidepartment.summarytab.contacts.show.purpose = Show contact? +com.arsdigita.cms.contenttypes.scidepartment.summarytab.contacts.show.example = true +com.arsdigita.cms.contenttypes.scidepartment.summarytab.contacts.show.format = [Boolean] \ No newline at end of file diff --git a/ccm-sci-types-institute/src/com/arsdigita/cms/contenttypes/ui/SciInstituteProjectsTab.java b/ccm-sci-types-institute/src/com/arsdigita/cms/contenttypes/ui/SciInstituteProjectsTab.java index 41971ccdb..819b36f1e 100644 --- a/ccm-sci-types-institute/src/com/arsdigita/cms/contenttypes/ui/SciInstituteProjectsTab.java +++ b/ccm-sci-types-institute/src/com/arsdigita/cms/contenttypes/ui/SciInstituteProjectsTab.java @@ -114,20 +114,26 @@ public class SciInstituteProjectsTab implements GenericOrgaUnitTab { projects.addOrder("title asc"); if (((Globalization.decodeParameter(request, STATUS_PARAM) == null) - || Globalization.decodeParameter(request, STATUS_PARAM).trim().isEmpty() - || CompareFilter.NONE.equals(Globalization.decodeParameter(request, STATUS_PARAM))) + || Globalization.decodeParameter(request, STATUS_PARAM).trim(). + isEmpty() + || CompareFilter.NONE.equals( + Globalization.decodeParameter(request, STATUS_PARAM))) && ((Globalization.decodeParameter(request, TITLE_PARAM) == null) - || Globalization.decodeParameter(request, TITLE_PARAM).trim().isEmpty())) { + || Globalization.decodeParameter(request, TITLE_PARAM).trim(). + isEmpty())) { statusFilter.generateXml(filtersElem); depProjectsElem.newChildElement("greeting"); - //projects.addOrder("projectEnd desc nulls last"); - //projects.addOrder("projectBegin desc nulls last"); - //projects.addOrderWithNull("projectEnd", null, false); - //projects.addOrderWithNull("projectBegin", null, false); - //projects.addOrder("title"); + final Calendar now = new GregorianCalendar(); + final String today = String.format("%d-%02d-%02d", + now.get(Calendar.YEAR), + now.get(Calendar.MONTH) + 1, + now.get(Calendar.DAY_OF_MONTH)); + + projects.addFilter(String.format( + "(projectEnd >= '%s') or (projectEnd is null)", today)); projects.setRange(1, config.getGreetingSize() + 1); @@ -153,8 +159,10 @@ public class SciInstituteProjectsTab implements GenericOrgaUnitTab { config.getPageSize()); if ((paginator.getPageCount() > config.getEnableSearchLimit()) - || ((Globalization.decodeParameter(request, TITLE_PARAM) != null) - || !(Globalization.decodeParameter(request, TITLE_PARAM).trim().isEmpty()))) { + || ((Globalization.decodeParameter(request, TITLE_PARAM) + != null) + || !(Globalization.decodeParameter(request, TITLE_PARAM). + trim().isEmpty()))) { titleFilter.generateXml(filtersElem); } @@ -230,7 +238,8 @@ public class SciInstituteProjectsTab implements GenericOrgaUnitTab { private void applyStatusFilter(final DataQuery projects, final HttpServletRequest request) { - final String statusValue = Globalization.decodeParameter(request, STATUS_PARAM); + final String statusValue = Globalization.decodeParameter(request, + STATUS_PARAM); if ((statusValue != null) && !(statusValue.trim().isEmpty())) { statusFilter.setValue(statusValue); } @@ -243,7 +252,8 @@ public class SciInstituteProjectsTab implements GenericOrgaUnitTab { private void applyTitleFilter(final DataQuery projects, final HttpServletRequest request) { - final String titleValue = Globalization.decodeParameter(request, TITLE_PARAM); + final String titleValue = Globalization.decodeParameter(request, + TITLE_PARAM); if ((titleValue != null) && !(titleValue.trim().isEmpty())) { titleFilter.setValue(titleValue); } diff --git a/ccm-sci-types-institute/src/com/arsdigita/cms/contenttypes/ui/SciInstituteSummaryTab.java b/ccm-sci-types-institute/src/com/arsdigita/cms/contenttypes/ui/SciInstituteSummaryTab.java index 0fe71ea91..a609c9882 100644 --- a/ccm-sci-types-institute/src/com/arsdigita/cms/contenttypes/ui/SciInstituteSummaryTab.java +++ b/ccm-sci-types-institute/src/com/arsdigita/cms/contenttypes/ui/SciInstituteSummaryTab.java @@ -2,7 +2,9 @@ package com.arsdigita.cms.contenttypes.ui; import com.arsdigita.bebop.PageState; import com.arsdigita.cms.ContentItem; +import com.arsdigita.cms.contenttypes.GenericContact; import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit; +import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitContactCollection; import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitPersonCollection; import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitSubordinateCollection; import com.arsdigita.cms.contenttypes.GenericPerson; @@ -59,6 +61,10 @@ public class SciInstituteSummaryTab implements GenericOrgaUnitTab { generateDepartmentsXml(institute, instituteSummaryElem, state); } + if (config.isShowingContacts()) { + generateContactsXml(institute, instituteSummaryElem, state); + } + logger.debug(String.format("Generated XML for summary tab of institute " + "'%s' in %d ms.", orgaunit.getName(), @@ -265,6 +271,41 @@ public class SciInstituteSummaryTab implements GenericOrgaUnitTab { member.getFullName(), System.currentTimeMillis() - start)); } + + protected void generateContactsXml(final SciInstitute department, + final Element parent, + final PageState state) { + final long start = System.currentTimeMillis(); + final GenericOrganizationalUnitContactCollection contacts = department. + getContacts(); + + if ((contacts == null) || contacts.isEmpty()) { + return; + } + + final Element contactsElem = parent.newChildElement("contacts"); + + while (contacts.next()) { + generateContactXml(contacts.getContact(), contactsElem, state); + } + logger.debug(String.format("Generated XML for contacts of project '%s'" + + " in %d ms.", + department.getName(), + System.currentTimeMillis() - start)); + } + + protected void generateContactXml(final GenericContact contact, + final Element parent, + final PageState state) { + final long start = System.currentTimeMillis(); + final XmlGenerator generator = new XmlGenerator(contact); + generator.setUseExtraXml(false); + generator.setItemElemName("contact", ""); + generator.generateXML(state, parent, ""); + logger.debug(String.format("Generated XML for contact '%s' in %d ms.", + contact.getName(), + System.currentTimeMillis() - start)); + } private class XmlGenerator extends SimpleXMLGenerator { diff --git a/ccm-sci-types-institute/src/com/arsdigita/cms/contenttypes/ui/SciInstituteSummaryTabConfig.java b/ccm-sci-types-institute/src/com/arsdigita/cms/contenttypes/ui/SciInstituteSummaryTabConfig.java index fc3280960..0018bfc6e 100644 --- a/ccm-sci-types-institute/src/com/arsdigita/cms/contenttypes/ui/SciInstituteSummaryTabConfig.java +++ b/ccm-sci-types-institute/src/com/arsdigita/cms/contenttypes/ui/SciInstituteSummaryTabConfig.java @@ -11,58 +11,70 @@ import com.arsdigita.util.parameter.StringParameter; * @version $Id$ */ public class SciInstituteSummaryTabConfig extends AbstractConfig { - + private final Parameter showHeads; private final Parameter headRole; private final Parameter activeStatus; private final Parameter showDepartments; - + private final Parameter showContacts; + public SciInstituteSummaryTabConfig() { showHeads = new BooleanParameter( "com.arsdigita.cms.contenttypes.sciinstitute.summarytab.heads.show", Parameter.REQUIRED, true); - + headRole = new StringParameter( "com.arsdigita.cms.contenttypes.sciinstitute.summarytab.heads.role", Parameter.REQUIRED, "head"); - + activeStatus = new StringParameter( "com.arsdigita.cms.contenttypes.sciinstitute.summarytab.heads.status.active", Parameter.REQUIRED, "active"); - + showDepartments = new BooleanParameter( "com.arsdigita.cms.contenttypes.sciinstitute.summarytab.departments.show", Parameter.REQUIRED, true); - + + showContacts = + new BooleanParameter( + "com.arsdigita.cms.contenttypes.sciinstitute.summarytab.contacts.show", + Parameter.REQUIRED, + true); + register(showHeads); register(headRole); register(activeStatus); register(showDepartments); - + register(showContacts); + loadInfo(); } - + public final boolean isShowingHead() { return (Boolean) get(showHeads); } - + public final String getHeadRole() { return (String) get(headRole); } - + public final String getActiveStatus() { return (String) get(activeStatus); } - - public final Boolean isShowingDepartments() { + + public final Boolean isShowingDepartments() { return (Boolean) get(showDepartments); } + + public final boolean isShowingContacts() { + return (Boolean) get(showContacts); + } } diff --git a/ccm-sci-types-institute/src/com/arsdigita/cms/contenttypes/ui/SciInstituteSummaryTabConfig_parameter.properties b/ccm-sci-types-institute/src/com/arsdigita/cms/contenttypes/ui/SciInstituteSummaryTabConfig_parameter.properties index c15fe74e3..e99f09148 100644 --- a/ccm-sci-types-institute/src/com/arsdigita/cms/contenttypes/ui/SciInstituteSummaryTabConfig_parameter.properties +++ b/ccm-sci-types-institute/src/com/arsdigita/cms/contenttypes/ui/SciInstituteSummaryTabConfig_parameter.properties @@ -16,4 +16,9 @@ com.arsdigita.cms.contenttypes.sciinstitute.summarytab.heads.status.active.forma com.arsdigita.cms.contenttypes.sciinstitute.summarytab.departments.show.title = Show departments? com.arsdigita.cms.contenttypes.sciinstitute.summarytab.departments.show.purpose = Show departments? com.arsdigita.cms.contenttypes.sciinstitute.summarytab.departments.show.example = true -com.arsdigita.cms.contenttypes.sciinstitute.summarytab.departments.show.format = [Boolean] \ No newline at end of file +com.arsdigita.cms.contenttypes.sciinstitute.summarytab.departments.show.format = [Boolean] + +com.arsdigita.cms.contenttypes.sciinstitute.summarytab.contacts.show.title = Show contact? +com.arsdigita.cms.contenttypes.sciinstitute.summarytab.contacts.show.purpose = Show contact? +com.arsdigita.cms.contenttypes.sciinstitute.summarytab.contacts.show.example = true +com.arsdigita.cms.contenttypes.sciinstitute.summarytab.contacts.show.format = [Boolean] \ No newline at end of file