- Verbesserungen am SciDepartmentsMemberTab
- SciDepartmentProjectsTab funktioniert jetzt git-svn-id: https://svn.libreccm.org/ccm/trunk@1615 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
ab1a6416ff
commit
39e6af24d1
|
|
@ -137,7 +137,7 @@ query getIdsOfSubordinateOrgaUnitsRecursivlyWithAssocType{
|
|||
cms_items.name as orgaunit_name
|
||||
from cms_orgaunit_bundles
|
||||
join cms_items on cms_orgaunit_bundles.bundle_id = cms_items.item_id
|
||||
where cms_orgaunit_bundles.bundle_id = 17003
|
||||
where cms_orgaunit_bundles.bundle_id = :orgaunitId
|
||||
union all
|
||||
select ou.bundle_id as orgaunit_id,
|
||||
cms_items.name as orgaunit_name
|
||||
|
|
@ -178,7 +178,7 @@ query getIdsOfMembersOfOrgaUnits {
|
|||
from cms_person_bundles
|
||||
join cms_organizationalunits_person_map on cms_person_bundles.bundle_id = cms_organizationalunits_person_map.person_id
|
||||
join cms_items on cms_person_bundles.bundle_id = cms_items.item_id
|
||||
where cms_organizationalunits_person_map.organizationalunit_id in :orgaunitIds
|
||||
where cms_organizationalunits_person_map.organizationalunit_id in :orgaunitIds
|
||||
} map {
|
||||
memberId = cms_person_bundles.bundle_id;
|
||||
orgaunitId = cms_organizationalunits_person_map.organizationalunit_id;
|
||||
|
|
|
|||
|
|
@ -12,13 +12,11 @@ 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.FilterFactory;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.xml.Element;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Filter;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
@ -66,7 +64,7 @@ public class SciDepartmentMembersTab implements GenericOrgaUnitTab {
|
|||
return true;
|
||||
} else if (config.isMergingMembers()) {
|
||||
final DataQuery persons = getData(orgaunit, state);
|
||||
return persons.isEmpty();
|
||||
return (persons != null) && persons.isEmpty();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -77,7 +75,7 @@ public class SciDepartmentMembersTab implements GenericOrgaUnitTab {
|
|||
final Element parent,
|
||||
final PageState state) {
|
||||
final long start = System.currentTimeMillis();
|
||||
final DataQuery persons = getData(orgaunit, state);
|
||||
final DataCollection persons = getData(orgaunit, state);
|
||||
final HttpServletRequest request = state.getRequest();
|
||||
|
||||
//applyStatusFilter(persons, request);
|
||||
|
|
@ -114,7 +112,7 @@ public class SciDepartmentMembersTab implements GenericOrgaUnitTab {
|
|||
paginator.generateXml(depMembersElem);
|
||||
|
||||
while (persons.next()) {
|
||||
generateMemberXml((BigDecimal) persons.get("id"),
|
||||
generateMemberXml(new GenericPerson(persons.getDataObject()),
|
||||
depMembersElem,
|
||||
state);
|
||||
}
|
||||
|
|
@ -125,8 +123,8 @@ public class SciDepartmentMembersTab implements GenericOrgaUnitTab {
|
|||
System.currentTimeMillis() - start));
|
||||
}
|
||||
|
||||
protected DataQuery getData(final GenericOrganizationalUnit orgaunit,
|
||||
final PageState state) {
|
||||
protected DataCollection getData(final GenericOrganizationalUnit orgaunit,
|
||||
final PageState state) {
|
||||
final long start = System.currentTimeMillis();
|
||||
|
||||
if (!(orgaunit instanceof SciDepartment)) {
|
||||
|
|
@ -170,11 +168,11 @@ public class SciDepartmentMembersTab implements GenericOrgaUnitTab {
|
|||
}
|
||||
final DataCollection membersQuery = SessionManager.getSession().retrieve(GenericPerson.BASE_DATA_OBJECT_TYPE);
|
||||
|
||||
if (filterBuilder.length() > 0) {
|
||||
membersQuery.addFilter(String.format("parent.id in (%s)", filterBuilder.toString()));
|
||||
} else {
|
||||
if (filterBuilder.length() == 0) {
|
||||
//No member return null to indicate
|
||||
return null;
|
||||
} else {
|
||||
membersQuery.addFilter(String.format("parent.id in (%s)", filterBuilder.toString()));
|
||||
}
|
||||
|
||||
membersQuery.addOrder(GenericPerson.SURNAME);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -72,6 +77,8 @@ public class SciDepartmentProjectsTab implements GenericOrgaUnitTab {
|
|||
public boolean hasData(final GenericOrganizationalUnit orgaunit,
|
||||
final PageState state) {
|
||||
final long start = System.currentTimeMillis();
|
||||
|
||||
//Check if SciProject content type is installed
|
||||
final ContentTypeCollection types = ContentType.getAllContentTypes();
|
||||
types.addFilter(
|
||||
"associatedObjectType = 'com.arsdigita.cms.contenttypes.SciProject'");
|
||||
|
|
@ -81,7 +88,9 @@ public class SciDepartmentProjectsTab 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 department "
|
||||
+ "'%s' has projects.",
|
||||
|
|
@ -95,7 +104,7 @@ public class SciDepartmentProjectsTab 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(
|
||||
|
|
@ -139,8 +148,6 @@ public class SciDepartmentProjectsTab implements GenericOrgaUnitTab {
|
|||
titleFilter.generateXml(filtersElem);
|
||||
|
||||
} else {
|
||||
//projects.addOrder("title");
|
||||
|
||||
applyStatusFilter(projects, request);
|
||||
applyTitleFilter(projects, request);
|
||||
|
||||
|
|
@ -171,7 +178,7 @@ public class SciDepartmentProjectsTab implements GenericOrgaUnitTab {
|
|||
}
|
||||
|
||||
while (projects.next()) {
|
||||
generateProjectXml((BigDecimal) projects.get("projectId"),
|
||||
generateProjectXml((BigDecimal) projects.get("id"),
|
||||
depProjectsElem,
|
||||
state);
|
||||
}
|
||||
|
|
@ -182,7 +189,7 @@ public class SciDepartmentProjectsTab 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 SciDepartment)) {
|
||||
|
|
@ -193,10 +200,9 @@ public class SciDepartmentProjectsTab 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()) {
|
||||
|
|
@ -204,27 +210,47 @@ public class SciDepartmentProjectsTab implements GenericOrgaUnitTab {
|
|||
SessionManager.getSession().retrieveQuery(
|
||||
"com.arsdigita.cms.contenttypes.getIdsOfSubordinateOrgaUnitsRecursivlyWithAssocType");
|
||||
subDepartmentsQuery.setParameter("orgaunitId",
|
||||
orgaunit.getID().toString());
|
||||
orgaunit.getContentBundle().getID().toString());
|
||||
subDepartmentsQuery.setParameter("assocType",
|
||||
SciDepartmentSubDepartmentsStep.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());
|
||||
}
|
||||
projectBundlesQuery.setParameter("orgaunitIds", orgaunitIds);
|
||||
|
||||
//projectsQuery.addFilter(projectsFilter.toString());
|
||||
projectsQuery.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;
|
||||
} else {
|
||||
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 department '%s'"
|
||||
|
|
@ -232,6 +258,7 @@ public class SciDepartmentProjectsTab implements GenericOrgaUnitTab {
|
|||
orgaunit.getName(),
|
||||
System.currentTimeMillis() - start,
|
||||
config.isMergingProjects()));
|
||||
|
||||
return projectsQuery;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,100 +26,21 @@ object type SciProjectBundle extends GenericOrganizationalUnitBundle {
|
|||
query getIdsOfProjectsOfOrgaUnit {
|
||||
BigDecimal projectId;
|
||||
BigDecimal orgaunitId;
|
||||
String title;
|
||||
Date projectBegin;
|
||||
Date projectEnd;
|
||||
String name;
|
||||
|
||||
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
|
||||
from ct_sci_projects
|
||||
join cms_pages on ct_sci_projects.project_id = cms_pages.item_id
|
||||
join cms_organizationalunits_hierarchy_map on ct_sci_projects.project_id = cms_organizationalunits_hierarchy_map.subordinate_orgaunit_id
|
||||
select distinct on (ct_sci_project_bundles.bundle_id)
|
||||
ct_sci_project_bundles.bundle_id,
|
||||
cms_items.name,
|
||||
cms_organizationalunits_hierarchy_map.superior_orgaunit_id
|
||||
from ct_sci_project_bundles
|
||||
join cms_items on ct_sci_project_bundles.bundle_id = ct_sci_project_bundles.bundle_id
|
||||
join cms_organizationalunits_hierarchy_map on ct_sci_project_bundles.bundle_id = cms_organizationalunits_hierarchy_map.subordinate_orgaunit_id
|
||||
where cms_organizationalunits_hierarchy_map.assoc_type = 'ProjectOf'
|
||||
and cms_organizationalunits_hierarchy_map.superior_orgaunit_id in :orgaunitIds
|
||||
} map {
|
||||
projectId = ct_sci_projects.project_id;
|
||||
projectId = ct_sci_project_bundles.bundle_id;
|
||||
orgaunitId = cms_organizationalunits_hierarchy_map.superior_orgaunit_id;
|
||||
title = cms_pages.title;
|
||||
projectBegin = ct_sci_projects.projectbegin;
|
||||
projectEnd = ct_sci_projects.projectend;
|
||||
name = cms_items.name;
|
||||
}
|
||||
}
|
||||
|
||||
// Some queries from old SciProjects, from ccm-sci-types-organization module
|
||||
//Not used anywhere. Kept for reference.
|
||||
//query getIdsOfContactsOfSciProject {
|
||||
// BigDecimal contactId;
|
||||
//
|
||||
// do {
|
||||
// select cms_organizationalunits_contact_map.contact_id
|
||||
// from cms_organizationalunits_contact_map
|
||||
// where cms_organizationalunits_contact_map.organizationalunit_id = :project
|
||||
// } map {
|
||||
// contactId = cms_organizationalunits_contact_map.contact_id;
|
||||
// }
|
||||
//}
|
||||
|
||||
//query getIdsOfSubProjectsOfSciProject {
|
||||
// BigDecimal projectId;
|
||||
//
|
||||
// do {
|
||||
// select cms_organizationalunit_hierarchy_map.subordinate_orgaunit_id
|
||||
// from cms_organizationalunit_hierarchy_map
|
||||
// where cms_organizationalunit_hierarchy_map.superior_orgaunit_id = :project
|
||||
// and cms_organizationalunit_hierarchy_map.assoc_type = 'subproject'
|
||||
// } map {
|
||||
// projectId = ct_sciorga_projects_subprojects_map.project_id;
|
||||
// }
|
||||
//}
|
||||
|
||||
//query getIdsOfMembersOfSciProject {
|
||||
// BigDecimal memberId;
|
||||
//
|
||||
// do {
|
||||
// select cms_organizationalunits_person_map.person_id
|
||||
// from cms_organizationalunits_person_map
|
||||
// where cms_organizationalunits_person_map.organizationalunit_id = :project
|
||||
// } map {
|
||||
// memberId = cms_organizationalunits_person_map.person_id;
|
||||
// }
|
||||
//}
|
||||
|
||||
//query getIdsOfActiveMembersOfSciProject {
|
||||
// BigDecimal memberId;
|
||||
//
|
||||
// do {
|
||||
// select cms_organizationalunits_person_map.person_id
|
||||
// from cms_organizationalunits_person_map
|
||||
// where cms_organizationalunits_person_map.organizationalunit_id = :project
|
||||
// and cms_organizationalunits_person_map.status = 'active'
|
||||
// } map {
|
||||
// memberId = cms_organizationalunits_person_map.person_id;
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//query getIdsOfAssociatedMembersOfSciProject {
|
||||
// BigDecimal memberId;
|
||||
//
|
||||
// do {
|
||||
// select cms_organizationalunits_person_map.person_id
|
||||
// from cms_organizationalunits_person_map
|
||||
// where cms_organizationalunits_person_map.organizationalunit_id = :project
|
||||
// and cms_organizationalunits_person_map.status = 'associated'
|
||||
// } map {
|
||||
// memberId = cms_organizationalunits_person_map.personId;
|
||||
//// }
|
||||
//}
|
||||
|
||||
//query getIdsOfFormerMembersOfSciProject {
|
||||
// BigDecimal memberId;
|
||||
//
|
||||
// do {
|
||||
// select cms_organizationalunits_person_map.cms_persons.person_id
|
||||
// from cms_organizationalunits_person_map
|
||||
// where cms_organizationalunits_person_map.organizationalunit_id = :project
|
||||
// and (cms_organizationalunits_person_map.status = 'former' or cms_organizationalunits_person_map.status = 'associatedFormer')
|
||||
// } map {
|
||||
// memberId = cms_organizationalunits_person_map.personId;
|
||||
// }
|
||||
//}
|
||||
|
|
|
|||
Loading…
Reference in New Issue