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