- Sichern des aktuellen Standes der neuen Sci-Typen.

- Kleinere Bug-Fixes an anderen Stellen


git-svn-id: https://svn.libreccm.org/ccm/trunk@1270 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2011-11-19 14:10:20 +00:00
parent f0b37603c1
commit f6ef24d03c
11 changed files with 240 additions and 112 deletions

View File

@ -16,11 +16,13 @@ import java.util.Map;
public class CompareFilter implements Filter { public class CompareFilter implements Filter {
private static final String ALL = "--ALL--"; private static final String ALL = "--ALL--";
private static final String NONE = "--NONE--";
private final String property; private final String property;
private final String label; private final String label;
private final boolean allOption; private final boolean allOption;
private final boolean allOptionIsDefault; private final boolean allOptionIsDefault;
private final boolean propertyIsNumeric; private final boolean propertyIsNumeric;
private boolean emptyDefaultOption = false;
private Map<String, Option> options = new LinkedHashMap<String, Option>(); private Map<String, Option> options = new LinkedHashMap<String, Option>();
private String value; private String value;
@ -36,6 +38,16 @@ public class CompareFilter implements Filter {
this.propertyIsNumeric = propertyIsNumeric; this.propertyIsNumeric = propertyIsNumeric;
} }
public CompareFilter(final String label,
final String property,
final boolean allOption,
final boolean allOptionIsDefault,
final boolean propertyIsNumeric,
final boolean emptyDefaultOption) {
this(label, property, allOption, allOptionIsDefault, propertyIsNumeric);
this.emptyDefaultOption = true;
}
@Override @Override
public String getProperty() { public String getProperty() {
return property; return property;
@ -67,13 +79,15 @@ public class CompareFilter implements Filter {
if ((value == null) || value.isEmpty()) { if ((value == null) || value.isEmpty()) {
if (allOptionIsDefault) { if (allOptionIsDefault) {
value = ALL; value = ALL;
} else if (emptyDefaultOption) {
return "";
} else { } else {
value = value =
new ArrayList<Option>(options.values()).get(0).getLabel(); new ArrayList<Option>(options.values()).get(0).getLabel();
} }
} }
if (ALL.equals(value)) { if (ALL.equals(value) || NONE.equals(value)) {
return ""; return "";
} }
@ -132,6 +146,8 @@ public class CompareFilter implements Filter {
if ((value == null) || value.isEmpty()) { if ((value == null) || value.isEmpty()) {
if (allOptionIsDefault) { if (allOptionIsDefault) {
selected = ALL; selected = ALL;
} else if (emptyDefaultOption) {
selected = NONE;
} else { } else {
List<Option> optionsList = List<Option> optionsList =
new ArrayList<Option>(options.values()); new ArrayList<Option>(options.values());
@ -151,6 +167,10 @@ public class CompareFilter implements Filter {
option.addAttribute("label", ALL); option.addAttribute("label", ALL);
} }
if (emptyDefaultOption) {
final Element emptyOption = filter.newChildElement("option");
emptyOption.addAttribute("label", NONE);
}
Element option; Element option;
for (Map.Entry<String, Option> entry : options.entrySet()) { for (Map.Entry<String, Option> entry : options.entrySet()) {
option = filter.newChildElement("option"); option = filter.newChildElement("option");

View File

@ -18,6 +18,7 @@ import java.util.Set;
*/ */
public class SelectFilter implements Filter { public class SelectFilter implements Filter {
public static final String NONE = "--NONE--";
public static final String ALL = "--ALL--"; public static final String ALL = "--ALL--";
private final String property; private final String property;
private final String label; private final String label;
@ -27,6 +28,7 @@ public class SelectFilter implements Filter {
private final boolean allOptionIsDefault; private final boolean allOptionIsDefault;
private final boolean reverseOptions; private final boolean reverseOptions;
private final boolean propertyIsNumeric; private final boolean propertyIsNumeric;
private boolean emptyDefaultOption = false;
private String value; private String value;
public SelectFilter(final String label, public SelectFilter(final String label,
@ -44,6 +46,18 @@ public class SelectFilter implements Filter {
this.propertyIsNumeric = propertyIsNumeric; this.propertyIsNumeric = propertyIsNumeric;
} }
public SelectFilter(final String label,
final String property,
final boolean reverseOptions,
final boolean allOption,
final boolean allOptionIsDefault,
final boolean propertyIsNumeric,
final boolean emptyDefaultOption) {
this(label, property, reverseOptions, allOption, allOptionIsDefault,
propertyIsNumeric);
this.emptyDefaultOption = emptyDefaultOption;
}
@Override @Override
public String getProperty() { public String getProperty() {
return property; return property;
@ -61,18 +75,17 @@ public class SelectFilter implements Filter {
} }
public String getFilter() { public String getFilter() {
List<String> options;
options = getOptions();
if ((value == null) || value.isEmpty()) { if ((value == null) || value.isEmpty()) {
if (allOptionIsDefault) { if (allOptionIsDefault) {
value = ALL; value = ALL;
} else if(emptyDefaultOption) {
value = NONE;
} else { } else {
value = options.get(0); value = getOptions().get(0);
} }
} }
if (ALL.equals(value)) { if (ALL.equals(value) || NONE.equals(value)) {
return null; return null;
} }
@ -95,9 +108,15 @@ public class SelectFilter implements Filter {
filter = parent.newChildElement("filter"); filter = parent.newChildElement("filter");
filter.addAttribute("type", "select"); filter.addAttribute("type", "select");
if(options.isEmpty()) {
return;
}
if ((value == null) || value.isEmpty()) { if ((value == null) || value.isEmpty()) {
if (allOptionIsDefault) { if (allOptionIsDefault) {
selected = ALL; selected = ALL;
} else if(emptyDefaultOption) {
selected = NONE;
} else { } else {
selected = options.get(0); selected = options.get(0);
} }
@ -108,6 +127,11 @@ public class SelectFilter implements Filter {
filter.addAttribute("label", label); filter.addAttribute("label", label);
filter.addAttribute("selected", selected); filter.addAttribute("selected", selected);
if (emptyDefaultOption) {
optionElem = filter.newChildElement("option");
optionElem.addAttribute("label", NONE);
}
if (allOption) { if (allOption) {
optionElem = filter.newChildElement("option"); optionElem = filter.newChildElement("option");
optionElem.addAttribute("label", ALL); optionElem.addAttribute("label", ALL);

View File

@ -94,7 +94,7 @@ public class PersonalPublicationsConfig extends AbstractConfig {
order = new StringParameter( order = new StringParameter(
"com.arsdigita.cms.publicpersonlprofile.publications.order", "com.arsdigita.cms.publicpersonlprofile.publications.order",
Parameter.REQUIRED, Parameter.REQUIRED,
"year,title"); "year,authors,title");
register(publicationGroups); register(publicationGroups);
register(groupSplit); register(groupSplit);

View File

@ -107,7 +107,8 @@ query getIdsOfPublicationsForOrgaUnitOneRowPerAuthor {
join cms_organizationalunits_publications_map on cms_pages.item_id = cms_organizationalunits_publications_map.publication_id join cms_organizationalunits_publications_map on cms_pages.item_id = cms_organizationalunits_publications_map.publication_id
join cms_organizationalunits on cms_organizationalunits_publications_map.orgaunit_id = cms_organizationalunits.organizationalunit_id join cms_organizationalunits on cms_organizationalunits_publications_map.orgaunit_id = cms_organizationalunits.organizationalunit_id
join acs_objects on cms_pages.item_id = acs_objects.object_id join acs_objects on cms_pages.item_id = acs_objects.object_id
join cms_items on cms_items.item_id = cms_pages.item_id; join cms_items on cms_items.item_id = cms_pages.item_id
where cms_organizationalunits.organizationalunit_id in :orgaunitIds
} map { } map {
publicationId = cms_pages.item_id; publicationId = cms_pages.item_id;
objectType = acs_objects.object_type; objectType = acs_objects.object_type;
@ -131,6 +132,7 @@ query getIdsOfPublicationsForOrgaUnit {
Integer year; Integer year;
String authors; String authors;
String language; String language;
Boolean reviewed;
do { do {
select cms_pages.item_id, select cms_pages.item_id,
@ -138,14 +140,16 @@ query getIdsOfPublicationsForOrgaUnit {
cms_pages.title, cms_pages.title,
cms_organizationalunits.organizationalunit_id, cms_organizationalunits.organizationalunit_id,
ct_publications.year, ct_publications.year,
ct_publications.authors ct_publications.authors,
cms_items.language cms_items.language,
ct_publications.reviewed
from cms_pages from cms_pages
join ct_publications on cms_pages.item_id = ct_publications.publication_id join ct_publications on cms_pages.item_id = ct_publications.publication_id
join cms_organizationalunits_publications_map on cms_pages.item_id = cms_organizationalunits_publications_map.publication_id join cms_organizationalunits_publications_map on cms_pages.item_id = cms_organizationalunits_publications_map.publication_id
join cms_organizationalunits on cms_organizationalunits_publications_map.orgaunit_id = cms_organizationalunits.organizationalunit_id join cms_organizationalunits on cms_organizationalunits_publications_map.orgaunit_id = cms_organizationalunits.organizationalunit_id
join acs_objects on cms_pages.item_id = acs_objects.object_id join acs_objects on cms_pages.item_id = acs_objects.object_id
join cms_items on cms_pages.item_id = cms_items.item_id join cms_items on cms_pages.item_id = cms_items.item_id
where cms_organizationalunits.organizationalunit_id in :orgaunitIds
} map { } map {
publicationId = cms_pages.item_id; publicationId = cms_pages.item_id;
objectType = acs_objects.object_type; objectType = acs_objects.object_type;
@ -153,6 +157,8 @@ query getIdsOfPublicationsForOrgaUnit {
title = cms_pages.title; title = cms_pages.title;
year = ct_publications.year; year = ct_publications.year;
authors = ct_publications.authors; authors = ct_publications.authors;
language = cms_items.language;
reviewed = ct_publications.reviewed;
} }
} }

View File

@ -70,7 +70,7 @@ public class SciDepartmentConfig extends AbstractConfig {
new StringParameter( new StringParameter(
"com.arsdigita.cms.contenttypes.sciproject.tabs", "com.arsdigita.cms.contenttypes.sciproject.tabs",
Parameter.REQUIRED, Parameter.REQUIRED,
"summary:com.arsdigita.cms.contenttypes.ui.SciDepartmentSummaryTab;desc:com.arsdigita.cms.contenttypes.ui.SciDepartmentDescTab;members:com.arsdigita.cms.contenttypes.ui.SciDepartmentMembersTab"); "summary:com.arsdigita.cms.contenttypes.ui.SciDepartmentSummaryTab;desc:com.arsdigita.cms.contenttypes.ui.SciDepartmentDescTab;members:com.arsdigita.cms.contenttypes.ui.SciDepartmentMembersTab;projects:com.arsdigita.cms.contenttypes.ui.SciDepartmentProjectsTab;publications:com.arsdigita.cms.contenttypes.ui.SciDepartmentPublicationsTab");
register(enableSubDepartmentsStep); register(enableSubDepartmentsStep);
register(enableSuperDepartmentsStep); register(enableSuperDepartmentsStep);

View File

@ -132,7 +132,7 @@ public class SciDepartmentMembersTab implements GenericOrgaUnitTab {
final DataQuery personsQuery = SessionManager.getSession(). final DataQuery personsQuery = SessionManager.getSession().
retrieveQuery( retrieveQuery(
"com.arsdigita.cms.contenttypes.getIdsOfMembersOfOrgaUnits"); "com.arsdigita.cms.contenttypes.getIdsOfMembersOfOrgaUnits");
final StringBuffer personsFilter = new StringBuffer(); //final StringBuffer personsFilter = new StringBuffer();
final List<String> orgaUnitIds = new ArrayList<String>(); final List<String> orgaUnitIds = new ArrayList<String>();
if (config.isMergingMembers()) { if (config.isMergingMembers()) {
@ -145,18 +145,18 @@ public class SciDepartmentMembersTab implements GenericOrgaUnitTab {
SciDepartmentSubDepartmentsStep.ASSOC_TYPE); SciDepartmentSubDepartmentsStep.ASSOC_TYPE);
while (subDepartmentsQuery.next()) { while (subDepartmentsQuery.next()) {
if (personsFilter.length() > 0) { /*if (personsFilter.length() > 0) {
personsFilter.append(" or "); personsFilter.append(" or ");
} }
personsFilter.append(String.format("orgaunitId = %s", personsFilter.append(String.format("orgaunitId = %s",
subDepartmentsQuery.get( subDepartmentsQuery.get(
"orgaunitId").toString())); "orgaunitId").toString()));*/
orgaUnitIds.add(subDepartmentsQuery.get( orgaUnitIds.add(subDepartmentsQuery.get(
"orgaunitId").toString()); "orgaunitId").toString());
} }
} else { } else {
personsFilter.append(String.format("orgaunitId = %s", /*personsFilter.append(String.format("orgaunitId = %s",
orgaunit.getID().toString())); orgaunit.getID().toString()));*/
orgaUnitIds.add(orgaunit.getID().toString()); orgaUnitIds.add(orgaunit.getID().toString());
} }

View File

@ -17,6 +17,10 @@ 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;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -37,6 +41,7 @@ public class SciDepartmentProjectsTab implements GenericOrgaUnitTab {
"projectEnd", "projectEnd",
false, false,
false, false,
false,
true); true);
private final TextFilter titleFilter = new TextFilter(TITLE_PARAM, private final TextFilter titleFilter = new TextFilter(TITLE_PARAM,
ContentPage.TITLE); ContentPage.TITLE);
@ -45,6 +50,23 @@ public class SciDepartmentProjectsTab implements GenericOrgaUnitTab {
config.load(); config.load();
} }
public SciDepartmentProjectsTab() {
final Calendar now = new GregorianCalendar();
final String today = String.format("%d-%02d-%02d",
now.get(Calendar.YEAR),
now.get(Calendar.MONTH) + 1,
now.get(Calendar.DAY_OF_MONTH));
statusFilter.addOption("currentProjects",
CompareFilter.Operators.GTEQ,
today,
true);
statusFilter.addOption("finishedProjects",
CompareFilter.Operators.LT,
today,
false);
}
public boolean hasData(final GenericOrganizationalUnit orgaunit) { public boolean hasData(final GenericOrganizationalUnit orgaunit) {
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
final ContentTypeCollection types = ContentType.getAllContentTypes(); final ContentTypeCollection types = ContentType.getAllContentTypes();
@ -81,9 +103,13 @@ public class SciDepartmentProjectsTab implements GenericOrgaUnitTab {
statusFilter.generateXml(filtersElem); statusFilter.generateXml(filtersElem);
if (((request.getParameter(STATUS_PARAM) == null) if (((request.getParameter(STATUS_PARAM) == null)
|| (request.getParameter(STATUS_PARAM).trim().isEmpty())) || (request.getParameter(STATUS_PARAM).trim().isEmpty())
|| (statusFilter.getFilter() == null)
|| (statusFilter.getFilter().trim().isEmpty()))
&& ((request.getParameter(TITLE_PARAM) == null) && ((request.getParameter(TITLE_PARAM) == null)
|| request.getParameter(TITLE_PARAM).trim().isEmpty())) { || request.getParameter(TITLE_PARAM).trim().isEmpty())
|| (titleFilter.getFilter() == null)
|| !(titleFilter.getFilter().trim().isEmpty())) {
depProjectsElem.newChildElement("greeting"); depProjectsElem.newChildElement("greeting");
@ -138,8 +164,9 @@ public class SciDepartmentProjectsTab implements GenericOrgaUnitTab {
final DataQuery projectsQuery = SessionManager.getSession(). final DataQuery projectsQuery = SessionManager.getSession().
retrieveQuery( retrieveQuery(
"com.arsdigita.cms.contenttypes. getIdsOfProjectsOfOrgaUnit"); "com.arsdigita.cms.contenttypes.getIdsOfProjectsOfOrgaUnit");
final StringBuffer projectsFilter = new StringBuffer(); //final StringBuffer projectsFilter = new StringBuffer();
final List<String> orgaunitIds = new ArrayList<String>();
if (config.isMergingProjects()) { if (config.isMergingProjects()) {
final DataQuery subDepartmentsQuery = final DataQuery subDepartmentsQuery =
@ -151,19 +178,22 @@ public class SciDepartmentProjectsTab implements GenericOrgaUnitTab {
SciDepartmentProjectsStep.ASSOC_TYPE); SciDepartmentProjectsStep.ASSOC_TYPE);
while (subDepartmentsQuery.next()) { while (subDepartmentsQuery.next()) {
if (projectsFilter.length() > 0) { /*if (projectsFilter.length() > 0) {
projectsFilter.append(" or "); projectsFilter.append(" or ");
} }
projectsFilter.append(String.format("orgaunitId = %s", projectsFilter.append(String.format("orgaunitId = %s",
subDepartmentsQuery.get( subDepartmentsQuery.get(
"orgaunitId").toString())); "orgaunitId").toString()));*/
orgaunitIds.add(subDepartmentsQuery.get("orgaunitId").toString());
} }
} else { } else {
projectsFilter.append(String.format("orgaunitId = %s", //projectsFilter.append(String.format("orgaunitId = %s",
orgaunit.getID().toString())); // orgaunit.getID().toString()));
orgaunitIds.add(orgaunit.getID().toString());
} }
projectsQuery.addFilter(projectsFilter.toString()); //projectsQuery.addFilter(projectsFilter.toString());
projectsQuery.setParameter("orgaunitIds", orgaunitIds);
logger.debug(String.format( logger.debug(String.format(
"Got projects of department '%s'" "Got projects of department '%s'"
@ -181,8 +211,11 @@ public class SciDepartmentProjectsTab implements GenericOrgaUnitTab {
statusFilter.setValue(statusValue); statusFilter.setValue(statusValue);
} }
if ((statusFilter.getFilter() != null)
&& !(statusFilter.getFilter().trim().isEmpty())) {
projects.addFilter(statusFilter.getFilter()); projects.addFilter(statusFilter.getFilter());
} }
}
private void applyTitleFilter(final DataQuery projects, private void applyTitleFilter(final DataQuery projects,
final HttpServletRequest request) { final HttpServletRequest request) {
@ -191,8 +224,11 @@ public class SciDepartmentProjectsTab implements GenericOrgaUnitTab {
titleFilter.setValue(titleValue); titleFilter.setValue(titleValue);
} }
if ((titleFilter.getFilter() != null)
&& !(titleFilter.getFilter().trim().isEmpty())) {
projects.addFilter(titleFilter.getFilter()); projects.addFilter(titleFilter.getFilter());
} }
}
private void generateProjectXml(final BigDecimal projectId, private void generateProjectXml(final BigDecimal projectId,
final Element parent, final Element parent,
@ -213,6 +249,8 @@ public class SciDepartmentProjectsTab implements GenericOrgaUnitTab {
final PageState state) { final PageState state) {
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
final XmlGenerator generator = new XmlGenerator(project); final XmlGenerator generator = new XmlGenerator(project);
generator.setItemElemName("project", "");
generator.setUseExtraXml(false);
generator.generateXML(state, parent, ""); generator.generateXML(state, parent, "");
logger.debug(String.format("Generated XML for project '%s' in %d ms.", logger.debug(String.format("Generated XML for project '%s' in %d ms.",
project.getName(), project.getName(),

View File

@ -17,6 +17,8 @@ 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;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -34,16 +36,17 @@ public class SciDepartmentPublicationsTab implements GenericOrgaUnitTab {
private static final String YEAR_PARAM = "year"; private static final String YEAR_PARAM = "year";
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_PARAM = "sortBy";
private static final String SORT_BY_YEAR_ASC = "yearAsc"; private static final String SORT_BY_YEAR_ASC = "yearAsc";
private static final String SORT_BY_YEAR_DESC = "yearDesc"; private static final String SORT_BY_YEAR_DESC = "yearDesc";
private static final String SORT_BY_TITLE = "title"; private static final String SORT_BY_TITLE = "title";
private static final String SORT_BY_AUTHOR = "author"; 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,
true,
false, false,
false, true,
true); true);
private final TextFilter titleFilter = new TextFilter(TITLE_PARAM, private final TextFilter titleFilter = new TextFilter(TITLE_PARAM,
ContentPage.TITLE); ContentPage.TITLE);
@ -97,15 +100,15 @@ public class SciDepartmentPublicationsTab implements GenericOrgaUnitTab {
final String yearValue = request.getParameter(YEAR_PARAM); final String yearValue = request.getParameter(YEAR_PARAM);
final String titleValue = request.getParameter(TITLE_PARAM); final String titleValue = request.getParameter(TITLE_PARAM);
final String authorValue = request.getParameter(AUTHOR_PARAM); final String authorValue = request.getParameter(AUTHOR_PARAM);
final String sortValue = request.getParameter(SORT_PARAM); //final String sortValue = request.getParameter(SORT_PARAM);
final Element filtersElem = depPublicationsElem.newChildElement( final Element filtersElem = depPublicationsElem.newChildElement(
"filters"); "filters");
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())) { //&& ((sortValue == null) || sortValue.trim().isEmpty())) {
depPublicationsElem.newChildElement("greeting"); depPublicationsElem.newChildElement("greeting");
@ -119,13 +122,15 @@ public class SciDepartmentPublicationsTab implements GenericOrgaUnitTab {
publications.setRange(1, config.getGreetingSize() + 1); publications.setRange(1, config.getGreetingSize() + 1);
yearFilter.setDataQuery(publications, "year");
yearFilter.generateXml(filtersElem); yearFilter.generateXml(filtersElem);
titleFilter.generateXml(filtersElem); titleFilter.generateXml(filtersElem);
authorFilter.generateXml(filtersElem); authorFilter.generateXml(filtersElem);
} else { } else {
if (SORT_BY_AUTHOR.equals(sortValue)) { /*if (SORT_BY_AUTHOR.equals(sortValue)) {
if (config.getOneRowPerAuthor()) { if (config.getOneRowPerAuthor()) {
publications.addOrder("surname"); publications.addOrder("surname");
} else { } else {
@ -165,8 +170,18 @@ public class SciDepartmentPublicationsTab implements GenericOrgaUnitTab {
} }
publications.addOrder("title"); publications.addOrder("title");
publications.addOrder("year asc"); publications.addOrder("year asc");
}*/
if (config.getOneRowPerAuthor()) {
publications.addOrder("surname");
publications.addOrder("title");
} else {
publications.addOrder("authors");
publications.addOrder("title");
} }
yearFilter.setDataQuery(publications, "year");
applyYearFilter(publications, request); applyYearFilter(publications, request);
applyTitleFilter(publications, request); applyTitleFilter(publications, request);
applyAuthorFilter(publications, request); applyAuthorFilter(publications, request);
@ -175,7 +190,10 @@ public class SciDepartmentPublicationsTab implements GenericOrgaUnitTab {
(int) publications.size(), (int) publications.size(),
config.getPageSize()); config.getPageSize());
if (paginator.getPageCount() > config.getEnableSearchLimit()) { if ((paginator.getPageCount() > config.getEnableSearchLimit())
|| (yearValue != null) || !(yearValue.trim().isEmpty())
|| (titleValue != null) || !(titleValue.trim().isEmpty())
|| (authorValue != null) || !(authorValue.trim().isEmpty())) {
yearFilter.generateXml(filtersElem); yearFilter.generateXml(filtersElem);
titleFilter.generateXml(filtersElem); titleFilter.generateXml(filtersElem);
authorFilter.generateXml(filtersElem); authorFilter.generateXml(filtersElem);
@ -185,7 +203,7 @@ public class SciDepartmentPublicationsTab implements GenericOrgaUnitTab {
paginator.generateXml(depPublicationsElem); paginator.generateXml(depPublicationsElem);
} }
final Element sortFieldsElem = depPublicationsElem.newChildElement( /*final Element sortFieldsElem = depPublicationsElem.newChildElement(
"sortFields"); "sortFields");
sortFieldsElem.addAttribute("sortBy", sortValue); sortFieldsElem.addAttribute("sortBy", sortValue);
@ -196,7 +214,7 @@ public class SciDepartmentPublicationsTab implements GenericOrgaUnitTab {
sortFieldsElem.newChildElement("sortField").addAttribute("label", sortFieldsElem.newChildElement("sortField").addAttribute("label",
SORT_BY_YEAR_ASC); SORT_BY_YEAR_ASC);
sortFieldsElem.newChildElement("sortField").addAttribute("label", sortFieldsElem.newChildElement("sortField").addAttribute("label",
SORT_BY_YEAR_DESC); SORT_BY_YEAR_DESC);*/
while (publications.next()) { while (publications.next()) {
generatePublicationXml( generatePublicationXml(
@ -236,7 +254,8 @@ public class SciDepartmentPublicationsTab implements GenericOrgaUnitTab {
retrieveQuery( retrieveQuery(
"com.arsdigita.cms.contenttypes.getIdsOfPublicationsForOrgaUnit"); "com.arsdigita.cms.contenttypes.getIdsOfPublicationsForOrgaUnit");
} }
final StringBuffer publicationsFilter = new StringBuffer(); //final StringBuffer publicationsFilter = new StringBuffer();
final List<String> orgaunitIds = new ArrayList<String>();
if (config.isMergingPublications()) { if (config.isMergingPublications()) {
final DataQuery subDepartmentsQuery = final DataQuery subDepartmentsQuery =
@ -247,19 +266,22 @@ public class SciDepartmentPublicationsTab implements GenericOrgaUnitTab {
subDepartmentsQuery.setParameter("assocType", subDepartmentsQuery.setParameter("assocType",
SciDepartmentSubDepartmentsStep.ASSOC_TYPE); SciDepartmentSubDepartmentsStep.ASSOC_TYPE);
while (subDepartmentsQuery.next()) { while (subDepartmentsQuery.next()) {
if (publicationsFilter.length() > 0) { /*if (publicationsFilter.length() > 0) {
publicationsFilter.append(" or "); publicationsFilter.append(" or ");
} }
publicationsFilter.append(String.format("orgaunitId = %s", publicationsFilter.append(String.format("orgaunitId = %s",
subDepartmentsQuery.get( subDepartmentsQuery.get(
"orgaunitId").toString())); "orgaunitId").toString()));*/
orgaunitIds.add(subDepartmentsQuery.get("orgaunitId").toString());
} }
} else { } else {
publicationsFilter.append(String.format("orgaunitId = %s", //publicationsFilter.append(String.format("orgaunitId = %s",
orgaunit.getID().toString())); // orgaunit.getID().toString()));
orgaunitIds.add(orgaunit.getID().toString());
} }
publicationsQuery.addFilter(publicationsFilter.toString()); //publicationsQuery.addFilter(publicationsFilter.toString());
publicationsQuery.setParameter("orgaunitIds", orgaunitIds);
logger.debug(String.format( logger.debug(String.format(
"Got publications of department '%s'" "Got publications of department '%s'"
@ -277,8 +299,11 @@ public class SciDepartmentPublicationsTab implements GenericOrgaUnitTab {
yearFilter.setValue(yearValue); yearFilter.setValue(yearValue);
} }
if ((yearFilter.getFilter() != null)
&& !(yearFilter.getFilter().isEmpty())) {
publications.addFilter(yearFilter.getFilter()); publications.addFilter(yearFilter.getFilter());
} }
}
private void applyTitleFilter(final DataQuery publications, private void applyTitleFilter(final DataQuery publications,
final HttpServletRequest request) { final HttpServletRequest request) {
@ -287,8 +312,11 @@ public class SciDepartmentPublicationsTab implements GenericOrgaUnitTab {
titleFilter.setValue(titleValue); titleFilter.setValue(titleValue);
} }
if ((titleFilter.getFilter() != null)
&& !(titleFilter.getFilter().isEmpty())) {
publications.addFilter(titleFilter.getFilter()); publications.addFilter(titleFilter.getFilter());
} }
}
private void applyAuthorFilter(final DataQuery publications, private void applyAuthorFilter(final DataQuery publications,
final HttpServletRequest request) { final HttpServletRequest request) {
@ -297,8 +325,11 @@ public class SciDepartmentPublicationsTab implements GenericOrgaUnitTab {
authorFilter.setValue(authorValue); authorFilter.setValue(authorValue);
} }
if ((authorFilter.getFilter() != null)
&& !(authorFilter.getFilter().isEmpty())) {
publications.addFilter(authorFilter.getFilter()); publications.addFilter(authorFilter.getFilter());
} }
}
private void generatePublicationXml(final BigDecimal publicationId, private void generatePublicationXml(final BigDecimal publicationId,
final String objectType, final String objectType,
@ -319,6 +350,8 @@ public class SciDepartmentPublicationsTab 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.setItemElemName("publication", "");
generator.generateXML(state, parent, ""); generator.generateXML(state, parent, "");
logger.debug(String.format( logger.debug(String.format(
"Generated XML for publication '%s' in %d ms.", "Generated XML for publication '%s' in %d ms.",

View File

@ -30,9 +30,10 @@ query getIdsOfProjectsOfOrgaUnit {
do { do {
select distinct on (ct_sci_projects.project_id) ct_sci_projects.project_id, cms_pages.title, ct_sci_projects.projectbegin, ct_sci_projects.projectend, cms_organizationalunits_hierarchy_map.superior_orgaunit_id select distinct on (ct_sci_projects.project_id) ct_sci_projects.project_id, cms_pages.title, ct_sci_projects.projectbegin, ct_sci_projects.projectend, cms_organizationalunits_hierarchy_map.superior_orgaunit_id
from ct_sci_projects from ct_sci_projects
join cms_pages on ct_sci_project.project_id = cms_pages.item_id join cms_pages on ct_sci_projects.project_id = cms_pages.item_id
join cms_organizationalunits_hierarchy_map on ct_sci_projects = cms_organizationalunits_hierarchy_map.subordinate_orgaunit_id join cms_organizationalunits_hierarchy_map on ct_sci_projects.project_id = cms_organizationalunits_hierarchy_map.subordinate_orgaunit_id
where cms_organizationalunits_hierarchy_map.assoc_type = 'ProjectOf' where cms_organizationalunits_hierarchy_map.assoc_type = 'ProjectOf'
and cms_organizationalunits_hierarchy_map.superior_orgaunit_id in :orgaunitIds
} map { } map {
projectId = ct_sci_projects.project_id; projectId = ct_sci_projects.project_id;
orgaunitId = cms_organizationalunits_hierarchy_map.superior_orgaunit_id; orgaunitId = cms_organizationalunits_hierarchy_map.superior_orgaunit_id;

View File

@ -13,8 +13,8 @@
<xrd:property name="/object/fundingVolume"/> <xrd:property name="/object/fundingVolume"/>
</xrd:attributes> </xrd:attributes>
<xrd:associations rule="include"> <xrd:associations rule="include">
<!-- <xrd:property name="/object/contacts"/> <!-- <xrd:property name="/object/contacts"/> -->
<xrd:property name="/object/persons"/> --> <xrd:property name="/object/persons"/>
</xrd:associations> </xrd:associations>
</xrd:adapter> </xrd:adapter>
</xrd:context> </xrd:context>

View File

@ -17,8 +17,10 @@ import com.arsdigita.persistence.SessionManager;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.DateFormat; import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -105,7 +107,8 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
final Element beginSkipMonthElem = lifeSpanElem.newChildElement( final Element beginSkipMonthElem = lifeSpanElem.newChildElement(
"beginSkipMonth"); "beginSkipMonth");
beginSkipMonthElem.setText(project.getBeginSkipMonth().toString()); beginSkipMonthElem.setText(
project.getBeginSkipMonth().toString());
final Element beginSkipDayElem = lifeSpanElem.newChildElement( final Element beginSkipDayElem = lifeSpanElem.newChildElement(
"beginSkipDay"); "beginSkipDay");
@ -196,16 +199,19 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
retrieveQuery( retrieveQuery(
"com.arsdigita.cms.contenttypes.getIdsOfMembersOfOrgaUnits"); "com.arsdigita.cms.contenttypes.getIdsOfMembersOfOrgaUnits");
final StringBuffer personsFilter = new StringBuffer(); //final StringBuffer personsFilter = new StringBuffer();
final List<String> projectIds = new ArrayList<String>();
while (subProjectsQuery.next()) { while (subProjectsQuery.next()) {
if (personsFilter.length() > 0) { /*if (personsFilter.length() > 0) {
personsFilter.append(" or "); personsFilter.append(" or ");
} }
personsFilter.append(String.format("orgaunitId = %s", personsFilter.append(String.format("orgaunitId = %s",
subProjectsQuery.get( subProjectsQuery.get(
"orgaunitId").toString())); "orgaunitId").toString()));*/
projectIds.add(subProjectsQuery.get("orgaunitId").toString());
} }
personsQuery.addFilter(personsFilter.toString()); //personsQuery.addFilter(personsFilter.toString());
personsQuery.setParameter("orgaunitIds", projectIds);
personsQuery.addOrder(GenericPerson.SURNAME); personsQuery.addOrder(GenericPerson.SURNAME);
personsQuery.addOrder(GenericPerson.GIVENNAME); personsQuery.addOrder(GenericPerson.GIVENNAME);