diff --git a/ccm-cms/src/com/arsdigita/cms/ContentItem.java b/ccm-cms/src/com/arsdigita/cms/ContentItem.java
index 7056a487c..7ea2c5c81 100755
--- a/ccm-cms/src/com/arsdigita/cms/ContentItem.java
+++ b/ccm-cms/src/com/arsdigita/cms/ContentItem.java
@@ -375,20 +375,27 @@ public class ContentItem extends VersionedACSObject implements CustomCopy {
* @return the base PDL object type for this item. Child classes should
* override this method to return the correct value
*/
+ @Override
public String getBaseDataObjectType() {
return this.BASE_DATA_OBJECT_TYPE;
}
/**
* Publicized getter method for use by metadata forms.
+ * @param key
+ * @return
*/
+ @Override
public Object get(final String key) {
return super.get(key);
}
/**
* Public setter method for use by metadata forms.
+ * @param key
+ * @param value
*/
+ @Override
public void set(final String key, final Object value) {
super.set(key, value);
}
@@ -396,7 +403,8 @@ public class ContentItem extends VersionedACSObject implements CustomCopy {
/**
* For new content items, sets the associated content type if it
* has not been already set.
- */
+ */
+ @Override
protected void beforeSave() {
m_wasNew = isNew();
diff --git a/ccm-sci-assets-organizationpublicationlink/application.xml b/ccm-sci-assets-organizationpublicationlink/application.xml
new file mode 100644
index 000000000..813df422d
--- /dev/null
+++ b/ccm-sci-assets-organizationpublicationlink/application.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Links a publication to a SciOrganization, SciDepartment or SciProject.
+
+
\ No newline at end of file
diff --git a/ccm-sci-assets-organizationpublicationlink/pdl/com/arsdigita/cms/contentassets/SciOrganizationPublicationLink.pdl b/ccm-sci-assets-organizationpublicationlink/pdl/com/arsdigita/cms/contentassets/SciOrganizationPublicationLink.pdl
new file mode 100644
index 000000000..c999019d2
--- /dev/null
+++ b/ccm-sci-assets-organizationpublicationlink/pdl/com/arsdigita/cms/contentassets/SciOrganizationPublicationLink.pdl
@@ -0,0 +1,16 @@
+model com.arsdigita.cms.contentassets;
+
+import com.arsdigita.kernel.ACSObject;
+import com.arsdigita.cms.*;
+
+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;
+
+ 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;
+}
\ No newline at end of file
diff --git a/ccm-sci-assets-organizationpublicationlink/sql/ccm-sci-assets-organizationpublicationlink/postgres-create.sql b/ccm-sci-assets-organizationpublicationlink/sql/ccm-sci-assets-organizationpublicationlink/postgres-create.sql
new file mode 100644
index 000000000..38716a0ca
--- /dev/null
+++ b/ccm-sci-assets-organizationpublicationlink/sql/ccm-sci-assets-organizationpublicationlink/postgres-create.sql
@@ -0,0 +1,4 @@
+begin;
+\i ddl/postgres/create.sql
+\i ddl/postgres/deferred.sql
+end;
\ No newline at end of file
diff --git a/ccm-sci-assets-organizationpublicationlink/src/ccm-sci-assets-sciorganizationpublication.conf b/ccm-sci-assets-organizationpublicationlink/src/ccm-sci-assets-sciorganizationpublication.conf
new file mode 100644
index 000000000..ee602705f
--- /dev/null
+++ b/ccm-sci-assets-organizationpublicationlink/src/ccm-sci-assets-sciorganizationpublication.conf
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/ccm-sci-assets-organizationpublicationlink/src/ccm-sci-assets-sciorganizationpublication.load b/ccm-sci-assets-organizationpublicationlink/src/ccm-sci-assets-sciorganizationpublication.load
new file mode 100644
index 000000000..5a7f4020b
--- /dev/null
+++ b/ccm-sci-assets-organizationpublicationlink/src/ccm-sci-assets-sciorganizationpublication.load
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/PublicationSciOrganizationCollection.java b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/PublicationSciOrganizationCollection.java
new file mode 100644
index 000000000..bb534b646
--- /dev/null
+++ b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/PublicationSciOrganizationCollection.java
@@ -0,0 +1,43 @@
+/*
+ * 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.contentassets;
+
+import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
+import com.arsdigita.domain.DomainCollection;
+import com.arsdigita.domain.DomainObjectFactory;
+import com.arsdigita.persistence.DataCollection;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class PublicationSciOrganizationCollection extends DomainCollection {
+
+ public PublicationSciOrganizationCollection(final DataCollection dataCollection) {
+ super(dataCollection);
+
+ m_dataCollection.addOrder("title");
+ }
+
+ public GenericOrganizationalUnit getOrganization() {
+ return (GenericOrganizationalUnit) DomainObjectFactory.newInstance(m_dataCollection.
+ getDataObject());
+ }
+}
diff --git a/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/SciOrganizationPublicationCollection.java b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/SciOrganizationPublicationCollection.java
new file mode 100644
index 000000000..815583fdf
--- /dev/null
+++ b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/SciOrganizationPublicationCollection.java
@@ -0,0 +1,43 @@
+/*
+ * 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.contentassets;
+
+import com.arsdigita.cms.contenttypes.Publication;
+import com.arsdigita.domain.DomainCollection;
+import com.arsdigita.domain.DomainObjectFactory;
+import com.arsdigita.persistence.DataCollection;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class SciOrganizationPublicationCollection extends DomainCollection {
+
+ public SciOrganizationPublicationCollection(final DataCollection dataCollection) {
+ super(dataCollection);
+
+ m_dataCollection.addOrder("title");
+ }
+
+ public Publication getPublication() {
+ return (Publication) DomainObjectFactory.newInstance(m_dataCollection.
+ getDataObject());
+ }
+}
diff --git a/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/SciOrganizationPublicationInitializer.java b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/SciOrganizationPublicationInitializer.java
new file mode 100644
index 000000000..991a10b95
--- /dev/null
+++ b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/SciOrganizationPublicationInitializer.java
@@ -0,0 +1,115 @@
+/*
+ * 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.contentassets;
+
+import com.arsdigita.cms.contentassets.ui.PublicationSciOrganizationStep;
+import com.arsdigita.cms.contentassets.ui.SciOrganizationPublicationStep;
+import com.arsdigita.cms.contenttypes.ContentAssetTraversalHandler;
+import com.arsdigita.cms.contenttypes.Publication;
+import com.arsdigita.cms.contenttypes.SciDepartment;
+import com.arsdigita.cms.contenttypes.SciOrganization;
+import com.arsdigita.cms.contenttypes.SciProject;
+import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
+import com.arsdigita.db.DbHelper;
+import com.arsdigita.globalization.GlobalizedMessage;
+import com.arsdigita.persistence.pdl.ManifestSource;
+import com.arsdigita.persistence.pdl.NameFilter;
+import com.arsdigita.runtime.CompoundInitializer;
+import com.arsdigita.runtime.DomainInitEvent;
+import com.arsdigita.runtime.PDLInitializer;
+import com.arsdigita.runtime.RuntimeConfig;
+import com.arsdigita.xml.XML;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class SciOrganizationPublicationInitializer extends CompoundInitializer {
+
+ public SciOrganizationPublicationInitializer() {
+ final String url = RuntimeConfig.getConfig().getJDBCURL();
+ final int database = DbHelper.getDatabaseFromURL(url);
+
+ add(new PDLInitializer(
+ new ManifestSource(
+ "ccm-sci-assets-sciorganiationpublication.pdl.mf",
+ new NameFilter(DbHelper.getDatabaseSuffix(database), "pdl"))));
+ }
+
+ @Override
+ public void init(DomainInitEvent event) {
+ super.init(event);
+
+ final String traversal = getTraversalXML();
+ XML.parseResource(traversal,
+ new ContentAssetTraversalHandler(getProperty()));
+
+ AuthoringKitWizard.registerAssetStep(
+ 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);
+ AuthoringKitWizard.registerAssetStep(
+ 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);
+ 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"),
+ 1);
+
+ 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"),
+ 1);
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getTraversalXML() {
+ return "/WEB-INF/traversal-adapters/com/arsdigita/"
+ + "cms/contentassets/SciOrganizationPublication.xml";
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getProperty() {
+ return "publications";
+ }
+}
diff --git a/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/SciOrganizationPublicationLoader.java b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/SciOrganizationPublicationLoader.java
new file mode 100644
index 000000000..e1ecce67d
--- /dev/null
+++ b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/SciOrganizationPublicationLoader.java
@@ -0,0 +1,35 @@
+/*
+ * 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.contentassets;
+
+import com.arsdigita.loader.PackageLoader;
+import com.arsdigita.runtime.ScriptContext;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class SciOrganizationPublicationLoader extends PackageLoader {
+
+ public void run(final ScriptContext cts) {
+ //Nothing to do.
+ }
+
+}
diff --git a/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/ui/PublicationSciOrganizationAddForm.java b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/ui/PublicationSciOrganizationAddForm.java
new file mode 100644
index 000000000..2094b4a17
--- /dev/null
+++ b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/ui/PublicationSciOrganizationAddForm.java
@@ -0,0 +1,90 @@
+/*
+ * 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.contentassets.ui;
+
+import com.arsdigita.bebop.FormData;
+import com.arsdigita.bebop.FormProcessException;
+import com.arsdigita.bebop.Label;
+import com.arsdigita.bebop.PageState;
+import com.arsdigita.bebop.event.FormInitListener;
+import com.arsdigita.bebop.event.FormProcessListener;
+import com.arsdigita.bebop.event.FormSectionEvent;
+import com.arsdigita.cms.ContentType;
+import com.arsdigita.cms.ItemSelectionModel;
+import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
+import com.arsdigita.cms.contenttypes.Publication;
+import com.arsdigita.cms.contenttypes.PublicationWithOrganization;
+import com.arsdigita.cms.ui.ItemSearchWidget;
+import com.arsdigita.cms.ui.authoring.BasicItemForm;
+import java.math.BigDecimal;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+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) {
+ 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));
+ 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();
+ PageState state = fse.getPageState();
+ Publication pub = (Publication) getItemSelectionModel().
+ getSelectedObject(state);
+ PublicationWithOrganization publication =
+ new PublicationWithOrganization(
+ pub.getOID());
+
+ if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
+ publication.addOrganization((GenericOrganizationalUnit) data.get(
+ ITEM_SEARCH));
+ }
+
+ init(fse);
+ }
+}
diff --git a/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/ui/PublicationSciOrganizationStep.java b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/ui/PublicationSciOrganizationStep.java
new file mode 100644
index 000000000..9e94ffd02
--- /dev/null
+++ b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/ui/PublicationSciOrganizationStep.java
@@ -0,0 +1,66 @@
+/*
+ * 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.contentassets.ui;
+
+import com.arsdigita.cms.ItemSelectionModel;
+import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
+import com.arsdigita.cms.contenttypes.SciOrganization;
+import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
+import com.arsdigita.cms.ui.authoring.BasicItemForm;
+import com.arsdigita.cms.ui.authoring.SimpleEditStep;
+import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class PublicationSciOrganizationStep extends SimpleEditStep {
+
+ private String ADD_ORGANIZATION_SHEET_NAME = "addOrganization";
+
+ public PublicationSciOrganizationStep(ItemSelectionModel itemModel,
+ AuthoringKitWizard parent) {
+ this(itemModel, parent, null);
+ }
+
+ public PublicationSciOrganizationStep(ItemSelectionModel itemModel,
+ AuthoringKitWizard parent,
+ String prefix) {
+ super(itemModel, parent, prefix);
+
+ BasicItemForm addOrganizationSheet =
+ new PublicationSciOrganizationAddForm(itemModel,
+ getOrganizationClassName());
+ add(ADD_ORGANIZATION_SHEET_NAME,
+ (String) SciOrganizationPublicationGlobalizationUtil.globalize(
+ "sciorganizationpublication.ui.addOrganization").localize(),
+ new WorkflowLockedComponentAccess(addOrganizationSheet, itemModel),
+ addOrganizationSheet.getSaveCancelSection().getCancelButton());
+
+ PublicationSciOrganizationTable organizationTable =
+ new PublicationSciOrganizationTable(
+ itemModel);
+ setDisplayComponent(organizationTable);
+ }
+
+ private String getOrganizationClassName() {
+ return GenericOrganizationalUnit.class.getName();
+ }
+}
diff --git a/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/ui/PublicationSciOrganizationTable.java b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/ui/PublicationSciOrganizationTable.java
new file mode 100644
index 000000000..d6b220044
--- /dev/null
+++ b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/ui/PublicationSciOrganizationTable.java
@@ -0,0 +1,267 @@
+/*
+ * 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.contentassets.ui;
+
+import com.arsdigita.bebop.Component;
+import com.arsdigita.bebop.ControlLink;
+import com.arsdigita.bebop.Label;
+import com.arsdigita.bebop.Link;
+import com.arsdigita.bebop.PageState;
+import com.arsdigita.bebop.Table;
+import com.arsdigita.bebop.event.TableActionEvent;
+import com.arsdigita.bebop.event.TableActionListener;
+import com.arsdigita.bebop.table.TableCellRenderer;
+import com.arsdigita.bebop.table.TableColumn;
+import com.arsdigita.bebop.table.TableColumnModel;
+import com.arsdigita.bebop.table.TableModel;
+import com.arsdigita.bebop.table.TableModelBuilder;
+import com.arsdigita.cms.CMS;
+import com.arsdigita.cms.ContentSection;
+import com.arsdigita.cms.ItemSelectionModel;
+import com.arsdigita.cms.contentassets.PublicationSciOrganizationCollection;
+import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
+import com.arsdigita.cms.contenttypes.Publication;
+import com.arsdigita.cms.contenttypes.PublicationWithOrganization;
+import com.arsdigita.cms.dispatcher.ItemResolver;
+import com.arsdigita.cms.dispatcher.Utilities;
+import com.arsdigita.dispatcher.ObjectNotFoundException;
+import com.arsdigita.util.Assert;
+import com.arsdigita.util.LockableImpl;
+import java.math.BigDecimal;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class PublicationSciOrganizationTable
+ extends Table
+ implements TableActionListener {
+
+ private final String TABLE_COL_EDIT = "table_col_edit";
+ private final String TABLE_COL_DEL = "table_col_del";
+ private ItemSelectionModel itemModel;
+
+ public PublicationSciOrganizationTable(ItemSelectionModel itemModel) {
+ super();
+ this.itemModel = itemModel;
+
+ setEmptyView(new Label(SciOrganizationPublicationGlobalizationUtil.
+ globalize("sciorganizationpublication.ui.organizations.none")));
+
+ TableColumnModel columnModel = getColumnModel();
+ columnModel.add(new TableColumn(
+ 0,
+ SciOrganizationPublicationGlobalizationUtil.globalize(
+ "sciorganizationpublication.ui.organization").localize(),
+ TABLE_COL_EDIT));
+ columnModel.add(new TableColumn(
+ 1,
+ SciOrganizationPublicationGlobalizationUtil.globalize(
+ "sciorganizationpublication.ui.organization.remove").
+ localize(), TABLE_COL_DEL));
+
+ setModelBuilder(new PublicationSciOrganizationTableModelBuilder(
+ itemModel));
+
+ columnModel.get(0).setCellRenderer(new EditCellRenderer());
+ columnModel.get(1).setCellRenderer(new DeleteCellRenderer());
+
+ addTableActionListener(this);
+ }
+
+ private class PublicationSciOrganizationTableModelBuilder
+ extends LockableImpl
+ implements TableModelBuilder {
+
+ private ItemSelectionModel itemModel;
+
+ public PublicationSciOrganizationTableModelBuilder(
+ ItemSelectionModel itemModel) {
+ this.itemModel = itemModel;
+ }
+
+ public TableModel makeModel(Table table, PageState state) {
+ table.getRowSelectionModel().clearSelection(state);
+ Publication publication = (Publication) itemModel.getSelectedObject(
+ state);
+ return new PublicationSciOrganizationTableModel(table,
+ state,
+ publication);
+ }
+ }
+
+ private class PublicationSciOrganizationTableModel
+ implements TableModel {
+
+ private Table table;
+ private PublicationSciOrganizationCollection organizations;
+ private GenericOrganizationalUnit orga;
+
+ public PublicationSciOrganizationTableModel(Table table,
+ PageState state,
+ Publication pub) {
+ PublicationWithOrganization publication;
+ this.table = table;
+ publication = new PublicationWithOrganization(pub.getOID());
+ organizations = publication.getOrganizations();
+ }
+
+ public int getColumnCount() {
+ return table.getColumnModel().size();
+ }
+
+ public boolean nextRow() {
+ boolean ret;
+
+ if ((organizations != null) && organizations.next()) {
+ orga = organizations.getOrganization();
+ ret = true;
+ } else {
+ ret = false;
+ }
+
+ return ret;
+ }
+
+ public Object getElementAt(int columnIndex) {
+ switch (columnIndex) {
+ case 0:
+ return orga.getTitle();
+ case 1:
+ return SciOrganizationPublicationGlobalizationUtil.globalize(
+ "sciorganizationpublication.ui.organization.remove").
+ localize();
+ default:
+ return null;
+ }
+ }
+
+ public Object getKeyAt(int columnIndex) {
+ return orga.getID();
+ }
+ }
+
+ private class EditCellRenderer
+ extends LockableImpl
+ implements TableCellRenderer {
+
+ public Component getComponent(Table table,
+ PageState state,
+ Object value,
+ boolean isSelected,
+ Object key,
+ int row,
+ int column) {
+ com.arsdigita.cms.SecurityManager securityManager = Utilities.
+ getSecurityManager(state);
+ Publication publication = (Publication) itemModel.getSelectedObject(
+ state);
+
+ boolean canEdit = securityManager.canAccess(
+ state.getRequest(),
+ com.arsdigita.cms.SecurityManager.EDIT_ITEM,
+ publication);
+
+ if (canEdit) {
+ GenericOrganizationalUnit orga;
+ try {
+ orga = new GenericOrganizationalUnit((BigDecimal) key);
+ } catch (ObjectNotFoundException ex) {
+ return new Label(value.toString());
+ }
+
+ ContentSection section = CMS.getContext().getContentSection();
+ ItemResolver resolver = section.getItemResolver();
+ Link link =
+ new Link(value.toString(),
+ resolver.generateItemURL(state,
+ orga,
+ section,
+ orga.getVersion()));
+ return link;
+ } else {
+ Label label = new Label(value.toString());
+ return label;
+ }
+ }
+ }
+
+ private class DeleteCellRenderer
+ extends LockableImpl
+ implements TableCellRenderer {
+
+ public Component getComponent(Table table,
+ PageState state,
+ Object value,
+ boolean isSelected,
+ Object key,
+ int row,
+ int column) {
+ com.arsdigita.cms.SecurityManager securityManager = Utilities.
+ getSecurityManager(state);
+ Publication publication = (Publication) itemModel.getSelectedObject(
+ state);
+
+ boolean canEdit = securityManager.canAccess(
+ state.getRequest(),
+ com.arsdigita.cms.SecurityManager.DELETE_ITEM,
+ publication);
+
+ if (canEdit) {
+ ControlLink link = new ControlLink(value.toString());
+ link.setConfirmation((String) SciOrganizationPublicationGlobalizationUtil.
+ globalize(
+ "sciorganizationpublication.ui.organization.confirm.remove").
+ localize());
+ return link;
+ } else {
+ Label label = new Label(value.toString());
+ return label;
+ }
+ }
+ }
+
+ public void cellSelected(TableActionEvent event) {
+ PageState state = event.getPageState();
+
+ GenericOrganizationalUnit orga = new GenericOrganizationalUnit(new BigDecimal(event.getRowKey().toString()));
+
+ Publication pub = (Publication) itemModel.getSelectedObject(
+ state);
+ PublicationWithOrganization publication = new PublicationWithOrganization(
+ pub.getOID());
+
+ PublicationSciOrganizationCollection organizations = publication.getOrganizations();
+
+ TableColumn column = getColumnModel().get(event.getColumn().intValue());
+
+ if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
+
+ } else if(column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
+ Assert.exists(orga, GenericOrganizationalUnit.class);
+
+ publication.removeOrganization(orga);
+ }
+ }
+
+ public void headSelected(TableActionEvent event) {
+ //Nothing to do.
+ }
+}
diff --git a/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/ui/SciOrganizationPublicationAddForm.java b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/ui/SciOrganizationPublicationAddForm.java
new file mode 100644
index 000000000..6da175b05
--- /dev/null
+++ b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/ui/SciOrganizationPublicationAddForm.java
@@ -0,0 +1,87 @@
+/*
+ * 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.contentassets.ui;
+
+import com.arsdigita.bebop.FormData;
+import com.arsdigita.bebop.FormProcessException;
+import com.arsdigita.bebop.Label;
+import com.arsdigita.bebop.PageState;
+import com.arsdigita.bebop.event.FormInitListener;
+import com.arsdigita.bebop.event.FormProcessListener;
+import com.arsdigita.bebop.event.FormSectionEvent;
+import com.arsdigita.cms.ContentType;
+import com.arsdigita.cms.ItemSelectionModel;
+import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
+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;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class SciOrganizationPublicationAddForm
+ extends BasicItemForm
+ implements FormProcessListener,
+ FormInitListener {
+
+ private ItemSearchWidget itemSearch;
+ private final String ITEM_SEARCH = "publications";
+
+ public SciOrganizationPublicationAddForm(ItemSelectionModel itemModel) {
+ super("PublicationsAddForm", itemModel);
+ }
+
+ @Override
+ public void addWidgets() {
+ add(new Label((String) SciOrganizationPublicationGlobalizationUtil.
+ globalize("sciorganization.ui.selectPublication").localize()));
+ itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.
+ findByAssociatedObjectType(Publication.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();
+ PageState state = fse.getPageState();
+ GenericOrganizationalUnit orga =
+ (GenericOrganizationalUnit) getItemSelectionModel().
+ getSelectedObject(state);
+ GenericOrganizationalUnitWithPublications organization;
+ organization = new GenericOrganizationalUnitWithPublications(
+ orga.getOID());
+
+ if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
+ organization.addPublication((Publication) data.get(ITEM_SEARCH));
+ }
+
+ init(fse);
+ }
+}
diff --git a/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/ui/SciOrganizationPublicationGlobalizationUtil.java b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/ui/SciOrganizationPublicationGlobalizationUtil.java
new file mode 100644
index 000000000..57df450f3
--- /dev/null
+++ b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/ui/SciOrganizationPublicationGlobalizationUtil.java
@@ -0,0 +1,40 @@
+/*
+ * 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.contentassets.ui;
+
+import com.arsdigita.globalization.GlobalizedMessage;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class SciOrganizationPublicationGlobalizationUtil {
+
+ public static final String BUNDLE_NAME =
+ "com.arsdigita.cms.contentassets.ui.SciOrganizationPublicationResources";
+
+ public static GlobalizedMessage globalize(String key) {
+ return new GlobalizedMessage(key, BUNDLE_NAME);
+ }
+
+ public static GlobalizedMessage globalize(String key, Object[] args) {
+ return new GlobalizedMessage(key, BUNDLE_NAME, args);
+ }
+}
diff --git a/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/ui/SciOrganizationPublicationStep.java b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/ui/SciOrganizationPublicationStep.java
new file mode 100644
index 000000000..a33288ad7
--- /dev/null
+++ b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/ui/SciOrganizationPublicationStep.java
@@ -0,0 +1,60 @@
+/*
+ * 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.contentassets.ui;
+
+import com.arsdigita.cms.ItemSelectionModel;
+import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
+import com.arsdigita.cms.ui.authoring.BasicItemForm;
+import com.arsdigita.cms.ui.authoring.SimpleEditStep;
+import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class SciOrganizationPublicationStep extends SimpleEditStep {
+
+ private String ADD_PUBLICATION_SHEET_NAME = "addPublication";
+
+ public SciOrganizationPublicationStep(ItemSelectionModel itemModel,
+ AuthoringKitWizard parent) {
+ this(itemModel, parent, null);
+ }
+
+ public SciOrganizationPublicationStep(ItemSelectionModel itemModel,
+ AuthoringKitWizard parent,
+ String prefix) {
+ super(itemModel, parent, prefix);
+
+ BasicItemForm addPublicationSheet =
+ new SciOrganizationPublicationAddForm(itemModel);
+ add(ADD_PUBLICATION_SHEET_NAME,
+ (String) SciOrganizationPublicationGlobalizationUtil.globalize(
+ "sciorganizationpublication.ui.addPublication").localize(),
+ new WorkflowLockedComponentAccess(addPublicationSheet, itemModel),
+ addPublicationSheet.getSaveCancelSection().getCancelButton());
+
+ SciOrganizationPublicationTable publicationTable =
+ new SciOrganizationPublicationTable(
+ itemModel);
+ setDisplayComponent(publicationTable);
+
+ }
+}
diff --git a/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/ui/SciOrganizationPublicationTable.java b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/ui/SciOrganizationPublicationTable.java
new file mode 100644
index 000000000..bf451a0c9
--- /dev/null
+++ b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contentassets/ui/SciOrganizationPublicationTable.java
@@ -0,0 +1,278 @@
+/*
+ * 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.contentassets.ui;
+
+import com.arsdigita.bebop.Component;
+import com.arsdigita.bebop.ControlLink;
+import com.arsdigita.bebop.Label;
+import com.arsdigita.bebop.Link;
+import com.arsdigita.bebop.PageState;
+import com.arsdigita.bebop.Table;
+import com.arsdigita.bebop.event.TableActionEvent;
+import com.arsdigita.bebop.event.TableActionListener;
+import com.arsdigita.bebop.table.TableCellRenderer;
+import com.arsdigita.bebop.table.TableColumn;
+import com.arsdigita.bebop.table.TableColumnModel;
+import com.arsdigita.bebop.table.TableModel;
+import com.arsdigita.bebop.table.TableModelBuilder;
+import com.arsdigita.cms.CMS;
+import com.arsdigita.cms.ContentSection;
+import com.arsdigita.cms.ItemSelectionModel;
+import com.arsdigita.cms.contentassets.SciOrganizationPublicationCollection;
+import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
+import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitWithPublications;
+import com.arsdigita.cms.contenttypes.Publication;
+import com.arsdigita.cms.dispatcher.ItemResolver;
+import com.arsdigita.cms.dispatcher.Utilities;
+import com.arsdigita.dispatcher.ObjectNotFoundException;
+import com.arsdigita.persistence.DataCollection;
+import com.arsdigita.util.Assert;
+import com.arsdigita.util.LockableImpl;
+import java.math.BigDecimal;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class SciOrganizationPublicationTable
+ extends Table
+ implements TableActionListener {
+
+ private final String TABLE_COL_EDIT = "table_col_edit";
+ private final String TABLE_COL_DEL = "table_col_del";
+ private ItemSelectionModel itemModel;
+
+ public SciOrganizationPublicationTable(ItemSelectionModel itemModel) {
+ super();
+ this.itemModel = itemModel;
+
+ setEmptyView(new Label(SciOrganizationPublicationGlobalizationUtil.
+ globalize("sciorganizationpublication.ui.publications.none")));
+
+ TableColumnModel columnModel = getColumnModel();
+ columnModel.add(new TableColumn(
+ 0,
+ SciOrganizationPublicationGlobalizationUtil.globalize(
+ "sciorganizationpublication.ui.publication").localize(),
+ TABLE_COL_EDIT));
+ columnModel.add(new TableColumn(
+ 1,
+ SciOrganizationPublicationGlobalizationUtil.globalize(
+ "sciorganizationpublication.ui.publication.remove").localize(),
+ TABLE_COL_DEL));
+
+ setModelBuilder(
+ new SciOrganizationPublicationTableModelBuilder(itemModel));
+
+ columnModel.get(0).setCellRenderer(new EditCellRenderer());
+ columnModel.get(1).setCellRenderer(new DeleteCellRenderer());
+
+ addTableActionListener(this);
+ }
+
+ private class SciOrganizationPublicationTableModelBuilder
+ extends LockableImpl
+ implements TableModelBuilder {
+
+ private ItemSelectionModel itemModel;
+
+ public SciOrganizationPublicationTableModelBuilder(
+ ItemSelectionModel itemModel) {
+ this.itemModel = itemModel;
+ }
+
+ @Override
+ public TableModel makeModel(Table table, PageState state) {
+ table.getRowSelectionModel().clearSelection(state);
+ GenericOrganizationalUnit orga =
+ (GenericOrganizationalUnit) itemModel.
+ getSelectedObject(state);
+ return new SciOrganizationPublicationTableModel(table, state, orga);
+ }
+ }
+
+ private class SciOrganizationPublicationTableModel
+ implements TableModel {
+
+ private Table table;
+ private SciOrganizationPublicationCollection publications;
+ private Publication publication;
+
+ public SciOrganizationPublicationTableModel(Table table,
+ PageState state,
+ GenericOrganizationalUnit orga) {
+ GenericOrganizationalUnitWithPublications organization;
+ this.table = table;
+ organization = new GenericOrganizationalUnitWithPublications(orga.
+ getOID());
+ publications = organization.getPublications();
+
+ }
+
+ public int getColumnCount() {
+ return table.getColumnModel().size();
+ }
+
+ public boolean nextRow() {
+ boolean ret;
+
+ if ((publications != null) && publications.next()) {
+ publication = publications.getPublication();
+ ret = true;
+ } else {
+ ret = false;
+ }
+
+ return ret;
+ }
+
+ public Object getElementAt(int columnIndex) {
+ switch (columnIndex) {
+ case 0:
+ return publication.getTitle();
+ case 1:
+ return SciOrganizationPublicationGlobalizationUtil.globalize(
+ "sciorganizationpublication.ui.publication.remove").
+ localize();
+ default:
+ return null;
+ }
+ }
+
+ public Object getKeyAt(int columnIndex) {
+ return publication.getID();
+ }
+ }
+
+ private class EditCellRenderer
+ extends LockableImpl
+ implements TableCellRenderer {
+
+ public Component getComponent(Table table,
+ PageState state,
+ Object value,
+ boolean isSelected,
+ Object key,
+ int row,
+ int column) {
+ com.arsdigita.cms.SecurityManager securityManager = Utilities.
+ getSecurityManager(state);
+ GenericOrganizationalUnit orga =
+ (GenericOrganizationalUnit) itemModel.
+ getSelectedObject(state);
+
+ boolean canEdit = securityManager.canAccess(
+ state.getRequest(),
+ com.arsdigita.cms.SecurityManager.EDIT_ITEM,
+ orga);
+
+ if (canEdit) {
+ Publication publication;
+ try {
+ publication = new Publication((BigDecimal) key);
+ } catch (ObjectNotFoundException ex) {
+ return new Label(value.toString());
+ }
+
+ ContentSection section = CMS.getContext().getContentSection();
+ ItemResolver resolver = section.getItemResolver();
+ Link link = new Link(value.toString(),
+ resolver.generateItemURL(state,
+ publication,
+ section,
+ publication.
+ getVersion()));
+
+ return link;
+ } else {
+ Label label = new Label(value.toString());
+ return label;
+ }
+ }
+ }
+
+ private class DeleteCellRenderer
+ extends LockableImpl
+ implements TableCellRenderer {
+
+ public Component getComponent(Table table,
+ PageState state,
+ Object value,
+ boolean isSelected,
+ Object key,
+ int row,
+ int column) {
+ com.arsdigita.cms.SecurityManager securityManager = Utilities.
+ getSecurityManager(state);
+ GenericOrganizationalUnit orga =
+ (GenericOrganizationalUnit) itemModel.
+ getSelectedObject(state);
+
+ boolean canEdit = securityManager.canAccess(
+ state.getRequest(),
+ com.arsdigita.cms.SecurityManager.DELETE_ITEM,
+ orga);
+
+ if (canEdit) {
+ ControlLink link = new ControlLink(value.toString());
+ link.setConfirmation((String) SciOrganizationPublicationGlobalizationUtil.
+ globalize(
+ "sciorganizationpublication.ui.publication.confirm.remove").
+ localize());
+ return link;
+ } else {
+ Label label = new Label(value.toString());
+ return label;
+ }
+ }
+ }
+
+ @Override
+ public void cellSelected(TableActionEvent event) {
+ PageState state = event.getPageState();
+
+ Publication publication =
+ new Publication(new BigDecimal(event.getRowKey().toString()));
+
+ GenericOrganizationalUnit orga = (GenericOrganizationalUnit) itemModel.
+ getSelectedObject(state);
+ GenericOrganizationalUnitWithPublications organization;
+ organization =
+ new GenericOrganizationalUnitWithPublications(orga.getOID());
+
+ SciOrganizationPublicationCollection publications =
+ organization.getPublications();
+
+ TableColumn column = getColumnModel().get(event.getColumn().intValue());
+
+ if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
+ //Nothing to do here
+ } else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
+ Assert.exists(publication, Publication.class);
+
+ organization.removePublication(publication);
+ }
+ }
+
+ @Override
+ public void headSelected(TableActionEvent event) {
+ //Nothing to do.
+ }
+}
diff --git a/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contenttypes/GenericOrganizationalUnitWithPublications.java b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contenttypes/GenericOrganizationalUnitWithPublications.java
new file mode 100644
index 000000000..855167641
--- /dev/null
+++ b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contenttypes/GenericOrganizationalUnitWithPublications.java
@@ -0,0 +1,78 @@
+/*
+ * 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.domain.DataObjectNotFoundException;
+import com.arsdigita.persistence.DataCollection;
+import com.arsdigita.persistence.DataObject;
+import com.arsdigita.persistence.OID;
+import com.arsdigita.util.Assert;
+import java.math.BigDecimal;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class GenericOrganizationalUnitWithPublications extends GenericOrganizationalUnit {
+
+ public static final String PUBLICATIONS = "publications";
+ //public static final String BASE_DATA_OBJECT_TYPE =
+ // "com.arsdigita.cms.contenttypes.GenericOrganizationalUnit";
+
+ private GenericOrganizationalUnitWithPublications() {
+ this(BASE_DATA_OBJECT_TYPE);
+ }
+
+ public GenericOrganizationalUnitWithPublications(BigDecimal id)
+ throws DataObjectNotFoundException {
+ this(new OID(BASE_DATA_OBJECT_TYPE, id));
+ }
+
+ public GenericOrganizationalUnitWithPublications(OID oid)
+ throws DataObjectNotFoundException {
+ super(oid);
+ }
+
+ public GenericOrganizationalUnitWithPublications(DataObject dobj) {
+ super(dobj);
+ }
+
+ private GenericOrganizationalUnitWithPublications(String type) {
+ super(type);
+ }
+
+ public SciOrganizationPublicationCollection getPublications() {
+ return new SciOrganizationPublicationCollection((DataCollection) get(
+ PUBLICATIONS));
+ }
+
+ public void addPublication(Publication publication) {
+ Assert.exists(publication, Publication.class);
+
+ add(PUBLICATIONS, publication);
+ }
+
+ public void removePublication(Publication publication) {
+ Assert.exists(publication, Publication.class);
+
+ remove(PUBLICATIONS, publication);
+ }
+}
diff --git a/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contenttypes/PublicationWithOrganization.java b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contenttypes/PublicationWithOrganization.java
new file mode 100644
index 000000000..d4984ad4d
--- /dev/null
+++ b/ccm-sci-assets-organizationpublicationlink/src/com/arsdigita/cms/contenttypes/PublicationWithOrganization.java
@@ -0,0 +1,75 @@
+/*
+ * 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.PublicationSciOrganizationCollection;
+import com.arsdigita.domain.DataObjectNotFoundException;
+import com.arsdigita.persistence.DataCollection;
+import com.arsdigita.persistence.DataObject;
+import com.arsdigita.persistence.OID;
+import com.arsdigita.util.Assert;
+import java.math.BigDecimal;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class PublicationWithOrganization extends Publication {
+
+ public static final String ORGANIZATIONS = "organizations";
+
+ private PublicationWithOrganization() {
+ this(BASE_DATA_OBJECT_TYPE);
+ }
+
+ public PublicationWithOrganization(BigDecimal id)
+ throws DataObjectNotFoundException {
+ this(new OID(BASE_DATA_OBJECT_TYPE, id));
+ }
+
+ public PublicationWithOrganization(OID oid)
+ throws DataObjectNotFoundException {
+ super(oid);
+ }
+
+ public PublicationWithOrganization(DataObject dobj) {
+ super(dobj);
+ }
+
+ private PublicationWithOrganization(String type) {
+ super(type);
+ }
+
+ public PublicationSciOrganizationCollection getOrganizations() {
+ return new PublicationSciOrganizationCollection((DataCollection) get(ORGANIZATIONS));
+ }
+
+ public void addOrganization(GenericOrganizationalUnit orga) {
+ Assert.exists(orga, GenericOrganizationalUnit.class);
+
+ add(ORGANIZATIONS, orga);
+ }
+
+ public void removeOrganization(GenericOrganizationalUnit orga) {
+ Assert.exists(orga, GenericOrganizationalUnit.class);
+
+ remove(ORGANIZATIONS, orga);
+ }
+}