Tabs für SciInstitute funktionieren wieder (Ticket #1228)
git-svn-id: https://svn.libreccm.org/ccm/trunk@1618 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
0196a570cd
commit
0ad0fbd6ff
|
|
@ -162,11 +162,9 @@ public class SelectFilter implements Filter {
|
||||||
optionsSet = new HashSet<String>();
|
optionsSet = new HashSet<String>();
|
||||||
|
|
||||||
while (dataQuery.next()) {
|
while (dataQuery.next()) {
|
||||||
if (dataQuery instanceof DataCollection) {
|
|
||||||
obj = ((DataCollection) dataQuery.get(queryProperty));
|
obj = dataQuery.get(queryProperty);
|
||||||
} else {
|
|
||||||
obj = dataQuery.get(queryProperty);
|
|
||||||
}
|
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,6 @@ public class SciDepartmentMembersTab implements GenericOrgaUnitTab {
|
||||||
final DataCollection persons = getData(orgaunit, state);
|
final DataCollection persons = getData(orgaunit, state);
|
||||||
final HttpServletRequest request = state.getRequest();
|
final HttpServletRequest request = state.getRequest();
|
||||||
|
|
||||||
//applyStatusFilter(persons, request);
|
|
||||||
applySurnameFilter(persons, request);
|
applySurnameFilter(persons, request);
|
||||||
|
|
||||||
final Element depMembersElem = parent.newChildElement(
|
final Element depMembersElem = parent.newChildElement(
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ public class SciDepartmentProjectsTab implements GenericOrgaUnitTab {
|
||||||
orgaunitIds.add(subDepartmentsQuery.get("orgaunitId").toString());
|
orgaunitIds.add(subDepartmentsQuery.get("orgaunitId").toString());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
orgaunitIds.add(orgaunit.getID().toString());
|
orgaunitIds.add(orgaunit.getContentBundle().getID().toString());
|
||||||
}
|
}
|
||||||
projectBundlesQuery.setParameter("orgaunitIds", orgaunitIds);
|
projectBundlesQuery.setParameter("orgaunitIds", orgaunitIds);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ public class SciDepartmentPublicationsTab implements GenericOrgaUnitTab {
|
||||||
private static final String YEAR_PARAM = "yearOfPublication";
|
private static final String YEAR_PARAM = "yearOfPublication";
|
||||||
private static final String TITLE_PARAM = "title";
|
private static final String TITLE_PARAM = "title";
|
||||||
private static final String AUTHOR_PARAM = "author";
|
private static final String AUTHOR_PARAM = "author";
|
||||||
private final SelectFilter yearFilter = new SelectFilter("year",
|
private final SelectFilter yearFilter = new SelectFilter(YEAR_PARAM,
|
||||||
YEAR_PARAM,
|
YEAR_PARAM,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
|
|
@ -107,7 +107,6 @@ public class SciDepartmentPublicationsTab implements GenericOrgaUnitTab {
|
||||||
if (((yearValue == null) || yearValue.trim().isEmpty())
|
if (((yearValue == null) || yearValue.trim().isEmpty())
|
||||||
&& ((titleValue == null) || titleValue.trim().isEmpty())
|
&& ((titleValue == null) || titleValue.trim().isEmpty())
|
||||||
&& ((authorValue == null) || authorValue.trim().isEmpty())) {
|
&& ((authorValue == null) || authorValue.trim().isEmpty())) {
|
||||||
//&& ((sortValue == null) || sortValue.trim().isEmpty())) {
|
|
||||||
|
|
||||||
depPublicationsElem.newChildElement("greeting");
|
depPublicationsElem.newChildElement("greeting");
|
||||||
|
|
||||||
|
|
@ -119,14 +118,13 @@ public class SciDepartmentPublicationsTab implements GenericOrgaUnitTab {
|
||||||
|
|
||||||
publications.addOrder("title asc");
|
publications.addOrder("title asc");
|
||||||
|
|
||||||
publications.setRange(1, config.getGreetingSize() + 1);
|
|
||||||
|
|
||||||
yearFilter.setDataQuery(publications, YEAR_PARAM);
|
yearFilter.setDataQuery(publications, YEAR_PARAM);
|
||||||
|
|
||||||
yearFilter.generateXml(filtersElem);
|
yearFilter.generateXml(filtersElem);
|
||||||
titleFilter.generateXml(filtersElem);
|
titleFilter.generateXml(filtersElem);
|
||||||
authorFilter.generateXml(filtersElem);
|
authorFilter.generateXml(filtersElem);
|
||||||
|
|
||||||
|
publications.setRange(1, config.getGreetingSize() + 1);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
publications.addOrder("yearOfPublication desc");
|
publications.addOrder("yearOfPublication desc");
|
||||||
|
|
@ -205,8 +203,7 @@ public class SciDepartmentPublicationsTab implements GenericOrgaUnitTab {
|
||||||
final DataQuery publicationBundlesQuery;
|
final DataQuery publicationBundlesQuery;
|
||||||
|
|
||||||
publicationBundlesQuery =
|
publicationBundlesQuery =
|
||||||
SessionManager.getSession().retrieveQuery(
|
SessionManager.getSession().retrieveQuery("com.arsdigita.cms.contenttypes.getIdsOfPublicationsForOrgaUnit");
|
||||||
"com.arsdigita.cms.contenttypes.getIdsOfPublicationsForOrgaUnit");
|
|
||||||
final List<String> orgaunitIds = new ArrayList<String>();
|
final List<String> orgaunitIds = new ArrayList<String>();
|
||||||
|
|
||||||
if (config.isMergingPublications()) {
|
if (config.isMergingPublications()) {
|
||||||
|
|
@ -221,7 +218,7 @@ public class SciDepartmentPublicationsTab implements GenericOrgaUnitTab {
|
||||||
orgaunitIds.add(subDepartmentsQuery.get("orgaunitId").toString());
|
orgaunitIds.add(subDepartmentsQuery.get("orgaunitId").toString());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
orgaunitIds.add(orgaunit.getID().toString());
|
orgaunitIds.add(orgaunit.getContentBundle().getID().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
publicationBundlesQuery.setParameter("orgaunitIds", orgaunitIds);
|
publicationBundlesQuery.setParameter("orgaunitIds", orgaunitIds);
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import com.arsdigita.cms.contenttypes.ui.panels.Paginator;
|
||||||
import com.arsdigita.cms.contenttypes.ui.panels.TextFilter;
|
import com.arsdigita.cms.contenttypes.ui.panels.TextFilter;
|
||||||
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||||
import com.arsdigita.globalization.Globalization;
|
import com.arsdigita.globalization.Globalization;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.persistence.DataQuery;
|
import com.arsdigita.persistence.DataQuery;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
|
|
@ -61,8 +62,8 @@ public class SciInstituteMembersTab implements GenericOrgaUnitTab {
|
||||||
&& orgaunit.getPersons().size() > 0) {
|
&& orgaunit.getPersons().size() > 0) {
|
||||||
return true;
|
return true;
|
||||||
} else if (config.isMergingMembers()) {
|
} else if (config.isMergingMembers()) {
|
||||||
final DataQuery persons = getData(orgaunit);
|
final DataCollection persons = getData(orgaunit, state);
|
||||||
return persons.isEmpty();
|
return (persons != null) && !persons.isEmpty();
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -72,10 +73,10 @@ public class SciInstituteMembersTab implements GenericOrgaUnitTab {
|
||||||
final Element parent,
|
final Element parent,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
final DataQuery persons = getData(orgaunit);
|
final DataCollection persons = getData(orgaunit, state);
|
||||||
final HttpServletRequest request = state.getRequest();
|
final HttpServletRequest request = state.getRequest();
|
||||||
|
|
||||||
applyStatusFilter(persons, request);
|
//applyStatusFilter(persons, request);
|
||||||
applySurnameFilter(persons, request);
|
applySurnameFilter(persons, request);
|
||||||
|
|
||||||
final Element depMembersElem = parent.newChildElement(
|
final Element depMembersElem = parent.newChildElement(
|
||||||
|
|
@ -109,7 +110,7 @@ public class SciInstituteMembersTab implements GenericOrgaUnitTab {
|
||||||
paginator.generateXml(depMembersElem);
|
paginator.generateXml(depMembersElem);
|
||||||
|
|
||||||
while (persons.next()) {
|
while (persons.next()) {
|
||||||
generateMemberXml((BigDecimal) persons.get("memberId"),
|
generateMemberXml(new GenericPerson(persons.getDataObject()),
|
||||||
depMembersElem,
|
depMembersElem,
|
||||||
state);
|
state);
|
||||||
}
|
}
|
||||||
|
|
@ -120,7 +121,8 @@ public class SciInstituteMembersTab implements GenericOrgaUnitTab {
|
||||||
System.currentTimeMillis() - start));
|
System.currentTimeMillis() - start));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DataQuery getData(final GenericOrganizationalUnit orgaunit) {
|
protected DataCollection getData(final GenericOrganizationalUnit orgaunit,
|
||||||
|
final PageState state) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
|
|
||||||
if (!(orgaunit instanceof SciInstitute)) {
|
if (!(orgaunit instanceof SciInstitute)) {
|
||||||
|
|
@ -131,10 +133,9 @@ public class SciInstituteMembersTab implements GenericOrgaUnitTab {
|
||||||
orgaunit.getClass().getName()));
|
orgaunit.getClass().getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
final DataQuery personsQuery = SessionManager.getSession().
|
final DataQuery personBundlesQuery = SessionManager.getSession().
|
||||||
retrieveQuery(
|
retrieveQuery(
|
||||||
"com.arsdigita.cms.contenttypes.getIdsOfMembersOfOrgaUnits");
|
"com.arsdigita.cms.contenttypes.getIdsOfMembersOfOrgaUnits");
|
||||||
//final StringBuffer personsFilter = new StringBuffer();
|
|
||||||
final List<String> orgaunitsIds = new ArrayList<String>();
|
final List<String> orgaunitsIds = new ArrayList<String>();
|
||||||
|
|
||||||
if (config.isMergingMembers()) {
|
if (config.isMergingMembers()) {
|
||||||
|
|
@ -142,30 +143,38 @@ public class SciInstituteMembersTab implements GenericOrgaUnitTab {
|
||||||
SessionManager.getSession().retrieveQuery(
|
SessionManager.getSession().retrieveQuery(
|
||||||
"com.arsdigita.cms.contenttypes.getIdsOfSubordinateOrgaUnitsRecursivlyWithAssocType");
|
"com.arsdigita.cms.contenttypes.getIdsOfSubordinateOrgaUnitsRecursivlyWithAssocType");
|
||||||
departmentsQuery.setParameter("orgaunitId",
|
departmentsQuery.setParameter("orgaunitId",
|
||||||
orgaunit.getID().toString());
|
orgaunit.getContentBundle().getID().toString());
|
||||||
departmentsQuery.setParameter("assocType",
|
departmentsQuery.setParameter("assocType",
|
||||||
SciInstituteDepartmentsStep.ASSOC_TYPE);
|
SciInstituteDepartmentsStep.ASSOC_TYPE);
|
||||||
|
|
||||||
while (departmentsQuery.next()) {
|
while (departmentsQuery.next()) {
|
||||||
/*if (personsFilter.length() > 0) {
|
|
||||||
personsFilter.append(" or ");
|
|
||||||
}
|
|
||||||
personsFilter.append(String.format("orgaunitId = %s",
|
|
||||||
departmentsQuery.get(
|
|
||||||
"orgaunitId").toString()));*/
|
|
||||||
orgaunitsIds.add(departmentsQuery.get("orgaunitId").toString());
|
orgaunitsIds.add(departmentsQuery.get("orgaunitId").toString());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*personsFilter.append(String.format("orgaunitId = %s",
|
orgaunitsIds.add(orgaunit.getContentBundle().getID().toString());
|
||||||
orgaunit.getID().toString()));*/
|
|
||||||
orgaunitsIds.add(orgaunit.getID().toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//personsQuery.addFilter(personsFilter.toString());
|
personBundlesQuery.setParameter("orgaunitIds", orgaunitsIds);
|
||||||
personsQuery.setParameter("orgaunitIds", orgaunitsIds);
|
applyStatusFilter(personBundlesQuery, state.getRequest());
|
||||||
|
|
||||||
personsQuery.addOrder(GenericPerson.SURNAME);
|
final StringBuilder filterBuilder = new StringBuilder();
|
||||||
personsQuery.addOrder(GenericPerson.GIVENNAME);
|
while(personBundlesQuery.next()) {
|
||||||
|
if (filterBuilder.length() > 0) {
|
||||||
|
filterBuilder.append(',');
|
||||||
|
}
|
||||||
|
filterBuilder.append(personBundlesQuery.get("memberId").toString());
|
||||||
|
}
|
||||||
|
final DataCollection membersQuery = SessionManager.getSession().retrieve(GenericPerson.BASE_DATA_OBJECT_TYPE);
|
||||||
|
|
||||||
|
if (filterBuilder.length() == 0) {
|
||||||
|
//No members, return null to indicate
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
membersQuery.addFilter(String.format("parent.id in (%s)", filterBuilder.toString()));
|
||||||
|
|
||||||
|
membersQuery.addOrder(GenericPerson.SURNAME);
|
||||||
|
membersQuery.addOrder(GenericPerson.GIVENNAME);
|
||||||
|
|
||||||
logger.debug(String.format(
|
logger.debug(String.format(
|
||||||
"Got members of institute '%s'"
|
"Got members of institute '%s'"
|
||||||
|
|
@ -173,7 +182,7 @@ public class SciInstituteMembersTab implements GenericOrgaUnitTab {
|
||||||
orgaunit.getName(),
|
orgaunit.getName(),
|
||||||
System.currentTimeMillis() - start,
|
System.currentTimeMillis() - start,
|
||||||
config.isMergingMembers()));
|
config.isMergingMembers()));
|
||||||
return personsQuery;
|
return membersQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyStatusFilter(final DataQuery persons,
|
private void applyStatusFilter(final DataQuery persons,
|
||||||
|
|
@ -219,7 +228,7 @@ public class SciInstituteMembersTab implements GenericOrgaUnitTab {
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
final XmlGenerator generator = new XmlGenerator(member);
|
final XmlGenerator generator = new XmlGenerator(member);
|
||||||
generator.setUseExtraXml(false);
|
//generator.setUseExtraXml(false);
|
||||||
generator.setItemElemName("member", "");
|
generator.setItemElemName("member", "");
|
||||||
generator.generateXML(state, parent, "");
|
generator.generateXML(state, parent, "");
|
||||||
logger.debug(String.format("Generated XML for member '%s' in %d ms.",
|
logger.debug(String.format("Generated XML for member '%s' in %d ms.",
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,12 @@ import com.arsdigita.cms.contenttypes.ui.panels.TextFilter;
|
||||||
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||||
import com.arsdigita.domain.DomainObjectFactory;
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
import com.arsdigita.globalization.Globalization;
|
import com.arsdigita.globalization.Globalization;
|
||||||
|
import com.arsdigita.globalization.GlobalizationHelper;
|
||||||
|
import com.arsdigita.kernel.Kernel;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.persistence.DataQuery;
|
import com.arsdigita.persistence.DataQuery;
|
||||||
|
import com.arsdigita.persistence.Filter;
|
||||||
|
import com.arsdigita.persistence.FilterFactory;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
|
|
@ -73,6 +78,8 @@ public class SciInstituteProjectsTab implements GenericOrgaUnitTab {
|
||||||
public boolean hasData(final GenericOrganizationalUnit orgaunit,
|
public boolean hasData(final GenericOrganizationalUnit orgaunit,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
//Check if SciProject is installed
|
||||||
final ContentTypeCollection types = ContentType.getAllContentTypes();
|
final ContentTypeCollection types = ContentType.getAllContentTypes();
|
||||||
types.addFilter(
|
types.addFilter(
|
||||||
"associatedObjectType = 'com.arsdigita.cms.contenttypes.SciProject'");
|
"associatedObjectType = 'com.arsdigita.cms.contenttypes.SciProject'");
|
||||||
|
|
@ -82,7 +89,9 @@ public class SciInstituteProjectsTab implements GenericOrgaUnitTab {
|
||||||
}
|
}
|
||||||
types.close();
|
types.close();
|
||||||
|
|
||||||
final boolean result = !getData(orgaunit).isEmpty();
|
//Check if we have projects to show
|
||||||
|
final DataCollection data = getData(orgaunit);
|
||||||
|
final boolean result = (data != null) && !data.isEmpty();
|
||||||
|
|
||||||
logger.debug(String.format("Needed %d ms to determine if institute "
|
logger.debug(String.format("Needed %d ms to determine if institute "
|
||||||
+ "'%s' has projects.",
|
+ "'%s' has projects.",
|
||||||
|
|
@ -96,7 +105,7 @@ public class SciInstituteProjectsTab implements GenericOrgaUnitTab {
|
||||||
final Element parent,
|
final Element parent,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
final DataQuery projects = getData(orgaunit);
|
final DataCollection projects = getData(orgaunit);
|
||||||
final HttpServletRequest request = state.getRequest();
|
final HttpServletRequest request = state.getRequest();
|
||||||
|
|
||||||
final Element depProjectsElem = parent.newChildElement(
|
final Element depProjectsElem = parent.newChildElement(
|
||||||
|
|
@ -173,7 +182,7 @@ public class SciInstituteProjectsTab implements GenericOrgaUnitTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
while (projects.next()) {
|
while (projects.next()) {
|
||||||
generateProjectXml((BigDecimal) projects.get("projectId"),
|
generateProjectXml((BigDecimal) projects.get("id"),
|
||||||
depProjectsElem,
|
depProjectsElem,
|
||||||
state);
|
state);
|
||||||
}
|
}
|
||||||
|
|
@ -184,7 +193,7 @@ public class SciInstituteProjectsTab implements GenericOrgaUnitTab {
|
||||||
System.currentTimeMillis() - start));
|
System.currentTimeMillis() - start));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DataQuery getData(final GenericOrganizationalUnit orgaunit) {
|
protected DataCollection getData(final GenericOrganizationalUnit orgaunit) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
|
|
||||||
if (!(orgaunit instanceof SciInstitute)) {
|
if (!(orgaunit instanceof SciInstitute)) {
|
||||||
|
|
@ -195,10 +204,9 @@ public class SciInstituteProjectsTab implements GenericOrgaUnitTab {
|
||||||
orgaunit.getClass().getName()));
|
orgaunit.getClass().getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
final DataQuery projectsQuery = SessionManager.getSession().
|
final DataQuery projectBundlesQuery = SessionManager.getSession().
|
||||||
retrieveQuery(
|
retrieveQuery(
|
||||||
"com.arsdigita.cms.contenttypes.getIdsOfProjectsOfOrgaUnit");
|
"com.arsdigita.cms.contenttypes.getIdsOfProjectsOfOrgaUnit");
|
||||||
//final StringBuffer projectsFilter = new StringBuffer();
|
|
||||||
final List<String> orgaunitIds = new ArrayList<String>();
|
final List<String> orgaunitIds = new ArrayList<String>();
|
||||||
|
|
||||||
if (config.isMergingProjects()) {
|
if (config.isMergingProjects()) {
|
||||||
|
|
@ -206,27 +214,47 @@ public class SciInstituteProjectsTab implements GenericOrgaUnitTab {
|
||||||
SessionManager.getSession().retrieveQuery(
|
SessionManager.getSession().retrieveQuery(
|
||||||
"com.arsdigita.cms.contenttypes.getIdsOfSubordinateOrgaUnitsRecursivlyWithAssocType");
|
"com.arsdigita.cms.contenttypes.getIdsOfSubordinateOrgaUnitsRecursivlyWithAssocType");
|
||||||
subDepartmentsQuery.setParameter("orgaunitId",
|
subDepartmentsQuery.setParameter("orgaunitId",
|
||||||
orgaunit.getID().toString());
|
orgaunit.getContentBundle().getID().toString());
|
||||||
subDepartmentsQuery.setParameter("assocType",
|
subDepartmentsQuery.setParameter("assocType",
|
||||||
SciInstituteDepartmentsStep.ASSOC_TYPE);
|
SciInstituteDepartmentsStep.ASSOC_TYPE);
|
||||||
|
|
||||||
while (subDepartmentsQuery.next()) {
|
while (subDepartmentsQuery.next()) {
|
||||||
/*if (projectsFilter.length() > 0) {
|
|
||||||
projectsFilter.append(" or ");
|
|
||||||
}
|
|
||||||
projectsFilter.append(String.format("orgaunitId = %s",
|
|
||||||
subDepartmentsQuery.get(
|
|
||||||
"orgaunitId").toString()));*/
|
|
||||||
orgaunitIds.add(subDepartmentsQuery.get("orgaunitId").toString());
|
orgaunitIds.add(subDepartmentsQuery.get("orgaunitId").toString());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*projectsFilter.append(String.format("orgaunitId = %s",
|
orgaunitIds.add(orgaunit.getContentBundle().getID().toString());
|
||||||
orgaunit.getID().toString()));*/
|
}
|
||||||
orgaunitIds.add(orgaunit.getID().toString());
|
projectBundlesQuery.setParameter("orgaunitIds", orgaunitIds);
|
||||||
|
|
||||||
|
final StringBuilder filterBuilder = new StringBuilder();
|
||||||
|
while (projectBundlesQuery.next()) {
|
||||||
|
if (filterBuilder.length() > 0) {
|
||||||
|
filterBuilder.append(',');
|
||||||
|
}
|
||||||
|
filterBuilder.append(projectBundlesQuery.get("projectId").toString());
|
||||||
|
}
|
||||||
|
final DataCollection projectsQuery = SessionManager.getSession().retrieve(
|
||||||
|
"com.arsdigita.cms.contenttypes.SciProject");
|
||||||
|
|
||||||
|
if (filterBuilder.length() == 0) {
|
||||||
|
//No projects, return null to indicate
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//projectsQuery.addFilter(projectsFilter.toString());
|
projectsQuery.addFilter(String.format("parent.id in (%s)", filterBuilder.toString()));
|
||||||
projectsQuery.setParameter("orgaunitIds", orgaunitIds);
|
|
||||||
|
if (Kernel.getConfig().languageIndependentItems()) {
|
||||||
|
final FilterFactory filterFactory = projectsQuery.getFilterFactory();
|
||||||
|
final Filter filter = filterFactory.or().
|
||||||
|
addFilter(filterFactory.equals("language", GlobalizationHelper.getNegotiatedLocale().getLanguage())).
|
||||||
|
addFilter(filterFactory.and().
|
||||||
|
addFilter(filterFactory.equals("language", GlobalizationHelper.LANG_INDEPENDENT)).
|
||||||
|
addFilter(filterFactory.notIn("parent", "com.arsdigita.navigation.getParentIDsOfMatchedItems").set(
|
||||||
|
"language", GlobalizationHelper.getNegotiatedLocale().getLanguage())));
|
||||||
|
projectsQuery.addFilter(filter);
|
||||||
|
} else {
|
||||||
|
projectsQuery.addEqualsFilter("language", GlobalizationHelper.getNegotiatedLocale().getLanguage());
|
||||||
|
}
|
||||||
|
|
||||||
logger.debug(String.format(
|
logger.debug(String.format(
|
||||||
"Got projects of institute '%s'"
|
"Got projects of institute '%s'"
|
||||||
|
|
@ -269,8 +297,7 @@ public class SciInstituteProjectsTab implements GenericOrgaUnitTab {
|
||||||
final Element parent,
|
final Element parent,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
final ContentPage project = (ContentPage) DomainObjectFactory.
|
final ContentPage project = (ContentPage) DomainObjectFactory.newInstance(new OID(
|
||||||
newInstance(new OID(
|
|
||||||
"com.arsdigita.cms.contenttypes.SciProject", projectId));
|
"com.arsdigita.cms.contenttypes.SciProject", projectId));
|
||||||
logger.debug(String.format("Got domain object for project '%s' "
|
logger.debug(String.format("Got domain object for project '%s' "
|
||||||
+ "in %d ms.",
|
+ "in %d ms.",
|
||||||
|
|
@ -305,5 +332,6 @@ public class SciInstituteProjectsTab implements GenericOrgaUnitTab {
|
||||||
protected ContentItem getContentItem(final PageState state) {
|
protected ContentItem getContentItem(final PageState state) {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,12 @@ import com.arsdigita.cms.contenttypes.ui.panels.TextFilter;
|
||||||
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||||
import com.arsdigita.domain.DomainObjectFactory;
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
import com.arsdigita.globalization.Globalization;
|
import com.arsdigita.globalization.Globalization;
|
||||||
|
import com.arsdigita.globalization.GlobalizationHelper;
|
||||||
|
import com.arsdigita.kernel.Kernel;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.persistence.DataQuery;
|
import com.arsdigita.persistence.DataQuery;
|
||||||
|
import com.arsdigita.persistence.Filter;
|
||||||
|
import com.arsdigita.persistence.FilterFactory;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
|
|
@ -34,14 +39,9 @@ public class SciInstitutePublicationsTab implements GenericOrgaUnitTab {
|
||||||
SciInstitutePublicationsTab.class);
|
SciInstitutePublicationsTab.class);
|
||||||
private static final SciInstitutePublicationsTabConfig config =
|
private static final SciInstitutePublicationsTabConfig config =
|
||||||
new SciInstitutePublicationsTabConfig();
|
new SciInstitutePublicationsTabConfig();
|
||||||
private static final String YEAR_PARAM = "year";
|
private static final String YEAR_PARAM = "yearOfPublication";
|
||||||
private static final String TITLE_PARAM = "title";
|
private static final String TITLE_PARAM = "title";
|
||||||
private static final String AUTHOR_PARAM = "author";
|
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,
|
private final SelectFilter yearFilter = new SelectFilter(YEAR_PARAM,
|
||||||
YEAR_PARAM,
|
YEAR_PARAM,
|
||||||
true,
|
true,
|
||||||
|
|
@ -62,11 +62,7 @@ public class SciInstitutePublicationsTab implements GenericOrgaUnitTab {
|
||||||
public SciInstitutePublicationsTab() {
|
public SciInstitutePublicationsTab() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
if (config.getOneRowPerAuthor()) {
|
authorFilter = new TextFilter(AUTHOR_PARAM, "authorsStr");
|
||||||
authorFilter = new TextFilter(AUTHOR_PARAM, "authorSurname");
|
|
||||||
} else {
|
|
||||||
authorFilter = new TextFilter(AUTHOR_PARAM, "authors");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExcludeWorkingPapers(final boolean excludeWorkingPapers) {
|
public void setExcludeWorkingPapers(final boolean excludeWorkingPapers) {
|
||||||
|
|
@ -81,6 +77,7 @@ public class SciInstitutePublicationsTab implements GenericOrgaUnitTab {
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
//Check if ccm-sci-publications is installed
|
||||||
final ContentTypeCollection types = ContentType.getAllContentTypes();
|
final ContentTypeCollection types = ContentType.getAllContentTypes();
|
||||||
types.addFilter(
|
types.addFilter(
|
||||||
"associatedObjectType = 'com.arsdigita.cms.contenttypes.Publication'");
|
"associatedObjectType = 'com.arsdigita.cms.contenttypes.Publication'");
|
||||||
|
|
@ -90,7 +87,8 @@ public class SciInstitutePublicationsTab implements GenericOrgaUnitTab {
|
||||||
}
|
}
|
||||||
types.close();
|
types.close();
|
||||||
|
|
||||||
final boolean result = !getData(orgaunit).isEmpty();
|
final DataCollection data = getData(orgaunit);
|
||||||
|
final boolean result = (data != null) && !data.isEmpty();
|
||||||
|
|
||||||
logger.debug(String.format("Needed %d ms to determine if institute "
|
logger.debug(String.format("Needed %d ms to determine if institute "
|
||||||
+ "'%s' has publications.",
|
+ "'%s' has publications.",
|
||||||
|
|
@ -103,7 +101,7 @@ public class SciInstitutePublicationsTab implements GenericOrgaUnitTab {
|
||||||
final Element parent,
|
final Element parent,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
final DataQuery publications = getData(orgaunit);
|
final DataCollection publications = getData(orgaunit);
|
||||||
final HttpServletRequest request = state.getRequest();
|
final HttpServletRequest request = state.getRequest();
|
||||||
|
|
||||||
final Element publicationsElem = parent.newChildElement(
|
final Element publicationsElem = parent.newChildElement(
|
||||||
|
|
@ -112,7 +110,6 @@ public class SciInstitutePublicationsTab implements GenericOrgaUnitTab {
|
||||||
final String yearValue = Globalization.decodeParameter(request, YEAR_PARAM);
|
final String yearValue = Globalization.decodeParameter(request, YEAR_PARAM);
|
||||||
final String titleValue = Globalization.decodeParameter(request, TITLE_PARAM);
|
final String titleValue = Globalization.decodeParameter(request, TITLE_PARAM);
|
||||||
final String authorValue = Globalization.decodeParameter(request, AUTHOR_PARAM);
|
final String authorValue = Globalization.decodeParameter(request, AUTHOR_PARAM);
|
||||||
//final String sortValue = Globalization.decodeParameter(request, SORT_PARAM);
|
|
||||||
|
|
||||||
final Element filtersElem = publicationsElem.newChildElement(
|
final Element filtersElem = publicationsElem.newChildElement(
|
||||||
"filters");
|
"filters");
|
||||||
|
|
@ -138,29 +135,17 @@ public class SciInstitutePublicationsTab implements GenericOrgaUnitTab {
|
||||||
|| SelectFilter.NONE.equals(yearValue))
|
|| SelectFilter.NONE.equals(yearValue))
|
||||||
&& ((titleValue == null) || titleValue.trim().isEmpty())
|
&& ((titleValue == null) || titleValue.trim().isEmpty())
|
||||||
&& ((authorValue == null) || authorValue.trim().isEmpty())) {
|
&& ((authorValue == null) || authorValue.trim().isEmpty())) {
|
||||||
// && ((sortValue == null) || sortValue.trim().isEmpty())) {
|
|
||||||
|
|
||||||
publicationsElem.newChildElement("greeting");
|
publicationsElem.newChildElement("greeting");
|
||||||
|
|
||||||
publications.addOrder("year desc");
|
publications.addOrder("yearOfPublication desc");
|
||||||
if (config.getOneRowPerAuthor()) {
|
publications.addOrder("case when (authorsStr is null) "
|
||||||
publications.addOrder("case when (authorSurname is null) "
|
+ "then 'zzzz' "
|
||||||
+ "then 'zzzz' "
|
+ "else authorsStr "
|
||||||
+ "else authorSurname "
|
+ "end asc");
|
||||||
+ "end asc");
|
|
||||||
publications.addOrder("case when (authorGivenname is null) "
|
|
||||||
+ "then 'zzzz' "
|
|
||||||
+ "else authorGivenname "
|
|
||||||
+ "end asc");
|
|
||||||
} else {
|
|
||||||
publications.addOrder("case when (authors is null) "
|
|
||||||
+ "then 'zzzz' "
|
|
||||||
+ "else authors "
|
|
||||||
+ "end asc");
|
|
||||||
}
|
|
||||||
publications.addOrder("title asc");
|
publications.addOrder("title asc");
|
||||||
|
|
||||||
yearFilter.setDataQuery(getData(orgaunit), "year");
|
yearFilter.setDataQuery(publications, YEAR_PARAM);
|
||||||
|
|
||||||
yearFilter.generateXml(filtersElem);
|
yearFilter.generateXml(filtersElem);
|
||||||
titleFilter.generateXml(filtersElem);
|
titleFilter.generateXml(filtersElem);
|
||||||
|
|
@ -169,67 +154,14 @@ public class SciInstitutePublicationsTab implements GenericOrgaUnitTab {
|
||||||
publications.setRange(1, config.getGreetingSize() + 1);
|
publications.setRange(1, config.getGreetingSize() + 1);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/*if (SORT_BY_AUTHOR.equals(sortValue)) {
|
publications.addOrder("case when (authorsStr is null) "
|
||||||
if (config.getOneRowPerAuthor()) {
|
+ "then 'zzzz' "
|
||||||
publications.addOrder("surname");
|
+ "else authorsStr "
|
||||||
} else {
|
+ "end asc");
|
||||||
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");
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (config.getOneRowPerAuthor()) {
|
|
||||||
publications.addOrder("case when (authorSurname is null) "
|
|
||||||
+ "then 'zzzz' "
|
|
||||||
+ "else authorSurname "
|
|
||||||
+ "end asc");
|
|
||||||
publications.addOrder("case when (authorGivenname is null) "
|
|
||||||
+ "then 'zzzz' "
|
|
||||||
+ "else authorGivenname "
|
|
||||||
+ "end asc");
|
|
||||||
} else {
|
|
||||||
publications.addOrder("case when (authors is null) "
|
|
||||||
+ "then 'zzzz' "
|
|
||||||
+ "else authors "
|
|
||||||
+ "end asc");
|
|
||||||
}
|
|
||||||
publications.addOrder("title asc");
|
publications.addOrder("title asc");
|
||||||
|
|
||||||
final DataQuery yearQuery = getData(orgaunit);
|
final DataQuery yearQuery = getData(orgaunit);
|
||||||
yearFilter.setDataQuery(yearQuery, "year");
|
yearFilter.setDataQuery(yearQuery, YEAR_PARAM);
|
||||||
|
|
||||||
applyYearFilter(publications, request);
|
applyYearFilter(publications, request);
|
||||||
applyTitleFilter(publications, request);
|
applyTitleFilter(publications, request);
|
||||||
|
|
@ -269,22 +201,9 @@ public class SciInstitutePublicationsTab implements GenericOrgaUnitTab {
|
||||||
paginator.generateXml(publicationsElem);
|
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()) {
|
while (publications.next()) {
|
||||||
generatePublicationXml(
|
generatePublicationXml(
|
||||||
(BigDecimal) publications.get("publicationId"),
|
(BigDecimal) publications.get("id"),
|
||||||
(String) publications.get("objectType"),
|
(String) publications.get("objectType"),
|
||||||
publicationsElem,
|
publicationsElem,
|
||||||
state);
|
state);
|
||||||
|
|
@ -296,7 +215,7 @@ public class SciInstitutePublicationsTab implements GenericOrgaUnitTab {
|
||||||
System.currentTimeMillis() - start));
|
System.currentTimeMillis() - start));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DataQuery getData(final GenericOrganizationalUnit orgaunit) {
|
protected DataCollection getData(final GenericOrganizationalUnit orgaunit) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
|
|
||||||
if (!(orgaunit instanceof SciInstitute)) {
|
if (!(orgaunit instanceof SciInstitute)) {
|
||||||
|
|
@ -308,19 +227,10 @@ public class SciInstitutePublicationsTab implements GenericOrgaUnitTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final DataQuery publicationsQuery;
|
final DataQuery publicationBundlesQuery;
|
||||||
if (config.getOneRowPerAuthor()) {
|
publicationBundlesQuery =
|
||||||
publicationsQuery =
|
SessionManager.getSession().retrieveQuery("com.arsdigita.cms.contenttypes.getIdsOfPublicationsForOrgaUnit");
|
||||||
SessionManager.getSession().
|
|
||||||
retrieveQuery(
|
|
||||||
"com.arsdigita.cms.contenttypes.getIdsOfPublicationsForOrgaUnitOneRowPerAuthor");
|
|
||||||
} else {
|
|
||||||
publicationsQuery =
|
|
||||||
SessionManager.getSession().
|
|
||||||
retrieveQuery(
|
|
||||||
"com.arsdigita.cms.contenttypes.getIdsOfPublicationsForOrgaUnit");
|
|
||||||
}
|
|
||||||
//final StringBuffer publicationsFilter = new StringBuffer();
|
|
||||||
final List<String> orgaunitIds = new ArrayList<String>();
|
final List<String> orgaunitIds = new ArrayList<String>();
|
||||||
|
|
||||||
if (config.isMergingPublications()) {
|
if (config.isMergingPublications()) {
|
||||||
|
|
@ -328,26 +238,47 @@ public class SciInstitutePublicationsTab implements GenericOrgaUnitTab {
|
||||||
SessionManager.getSession().retrieveQuery(
|
SessionManager.getSession().retrieveQuery(
|
||||||
"com.arsdigita.cms.contenttypes.getIdsOfSubordinateOrgaUnitsRecursivlyWithAssocType");
|
"com.arsdigita.cms.contenttypes.getIdsOfSubordinateOrgaUnitsRecursivlyWithAssocType");
|
||||||
departmentsQuery.setParameter("orgaunitId",
|
departmentsQuery.setParameter("orgaunitId",
|
||||||
orgaunit.getID().toString());
|
orgaunit.getContentBundle().getID().toString());
|
||||||
departmentsQuery.setParameter("assocType",
|
departmentsQuery.setParameter("assocType",
|
||||||
SciInstituteDepartmentsStep.ASSOC_TYPE);
|
SciInstituteDepartmentsStep.ASSOC_TYPE);
|
||||||
while (departmentsQuery.next()) {
|
while (departmentsQuery.next()) {
|
||||||
/*if (publicationsFilter.length() > 0) {
|
|
||||||
publicationsFilter.append(" or ");
|
|
||||||
}
|
|
||||||
publicationsFilter.append(String.format("orgaunitId = %s",
|
|
||||||
departmentsQuery.get(
|
|
||||||
"orgaunitId").toString()));*/
|
|
||||||
orgaunitIds.add(departmentsQuery.get("orgaunitId").toString());
|
orgaunitIds.add(departmentsQuery.get("orgaunitId").toString());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*publicationsFilter.append(String.format("orgaunitId = %s",
|
|
||||||
orgaunit.getID().toString()));*/
|
|
||||||
orgaunitIds.add(orgaunit.getID().toString());
|
orgaunitIds.add(orgaunit.getID().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
//publicationsQuery.addFilter(publicationsFilter.toString());
|
publicationBundlesQuery.setParameter("orgaunitIds", orgaunitIds);
|
||||||
publicationsQuery.setParameter("orgaunitIds", orgaunitIds);
|
|
||||||
|
final StringBuilder filterBuilder = new StringBuilder();
|
||||||
|
while (publicationBundlesQuery.next()) {
|
||||||
|
if (filterBuilder.length() > 0) {
|
||||||
|
filterBuilder.append(',');
|
||||||
|
}
|
||||||
|
filterBuilder.append(publicationBundlesQuery.get("publicationId").toString());
|
||||||
|
}
|
||||||
|
final DataCollection publicationsQuery = SessionManager.getSession().retrieve(
|
||||||
|
"com.arsdigita.cms.contenttypes.Publication");
|
||||||
|
|
||||||
|
if (filterBuilder.length() == 0) {
|
||||||
|
//No publications return null to indicate
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
publicationsQuery.addFilter(String.format("parent.id in (%s)", filterBuilder.toString()));
|
||||||
|
|
||||||
|
if (Kernel.getConfig().languageIndependentItems()) {
|
||||||
|
final FilterFactory filterFactory = publicationsQuery.getFilterFactory();
|
||||||
|
final Filter filter = filterFactory.or().
|
||||||
|
addFilter(filterFactory.equals("language", GlobalizationHelper.getNegotiatedLocale().getLanguage())).
|
||||||
|
addFilter(filterFactory.and().
|
||||||
|
addFilter(filterFactory.equals("language", GlobalizationHelper.LANG_INDEPENDENT)).
|
||||||
|
addFilter(filterFactory.notIn("parent", "com.arsdigita.navigation.getParentIDsOfMatchedItems").set(
|
||||||
|
"language", GlobalizationHelper.getNegotiatedLocale().getLanguage())));
|
||||||
|
publicationsQuery.addFilter(filter);
|
||||||
|
} else {
|
||||||
|
publicationsQuery.addEqualsFilter("language", GlobalizationHelper.getNegotiatedLocale().getLanguage());
|
||||||
|
}
|
||||||
|
|
||||||
logger.debug(String.format(
|
logger.debug(String.format(
|
||||||
"Got publications of institute '%s'"
|
"Got publications of institute '%s'"
|
||||||
|
|
@ -402,8 +333,8 @@ public class SciInstitutePublicationsTab implements GenericOrgaUnitTab {
|
||||||
final Element parent,
|
final Element parent,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
final ContentPage publication = (ContentPage) DomainObjectFactory.
|
final ContentPage publication =
|
||||||
newInstance(new OID(objectType, publicationId));
|
(ContentPage) DomainObjectFactory.newInstance(new OID(objectType, publicationId));
|
||||||
logger.debug(String.format("Got domain object for publication '%s' "
|
logger.debug(String.format("Got domain object for publication '%s' "
|
||||||
+ "in %d ms.",
|
+ "in %d ms.",
|
||||||
publication.getName(),
|
publication.getName(),
|
||||||
|
|
@ -416,7 +347,7 @@ public class SciInstitutePublicationsTab implements GenericOrgaUnitTab {
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
final XmlGenerator generator = new XmlGenerator(publication);
|
final XmlGenerator generator = new XmlGenerator(publication);
|
||||||
generator.setUseExtraXml(false);
|
generator.setListMode(true);
|
||||||
generator.setItemElemName("publications", "");
|
generator.setItemElemName("publications", "");
|
||||||
generator.generateXML(state, parent, "");
|
generator.generateXML(state, parent, "");
|
||||||
logger.debug(String.format(
|
logger.debug(String.format(
|
||||||
|
|
@ -438,5 +369,6 @@ public class SciInstitutePublicationsTab implements GenericOrgaUnitTab {
|
||||||
protected ContentItem getContentItem(final PageState state) {
|
protected ContentItem getContentItem(final PageState state) {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,10 @@ import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||||
import com.arsdigita.globalization.GlobalizationHelper;
|
import com.arsdigita.globalization.GlobalizationHelper;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -123,8 +127,7 @@ public class SciInstituteSummaryTab implements GenericOrgaUnitTab {
|
||||||
|
|
||||||
final Element headsElem = parent.newChildElement("heads");
|
final Element headsElem = parent.newChildElement("heads");
|
||||||
|
|
||||||
final GenericOrganizationalUnitPersonCollection heads = institute.
|
final GenericOrganizationalUnitPersonCollection heads = institute.getPersons();
|
||||||
getPersons();
|
|
||||||
heads.addFilter(roleFilter.toString());
|
heads.addFilter(roleFilter.toString());
|
||||||
heads.addFilter(statusFilter.toString());
|
heads.addFilter(statusFilter.toString());
|
||||||
heads.addOrder("name");
|
heads.addOrder("name");
|
||||||
|
|
@ -170,17 +173,31 @@ public class SciInstituteSummaryTab implements GenericOrgaUnitTab {
|
||||||
activeStatus));
|
activeStatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
final Element headsElem = parent.newChildElement("heads");
|
final GenericOrganizationalUnitPersonCollection headsCollection = department.getPersons();
|
||||||
|
headsCollection.addFilter(roleFilter.toString());
|
||||||
|
headsCollection.addFilter(statusFilter.toString());
|
||||||
|
|
||||||
final GenericOrganizationalUnitPersonCollection heads = department.
|
final List<GenericPerson> heads = new ArrayList<GenericPerson>();
|
||||||
getPersons();
|
while (headsCollection.next()) {
|
||||||
heads.addFilter(roleFilter.toString());
|
heads.add(headsCollection.getPerson());
|
||||||
heads.addFilter(statusFilter.toString());
|
}
|
||||||
heads.addOrder("surname");
|
Collections.sort(heads, new Comparator<GenericPerson>() {
|
||||||
heads.addOrder("givenname");
|
|
||||||
|
|
||||||
while (heads.next()) {
|
public int compare(final GenericPerson person1,
|
||||||
generateMemberXml(heads.getPerson(), headsElem, state);
|
final GenericPerson person2) {
|
||||||
|
final String name1 = String.format("%s %s", person1.getSurname(), person1.getGivenName());
|
||||||
|
final String name2 = String.format("%s %s", person2.getSurname(), person2.getGivenName());
|
||||||
|
return name1.compareTo(name2);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!heads.isEmpty()) {
|
||||||
|
final Element headsElem = parent.newChildElement("heads");
|
||||||
|
//while (headsCollection.next()) {
|
||||||
|
for (GenericPerson head : heads) {
|
||||||
|
generateMemberXml(head, headsElem, state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug(String.format("Generated head of department XML for department '%s' "
|
logger.debug(String.format("Generated head of department XML for department '%s' "
|
||||||
|
|
@ -195,8 +212,7 @@ public class SciInstituteSummaryTab implements GenericOrgaUnitTab {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
|
|
||||||
final GenericOrganizationalUnitSubordinateCollection departments =
|
final GenericOrganizationalUnitSubordinateCollection departments =
|
||||||
institute.
|
institute.getSubordinateOrgaUnits();
|
||||||
getSubordinateOrgaUnits();
|
|
||||||
departments.addFilter(
|
departments.addFilter(
|
||||||
String.format("%s = '%s'",
|
String.format("%s = '%s'",
|
||||||
GenericOrganizationalUnitSubordinateCollection.LINK_ASSOCTYPE,
|
GenericOrganizationalUnitSubordinateCollection.LINK_ASSOCTYPE,
|
||||||
|
|
@ -278,8 +294,7 @@ public class SciInstituteSummaryTab implements GenericOrgaUnitTab {
|
||||||
final Element parent,
|
final Element parent,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
final GenericOrganizationalUnitContactCollection contacts = department.
|
final GenericOrganizationalUnitContactCollection contacts = department.getContacts();
|
||||||
getContacts();
|
|
||||||
|
|
||||||
if ((contacts == null) || contacts.isEmpty()) {
|
if ((contacts == null) || contacts.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -321,8 +336,7 @@ public class SciInstituteSummaryTab implements GenericOrgaUnitTab {
|
||||||
relAttrs.addFilter(String.format("attribute = '%s'",
|
relAttrs.addFilter(String.format("attribute = '%s'",
|
||||||
"GenericContactTypes"));
|
"GenericContactTypes"));
|
||||||
relAttrs.addFilter(String.format("attr_key = '%s'", contactTypeKey));
|
relAttrs.addFilter(String.format("attr_key = '%s'", contactTypeKey));
|
||||||
relAttrs.addFilter(String.format("lang = '%s'", GlobalizationHelper.
|
relAttrs.addFilter(String.format("lang = '%s'", GlobalizationHelper.getNegotiatedLocale().getLanguage()));
|
||||||
getNegotiatedLocale().getLanguage()));
|
|
||||||
|
|
||||||
if (relAttrs.isEmpty()) {
|
if (relAttrs.isEmpty()) {
|
||||||
return contactTypeKey;
|
return contactTypeKey;
|
||||||
|
|
@ -348,5 +362,6 @@ public class SciInstituteSummaryTab implements GenericOrgaUnitTab {
|
||||||
protected ContentItem getContentItem(final PageState state) {
|
protected ContentItem getContentItem(final PageState state) {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue