Erster Teil des Assets zum Verbinden von Organisationen/Abteilungen/Projekten und Publikationen. Noch nicht getestest, kompiliert wahrscheinlich nicht nicht.

git-svn-id: https://svn.libreccm.org/ccm/trunk@948 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2011-06-01 15:43:57 +00:00
parent 09eeec3a34
commit dfa1d01ea3
19 changed files with 1351 additions and 1 deletions

View File

@ -375,20 +375,27 @@ public class ContentItem extends VersionedACSObject implements CustomCopy {
* @return the base PDL object type for this item. Child classes should * @return the base PDL object type for this item. Child classes should
* override this method to return the correct value * override this method to return the correct value
*/ */
@Override
public String getBaseDataObjectType() { public String getBaseDataObjectType() {
return this.BASE_DATA_OBJECT_TYPE; return this.BASE_DATA_OBJECT_TYPE;
} }
/** /**
* Publicized getter method for use by metadata forms. * Publicized getter method for use by metadata forms.
* @param key
* @return
*/ */
@Override
public Object get(final String key) { public Object get(final String key) {
return super.get(key); return super.get(key);
} }
/** /**
* Public setter method for use by metadata forms. * Public setter method for use by metadata forms.
* @param key
* @param value
*/ */
@Override
public void set(final String key, final Object value) { public void set(final String key, final Object value) {
super.set(key, 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 * For new content items, sets the associated content type if it
* has not been already set. * has not been already set.
*/ */
@Override
protected void beforeSave() { protected void beforeSave() {
m_wasNew = isNew(); m_wasNew = isNew();

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project"
name = "ccm-sci-assets-organizationpublicationlink"
prettyName = "CCM Sci Assets OrganizationPublicationLink"
version="6.6.1"
release="1"
webapp="ROOT">
<ccm:dependencies>
<ccm:requires name="ccm-core" version="6.6.0" relation="ge"/>
<ccm:requires name="ccm-cms" version="6.6.0" relation="ge"/>
<ccm:requires name="ccm-sci-types-organization" version="6.6.0" relation="ge"/>
<ccm:requires name="ccm-sci-publications" version="6.6.0" relation="ge"/>
</ccm:dependencies>
<ccm:directories>
<ccm:directory name="pdl"/>
<ccm:directory name="sql"/>
<ccm:directory name="src"/>
</ccm:directories>
<ccm:contacts>
<ccm:contact uri="http://www.redhat.com/software/rhea" type="website"/>
<ccm:contact uri="mailto:rhea@redhat.com" type="support"/>
</ccm:contacts>
<ccm:description>
Links a publication to a SciOrganization, SciDepartment or SciProject.
</ccm:description>
</ccm:application>

View File

@ -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;
}

View File

@ -0,0 +1,4 @@
begin;
\i ddl/postgres/create.sql
\i ddl/postgres/deferred.sql
end;

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<registry>
<!-- <config class="com.arsdigita.cms.SciOrganizationPublicationsConfig" storage="ccm-sci-assets-sciorganizationpublication/sciorganizationpublication.properties"/> -->
</registry>

View File

@ -0,0 +1,15 @@
<load>
<requires>
<table name="inits"/>
<table name="acs_objects"/>
<table name="cms_items"/>
<initalizer class="com.arsdigita.cms.Initializer"/>
</requires>
<provides>
<initializer class="com.arsdigita.cms.contentassets.SciOrganizationPublicationInitializer"/>
</provides>
<scripts>
<schema directory="ccm-sci-assets-sciorganizationpublication"/>
<data class="com.arsdigita.cms.contentassets.SciOrganizationPublicationLoader"/>
</scripts>
</load>

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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";
}
}

View File

@ -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.
}
}

View File

@ -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);
}
}

View File

@ -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();
}
}

View File

@ -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.
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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.
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}