Sichern Entwicklungsstand der neuen, optimierten Sci-Module
git-svn-id: https://svn.libreccm.org/ccm/trunk@1245 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
9673ff8af8
commit
d0b104fbfa
|
|
@ -8,6 +8,6 @@
|
||||||
storage="ccm-sci-types-department/memberstab.properties"/>
|
storage="ccm-sci-types-department/memberstab.properties"/>
|
||||||
<config class="com.arsdigita.cms.contenttypes.ui.SciDepartmentProjectsTabConfig"
|
<config class="com.arsdigita.cms.contenttypes.ui.SciDepartmentProjectsTabConfig"
|
||||||
storage="ccm-sci-types-department/projectstab.properties"/>
|
storage="ccm-sci-types-department/projectstab.properties"/>
|
||||||
<config class="com.arsdigita.cms.contenttypes.ui.SciDepartmentPublicationsTabConfig"
|
<config class="com.arsdigita.cms.contenttypes.ui.SciDepartmentPublicationsTabConfig"
|
||||||
storage="ccm-sci-types-department/publicationstab.properties"/>
|
storage="ccm-sci-types-department/publicationstab.properties"/>
|
||||||
</registry>
|
</registry>
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,12 @@ public class SciDepartmentDescTab implements GenericOrgaUnitTab {
|
||||||
result = !desc.getDesc().trim().isEmpty();
|
result = !desc.getDesc().trim().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug(String.format("Needed %d ms to determine if department '%s' "
|
logger.debug(String.format("Needed %d ms to determine if department '%s' "
|
||||||
+ "has a description.",
|
+ "has a description.",
|
||||||
System.currentTimeMillis() - start,
|
System.currentTimeMillis() - start,
|
||||||
orgaunit.getName()));
|
orgaunit.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,21 @@
|
||||||
package com.arsdigita.cms.contenttypes.ui;
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
import com.arsdigita.bebop.Page;
|
import com.arsdigita.cms.contenttypes.SciDepartment;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.cms.contenttypes.SciDepartmentConfig;
|
||||||
import com.arsdigita.cms.ContentItem;
|
|
||||||
import com.arsdigita.cms.ExtraXMLGenerator;
|
|
||||||
import com.arsdigita.xml.Element;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Jens Pelzetter
|
* @author Jens Pelzetter
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class SciDepartmentExtraXmlGenerator implements ExtraXMLGenerator {
|
public class SciDepartmentExtraXmlGenerator
|
||||||
|
extends GenericOrgaUnitExtraXmlGenerator {
|
||||||
|
|
||||||
public void generateXML(ContentItem item, Element element, PageState state) {
|
@Override
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
public String getTabConfig() {
|
||||||
}
|
final SciDepartmentConfig config = SciDepartment.getConfig();
|
||||||
|
|
||||||
public void addGlobalStateParams(Page p) {
|
return config.getTabs();
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ public class SciDepartmentProjectsTab implements GenericOrgaUnitTab {
|
||||||
subDepartmentsQuery.setParameter("orgaunitId",
|
subDepartmentsQuery.setParameter("orgaunitId",
|
||||||
orgaunit.getID().toString());
|
orgaunit.getID().toString());
|
||||||
subDepartmentsQuery.setParameter("assocType",
|
subDepartmentsQuery.setParameter("assocType",
|
||||||
SciDepartmentSubDepartmentsStep.ASSOC_TYPE);
|
SciDepartmentProjectsStep.ASSOC_TYPE);
|
||||||
|
|
||||||
while (subDepartmentsQuery.next()) {
|
while (subDepartmentsQuery.next()) {
|
||||||
if (projectsFilter.length() > 0) {
|
if (projectsFilter.length() > 0) {
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,13 @@ public class SciDepartmentPublicationsTabConfig extends AbstractConfig {
|
||||||
|
|
||||||
mergePublications =
|
mergePublications =
|
||||||
new BooleanParameter(
|
new BooleanParameter(
|
||||||
"com.arsdigita.cms.contenttypes.scidepartments.tabs.publications.merge",
|
"com.arsdigita.cms.contenttypes.scidepartment.tabs.publications.merge",
|
||||||
Parameter.REQUIRED,
|
Parameter.REQUIRED,
|
||||||
Boolean.TRUE);
|
Boolean.TRUE);
|
||||||
|
|
||||||
oneRowPerAuthor =
|
oneRowPerAuthor =
|
||||||
new BooleanParameter(
|
new BooleanParameter(
|
||||||
"com.arsdigita.cms.contenttypes.scidepartments.tabs.publications.one_row_per_author",
|
"com.arsdigita.cms.contenttypes.scidepartment.tabs.publications.one_row_per_author",
|
||||||
Parameter.REQUIRED,
|
Parameter.REQUIRED,
|
||||||
Boolean.FALSE);
|
Boolean.FALSE);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,13 @@ com.arsdigita.cms.contenttypes.scidepartment.tabs.publications.enable_search_lim
|
||||||
com.arsdigita.cms.contenttypes.scidepartment.tabs.publications.enable_search_limit.example = 2
|
com.arsdigita.cms.contenttypes.scidepartment.tabs.publications.enable_search_limit.example = 2
|
||||||
com.arsdigita.cms.contenttypes.scidepartment.tabs.publications.enable_search_limit.format = [Integer]
|
com.arsdigita.cms.contenttypes.scidepartment.tabs.publications.enable_search_limit.format = [Integer]
|
||||||
|
|
||||||
com.arsdigita.cms.contenttypes.scidepartments.tabs.publications.merge.title = Merge publications?
|
com.arsdigita.cms.contenttypes.scidepartment.tabs.publications.merge.title = Merge publications?
|
||||||
com.arsdigita.cms.contenttypes.scidepartments.tabs.publications.merge.purpose = Merge the publications of the department and its sub departments into one list?
|
com.arsdigita.cms.contenttypes.scidepartment.tabs.publications.merge.purpose = Merge the publications of the department and its sub departments into one list?
|
||||||
com.arsdigita.cms.contenttypes.scidepartments.tabs.publications.merge.example = true
|
com.arsdigita.cms.contenttypes.scidepartment.tabs.publications.merge.example = true
|
||||||
com.arsdigita.cms.contenttypes.scidepartments.tabs.publications.merge.format = [Boolean]
|
com.arsdigita.cms.contenttypes.scidepartment.tabs.publications.merge.format = [Boolean]
|
||||||
|
|
||||||
com.arsdigita.cms.contenttypes.scidepartments.tabs.publications.one_row_per_author.title = One row per author?
|
com.arsdigita.cms.contenttypes.scidepartment.tabs.publications.one_row_per_author.title = One row per author?
|
||||||
com.arsdigita.cms.contenttypes.scidepartments.tabs.publications.one_row_per_author.purpose = If set to true, the list of publications will contain each publication n times, where n is the number of authors. Only used if the list of publications is sorted by the authors.
|
com.arsdigita.cms.contenttypes.scidepartment.tabs.publications.one_row_per_author.purpose = If set to true, the list of publications will contain each publication n times, where n is the number of authors. Only used if the list of publications is sorted by the authors.
|
||||||
com.arsdigita.cms.contenttypes.scidepartments.tabs.publications.one_row_per_author.example = false
|
com.arsdigita.cms.contenttypes.scidepartment.tabs.publications.one_row_per_author.example = false
|
||||||
com.arsdigita.cms.contenttypes.scidepartments.tabs.publications.one_row_per_author.format = [Boolean]
|
com.arsdigita.cms.contenttypes.scidepartment.tabs.publications.one_row_per_author.format = [Boolean]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class SciDepartmentSummaryTab implements GenericOrgaUnitTab {
|
||||||
generateHeadOfDepartmentXml(department, departmentSummaryElem, state);
|
generateHeadOfDepartmentXml(department, departmentSummaryElem, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.isShowingHead()) {
|
if (config.isShowingSubDepartment()) {
|
||||||
generateSubDepartmentsXml(department, departmentSummaryElem, state);
|
generateSubDepartmentsXml(department, departmentSummaryElem, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,12 @@
|
||||||
<registry>
|
<registry>
|
||||||
<config class="com.arsdigita.cms.contenttypes.SciInstituteConfig"
|
<config class="com.arsdigita.cms.contenttypes.SciInstituteConfig"
|
||||||
storage="ccm-sci-types-institute/sciinstitute.properties"/>
|
storage="ccm-sci-types-institute/sciinstitute.properties"/>
|
||||||
<!-- <config class="com.arsdigita.cms.contenttypes.ui.SciInstituteSummaryTabConfig"
|
<config class="com.arsdigita.cms.contenttypes.ui.SciInstituteSummaryTabConfig"
|
||||||
storage="ccm-sci-types-institute/summarytab.properties"/> -->
|
storage="ccm-sci-types-department/summarytab.properties"/>
|
||||||
|
<config class="com.arsdigita.cms.contenttypes.ui.SciInstituteMembersTabConfig"
|
||||||
|
storage="ccm-sci-types-department/memberstab.properties"/>
|
||||||
|
<config class="com.arsdigita.cms.contenttypes.ui.SciInstituteProjectsTabConfig"
|
||||||
|
storage="ccm-sci-types-department/projectstab.properties"/>
|
||||||
|
<config class="com.arsdigita.cms.contenttypes.ui.SciInstitutePublicationsTabConfig"
|
||||||
|
storage="ccm-sci-types-department/publicationstab.properties"/>
|
||||||
</registry>
|
</registry>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,98 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||||
|
import com.arsdigita.cms.contenttypes.SciInstitute;
|
||||||
|
import com.arsdigita.xml.Element;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class SciInstituteDescTab implements GenericOrgaUnitTab {
|
||||||
|
|
||||||
|
public final Logger logger = Logger.getLogger(SciInstituteDescTab.class);
|
||||||
|
|
||||||
|
public boolean hasData(final GenericOrganizationalUnit orgaunit) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
boolean result;
|
||||||
|
final Desc desc = getData(orgaunit);
|
||||||
|
|
||||||
|
if (desc.getDesc() == null) {
|
||||||
|
result = false;
|
||||||
|
} else {
|
||||||
|
result = !desc.getDesc().trim().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug(String.format("Needed %d ms to determine if institute "
|
||||||
|
+ "'%s' has a description.",
|
||||||
|
System.currentTimeMillis() - start,
|
||||||
|
orgaunit.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void generateXml(final GenericOrganizationalUnit orgaunit,
|
||||||
|
final Element parent,
|
||||||
|
final PageState state) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
final Desc desc = getData(orgaunit);
|
||||||
|
|
||||||
|
if ((desc.getShortDesc() != null)
|
||||||
|
&& !desc.getShortDesc().trim().isEmpty()) {
|
||||||
|
final Element shortDescElem = parent.newChildElement(
|
||||||
|
"shortDescription");
|
||||||
|
shortDescElem.setText(desc.getShortDesc());
|
||||||
|
}
|
||||||
|
|
||||||
|
final Element descElem = parent.newChildElement("description");
|
||||||
|
descElem.setText(desc.getDesc());
|
||||||
|
|
||||||
|
logger.debug(String.format("Generated XML for description tab of "
|
||||||
|
+ "institute '%s' in %d ms",
|
||||||
|
orgaunit.getName(),
|
||||||
|
System.currentTimeMillis() - start));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Desc getData(final GenericOrganizationalUnit orgaunit) {
|
||||||
|
if (!(orgaunit instanceof SciInstitute)) {
|
||||||
|
throw new IllegalArgumentException(String.format(
|
||||||
|
"This tab can only process instances of "
|
||||||
|
+ "'com.arsdigita.cms.contenttypes.SciDepartment'. Provided "
|
||||||
|
+ "object is of type '%s'",
|
||||||
|
orgaunit.getClass().getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
final SciInstitute institute = (SciInstitute) orgaunit;
|
||||||
|
final Desc desc = new Desc();
|
||||||
|
desc.setShortDesc(institute.getInstituteShortDescription());
|
||||||
|
desc.setDesc(institute.getInstituteDescription());
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Desc {
|
||||||
|
|
||||||
|
private String shortDesc;
|
||||||
|
private String desc;
|
||||||
|
|
||||||
|
public String getShortDesc() {
|
||||||
|
return shortDesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShortDesc(final String shortDesc) {
|
||||||
|
this.shortDesc = shortDesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDesc() {
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDesc(final String desc) {
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,24 +1,20 @@
|
||||||
package com.arsdigita.cms.contenttypes.ui;
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
import com.arsdigita.bebop.Page;
|
import com.arsdigita.cms.contenttypes.SciInstitute;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.cms.contenttypes.SciInstituteConfig;
|
||||||
import com.arsdigita.cms.ContentItem;
|
|
||||||
import com.arsdigita.cms.ExtraXMLGenerator;
|
|
||||||
import com.arsdigita.xml.Element;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Jens Pelzetter
|
* @author Jens Pelzetter
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class SciInstituteExtraXmlGenerator implements ExtraXMLGenerator {
|
public class SciInstituteExtraXmlGenerator
|
||||||
|
extends GenericOrgaUnitExtraXmlGenerator {
|
||||||
|
|
||||||
public void generateXML(ContentItem item, Element element, PageState state) {
|
@Override
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
public String getTabConfig() {
|
||||||
}
|
final SciInstituteConfig config = SciInstitute.getConfig();
|
||||||
|
return config.getTabs();
|
||||||
public void addGlobalStateParams(Page p) {
|
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,216 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitPersonCollection;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||||
|
import com.arsdigita.cms.contenttypes.SciInstitute;
|
||||||
|
import com.arsdigita.cms.contenttypes.ui.panels.CompareFilter;
|
||||||
|
import com.arsdigita.cms.contenttypes.ui.panels.Paginator;
|
||||||
|
import com.arsdigita.cms.contenttypes.ui.panels.TextFilter;
|
||||||
|
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||||
|
import com.arsdigita.persistence.DataQuery;
|
||||||
|
import com.arsdigita.persistence.SessionManager;
|
||||||
|
import com.arsdigita.xml.Element;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class SciInstituteMembersTab implements GenericOrgaUnitTab {
|
||||||
|
|
||||||
|
private final Logger logger = Logger.getLogger(SciInstituteMembersTab.class);
|
||||||
|
private static final SciInstituteMembersTabConfig config =
|
||||||
|
new SciInstituteMembersTabConfig();
|
||||||
|
private static final String STATUS_PARAM = "memberStatus";
|
||||||
|
private static final String SURNAME_PARAM = "memberSurname";
|
||||||
|
private final CompareFilter statusFilter = new CompareFilter(
|
||||||
|
STATUS_PARAM,
|
||||||
|
GenericOrganizationalUnitPersonCollection.LINK_STATUS,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false);
|
||||||
|
private final TextFilter surnameFilter =
|
||||||
|
new TextFilter(SURNAME_PARAM,
|
||||||
|
GenericPerson.SURNAME);
|
||||||
|
|
||||||
|
static {
|
||||||
|
config.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SciInstituteMembersTab() {
|
||||||
|
super();
|
||||||
|
final String[] statusValues = config.getStatusValues();
|
||||||
|
|
||||||
|
for (String status : statusValues) {
|
||||||
|
statusFilter.addOption(status, status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasData(final GenericOrganizationalUnit orgaunit) {
|
||||||
|
if ((orgaunit.getPersons() != null)
|
||||||
|
&& orgaunit.getPersons().size() > 0) {
|
||||||
|
return true;
|
||||||
|
} else if (config.isMergingMembers()) {
|
||||||
|
final DataQuery persons = getData(orgaunit);
|
||||||
|
return persons.isEmpty();
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void generateXml(final GenericOrganizationalUnit orgaunit,
|
||||||
|
final Element parent,
|
||||||
|
final PageState state) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
final DataQuery persons = getData(orgaunit);
|
||||||
|
final HttpServletRequest request = state.getRequest();
|
||||||
|
|
||||||
|
applyStatusFilter(persons, request);
|
||||||
|
applySurnameFilter(persons, request);
|
||||||
|
|
||||||
|
final Element depMembersElem = parent.newChildElement(
|
||||||
|
"instituteMembers");
|
||||||
|
|
||||||
|
final Element filtersElem = depMembersElem.newChildElement("filters");
|
||||||
|
|
||||||
|
final Paginator paginator = new Paginator(request,
|
||||||
|
(int) persons.size(),
|
||||||
|
config.getPageSize());
|
||||||
|
|
||||||
|
statusFilter.generateXml(filtersElem);
|
||||||
|
if (paginator.getPageCount() > config.getEnableSearchLimit()) {
|
||||||
|
surnameFilter.generateXml(filtersElem);
|
||||||
|
}
|
||||||
|
|
||||||
|
paginator.applyLimits(persons);
|
||||||
|
paginator.generateXml(depMembersElem);
|
||||||
|
|
||||||
|
while (persons.next()) {
|
||||||
|
generateMemberXml((BigDecimal) persons.get("memberId"),
|
||||||
|
depMembersElem,
|
||||||
|
state);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug(String.format("Generated members list of institute'%s' "
|
||||||
|
+ "in %d ms.",
|
||||||
|
orgaunit.getName(),
|
||||||
|
System.currentTimeMillis() - start));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DataQuery getData(final GenericOrganizationalUnit orgaunit) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
if (!(orgaunit instanceof SciInstitute)) {
|
||||||
|
throw new IllegalArgumentException(String.format(
|
||||||
|
"This tab can only process instances of "
|
||||||
|
+ "'com.arsdigita.cms.contenttypes.SciInstitute'. Provided "
|
||||||
|
+ "object is of type '%s'",
|
||||||
|
orgaunit.getClass().getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
final DataQuery personsQuery = SessionManager.getSession().
|
||||||
|
retrieveQuery(
|
||||||
|
"com.arsdigita.cms.contenttypes.getIdsOfMembersOfOrgaUnits");
|
||||||
|
final StringBuffer personsFilter = new StringBuffer();
|
||||||
|
|
||||||
|
if (config.isMergingMembers()) {
|
||||||
|
final DataQuery departmentsQuery =
|
||||||
|
SessionManager.getSession().retrieveQuery(
|
||||||
|
"com.arsdigita.cms.contenttypes.getIdsOfSubordinateOrgaUnitsRecursivlyWithAssocType");
|
||||||
|
departmentsQuery.setParameter("orgaunitId",
|
||||||
|
orgaunit.getID().toString());
|
||||||
|
departmentsQuery.setParameter("assocType",
|
||||||
|
SciInstituteDepartmentsStep.ASSOC_TYPE);
|
||||||
|
|
||||||
|
while (departmentsQuery.next()) {
|
||||||
|
if (personsFilter.length() > 0) {
|
||||||
|
personsFilter.append(" or ");
|
||||||
|
}
|
||||||
|
personsFilter.append(String.format("orgaunitId = %s",
|
||||||
|
departmentsQuery.get(
|
||||||
|
"orgaunitId").toString()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
personsFilter.append(String.format("orgaunitId = %s",
|
||||||
|
orgaunit.getID().toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
personsQuery.addFilter(personsFilter.toString());
|
||||||
|
|
||||||
|
personsQuery.addOrder(GenericPerson.SURNAME);
|
||||||
|
personsQuery.addOrder(GenericPerson.GIVENNAME);
|
||||||
|
|
||||||
|
logger.debug(String.format(
|
||||||
|
"Got members of institute '%s'"
|
||||||
|
+ "in '%d ms'. MergeMembers is set to '%b'.",
|
||||||
|
orgaunit.getName(),
|
||||||
|
System.currentTimeMillis() - start,
|
||||||
|
config.isMergingMembers()));
|
||||||
|
return personsQuery;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyStatusFilter(final DataQuery persons,
|
||||||
|
final HttpServletRequest request) {
|
||||||
|
final String statusValue = request.getParameter(STATUS_PARAM);
|
||||||
|
if ((statusValue != null) && !(statusValue.trim().isEmpty())) {
|
||||||
|
statusFilter.setValue(statusValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
persons.addFilter(statusFilter.getFilter());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applySurnameFilter(final DataQuery persons,
|
||||||
|
final HttpServletRequest request) {
|
||||||
|
final String surnameValue = request.getParameter(SURNAME_PARAM);
|
||||||
|
if ((surnameValue != null) && !(surnameValue.trim().isEmpty())) {
|
||||||
|
surnameFilter.setValue(surnameValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
persons.addFilter(surnameFilter.getFilter());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void generateMemberXml(final BigDecimal memberId,
|
||||||
|
final Element parent,
|
||||||
|
final PageState state) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
final GenericPerson member = new GenericPerson(memberId);
|
||||||
|
logger.debug(String.format("Got domain object for member '%s' "
|
||||||
|
+ "in %d ms.",
|
||||||
|
member.getFullName(),
|
||||||
|
System.currentTimeMillis() - start));
|
||||||
|
generateMemberXml(member, parent, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void generateMemberXml(final GenericPerson member,
|
||||||
|
final Element parent,
|
||||||
|
final PageState state) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
final XmlGenerator generator = new XmlGenerator(member);
|
||||||
|
generator.setUseExtraXml(false);
|
||||||
|
generator.generateXML(state, parent, "");
|
||||||
|
logger.debug(String.format("Generated XML for member '%s' in %d ms.",
|
||||||
|
member.getFullName(),
|
||||||
|
System.currentTimeMillis() - start));
|
||||||
|
}
|
||||||
|
|
||||||
|
private class XmlGenerator extends SimpleXMLGenerator {
|
||||||
|
|
||||||
|
private final ContentItem item;
|
||||||
|
|
||||||
|
public XmlGenerator(final ContentItem item) {
|
||||||
|
super();
|
||||||
|
this.item = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ContentItem getContentItem(final PageState state) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
|
||||||
|
import com.arsdigita.runtime.AbstractConfig;
|
||||||
|
import com.arsdigita.util.parameter.BooleanParameter;
|
||||||
|
import com.arsdigita.util.parameter.IntegerParameter;
|
||||||
|
import com.arsdigita.util.parameter.Parameter;
|
||||||
|
import com.arsdigita.util.parameter.StringArrayParameter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class SciInstituteMembersTabConfig extends AbstractConfig {
|
||||||
|
|
||||||
|
private Parameter statusValues;
|
||||||
|
private Parameter pageSize;
|
||||||
|
private Parameter enableSearchLimit;
|
||||||
|
private Parameter mergeMembers;
|
||||||
|
|
||||||
|
public SciInstituteMembersTabConfig() {
|
||||||
|
statusValues =
|
||||||
|
new StringArrayParameter(
|
||||||
|
"com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.status_values",
|
||||||
|
Parameter.REQUIRED,
|
||||||
|
new String[]{"active", "associated", "former"});
|
||||||
|
|
||||||
|
pageSize =
|
||||||
|
new IntegerParameter(
|
||||||
|
"com.arsdigita.cms.contenttypes.sciinstitute.tabs.embers.page_size",
|
||||||
|
Parameter.REQUIRED,
|
||||||
|
30);
|
||||||
|
|
||||||
|
enableSearchLimit =
|
||||||
|
new IntegerParameter(
|
||||||
|
"com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.enable_search_limit",
|
||||||
|
Parameter.REQUIRED,
|
||||||
|
2);
|
||||||
|
|
||||||
|
mergeMembers =
|
||||||
|
new BooleanParameter(
|
||||||
|
"com.arsdigita.cms.contenttypes.sciinstitutes.tabs.members.merge",
|
||||||
|
Parameter.REQUIRED,
|
||||||
|
Boolean.TRUE);
|
||||||
|
|
||||||
|
register(statusValues);
|
||||||
|
register(pageSize);
|
||||||
|
register(enableSearchLimit);
|
||||||
|
register(mergeMembers);
|
||||||
|
|
||||||
|
loadInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String[] getStatusValues() {
|
||||||
|
return (String[]) get(statusValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getPageSize() {
|
||||||
|
return (Integer) get(pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getEnableSearchLimit() {
|
||||||
|
return (Integer) get(enableSearchLimit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean isMergingMembers() {
|
||||||
|
return (Boolean) get(mergeMembers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.status_values.title = Status values
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.status_values.purpose = Possible values for status attribute of the SciInstitute -> GenericPerson association. Used to build the select box and the filter for the status.
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.status_values.example = active,associated,former
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.status_values.format = [String]
|
||||||
|
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.embers.page_size.title = Page size
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.embers.page_size.purpose = Maximum number of members per page
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.embers.page_size.example = 30
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.embers.page_size.format = [Integer]
|
||||||
|
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.enable_search_limit.title = Enable search limit
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.enable_search_limit.purpose = Number of result pages when to activate the search. Set to 1 or 0 to show the search on every time.
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.enable_search_limit.example = 2
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.enable_search_limit.format = Integer
|
||||||
|
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitutes.tabs.members.merge.title = Merge members
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitutes.tabs.members.merge.purpose = Merge the members of the department and its sub departments into one list?
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitutes.tabs.members.merge.example = true
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitutes.tabs.members.merge.format = [Boolean]
|
||||||
|
|
||||||
|
|
@ -0,0 +1,235 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.ContentPage;
|
||||||
|
import com.arsdigita.cms.ContentType;
|
||||||
|
import com.arsdigita.cms.ContentTypeCollection;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||||
|
import com.arsdigita.cms.contenttypes.SciInstitute;
|
||||||
|
import com.arsdigita.cms.contenttypes.ui.panels.CompareFilter;
|
||||||
|
import com.arsdigita.cms.contenttypes.ui.panels.Paginator;
|
||||||
|
import com.arsdigita.cms.contenttypes.ui.panels.TextFilter;
|
||||||
|
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||||
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
import com.arsdigita.persistence.DataQuery;
|
||||||
|
import com.arsdigita.persistence.OID;
|
||||||
|
import com.arsdigita.persistence.SessionManager;
|
||||||
|
import com.arsdigita.xml.Element;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class SciInstituteProjectsTab implements GenericOrgaUnitTab {
|
||||||
|
|
||||||
|
private final Logger logger =
|
||||||
|
Logger.getLogger(SciInstituteProjectsTab.class);
|
||||||
|
private final static SciInstituteProjectsTabConfig config =
|
||||||
|
new SciInstituteProjectsTabConfig();
|
||||||
|
private static final String STATUS_PARAM = "projectStatus";
|
||||||
|
private static final String TITLE_PARAM = "projectTitle";
|
||||||
|
private final CompareFilter statusFilter = new CompareFilter(STATUS_PARAM,
|
||||||
|
"projectEnd",
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true);
|
||||||
|
private final TextFilter titleFilter = new TextFilter(TITLE_PARAM,
|
||||||
|
ContentPage.TITLE);
|
||||||
|
|
||||||
|
static {
|
||||||
|
config.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasData(final GenericOrganizationalUnit orgaunit) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
final ContentTypeCollection types = ContentType.getAllContentTypes();
|
||||||
|
types.addFilter(
|
||||||
|
"associatedObjectType = 'com.arsdigita.cms.contenttypes.SciProject'");
|
||||||
|
|
||||||
|
if (types.size() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
types.close();
|
||||||
|
|
||||||
|
final boolean result = !getData(orgaunit).isEmpty();
|
||||||
|
|
||||||
|
logger.debug(String.format("Needed %d ms to determine if institute "
|
||||||
|
+ "'%s' has projects.",
|
||||||
|
System.currentTimeMillis() - start,
|
||||||
|
orgaunit.getName()));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void generateXml(final GenericOrganizationalUnit orgaunit,
|
||||||
|
final Element parent,
|
||||||
|
final PageState state) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
final DataQuery projects = getData(orgaunit);
|
||||||
|
final HttpServletRequest request = state.getRequest();
|
||||||
|
|
||||||
|
final Element depProjectsElem = parent.newChildElement(
|
||||||
|
"departmentProjects");
|
||||||
|
final Element filtersElem = depProjectsElem.newChildElement(
|
||||||
|
"filters");
|
||||||
|
|
||||||
|
statusFilter.generateXml(filtersElem);
|
||||||
|
|
||||||
|
if (((request.getParameter(STATUS_PARAM) == null)
|
||||||
|
|| (request.getParameter(STATUS_PARAM).trim().isEmpty()))
|
||||||
|
&& ((request.getParameter(TITLE_PARAM) == null)
|
||||||
|
|| request.getParameter(TITLE_PARAM).trim().isEmpty())) {
|
||||||
|
|
||||||
|
depProjectsElem.newChildElement("greeting");
|
||||||
|
|
||||||
|
projects.addOrder("projectBegin");
|
||||||
|
projects.addOrder("title");
|
||||||
|
|
||||||
|
projects.setRange(1, config.getGreetingSize() + 1);
|
||||||
|
|
||||||
|
titleFilter.generateXml(filtersElem);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
projects.addOrder("title");
|
||||||
|
|
||||||
|
|
||||||
|
applyStatusFilter(projects, request);
|
||||||
|
applyTitleFilter(projects, request);
|
||||||
|
|
||||||
|
final Paginator paginator = new Paginator(request,
|
||||||
|
(int) projects.size(),
|
||||||
|
config.getPageSize());
|
||||||
|
|
||||||
|
if (paginator.getPageCount() > config.getEnableSearchLimit()) {
|
||||||
|
titleFilter.generateXml(filtersElem);
|
||||||
|
}
|
||||||
|
|
||||||
|
paginator.applyLimits(projects);
|
||||||
|
paginator.generateXml(depProjectsElem);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (projects.next()) {
|
||||||
|
generateProjectXml((BigDecimal) projects.get("projectId"),
|
||||||
|
depProjectsElem,
|
||||||
|
state);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug(String.format("Generated projects list of department '%s' "
|
||||||
|
+ "in %d ms.",
|
||||||
|
orgaunit.getName(),
|
||||||
|
System.currentTimeMillis() - start));
|
||||||
|
}
|
||||||
|
protected DataQuery getData(final GenericOrganizationalUnit orgaunit) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
if (!(orgaunit instanceof SciInstitute)) {
|
||||||
|
throw new IllegalArgumentException(String.format(
|
||||||
|
"This tab can only process instances of "
|
||||||
|
+ "'com.arsdigita.cms.contenttypes.SciInstitute'. Provided "
|
||||||
|
+ "object is of type '%s'",
|
||||||
|
orgaunit.getClass().getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
final DataQuery projectsQuery = SessionManager.getSession().
|
||||||
|
retrieveQuery(
|
||||||
|
"com.arsdigita.cms.contenttypes. getIdsOfProjectsOfOrgaUnit");
|
||||||
|
final StringBuffer projectsFilter = new StringBuffer();
|
||||||
|
|
||||||
|
if (config.isMergingProjects()) {
|
||||||
|
final DataQuery subDepartmentsQuery =
|
||||||
|
SessionManager.getSession().retrieveQuery(
|
||||||
|
"com.arsdigita.cms.contenttypes.getIdsOfSubordinateOrgaUnitsRecursivlyWithAssocType");
|
||||||
|
subDepartmentsQuery.setParameter("orgaunitId",
|
||||||
|
orgaunit.getID().toString());
|
||||||
|
subDepartmentsQuery.setParameter("assocType",
|
||||||
|
SciInstituteProjectsStep.ASSOC_TYPE);
|
||||||
|
|
||||||
|
while (subDepartmentsQuery.next()) {
|
||||||
|
if (projectsFilter.length() > 0) {
|
||||||
|
projectsFilter.append(" or ");
|
||||||
|
}
|
||||||
|
projectsFilter.append(String.format("orgaunitId = %s",
|
||||||
|
subDepartmentsQuery.get(
|
||||||
|
"orgaunitId").toString()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
projectsFilter.append(String.format("orgaunitId = %s",
|
||||||
|
orgaunit.getID().toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
projectsQuery.addFilter(projectsFilter.toString());
|
||||||
|
|
||||||
|
logger.debug(String.format(
|
||||||
|
"Got projects of institute '%s'"
|
||||||
|
+ "in '%d ms'. MergeProjects is set to '%b'.",
|
||||||
|
orgaunit.getName(),
|
||||||
|
System.currentTimeMillis() - start,
|
||||||
|
config.isMergingProjects()));
|
||||||
|
return projectsQuery;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyStatusFilter(final DataQuery projects,
|
||||||
|
final HttpServletRequest request) {
|
||||||
|
final String statusValue = request.getParameter(STATUS_PARAM);
|
||||||
|
if ((statusValue != null) && !(statusValue.trim().isEmpty())) {
|
||||||
|
statusFilter.setValue(statusValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
projects.addFilter(statusFilter.getFilter());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyTitleFilter(final DataQuery projects,
|
||||||
|
final HttpServletRequest request) {
|
||||||
|
final String titleValue = request.getParameter(TITLE_PARAM);
|
||||||
|
if ((titleValue != null) && !(titleValue.trim().isEmpty())) {
|
||||||
|
titleFilter.setValue(titleValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
projects.addFilter(titleFilter.getFilter());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generateProjectXml(final BigDecimal projectId,
|
||||||
|
final Element parent,
|
||||||
|
final PageState state) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
final ContentPage project = (ContentPage) DomainObjectFactory.
|
||||||
|
newInstance(new OID(
|
||||||
|
"com.arsdigita.cms.contenttypes.SciProject", projectId));
|
||||||
|
logger.debug(String.format("Got domain object for project '%s' "
|
||||||
|
+ "in %d ms.",
|
||||||
|
project.getName(),
|
||||||
|
System.currentTimeMillis() - start));
|
||||||
|
generateProjectXml(project, parent, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generateProjectXml(final ContentPage project,
|
||||||
|
final Element parent,
|
||||||
|
final PageState state) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
final XmlGenerator generator = new XmlGenerator(project);
|
||||||
|
generator.generateXML(state, parent, "");
|
||||||
|
logger.debug(String.format("Generated XML for project '%s' in %d ms.",
|
||||||
|
project.getName(),
|
||||||
|
System.currentTimeMillis() - start));
|
||||||
|
}
|
||||||
|
|
||||||
|
private class XmlGenerator extends SimpleXMLGenerator {
|
||||||
|
|
||||||
|
private final ContentItem item;
|
||||||
|
|
||||||
|
public XmlGenerator(final ContentItem item) {
|
||||||
|
super();
|
||||||
|
this.item = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ContentItem getContentItem(final PageState state) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.runtime.AbstractConfig;
|
||||||
|
import com.arsdigita.util.parameter.BooleanParameter;
|
||||||
|
import com.arsdigita.util.parameter.IntegerParameter;
|
||||||
|
import com.arsdigita.util.parameter.Parameter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class SciInstituteProjectsTabConfig extends AbstractConfig {
|
||||||
|
|
||||||
|
private final Parameter greetingSize;
|
||||||
|
private final Parameter pageSize;
|
||||||
|
private final Parameter enableSearchLimit;
|
||||||
|
private final Parameter mergeProjects;
|
||||||
|
|
||||||
|
public SciInstituteProjectsTabConfig() {
|
||||||
|
greetingSize =
|
||||||
|
new IntegerParameter(
|
||||||
|
"com.arsdigita.cms.contenttypes.sciinstitute.tabs.projects.greeting_number",
|
||||||
|
Parameter.REQUIRED,
|
||||||
|
10);
|
||||||
|
|
||||||
|
pageSize =
|
||||||
|
new IntegerParameter(
|
||||||
|
"com.arsdigita.cms.contenttypes.sciinstitute.tabs.projects.page_size",
|
||||||
|
Parameter.REQUIRED,
|
||||||
|
30);
|
||||||
|
|
||||||
|
enableSearchLimit =
|
||||||
|
new IntegerParameter(
|
||||||
|
"com.arsdigita.cms.contenttypes.sciinstitute.tabs.projects.enable_search_limit",
|
||||||
|
Parameter.REQUIRED,
|
||||||
|
2);
|
||||||
|
|
||||||
|
mergeProjects =
|
||||||
|
new BooleanParameter(
|
||||||
|
"com.arsdigita.cms.contenttypes.sciinstitutes.tabs.projects.merge",
|
||||||
|
Parameter.REQUIRED,
|
||||||
|
Boolean.TRUE);
|
||||||
|
|
||||||
|
register(greetingSize);
|
||||||
|
register(pageSize);
|
||||||
|
register(enableSearchLimit);
|
||||||
|
register(mergeProjects);
|
||||||
|
|
||||||
|
loadInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getGreetingSize() {
|
||||||
|
return (Integer) get(greetingSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getPageSize() {
|
||||||
|
return (Integer) get(pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getEnableSearchLimit() {
|
||||||
|
return (Integer) get(enableSearchLimit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean isMergingProjects() {
|
||||||
|
return (Boolean) get(mergeProjects);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.status_values.title = Status values
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.status_values.purpose = Possible values for status attribute of the SciDepartment -> GenericPerson association. Used to build the select box and the filter for the status.
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.status_values.example = active,associated,former
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.status_values.format = [String]
|
||||||
|
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.embers.page_size.title = Page size
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.embers.page_size.purpose = Maximum number of members per page
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.embers.page_size.example = 30
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.embers.page_size.format = [Integer]
|
||||||
|
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.enable_search_limit.title = Enable search limit
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.enable_search_limit.purpose = Number of result pages when to activate the search. Set to 1 or 0 to show the search on every time.
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.enable_search_limit.example = 2
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.enable_search_limit.format = Integer
|
||||||
|
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.merge.title = Merge members
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.merge.purpose = Merge the members of the institute and its sub institutes into one list?
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.merge.example = true
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.members.merge.format = [Boolean]
|
||||||
|
|
||||||
|
|
@ -0,0 +1,343 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.ContentPage;
|
||||||
|
import com.arsdigita.cms.ContentType;
|
||||||
|
import com.arsdigita.cms.ContentTypeCollection;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||||
|
import com.arsdigita.cms.contenttypes.SciInstitute;
|
||||||
|
import com.arsdigita.cms.contenttypes.ui.panels.Paginator;
|
||||||
|
import com.arsdigita.cms.contenttypes.ui.panels.SelectFilter;
|
||||||
|
import com.arsdigita.cms.contenttypes.ui.panels.TextFilter;
|
||||||
|
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||||
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
import com.arsdigita.persistence.DataQuery;
|
||||||
|
import com.arsdigita.persistence.OID;
|
||||||
|
import com.arsdigita.persistence.SessionManager;
|
||||||
|
import com.arsdigita.xml.Element;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class SciInstitutePublicationsTab implements GenericOrgaUnitTab {
|
||||||
|
|
||||||
|
private final Logger logger = Logger.getLogger(
|
||||||
|
SciInstitutePublicationsTab.class);
|
||||||
|
private static final SciInstitutePublicationsTabConfig config =
|
||||||
|
new SciInstitutePublicationsTabConfig();
|
||||||
|
private static final String YEAR_PARAM = "year";
|
||||||
|
private static final String TITLE_PARAM = "title";
|
||||||
|
private static final String AUTHOR_PARAM = "author";
|
||||||
|
private static final String SORT_PARAM = "sortBy";
|
||||||
|
private static final String SORT_BY_YEAR_ASC = "yearAsc";
|
||||||
|
private static final String SORT_BY_YEAR_DESC = "yearDesc";
|
||||||
|
private static final String SORT_BY_TITLE = "title";
|
||||||
|
private static final String SORT_BY_AUTHOR = "author";
|
||||||
|
private final SelectFilter yearFilter = new SelectFilter(YEAR_PARAM,
|
||||||
|
YEAR_PARAM,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true);
|
||||||
|
private final TextFilter titleFilter = new TextFilter(TITLE_PARAM,
|
||||||
|
ContentPage.TITLE);
|
||||||
|
private final TextFilter authorFilter;
|
||||||
|
|
||||||
|
static {
|
||||||
|
config.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SciInstitutePublicationsTab() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
if (config.getOneRowPerAuthor()) {
|
||||||
|
authorFilter = new TextFilter(AUTHOR_PARAM, "authorSurname");
|
||||||
|
} else {
|
||||||
|
authorFilter = new TextFilter(AUTHOR_PARAM, "authors");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasData(final GenericOrganizationalUnit orgaunit) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
final ContentTypeCollection types = ContentType.getAllContentTypes();
|
||||||
|
types.addFilter(
|
||||||
|
"associatedObjectType = 'com.arsdigita.cms.contenttypes.Publication'");
|
||||||
|
|
||||||
|
if (types.size() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
types.close();
|
||||||
|
|
||||||
|
final boolean result = !getData(orgaunit).isEmpty();
|
||||||
|
|
||||||
|
logger.debug(String.format("Needed %d ms to determine if institute "
|
||||||
|
+ "'%s' has publications.",
|
||||||
|
System.currentTimeMillis() - start,
|
||||||
|
orgaunit.getName()));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void generateXml(final GenericOrganizationalUnit orgaunit,
|
||||||
|
final Element parent,
|
||||||
|
final PageState state) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
final DataQuery publications = getData(orgaunit);
|
||||||
|
final HttpServletRequest request = state.getRequest();
|
||||||
|
|
||||||
|
final Element publicationsElem = parent.newChildElement(
|
||||||
|
"institutePublications");
|
||||||
|
|
||||||
|
final String yearValue = request.getParameter(YEAR_PARAM);
|
||||||
|
final String titleValue = request.getParameter(TITLE_PARAM);
|
||||||
|
final String authorValue = request.getParameter(AUTHOR_PARAM);
|
||||||
|
final String sortValue = request.getParameter(SORT_PARAM);
|
||||||
|
|
||||||
|
final Element filtersElem = publicationsElem.newChildElement(
|
||||||
|
"filters");
|
||||||
|
|
||||||
|
if (((yearValue == null) || yearValue.trim().isEmpty())
|
||||||
|
&& ((titleValue == null) || titleValue.trim().isEmpty())
|
||||||
|
&& ((authorValue == null) || authorValue.trim().isEmpty())
|
||||||
|
&& ((sortValue == null) || sortValue.trim().isEmpty())) {
|
||||||
|
|
||||||
|
publicationsElem.newChildElement("greeting");
|
||||||
|
|
||||||
|
publications.addOrder("year");
|
||||||
|
if (config.getOneRowPerAuthor()) {
|
||||||
|
publications.addOrder("surname");
|
||||||
|
} else {
|
||||||
|
publications.addOrder("authors");
|
||||||
|
}
|
||||||
|
publications.addOrder("title");
|
||||||
|
|
||||||
|
publications.setRange(1, config.getGreetingSize() + 1);
|
||||||
|
|
||||||
|
yearFilter.generateXml(filtersElem);
|
||||||
|
titleFilter.generateXml(filtersElem);
|
||||||
|
authorFilter.generateXml(filtersElem);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (SORT_BY_AUTHOR.equals(sortValue)) {
|
||||||
|
if (config.getOneRowPerAuthor()) {
|
||||||
|
publications.addOrder("surname");
|
||||||
|
} else {
|
||||||
|
publications.addOrder("authors");
|
||||||
|
}
|
||||||
|
publications.addOrder("title");
|
||||||
|
publications.addOrder("year asc");
|
||||||
|
} else if (SORT_BY_TITLE.equals(sortValue)) {
|
||||||
|
publications.addOrder("title");
|
||||||
|
if (config.getOneRowPerAuthor()) {
|
||||||
|
publications.addOrder("surname");
|
||||||
|
} else {
|
||||||
|
publications.addOrder("authors");
|
||||||
|
}
|
||||||
|
publications.addOrder("year asc");
|
||||||
|
} else if (SORT_BY_YEAR_ASC.equals(sortValue)) {
|
||||||
|
publications.addOrder("year asc");
|
||||||
|
if (config.getOneRowPerAuthor()) {
|
||||||
|
publications.addOrder("surname");
|
||||||
|
} else {
|
||||||
|
publications.addOrder("authors");
|
||||||
|
}
|
||||||
|
publications.addOrder("title");
|
||||||
|
} else if (SORT_BY_YEAR_DESC.equals(sortValue)) {
|
||||||
|
publications.addOrder("year desc");
|
||||||
|
if (config.getOneRowPerAuthor()) {
|
||||||
|
publications.addOrder("surname");
|
||||||
|
} else {
|
||||||
|
publications.addOrder("authors");
|
||||||
|
}
|
||||||
|
publications.addOrder("title");
|
||||||
|
} else {
|
||||||
|
if (config.getOneRowPerAuthor()) {
|
||||||
|
publications.addOrder("surname");
|
||||||
|
} else {
|
||||||
|
publications.addOrder("authors");
|
||||||
|
}
|
||||||
|
publications.addOrder("title");
|
||||||
|
publications.addOrder("year asc");
|
||||||
|
}
|
||||||
|
|
||||||
|
applyYearFilter(publications, request);
|
||||||
|
applyTitleFilter(publications, request);
|
||||||
|
applyAuthorFilter(publications, request);
|
||||||
|
|
||||||
|
final Paginator paginator = new Paginator(request,
|
||||||
|
(int) publications.size(),
|
||||||
|
config.getPageSize());
|
||||||
|
|
||||||
|
if (paginator.getPageCount() > config.getEnableSearchLimit()) {
|
||||||
|
yearFilter.generateXml(filtersElem);
|
||||||
|
titleFilter.generateXml(filtersElem);
|
||||||
|
authorFilter.generateXml(filtersElem);
|
||||||
|
}
|
||||||
|
|
||||||
|
paginator.applyLimits(publications);
|
||||||
|
paginator.generateXml(publicationsElem);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Element sortFieldsElem = publicationsElem.newChildElement(
|
||||||
|
"sortFields");
|
||||||
|
sortFieldsElem.addAttribute("sortBy", sortValue);
|
||||||
|
|
||||||
|
sortFieldsElem.newChildElement("sortField").addAttribute("label",
|
||||||
|
SORT_BY_AUTHOR);
|
||||||
|
sortFieldsElem.newChildElement("sortField").addAttribute("label",
|
||||||
|
SORT_BY_TITLE);
|
||||||
|
sortFieldsElem.newChildElement("sortField").addAttribute("label",
|
||||||
|
SORT_BY_YEAR_ASC);
|
||||||
|
sortFieldsElem.newChildElement("sortField").addAttribute("label",
|
||||||
|
SORT_BY_YEAR_DESC);
|
||||||
|
|
||||||
|
while (publications.next()) {
|
||||||
|
generatePublicationXml(
|
||||||
|
(BigDecimal) publications.get("publicationId"),
|
||||||
|
(String) publications.get("objectType"),
|
||||||
|
publicationsElem,
|
||||||
|
state);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug(String.format("Generated publications list of institute '%s' "
|
||||||
|
+ "in %d ms.",
|
||||||
|
orgaunit.getName(),
|
||||||
|
System.currentTimeMillis() - start));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DataQuery getData(final GenericOrganizationalUnit orgaunit) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
if (!(orgaunit instanceof SciInstitute)) {
|
||||||
|
throw new IllegalArgumentException(String.format(
|
||||||
|
"This tab can only process instances of "
|
||||||
|
+ "'com.arsdigita.cms.contenttypes.SciInstitute'. Provided "
|
||||||
|
+ "object is of type '%s'",
|
||||||
|
orgaunit.getClass().getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
final DataQuery publicationsQuery;
|
||||||
|
if (config.getOneRowPerAuthor()) {
|
||||||
|
publicationsQuery =
|
||||||
|
SessionManager.getSession().
|
||||||
|
retrieveQuery(
|
||||||
|
"com.arsdigita.cms.contenttypes.getIdsOfPublicationsForOrgaUnitOneRowPerAuthor");
|
||||||
|
} else {
|
||||||
|
publicationsQuery =
|
||||||
|
SessionManager.getSession().
|
||||||
|
retrieveQuery(
|
||||||
|
"com.arsdigita.cms.contenttypes.getIdsOfPublicationsForOrgaUnit");
|
||||||
|
}
|
||||||
|
final StringBuffer publicationsFilter = new StringBuffer();
|
||||||
|
|
||||||
|
if (config.isMergingPublications()) {
|
||||||
|
final DataQuery departmentsQuery =
|
||||||
|
SessionManager.getSession().retrieveQuery(
|
||||||
|
"com.arsdigita.cms.contenttypes.getIdsOfSubordinateOrgaUnitsRecursivlyWithAssocType");
|
||||||
|
departmentsQuery.setParameter("orgaunitId",
|
||||||
|
orgaunit.getID().toString());
|
||||||
|
departmentsQuery.setParameter("assocType",
|
||||||
|
SciInstituteDepartmentsStep.ASSOC_TYPE);
|
||||||
|
while (departmentsQuery.next()) {
|
||||||
|
if (publicationsFilter.length() > 0) {
|
||||||
|
publicationsFilter.append(" or ");
|
||||||
|
}
|
||||||
|
publicationsFilter.append(String.format("orgaunitId = %s",
|
||||||
|
departmentsQuery.get(
|
||||||
|
"orgaunitId").toString()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
publicationsFilter.append(String.format("orgaunitId = %s",
|
||||||
|
orgaunit.getID().toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
publicationsQuery.addFilter(publicationsFilter.toString());
|
||||||
|
|
||||||
|
logger.debug(String.format(
|
||||||
|
"Got publications of institute '%s'"
|
||||||
|
+ "in '%d ms'. MergeProjects is set to '%b'.",
|
||||||
|
orgaunit.getName(),
|
||||||
|
System.currentTimeMillis() - start,
|
||||||
|
config.isMergingPublications()));
|
||||||
|
return publicationsQuery;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyYearFilter(final DataQuery publications,
|
||||||
|
final HttpServletRequest request) {
|
||||||
|
final String yearValue = request.getParameter(YEAR_PARAM);
|
||||||
|
if ((yearValue != null) && !(yearValue.trim().isEmpty())) {
|
||||||
|
yearFilter.setValue(yearValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
publications.addFilter(yearFilter.getFilter());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyTitleFilter(final DataQuery publications,
|
||||||
|
final HttpServletRequest request) {
|
||||||
|
final String titleValue = request.getParameter(TITLE_PARAM);
|
||||||
|
if ((titleValue != null) && !(titleValue.trim().isEmpty())) {
|
||||||
|
titleFilter.setValue(titleValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
publications.addFilter(titleFilter.getFilter());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyAuthorFilter(final DataQuery publications,
|
||||||
|
final HttpServletRequest request) {
|
||||||
|
final String authorValue = request.getParameter(AUTHOR_PARAM);
|
||||||
|
if ((authorValue != null) && !(authorValue.trim().isEmpty())) {
|
||||||
|
authorFilter.setValue(authorValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
publications.addFilter(authorFilter.getFilter());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generatePublicationXml(final BigDecimal publicationId,
|
||||||
|
final String objectType,
|
||||||
|
final Element parent,
|
||||||
|
final PageState state) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
final ContentPage publication = (ContentPage) DomainObjectFactory.
|
||||||
|
newInstance(new OID(objectType, publicationId));
|
||||||
|
logger.debug(String.format("Got domain object for publication '%s' "
|
||||||
|
+ "in %d ms.",
|
||||||
|
publication.getName(),
|
||||||
|
System.currentTimeMillis() - start));
|
||||||
|
generatePublicationXml(publication, parent, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generatePublicationXml(final ContentPage publication,
|
||||||
|
final Element parent,
|
||||||
|
final PageState state) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
final XmlGenerator generator = new XmlGenerator(publication);
|
||||||
|
generator.generateXML(state, parent, "");
|
||||||
|
logger.debug(String.format(
|
||||||
|
"Generated XML for publication '%s' in %d ms.",
|
||||||
|
publication.getName(),
|
||||||
|
System.currentTimeMillis() - start));
|
||||||
|
}
|
||||||
|
|
||||||
|
private class XmlGenerator extends SimpleXMLGenerator {
|
||||||
|
|
||||||
|
private final ContentItem item;
|
||||||
|
|
||||||
|
public XmlGenerator(final ContentItem item) {
|
||||||
|
super();
|
||||||
|
this.item = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ContentItem getContentItem(final PageState state) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.runtime.AbstractConfig;
|
||||||
|
import com.arsdigita.util.parameter.BooleanParameter;
|
||||||
|
import com.arsdigita.util.parameter.IntegerParameter;
|
||||||
|
import com.arsdigita.util.parameter.Parameter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class SciInstitutePublicationsTabConfig extends AbstractConfig {
|
||||||
|
|
||||||
|
private final Parameter greetingSize;
|
||||||
|
private final Parameter pageSize;
|
||||||
|
private final Parameter enableSearchLimit;
|
||||||
|
private final Parameter mergePublications;
|
||||||
|
private final Parameter oneRowPerAuthor;
|
||||||
|
|
||||||
|
public SciInstitutePublicationsTabConfig() {
|
||||||
|
greetingSize =
|
||||||
|
new IntegerParameter(
|
||||||
|
"com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.greeting_number",
|
||||||
|
Parameter.REQUIRED,
|
||||||
|
10);
|
||||||
|
|
||||||
|
pageSize =
|
||||||
|
new IntegerParameter(
|
||||||
|
"com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.page_size",
|
||||||
|
Parameter.REQUIRED,
|
||||||
|
30);
|
||||||
|
|
||||||
|
enableSearchLimit =
|
||||||
|
new IntegerParameter(
|
||||||
|
"com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.enable_search_limit",
|
||||||
|
Parameter.REQUIRED,
|
||||||
|
2);
|
||||||
|
|
||||||
|
mergePublications =
|
||||||
|
new BooleanParameter(
|
||||||
|
"com.arsdigita.cms.contenttypes.sciinstitutes.tabs.publications.merge",
|
||||||
|
Parameter.REQUIRED,
|
||||||
|
Boolean.TRUE);
|
||||||
|
|
||||||
|
oneRowPerAuthor =
|
||||||
|
new BooleanParameter(
|
||||||
|
"com.arsdigita.cms.contenttypes.sciinstitutes.tabs.publications.one_row_per_author",
|
||||||
|
Parameter.REQUIRED,
|
||||||
|
Boolean.FALSE);
|
||||||
|
|
||||||
|
register(greetingSize);
|
||||||
|
register(pageSize);
|
||||||
|
register(enableSearchLimit);
|
||||||
|
register(mergePublications);
|
||||||
|
register(oneRowPerAuthor);
|
||||||
|
|
||||||
|
loadInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getGreetingSize() {
|
||||||
|
return (Integer) get(greetingSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getPageSize() {
|
||||||
|
return (Integer) get(pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getEnableSearchLimit() {
|
||||||
|
return (Integer) get(enableSearchLimit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean isMergingPublications() {
|
||||||
|
return (Boolean) get(mergePublications);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean getOneRowPerAuthor() {
|
||||||
|
return (Boolean) get(oneRowPerAuthor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.greeting_number.title = Greeting size
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.greeting_number.purpose = Number of publications to show when no a user visits the page with no search parameters set. The publications shown are the n newest publications (determined by begin and end of the publications). Set the 0 to disable the greeting and show a complete list of current publications instead.
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.greeting_number.example = 10
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.greeting_number.format = [Integer]
|
||||||
|
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.page_size.title = Page size
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.page_size.purpose = Maximum number of publications on one page
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.page_size.example = 30
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.page_size.format = [Integer]
|
||||||
|
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.enable_search_limit.title = Search limit
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.enable_search_limit.purpose = Below this limit (number of pages) no search for titles is visible
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.enable_search_limit.example = 2
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.enable_search_limit.format = [Integer]
|
||||||
|
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.merge.title = Merge publications?
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.merge.purpose = Merge the publications of the institute and its sub institutes into one list?
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.merge.example = true
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.merge.format = [Boolean]
|
||||||
|
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.one_row_per_author.title = One row per author?
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.one_row_per_author.purpose = If set to true, the list of publications will contain each publication n times, where n is the number of authors. Only used if the list of publications is sorted by the authors.
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.one_row_per_author.example = false
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.tabs.publications.one_row_per_author.format = [Boolean]
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,277 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitPersonCollection;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitSubordinateCollection;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||||
|
import com.arsdigita.cms.contenttypes.SciInstitute;
|
||||||
|
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||||
|
import com.arsdigita.xml.Element;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class SciInstituteSummaryTab implements GenericOrgaUnitTab {
|
||||||
|
|
||||||
|
private final Logger logger =
|
||||||
|
Logger.getLogger(SciInstituteSummaryTab.class);
|
||||||
|
private final static SciInstituteSummaryTabConfig config =
|
||||||
|
new SciInstituteSummaryTabConfig();
|
||||||
|
|
||||||
|
static {
|
||||||
|
config.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasData(final GenericOrganizationalUnit orgaunit) {
|
||||||
|
//Some of the the data shown by this tab will ever be there
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void generateXml(final GenericOrganizationalUnit orgaunit,
|
||||||
|
final Element parent,
|
||||||
|
final PageState state) {
|
||||||
|
if (!(orgaunit instanceof SciInstitute)) {
|
||||||
|
throw new IllegalArgumentException(String.format(
|
||||||
|
"This tab can only process instances of SciInstitute."
|
||||||
|
+ "The provided object is of type '%s',",
|
||||||
|
orgaunit.getClass().getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
final SciInstitute institute = (SciInstitute) orgaunit;
|
||||||
|
|
||||||
|
final Element instituteSummaryElem = parent.newChildElement(
|
||||||
|
"instituteSummary");
|
||||||
|
|
||||||
|
generateShortDescXml(institute, instituteSummaryElem);
|
||||||
|
|
||||||
|
if (config.isShowingHead()) {
|
||||||
|
generateHeadOfInstituteXml(institute, instituteSummaryElem, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug(String.format("Generated XML for summary tab of institute "
|
||||||
|
+ "'%s' in %d ms.",
|
||||||
|
orgaunit.getName(),
|
||||||
|
System.currentTimeMillis() - start));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void generateShortDescXml(final SciInstitute department,
|
||||||
|
final Element parent) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
if ((department != null)
|
||||||
|
&& !department.getInstituteShortDescription().trim().isEmpty()) {
|
||||||
|
final Element shortDescElem = parent.newChildElement("shortDesc");
|
||||||
|
shortDescElem.setText(department.getInstituteShortDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug(String.format("Generated short desc XML for institute '%s' "
|
||||||
|
+ "in %d ms",
|
||||||
|
department.getName(),
|
||||||
|
System.currentTimeMillis() - start));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void generateHeadOfInstituteXml(final SciInstitute institute,
|
||||||
|
final Element parent,
|
||||||
|
final PageState state) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
final String headRoleStr = config.getHeadRole();
|
||||||
|
final String activeStatusStr = config.getActiveStatus();
|
||||||
|
|
||||||
|
final String[] headRoles = headRoleStr.split(",");
|
||||||
|
final String[] activeStatuses = activeStatusStr.split(",");
|
||||||
|
|
||||||
|
final StringBuffer roleFilter = new StringBuffer();
|
||||||
|
for (String headRole : headRoles) {
|
||||||
|
if (roleFilter.length() > 0) {
|
||||||
|
roleFilter.append(',');
|
||||||
|
}
|
||||||
|
roleFilter.append(String.format("%s = '%s'",
|
||||||
|
GenericOrganizationalUnitPersonCollection.LINK_PERSON_ROLE,
|
||||||
|
headRole));
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuffer statusFilter = new StringBuffer();
|
||||||
|
for (String activeStatus : activeStatuses) {
|
||||||
|
if (statusFilter.length() > 0) {
|
||||||
|
statusFilter.append(",");
|
||||||
|
}
|
||||||
|
statusFilter.append(String.format("%s = '%s'",
|
||||||
|
GenericOrganizationalUnitPersonCollection.LINK_STATUS,
|
||||||
|
activeStatus));
|
||||||
|
}
|
||||||
|
|
||||||
|
final Element headsElem = parent.newChildElement("heads");
|
||||||
|
|
||||||
|
final GenericOrganizationalUnitPersonCollection heads = institute.
|
||||||
|
getPersons();
|
||||||
|
heads.addFilter(roleFilter.toString());
|
||||||
|
heads.addFilter(statusFilter.toString());
|
||||||
|
heads.addOrder("surname");
|
||||||
|
heads.addOrder("givenname");
|
||||||
|
|
||||||
|
while (heads.next()) {
|
||||||
|
generateMemberXml(heads.getPerson(), headsElem, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug(String.format("Generated head of department XML for institute '%s' "
|
||||||
|
+ "in %d ms",
|
||||||
|
institute.getName(),
|
||||||
|
System.currentTimeMillis() - start));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void generateHeadOfDepartmentXml(
|
||||||
|
final GenericOrganizationalUnit department,
|
||||||
|
final Element parent,
|
||||||
|
final PageState state) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
final String headRoleStr = config.getHeadRole();
|
||||||
|
final String activeStatusStr = config.getActiveStatus();
|
||||||
|
|
||||||
|
final String[] headRoles = headRoleStr.split(",");
|
||||||
|
final String[] activeStatuses = activeStatusStr.split(",");
|
||||||
|
|
||||||
|
final StringBuffer roleFilter = new StringBuffer();
|
||||||
|
for (String headRole : headRoles) {
|
||||||
|
if (roleFilter.length() > 0) {
|
||||||
|
roleFilter.append(',');
|
||||||
|
}
|
||||||
|
roleFilter.append(String.format("%s = '%s'",
|
||||||
|
GenericOrganizationalUnitPersonCollection.LINK_PERSON_ROLE,
|
||||||
|
headRole));
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuffer statusFilter = new StringBuffer();
|
||||||
|
for (String activeStatus : activeStatuses) {
|
||||||
|
if (statusFilter.length() > 0) {
|
||||||
|
statusFilter.append(",");
|
||||||
|
}
|
||||||
|
statusFilter.append(String.format("%s = '%s'",
|
||||||
|
GenericOrganizationalUnitPersonCollection.LINK_STATUS,
|
||||||
|
activeStatus));
|
||||||
|
}
|
||||||
|
|
||||||
|
final Element headsElem = parent.newChildElement("heads");
|
||||||
|
|
||||||
|
final GenericOrganizationalUnitPersonCollection heads = department.
|
||||||
|
getPersons();
|
||||||
|
heads.addFilter(roleFilter.toString());
|
||||||
|
heads.addFilter(statusFilter.toString());
|
||||||
|
heads.addOrder("surname");
|
||||||
|
heads.addOrder("givenname");
|
||||||
|
|
||||||
|
while (heads.next()) {
|
||||||
|
generateMemberXml(heads.getPerson(), headsElem, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug(String.format("Generated head of department XML for department '%s' "
|
||||||
|
+ "in %d ms",
|
||||||
|
department.getName(),
|
||||||
|
System.currentTimeMillis() - start));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void generateDepartmentsXml(final SciInstitute institute,
|
||||||
|
final Element parent,
|
||||||
|
final PageState state) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
final GenericOrganizationalUnitSubordinateCollection departments =
|
||||||
|
institute.
|
||||||
|
getSubordinateOrgaUnits();
|
||||||
|
departments.addFilter(
|
||||||
|
String.format("%s = '%s",
|
||||||
|
GenericOrganizationalUnitSubordinateCollection.LINK_ASSOCTYPE,
|
||||||
|
SciInstituteDepartmentsStep.ASSOC_TYPE));
|
||||||
|
|
||||||
|
final Element subDepsElem = parent.newChildElement("departments");
|
||||||
|
|
||||||
|
while (departments.next()) {
|
||||||
|
generateDepartmentXml(
|
||||||
|
departments.getGenericOrganizationalUnit(),
|
||||||
|
subDepsElem,
|
||||||
|
state);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug(String.format("Generated sub departments XML for institute '%s' "
|
||||||
|
+ "in %d ms",
|
||||||
|
institute.getName(),
|
||||||
|
System.currentTimeMillis() - start));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void generateDepartmentXml(
|
||||||
|
final GenericOrganizationalUnit orgaunit,
|
||||||
|
final Element parent,
|
||||||
|
final PageState state) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
if (!(orgaunit.getClass().getName().equals(
|
||||||
|
"com.arsdigita.cms.contenttypes.SciDepartment"))) {
|
||||||
|
throw new IllegalArgumentException(String.format(
|
||||||
|
"Can't process "
|
||||||
|
+ "orgaunit '%s' as department because the orgaunit is "
|
||||||
|
+ "not a SciDepartment but of type '%s'.",
|
||||||
|
orgaunit.getName(),
|
||||||
|
orgaunit.getClass().
|
||||||
|
getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
final GenericOrganizationalUnit department = orgaunit;
|
||||||
|
|
||||||
|
final Element subDepElem = parent.newChildElement("department");
|
||||||
|
subDepElem.addAttribute("oid", department.getOID().toString());
|
||||||
|
final Element nameElem = subDepElem.newChildElement("title");
|
||||||
|
nameElem.setText(department.getTitle());
|
||||||
|
|
||||||
|
generateHeadOfDepartmentXml(department, subDepElem, state);
|
||||||
|
|
||||||
|
logger.debug(String.format("Generated XML for department '%s' "
|
||||||
|
+ "in %d ms",
|
||||||
|
orgaunit.getName(),
|
||||||
|
System.currentTimeMillis() - start));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void generateMemberXml(final BigDecimal memberId,
|
||||||
|
final Element parent,
|
||||||
|
final PageState state) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
final GenericPerson member = new GenericPerson(memberId);
|
||||||
|
logger.debug(String.format("Got domain object for member '%s' "
|
||||||
|
+ "in %d ms.",
|
||||||
|
member.getFullName(),
|
||||||
|
System.currentTimeMillis() - start));
|
||||||
|
generateMemberXml(member, parent, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void generateMemberXml(final GenericPerson member,
|
||||||
|
final Element parent,
|
||||||
|
final PageState state) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
final XmlGenerator generator = new XmlGenerator(member);
|
||||||
|
generator.setUseExtraXml(false);
|
||||||
|
generator.generateXML(state, parent, "");
|
||||||
|
logger.debug(String.format("Generated XML for member '%s' in %d ms.",
|
||||||
|
member.getFullName(),
|
||||||
|
System.currentTimeMillis() - start));
|
||||||
|
}
|
||||||
|
|
||||||
|
private class XmlGenerator extends SimpleXMLGenerator {
|
||||||
|
|
||||||
|
private final ContentItem item;
|
||||||
|
|
||||||
|
public XmlGenerator(final ContentItem item) {
|
||||||
|
super();
|
||||||
|
this.item = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ContentItem getContentItem(final PageState state) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.runtime.AbstractConfig;
|
||||||
|
import com.arsdigita.util.parameter.BooleanParameter;
|
||||||
|
import com.arsdigita.util.parameter.Parameter;
|
||||||
|
import com.arsdigita.util.parameter.StringParameter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class SciInstituteSummaryTabConfig extends AbstractConfig {
|
||||||
|
|
||||||
|
private final Parameter showHeads;
|
||||||
|
private final Parameter headRole;
|
||||||
|
private final Parameter activeStatus;
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
|
register(showHeads);
|
||||||
|
register(headRole);
|
||||||
|
register(activeStatus);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.summarytab.heads.show.title = Show heads of institute in summary tab?
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.summarytab.heads.show.purpose = Show heads of institute in summary tab?
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.summarytab.heads.show.example = true
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.summarytab.heads.show.format = [Boolean]
|
||||||
|
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.summarytab.heads.role = Role of the heads of the institute
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.summarytab.heads.role = Role of the heads of the institute. This is an attribute of the association between GenericOrganizationalUnit and GenericPerson. This value may contains more than value, separated by ','.
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.summarytab.heads.role = active,heading
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.summarytab.heads.role = [String]
|
||||||
|
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.summarytab.heads.status.active = Status of active members
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.summarytab.heads.status.active = Status of the active members of the institute. 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.sciinstitute.summarytab.heads.status.active = former,formerHead
|
||||||
|
com.arsdigita.cms.contenttypes.sciinstitute.summarytab.heads.status.active = [String]
|
||||||
Loading…
Reference in New Issue