PublicPersonalProfile/PersonProjects und PublicPersonProfile/PersonalProjects sind jetzt kompatibel mit neuen
Datenstrukturen für Projekte und Publikationen. (Tickets #1215 und #1216) git-svn-id: https://svn.libreccm.org/ccm/trunk@1610 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
36b38964e1
commit
af807b85ff
|
|
@ -91,6 +91,8 @@ public class PublicPersonalProfileExtraXmlGenerator implements ExtraXMLGenerator
|
||||||
new PublicPersonalProfileXmlGenerator(
|
new PublicPersonalProfileXmlGenerator(
|
||||||
contacts.getContact());
|
contacts.getContact());
|
||||||
cGenerator.setItemElemName("contact", "");
|
cGenerator.setItemElemName("contact", "");
|
||||||
|
cGenerator.addItemAttribute("contactType",
|
||||||
|
contacts.getContactType());
|
||||||
cGenerator.generateXML(state, contactsElem, "");
|
cGenerator.generateXML(state, contactsElem, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,14 @@ public class GenericOrganizationalUnitSubordinateCollection extends DomainCollec
|
||||||
return (GenericOrganizationalUnit) bundle.getPrimaryInstance();
|
return (GenericOrganizationalUnit) bundle.getPrimaryInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GenericOrganizationalUnit getGenericOrganizationalUnit(
|
||||||
|
final String language) {
|
||||||
|
final ContentBundle bundle = (ContentBundle) DomainObjectFactory.
|
||||||
|
newInstance(m_dataCollection.getDataObject());
|
||||||
|
|
||||||
|
return (GenericOrganizationalUnit) bundle.getInstance(language);
|
||||||
|
}
|
||||||
|
|
||||||
public BigDecimal getId() {
|
public BigDecimal getId() {
|
||||||
return (BigDecimal) m_dataCollection.getDataObject().get(ACSObject.ID);
|
return (BigDecimal) m_dataCollection.getDataObject().get(ACSObject.ID);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,13 @@ import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.cms.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitPersonCollection;
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitPersonCollection;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitSubordinateCollection;
|
||||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||||
|
import com.arsdigita.cms.contenttypes.ui.panels.Paginator;
|
||||||
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||||
import com.arsdigita.persistence.DataQuery;
|
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
@ -23,7 +25,7 @@ public abstract class GenericOrgaUnitMembersTab implements GenericOrgaUnitTab {
|
||||||
Logger.getLogger(GenericOrgaUnitMembersTab.class);
|
Logger.getLogger(GenericOrgaUnitMembersTab.class);
|
||||||
|
|
||||||
public boolean hasData(final GenericOrganizationalUnit orgaunit) {
|
public boolean hasData(final GenericOrganizationalUnit orgaunit) {
|
||||||
final long start = System.currentTimeMillis();
|
/*final long start = System.currentTimeMillis();
|
||||||
final boolean result = !getData(orgaunit).isEmpty();
|
final boolean result = !getData(orgaunit).isEmpty();
|
||||||
logger.debug(String.format(
|
logger.debug(String.format(
|
||||||
"Needed %d ms to determine if "
|
"Needed %d ms to determine if "
|
||||||
|
|
@ -31,7 +33,8 @@ public abstract class GenericOrgaUnitMembersTab implements GenericOrgaUnitTab {
|
||||||
System.currentTimeMillis() - start,
|
System.currentTimeMillis() - start,
|
||||||
orgaunit.getName(),
|
orgaunit.getName(),
|
||||||
isMergingMembers()));
|
isMergingMembers()));
|
||||||
return result;
|
return result;*/
|
||||||
|
return !orgaunit.getPersons().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateXml(final GenericOrganizationalUnit orgaunit,
|
public void generateXml(final GenericOrganizationalUnit orgaunit,
|
||||||
|
|
@ -39,26 +42,23 @@ public abstract class GenericOrgaUnitMembersTab implements GenericOrgaUnitTab {
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
|
|
||||||
final DataQuery persons = getData(orgaunit, state);
|
List<GenericPerson> persons = getPersons(orgaunit, state);
|
||||||
|
|
||||||
final Element personsElem = parent.newChildElement(getXmlElementName());
|
final Element personsElem = parent.newChildElement(getXmlElementName());
|
||||||
|
|
||||||
if (getPageSize() != 0) {
|
if (getPageSize() != 0) {
|
||||||
final GenericOrgaUnitPaginator<DataQuery> paginator =
|
final Paginator paginator = new Paginator(
|
||||||
new GenericOrgaUnitPaginator<DataQuery>(
|
state.getRequest(), persons.size(), getPageSize());
|
||||||
persons, state, getPageSize());
|
|
||||||
paginator.setRange(persons);
|
|
||||||
paginator.generateXml(personsElem);
|
paginator.generateXml(personsElem);
|
||||||
|
if (paginator.getEnd() < persons.size()) {
|
||||||
|
persons = persons.subList(paginator.getBegin(), paginator.getEnd());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (persons.next()) {
|
for(GenericPerson person : persons) {
|
||||||
/*generatePersonXml((BigDecimal) persons.get("memberId"),
|
generatePersonXml(person, personsElem, state);
|
||||||
parent,
|
|
||||||
state);*/
|
|
||||||
generatePersonXml(((GenericOrganizationalUnitPersonCollection) persons).getPerson().getID(),
|
|
||||||
parent,
|
|
||||||
state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug(String.format("Generated member list of organizational "
|
logger.debug(String.format("Generated member list of organizational "
|
||||||
+ "unit '%s' in %d ms.",
|
+ "unit '%s' in %d ms.",
|
||||||
orgaunit.getName(),
|
orgaunit.getName(),
|
||||||
|
|
@ -70,6 +70,14 @@ public abstract class GenericOrgaUnitMembersTab implements GenericOrgaUnitTab {
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final GenericPerson person = new GenericPerson(personId);
|
final GenericPerson person = new GenericPerson(personId);
|
||||||
|
|
||||||
|
final XmlGenerator generator = new XmlGenerator(person);
|
||||||
|
generator.setItemElemName("person", "");
|
||||||
|
generator.generateXML(state, parent, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generatePersonXml(final GenericPerson person,
|
||||||
|
final Element parent,
|
||||||
|
final PageState state) {
|
||||||
final XmlGenerator generator = new XmlGenerator(person);
|
final XmlGenerator generator = new XmlGenerator(person);
|
||||||
generator.generateXML(state, parent, "");
|
generator.generateXML(state, parent, "");
|
||||||
}
|
}
|
||||||
|
|
@ -86,50 +94,15 @@ public abstract class GenericOrgaUnitMembersTab implements GenericOrgaUnitTab {
|
||||||
|
|
||||||
protected abstract int getPageSize();
|
protected abstract int getPageSize();
|
||||||
|
|
||||||
protected DataQuery getData(final GenericOrganizationalUnit orgaunit,
|
protected List<GenericPerson> getPersons(
|
||||||
|
final GenericOrganizationalUnit orgaunit,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
return getData(orgaunit);
|
final long start = System.currentTimeMillis();
|
||||||
}
|
|
||||||
|
|
||||||
protected DataQuery getData(final GenericOrganizationalUnit orgaunit) {
|
final List<GenericPerson> persons = new LinkedList<GenericPerson>();
|
||||||
return orgaunit.getPersons();
|
|
||||||
|
|
||||||
/*final long start = System.currentTimeMillis();
|
final GenericOrganizationalUnitPersonCollection personColl = orgaunit.
|
||||||
|
getPersons();
|
||||||
final DataQuery personsQuery = SessionManager.getSession().retrieveQuery(
|
|
||||||
"com.arsdigita.cms.contenttypes.getIdsOfMembersOfOrgaUnits");
|
|
||||||
|
|
||||||
if (isMergingMembers()) {
|
|
||||||
final DataQuery subOrgaUnitsQuery =
|
|
||||||
SessionManager.getSession().retrieveQuery(
|
|
||||||
"com.arsdigita.cms.contenttypes.getIdsOfSubordinateOrgaUnitsRecursivly");
|
|
||||||
subOrgaUnitsQuery.setParameter("orgaunitId", orgaunit.getID().
|
|
||||||
toString());
|
|
||||||
final StringBuffer assocTypeFilter = new StringBuffer();
|
|
||||||
for (String assocType : getAssocTypesToMerge()) {
|
|
||||||
if (assocTypeFilter.length() > 0) {
|
|
||||||
assocTypeFilter.append(" or ");
|
|
||||||
}
|
|
||||||
assocTypeFilter.append(String.format("assocType = '%s'",
|
|
||||||
assocType));
|
|
||||||
}
|
|
||||||
subOrgaUnitsQuery.addFilter(assocTypeFilter.toString());
|
|
||||||
|
|
||||||
final StringBuffer buffer = new StringBuffer();
|
|
||||||
while (subOrgaUnitsQuery.next()) {
|
|
||||||
if (buffer.length() > 0) {
|
|
||||||
buffer.append(" or ");
|
|
||||||
}
|
|
||||||
buffer.append(String.format("orgaunitId = %s",
|
|
||||||
subOrgaUnitsQuery.get("orgaunitId").
|
|
||||||
toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
personsQuery.addFilter(buffer.toString());
|
|
||||||
} else {
|
|
||||||
personsQuery.addFilter(String.format("orgaunitId = %s",
|
|
||||||
orgaunit.getID().toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((getRolesToInclude() != null) && !getRolesToInclude().isEmpty()) {
|
if ((getRolesToInclude() != null) && !getRolesToInclude().isEmpty()) {
|
||||||
final StringBuffer roleFilter = new StringBuffer();
|
final StringBuffer roleFilter = new StringBuffer();
|
||||||
|
|
@ -137,9 +110,10 @@ public abstract class GenericOrgaUnitMembersTab implements GenericOrgaUnitTab {
|
||||||
if (roleFilter.length() > 0) {
|
if (roleFilter.length() > 0) {
|
||||||
roleFilter.append(" or ");
|
roleFilter.append(" or ");
|
||||||
}
|
}
|
||||||
roleFilter.append(String.format("roleName = '%s'", role));
|
roleFilter.append(String.format("link.roleName = '%s'",
|
||||||
|
role));
|
||||||
}
|
}
|
||||||
personsQuery.addFilter(roleFilter.toString());
|
personColl.addFilter(roleFilter.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((getStatusesToInclude() != null)
|
if ((getStatusesToInclude() != null)
|
||||||
|
|
@ -149,21 +123,56 @@ public abstract class GenericOrgaUnitMembersTab implements GenericOrgaUnitTab {
|
||||||
if (statusFilter.length() > 0) {
|
if (statusFilter.length() > 0) {
|
||||||
statusFilter.append(" or ");
|
statusFilter.append(" or ");
|
||||||
}
|
}
|
||||||
statusFilter.append(String.format("status = '%s'", status));
|
statusFilter.append(String.format("link.status = '%s'", status));
|
||||||
}
|
}
|
||||||
personsQuery.addFilter(statusFilter.toString());
|
personColl.addFilter(statusFilter.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
personsQuery.addOrder("surname");
|
while (personColl.next()) {
|
||||||
personsQuery.addOrder("givenname");
|
persons.add(personColl.getPerson());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isMergingMembers()) {
|
||||||
|
getPersonsFromSubordinateOrgaUnits(orgaunit, persons, state);
|
||||||
|
}
|
||||||
|
|
||||||
logger.debug(String.format(
|
logger.debug(String.format(
|
||||||
"Got persons for organizational unit '%s'"
|
"Got members of orgaunit '%s'"
|
||||||
+ "in %d ms. isMergingMembers is set to '%b'.",
|
+ "in '%d ms'. MergeMembers is set to '%b'.",
|
||||||
orgaunit.getName(),
|
orgaunit.getName(),
|
||||||
System.currentTimeMillis() - start,
|
System.currentTimeMillis() - start,
|
||||||
isMergingMembers()));
|
isMergingMembers()));
|
||||||
return personsQuery;*/
|
return persons;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void getPersonsFromSubordinateOrgaUnits(
|
||||||
|
final GenericOrganizationalUnit orgaunit,
|
||||||
|
final List<GenericPerson> persons,
|
||||||
|
final PageState state) {
|
||||||
|
final GenericOrganizationalUnitSubordinateCollection subOrgaUnits =
|
||||||
|
orgaunit.
|
||||||
|
getSubordinateOrgaUnits();
|
||||||
|
final StringBuffer assocTypeFilter = new StringBuffer();
|
||||||
|
for (String assocType : getAssocTypesToMerge()) {
|
||||||
|
if (assocTypeFilter.length() > 0) {
|
||||||
|
assocTypeFilter.append(" or ");
|
||||||
|
}
|
||||||
|
assocTypeFilter.append(String.format("assocType = '%s'", assocType));
|
||||||
|
}
|
||||||
|
subOrgaUnits.addFilter(assocTypeFilter.toString());
|
||||||
|
|
||||||
|
while (subOrgaUnits.next()) {
|
||||||
|
getPersonsFromSubordinateOrgaUnit(orgaunit, persons, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void getPersonsFromSubordinateOrgaUnit(
|
||||||
|
final GenericOrganizationalUnit subOrgaUnit,
|
||||||
|
final List<GenericPerson> persons,
|
||||||
|
final PageState state) {
|
||||||
|
final List<GenericPerson> subOrgaUnitMembers = getPersons(subOrgaUnit,
|
||||||
|
state);
|
||||||
|
persons.addAll(subOrgaUnitMembers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import com.arsdigita.cms.ItemSelectionModel;
|
||||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitSubordinateCollection;
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitSubordinateCollection;
|
||||||
import com.arsdigita.cms.dispatcher.ItemResolver;
|
import com.arsdigita.cms.dispatcher.ItemResolver;
|
||||||
import com.arsdigita.cms.dispatcher.Utilities;
|
import com.arsdigita.globalization.GlobalizationHelper;
|
||||||
import com.arsdigita.util.LockableImpl;
|
import com.arsdigita.util.LockableImpl;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
@ -152,7 +152,9 @@ public class GenericOrganizationalUnitSubordinateOrgaUnitsTable
|
||||||
public Object getElementAt(final int columnIndex) {
|
public Object getElementAt(final int columnIndex) {
|
||||||
switch (columnIndex) {
|
switch (columnIndex) {
|
||||||
case 0:
|
case 0:
|
||||||
return subordinateOrgaUnits.getTitle();
|
return subordinateOrgaUnits.getGenericOrganizationalUnit(
|
||||||
|
GlobalizationHelper.getNegotiatedLocale().
|
||||||
|
getLanguage()).getTitle();
|
||||||
case 1:
|
case 1:
|
||||||
return customizer.getDeleteLabel();
|
return customizer.getDeleteLabel();
|
||||||
case 2:
|
case 2:
|
||||||
|
|
@ -166,7 +168,9 @@ public class GenericOrganizationalUnitSubordinateOrgaUnitsTable
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getKeyAt(final int columnIndex) {
|
public Object getKeyAt(final int columnIndex) {
|
||||||
return subordinateOrgaUnits.getId();
|
return subordinateOrgaUnits.getGenericOrganizationalUnit(
|
||||||
|
GlobalizationHelper.getNegotiatedLocale().getLanguage()).
|
||||||
|
getID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -182,7 +186,7 @@ public class GenericOrganizationalUnitSubordinateOrgaUnitsTable
|
||||||
final Object key,
|
final Object key,
|
||||||
final int row,
|
final int row,
|
||||||
final int column) {
|
final int column) {
|
||||||
final com.arsdigita.cms.SecurityManager securityManager = Utilities.
|
final com.arsdigita.cms.SecurityManager securityManager = CMS.
|
||||||
getSecurityManager(state);
|
getSecurityManager(state);
|
||||||
final GenericOrganizationalUnit subordinateOrgaUnit =
|
final GenericOrganizationalUnit subordinateOrgaUnit =
|
||||||
new GenericOrganizationalUnit(
|
new GenericOrganizationalUnit(
|
||||||
|
|
@ -230,7 +234,7 @@ public class GenericOrganizationalUnitSubordinateOrgaUnitsTable
|
||||||
final Object key,
|
final Object key,
|
||||||
final int row,
|
final int row,
|
||||||
final int column) {
|
final int column) {
|
||||||
final com.arsdigita.cms.SecurityManager securityManager = Utilities.
|
final com.arsdigita.cms.SecurityManager securityManager = CMS.
|
||||||
getSecurityManager(state);
|
getSecurityManager(state);
|
||||||
final GenericOrganizationalUnit orgaunit =
|
final GenericOrganizationalUnit orgaunit =
|
||||||
(GenericOrganizationalUnit) itemModel.
|
(GenericOrganizationalUnit) itemModel.
|
||||||
|
|
@ -303,9 +307,9 @@ public class GenericOrganizationalUnitSubordinateOrgaUnitsTable
|
||||||
}
|
}
|
||||||
if ((customizer.getContentType() != null)
|
if ((customizer.getContentType() != null)
|
||||||
&& !(customizer.getContentType().isEmpty())) {
|
&& !(customizer.getContentType().isEmpty())) {
|
||||||
subOrgaUnits.addFilter(String.format("objectType = '%s'",
|
subOrgaUnits.addFilter(
|
||||||
customizer.
|
String.format("objectType = '%s'",
|
||||||
getContentType()));
|
customizer.getContentType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((subOrgaUnits.size() - 1) == row) {
|
if ((subOrgaUnits.size() - 1) == row) {
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,14 @@ public class CompareFilter implements Filter {
|
||||||
return filter.toString();
|
return filter.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Operators getOperator() {
|
||||||
|
return options.get(value).getOperator();
|
||||||
|
}
|
||||||
|
|
||||||
public void generateXml(final Element parent) {
|
public void generateXml(final Element parent) {
|
||||||
Element filter;
|
Element filter;
|
||||||
String selected;
|
String selected;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import com.arsdigita.web.URL;
|
||||||
import com.arsdigita.web.Web;
|
import com.arsdigita.web.Web;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
@ -122,7 +123,7 @@ public class Paginator {
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getBegin() {
|
public int getBegin() {
|
||||||
if (pageNumber == 1) {
|
if (pageNumber == 1) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -130,11 +131,11 @@ public class Paginator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getCount() {
|
public int getCount() {
|
||||||
return Math.min(pageSize, (objectCount - getBegin() + 1));
|
return Math.min(pageSize, (objectCount - getBegin() + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getEnd() {
|
public int getEnd() {
|
||||||
int paginatorEnd = getBegin() + getCount() - 1;
|
int paginatorEnd = getBegin() + getCount() - 1;
|
||||||
if (paginatorEnd < 0) {
|
if (paginatorEnd < 0) {
|
||||||
paginatorEnd = 0;
|
paginatorEnd = 0;
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,10 @@ public class TextFilter implements Filter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setValue(final String value) {
|
public void setValue(final String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.arsdigita.cms.publicpersonalprofile;
|
package com.arsdigita.cms.publicpersonalprofile;
|
||||||
|
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
import com.arsdigita.cms.contenttypes.GenericAddress;
|
import com.arsdigita.cms.contenttypes.GenericAddress;
|
||||||
import com.arsdigita.cms.contenttypes.GenericContactEntry;
|
import com.arsdigita.cms.contenttypes.GenericContactEntry;
|
||||||
import com.arsdigita.cms.contenttypes.GenericContactEntryCollection;
|
import com.arsdigita.cms.contenttypes.GenericContactEntryCollection;
|
||||||
|
|
@ -9,10 +10,11 @@ import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitPersonCollection;
|
||||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||||
import com.arsdigita.cms.contenttypes.GenericPersonContactCollection;
|
import com.arsdigita.cms.contenttypes.GenericPersonContactCollection;
|
||||||
import com.arsdigita.cms.contenttypes.SciProject;
|
import com.arsdigita.cms.contenttypes.SciProject;
|
||||||
|
import com.arsdigita.cms.contenttypes.SciProjectBundle;
|
||||||
|
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||||
import com.arsdigita.domain.DomainObject;
|
import com.arsdigita.domain.DomainObject;
|
||||||
import com.arsdigita.domain.DomainObjectFactory;
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
import com.arsdigita.globalization.GlobalizationHelper;
|
import com.arsdigita.globalization.GlobalizationHelper;
|
||||||
import com.arsdigita.kernel.Kernel;
|
|
||||||
import com.arsdigita.persistence.DataCollection;
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
|
|
@ -24,6 +26,7 @@ import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
@ -57,7 +60,7 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
final GenericPerson person,
|
final GenericPerson person,
|
||||||
final PageState state,
|
final PageState state,
|
||||||
final String profileLanguage) {
|
final String profileLanguage) {
|
||||||
final List<SciProject> projects = collectProjects(person,
|
final List<SciProjectBundle> projects = collectProjects(person,
|
||||||
profileLanguage);
|
profileLanguage);
|
||||||
|
|
||||||
final Element personalProjectsElem = parent.newChildElement(
|
final Element personalProjectsElem = parent.newChildElement(
|
||||||
|
|
@ -66,9 +69,10 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
if ((projects == null) || projects.isEmpty()) {
|
if ((projects == null) || projects.isEmpty()) {
|
||||||
personalProjectsElem.newChildElement("noProjects");
|
personalProjectsElem.newChildElement("noProjects");
|
||||||
} else {
|
} else {
|
||||||
final List<SciProject> currentProjects = new ArrayList<SciProject>();
|
final List<SciProjectBundle> currentProjects =
|
||||||
final List<SciProject> finishedProjects =
|
new ArrayList<SciProjectBundle>();
|
||||||
new ArrayList<SciProject>();
|
final List<SciProjectBundle> finishedProjects =
|
||||||
|
new ArrayList<SciProjectBundle>();
|
||||||
|
|
||||||
String sortBy = config.getSortBy();
|
String sortBy = config.getSortBy();
|
||||||
String sortByParam = state.getRequest().getParameter("sortBy");
|
String sortByParam = state.getRequest().getParameter("sortBy");
|
||||||
|
|
@ -86,67 +90,17 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SciProject> collectProjects(final GenericPerson person,
|
private List<SciProjectBundle> collectProjects(final GenericPerson person,
|
||||||
final String language) {
|
final String language) {
|
||||||
final List<SciProject> projects = new ArrayList<SciProject>();
|
final List<SciProjectBundle> projects =
|
||||||
|
new LinkedList<SciProjectBundle>();
|
||||||
/*final DataCollection collection = (DataCollection) person.get(
|
final DataCollection collection = (DataCollection) person.
|
||||||
"organizationalunit");
|
getGenericPersonBundle().get("organizationalunits");
|
||||||
if (Kernel.getConfig().languageIndependentItems()) {*/
|
|
||||||
/* FilterFactory ff = collection.getFilterFactory();
|
|
||||||
Filter filter = ff.or().*/
|
|
||||||
/*addFilter(ff.equals("language",
|
|
||||||
com.arsdigita.globalization.GlobalizationHelper.
|
|
||||||
getNegotiatedLocale().getLanguage())).*/
|
|
||||||
/*addFilter(ff.equals("language", language)).
|
|
||||||
addFilter(ff.and().
|
|
||||||
addFilter(ff.equals("language",
|
|
||||||
GlobalizationHelper.LANG_INDEPENDENT)).
|
|
||||||
addFilter(ff.notIn("parent",
|
|
||||||
"com.arsdigita.london.navigation.getParentIDsOfMatchedItems").
|
|
||||||
set("language",
|
|
||||||
com.arsdigita.globalization.GlobalizationHelper.
|
|
||||||
getNegotiatedLocale().getLanguage())));
|
|
||||||
collection.addFilter(filter);*/
|
|
||||||
/*collection.addFilter(
|
|
||||||
String.format("(language = '%s' or language = '%s')",
|
|
||||||
language,
|
|
||||||
GlobalizationHelper.LANG_INDEPENDENT));
|
|
||||||
} else {
|
|
||||||
/*collection.addEqualsFilter("language",
|
|
||||||
com.arsdigita.globalization.GlobalizationHelper.
|
|
||||||
getNegotiatedLocale().getLanguage());*/
|
|
||||||
/* collection.addEqualsFilter("language", language);
|
|
||||||
}*/
|
|
||||||
final List<BigDecimal> processed = new ArrayList<BigDecimal>();
|
|
||||||
final DataCollection collection = (DataCollection) person.get(
|
|
||||||
"organizationalunit");
|
|
||||||
collection.addFilter(String.format("language = '%s'", language));
|
|
||||||
DomainObject obj;
|
DomainObject obj;
|
||||||
while (collection.next()) {
|
while (collection.next()) {
|
||||||
obj = DomainObjectFactory.newInstance(collection.getDataObject());
|
obj = DomainObjectFactory.newInstance(collection.getDataObject());
|
||||||
if (obj instanceof SciProject) {
|
if (obj instanceof SciProjectBundle) {
|
||||||
processed.add(((SciProject) obj).getParent().getID());
|
projects.add((SciProjectBundle) obj);
|
||||||
projects.add((SciProject) obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Kernel.getConfig().languageIndependentItems()) {
|
|
||||||
final DataCollection collectionLi = (DataCollection) person.get(
|
|
||||||
"organizationalunit");
|
|
||||||
collectionLi.addFilter(
|
|
||||||
String.format("language = '%s'",
|
|
||||||
GlobalizationHelper.LANG_INDEPENDENT));
|
|
||||||
|
|
||||||
while (collectionLi.next()) {
|
|
||||||
obj =
|
|
||||||
DomainObjectFactory.newInstance(collectionLi.getDataObject());
|
|
||||||
if (obj instanceof SciProject) {
|
|
||||||
if (!(processed.contains(((SciProject) obj).getParent().
|
|
||||||
getID()))) {
|
|
||||||
projects.add((SciProject) obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -158,63 +112,40 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collectProjects(final GenericPerson alias,
|
private void collectProjects(final GenericPerson alias,
|
||||||
final List<SciProject> projects,
|
final List<SciProjectBundle> projects,
|
||||||
final String language) {
|
final String language) {
|
||||||
final DataCollection collection = (DataCollection) alias.get(
|
final DataCollection collection = (DataCollection) alias.
|
||||||
"organizationalunit");
|
getGenericPersonBundle().get("organizationalunits");
|
||||||
final List<BigDecimal> processed = new ArrayList<BigDecimal>();
|
|
||||||
collection.addFilter(String.format("language = '%s'", language));
|
|
||||||
DomainObject obj;
|
DomainObject obj;
|
||||||
while (collection.next()) {
|
while (collection.next()) {
|
||||||
obj = DomainObjectFactory.newInstance(collection.getDataObject());
|
obj = DomainObjectFactory.newInstance(collection.getDataObject());
|
||||||
if (obj instanceof SciProject) {
|
if (obj instanceof SciProjectBundle) {
|
||||||
processed.add(((SciProject) obj).getParent().getID());
|
projects.add((SciProjectBundle) obj);
|
||||||
projects.add((SciProject) obj);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Kernel.getConfig().languageIndependentItems()) {
|
|
||||||
final DataCollection collectionLi = (DataCollection) alias.get(
|
|
||||||
"organizationalunit");
|
|
||||||
collectionLi.addFilter(
|
|
||||||
String.format("language = '%s'",
|
|
||||||
GlobalizationHelper.LANG_INDEPENDENT));
|
|
||||||
|
|
||||||
while (collectionLi.next()) {
|
|
||||||
obj =
|
|
||||||
DomainObjectFactory.newInstance(collectionLi.getDataObject());
|
|
||||||
if (obj instanceof SciProject) {
|
|
||||||
if (!(processed.contains(((SciProject) obj).getParent().
|
|
||||||
getID()))) {
|
|
||||||
projects.add((SciProject) obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (alias.getAlias() != null) {
|
if (alias.getAlias() != null) {
|
||||||
collectProjects(alias.getAlias(), projects, language);
|
collectProjects(alias.getAlias(), projects, language);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processProjects(final List<SciProject> projects,
|
private void processProjects(final List<SciProjectBundle> projects,
|
||||||
final List<SciProject> currentProjects,
|
final List<SciProjectBundle> currentProjects,
|
||||||
final List<SciProject> finishedProjects,
|
final List<SciProjectBundle> finishedProjects,
|
||||||
final String sortBy) {
|
final String sortBy) {
|
||||||
final Calendar today = new GregorianCalendar();
|
final Calendar today = new GregorianCalendar();
|
||||||
final Date todayDate = today.getTime();
|
final Date todayDate = today.getTime();
|
||||||
for (SciProject project : projects) {
|
for (SciProjectBundle project : projects) {
|
||||||
if ((project.getEnd() != null)
|
if ((project.getProject().getEnd() != null)
|
||||||
&& project.getEnd().before(todayDate)) {
|
&& project.getProject().getEnd().before(todayDate)) {
|
||||||
finishedProjects.add(project);
|
finishedProjects.add(project);
|
||||||
} else {
|
} else {
|
||||||
currentProjects.add(project);
|
currentProjects.add(project);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Comparator<SciProject> comparator;
|
Comparator<SciProjectBundle> comparator;
|
||||||
if ("date".equals(sortBy)) {
|
if ("date".equals(sortBy)) {
|
||||||
comparator = new ProjectByDateComparator();
|
comparator = new ProjectByDateComparator();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -226,8 +157,8 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateGroupsXml(final Element parent,
|
private void generateGroupsXml(final Element parent,
|
||||||
final List<SciProject> currentProjects,
|
final List<SciProjectBundle> currentProjects,
|
||||||
final List<SciProject> finishedProjects) {
|
final List<SciProjectBundle> finishedProjects) {
|
||||||
final Element availableGroups = parent.newChildElement(
|
final Element availableGroups = parent.newChildElement(
|
||||||
"availableProjectGroups");
|
"availableProjectGroups");
|
||||||
|
|
||||||
|
|
@ -247,8 +178,8 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateProjectsXml(final Element parent,
|
private void generateProjectsXml(final Element parent,
|
||||||
final List<SciProject> currentProjects,
|
final List<SciProjectBundle> currentProjects,
|
||||||
final List<SciProject> finishedProjects,
|
final List<SciProjectBundle> finishedProjects,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final Element projectsElem = parent.newChildElement("projects");
|
final Element projectsElem = parent.newChildElement("projects");
|
||||||
|
|
||||||
|
|
@ -297,7 +228,7 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
|
|
||||||
private void generateProjectsGroupXml(final Element projectsElem,
|
private void generateProjectsGroupXml(final Element projectsElem,
|
||||||
final String groupName,
|
final String groupName,
|
||||||
final List<SciProject> projects,
|
final List<SciProjectBundle> projects,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
if (projects == null) {
|
if (projects == null) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -306,18 +237,17 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
final Element groupElem = projectsElem.newChildElement("projectGroup");
|
final Element groupElem = projectsElem.newChildElement("projectGroup");
|
||||||
groupElem.addAttribute("name", groupName);
|
groupElem.addAttribute("name", groupName);
|
||||||
|
|
||||||
for (SciProject project : projects) {
|
for (SciProjectBundle project : projects) {
|
||||||
generateProjectXml(groupElem, project, state);
|
generateProjectXml(groupElem, project, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateProjectXml(final Element projectGroupElem,
|
private void generateProjectXml(final Element projectGroupElem,
|
||||||
final SciProject project,
|
final SciProjectBundle projectBundle,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
/*final PublicPersonalProfileXmlGenerator generator =
|
final SciProject project = projectBundle.getProject(GlobalizationHelper.
|
||||||
new PublicPersonalProfileXmlGenerator(
|
getNegotiatedLocale().getLanguage());
|
||||||
project);
|
|
||||||
generator.generateXML(state, projectGroupElem, "");*/
|
|
||||||
Element projectElem = projectGroupElem.newChildElement("project");
|
Element projectElem = projectGroupElem.newChildElement("project");
|
||||||
projectElem.addAttribute("oid", project.getOID().toString());
|
projectElem.addAttribute("oid", project.getOID().toString());
|
||||||
|
|
||||||
|
|
@ -380,7 +310,7 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
|
|
||||||
GenericOrganizationalUnitPersonCollection members;
|
GenericOrganizationalUnitPersonCollection members;
|
||||||
members = project.getPersons();
|
members = project.getPersons();
|
||||||
members.addOrder("surname asc, givenname asc");
|
//members.addOrder("surname asc, givenname asc");
|
||||||
|
|
||||||
if (members.size() > 0) {
|
if (members.size() > 0) {
|
||||||
Element membersElem = projectElem.newChildElement("members");
|
Element membersElem = projectElem.newChildElement("members");
|
||||||
|
|
@ -444,7 +374,7 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
Element surname = memberElem.newChildElement("surname");
|
Element surname = memberElem.newChildElement("surname");
|
||||||
surname.setText(person.getSurname());
|
surname.setText(person.getSurname());
|
||||||
|
|
||||||
Element givenName = memberElem.newChildElement("givenname");
|
Element givenName = memberElem.newChildElement("givenName");
|
||||||
givenName.setText(person.getGivenName());
|
givenName.setText(person.getGivenName());
|
||||||
|
|
||||||
if ((person.getTitlePost() != null)
|
if ((person.getTitlePost() != null)
|
||||||
|
|
@ -739,29 +669,38 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ProjectByTitleComparator implements Comparator<SciProject> {
|
private class ProjectByTitleComparator
|
||||||
|
implements Comparator<SciProjectBundle> {
|
||||||
|
|
||||||
public int compare(final SciProject project1,
|
public int compare(final SciProjectBundle project1,
|
||||||
final SciProject project2) {
|
final SciProjectBundle project2) {
|
||||||
return project1.getTitle().compareTo(project2.getTitle());
|
return project1.getProject().getTitle().compareTo(project2.
|
||||||
|
getProject().getTitle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ProjectByDateComparator implements Comparator<SciProject> {
|
private class ProjectByDateComparator implements
|
||||||
|
Comparator<SciProjectBundle> {
|
||||||
|
|
||||||
public int compare(final SciProject project1,
|
public int compare(final SciProjectBundle project1,
|
||||||
final SciProject project2) {
|
final SciProjectBundle project2) {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if ((project2.getBegin() != null) && (project1.getBegin() != null)) {
|
if ((project2.getProject().getBegin() != null) && (project1.
|
||||||
ret = project2.getBegin().compareTo(project1.getBegin());
|
getProject().
|
||||||
|
getBegin()
|
||||||
|
!= null)) {
|
||||||
|
ret = project2.getProject().getBegin().compareTo(project1.
|
||||||
|
getProject().getBegin());
|
||||||
}
|
}
|
||||||
if ((ret == 0)
|
if ((ret == 0)
|
||||||
&& (project2.getEnd() != null)
|
&& (project2.getProject().getEnd() != null)
|
||||||
&& (project1.getEnd() != null)) {
|
&& (project1.getProject().getEnd() != null)) {
|
||||||
ret = project2.getEnd().compareTo(project1.getBegin());
|
ret = project2.getProject().getEnd().compareTo(project1.
|
||||||
|
getProject().getBegin());
|
||||||
}
|
}
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = project1.getTitle().compareTo(project2.getTitle());
|
ret = project1.getProject().getTitle().compareTo(project2.
|
||||||
|
getProject().getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -802,4 +741,19 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
elem.addAttribute("longDate", longDateFormat.format(date));
|
elem.addAttribute("longDate", longDateFormat.format(date));
|
||||||
elem.addAttribute("time", timeFormat.format(date));
|
elem.addAttribute("time", timeFormat.format(date));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class XmlGenerator extends SimpleXMLGenerator {
|
||||||
|
|
||||||
|
private final ContentItem item;
|
||||||
|
|
||||||
|
public XmlGenerator(final ContentItem item) {
|
||||||
|
super();
|
||||||
|
this.item = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ContentItem getContentItem(final PageState state) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,21 +4,19 @@ import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.cms.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||||
import com.arsdigita.cms.contenttypes.Publication;
|
import com.arsdigita.cms.contenttypes.Publication;
|
||||||
import com.arsdigita.cms.contenttypes.ui.PublicationXmlHelper;
|
import com.arsdigita.cms.contenttypes.PublicationBundle;
|
||||||
import com.arsdigita.cms.contenttypes.ui.panels.Paginator;
|
import com.arsdigita.cms.contenttypes.ui.panels.Paginator;
|
||||||
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||||
|
import com.arsdigita.domain.DomainObject;
|
||||||
import com.arsdigita.domain.DomainObjectFactory;
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
import com.arsdigita.globalization.GlobalizationHelper;
|
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;
|
import com.arsdigita.xml.Element;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
@ -52,136 +50,85 @@ public class PersonalPublications implements ContentGenerator {
|
||||||
final String language) {
|
final String language) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
|
|
||||||
final DataQuery allQuery = SessionManager.getSession().retrieveQuery(
|
final List<PublicationBundle> publications =
|
||||||
"com.arsdigita.cms.contenttypes.getPublicationsForAuthor");
|
collectPublications(person, language);
|
||||||
applyAuthorFilter(person, allQuery, true, language);
|
|
||||||
|
|
||||||
final Element personalPubsElem = parent.newChildElement(
|
final Element personalPubsElem = parent.newChildElement(
|
||||||
"personalPublications");
|
"personalPublications");
|
||||||
final long overallSize;
|
final long overallSize;
|
||||||
if (allQuery == null) {
|
if (publications == null) {
|
||||||
overallSize = 0;
|
overallSize = 0;
|
||||||
} else {
|
} else {
|
||||||
overallSize = allQuery.size();
|
overallSize = publications.size();
|
||||||
}
|
}
|
||||||
if (overallSize <= 0) {
|
if (overallSize <= 0) {
|
||||||
personalPubsElem.newChildElement("noPublications");
|
personalPubsElem.newChildElement("noPublications");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
logger.debug(String.format("1: %d ms until now...", System.
|
final Map<String, List<String>> groupsConfig = getGroupsConfig();
|
||||||
currentTimeMillis() - start));
|
final Map<String, List<PublicationBundle>> publicationsByGroup =
|
||||||
|
new HashMap<String, List<PublicationBundle>>();
|
||||||
|
|
||||||
|
for (Map.Entry<String, List<String>> entry : groupsConfig.entrySet()) {
|
||||||
|
filterPublicationsByGroup(entry.getKey(),
|
||||||
|
entry.getValue(),
|
||||||
|
publications,
|
||||||
|
publicationsByGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<PublicationBundle> miscGroup =
|
||||||
|
filterPublicationsForMiscGroup(
|
||||||
|
publications, groupsConfig);
|
||||||
|
publicationsByGroup.put(MISC, miscGroup);
|
||||||
|
|
||||||
final Element availableGroupsElem =
|
final Element availableGroupsElem =
|
||||||
personalPubsElem.newChildElement(
|
personalPubsElem.newChildElement(
|
||||||
"availablePublicationGroups");
|
"availablePublicationGroups");
|
||||||
final Element publicationsElem = personalPubsElem.newChildElement(
|
final Element publicationsElem = personalPubsElem.newChildElement(
|
||||||
"publications");
|
"publications");
|
||||||
|
|
||||||
final Map<String, List<String>> groupsConfig = getGroupsConfig();
|
|
||||||
final Map<String, DataQuery> groupQueries =
|
|
||||||
new LinkedHashMap<String, DataQuery>();
|
|
||||||
logger.debug(String.format("2: %d ms until now...", System.
|
|
||||||
currentTimeMillis() - start));
|
|
||||||
for (Map.Entry<String, List<String>> entry : groupsConfig.entrySet()) {
|
|
||||||
createGroupQuery(person,
|
|
||||||
entry.getKey(),
|
|
||||||
entry.getValue(),
|
|
||||||
groupQueries,
|
|
||||||
language);
|
|
||||||
logger.debug(String.format("3: %d ms until now...", System.
|
|
||||||
currentTimeMillis() - start));
|
|
||||||
}
|
|
||||||
|
|
||||||
final String miscFilter = generateFilterForMiscGroup(groupsConfig);
|
|
||||||
final DataQuery miscQuery = SessionManager.getSession().
|
|
||||||
retrieveQuery(
|
|
||||||
"com.arsdigita.cms.contenttypes.getPublicationsForAuthor");
|
|
||||||
applyAuthorFilter(person, miscQuery, true, language);
|
|
||||||
miscQuery.addFilter(miscFilter);
|
|
||||||
groupQueries.put(MISC, miscQuery);
|
|
||||||
logger.debug(String.format("4: %d ms until now...", System.
|
|
||||||
currentTimeMillis() - start));
|
|
||||||
logger.debug(String.format("5: %d ms until now...", System.
|
|
||||||
currentTimeMillis() - start));
|
|
||||||
|
|
||||||
if (overallSize < config.getGroupSplit()) {
|
if (overallSize < config.getGroupSplit()) {
|
||||||
publicationsElem.addAttribute("all", "all");
|
publicationsElem.addAttribute("all", "all");
|
||||||
for (Map.Entry<String, List<String>> entry : groupsConfig.
|
for (Map.Entry<String, List<PublicationBundle>> group :
|
||||||
entrySet()) {
|
publicationsByGroup.entrySet()) {
|
||||||
generateXmlForGroup(entry.getKey(),
|
generateXmlForGroup(group.getKey(),
|
||||||
availableGroupsElem,
|
availableGroupsElem,
|
||||||
publicationsElem,
|
publicationsElem,
|
||||||
groupQueries.get(entry.getKey()),
|
group.getValue(),
|
||||||
state,
|
|
||||||
false,
|
false,
|
||||||
true);
|
true,
|
||||||
|
state);
|
||||||
}
|
}
|
||||||
|
|
||||||
generateXmlForGroup(MISC,
|
|
||||||
availableGroupsElem,
|
|
||||||
publicationsElem,
|
|
||||||
groupQueries.get(MISC),
|
|
||||||
state,
|
|
||||||
false,
|
|
||||||
true);
|
|
||||||
} else {
|
} else {
|
||||||
|
final List<String> availableGroups = new LinkedList<String>();
|
||||||
final List<String> availableGroups = new ArrayList<String>();
|
|
||||||
logger.debug(String.format("6: %d ms until now...", System.
|
|
||||||
currentTimeMillis() - start));
|
|
||||||
for (Map.Entry<String, List<String>> entry : groupsConfig.
|
for (Map.Entry<String, List<String>> entry : groupsConfig.
|
||||||
entrySet()) {
|
entrySet()) {
|
||||||
if (!(groupQueries.get(entry.getKey()).isEmpty())) {
|
if (!(publicationsByGroup.get(entry.getKey()).isEmpty())) {
|
||||||
generateAvailableForGroup(entry.getKey(),
|
generateAvailableForGroup(entry.getKey(),
|
||||||
availableGroupsElem);
|
availableGroupsElem);
|
||||||
availableGroups.add(entry.getKey());
|
availableGroups.add(entry.getKey());
|
||||||
}
|
}
|
||||||
logger.debug(String.format("7: %d ms until now...", System.
|
|
||||||
currentTimeMillis() - start));
|
|
||||||
}
|
}
|
||||||
logger.debug(String.format("8: %d ms until now...", System.
|
|
||||||
currentTimeMillis() - start));
|
|
||||||
|
|
||||||
final long b1 = System.currentTimeMillis();
|
if (!(publicationsByGroup.get(MISC).isEmpty())) {
|
||||||
if (!(groupQueries.get(MISC).isEmpty())) {
|
generateAvailableForGroup(MISC, availableGroupsElem);
|
||||||
generateAvailableForGroup(MISC,
|
|
||||||
availableGroupsElem);
|
|
||||||
availableGroups.add(MISC);
|
availableGroups.add(MISC);
|
||||||
}
|
}
|
||||||
if (logger.isDebugEnabled()) {
|
|
||||||
logger.debug(String.format("9: %d ms until now...", System.
|
|
||||||
currentTimeMillis() - start));
|
|
||||||
logger.debug(String.format(
|
|
||||||
"Determined if misc group is available in %d ms",
|
|
||||||
System.currentTimeMillis() - b1));
|
|
||||||
logger.debug(String.format("Determined available groups "
|
|
||||||
+ "in %d ms.",
|
|
||||||
System.currentTimeMillis()
|
|
||||||
- start));
|
|
||||||
}
|
|
||||||
|
|
||||||
final HttpServletRequest request = state.getRequest();
|
final HttpServletRequest request = state.getRequest();
|
||||||
String group = selectGroup(request, config.getDefaultGroup(),
|
final String group = selectGroup(request,
|
||||||
|
config.getDefaultGroup(),
|
||||||
availableGroups);
|
availableGroups);
|
||||||
if (logger.isDebugEnabled()) {
|
|
||||||
logger.debug(String.format("Selected group: '%s'", group));
|
|
||||||
}
|
|
||||||
logger.debug(String.format("10: %d ms until now...", System.
|
|
||||||
currentTimeMillis() - start));
|
|
||||||
generateXmlForGroup(group,
|
generateXmlForGroup(group,
|
||||||
availableGroupsElem,
|
availableGroupsElem,
|
||||||
publicationsElem,
|
publicationsElem,
|
||||||
groupQueries.get(group),
|
publicationsByGroup.get(group),
|
||||||
state,
|
|
||||||
true,
|
true,
|
||||||
false);
|
false,
|
||||||
logger.debug(String.format("11: %d ms until now...", System.
|
state);
|
||||||
currentTimeMillis() - start));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
allQuery.close();
|
|
||||||
logger.debug(String.format("12: %d ms until now...", System.
|
|
||||||
currentTimeMillis() - start));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
|
|
@ -194,62 +141,45 @@ public class PersonalPublications implements ContentGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyAuthorFilter(final GenericPerson person,
|
private List<PublicationBundle> collectPublications(
|
||||||
final DataQuery query,
|
final GenericPerson author,
|
||||||
final boolean addOrders,
|
|
||||||
final String language) {
|
final String language) {
|
||||||
final StringBuilder authorFilterBuilder = new StringBuilder();
|
final List<PublicationBundle> publications =
|
||||||
authorFilterBuilder.append('(');
|
new LinkedList<PublicationBundle>();
|
||||||
authorFilterBuilder.append(String.format("authorId = %s",
|
final List<BigDecimal> processed = new ArrayList<BigDecimal>();
|
||||||
person.getID().toString()));
|
final DataCollection collection = (DataCollection) author.
|
||||||
if (person.getAlias() != null) {
|
getGenericPersonBundle().get("publication");
|
||||||
addAliasToFilter(authorFilterBuilder, person.getAlias());
|
DomainObject obj;
|
||||||
}
|
while (collection.next()) {
|
||||||
|
obj = DomainObjectFactory.newInstance(collection.getDataObject());
|
||||||
authorFilterBuilder.append(')');
|
if (obj instanceof PublicationBundle) {
|
||||||
|
processed.add(((PublicationBundle) obj).getParent().getID());
|
||||||
query.addFilter(authorFilterBuilder.toString());
|
publications.add((PublicationBundle) obj);
|
||||||
|
|
||||||
/*query.addFilter(String.format("authorId = %s",
|
|
||||||
person.getID().toString()));*/
|
|
||||||
if (Kernel.getConfig().languageIndependentItems()) {
|
|
||||||
FilterFactory ff = query.getFilterFactory();
|
|
||||||
Filter filter = ff.or().
|
|
||||||
addFilter(ff.equals("language", language)).
|
|
||||||
addFilter(ff.and().
|
|
||||||
addFilter(ff.equals("language", GlobalizationHelper.LANG_INDEPENDENT)).
|
|
||||||
addFilter(ff.notIn("parent", "com.arsdigita.navigation.getParentIDsOfMatchedItems")
|
|
||||||
.set("language", language)));
|
|
||||||
query.addFilter(filter);
|
|
||||||
/*query.addFilter(
|
|
||||||
String.format("(language = '%s' or language = '%s')",
|
|
||||||
GlobalizationHelper.getNegotiatedLocale().
|
|
||||||
getLanguage(),
|
|
||||||
GlobalizationHelper.LANG_INDEPENDENT));*/
|
|
||||||
/*query.addFilter(String.format("language = '%s' or language = '%s'",
|
|
||||||
language,
|
|
||||||
GlobalizationHelper.LANG_INDEPENDENT));*/
|
|
||||||
} else {
|
|
||||||
/*query.addEqualsFilter("language",
|
|
||||||
com.arsdigita.globalization.GlobalizationHelper.
|
|
||||||
getNegotiatedLocale().getLanguage());*/
|
|
||||||
query.addEqualsFilter("language", language);
|
|
||||||
}
|
|
||||||
if (addOrders) {
|
|
||||||
final String[] orders = config.getOrder().split(",");
|
|
||||||
for (String order : orders) {
|
|
||||||
query.addOrder(order);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addAliasToFilter(final StringBuilder builder,
|
if (author.getAlias() != null) {
|
||||||
final GenericPerson alias) {
|
collectPublications(author.getAlias(), publications, language);
|
||||||
builder.append(String.format("or authorId = %s",
|
}
|
||||||
alias.getID().toString()));
|
|
||||||
|
return publications;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void collectPublications(final GenericPerson alias,
|
||||||
|
final List<PublicationBundle> publications,
|
||||||
|
final String language) {
|
||||||
|
final DataCollection collection = (DataCollection) alias.
|
||||||
|
getGenericPersonBundle().get("publication");
|
||||||
|
DomainObject obj;
|
||||||
|
while (collection.next()) {
|
||||||
|
obj = DomainObjectFactory.newInstance(collection.getDataObject());
|
||||||
|
if (obj instanceof PublicationBundle) {
|
||||||
|
publications.add((PublicationBundle) obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (alias.getAlias() != null) {
|
if (alias.getAlias() != null) {
|
||||||
addAliasToFilter(builder, alias.getAlias());
|
collectPublications(alias.getAlias(), publications, language);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -283,52 +213,6 @@ public class PersonalPublications implements ContentGenerator {
|
||||||
groups.put(tokens[0], types);
|
groups.put(tokens[0], types);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateFilterForTypeToken(String typeToken) {
|
|
||||||
if (typeToken.endsWith("_reviewed")) {
|
|
||||||
return String.format("(objectType = '%s' and reviewed = 'true')",
|
|
||||||
typeToken.substring(0, typeToken.length() - 9));
|
|
||||||
} else if (typeToken.endsWith("_notreviewed")) {
|
|
||||||
return String.format(
|
|
||||||
"(objectType = '%s' and (reviewed = 'false' or reviewed is null))",
|
|
||||||
typeToken.substring(0, typeToken.length() - 12));
|
|
||||||
} else {
|
|
||||||
return String.format("(objectType = '%s')", typeToken);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String generateFilterForTypeTokens(final List<String> typeTokens) {
|
|
||||||
final StringBuffer buffer = new StringBuffer();
|
|
||||||
for (String typeToken : typeTokens) {
|
|
||||||
if (buffer.length() > 0) {
|
|
||||||
buffer.append(" or ");
|
|
||||||
}
|
|
||||||
buffer.append(generateFilterForTypeToken(typeToken));
|
|
||||||
}
|
|
||||||
|
|
||||||
return buffer.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String generateFilterForMiscGroup(
|
|
||||||
final Map<String, List<String>> groups) {
|
|
||||||
final StringBuffer buffer = new StringBuffer();
|
|
||||||
|
|
||||||
for (Map.Entry<String, List<String>> entry : groups.entrySet()) {
|
|
||||||
if (buffer.length() > 0) {
|
|
||||||
buffer.append(" and ");
|
|
||||||
}
|
|
||||||
buffer.append(String.format("not (%s)",
|
|
||||||
generateFilterForTypeTokens(entry.
|
|
||||||
getValue())));
|
|
||||||
}
|
|
||||||
|
|
||||||
return buffer.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void applyFiltersForTypeTokens(final List<String> typeTokens,
|
|
||||||
final DataQuery query) {
|
|
||||||
query.addFilter(generateFilterForTypeTokens(typeTokens));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void generateAvailableForGroup(final String groupName,
|
private void generateAvailableForGroup(final String groupName,
|
||||||
final Element availableGroupsElem) {
|
final Element availableGroupsElem) {
|
||||||
final Element group =
|
final Element group =
|
||||||
|
|
@ -340,11 +224,13 @@ public class PersonalPublications implements ContentGenerator {
|
||||||
private void generateXmlForGroup(final String groupName,
|
private void generateXmlForGroup(final String groupName,
|
||||||
final Element availableGroupsElem,
|
final Element availableGroupsElem,
|
||||||
final Element publicationsElem,
|
final Element publicationsElem,
|
||||||
final DataQuery query,
|
final List<PublicationBundle> publications,
|
||||||
final PageState state,
|
|
||||||
final boolean withPaginator,
|
final boolean withPaginator,
|
||||||
final boolean generateAvailable) {
|
final boolean generateAvailable,
|
||||||
if ((query == null) || query.isEmpty()) {
|
final PageState state) {
|
||||||
|
List<PublicationBundle> publicationList = publications;
|
||||||
|
|
||||||
|
if ((publications == null) || publications.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -358,48 +244,28 @@ public class PersonalPublications implements ContentGenerator {
|
||||||
|
|
||||||
if (withPaginator) {
|
if (withPaginator) {
|
||||||
final Paginator paginator = new Paginator(state.getRequest(),
|
final Paginator paginator = new Paginator(state.getRequest(),
|
||||||
(int) query.size(),
|
publications.size(),
|
||||||
config.getPageSize());
|
config.getPageSize());
|
||||||
paginator.applyLimits(query);
|
publicationList = publicationList.subList(paginator.getBegin(),
|
||||||
|
paginator.getEnd());
|
||||||
paginator.generateXml(groupElem);
|
paginator.generateXml(groupElem);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (query.next()) {
|
for (PublicationBundle publication : publicationList) {
|
||||||
generatePublicationXml((BigDecimal) query.get("publicationId"),
|
generatePublicationXml(publication.getPublication(
|
||||||
(String) query.get("objectType"),
|
GlobalizationHelper.getNegotiatedLocale().getLanguage()),
|
||||||
groupElem,
|
groupElem,
|
||||||
state);
|
state);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generatePublicationXml(final BigDecimal publicationId,
|
private void generatePublicationXml(final Publication publication,
|
||||||
final String objectType,
|
|
||||||
final Element parent,
|
final Element parent,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final long start = System.currentTimeMillis();
|
final XmlGenerator generator = new XmlGenerator(publication);
|
||||||
final ContentItem publication = (ContentItem) DomainObjectFactory.
|
|
||||||
newInstance(new OID(
|
|
||||||
objectType, publicationId));
|
|
||||||
if (logger.isDebugEnabled()) {
|
|
||||||
logger.debug(String.format("Got domain object for publication "
|
|
||||||
+ "'%s' in %d ms.",
|
|
||||||
publication.getName(),
|
|
||||||
System.currentTimeMillis() - start));
|
|
||||||
}
|
|
||||||
/*final XmlGenerator generator = new XmlGenerator(publication);
|
|
||||||
generator.setItemElemName("publications", "");
|
generator.setItemElemName("publications", "");
|
||||||
generator.generateXML(state, parent, "");*/
|
generator.setListMode(true);
|
||||||
final PublicationXmlHelper xmlHelper =
|
generator.generateXML(null, parent, "");
|
||||||
new PublicationXmlHelper(parent,
|
|
||||||
(Publication) publication);
|
|
||||||
xmlHelper.generateXml();
|
|
||||||
if (logger.isDebugEnabled()) {
|
|
||||||
logger.debug(String.format("Generated XML for publication '%s' "
|
|
||||||
+ "in %d ms.",
|
|
||||||
publication.getName(),
|
|
||||||
System.currentTimeMillis() - start));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class XmlGenerator extends SimpleXMLGenerator {
|
private class XmlGenerator extends SimpleXMLGenerator {
|
||||||
|
|
@ -437,362 +303,51 @@ public class PersonalPublications implements ContentGenerator {
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createGroupQuery(final GenericPerson author,
|
private void filterPublicationsByGroup(
|
||||||
final String groupName,
|
final String groupName,
|
||||||
final List<String> typeTokens,
|
final List<String> typeTokens,
|
||||||
final Map<String, DataQuery> groupQueries,
|
final List<PublicationBundle> publications,
|
||||||
final String language) {
|
final Map<String, List<PublicationBundle>> publicationsByGroup) {
|
||||||
final DataQuery query = SessionManager.getSession().retrieveQuery(
|
final List<PublicationBundle> group =
|
||||||
"com.arsdigita.cms.contenttypes.getPublicationsForAuthor");
|
new LinkedList<PublicationBundle>();
|
||||||
applyAuthorFilter(author, query, true, language);
|
|
||||||
applyFiltersForTypeTokens(typeTokens, query);
|
|
||||||
|
|
||||||
groupQueries.put(groupName, query);
|
for (PublicationBundle publication : publications) {
|
||||||
|
for (String typeToken : typeTokens) {
|
||||||
|
if (publication.getContentType().getAssociatedObjectType().
|
||||||
|
equals(
|
||||||
|
typeToken)) {
|
||||||
|
group.add(publication);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------ */
|
if (group.size() > 0) {
|
||||||
// public void generateContentOld(final Element parent,
|
publicationsByGroup.put(groupName, group);
|
||||||
// final GenericPerson person,
|
}
|
||||||
// final PageState state) {
|
}
|
||||||
// final long start = System.currentTimeMillis();
|
|
||||||
// final List<DataObject> publications = collectPublications(person);
|
private List<PublicationBundle> filterPublicationsForMiscGroup(
|
||||||
//
|
final List<PublicationBundle> publications,
|
||||||
// final Element personalPubsElem = parent.newChildElement(
|
final Map<String, List<String>> groupsConfig) {
|
||||||
// "personalPublications");
|
final List<PublicationBundle> misc = new LinkedList<PublicationBundle>();
|
||||||
//
|
|
||||||
// if ((publications == null) || publications.isEmpty()) {
|
boolean found = false;
|
||||||
// personalPubsElem.newChildElement("noPublications");
|
for (PublicationBundle publication : publications) {
|
||||||
//
|
for (Map.Entry<String, List<String>> entry : groupsConfig.entrySet()) {
|
||||||
// return;
|
for (String type : entry.getValue()) {
|
||||||
// } else {
|
if (publication.getContentType().getAssociatedObjectType().
|
||||||
// final Map<String, List<Publication>> groupedPublications =
|
equals(type)) {
|
||||||
// processPublications(
|
found = true;
|
||||||
// publications);
|
}
|
||||||
//
|
}
|
||||||
// generateGroupsXml(personalPubsElem, groupedPublications);
|
}
|
||||||
// generatePublicationsXml(personalPubsElem, groupedPublications, state);
|
if (!found) {
|
||||||
// }
|
misc.add(publication);
|
||||||
// if (logger.isDebugEnabled()) {
|
}
|
||||||
// logger.debug(String.format("Generated publications of %d publications "
|
found = false;
|
||||||
// + "for '%s' in %d ms.",
|
}
|
||||||
// publications.size(),
|
|
||||||
// person.getFullName(),
|
return misc;
|
||||||
// System.currentTimeMillis() - start));
|
}
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private List<DataObject> collectPublications(final GenericPerson person) {
|
|
||||||
// final long start = System.currentTimeMillis();
|
|
||||||
// final List<DataObject> publications = new ArrayList<DataObject>();
|
|
||||||
// final DataCollection collection = (DataCollection) person.get(
|
|
||||||
// "publication");
|
|
||||||
//
|
|
||||||
// while (collection.next()) {
|
|
||||||
// publications.add(collection.getDataObject());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (person.getAlias() != null) {
|
|
||||||
// collectPublications(person, publications);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (logger.isDebugEnabled()) {
|
|
||||||
// logger.debug(String.format(
|
|
||||||
// "Collected publications of '%s' in %d ms.",
|
|
||||||
// person.getFullName(),
|
|
||||||
// System.currentTimeMillis() - start));
|
|
||||||
// }
|
|
||||||
// return publications;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void collectPublications(final GenericPerson alias,
|
|
||||||
// final List<DataObject> publications) {
|
|
||||||
// final DataCollection collection = (DataCollection) alias.get(
|
|
||||||
// "publication");
|
|
||||||
//
|
|
||||||
// while (collection.next()) {
|
|
||||||
// publications.add(collection.getDataObject());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (alias.getAlias() != null) {
|
|
||||||
// collectPublications(alias, publications);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Processes the publications and puts them into the groups.
|
|
||||||
// *
|
|
||||||
// * @param publications The publications to process
|
|
||||||
// * @param typeGroupMap The group-type map
|
|
||||||
// * @return A map with the group names as keys and a list of publications
|
|
||||||
// * as value.
|
|
||||||
// */
|
|
||||||
// private Map<String, List<Publication>> processPublications(
|
|
||||||
// final List<DataObject> publications) {
|
|
||||||
//
|
|
||||||
// final long start = System.currentTimeMillis();
|
|
||||||
// final GroupConfig groupConfig = new GroupConfig(config.
|
|
||||||
// getPublictionGroups());
|
|
||||||
// final Map<String, List<Publication>> pubGroups =
|
|
||||||
// new LinkedHashMap<String, List<Publication>>();
|
|
||||||
//
|
|
||||||
// for (String group : groupConfig.getGroups()) {
|
|
||||||
// initalizePubGroupMap(pubGroups, group);
|
|
||||||
// }
|
|
||||||
// initalizePubGroupMap(pubGroups, MISC);
|
|
||||||
//
|
|
||||||
// Publication publication;
|
|
||||||
// String type;
|
|
||||||
// String groupName;
|
|
||||||
// Boolean reviewed;
|
|
||||||
// List<Publication> group;
|
|
||||||
// int i = 1;
|
|
||||||
// for (DataObject dobj : publications) {
|
|
||||||
// if (logger.isDebugEnabled()) {
|
|
||||||
// logger.debug(String.format("Processing publications %d "
|
|
||||||
// + "of %d...",
|
|
||||||
// i,
|
|
||||||
// publications.size()));
|
|
||||||
// }
|
|
||||||
// i++;
|
|
||||||
// publication = (Publication) DomainObjectFactory.newInstance(dobj);
|
|
||||||
// type = publication.getClass().getName();
|
|
||||||
//
|
|
||||||
// if (dobj.getObjectType().hasProperty("reviewed")) {
|
|
||||||
// reviewed = (Boolean) dobj.get("reviewed");
|
|
||||||
// if (reviewed == null) {
|
|
||||||
// reviewed = Boolean.FALSE;
|
|
||||||
// }
|
|
||||||
// if (reviewed) {
|
|
||||||
// groupName = groupConfig.getTypeGroupMap().get(String.format(
|
|
||||||
// "%s_ref", type));
|
|
||||||
// } else {
|
|
||||||
// groupName = groupConfig.getTypeGroupMap().get(String.format(
|
|
||||||
// "%s_noref", type));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (groupName == null) {
|
|
||||||
// groupName = groupConfig.getTypeGroupMap().get(type);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// groupName = groupConfig.getTypeGroupMap().get(type);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (groupName == null) {
|
|
||||||
// groupName = MISC;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// group = pubGroups.get(groupName);
|
|
||||||
// group.add(publication);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// final PublicationGroupComparator comparator =
|
|
||||||
// new PublicationGroupComparator();
|
|
||||||
// for (List<Publication> currentGroup : pubGroups.values()) {
|
|
||||||
// Collections.sort(currentGroup, comparator);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (logger.isDebugEnabled()) {
|
|
||||||
// logger.debug(String.format("Proceessed %d publications in %d ms.",
|
|
||||||
// publications.size(),
|
|
||||||
// System.currentTimeMillis() - start));
|
|
||||||
// }
|
|
||||||
// return pubGroups;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void initalizePubGroupMap(
|
|
||||||
// final Map<String, List<Publication>> pubGroups,
|
|
||||||
// final String groupName) {
|
|
||||||
// pubGroups.put(groupName, new ArrayList<Publication>());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void generateGroupsXml(final Element parent,
|
|
||||||
// final Map<String, List<Publication>> publications) {
|
|
||||||
// final Element availableGroups = parent.newChildElement(
|
|
||||||
// "availablePublicationGroups");
|
|
||||||
//
|
|
||||||
// for (Map.Entry<String, List<Publication>> entry :
|
|
||||||
// publications.entrySet()) {
|
|
||||||
// if (!entry.getValue().isEmpty()) {
|
|
||||||
// createAvailablePublicationGroupXml(availableGroups,
|
|
||||||
// entry.getKey());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void createAvailablePublicationGroupXml(final Element parent,
|
|
||||||
// final String name) {
|
|
||||||
// final Element group =
|
|
||||||
// parent.newChildElement("availablePublicationGroup");
|
|
||||||
// group.addAttribute("name", name);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void generatePublicationsXml(
|
|
||||||
// final Element parent,
|
|
||||||
// final Map<String, List<Publication>> publications,
|
|
||||||
// final PageState state) {
|
|
||||||
// final Element publicationsElem = parent.newChildElement("publications");
|
|
||||||
//
|
|
||||||
// int numberOfPubs = 0;
|
|
||||||
// final int groupSplit = config.getGroupSplit();
|
|
||||||
//
|
|
||||||
// for (List<Publication> list : publications.values()) {
|
|
||||||
// numberOfPubs += list.size();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (numberOfPubs < groupSplit) {
|
|
||||||
// publicationsElem.addAttribute("all", "all");
|
|
||||||
//
|
|
||||||
// for (Map.Entry<String, List<Publication>> entry : publications.
|
|
||||||
// entrySet()) {
|
|
||||||
// if (entry.getValue().size() > 0) {
|
|
||||||
// generatePublicationGroupXml(publicationsElem,
|
|
||||||
// entry.getKey(),
|
|
||||||
// entry.getValue(),
|
|
||||||
// state);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// final HttpServletRequest request = state.getRequest();
|
|
||||||
// final String[] defaultGroup = config.getDefaultGroup().split(",");
|
|
||||||
//
|
|
||||||
// String groupToShow = request.getParameter("group");
|
|
||||||
// if ((groupToShow == null)
|
|
||||||
// || groupToShow.isEmpty()
|
|
||||||
// || !(publications.containsKey(groupToShow))) {
|
|
||||||
// int i = 0;
|
|
||||||
// groupToShow = defaultGroup[i];
|
|
||||||
// while ((publications.get(groupToShow).isEmpty())
|
|
||||||
// && i < defaultGroup.length) {
|
|
||||||
// groupToShow = defaultGroup[i];
|
|
||||||
// i++;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (groupToShow == null) {
|
|
||||||
// groupToShow = MISC;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// generatePublicationGroupXml(publicationsElem,
|
|
||||||
// groupToShow,
|
|
||||||
// publications.get(groupToShow),
|
|
||||||
// state);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void generatePublicationGroupXml(final Element publicationsElem,
|
|
||||||
// final String groupName,
|
|
||||||
// final List<Publication> publications,
|
|
||||||
// final PageState state) {
|
|
||||||
// if (publications == null) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// final Element groupElem = publicationsElem.newChildElement(
|
|
||||||
// "publicationGroup");
|
|
||||||
// groupElem.addAttribute("name", groupName);
|
|
||||||
//
|
|
||||||
// for (Publication publication : publications) {
|
|
||||||
// generatePublicationXml(groupElem, publication, state);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void generatePublicationXml(final Element publicationGroupElem,
|
|
||||||
// final Publication publication,
|
|
||||||
// final PageState state) {
|
|
||||||
// /*final PublicPersonalProfileXmlGenerator generator =
|
|
||||||
// new PublicPersonalProfileXmlGenerator(
|
|
||||||
// publication);
|
|
||||||
// generator.generateXML(state, publicationGroupElem, "");*/
|
|
||||||
// final PublicationXmlHelper xmlHelper = new PublicationXmlHelper(
|
|
||||||
// publicationGroupElem, publication);
|
|
||||||
// xmlHelper.generateXml();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Processes the publications and puts them into the groups.
|
|
||||||
// *
|
|
||||||
// * @param publications The publications to process
|
|
||||||
// * @param typeGroupMap The group-type map
|
|
||||||
// * @return A map with the group names as keys and a list of publications
|
|
||||||
// * as value.
|
|
||||||
// */
|
|
||||||
// private class GroupConfig {
|
|
||||||
//
|
|
||||||
// private final Map<String, String> typeGroupMap =
|
|
||||||
// new HashMap<String, String>();
|
|
||||||
// private final List<String> groups = new ArrayList<String>();
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Processes the configuration string and puts the result into the
|
|
||||||
// * collections.
|
|
||||||
// *
|
|
||||||
// * @param groupStr
|
|
||||||
// */
|
|
||||||
// public GroupConfig(final String groupStr) {
|
|
||||||
// final String[] groupTokens = groupStr.split(";");
|
|
||||||
// String[] groupTokenSplit;
|
|
||||||
// String groupName;
|
|
||||||
// String publicationTypeTokens;
|
|
||||||
// String[] publicationTypeTokensSplit;
|
|
||||||
// List<String> types;
|
|
||||||
// for (String groupToken : groupTokens) {
|
|
||||||
// groupTokenSplit = groupToken.split(":");
|
|
||||||
// if (groupTokenSplit.length != 2) {
|
|
||||||
// logger.warn(String.format(
|
|
||||||
// "Invalid entry in publication group config: '%s'. "
|
|
||||||
// + "Ignoring.",
|
|
||||||
// groupToken));
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// groupName = groupTokenSplit[0];
|
|
||||||
// groups.add(groupName);
|
|
||||||
// publicationTypeTokens = groupTokenSplit[1];
|
|
||||||
// publicationTypeTokensSplit = publicationTypeTokens.split(",");
|
|
||||||
// for (String publicationTypeToken : publicationTypeTokensSplit) {
|
|
||||||
// typeGroupMap.put(publicationTypeToken, groupName);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public Map<String, String> getTypeGroupMap() {
|
|
||||||
// return Collections.unmodifiableMap(typeGroupMap);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public List<String> getGroups() {
|
|
||||||
// return Collections.unmodifiableList(groups);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private class PublicationGroupComparator implements Comparator<Publication> {
|
|
||||||
//
|
|
||||||
// public int compare(final Publication publication1,
|
|
||||||
// final Publication publication2) {
|
|
||||||
// AuthorshipCollection authors1;
|
|
||||||
// AuthorshipCollection authors2;
|
|
||||||
// GenericPerson author;
|
|
||||||
// String authorsStr1;
|
|
||||||
// String authorsStr2;
|
|
||||||
// final StringBuffer authors1Buffer = new StringBuffer();
|
|
||||||
// final StringBuffer authors2Buffer = new StringBuffer();
|
|
||||||
//
|
|
||||||
// authors1 = publication1.getAuthors();
|
|
||||||
// while (authors1.next()) {
|
|
||||||
// author = authors1.getAuthor();
|
|
||||||
// authors1Buffer.append(author.getSurname());
|
|
||||||
// authors1Buffer.append(author.getGivenName());
|
|
||||||
// }
|
|
||||||
// authors2 = publication2.getAuthors();
|
|
||||||
// while (authors2.next()) {
|
|
||||||
// author = authors2.getAuthor();
|
|
||||||
// authors2Buffer.append(author.getSurname());
|
|
||||||
// authors2Buffer.append(author.getGivenName());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// authorsStr1 = authors1Buffer.toString();
|
|
||||||
// authorsStr2 = authors2Buffer.toString();
|
|
||||||
//
|
|
||||||
// return authorsStr1.compareTo(authorsStr2);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -336,4 +336,12 @@ public class PublicationBundle extends ContentBundle {
|
||||||
|
|
||||||
remove(SERIES, series.getSeriesBundle());
|
remove(SERIES, series.getSeriesBundle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Publication getPublication() {
|
||||||
|
return (Publication) getPrimaryInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Publication getPublication(final String language) {
|
||||||
|
return (Publication) getInstance(language);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ package com.arsdigita.cms.contenttypes.ui;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.cms.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitPersonCollection;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitSubordinateCollection;
|
||||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||||
import com.arsdigita.cms.contenttypes.SciDepartment;
|
import com.arsdigita.cms.contenttypes.SciDepartment;
|
||||||
import com.arsdigita.cms.contenttypes.ui.panels.CompareFilter;
|
import com.arsdigita.cms.contenttypes.ui.panels.CompareFilter;
|
||||||
|
|
@ -15,6 +17,9 @@ 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.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
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,13 +39,13 @@ public class SciDepartmentMembersTab implements GenericOrgaUnitTab {
|
||||||
private static final String SURNAME_PARAM = "memberSurname";
|
private static final String SURNAME_PARAM = "memberSurname";
|
||||||
private final CompareFilter statusFilter = new CompareFilter(
|
private final CompareFilter statusFilter = new CompareFilter(
|
||||||
STATUS_PARAM,
|
STATUS_PARAM,
|
||||||
"status",
|
"link.status",
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false);
|
false);
|
||||||
private final TextFilter surnameFilter =
|
private final TextFilter surnameFilter =
|
||||||
new TextFilter(SURNAME_PARAM,
|
new TextFilter(SURNAME_PARAM,
|
||||||
GenericPerson.SURNAME);
|
"name");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
config.load();
|
config.load();
|
||||||
|
|
@ -55,28 +60,29 @@ public class SciDepartmentMembersTab implements GenericOrgaUnitTab {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean hasData(final GenericOrganizationalUnit orgaunit) {
|
public boolean hasData(final GenericOrganizationalUnit orgaunit) {
|
||||||
if ((orgaunit.getPersons() != null)
|
// if ((orgaunit.getPersons() != null)
|
||||||
&& 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 DataQuery persons = getData(orgaunit);
|
||||||
return persons.isEmpty();
|
// return persons.isEmpty();
|
||||||
} else {
|
// } else {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
return !orgaunit.getPersons().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void generateXml(final GenericOrganizationalUnit orgaunit,
|
public void generateXml(final GenericOrganizationalUnit orgaunit,
|
||||||
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);
|
List<GenericPerson> members = getMembers(orgaunit, state);
|
||||||
final HttpServletRequest request = state.getRequest();
|
final HttpServletRequest request = state.getRequest();
|
||||||
|
|
||||||
applyStatusFilter(persons, request);
|
|
||||||
applySurnameFilter(persons, request);
|
|
||||||
|
|
||||||
final Element depMembersElem = parent.newChildElement(
|
final Element depMembersElem = parent.newChildElement(
|
||||||
"departmentMembers");
|
"departmentMembers");
|
||||||
|
|
||||||
|
|
@ -84,7 +90,8 @@ public class SciDepartmentMembersTab implements GenericOrgaUnitTab {
|
||||||
|
|
||||||
statusFilter.generateXml(filtersElem);
|
statusFilter.generateXml(filtersElem);
|
||||||
|
|
||||||
if (persons.isEmpty()) {
|
if (members.isEmpty()) {
|
||||||
|
//if (persons.isEmpty()) {
|
||||||
if ((surnameFilter != null)
|
if ((surnameFilter != null)
|
||||||
&& (surnameFilter.getFilter() != null)
|
&& (surnameFilter.getFilter() != null)
|
||||||
&& !(surnameFilter.getFilter().trim().isEmpty())) {
|
&& !(surnameFilter.getFilter().trim().isEmpty())) {
|
||||||
|
|
@ -94,8 +101,23 @@ public class SciDepartmentMembersTab implements GenericOrgaUnitTab {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Collections.sort(members, new Comparator<GenericPerson>() {
|
||||||
|
|
||||||
|
public int compare(final GenericPerson person1,
|
||||||
|
final GenericPerson person2) {
|
||||||
|
String name1 = String.format("%s %s", person1.getSurname(),
|
||||||
|
person1.getGivenName());
|
||||||
|
String name2 = String.format("%s %s", person2.getSurname(),
|
||||||
|
person2.getGivenName());
|
||||||
|
|
||||||
|
return name1.compareTo(name2);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
final Paginator paginator = new Paginator(request,
|
final Paginator paginator = new Paginator(request,
|
||||||
(int) persons.size(),
|
//(int) persons.size(),
|
||||||
|
members.size(),
|
||||||
config.getPageSize());
|
config.getPageSize());
|
||||||
|
|
||||||
if ((paginator.getPageCount() > config.getEnableSearchLimit())
|
if ((paginator.getPageCount() > config.getEnableSearchLimit())
|
||||||
|
|
@ -104,11 +126,13 @@ public class SciDepartmentMembersTab implements GenericOrgaUnitTab {
|
||||||
surnameFilter.generateXml(filtersElem);
|
surnameFilter.generateXml(filtersElem);
|
||||||
}
|
}
|
||||||
|
|
||||||
paginator.applyLimits(persons);
|
|
||||||
paginator.generateXml(depMembersElem);
|
paginator.generateXml(depMembersElem);
|
||||||
|
if (paginator.getEnd() < members.size()) {
|
||||||
|
members = members.subList(paginator.getBegin(), paginator.getEnd());
|
||||||
|
}
|
||||||
|
|
||||||
while (persons.next()) {
|
for (GenericPerson member : members) {
|
||||||
generateMemberXml((BigDecimal) persons.get("memberId"),
|
generateMemberXml(member,
|
||||||
depMembersElem,
|
depMembersElem,
|
||||||
state);
|
state);
|
||||||
}
|
}
|
||||||
|
|
@ -119,6 +143,62 @@ public class SciDepartmentMembersTab implements GenericOrgaUnitTab {
|
||||||
System.currentTimeMillis() - start));
|
System.currentTimeMillis() - start));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected List<GenericPerson> getMembers(
|
||||||
|
final GenericOrganizationalUnit orgaunit,
|
||||||
|
final PageState state) {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
final List<GenericPerson> members = new LinkedList<GenericPerson>();
|
||||||
|
|
||||||
|
final GenericOrganizationalUnitPersonCollection persons = orgaunit.
|
||||||
|
getPersons();
|
||||||
|
|
||||||
|
if (state != null) {
|
||||||
|
applyStatusFilter(persons, state.getRequest());
|
||||||
|
applySurnameFilter(persons, state.getRequest());
|
||||||
|
}
|
||||||
|
|
||||||
|
while (persons.next()) {
|
||||||
|
members.add(persons.getPerson());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.isMergingMembers()) {
|
||||||
|
getMembersFromSubordinateOrgaUnits(orgaunit, members, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug(String.format(
|
||||||
|
"Got members of department '%s'"
|
||||||
|
+ "in '%d ms'. MergeMembers is set to '%b'.",
|
||||||
|
orgaunit.getName(),
|
||||||
|
System.currentTimeMillis() - start,
|
||||||
|
config.isMergingMembers()));
|
||||||
|
return members;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void getMembersFromSubordinateOrgaUnits(
|
||||||
|
final GenericOrganizationalUnit orgaunit,
|
||||||
|
final List<GenericPerson> members,
|
||||||
|
final PageState state) {
|
||||||
|
final GenericOrganizationalUnitSubordinateCollection subDeps = orgaunit.
|
||||||
|
getSubordinateOrgaUnits();
|
||||||
|
subDeps.addFilter(
|
||||||
|
"objecttype = 'com.arsdigita.cms.contenttypes.SciDepartment'");
|
||||||
|
|
||||||
|
while (subDeps.next()) {
|
||||||
|
getMembersFromSubordinateOrgaUnit(
|
||||||
|
subDeps.getGenericOrganizationalUnit(), members, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void getMembersFromSubordinateOrgaUnit(
|
||||||
|
final GenericOrganizationalUnit subOrgaUnit,
|
||||||
|
final List<GenericPerson> members,
|
||||||
|
final PageState state) {
|
||||||
|
final List<GenericPerson> subOrgaUnitMembers = getMembers(subOrgaUnit,
|
||||||
|
state);
|
||||||
|
members.addAll(subOrgaUnitMembers);
|
||||||
|
}
|
||||||
|
|
||||||
protected DataQuery getData(final GenericOrganizationalUnit orgaunit) {
|
protected DataQuery getData(final GenericOrganizationalUnit orgaunit) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
|
@ -133,7 +213,6 @@ 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 List<String> orgaUnitIds = new ArrayList<String>();
|
final List<String> orgaUnitIds = new ArrayList<String>();
|
||||||
|
|
||||||
if (config.isMergingMembers()) {
|
if (config.isMergingMembers()) {
|
||||||
|
|
@ -146,48 +225,14 @@ public class SciDepartmentMembersTab implements GenericOrgaUnitTab {
|
||||||
SciDepartmentSubDepartmentsStep.ASSOC_TYPE);
|
SciDepartmentSubDepartmentsStep.ASSOC_TYPE);
|
||||||
|
|
||||||
while (subDepartmentsQuery.next()) {
|
while (subDepartmentsQuery.next()) {
|
||||||
/*if (personsFilter.length() > 0) {
|
|
||||||
personsFilter.append(" or ");
|
|
||||||
}
|
|
||||||
personsFilter.append(String.format("orgaunitId = %s",
|
|
||||||
subDepartmentsQuery.get(
|
|
||||||
"orgaunitId").toString()));*/
|
|
||||||
orgaUnitIds.add(subDepartmentsQuery.get("orgaunitId").toString());
|
orgaUnitIds.add(subDepartmentsQuery.get("orgaunitId").toString());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*personsFilter.append(String.format("orgaunitId = %s",
|
|
||||||
orgaunit.getID().toString()));*/
|
|
||||||
orgaUnitIds.add(orgaunit.getID().toString());
|
orgaUnitIds.add(orgaunit.getID().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
//personsQuery.addFilter(personsFilter.toString());
|
|
||||||
personsQuery.setParameter("orgaunitIds", orgaUnitIds);
|
personsQuery.setParameter("orgaunitIds", orgaUnitIds);
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter for language independent items
|
|
||||||
*/
|
|
||||||
/*if (Kernel.getConfig().languageIndependentItems()) {
|
|
||||||
FilterFactory ff = personsQuery.getFilterFactory();
|
|
||||||
Filter filter = ff.or().
|
|
||||||
addFilter(ff.equals("language",
|
|
||||||
com.arsdigita.globalization.GlobalizationHelper.
|
|
||||||
getNegotiatedLocale().getLanguage())).
|
|
||||||
addFilter(ff.and().
|
|
||||||
addFilter(ff.equals("language",
|
|
||||||
GlobalizationHelper.LANG_INDEPENDENT)).
|
|
||||||
addFilter(ff.notIn("parentId",
|
|
||||||
"com.arsdigita.cms.contenttypes.getParentIDsOfMatchedItems").
|
|
||||||
set("language",
|
|
||||||
com.arsdigita.globalization.GlobalizationHelper.
|
|
||||||
getNegotiatedLocale().getLanguage())));
|
|
||||||
personsQuery.addFilter(filter);
|
|
||||||
} else {
|
|
||||||
personsQuery.addEqualsFilter("language",
|
|
||||||
com.arsdigita.globalization.GlobalizationHelper.
|
|
||||||
getNegotiatedLocale().getLanguage());
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
personsQuery.addOrder(GenericPerson.SURNAME);
|
personsQuery.addOrder(GenericPerson.SURNAME);
|
||||||
personsQuery.addOrder(GenericPerson.GIVENNAME);
|
personsQuery.addOrder(GenericPerson.GIVENNAME);
|
||||||
|
|
||||||
|
|
@ -245,7 +290,8 @@ public class SciDepartmentMembersTab 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.setListMode(true);
|
||||||
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.",
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ public class SciDepartmentMembersTabConfig extends AbstractConfig {
|
||||||
new BooleanParameter(
|
new BooleanParameter(
|
||||||
"com.arsdigita.cms.contenttypes.scidepartments.tabs.members.merge",
|
"com.arsdigita.cms.contenttypes.scidepartments.tabs.members.merge",
|
||||||
Parameter.REQUIRED,
|
Parameter.REQUIRED,
|
||||||
Boolean.TRUE);
|
Boolean.FALSE);
|
||||||
|
|
||||||
register(statusValues);
|
register(statusValues);
|
||||||
register(pageSize);
|
register(pageSize);
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
objectType="com.arsdigita.cms.contenttypes.SciProject"
|
objectType="com.arsdigita.cms.contenttypes.SciProject"
|
||||||
classname="com.arsdigita.cms.contenttypes.SciProject">
|
classname="com.arsdigita.cms.contenttypes.SciProject">
|
||||||
|
|
||||||
<ctd:authoring-kit createComponent="com.arsdigita.cms.contenttypes.ui.GenericOrganizationalUnitCreate">
|
<ctd:authoring-kit createComponent="com.arsdigita.cms.contenttypes.ui.SciProjectCreate">
|
||||||
|
|
||||||
<ctd:authoring-step
|
<ctd:authoring-step
|
||||||
labelKey="sciorganization.ui.project_properties.title"
|
labelKey="sciorganization.ui.project_properties.title"
|
||||||
|
|
|
||||||
|
|
@ -46,4 +46,12 @@ public class SciProjectBundle extends GenericOrganizationalUnitBundle {
|
||||||
public SciProjectBundle(final String type) {
|
public SciProjectBundle(final String type) {
|
||||||
super(type);
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SciProject getProject() {
|
||||||
|
return (SciProject) getPrimaryInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SciProject getProject(final String language) {
|
||||||
|
return (SciProject) getInstance(language);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue