trunk/ccm-ldn-util/src/com/arsdigita/london/util/cmd/ReloadAuthoringSteps.java:
Kleines Tool, um die AuthoringSteps eines Content-Typs neu einzulesen trunk/ccm-sci-assets-organizationpublicationlink: Zweiter Teil für die Verknüpfung von Publikationen und SciOrganization. Content-Center bereits funktionsfähig, Ansicht auf Webseite noch nicht getestet. trunk/ccm-sci-types-organization: - Methoden zum Anzeigen verknüpfter Publikationen über RelatedLink entfernt - Anzeige-Panels für Vererbung optimiert Weiteres: Formatierungen git-svn-id: https://svn.libreccm.org/ccm/trunk@950 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
4b4198dccc
commit
644868eeea
|
|
@ -71,6 +71,8 @@ public abstract class ContentAssetInitializer extends CompoundInitializer {
|
|||
*/
|
||||
@Override
|
||||
public void init(DomainInitEvent evt) {
|
||||
System.err.println("ContentAssetInitializer init running...");
|
||||
|
||||
super.init(evt);
|
||||
|
||||
final String traversal = getTraversalXML();
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ class Load extends Command {
|
|||
if (loaders.containsKey(key)) { continue; }
|
||||
Loader l = Loader.get(key);
|
||||
if (l == null) {
|
||||
System.err.println("unable to locate package: " + key);
|
||||
System.err.println("unable to locate package: " + key);
|
||||
err = true;
|
||||
} else {
|
||||
loaders.put(key, l);
|
||||
|
|
|
|||
|
|
@ -57,23 +57,26 @@ import org.apache.log4j.Logger;
|
|||
* @version $Revision: #13 $ $Date: 2004/08/16 $
|
||||
* @version $Id: Loader.java 736 2005-09-01 10:46:05Z sskracic $
|
||||
**/
|
||||
|
||||
class Loader {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(Loader.class);
|
||||
|
||||
private static final String INIT = "com.arsdigita.runtime.Initializer";
|
||||
|
||||
public static Loader get(String pkg) {
|
||||
ClassLoader ldr = Loader.class.getClassLoader();
|
||||
InputStream is = ldr.getResourceAsStream(pkg + ".load");
|
||||
if (is == null) { return null; }
|
||||
if (is == null) {
|
||||
s_log.error(String.format("Failed to find '%s.load'.", pkg));
|
||||
return null;
|
||||
}
|
||||
LoaderInfo info = new LoaderInfo(is);
|
||||
try { is.close(); }
|
||||
catch (IOException e) { throw new UncheckedWrapperException(e); }
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedWrapperException(e);
|
||||
}
|
||||
return new Loader(pkg, info, Checklist.get(pkg));
|
||||
}
|
||||
|
||||
private String m_key;
|
||||
private LoaderInfo m_info;
|
||||
private Checklist m_checks;
|
||||
|
|
@ -85,7 +88,7 @@ class Loader {
|
|||
m_checks = checks;
|
||||
m_scripts = new ArrayList();
|
||||
for (Iterator it = m_info.getDataScripts().iterator();
|
||||
it.hasNext(); ) {
|
||||
it.hasNext();) {
|
||||
String script = (String) it.next();
|
||||
m_scripts.add(Classes.newInstance(script));
|
||||
}
|
||||
|
|
@ -107,8 +110,7 @@ class Loader {
|
|||
if (m_checks == null) {
|
||||
return true;
|
||||
} else {
|
||||
return m_checks.run
|
||||
(Checklist.SCHEMA, new ScriptContext(null, null));
|
||||
return m_checks.run(Checklist.SCHEMA, new ScriptContext(null, null));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +118,7 @@ class Loader {
|
|||
int db = DbHelper.getDatabase(conn);
|
||||
String dir = DbHelper.getDatabaseDirectory(db);
|
||||
List scripts = m_info.getSchemaScripts();
|
||||
for (Iterator it = scripts.iterator(); it.hasNext(); ) {
|
||||
for (Iterator it = scripts.iterator(); it.hasNext();) {
|
||||
String script = (String) it.next();
|
||||
s_log.info("Loading schema for " + script);
|
||||
PackageLoader.load(conn, script + "/" + dir + "-create.sql");
|
||||
|
|
@ -131,13 +133,12 @@ class Loader {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// deprecated:
|
||||
// public void loadData(Session ssn, ParameterLoader loader) {
|
||||
public void loadData(Session ssn, ParameterReader prd) {
|
||||
final List inits = m_info.getProvidedInitializers();
|
||||
CompoundInitializer ini = new CompoundInitializer();
|
||||
for (Iterator it = inits.iterator(); it.hasNext(); ) {
|
||||
for (Iterator it = inits.iterator(); it.hasNext();) {
|
||||
String init = (String) it.next();
|
||||
s_log.info("Running initializer " + init);
|
||||
ini.add((Initializer) Classes.newInstance(init));
|
||||
|
|
@ -150,11 +151,13 @@ class Loader {
|
|||
// final ScriptContext ctx = new ScriptContext(ssn, loader);
|
||||
final ScriptContext ctx = new ScriptContext(ssn, prd);
|
||||
new KernelExcursion() {
|
||||
|
||||
protected void excurse() {
|
||||
setEffectiveParty(Kernel.getSystemParty());
|
||||
for (Iterator it = m_scripts.iterator(); it.hasNext(); ) {
|
||||
for (Iterator it = m_scripts.iterator(); it.hasNext();) {
|
||||
Script script = (Script) it.next();
|
||||
s_log.info("Running data loader " + script.getClass().getName());
|
||||
s_log.info("Running data loader " + script.getClass().
|
||||
getName());
|
||||
script.run(ctx);
|
||||
}
|
||||
}
|
||||
|
|
@ -171,11 +174,12 @@ class Loader {
|
|||
|
||||
final List inits = m_info.getProvidedInitializers();
|
||||
final List required = m_info.getRequiredInitializers();
|
||||
for (Iterator it = inits.iterator(); it.hasNext(); ) {
|
||||
for (Iterator it = inits.iterator(); it.hasNext();) {
|
||||
String init = (String) it.next();
|
||||
DataObject dataobject = ssn.create(new OID(INIT, init));
|
||||
DataAssociation da = (DataAssociation)dataobject.get("requirements");
|
||||
for (Iterator reqit = required.iterator(); reqit.hasNext(); ) {
|
||||
DataAssociation da =
|
||||
(DataAssociation) dataobject.get("requirements");
|
||||
for (Iterator reqit = required.iterator(); reqit.hasNext();) {
|
||||
String reqinit = (String) reqit.next();
|
||||
da.add(ssn.retrieve(new OID(INIT, reqinit)));
|
||||
}
|
||||
|
|
@ -206,5 +210,4 @@ class Loader {
|
|||
public String toString() {
|
||||
return "<loader for " + m_key + ">";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
package com.arsdigita.london.util.cmd;
|
||||
|
||||
import com.arsdigita.cms.installer.xml.XMLContentItemHandler;
|
||||
import com.arsdigita.cms.installer.xml.XMLContentTypeHandler;
|
||||
import com.arsdigita.london.util.Transaction;
|
||||
import com.arsdigita.packaging.Program;
|
||||
import com.arsdigita.persistence.Session;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.persistence.TransactionContext;
|
||||
import com.arsdigita.xml.XML;
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.Options;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class ReloadAuthoringSteps extends Program {
|
||||
|
||||
public ReloadAuthoringSteps() {
|
||||
super("ReloadAuthoringSteps",
|
||||
"1.0.0",
|
||||
"");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doRun(CommandLine cmdLine) {
|
||||
|
||||
String[] args = cmdLine.getArgs();
|
||||
|
||||
if (args.length < 1) {
|
||||
System.out.println(
|
||||
"Usage ReloadAuthoringSteps pathToAuthoringStepDefinition");
|
||||
System.out.println("");
|
||||
System.out.println(
|
||||
"The path to the definition file has usally the form");
|
||||
System.out.println("");
|
||||
System.out.println(
|
||||
"/WEB-INF/content-types/com/arsdigita/contenttypes/ContentType.xml");
|
||||
System.out.println("");
|
||||
System.out.println(
|
||||
"Replace 'ContentType.xml' with the name of the ContentType which AuthoringSteps should be reloaded.");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
final String defToReload = args[0];
|
||||
|
||||
System.out.printf("Reloading AuthoringSteps from '%s'...", defToReload);
|
||||
new Transaction() {
|
||||
|
||||
@Override
|
||||
protected void doRun() {
|
||||
XMLContentTypeHandler handler = new XMLContentTypeHandler();
|
||||
XML.parseResource(defToReload, handler);
|
||||
}
|
||||
}.run();
|
||||
System.out.printf("Reloaded AuthoringSteps from '%s'.", defToReload);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -2,15 +2,17 @@ model com.arsdigita.cms.contentassets;
|
|||
|
||||
import com.arsdigita.kernel.ACSObject;
|
||||
import com.arsdigita.cms.*;
|
||||
import com.arsdigita.cms.contenttypes.Publication;
|
||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||
|
||||
association {
|
||||
GenericOrganizationalUnit[0..n] organizations = join ct_publications.publication_id
|
||||
to cms_organization_publication_map.publication_id,
|
||||
join cms_organization_publication_map.organization_id
|
||||
to cms_organizationalunit.organizationalunit_id;
|
||||
to cms_organizationalunits.organizationalunit_id;
|
||||
|
||||
Publication[0..n] publications = join cms_organizationalunit.organizationalunit_id
|
||||
to cms_organization_publication_link.organization_id,
|
||||
join cms_organization_publication_link.publication_id
|
||||
to ct_publication.publication_id;
|
||||
Publication[0..n] publications = join cms_organizationalunits.organizationalunit_id
|
||||
to cms_organization_publication_map.organization_id,
|
||||
join cms_organization_publication_map.publication_id
|
||||
to ct_publications.publication_id;
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<xrd:adapters xmlns:xrd="http://xmlns.redhat.com/schemas/waf/xml-renderer-rules"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://rhea.redhat.com/schemas/waf/xml-renderer-rules xml-renderer-rules.xsd">
|
||||
|
||||
<xrd:context name="com.arsdigita.cms.dispatcher.SimpleXMLGenerator">
|
||||
</xrd:context>
|
||||
</xrd:adapters>
|
||||
|
|
@ -2,14 +2,16 @@
|
|||
<requires>
|
||||
<table name="inits"/>
|
||||
<table name="acs_objects"/>
|
||||
<table name="cms_items"/>
|
||||
<table name="cms_items"/>
|
||||
<table name="ct_publications"/>
|
||||
<initalizer class="com.arsdigita.cms.Initializer"/>
|
||||
<initalizer class="com.arsdigita.cms.contenttypes.PublicationInitializer"/>
|
||||
</requires>
|
||||
<provides>
|
||||
<initializer class="com.arsdigita.cms.contentassets.SciOrganizationPublicationInitializer"/>
|
||||
</provides>
|
||||
<scripts>
|
||||
<schema directory="ccm-sci-assets-sciorganizationpublication"/>
|
||||
<schema directory="ccm-sci-assets-organizationpublicationlink"/>
|
||||
<data class="com.arsdigita.cms.contentassets.SciOrganizationPublicationLoader"/>
|
||||
</scripts>
|
||||
</load>
|
||||
|
|
@ -47,53 +47,69 @@ public class SciOrganizationPublicationInitializer extends CompoundInitializer {
|
|||
final String url = RuntimeConfig.getConfig().getJDBCURL();
|
||||
final int database = DbHelper.getDatabaseFromURL(url);
|
||||
|
||||
System.err.println("Creating SciOrganizationPublicationInitializer...");
|
||||
|
||||
add(new PDLInitializer(
|
||||
new ManifestSource(
|
||||
"ccm-sci-assets-sciorganiationpublication.pdl.mf",
|
||||
"ccm-sci-assets-organizationpublicationlink.pdl.mf",
|
||||
new NameFilter(DbHelper.getDatabaseSuffix(database), "pdl"))));
|
||||
|
||||
System.err.println("Constructor of SciOrganizationPublicationInitializer finished...");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(DomainInitEvent event) {
|
||||
System.out.println("Beginning init of SciOrganizationPublicationInitializer...");
|
||||
|
||||
System.out.println("Calling super.init()");
|
||||
super.init(event);
|
||||
|
||||
|
||||
System.out.println("Creating traversal handler...");
|
||||
final String traversal = getTraversalXML();
|
||||
XML.parseResource(traversal,
|
||||
new ContentAssetTraversalHandler(getProperty()));
|
||||
|
||||
System.out.println("Registering authoring step for publications of an organization...");
|
||||
AuthoringKitWizard.registerAssetStep(
|
||||
SciOrganization.BASE_DATA_OBJECT_TYPE,
|
||||
SciOrganization.BASE_DATA_OBJECT_TYPE,
|
||||
SciOrganizationPublicationStep.class,
|
||||
new GlobalizedMessage("sciorganization.ui.publications",
|
||||
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublication"),
|
||||
new GlobalizedMessage("sciorganization.ui.publications",
|
||||
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublication"),
|
||||
1);
|
||||
new GlobalizedMessage("sciorganizationpublication.ui.publicationsOfOrganization",
|
||||
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublicationResources"),
|
||||
new GlobalizedMessage("sciorganizationpublication.ui.publicationsOfOrganization",
|
||||
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublicationResources"),
|
||||
99);
|
||||
|
||||
System.out.println("Registering authoring step for publications of a department..");
|
||||
AuthoringKitWizard.registerAssetStep(
|
||||
SciDepartment.BASE_DATA_OBJECT_TYPE,
|
||||
SciDepartment.BASE_DATA_OBJECT_TYPE,
|
||||
SciOrganizationPublicationStep.class,
|
||||
new GlobalizedMessage("sciorganization.ui.publications",
|
||||
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublication"),
|
||||
new GlobalizedMessage("sciorganization.ui.publications",
|
||||
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublication"),
|
||||
1);
|
||||
new GlobalizedMessage("sciorganizationpublication.ui.publicationsOfDepartment",
|
||||
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublicationResources"),
|
||||
new GlobalizedMessage("sciorganizationpublication.ui.publicationsOfDepartment",
|
||||
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublicationResources"),
|
||||
99);
|
||||
|
||||
System.out.println("Registering authoring step for publications of a project...");
|
||||
AuthoringKitWizard.registerAssetStep(
|
||||
SciProject.BASE_DATA_OBJECT_TYPE,
|
||||
SciOrganizationPublicationStep.class,
|
||||
new GlobalizedMessage("sciorganization.ui.publications",
|
||||
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublication"),
|
||||
new GlobalizedMessage("sciorganization.ui.publications",
|
||||
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublication"),
|
||||
new GlobalizedMessage("sciorganizationpublication.ui.publicationsOfProject",
|
||||
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublicationResources"),
|
||||
new GlobalizedMessage("sciorganizationpublication.ui.publicationsOfProject",
|
||||
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublicationResources"),
|
||||
1);
|
||||
|
||||
System.out.println("Registering authoring step of organization of a publication...");
|
||||
AuthoringKitWizard.registerAssetStep(
|
||||
Publication.BASE_DATA_OBJECT_TYPE,
|
||||
PublicationSciOrganizationStep.class,
|
||||
new GlobalizedMessage("sciorganization.ui.organizations",
|
||||
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublication"),
|
||||
new GlobalizedMessage("sciorganization.ui.organizations",
|
||||
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublication"),
|
||||
new GlobalizedMessage("sciorganizationpublication.ui.organizationsOfPublication",
|
||||
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublicationResources"),
|
||||
new GlobalizedMessage("ssciorganizationpublication.ui.organizationsOfPublication",
|
||||
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublicationResources"),
|
||||
1);
|
||||
|
||||
System.err.println("Finished init of SciOrganizationPublicationInitializer.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -43,33 +43,31 @@ public class PublicationSciOrganizationAddForm
|
|||
extends BasicItemForm
|
||||
implements FormProcessListener,
|
||||
FormInitListener {
|
||||
|
||||
|
||||
private ItemSearchWidget itemSearch;
|
||||
private final String ITEM_SEARCH = "organizations";
|
||||
private String orgaClassName;
|
||||
|
||||
public PublicationSciOrganizationAddForm(ItemSelectionModel itemModel,
|
||||
String orgaClassName) {
|
||||
|
||||
public PublicationSciOrganizationAddForm(ItemSelectionModel itemModel) {
|
||||
super("OrganizationsAddForm", itemModel);
|
||||
this.orgaClassName = orgaClassName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addWidgets() {
|
||||
add(new Label((String) SciOrganizationPublicationGlobalizationUtil.
|
||||
globalize("sciorganization.ui.selectOrganization").localize()));
|
||||
itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.
|
||||
findByAssociatedObjectType(orgaClassName));
|
||||
findByAssociatedObjectType(GenericOrganizationalUnit.class.
|
||||
getName()));
|
||||
add(itemSearch);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void init(FormSectionEvent fse) throws FormProcessException {
|
||||
PageState state = fse.getPageState();
|
||||
|
||||
|
||||
setVisible(state, true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void process(FormSectionEvent fse) throws FormProcessException {
|
||||
FormData data = fse.getFormData();
|
||||
|
|
@ -79,12 +77,12 @@ public class PublicationSciOrganizationAddForm
|
|||
PublicationWithOrganization publication =
|
||||
new PublicationWithOrganization(
|
||||
pub.getOID());
|
||||
|
||||
|
||||
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||
publication.addOrganization((GenericOrganizationalUnit) data.get(
|
||||
ITEM_SEARCH));
|
||||
ITEM_SEARCH));
|
||||
}
|
||||
|
||||
|
||||
init(fse);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,10 +44,9 @@ public class PublicationSciOrganizationStep extends SimpleEditStep {
|
|||
AuthoringKitWizard parent,
|
||||
String prefix) {
|
||||
super(itemModel, parent, prefix);
|
||||
|
||||
|
||||
BasicItemForm addOrganizationSheet =
|
||||
new PublicationSciOrganizationAddForm(itemModel,
|
||||
getOrganizationClassName());
|
||||
new PublicationSciOrganizationAddForm(itemModel);
|
||||
add(ADD_ORGANIZATION_SHEET_NAME,
|
||||
(String) SciOrganizationPublicationGlobalizationUtil.globalize(
|
||||
"sciorganizationpublication.ui.addOrganization").localize(),
|
||||
|
|
@ -58,9 +57,5 @@ public class PublicationSciOrganizationStep extends SimpleEditStep {
|
|||
new PublicationSciOrganizationTable(
|
||||
itemModel);
|
||||
setDisplayComponent(organizationTable);
|
||||
}
|
||||
|
||||
private String getOrganizationClassName() {
|
||||
return GenericOrganizationalUnit.class.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitWithPublications;
|
|||
import com.arsdigita.cms.contenttypes.Publication;
|
||||
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
sciorganizationpublication.ui.publicationsOfOrganization=Publications of the organization
|
||||
sciorganizationpublication.ui.publicationsOfDepartment=Publications of the department
|
||||
sciorganizationpublication.ui.publicationsOfProject=Publications of the project
|
||||
sciorganizationpublication.ui.organizationsOfPublication=Organizations
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
sciorganizationpublication.ui.publicationsOfOrganization=Publikationen der Organisation
|
||||
sciorganizationpublication.ui.publicationsOfDepartment=Publikationen der Abteilung
|
||||
sciorganizationpublication.ui.publicationsOfProject=Publikationen des Projektes
|
||||
sciorganizationpublication.ui.organizationsOfPublication=Beteiligte Organizationen
|
||||
|
|
@ -41,21 +41,21 @@ public class GenericOrganizationalUnitWithPublications extends GenericOrganizati
|
|||
this(BASE_DATA_OBJECT_TYPE);
|
||||
}
|
||||
|
||||
public GenericOrganizationalUnitWithPublications(BigDecimal id)
|
||||
public GenericOrganizationalUnitWithPublications(final BigDecimal id)
|
||||
throws DataObjectNotFoundException {
|
||||
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||
}
|
||||
|
||||
public GenericOrganizationalUnitWithPublications(OID oid)
|
||||
public GenericOrganizationalUnitWithPublications(final OID oid)
|
||||
throws DataObjectNotFoundException {
|
||||
super(oid);
|
||||
}
|
||||
|
||||
public GenericOrganizationalUnitWithPublications(DataObject dobj) {
|
||||
public GenericOrganizationalUnitWithPublications(final DataObject dobj) {
|
||||
super(dobj);
|
||||
}
|
||||
|
||||
private GenericOrganizationalUnitWithPublications(String type) {
|
||||
private GenericOrganizationalUnitWithPublications(final String type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,147 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jens Pelzetter,
|
||||
* for the Center of Social Politics of the University of Bremen
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.contentassets.SciOrganizationPublicationCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.DataQuery;
|
||||
import com.arsdigita.persistence.OID;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class SciDepartmentWithPublications extends SciDepartment {
|
||||
|
||||
private GenericOrganizationalUnitWithPublications departmentWithPublications;
|
||||
|
||||
private SciDepartmentWithPublications() {
|
||||
}
|
||||
|
||||
private SciDepartmentWithPublications(final BigDecimal id) {
|
||||
}
|
||||
|
||||
private SciDepartmentWithPublications(final OID oid) {
|
||||
}
|
||||
|
||||
private SciDepartmentWithPublications(final DataObject dobj) {
|
||||
}
|
||||
|
||||
private SciDepartmentWithPublications(final String type) {
|
||||
}
|
||||
|
||||
public SciDepartmentWithPublications(final SciDepartment department) {
|
||||
departmentWithPublications =
|
||||
new GenericOrganizationalUnitWithPublications(department.getID());
|
||||
}
|
||||
|
||||
public boolean hasPublications(final boolean merge) {
|
||||
DataQuery query =
|
||||
SessionManager.getSession().retrieveQuery(
|
||||
"com.arsdigita.cms.contentassets.getIdsOfPublicationsOfSciDepartment");
|
||||
query.setParameter("departmentId", getID());
|
||||
|
||||
if (query.size() > 0) {
|
||||
query.close();
|
||||
return true;
|
||||
} else {
|
||||
if (merge) {
|
||||
query.close();
|
||||
DataQuery departmentsQuery =
|
||||
SessionManager.getSession().retrieveQuery(
|
||||
"com.arsdigita.cms.contenttypes.getIdsOfSubDepartmentsOfSciDepartment");
|
||||
departmentsQuery.setParameter("department", getID());
|
||||
|
||||
if (departmentsQuery.size() > 0) {
|
||||
BigDecimal departmentId;
|
||||
boolean result = false;
|
||||
while (departmentsQuery.next()) {
|
||||
departmentId = (BigDecimal) departmentsQuery.get(
|
||||
"departmentId");
|
||||
result = hasPublications(departmentId, merge);
|
||||
|
||||
if (result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
departmentsQuery.close();
|
||||
return result;
|
||||
} else {
|
||||
departmentsQuery.close();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
query.close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasPublications(final BigDecimal departmentId,
|
||||
final boolean merge) {
|
||||
DataQuery query =
|
||||
SessionManager.getSession().retrieveQuery(
|
||||
"com.arsdigita.cms.contentassets.getIdsOfPublicationsOfSciDepartment");
|
||||
query.setParameter("departmentId", departmentId);
|
||||
|
||||
if (query.size() > 0) {
|
||||
query.close();
|
||||
return true;
|
||||
} else {
|
||||
if (merge) {
|
||||
query.close();
|
||||
DataQuery subDepartmentsQuery =
|
||||
SessionManager.getSession().retrieveQuery(
|
||||
"com.arsdigita.cms.contenttypes.getIdsOfSubDepartmentsOfSciDepartment");
|
||||
subDepartmentsQuery.setParameter("department", departmentId);
|
||||
|
||||
if (query.size() > 0) {
|
||||
BigDecimal subDepartmentId;
|
||||
boolean result = false;
|
||||
while (subDepartmentsQuery.next()) {
|
||||
subDepartmentId = (BigDecimal) subDepartmentsQuery.get(
|
||||
"departmentId");
|
||||
result = hasPublications(subDepartmentId, merge);
|
||||
|
||||
if (result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
subDepartmentsQuery.close();
|
||||
return result;
|
||||
} else {
|
||||
subDepartmentsQuery.close();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
query.close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SciOrganizationPublicationCollection getPublications() {
|
||||
return departmentWithPublications.getPublications();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jens Pelzetter,
|
||||
* for the Center of Social Politics of the University of Bremen
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.contentassets.SciOrganizationPublicationCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.DataQuery;
|
||||
import com.arsdigita.persistence.OID;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class SciOrganizationWithPublications extends SciOrganization {
|
||||
|
||||
private GenericOrganizationalUnitWithPublications orgaWithPublications;
|
||||
private static final SciOrganizationWithPublicationsConfig config = new SciOrganizationWithPublicationsConfig();
|
||||
|
||||
static {
|
||||
config.load();
|
||||
}
|
||||
|
||||
private SciOrganizationWithPublications() {
|
||||
}
|
||||
|
||||
private SciOrganizationWithPublications(final BigDecimal id) {
|
||||
}
|
||||
|
||||
private SciOrganizationWithPublications(final OID oid) {
|
||||
}
|
||||
|
||||
private SciOrganizationWithPublications(final DataObject dobj) {
|
||||
}
|
||||
|
||||
private SciOrganizationWithPublications(final String type) {
|
||||
}
|
||||
|
||||
public SciOrganizationWithPublications(final SciOrganization organization) {
|
||||
orgaWithPublications = new GenericOrganizationalUnitWithPublications(
|
||||
organization.getID());
|
||||
}
|
||||
|
||||
public static SciOrganizationWithPublicationsConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public boolean hasPublications(final boolean merge) {
|
||||
DataQuery query =
|
||||
SessionManager.getSession().retrieveQuery(
|
||||
"com.arsdigita.cms.contentassets.getIdsOfPublicationsOfSciOrganization");
|
||||
query.setParameter("organization", getID());
|
||||
|
||||
if (query.size() > 0) {
|
||||
query.close();
|
||||
return true;
|
||||
} else {
|
||||
if (merge) {
|
||||
query.close();
|
||||
DataQuery departmentsQuery =
|
||||
SessionManager.getSession().retrieveQuery(
|
||||
"com.arsdigita.cms.contenttypes.getIdsOfDepartmentsOfSciOrganization");
|
||||
departmentsQuery.setParameter("organization", getID());
|
||||
|
||||
if (query.size() > 0) {
|
||||
BigDecimal departmentId;
|
||||
boolean result = false;
|
||||
while (departmentsQuery.next()) {
|
||||
departmentId = (BigDecimal) departmentsQuery.get(
|
||||
"departmentsId");
|
||||
result = hasPublications(departmentId, merge);
|
||||
|
||||
if (result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
departmentsQuery.close();
|
||||
return result;
|
||||
} else {
|
||||
departmentsQuery.close();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
query.close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasPublications(final BigDecimal departmentId,
|
||||
final boolean merge) {
|
||||
DataQuery query =
|
||||
SessionManager.getSession().retrieveQuery(
|
||||
"com.arsdigita.cms.contentassets.getIdsOfPublicationsOfSciDepartment");
|
||||
query.setParameter("departmentId", departmentId);
|
||||
|
||||
if (query.size() > 0) {
|
||||
query.close();
|
||||
return true;
|
||||
} else {
|
||||
if (merge) {
|
||||
query.close();
|
||||
DataQuery subDepartmentsQuery =
|
||||
SessionManager.getSession().retrieveQuery(
|
||||
"com.arsdigita.cms.contenttypes.getIdsOfSubDepartmentsOfSciDepartment");
|
||||
subDepartmentsQuery.setParameter("department", departmentId);
|
||||
|
||||
if (query.size() > 0) {
|
||||
BigDecimal subDepartmentId;
|
||||
boolean result = false;
|
||||
while(subDepartmentsQuery.next()) {
|
||||
subDepartmentId = (BigDecimal) subDepartmentsQuery.get(
|
||||
"departmentId");
|
||||
result = hasPublications(subDepartmentId, merge);
|
||||
|
||||
if (result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
subDepartmentsQuery.close();
|
||||
return result;
|
||||
} else {
|
||||
subDepartmentsQuery.close();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
query.close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SciOrganizationPublicationCollection getPublications() {
|
||||
return orgaWithPublications.getPublications();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.util.parameter.BooleanParameter;
|
||||
import com.arsdigita.util.parameter.Parameter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class SciOrganizationWithPublicationsConfig extends SciOrganizationConfig {
|
||||
|
||||
private final Parameter m_organizationPublicationsMerge;
|
||||
|
||||
public SciOrganizationWithPublicationsConfig() {
|
||||
super();
|
||||
|
||||
m_organizationPublicationsMerge =
|
||||
new BooleanParameter(
|
||||
"com.arsdigita.cms.contenttypes.sciorganization.publications_merge",
|
||||
Parameter.REQUIRED,
|
||||
Boolean.TRUE);
|
||||
|
||||
register(m_organizationPublicationsMerge);
|
||||
|
||||
loadInfo();
|
||||
}
|
||||
|
||||
public final boolean getOrganizationPublicationsMerge() {
|
||||
return (Boolean) get(m_organizationPublicationsMerge);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
com.arsdigita.cms.contenttypes.sciorganization.publications_merge.title = Merge publications
|
||||
com.arsdigita.cms.contenttypes.sciorganization.publications_merge.purpose = Merge publications from sub organizations into one list.
|
||||
com.arsdigita.cms.contenttypes.sciorganization.publications_merge.example = true
|
||||
com.arsdigita.cms.contenttypes.sciorganization.publications_merge.format = [boolean]
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,147 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jens Pelzetter,
|
||||
* for the Center of Social Politics of the University of Bremen
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.contentassets.SciOrganizationPublicationCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.DataQuery;
|
||||
import com.arsdigita.persistence.OID;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class SciProjectWithPublications extends SciProject {
|
||||
|
||||
private GenericOrganizationalUnitWithPublications projectWithPublications;
|
||||
|
||||
private SciProjectWithPublications() {
|
||||
}
|
||||
|
||||
private SciProjectWithPublications(final BigDecimal id) {
|
||||
}
|
||||
|
||||
private SciProjectWithPublications(final OID oid) {
|
||||
}
|
||||
|
||||
private SciProjectWithPublications(final DataObject dobj) {
|
||||
}
|
||||
|
||||
private SciProjectWithPublications(final String type) {
|
||||
}
|
||||
|
||||
public SciProjectWithPublications(final SciProject project) {
|
||||
projectWithPublications =
|
||||
new GenericOrganizationalUnitWithPublications(project.getID());
|
||||
}
|
||||
|
||||
public boolean hasPublications(final boolean merge) {
|
||||
DataQuery query =
|
||||
SessionManager.getSession().retrieveQuery(
|
||||
"com.arsdigita.cms.contentassets.getIdsOfPublicationsOfSciProject");
|
||||
query.setParameter("projectId", getID());
|
||||
|
||||
if (query.size() > 0) {
|
||||
query.close();
|
||||
return true;
|
||||
} else {
|
||||
if (merge) {
|
||||
query.close();
|
||||
DataQuery subProjectsQuery =
|
||||
SessionManager.getSession().retrieveQuery(
|
||||
"com.arsdigita.cms.contenttypes.getIdsOfSubProjectsOfSciProject");
|
||||
subProjectsQuery.setParameter("project", getID());
|
||||
|
||||
if (subProjectsQuery.size() > 0) {
|
||||
BigDecimal subProjectId;
|
||||
boolean result = false;
|
||||
while (subProjectsQuery.next()) {
|
||||
subProjectId = (BigDecimal) subProjectsQuery.get(
|
||||
"projectId");
|
||||
result = hasPublications(subProjectId, merge);
|
||||
|
||||
if (result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
subProjectsQuery.close();
|
||||
return result;
|
||||
} else {
|
||||
subProjectsQuery.close();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
query.close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasPublications(final BigDecimal projectId,
|
||||
final boolean merge) {
|
||||
DataQuery query =
|
||||
SessionManager.getSession().retrieveQuery(
|
||||
"com.arsdigita.cms.contentassets.getIdsOfPublicationsOfSciProject");
|
||||
query.setParameter("projectId", projectId);
|
||||
|
||||
if (query.size() > 0) {
|
||||
query.close();
|
||||
return true;
|
||||
} else {
|
||||
if (merge) {
|
||||
query.close();
|
||||
DataQuery subProjectsQuery =
|
||||
SessionManager.getSession().retrieveQuery(
|
||||
"com.arsdigita.cms.contenttypes.getIdsOfSubProjectsOfSciProject");
|
||||
subProjectsQuery.setParameter("project", projectId);
|
||||
|
||||
if (subProjectsQuery.size() > 0) {
|
||||
BigDecimal subProjectId;
|
||||
boolean result = false;
|
||||
while (subProjectsQuery.next()) {
|
||||
subProjectId = (BigDecimal) subProjectsQuery.get(
|
||||
"projectId");
|
||||
result = hasPublications(subProjectId, merge);
|
||||
|
||||
if (result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
subProjectsQuery.close();
|
||||
return result;
|
||||
} else {
|
||||
subProjectsQuery.close();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
query.close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SciOrganizationPublicationCollection getPublications() {
|
||||
return projectWithPublications.getPublications();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class SciPublicationComparator implements Comparator<Publication> {
|
||||
|
||||
public int compare(Publication publication1, Publication publication2) {
|
||||
return publication1.getTitle().compareTo(publication2.getTitle());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,198 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jens Pelzetter,
|
||||
* for the Center of Social Politics of the University of Bremen
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.cms.ContentItemXMLRenderer;
|
||||
import com.arsdigita.cms.contentassets.SciOrganizationPublicationCollection;
|
||||
import com.arsdigita.cms.contenttypes.Publication;
|
||||
import com.arsdigita.cms.contenttypes.SciDepartment;
|
||||
import com.arsdigita.cms.contenttypes.SciDepartmentSubDepartmentsCollection;
|
||||
import com.arsdigita.cms.contenttypes.SciDepartmentWithPublications;
|
||||
import com.arsdigita.cms.contenttypes.SciOrganizationWithPublications;
|
||||
import com.arsdigita.cms.contenttypes.SciOrganizationWithPublicationsConfig;
|
||||
import com.arsdigita.cms.contenttypes.SciPublicationComparator;
|
||||
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||
import com.arsdigita.xml.Element;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class SciDepartmentsWithPublicationsPanel extends SciDepartmentPanel {
|
||||
|
||||
public static final String SHOW_PUBLICATIONS = "publications";
|
||||
private boolean displayPublications = true;
|
||||
|
||||
public boolean isDisplayPublications() {
|
||||
return displayPublications;
|
||||
}
|
||||
|
||||
public void setDisplayPublications(final boolean displayPublications) {
|
||||
this.displayPublications = displayPublications;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void generateAvailableDataXml(final SciDepartment department,
|
||||
final Element element,
|
||||
final PageState state) {
|
||||
super.generateAvailableDataXml(department, element, state);
|
||||
|
||||
SciOrganizationWithPublicationsConfig config =
|
||||
SciOrganizationWithPublications.
|
||||
getConfig();
|
||||
|
||||
SciDepartmentWithPublications dep = new SciDepartmentWithPublications(
|
||||
department);
|
||||
|
||||
if ((dep.hasPublications(config.getOrganizationPublicationsMerge()))
|
||||
&& displayPublications) {
|
||||
element.newChildElement("publications");
|
||||
}
|
||||
}
|
||||
|
||||
protected void mergePublications(
|
||||
final SciDepartmentSubDepartmentsCollection subDepartments,
|
||||
final List<Publication> publications) {
|
||||
while (subDepartments.next()) {
|
||||
SciDepartment dep;
|
||||
SciDepartmentWithPublications department;
|
||||
SciOrganizationPublicationCollection departmentPublications;
|
||||
|
||||
dep = subDepartments.getSubDepartment();
|
||||
department = new SciDepartmentWithPublications(dep);
|
||||
departmentPublications = department.getPublications();
|
||||
|
||||
while (departmentPublications.next()) {
|
||||
publications.add(departmentPublications.getPublication());
|
||||
}
|
||||
|
||||
SciDepartmentSubDepartmentsCollection subSubDepartments = dep.
|
||||
getSubDepartments();
|
||||
|
||||
if ((subSubDepartments != null) && subSubDepartments.size() > 0) {
|
||||
mergePublications(subDepartments, publications);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void generatePublicationsXml(final SciDepartment department,
|
||||
final Element parent,
|
||||
final PageState state) {
|
||||
final SciDepartmentWithPublications dep =
|
||||
new SciDepartmentWithPublications(
|
||||
department);
|
||||
|
||||
if (SciOrganizationWithPublications.getConfig().
|
||||
getOrganizationPublicationsMerge()) {
|
||||
List<Publication> publications;
|
||||
publications = new LinkedList<Publication>();
|
||||
SciOrganizationPublicationCollection departmentPublications;
|
||||
departmentPublications = dep.getPublications();
|
||||
|
||||
while (departmentPublications.next()) {
|
||||
publications.add(departmentPublications.getPublication());
|
||||
}
|
||||
|
||||
mergePublications(department.getSubDepartments(), publications);
|
||||
|
||||
Set<Publication> publicationsSet;
|
||||
List<Publication> publicationsWithoutDoubles;
|
||||
publicationsSet = new HashSet<Publication>(publications);
|
||||
publicationsWithoutDoubles = new LinkedList<Publication>(
|
||||
publicationsSet);
|
||||
|
||||
Collections.sort(publicationsWithoutDoubles,
|
||||
new SciPublicationComparator());
|
||||
|
||||
long pageNumber = getPageNumber(state);
|
||||
long pageCount = getPageCount(publicationsWithoutDoubles.size());
|
||||
long begin = getPaginatorBegin(pageNumber);
|
||||
long count = getPaginatorCount(begin, publicationsWithoutDoubles.
|
||||
size());
|
||||
long end = getPaginatorEnd(begin, count);
|
||||
pageNumber = normalizePageNumber(pageCount, pageNumber);
|
||||
|
||||
createPaginatorElement(parent, pageNumber, pageCount, begin, end,
|
||||
count, publicationsWithoutDoubles.size());
|
||||
List<Publication> publicationsToShow = publicationsWithoutDoubles.
|
||||
subList((int) begin, (int) end);
|
||||
|
||||
final Element publicationsElem = parent.newChildElement(
|
||||
"publications");
|
||||
final ContentItemXMLRenderer renderer = new ContentItemXMLRenderer(
|
||||
publicationsElem);
|
||||
renderer.setWrapAttributes(true);
|
||||
for (Publication publication : publicationsToShow) {
|
||||
renderer.walk(publication, SimpleXMLGenerator.class.getName());
|
||||
}
|
||||
} else {
|
||||
SciOrganizationPublicationCollection departmentPublications;
|
||||
departmentPublications = dep.getPublications();
|
||||
|
||||
List<Publication> publications = new LinkedList<Publication>();
|
||||
|
||||
while (departmentPublications.next()) {
|
||||
publications.add(departmentPublications.getPublication());
|
||||
}
|
||||
|
||||
Collections.sort(publications, new SciPublicationComparator());
|
||||
|
||||
long pageNumber = getPageNumber(state);
|
||||
long pageCount = getPageCount(publications.size());
|
||||
long begin = getPaginatorBegin(pageNumber);
|
||||
long count = getPaginatorCount(begin, publications.size());
|
||||
long end = getPaginatorEnd(begin, count);
|
||||
pageNumber = normalizePageNumber(pageCount, pageNumber);
|
||||
|
||||
createPaginatorElement(parent, pageNumber, pageCount, begin, end,
|
||||
count, publications.size());
|
||||
List<Publication> publicationsToShow = publications.subList(
|
||||
(int) begin, (int) end);
|
||||
|
||||
final Element publicationsElem = parent.newChildElement(
|
||||
"publications");
|
||||
final ContentItemXMLRenderer renderer = new ContentItemXMLRenderer(
|
||||
publicationsElem);
|
||||
renderer.setWrapAttributes(true);
|
||||
for (Publication publication : publicationsToShow) {
|
||||
renderer.walk(publication, SimpleXMLGenerator.class.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateDataXml(final SciDepartment department,
|
||||
final Element element,
|
||||
final PageState state) {
|
||||
String show = getShowParam(state);
|
||||
|
||||
if (SHOW_PUBLICATIONS.equals(show)) {
|
||||
generatePublicationsXml(department, element, state);
|
||||
} else {
|
||||
super.generateDataXml(department, element, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,203 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jens Pelzetter,
|
||||
* for the Center of Social Politics of the University of Bremen
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.cms.ContentItemXMLRenderer;
|
||||
import com.arsdigita.cms.contentassets.SciOrganizationPublicationCollection;
|
||||
import com.arsdigita.cms.contenttypes.Publication;
|
||||
import com.arsdigita.cms.contenttypes.SciDepartment;
|
||||
import com.arsdigita.cms.contenttypes.SciDepartmentSubDepartmentsCollection;
|
||||
import com.arsdigita.cms.contenttypes.SciDepartmentWithPublications;
|
||||
import com.arsdigita.cms.contenttypes.SciOrganization;
|
||||
import com.arsdigita.cms.contenttypes.SciOrganizationDepartmentsCollection;
|
||||
import com.arsdigita.cms.contenttypes.SciOrganizationWithPublications;
|
||||
import com.arsdigita.cms.contenttypes.SciOrganizationWithPublicationsConfig;
|
||||
import com.arsdigita.cms.contenttypes.SciPublicationComparator;
|
||||
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||
import com.arsdigita.xml.Element;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class SciOrganizationWithPublicationsPanel extends SciOrganizationPanel {
|
||||
|
||||
public static final String SHOW_PUBLICATIONS = "publications";
|
||||
private boolean displayPublications = true;
|
||||
|
||||
public boolean isDisplayPublications() {
|
||||
return displayPublications;
|
||||
}
|
||||
|
||||
public void setDisplayPublications(final boolean displayPublications) {
|
||||
this.displayPublications = displayPublications;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void generateAvailableDataXml(final SciOrganization organization,
|
||||
final Element element,
|
||||
final PageState state) {
|
||||
super.generateAvailableDataXml(organization, element, state);
|
||||
|
||||
SciOrganizationWithPublicationsConfig config;
|
||||
config = SciOrganizationWithPublications.getConfig();
|
||||
|
||||
SciOrganizationWithPublications orga =
|
||||
new SciOrganizationWithPublications(
|
||||
organization);
|
||||
|
||||
if ((orga.hasPublications(config.getOrganizationPublicationsMerge()))
|
||||
&& displayPublications) {
|
||||
element.newChildElement("publications");
|
||||
}
|
||||
}
|
||||
|
||||
protected void mergePublications(
|
||||
final SciOrganizationDepartmentsCollection departments,
|
||||
final List<Publication> publications) {
|
||||
while (departments.next()) {
|
||||
SciDepartment dep;
|
||||
SciDepartmentWithPublications department;
|
||||
SciOrganizationPublicationCollection departmentPublications;
|
||||
|
||||
dep = departments.getDepartment();
|
||||
department = new SciDepartmentWithPublications(dep);
|
||||
departmentPublications = department.getPublications();
|
||||
|
||||
while (departmentPublications.next()) {
|
||||
publications.add(departmentPublications.getPublication());
|
||||
}
|
||||
|
||||
SciDepartmentSubDepartmentsCollection subDepartments;
|
||||
subDepartments = dep.getSubDepartments();
|
||||
|
||||
if ((subDepartments != null) && subDepartments.size() > 0) {
|
||||
mergePublications(departments, publications);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void generatePublicationsXml(final SciOrganization organization,
|
||||
final Element parent,
|
||||
final PageState state) {
|
||||
final SciOrganizationWithPublications orga =
|
||||
new SciOrganizationWithPublications(
|
||||
organization);
|
||||
|
||||
if (SciOrganizationWithPublications.getConfig().
|
||||
getOrganizationPublicationsMerge()) {
|
||||
List<Publication> publications;
|
||||
publications = new LinkedList<Publication>();
|
||||
SciOrganizationPublicationCollection orgaPublications;
|
||||
orgaPublications = orga.getPublications();
|
||||
|
||||
while (orgaPublications.next()) {
|
||||
publications.add(orgaPublications.getPublication());
|
||||
}
|
||||
|
||||
mergePublications(organization.getDepartments(),
|
||||
publications);
|
||||
|
||||
Set<Publication> publicationsSet;
|
||||
List<Publication> publicationWithoutDoubles;
|
||||
publicationsSet = new HashSet<Publication>(publications);
|
||||
publicationWithoutDoubles = new LinkedList<Publication>(
|
||||
publicationsSet);
|
||||
|
||||
Collections.sort(publicationWithoutDoubles,
|
||||
new SciPublicationComparator());
|
||||
|
||||
long pageNumber = getPageNumber(state);
|
||||
long pageCount = getPageCount(publicationWithoutDoubles.size());
|
||||
long begin = getPaginatorBegin(pageNumber);
|
||||
long count = getPaginatorCount(begin,
|
||||
publicationWithoutDoubles.size());
|
||||
long end = getPaginatorEnd(begin, count);
|
||||
pageNumber = normalizePageNumber(pageCount, pageNumber);
|
||||
|
||||
createPaginatorElement(parent, pageNumber, pageCount, begin, end,
|
||||
count, publicationWithoutDoubles.size());
|
||||
List<Publication> publicationsToShow = publicationWithoutDoubles.
|
||||
subList((int) begin, (int) end);
|
||||
|
||||
final Element publicationsElem = parent.newChildElement(
|
||||
"publications");
|
||||
final ContentItemXMLRenderer renderer =
|
||||
new ContentItemXMLRenderer(
|
||||
publicationsElem);
|
||||
renderer.setWrapAttributes(true);
|
||||
for (Publication publication : publicationsToShow) {
|
||||
renderer.walk(publication, SimpleXMLGenerator.class.getName());
|
||||
}
|
||||
} else {
|
||||
SciOrganizationPublicationCollection orgaPublications;
|
||||
orgaPublications = orga.getPublications();
|
||||
|
||||
List<Publication> publications = new LinkedList<Publication>();
|
||||
|
||||
while (orgaPublications.next()) {
|
||||
publications.add(orgaPublications.getPublication());
|
||||
}
|
||||
|
||||
Collections.sort(publications, new SciPublicationComparator());
|
||||
|
||||
long pageNumber = getPageNumber(state);
|
||||
long pageCount = getPageCount(publications.size());
|
||||
long begin = getPaginatorBegin(pageNumber);
|
||||
long count = getPaginatorCount(begin, publications.size());
|
||||
long end = getPaginatorEnd(begin, count);
|
||||
pageNumber = normalizePageNumber(pageCount, pageNumber);
|
||||
|
||||
createPaginatorElement(parent, pageNumber, pageCount, begin, end,
|
||||
count, publications.size());
|
||||
List<Publication> publicationsToShow = publications.subList(
|
||||
(int) begin, (int) end);
|
||||
|
||||
final Element publicationsElem = parent.newChildElement(
|
||||
"publications");
|
||||
final ContentItemXMLRenderer renderer =
|
||||
new ContentItemXMLRenderer(
|
||||
publicationsElem);
|
||||
renderer.setWrapAttributes(true);
|
||||
for (Publication publication : publicationsToShow) {
|
||||
renderer.walk(publication, SimpleXMLGenerator.class.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void generateDataXml(final SciOrganization organization,
|
||||
final Element element,
|
||||
final PageState state) {
|
||||
String show = getShowParam(state);
|
||||
|
||||
if (SHOW_PUBLICATIONS.equals(show)) {
|
||||
generatePublicationsXml(organization, element, state);
|
||||
} else {
|
||||
super.generateDataXml(organization, element, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,195 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jens Pelzetter,
|
||||
* for the Center of Social Politics of the University of Bremen
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.cms.ContentItemXMLRenderer;
|
||||
import com.arsdigita.cms.contentassets.SciOrganizationPublicationCollection;
|
||||
import com.arsdigita.cms.contenttypes.Publication;
|
||||
import com.arsdigita.cms.contenttypes.SciOrganizationWithPublications;
|
||||
import com.arsdigita.cms.contenttypes.SciOrganizationWithPublicationsConfig;
|
||||
import com.arsdigita.cms.contenttypes.SciProject;
|
||||
import com.arsdigita.cms.contenttypes.SciProjectSubProjectsCollection;
|
||||
import com.arsdigita.cms.contenttypes.SciProjectWithPublications;
|
||||
import com.arsdigita.cms.contenttypes.SciPublicationComparator;
|
||||
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||
import com.arsdigita.xml.Element;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class SciProjectWithPublicationsPanel extends SciProjectPanel {
|
||||
|
||||
public static final String SHOW_PUBLICATIONS = "publications";
|
||||
private boolean displayPublications = true;
|
||||
|
||||
public boolean isDisplayPublications() {
|
||||
return displayPublications;
|
||||
}
|
||||
|
||||
public void setDisplayPublications(final boolean displayPublications) {
|
||||
this.displayPublications = displayPublications;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateAvailableDataXml(final SciProject project,
|
||||
final Element element,
|
||||
final PageState state) {
|
||||
super.generateAvailableDataXml(project, element, state);
|
||||
|
||||
SciOrganizationWithPublicationsConfig config =
|
||||
SciOrganizationWithPublications.
|
||||
getConfig();
|
||||
|
||||
SciProjectWithPublications proj =
|
||||
new SciProjectWithPublications(project);
|
||||
|
||||
if ((proj.hasPublications(config.getOrganizationPublicationsMerge()))
|
||||
&& displayPublications) {
|
||||
element.newChildElement("publications");
|
||||
}
|
||||
}
|
||||
|
||||
protected void mergePublications(
|
||||
final SciProjectSubProjectsCollection subProjects,
|
||||
final List<Publication> publications) {
|
||||
while (subProjects.next()) {
|
||||
SciProject proj;
|
||||
SciProjectWithPublications project;
|
||||
SciOrganizationPublicationCollection projectPublications;
|
||||
|
||||
proj = subProjects.getSubProject();
|
||||
project = new SciProjectWithPublications(proj);
|
||||
projectPublications = project.getPublications();
|
||||
|
||||
while (projectPublications.next()) {
|
||||
publications.add(projectPublications.getPublication());
|
||||
}
|
||||
|
||||
SciProjectSubProjectsCollection subSubProjects =
|
||||
proj.getSubProjects();
|
||||
|
||||
if ((subSubProjects != null) && subSubProjects.size() > 0) {
|
||||
mergePublications(subSubProjects, publications);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void generatePublicationsXml(final SciProject project,
|
||||
final Element parent,
|
||||
final PageState state) {
|
||||
final SciProjectWithPublications proj = new SciProjectWithPublications(
|
||||
project);
|
||||
|
||||
if (SciOrganizationWithPublications.getConfig().
|
||||
getOrganizationPublicationsMerge()) {
|
||||
List<Publication> publications = new LinkedList<Publication>();
|
||||
SciOrganizationPublicationCollection projectPublications = proj.
|
||||
getPublications();
|
||||
|
||||
while (projectPublications.next()) {
|
||||
publications.add(projectPublications.getPublication());
|
||||
}
|
||||
|
||||
mergePublications(project.getSubProjects(), publications);
|
||||
|
||||
Set<Publication> publicationsSet;
|
||||
List<Publication> publicationsWithoutDoubles;
|
||||
publicationsSet = new HashSet<Publication>(publications);
|
||||
publicationsWithoutDoubles = new LinkedList<Publication>(
|
||||
publicationsSet);
|
||||
Collections.sort(publicationsWithoutDoubles,
|
||||
new SciPublicationComparator());
|
||||
|
||||
long pageNumber = getPageNumber(state);
|
||||
long pageCount = getPageCount(publicationsWithoutDoubles.size());
|
||||
long begin = getPaginatorBegin(pageNumber);
|
||||
long count = getPaginatorCount(begin, publicationsWithoutDoubles.
|
||||
size());
|
||||
long end = getPaginatorEnd(begin, count);
|
||||
pageNumber = normalizePageNumber(pageCount, pageNumber);
|
||||
|
||||
createPaginatorElement(parent, pageNumber, pageCount, begin, end,
|
||||
count, publicationsWithoutDoubles.size());
|
||||
List<Publication> publicationsToShow = publicationsWithoutDoubles.
|
||||
subList((int) begin, (int) end);
|
||||
|
||||
final Element publicationsElem = parent.newChildElement(
|
||||
"publications");
|
||||
final ContentItemXMLRenderer renderer = new ContentItemXMLRenderer(
|
||||
publicationsElem);
|
||||
renderer.setWrapAttributes(true);
|
||||
for (Publication publication : publicationsToShow) {
|
||||
renderer.walk(publication, SimpleXMLGenerator.class.getName());
|
||||
}
|
||||
} else {
|
||||
SciOrganizationPublicationCollection projectPublications = proj.
|
||||
getPublications();
|
||||
|
||||
List<Publication> publications = new LinkedList<Publication>();
|
||||
|
||||
while (projectPublications.next()) {
|
||||
publications.add(projectPublications.getPublication());
|
||||
}
|
||||
|
||||
Collections.sort(publications, new SciPublicationComparator());
|
||||
|
||||
long pageNumber = getPageNumber(state);
|
||||
long pageCount = getPageCount(publications.size());
|
||||
long begin = getPaginatorBegin(pageNumber);
|
||||
long count = getPaginatorCount(begin, publications.size());
|
||||
long end = getPaginatorEnd(begin, count);
|
||||
pageNumber = normalizePageNumber(pageCount, pageNumber);
|
||||
|
||||
createPaginatorElement(parent, pageNumber, pageCount, begin, end,
|
||||
count, publications.size());
|
||||
List<Publication> publicationsToShow = publications.subList(
|
||||
(int) begin, (int) end);
|
||||
|
||||
final Element publicationsElem = parent.newChildElement(
|
||||
"publications");
|
||||
final ContentItemXMLRenderer renderer = new ContentItemXMLRenderer(
|
||||
publicationsElem);
|
||||
renderer.setWrapAttributes(true);
|
||||
for (Publication publication : publicationsToShow) {
|
||||
renderer.walk(publication, SimpleXMLGenerator.class.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateDataXml(final SciProject project,
|
||||
final Element element,
|
||||
final PageState state) {
|
||||
String show = getShowParam(state);
|
||||
|
||||
if (SHOW_PUBLICATIONS.equals(show)) {
|
||||
generatePublicationsXml(project, element, state);
|
||||
} else {
|
||||
super.generateDataXml(project, element, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -41,19 +41,19 @@
|
|||
component="com.arsdigita.cms.contenttypes.ui.SciDepartmentProjectsStep"
|
||||
ordering="4"/>
|
||||
|
||||
<ctd:authoring-step
|
||||
<!--<ctd:authoring-step
|
||||
labelKey="sciorganization.ui.department.publications"
|
||||
labelBundle="com.arsdigita.cms.contenttypes.ui.SciOrganizationResources"
|
||||
descriptionKey="sciorganization.ui.department.publications.description.title"
|
||||
component="com.arsdigita.cms.contenttypes.ui.SciDepartmentPublicationsStep"
|
||||
ordering="5"/>
|
||||
ordering="5"/> -->
|
||||
|
||||
<ctd:authoring-step
|
||||
labelKey="sciorganization.ui.department.description.title"
|
||||
labelBundle="com.arsdigita.cms.contenttypes.ui.SciOrganizationResources"
|
||||
descriptionKey="sciorganization.ui.department.description.title"
|
||||
component="com.arsdigita.cms.contenttypes.ui.SciDepartmentDescriptionStep"
|
||||
ordering="6"/>
|
||||
ordering="5"/>
|
||||
|
||||
<ctd:include href="/WEB-INF/content-types/assign-categories-step.xml"/>
|
||||
|
||||
|
|
|
|||
|
|
@ -42,19 +42,19 @@
|
|||
ordering="4"/>
|
||||
|
||||
|
||||
<ctd:authoring-step
|
||||
<!--<ctd:authoring-step
|
||||
labelKey="sciorganization.ui.project.publications"
|
||||
labelBundle="com.arsdigita.cms.contenttypes.ui.SciOrganizationResources"
|
||||
descriptionKey="sciorganization.ui.project.publications"
|
||||
component="com.arsdigita.cms.contenttypes.ui.SciProjectPublicationsStep"
|
||||
ordering="5"/>
|
||||
ordering="5"/> -->
|
||||
|
||||
<ctd:authoring-step
|
||||
labelKey="sciorganization.ui.project_description.title"
|
||||
labelBundle="com.arsdigita.cms.contenttypes.ui.SciOrganizationResources"
|
||||
descriptionKey="sciorganization.ui.project_description.title"
|
||||
component="com.arsdigita.cms.contenttypes.ui.SciProjectDescriptionStep"
|
||||
ordering="6"/>
|
||||
ordering="5"/>
|
||||
|
||||
<ctd:include href="/WEB-INF/content-types/assign-categories-step.xml"/>
|
||||
|
||||
|
|
|
|||
|
|
@ -501,7 +501,7 @@ public class SciDepartment extends GenericOrganizationalUnit {
|
|||
"com.arsdigita.cms.contenttypes.getIdsOfSubDepartmentsOfSciDepartment");
|
||||
departmentsQuery.setParameter("department", getID());
|
||||
|
||||
if (query.size() > 0) {
|
||||
if (departmentsQuery.size() > 0) {
|
||||
BigDecimal departmentId;
|
||||
boolean result = false;
|
||||
while (departmentsQuery.next()) {
|
||||
|
|
@ -551,7 +551,7 @@ public class SciDepartment extends GenericOrganizationalUnit {
|
|||
}
|
||||
|
||||
DataQuery query = SessionManager.getSession().retrieveQuery(queryName);
|
||||
query.setParameter("department", getID());
|
||||
query.setParameter("department", departmentId);
|
||||
if (status != ProjectStatus.ALL) {
|
||||
Calendar today = new GregorianCalendar();
|
||||
query.setParameter("today",
|
||||
|
|
|
|||
|
|
@ -407,7 +407,7 @@ public class SciOrganization extends GenericOrganizationalUnit {
|
|||
}
|
||||
|
||||
DataQuery query = SessionManager.getSession().retrieveQuery(queryName);
|
||||
query.setParameter("department", getID());
|
||||
query.setParameter("department", departmentId);
|
||||
if (status != ProjectStatus.ALL) {
|
||||
Calendar today = new GregorianCalendar();
|
||||
query.setParameter("today",
|
||||
|
|
@ -455,7 +455,7 @@ public class SciOrganization extends GenericOrganizationalUnit {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean hasPublications() {
|
||||
/*public boolean hasPublications() {
|
||||
boolean result = false;
|
||||
|
||||
DataQuery query =
|
||||
|
|
@ -472,7 +472,7 @@ public class SciOrganization extends GenericOrganizationalUnit {
|
|||
query.close();
|
||||
|
||||
return result;
|
||||
}
|
||||
}*/
|
||||
|
||||
public void setOrganizationDescription(String description) {
|
||||
set(ORGANIZATION_DESCRIPTION, description);
|
||||
|
|
|
|||
|
|
@ -475,7 +475,7 @@ public class SciProject extends GenericOrganizationalUnit {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean hasPublications() {
|
||||
/*public boolean hasPublications() {
|
||||
boolean result = false;
|
||||
|
||||
DataQuery query =
|
||||
|
|
@ -492,5 +492,5 @@ public class SciProject extends GenericOrganizationalUnit {
|
|||
query.close();
|
||||
|
||||
return result;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import com.arsdigita.cms.contenttypes.GenericPerson;
|
|||
import com.arsdigita.cms.contenttypes.SciDepartment;
|
||||
import com.arsdigita.cms.contenttypes.SciDepartmentProjectsCollection;
|
||||
import com.arsdigita.cms.contenttypes.SciDepartmentSubDepartmentsCollection;
|
||||
import com.arsdigita.cms.contenttypes.SciOrganization;
|
||||
import com.arsdigita.cms.contenttypes.SciOrganizationConfig;
|
||||
import com.arsdigita.cms.contenttypes.SciProject;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
|
@ -54,7 +55,6 @@ public class SciDepartmentPanel extends SciOrganizationBasePanel {
|
|||
public static final String SHOW_PROJECTS = "projects";
|
||||
public static final String SHOW_PROJECTS_ONGOING = "projectsOngoing";
|
||||
public static final String SHOW_PROJECTS_FINISHED = "projectsFinished";
|
||||
public static final String SHOW_PUBLICATIONS = "publications";
|
||||
private boolean displayDescription = true;
|
||||
private boolean displaySubDepartments = true;
|
||||
private boolean displayProjects = true;
|
||||
|
|
@ -85,15 +85,7 @@ public class SciDepartmentPanel extends SciOrganizationBasePanel {
|
|||
public void setDisplayProjects(boolean displayProjects) {
|
||||
this.displayProjects = displayProjects;
|
||||
}
|
||||
|
||||
public boolean isDisplayPublications() {
|
||||
return displayPublications;
|
||||
}
|
||||
|
||||
public void setDisplayPublications(boolean displayPublications) {
|
||||
this.displayPublications = displayPublications;
|
||||
}
|
||||
|
||||
|
||||
public boolean isDisplaySubDepartments() {
|
||||
return displaySubDepartments;
|
||||
}
|
||||
|
|
@ -374,8 +366,9 @@ public class SciDepartmentPanel extends SciOrganizationBasePanel {
|
|||
end,
|
||||
count,
|
||||
projectsWithoutDoubles.size());
|
||||
List<SciProject> projectsToShow = projectsWithoutDoubles.subList((int) begin,
|
||||
(int) end);
|
||||
List<SciProject> projectsToShow =
|
||||
projectsWithoutDoubles.subList((int) begin,
|
||||
(int) end);
|
||||
|
||||
Element projectsElem = parent.newChildElement("projects");
|
||||
for (SciProject project : projectsToShow) {
|
||||
|
|
@ -420,6 +413,99 @@ public class SciDepartmentPanel extends SciOrganizationBasePanel {
|
|||
}
|
||||
}
|
||||
|
||||
protected void generateAvailableDataXml(final SciDepartment department,
|
||||
final Element element,
|
||||
final PageState state) {
|
||||
final SciOrganizationConfig config = SciOrganization.getConfig();
|
||||
|
||||
if ((department.getDepartmentDescription() != null)
|
||||
&& !department.getDepartmentDescription().isEmpty()
|
||||
&& displayDescription) {
|
||||
element.newChildElement("description");
|
||||
}
|
||||
if (department.hasContacts()
|
||||
&& isDisplayContacts()) {
|
||||
element.newChildElement("contacts");
|
||||
}
|
||||
if (department.hasSubDepartments()
|
||||
&& displaySubDepartments) {
|
||||
element.newChildElement("subDepartments");
|
||||
}
|
||||
if (config.getOrganizationMembersAllInOne()) {
|
||||
if (hasMembers(department)
|
||||
&& isDisplayMembers()) {
|
||||
element.newChildElement("members");
|
||||
}
|
||||
} else {
|
||||
if (hasActiveMembers(department)
|
||||
&& isDisplayMembers()) {
|
||||
element.newChildElement("membersActive");
|
||||
}
|
||||
if (hasAssociatedMembers(department)
|
||||
&& isDisplayMembers()) {
|
||||
element.newChildElement("membersAssociated");
|
||||
}
|
||||
if (hasFormerMembers(department)
|
||||
&& isDisplayMembers()) {
|
||||
element.newChildElement("membersFormer");
|
||||
}
|
||||
}
|
||||
if (config.getOrganizationProjectsAllInOne()) {
|
||||
if (hasProjects(department)
|
||||
&& displayProjects) {
|
||||
element.newChildElement("projects");
|
||||
}
|
||||
} else {
|
||||
if (hasOngoingProjects(department)
|
||||
&& displayProjects) {
|
||||
element.newChildElement("projectsOngoing");
|
||||
}
|
||||
if (hasFinishedProjects(department)
|
||||
&& displayProjects) {
|
||||
element.newChildElement("projectsFinished");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void generateDataXml(SciDepartment department,
|
||||
Element element,
|
||||
PageState state) {
|
||||
String show = getShowParam(state);
|
||||
|
||||
if (SHOW_DESCRIPTION.equals(show)) {
|
||||
String desc;
|
||||
desc = department.getDepartmentDescription();
|
||||
|
||||
Element description = element.newChildElement("description");
|
||||
description.setText(desc);
|
||||
} else if (SHOW_CONTACTS.equals(show)) {
|
||||
generateContactsXML(department, element, state);
|
||||
} else if (SHOW_MEMBERS.equals(show)) {
|
||||
generateMembersXML(department, element, state,
|
||||
new LinkedList<String>());
|
||||
} else if (SHOW_MEMBERS_ACTIVE.equals(show)) {
|
||||
generateMembersXML(department, element, state,
|
||||
getFiltersForActiveMembers());
|
||||
} else if (SHOW_MEMBERS_ASSOCIATED.equals(show)) {
|
||||
generateMembersXML(department, element, state,
|
||||
getFiltersForAssociatedMembers());
|
||||
} else if (SHOW_MEMBERS_FORMER.equals(show)) {
|
||||
generateMembersXML(department, element, state,
|
||||
getFiltersForFormerMembers());
|
||||
} else if (SHOW_PROJECTS.equals(show)) {
|
||||
generateProjectsXML(department, element, state,
|
||||
new LinkedList<String>());
|
||||
} else if (SHOW_PROJECTS_ONGOING.equals(show)) {
|
||||
generateProjectsXML(department, element, state,
|
||||
getFiltersForOngoingProjects());
|
||||
} else if (SHOW_PROJECTS_FINISHED.equals(show)) {
|
||||
generateProjectsXML(department, element, state,
|
||||
getFiltersForFinishedProjects());
|
||||
} else if (SHOW_SUBDEPARTMENTS.equals(show)) {
|
||||
generateSubDepartmentsXML(department, element, state);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateXML(ContentItem item,
|
||||
Element element,
|
||||
|
|
@ -430,99 +516,8 @@ public class SciDepartmentPanel extends SciOrganizationBasePanel {
|
|||
|
||||
SciDepartment department = (SciDepartment) item;
|
||||
|
||||
SciOrganizationConfig config = SciDepartment.getConfig();
|
||||
generateAvailableDataXml(department, availableData, state);
|
||||
|
||||
if ((department.getDepartmentDescription() != null)
|
||||
&& !department.getDepartmentDescription().isEmpty()
|
||||
&& displayDescription) {
|
||||
availableData.newChildElement("description");
|
||||
}
|
||||
if (department.hasContacts()
|
||||
&& isDisplayContacts()) {
|
||||
availableData.newChildElement("contacts");
|
||||
}
|
||||
if (department.hasSubDepartments()
|
||||
&& displaySubDepartments) {
|
||||
availableData.newChildElement("subDepartments");
|
||||
}
|
||||
if (config.getOrganizationMembersAllInOne()) {
|
||||
if (hasMembers(department)
|
||||
&& isDisplayMembers()) {
|
||||
availableData.newChildElement("members");
|
||||
}
|
||||
} else {
|
||||
if (hasActiveMembers(department)
|
||||
&& isDisplayMembers()) {
|
||||
availableData.newChildElement("membersActive");
|
||||
}
|
||||
if (hasAssociatedMembers(department)
|
||||
&& isDisplayMembers()) {
|
||||
availableData.newChildElement("membersAssociated");
|
||||
}
|
||||
if (hasFormerMembers(department)
|
||||
&& isDisplayMembers()) {
|
||||
availableData.newChildElement("membersFormer");
|
||||
}
|
||||
}
|
||||
if (config.getOrganizationProjectsAllInOne()) {
|
||||
if (hasProjects(department)
|
||||
&& displayProjects) {
|
||||
availableData.newChildElement("projects");
|
||||
}
|
||||
} else {
|
||||
if (hasOngoingProjects(department)
|
||||
&& displayProjects) {
|
||||
availableData.newChildElement("projectsOngoing");
|
||||
}
|
||||
if (hasFinishedProjects(department)
|
||||
&& displayProjects) {
|
||||
availableData.newChildElement("projectsFinished");
|
||||
}
|
||||
}
|
||||
if (department.hasPublications()
|
||||
&& displayPublications) {
|
||||
availableData.newChildElement("publications");
|
||||
}
|
||||
|
||||
String show = getShowParam(state);
|
||||
|
||||
if (SHOW_DESCRIPTION.equals(show)) {
|
||||
String desc;
|
||||
desc = department.getDepartmentDescription();
|
||||
|
||||
Element description = content.newChildElement("description");
|
||||
description.setText(desc);
|
||||
} else if (SHOW_CONTACTS.equals(show)) {
|
||||
generateContactsXML(department, content, state);
|
||||
} else if (SHOW_MEMBERS.equals(show)) {
|
||||
generateMembersXML(department, content, state,
|
||||
new LinkedList<String>());
|
||||
} else if (SHOW_MEMBERS_ACTIVE.equals(show)) {
|
||||
generateMembersXML(department, content, state,
|
||||
getFiltersForActiveMembers());
|
||||
} else if (SHOW_MEMBERS_ASSOCIATED.equals(show)) {
|
||||
generateMembersXML(department, content, state,
|
||||
getFiltersForAssociatedMembers());
|
||||
} else if (SHOW_MEMBERS_FORMER.equals(show)) {
|
||||
generateMembersXML(department, content, state,
|
||||
getFiltersForFormerMembers());
|
||||
} else if (SHOW_PROJECTS.equals(show)) {
|
||||
generateProjectsXML(department, content, state,
|
||||
new LinkedList<String>());
|
||||
} else if (SHOW_PROJECTS_ONGOING.equals(show)) {
|
||||
generateProjectsXML(department, content, state,
|
||||
getFiltersForOngoingProjects());
|
||||
} else if (SHOW_PROJECTS_FINISHED.equals(show)) {
|
||||
generateProjectsXML(department, content, state,
|
||||
getFiltersForFinishedProjects());
|
||||
} else if (SHOW_SUBDEPARTMENTS.equals(show)) {
|
||||
generateSubDepartmentsXML(department, content, state);
|
||||
} else if (SHOW_PUBLICATIONS.equals(show)) {
|
||||
generatePublicationsXML(
|
||||
RelatedLink.getRelatedLinks(item,
|
||||
"SciDepartmentPublications"),
|
||||
content,
|
||||
state);
|
||||
}
|
||||
generateDataXml(department, content, state);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -479,7 +479,7 @@ public abstract class SciOrganizationBasePanel
|
|||
* @param parent The parent XML element for the XML created by this method
|
||||
* @param state The current page state.
|
||||
*/
|
||||
protected void generatePublicationsXML(final DataCollection links,
|
||||
/* protected void generatePublicationsXML(final DataCollection links,
|
||||
final Element parent,
|
||||
final PageState state) {
|
||||
RelatedLink link;
|
||||
|
|
@ -561,5 +561,5 @@ public abstract class SciOrganizationBasePanel
|
|||
renderer.setWrapAttributes(true);
|
||||
|
||||
renderer.walk(publication, SimpleXMLGenerator.class.getName());
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ package com.arsdigita.cms.contenttypes.ui;
|
|||
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.contentassets.RelatedLink;
|
||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitContactCollection;
|
||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitPersonCollection;
|
||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||
|
|
@ -58,12 +57,11 @@ public class SciOrganizationPanel extends SciOrganizationBasePanel {
|
|||
public static final String SHOW_DEPARTMENTS = "departments";
|
||||
public static final String SHOW_PROJECTS = "projects";
|
||||
public static final String SHOW_PROJECTS_ONGOING = "projectsOngoing";
|
||||
public static final String SHOW_PROJECTS_FINISHED = "projectsFinished";
|
||||
public static final String SHOW_PUBLICATIONS = "publications";
|
||||
public static final String SHOW_PROJECTS_FINISHED = "projectsFinished";
|
||||
private boolean displayDescription = true;
|
||||
private boolean displayDepartments = true;
|
||||
private boolean displayProjects = true;
|
||||
private boolean displayPublications = true;
|
||||
//private boolean displayPublications = true;
|
||||
|
||||
@Override
|
||||
protected String getDefaultForShowParam() {
|
||||
|
|
@ -120,19 +118,19 @@ public class SciOrganizationPanel extends SciOrganizationBasePanel {
|
|||
getOrganizationProjectsMerge(),
|
||||
SciOrganization.ProjectStatus.ALL);
|
||||
}
|
||||
|
||||
protected boolean hasOngoingProjects(final SciOrganization orga) {
|
||||
|
||||
protected boolean hasOngoingProjects(final SciOrganization orga) {
|
||||
return orga.hasProjects(SciOrganization.getConfig().
|
||||
getOrganizationProjectsMerge(),
|
||||
SciOrganization.ProjectStatus.ONGOING);
|
||||
}
|
||||
|
||||
protected boolean hasFinishedProjects(final SciOrganization orga) {
|
||||
|
||||
protected boolean hasFinishedProjects(final SciOrganization orga) {
|
||||
return orga.hasProjects(SciOrganization.getConfig().
|
||||
getOrganizationProjectsMerge(),
|
||||
SciOrganization.ProjectStatus.FINISHED);
|
||||
}
|
||||
|
||||
|
||||
protected void generateDepartmentsXML(final SciOrganization orga,
|
||||
final Element parent,
|
||||
final PageState state) {
|
||||
|
|
@ -264,7 +262,7 @@ public class SciOrganizationPanel extends SciOrganizationBasePanel {
|
|||
for (String filter : filters) {
|
||||
orgaMembers.addFilter(filter);
|
||||
}
|
||||
|
||||
|
||||
SciOrganizationDepartmentsCollection departments;
|
||||
departments = orga.getDepartments();
|
||||
|
||||
|
|
@ -418,108 +416,112 @@ public class SciOrganizationPanel extends SciOrganizationBasePanel {
|
|||
}
|
||||
}
|
||||
|
||||
protected void generateAvailableDataXml(final SciOrganization organization,
|
||||
final Element element,
|
||||
final PageState state) {
|
||||
SciOrganizationConfig config;
|
||||
config = SciOrganization.getConfig();
|
||||
|
||||
if ((organization.getOrganizationDescription() != null)
|
||||
&& !(organization.getOrganizationDescription().isEmpty())
|
||||
&& displayDescription) {
|
||||
element.newChildElement("description");
|
||||
}
|
||||
if (organization.hasContacts()
|
||||
&& isDisplayContacts()) {
|
||||
element.newChildElement("contacts");
|
||||
}
|
||||
if (organization.hasDepartments()
|
||||
&& displayDepartments) {
|
||||
element.newChildElement("departments");
|
||||
}
|
||||
if (config.getOrganizationMembersAllInOne()) {
|
||||
if (hasMembers(organization)
|
||||
&& isDisplayMembers()) {
|
||||
element.newChildElement("members");
|
||||
}
|
||||
} else {
|
||||
if (hasActiveMembers(organization)
|
||||
&& isDisplayMembers()) {
|
||||
element.newChildElement("membersActive");
|
||||
}
|
||||
if (hasAssociatedMembers(organization)
|
||||
&& isDisplayMembers()) {
|
||||
element.newChildElement("membersAssociated");
|
||||
}
|
||||
if (hasFormerMembers(organization)
|
||||
&& isDisplayMembers()) {
|
||||
element.newChildElement("membersFormer");
|
||||
}
|
||||
}
|
||||
if (config.getOrganizationProjectsAllInOne()) {
|
||||
if (hasProjects(organization)
|
||||
&& displayProjects) {
|
||||
element.newChildElement("projects");
|
||||
}
|
||||
} else {
|
||||
if (hasOngoingProjects(organization)
|
||||
&& displayProjects) {
|
||||
element.newChildElement("projectsOngoing");
|
||||
}
|
||||
if (hasFinishedProjects(organization)
|
||||
&& displayProjects) {
|
||||
element.newChildElement("projectsFinished");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void generateDataXml(SciOrganization organization,
|
||||
Element element,
|
||||
PageState state) {
|
||||
String show = getShowParam(state);
|
||||
|
||||
if (SHOW_DESCRIPTION.equals(show)) {
|
||||
String desc;
|
||||
desc = organization.getOrganizationDescription();
|
||||
|
||||
Element description = element.newChildElement("description");
|
||||
description.setText(desc);
|
||||
} else if (SHOW_CONTACTS.equals(show)) {
|
||||
generateContactsXML(organization, element, state);
|
||||
} else if (SHOW_DEPARTMENTS.equals(show)) {
|
||||
generateDepartmentsXML(organization, element, state);
|
||||
} else if (SHOW_MEMBERS.equals(show)) {
|
||||
generateMembersXML(organization, element, state,
|
||||
new LinkedList<String>());
|
||||
} else if (SHOW_MEMBERS_ACTIVE.equals(show)) {
|
||||
generateMembersXML(organization, element, state,
|
||||
getFiltersForActiveMembers());
|
||||
} else if (SHOW_MEMBERS_ASSOCIATED.equals(show)) {
|
||||
generateMembersXML(organization, element, state,
|
||||
getFiltersForAssociatedMembers());
|
||||
} else if (SHOW_MEMBERS_FORMER.equals(show)) {
|
||||
generateMembersXML(organization, element, state,
|
||||
getFiltersForFormerMembers());
|
||||
} else if (SHOW_PROJECTS.equals(show)) {
|
||||
generateProjectsXML(organization, element, state,
|
||||
new LinkedList<String>());
|
||||
} else if (SHOW_PROJECTS_ONGOING.equals(show)) {
|
||||
generateProjectsXML(
|
||||
organization, element, state, getFiltersForOngoingProjects());
|
||||
} else if (SHOW_PROJECTS_FINISHED.equals(show)) {
|
||||
generateProjectsXML(
|
||||
organization, element, state,
|
||||
getFiltersForFinishedProjects());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateXML(ContentItem item,
|
||||
Element element,
|
||||
PageState state) {
|
||||
Element content = generateBaseXML(item, element, state);
|
||||
|
||||
Element availableData = content.newChildElement("availableData");
|
||||
|
||||
SciOrganization orga = (SciOrganization) item;
|
||||
Element availableData = element.newChildElement("availableData");
|
||||
|
||||
SciOrganizationConfig config;
|
||||
config = SciOrganization.getConfig();
|
||||
generateAvailableDataXml(orga, availableData, state);
|
||||
|
||||
if ((orga.getOrganizationDescription() != null)
|
||||
&& !(orga.getOrganizationDescription().isEmpty())
|
||||
&& displayDescription) {
|
||||
availableData.newChildElement("description");
|
||||
}
|
||||
if (orga.hasContacts()
|
||||
&& isDisplayContacts()) {
|
||||
availableData.newChildElement("contacts");
|
||||
}
|
||||
if (orga.hasDepartments()
|
||||
&& displayDepartments) {
|
||||
availableData.newChildElement("departments");
|
||||
}
|
||||
if (config.getOrganizationMembersAllInOne()) {
|
||||
if (hasMembers(orga)
|
||||
&& isDisplayMembers()) {
|
||||
availableData.newChildElement("members");
|
||||
}
|
||||
} else {
|
||||
if (hasActiveMembers(orga)
|
||||
&& isDisplayMembers()) {
|
||||
availableData.newChildElement("membersActive");
|
||||
}
|
||||
if (hasAssociatedMembers(orga)
|
||||
&& isDisplayMembers()) {
|
||||
availableData.newChildElement("membersAssociated");
|
||||
}
|
||||
if (hasFormerMembers(orga)
|
||||
&& isDisplayMembers()) {
|
||||
availableData.newChildElement("membersFormer");
|
||||
}
|
||||
}
|
||||
if (config.getOrganizationProjectsAllInOne()) {
|
||||
if (hasProjects(orga)
|
||||
&& displayProjects) {
|
||||
availableData.newChildElement("projects");
|
||||
}
|
||||
} else {
|
||||
if (hasOngoingProjects(orga)
|
||||
&& displayProjects) {
|
||||
availableData.newChildElement("projectsOngoing");
|
||||
}
|
||||
if (hasFinishedProjects(orga)
|
||||
&& displayProjects) {
|
||||
availableData.newChildElement("projectsFinished");
|
||||
}
|
||||
}
|
||||
if (orga.hasPublications()
|
||||
&& displayPublications) {
|
||||
availableData.newChildElement("publications");
|
||||
}
|
||||
|
||||
String show = getShowParam(state);
|
||||
|
||||
if (SHOW_DESCRIPTION.equals(show)) {
|
||||
String desc;
|
||||
desc = orga.getOrganizationDescription();
|
||||
|
||||
Element description = content.newChildElement("description");
|
||||
description.setText(desc);
|
||||
} else if (SHOW_CONTACTS.equals(show)) {
|
||||
generateContactsXML(orga, content, state);
|
||||
} else if (SHOW_DEPARTMENTS.equals(show)) {
|
||||
generateDepartmentsXML(orga, content, state);
|
||||
} else if (SHOW_MEMBERS.equals(show)) {
|
||||
generateMembersXML(orga, content, state, new LinkedList<String>());
|
||||
} else if (SHOW_MEMBERS_ACTIVE.equals(show)) {
|
||||
generateMembersXML(orga, content, state,
|
||||
getFiltersForActiveMembers());
|
||||
} else if (SHOW_MEMBERS_ASSOCIATED.equals(show)) {
|
||||
generateMembersXML(orga, content, state,
|
||||
getFiltersForAssociatedMembers());
|
||||
} else if (SHOW_MEMBERS_FORMER.equals(show)) {
|
||||
generateMembersXML(orga, content, state,
|
||||
getFiltersForFormerMembers());
|
||||
} else if (SHOW_PROJECTS.equals(show)) {
|
||||
generateProjectsXML(orga, content, state, new LinkedList<String>());
|
||||
} else if (SHOW_PROJECTS_ONGOING.equals(show)) {
|
||||
generateProjectsXML(
|
||||
orga, content, state, getFiltersForOngoingProjects());
|
||||
} else if (SHOW_PROJECTS_FINISHED.equals(show)) {
|
||||
generateProjectsXML(
|
||||
orga, content, state, getFiltersForFinishedProjects());
|
||||
} else if (SHOW_PUBLICATIONS.equals(show)) {
|
||||
generatePublicationsXML(
|
||||
RelatedLink.getRelatedLinks(item,
|
||||
"SciOrganizationPublications"),
|
||||
content,
|
||||
state);
|
||||
}
|
||||
generateDataXml(orga, content, state);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,12 +21,10 @@ package com.arsdigita.cms.contenttypes.ui;
|
|||
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.contentassets.RelatedLink;
|
||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitPersonCollection;
|
||||
import com.arsdigita.cms.contenttypes.SciOrganizationConfig;
|
||||
import com.arsdigita.cms.contenttypes.SciProject;
|
||||
import com.arsdigita.cms.contenttypes.SciProjectSubProjectsCollection;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.xml.Element;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
|
@ -42,8 +40,7 @@ public class SciProjectPanel extends SciOrganizationBasePanel {
|
|||
public static final String SHOW_DESCRIPTION = "description";
|
||||
public static final String SHOW_SUBPROJECTS = "subprojects";
|
||||
public static final String SHOW_SUBPROJECTS_ONGOING = "subprojectsOngoing";
|
||||
public static final String SHOW_SUBPROJECTS_FINISHED = "subprojectsFinished";
|
||||
public static final String SHOW_PUBLICATIONS = "publications";
|
||||
public static final String SHOW_SUBPROJECTS_FINISHED = "subprojectsFinished";
|
||||
private boolean displayDescription = true;
|
||||
private boolean displaySubProjects = true;
|
||||
private boolean displayPublications = true;
|
||||
|
|
@ -65,15 +62,7 @@ public class SciProjectPanel extends SciOrganizationBasePanel {
|
|||
public void setDisplayDescription(boolean displayDescription) {
|
||||
this.displayDescription = displayDescription;
|
||||
}
|
||||
|
||||
public boolean isDisplayPublications() {
|
||||
return displayPublications;
|
||||
}
|
||||
|
||||
public void setDisplayPublications(boolean displayPublications) {
|
||||
this.displayPublications = displayPublications;
|
||||
}
|
||||
|
||||
|
||||
public boolean isDisplaySubProjects() {
|
||||
return displaySubProjects;
|
||||
}
|
||||
|
|
@ -200,6 +189,74 @@ public class SciProjectPanel extends SciOrganizationBasePanel {
|
|||
generateMembersListXML(members, parent, state);
|
||||
}
|
||||
|
||||
protected void generateAvailableDataXml(final SciProject project,
|
||||
final Element element,
|
||||
final PageState state) {
|
||||
|
||||
SciOrganizationConfig config = SciProject.getConfig();
|
||||
|
||||
if ((project.getProjectDescription() != null)
|
||||
&& !project.getProjectDescription().isEmpty()
|
||||
&& displayDescription) {
|
||||
element.newChildElement("description");
|
||||
}
|
||||
if (project.hasContacts()
|
||||
&& isDisplayContacts()) {
|
||||
element.newChildElement("contacts");
|
||||
}
|
||||
if (hasSubProjects(project)
|
||||
&& displaySubProjects) {
|
||||
element.newChildElement("subProjects");
|
||||
}
|
||||
if (config.getProjectMembersAllInOne()) {
|
||||
if (hasMembers(project)
|
||||
&& isDisplayMembers()) {
|
||||
element.newChildElement("members");
|
||||
}
|
||||
} else {
|
||||
if (hasActiveMembers(project)
|
||||
&& isDisplayMembers()) {
|
||||
element.newChildElement("activeMembers");
|
||||
}
|
||||
if (hasAssociatedMembers(project)
|
||||
&& isDisplayMembers()) {
|
||||
element.newChildElement("associatedMembers");
|
||||
}
|
||||
if (hasFormerMembers(project)
|
||||
&& isDisplayMembers()) {
|
||||
element.newChildElement("formerMembers");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void generateDataXml(final SciProject project,
|
||||
final Element element,
|
||||
final PageState state) {
|
||||
|
||||
String show = getShowParam(state);
|
||||
|
||||
if (SHOW_DESCRIPTION.equals(show)) {
|
||||
Element description = element.newChildElement("description");
|
||||
description.setText(project.getProjectDescription());
|
||||
|
||||
Element funding = element.newChildElement("funding");
|
||||
funding.setText(project.getFunding());
|
||||
} else if (SHOW_CONTACTS.equals(show)) {
|
||||
generateContactsXML(project, element, state);
|
||||
} else if (SHOW_SUBPROJECTS.equals(show)) {
|
||||
generateSubProjectsXML(project, element, state,
|
||||
new LinkedList<String>());
|
||||
} else if (SHOW_SUBPROJECTS_ONGOING.equals(show)) {
|
||||
generateSubProjectsXML(project, element, state,
|
||||
getFiltersForOngoingProjects());
|
||||
} else if (SHOW_SUBPROJECTS_FINISHED.equals(show)) {
|
||||
generateSubProjectsXML(project, element, state,
|
||||
getFiltersForFinishedProjects());
|
||||
} else if (SHOW_MEMBERS.equals(show)) {
|
||||
generateMembersXML(project, element, state, true, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateXML(ContentItem item,
|
||||
Element element,
|
||||
|
|
@ -210,72 +267,9 @@ public class SciProjectPanel extends SciOrganizationBasePanel {
|
|||
|
||||
SciProject project = (SciProject) item;
|
||||
|
||||
SciOrganizationConfig config = SciProject.getConfig();
|
||||
|
||||
if ((project.getProjectDescription() != null)
|
||||
&& !project.getProjectDescription().isEmpty()
|
||||
&& displayDescription) {
|
||||
availableData.newChildElement("description");
|
||||
}
|
||||
if (project.hasContacts()
|
||||
&& isDisplayContacts()) {
|
||||
availableData.newChildElement("contacts");
|
||||
}
|
||||
if (hasSubProjects(project)
|
||||
&& displaySubProjects) {
|
||||
availableData.newChildElement("subProjects");
|
||||
}
|
||||
if (config.getProjectMembersAllInOne()) {
|
||||
if (hasMembers(project)
|
||||
&& isDisplayMembers()) {
|
||||
availableData.newChildElement("members");
|
||||
}
|
||||
} else {
|
||||
if (hasActiveMembers(project)
|
||||
&& isDisplayMembers()) {
|
||||
availableData.newChildElement("activeMembers");
|
||||
}
|
||||
if (hasAssociatedMembers(project)
|
||||
&& isDisplayMembers()) {
|
||||
availableData.newChildElement("associatedMembers");
|
||||
}
|
||||
if (hasFormerMembers(project)
|
||||
&& isDisplayMembers()) {
|
||||
availableData.newChildElement("formerMembers");
|
||||
}
|
||||
}
|
||||
if (project.hasPublications()
|
||||
&& displayPublications) {
|
||||
availableData.newChildElement("publications");
|
||||
}
|
||||
|
||||
String show = getShowParam(state);
|
||||
|
||||
if (SHOW_DESCRIPTION.equals(show)) {
|
||||
Element description = content.newChildElement("description");
|
||||
description.setText(project.getProjectDescription());
|
||||
|
||||
Element funding = content.newChildElement("funding");
|
||||
funding.setText(project.getFunding());
|
||||
} else if (SHOW_CONTACTS.equals(show)) {
|
||||
generateContactsXML(project, content, state);
|
||||
} else if (SHOW_SUBPROJECTS.equals(show)) {
|
||||
generateSubProjectsXML(project, content, state,
|
||||
new LinkedList<String>());
|
||||
} else if (SHOW_SUBPROJECTS_ONGOING.equals(show)) {
|
||||
generateSubProjectsXML(project, content, state,
|
||||
getFiltersForOngoingProjects());
|
||||
} else if (SHOW_SUBPROJECTS_FINISHED.equals(show)) {
|
||||
generateSubProjectsXML(project, content, state,
|
||||
getFiltersForFinishedProjects());
|
||||
} else if (SHOW_MEMBERS.equals(show)) {
|
||||
generateMembersXML(project, content, state, true, true, true);
|
||||
} else if (SHOW_PUBLICATIONS.equals(show)) {
|
||||
generatePublicationsXML(
|
||||
RelatedLink.getRelatedLinks(item,
|
||||
"SciProjectPublications"),
|
||||
content,
|
||||
state);
|
||||
}
|
||||
generateAvailableDataXml(project, element, state);
|
||||
|
||||
generateDataXml(project, element, state);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue