diff --git a/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/SciPublicationsAboutInitializer.java b/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/SciPublicationsAboutInitializer.java index 012087a1a..ef5f99b18 100644 --- a/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/SciPublicationsAboutInitializer.java +++ b/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/SciPublicationsAboutInitializer.java @@ -103,7 +103,7 @@ public class SciPublicationsAboutInitializer extends CompoundInitializer { "com.arsdigita.cms.contentassets.SciPublicationsAboutResources"), 40); - PublicationExtraXmlGenerator.addExtentingGenerator(new SciPublicationsAboutExtraXMLGenerator()); + PublicationExtraXmlGenerator.addExtendingGenerator(new SciPublicationsAboutExtraXMLGenerator()); } } diff --git a/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/ui/SciPublicationsAboutDiscussesTable.java b/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/ui/SciPublicationsAboutDiscussesTable.java index f04b703a2..2ea2f9168 100644 --- a/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/ui/SciPublicationsAboutDiscussesTable.java +++ b/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/ui/SciPublicationsAboutDiscussesTable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Jens Pelzetter + * Copyright (c) 2014 Jens Pelzetter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License diff --git a/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/ui/SciPublicationsAboutExtraXMLGenerator.java b/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/ui/SciPublicationsAboutExtraXMLGenerator.java index 1452c8cee..6d2b12a5e 100644 --- a/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/ui/SciPublicationsAboutExtraXMLGenerator.java +++ b/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/ui/SciPublicationsAboutExtraXMLGenerator.java @@ -42,6 +42,7 @@ public class SciPublicationsAboutExtraXMLGenerator implements ExtraXMLGenerator final Element element, final PageState state) { if (listMode) { + //In list mode we don't need th information provided by this ExtraXMLGenerator return; } diff --git a/ccm-sci-assets-publicationspersons/pdl/com/arsdigita/cms/contentassets/SciPublicationsPersons.pdl b/ccm-sci-assets-publicationspersons/pdl/com/arsdigita/cms/contentassets/SciPublicationsPersons.pdl index 712ba2d12..99f9c1d18 100644 --- a/ccm-sci-assets-publicationspersons/pdl/com/arsdigita/cms/contentassets/SciPublicationsPersons.pdl +++ b/ccm-sci-assets-publicationspersons/pdl/com/arsdigita/cms/contentassets/SciPublicationsPersons.pdl @@ -41,20 +41,36 @@ association { } -object type SciPublicationsPersons extends ACSObject { +object type SciPublicationsPersonsPublicationsPersons extends ACSObject { - String[0..1] publications = ca_publications_persons_asset.publications; - String[0..1] persons = ca_publications_persons_asset.persons; + String[0..1] persons = ca_publications_persons_publications_persons_asset.persons; - reference key ( ca_publications_persons_asset.asset_id ); + reference key ( ca_publications_persons_publications_persons_asset.asset_id ); } association { - composite ContentItem[1..1] owner = join ca_publications_persons_asset.owner_id + composite ContentItem[1..1] owner = join ca_publications_persons_publications_persons_asset.owner_id to cms_items.item_id; - component SciPublicationsPersons[0..1] publicationsPersons = join cms_items.item_id - to ca_publications_persons_asset.owner_id; -} \ No newline at end of file + component SciPublicationsPersonsPublicationsPersons[0..1] publicationsPersons = join cms_items.item_id + to ca_publications_persons_publications_persons_asset.owner_id; +} + +object type SciPublicationsPersonsPersonsPublications extends ACSObject { + + String[0..1] publications = ca_publications_persons_persons_publications_asset.publications; + + reference key(ca_publications_persons_persons_publications_asset.asset_id); +} + +association { + + composite ContentItem[1..1] owner = join ca_publications_persons_persons_publications_asset.owner_id + to cms_items.item_id; + + component SciPublicationsPersonsPersonsPublications[0..1] personsPublications = join cms_items.item_id + to ca_publications_persons_persons_publications_asset.owner_id; +} + diff --git a/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersons.java b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersons.java deleted file mode 100644 index a64daaffa..000000000 --- a/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersons.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2014 Jens Pelzetter - * - * 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.ContentItem; -import com.arsdigita.cms.ItemCollection; -import com.arsdigita.cms.contenttypes.GenericPerson; -import com.arsdigita.cms.contenttypes.GenericPersonBundle; -import com.arsdigita.cms.contenttypes.Publication; -import com.arsdigita.cms.contenttypes.PublicationBundle; -import com.arsdigita.domain.DomainObjectFactory; -import com.arsdigita.kernel.ACSObject; -import com.arsdigita.persistence.DataObject; - -/** - * Helper class for easy and efficient filtering - * - * @author Jens Pelzetter - * @version $Id$ - */ -public class SciPublicationsPersons extends ACSObject { - - public static final String BASE_DATA_OBJECT_TYPE - = "com.arsdigita.cms.contentassets.SciPublicationsPersons"; - - public static final String PUBLICATIONS = "publications"; - public static final String PUBLICATIONS_PERSONS = "publicationsPersons"; - public static final String PERSONS = "persons"; - public static final String OWNER = "owner"; - - public SciPublicationsPersons() { - super(BASE_DATA_OBJECT_TYPE); - } - - public SciPublicationsPersons(final String type) { - super(type); - } - - public SciPublicationsPersons(final DataObject dataObject) { - super(dataObject); - } - - public static SciPublicationsPersons create(final Publication owner) { - final PublicationBundle bundle = owner.getPublicationBundle(); - final ItemCollection instances = bundle.getInstances(); - - Publication instance; - while (instances.next()) { - instance = (Publication) instances.getContentItem(); - createForInstance(instance); - } - - return new SciPublicationsPersons((DataObject) owner.get(PUBLICATIONS_PERSONS)); - } - - private static void createForInstance(final Publication instance) { - final SciPublicationsPersons persons = new SciPublicationsPersons(); - persons.set(OWNER, instance); - persons.update(); - - persons.save(); - } - - public static SciPublicationsPersons create(final GenericPerson owner) { - final GenericPersonBundle bundle = owner.getGenericPersonBundle(); - final ItemCollection instances = bundle.getInstances(); - - GenericPerson instance; - while (instances.next()) { - instance = (GenericPerson) instances.getContentItem(); - createForInstance(instance); - } - - return new SciPublicationsPersons((DataObject) owner.get(PUBLICATIONS_PERSONS)); - } - - private static void createForInstance(final GenericPerson instance) { - final SciPublicationsPersons persons = new SciPublicationsPersons(); - persons.set(OWNER, instance); - persons.update(); - - persons.save(); - } - - public String getPersons() { - return (String) get(PERSONS); - } - - public String getPublications() { - return (String) get(PUBLICATIONS); - } - - protected void update() { - - final ContentItem owner = (ContentItem) DomainObjectFactory.newInstance((DataObject) get( - OWNER)); - final SciPublicationsPersonsService service = new SciPublicationsPersonsService(); - - - if (owner instanceof Publication) { - - final SciPublicationsPersonsPersonCollection persons = service.getPersons( - (Publication) owner); - final StringBuilder builder = new StringBuilder(); - while (persons.next()) { - builder.append(persons.getPerson().getTitle()); - builder.append(';'); - } - - final PublicationBundle bundle = ((Publication) owner).getPublicationBundle(); - final ItemCollection instances = bundle.getInstances(); - Publication instance; - SciPublicationsPersons asset; - while (instances.next()) { - instance = (Publication) instances.getContentItem(); - asset = new SciPublicationsPersons((DataObject) instance.get(PUBLICATIONS_PERSONS)); - - asset.set(PERSONS, builder.toString()); - } - - } else if (owner instanceof GenericPerson) { - - final SciPublicationsPersonsPublicationCollection publications = service - .getPublications((GenericPerson) owner); - final StringBuilder builder = new StringBuilder(); - while(publications.next()) { - builder.append(publications.getPublication().getTitle()); - builder.append(';'); - } - - final GenericPersonBundle bundle = ((GenericPerson) owner).getGenericPersonBundle(); - final ItemCollection instances = bundle.getInstances(); - GenericPerson instance; - SciPublicationsPersons asset; - while(instances.next()) { - instance = (GenericPerson) instances.getContentItem(); - asset = new SciPublicationsPersons((DataObject) instance.get(PUBLICATIONS_PERSONS)); - - asset.set(PUBLICATIONS, builder.toString()); - } - - } - - } - -} diff --git a/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsInitializer.java b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsInitializer.java index 33b359688..2bf456cf4 100644 --- a/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsInitializer.java +++ b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsInitializer.java @@ -18,10 +18,20 @@ */ package com.arsdigita.cms.contentassets; +import com.arsdigita.cms.contentassets.ui.SciPublicationsPersonsExtraXMLGenerator; +import com.arsdigita.cms.contentassets.ui.SciPublicationsPersonsGlobalisationUtil; +import com.arsdigita.cms.contentassets.ui.SciPublicationsPersonsStep; import com.arsdigita.cms.contenttypes.ContentItemTraversalAdapter; +import com.arsdigita.cms.contenttypes.Publication; +import com.arsdigita.cms.contenttypes.ui.PublicationExtraXmlGenerator; +import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; import com.arsdigita.db.DbHelper; +import com.arsdigita.domain.DomainObject; +import com.arsdigita.domain.DomainObjectFactory; +import com.arsdigita.domain.DomainObjectInstantiator; import com.arsdigita.domain.DomainObjectTraversalAdapter; import com.arsdigita.domain.xml.TraversalHandler; +import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.pdl.ManifestSource; import com.arsdigita.persistence.pdl.NameFilter; import com.arsdigita.runtime.CompoundInitializer; @@ -51,21 +61,34 @@ public class SciPublicationsPersonsInitializer extends CompoundInitializer { super.init(event); -// DomainObjectFactory.registerInstantiator( -// SciPublicationsPersons.BASE_DATA_OBJECT_TYPE, -// new DomainObjectInstantiator() { -// -// @Override -// protected DomainObject doNewInstance( -// final DataObject dataObject) { -// return new SciPublicationsPersons( -// dataObject); -// } -// -// }); + DomainObjectFactory.registerInstantiator( + SciPublicationsPersonsPublicationsPersons.BASE_DATA_OBJECT_TYPE, + new DomainObjectInstantiator() { + + @Override + protected DomainObject doNewInstance( + final DataObject dataObject) { + return new SciPublicationsPersonsPublicationsPersons( + dataObject); + } + + }); + + DomainObjectFactory.registerInstantiator( + SciPublicationsPersonsPersonsPublications.BASE_DATA_OBJECT_TYPE, + new DomainObjectInstantiator() { + + @Override + protected DomainObject doNewInstance( + final DataObject dataObject) { + return new SciPublicationsPersonsPersonsPublications( + dataObject); + } + + }); final String traversal = "/WEB-INF/traversal-adapters/com/arsdigita/cms/contentassets/" - + "SciPublicationsPersons.xml"; + + "SciPublicationsPersons.xml"; XML.parseResource(traversal, new TraversalHandler() { @Override @@ -77,11 +100,20 @@ public class SciPublicationsPersonsInitializer extends CompoundInitializer { } }); - - //ToDo Add authoring steps - - //ToDo Add extra xml generator - + + final SciPublicationsPersonsGlobalisationUtil globalisationUtil + = new SciPublicationsPersonsGlobalisationUtil(); + AuthoringKitWizard.registerAssetStep( + Publication.BASE_DATA_OBJECT_TYPE, + SciPublicationsPersonsStep.class, + globalisationUtil.globalise( + "com.arsdigita.cms.contentassets.publications_persons.related_persons.title"), + globalisationUtil.globalise( + "com.arsdigita.cms.contentassets.publications_persons.related_persons.desc"), + 50); + + PublicationExtraXmlGenerator.addExtendingGenerator( + new SciPublicationsPersonsExtraXMLGenerator()); } } diff --git a/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsPersonCollection.java b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsPersonCollection.java index 4456c48a7..89bfa1374 100644 --- a/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsPersonCollection.java +++ b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsPersonCollection.java @@ -23,6 +23,7 @@ import com.arsdigita.cms.contenttypes.GenericPerson; import com.arsdigita.domain.DomainCollection; import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.persistence.DataCollection; +import com.arsdigita.persistence.DataObject; /** * @@ -44,12 +45,22 @@ public class SciPublicationsPersonsPersonCollection extends DomainCollection { return (GenericPerson) bundle.getPrimaryInstance(); } - public GenericPerson getPublication(final String language) { + public GenericPerson getPerson(final String language) { final ContentBundle bundle = (ContentBundle) DomainObjectFactory.newInstance( m_dataCollection.getDataObject() ); return (GenericPerson) bundle.getInstance(language); } + + public String getRelation() { + return (String) m_dataCollection.get("link.relation"); + } + + public void setRelation(final String relation) { + DataObject link = (DataObject) this.get("link"); + + link.set("relation", relation); + } } diff --git a/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsPersonsPublications.java b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsPersonsPublications.java new file mode 100644 index 000000000..b7bb63899 --- /dev/null +++ b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsPersonsPublications.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2014 Jens Pelzetter + * + * 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.ItemCollection; +import com.arsdigita.cms.contenttypes.GenericPerson; +import com.arsdigita.cms.contenttypes.GenericPersonBundle; +import com.arsdigita.domain.DomainObjectFactory; +import com.arsdigita.kernel.ACSObject; +import com.arsdigita.persistence.DataObject; + +/** + * + * @author Jens Pelzetter + * @version $Id$ + */ +public class SciPublicationsPersonsPersonsPublications extends ACSObject { + + public static final String BASE_DATA_OBJECT_TYPE + = "com.arsdigita.cms.contentassets.SciPublicationsPersonsPersonsPublications"; + + public static final String PUBLICATIONS = "publications"; + public static final String PERSONS_PUBLICATIONS = "personsPublications"; + public static final String OWNER = "owner"; + + public SciPublicationsPersonsPersonsPublications() { + super(BASE_DATA_OBJECT_TYPE); + } + + public SciPublicationsPersonsPersonsPublications(final String type) { + super(type); + } + + public SciPublicationsPersonsPersonsPublications(final DataObject dataObject) { + super(dataObject); + } + + public static SciPublicationsPersonsPersonsPublications create(final GenericPerson owner) { + final GenericPersonBundle bundle = owner.getGenericPersonBundle(); + final ItemCollection instances = bundle.getInstances(); + + GenericPerson instance; + while (instances.next()) { + instance = (GenericPerson) instances.getContentItem(); + createForInstance(instance); + } + + return new SciPublicationsPersonsPersonsPublications((DataObject) owner.get( + PERSONS_PUBLICATIONS)); + } + + private static void createForInstance(final GenericPerson instance) { + + final SciPublicationsPersonsPersonsPublications publications + = new SciPublicationsPersonsPersonsPublications(); + publications.set(OWNER, instance); + publications.update(); + + publications.save(); + } + + public String getPublications() { + return (String) get(PUBLICATIONS); + } + + protected void update() { + + final GenericPerson owner = (GenericPerson) DomainObjectFactory .newInstance((DataObject) get(OWNER)); + final SciPublicationsPersonsService service = new SciPublicationsPersonsService(); + + final SciPublicationsPersonsPublicationCollection publications = service.getPublications( + owner); + final StringBuilder builder = new StringBuilder(); + while(publications.next()) { + builder.append(publications.getPublication().getTitle()); + builder.append(';'); + } + + final GenericPersonBundle bundle = owner.getGenericPersonBundle(); + final ItemCollection instances = bundle.getInstances(); + GenericPerson instance; + SciPublicationsPersonsPersonsPublications asset; + while(instances.next()) { + instance = (GenericPerson) instances.getContentItem(); + asset = new SciPublicationsPersonsPersonsPublications((DataObject) instance.get(PERSONS_PUBLICATIONS)); + + asset.set(PUBLICATIONS, builder.toString()); + asset.save(); + } + + } + +} diff --git a/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsPublicationsPersons.java b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsPublicationsPersons.java new file mode 100644 index 000000000..68e6c01e0 --- /dev/null +++ b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsPublicationsPersons.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2014 Jens Pelzetter + * + * 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.ItemCollection; +import com.arsdigita.cms.contenttypes.Publication; +import com.arsdigita.cms.contenttypes.PublicationBundle; +import com.arsdigita.domain.DomainObjectFactory; +import com.arsdigita.kernel.ACSObject; +import com.arsdigita.persistence.DataObject; + +/** + * Helper class for easy and efficient filtering + * + * @author Jens Pelzetter + * @version $Id$ + */ +public class SciPublicationsPersonsPublicationsPersons extends ACSObject { + + public static final String BASE_DATA_OBJECT_TYPE + = "com.arsdigita.cms.contentassets.SciPublicationsPersonsPublicationsPersons"; + + public static final String PUBLICATIONS_PERSONS = "publicationsPersons"; + public static final String PERSONS = "persons"; + public static final String OWNER = "owner"; + + public SciPublicationsPersonsPublicationsPersons() { + super(BASE_DATA_OBJECT_TYPE); + } + + public SciPublicationsPersonsPublicationsPersons(final String type) { + super(type); + } + + public SciPublicationsPersonsPublicationsPersons(final DataObject dataObject) { + super(dataObject); + } + + public static SciPublicationsPersonsPublicationsPersons create(final Publication owner) { + final PublicationBundle bundle = owner.getPublicationBundle(); + final ItemCollection instances = bundle.getInstances(); + + Publication instance; + while (instances.next()) { + instance = (Publication) instances.getContentItem(); + createForInstance(instance); + } + + return new SciPublicationsPersonsPublicationsPersons((DataObject) owner.get( + PUBLICATIONS_PERSONS)); + } + + private static void createForInstance(final Publication instance) { + final SciPublicationsPersonsPublicationsPersons persons + = new SciPublicationsPersonsPublicationsPersons(); + persons.set(OWNER, instance); + persons.update(); + + persons.save(); + } + + public String getPersons() { + return (String) get(PERSONS); + } + + protected void update() { + + final Publication owner = (Publication) DomainObjectFactory.newInstance((DataObject) get( + OWNER)); + final SciPublicationsPersonsService service = new SciPublicationsPersonsService(); + + final SciPublicationsPersonsPersonCollection persons = service.getPersons( + (Publication) owner); + final StringBuilder builder = new StringBuilder(); + while (persons.next()) { + builder.append(persons.getPerson().getTitle()); + builder.append(';'); + } + + final PublicationBundle bundle = ((Publication) owner).getPublicationBundle(); + final ItemCollection instances = bundle.getInstances(); + Publication instance; + SciPublicationsPersonsPublicationsPersons asset; + while (instances.next()) { + instance = (Publication) instances.getContentItem(); + asset = new SciPublicationsPersonsPublicationsPersons((DataObject) instance.get( + PUBLICATIONS_PERSONS)); + + asset.set(PERSONS, builder.toString()); + } + + } + +} + + diff --git a/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsResource.properties b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsResource.properties new file mode 100644 index 000000000..a15c45f8c --- /dev/null +++ b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsResource.properties @@ -0,0 +1,13 @@ + +com.arsdigita.cms.contentassets.publications_persons.related_persons.title=Related persons +com.arsdigita.cms.contentassets.publications_persons.related_persons.desc=Step for relating persons with a publication +com.arsdigita.cms.contentassets.publicationspersons.select_person=Select person +com.arsdigita.cms.contentassets.publicationspersons.select_person_relation=Relation +com.arsdigita.cms.contentasset.publications_persons.none_selected=No person selected +com.arsdigita.cms.contentasset.publications_persons.none_relation_selected=No relation definied +com.arsdigita.cms.contentassets.publication_persons.person.remove=Remove person +com.arsdigita.cms.contentassets.publications_persons.persons.none=No related persons found +com.arsdigita.cms.contentassets.publications_persons.person=Person +com.arsdigita.cms.contentassets.publications_persons.person.relation=Relation +com.arsdigita.cms.contentassets.publications_persons.person.remove=Remove +com.arsdigita.cms.contentassets.publications_persons.person.remove.confirm=Are you sure to remove the relation to the selected person? diff --git a/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsResource_de.properties b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsResource_de.properties new file mode 100644 index 000000000..379c7ee58 --- /dev/null +++ b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsResource_de.properties @@ -0,0 +1,13 @@ + +com.arsdigita.cms.contentassets.publications_persons.related_persons.title=Personen +com.arsdigita.cms.contentassets.publications_persons.related_persons.desc=Hier k\u00f6nnen Beziehungen zwischen einer Publikation und Personen definiert werden +com.arsdigita.cms.contentassets.publicationspersons.select_person=Person ausw\u00e4hlen +com.arsdigita.cms.contentassets.publicationspersons.select_person_relation=Beziehung +com.arsdigita.cms.contentasset.publications_persons.none_selected=Keine Person ausgew\u00e4hlt +com.arsdigita.cms.contentasset.publications_persons.none_relation_selected=Keine Beziehung definiert +com.arsdigita.cms.contentassets.publication_persons.person.remove=Person entfernen +com.arsdigita.cms.contentassets.publications_persons.persons.none=Keine Beziehung mit Personen vorhanden +com.arsdigita.cms.contentassets.publications_persons.person=Person +com.arsdigita.cms.contentassets.publications_persons.person.relation=Beziehung +com.arsdigita.cms.contentassets.publications_persons.person.remove=Entfernen +com.arsdigita.cms.contentassets.publications_persons.person.remove.confirm=Sie sie sicher das Sie die Beziehung mit der ausgew\u00e4hlten Person l\u00f6schen wollen? diff --git a/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsService.java b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsService.java index 08c4e3356..e4258f08d 100644 --- a/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsService.java +++ b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsService.java @@ -24,7 +24,6 @@ import com.arsdigita.cms.contenttypes.Publication; import com.arsdigita.cms.contenttypes.PublicationBundle; import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataObject; -import com.redhat.persistence.metadata.Link; /** * This class provides some convenient methods for dealing woth the Persons asset/mixin. @@ -38,6 +37,7 @@ public class SciPublicationsPersonsService { public static final String PUBLICATIONS = "publications"; public static final String RELATION = "relation"; private static final String PUBLICATIONS_PERSONS = "publicationsPersons"; + private static final String PERSONS_PUBLICATIONS = "personsPublications"; public SciPublicationsPersonsPublicationCollection getPublications(final GenericPerson person) { @@ -59,20 +59,20 @@ public class SciPublicationsPersonsService { link.set(RELATION, relation); link.save(); - final DataObject asset1 = (DataObject) publication.get(PUBLICATIONS_PERSONS); - if (asset1 == null) { - SciPublicationsPersons.create(publication); + final DataObject personsAsset = (DataObject) publication.get(PUBLICATIONS_PERSONS); + if (personsAsset == null) { + SciPublicationsPersonsPublicationsPersons.create(publication); } else { - final SciPublicationsPersons persons = new SciPublicationsPersons(asset1); + final SciPublicationsPersonsPublicationsPersons persons = new SciPublicationsPersonsPublicationsPersons(personsAsset); persons.update(); } - final DataObject asset2 = (DataObject) person.get(PUBLICATIONS_PERSONS); - if (asset2 == null) { - SciPublicationsPersons.create(person); + final DataObject publicationsAsset = (DataObject) person.get(PERSONS_PUBLICATIONS); + if (publicationsAsset == null) { + SciPublicationsPersonsPersonsPublications.create(person); } else { - final SciPublicationsPersons persons = new SciPublicationsPersons(asset2); - persons.update(); + final SciPublicationsPersonsPublicationsPersons publications = new SciPublicationsPersonsPublicationsPersons(publicationsAsset); + publications.update(); } } @@ -82,12 +82,12 @@ public class SciPublicationsPersonsService { final PublicationBundle publicationBundle = publication.getPublicationBundle(); personBundle.remove(PUBLICATIONS, publicationBundle); - final DataObject dobj1 = (DataObject) person.get(PUBLICATIONS_PERSONS); - final SciPublicationsPersons persons1 = new SciPublicationsPersons(dobj1); - persons1.update(); - final DataObject dobj2 = (DataObject) publication.get(PUBLICATIONS_PERSONS); - final SciPublicationsPersons persons2 = new SciPublicationsPersons(dobj2); - persons2.update(); + final DataObject personsAsset = (DataObject) person.get(PUBLICATIONS_PERSONS); + final SciPublicationsPersonsPublicationsPersons persons = new SciPublicationsPersonsPublicationsPersons(personsAsset); + persons.update(); + final DataObject publicationsAsset = (DataObject) publication.get(PERSONS_PUBLICATIONS); + final SciPublicationsPersonsPersonsPublications publications = new SciPublicationsPersonsPersonsPublications(publicationsAsset); + publications.update(); } diff --git a/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/ui/SciPublicationsPersonsExtraXMLGenerator.java b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/ui/SciPublicationsPersonsExtraXMLGenerator.java new file mode 100644 index 000000000..50def4d2d --- /dev/null +++ b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/ui/SciPublicationsPersonsExtraXMLGenerator.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2014 Jens Pelzetter + * + * 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.Page; +import com.arsdigita.bebop.PageState; +import com.arsdigita.cms.ContentItem; +import com.arsdigita.cms.ExtraXMLGenerator; +import com.arsdigita.cms.contentassets.SciPublicationsPersonsPersonCollection; +import com.arsdigita.cms.contentassets.SciPublicationsPersonsService; +import com.arsdigita.cms.contenttypes.GenericPerson; +import com.arsdigita.cms.contenttypes.Publication; +import com.arsdigita.cms.dispatcher.SimpleXMLGenerator; +import com.arsdigita.xml.Element; + +/** + * + * @author Jens Pelzetter + * @version $Id$ + */ +public class SciPublicationsPersonsExtraXMLGenerator implements ExtraXMLGenerator { + + private boolean listMode; + + @Override + public void generateXML(final ContentItem item, + final Element element, + final PageState state) { + + if (listMode) { + //In list mode we don't need th information provided by this ExtraXMLGenerator + return; + } + + if (!(item instanceof Publication)) { + throw new IllegalArgumentException(String.format( + "ExtraXMLGenerator '%s' only supports items of type '%s'.", + getClass().getName(), + Publication.class.getName())); + } + + final Publication publication = (Publication) item; + final SciPublicationsPersonsService service = new SciPublicationsPersonsService(); + final SciPublicationsPersonsPersonCollection persons = service.getPersons(publication); + if ((persons != null) && !persons.isEmpty()) { + final Element personsElem = element.newChildElement("persons"); + + while (persons.next()) { + addPerson(personsElem, persons.getPerson(), persons.getRelation(), state); + } + } + + } + + private void addPerson(final Element parent, + final GenericPerson person, + final String relation, + final PageState state) { + + final XmlGenerator generator = new XmlGenerator(person); + generator.setItemElemName("person", ""); + generator.addItemAttribute("relation", relation); + generator.setListMode(true); + generator.generateXML(state, parent, ""); + + } + + @Override + public void addGlobalStateParams(final Page page) { + //Nothing + } + + @Override + public void setListMode(final boolean listMode) { + this.listMode = listMode; + } + + private class XmlGenerator extends SimpleXMLGenerator { + + private final ContentItem item; + + public XmlGenerator(final ContentItem item) { + super(); + this.item = item; + } + + @Override + protected ContentItem getContentItem(final PageState state) { + return item; + } + + } + +} diff --git a/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/ui/SciPublicationsPersonsGlobalisationUtil.java b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/ui/SciPublicationsPersonsGlobalisationUtil.java new file mode 100644 index 000000000..b6550cc71 --- /dev/null +++ b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/ui/SciPublicationsPersonsGlobalisationUtil.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2014 Jens Pelzetter + * + * 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.toolbox.GlobalisationUtil; + +/** + * + * @author Jens Pelzetter + * @version $Id$ + */ +public class SciPublicationsPersonsGlobalisationUtil extends GlobalisationUtil { + + public SciPublicationsPersonsGlobalisationUtil() { + super("com.arsdigita.cms.contentassets.SciPublicationsPersonsResources"); + } + +} diff --git a/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/ui/SciPublicationsPersonsPersonForm.java b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/ui/SciPublicationsPersonsPersonForm.java new file mode 100644 index 000000000..f0b76fea2 --- /dev/null +++ b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/ui/SciPublicationsPersonsPersonForm.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2014 Jens Pelzetter + * + * 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.FormSectionEvent; +import com.arsdigita.bebop.form.Option; +import com.arsdigita.bebop.form.SingleSelect; +import com.arsdigita.bebop.parameters.NotNullValidationListener; +import com.arsdigita.bebop.parameters.ParameterModel; +import com.arsdigita.bebop.parameters.StringParameter; +import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.RelationAttribute; +import com.arsdigita.cms.RelationAttributeCollection; +import com.arsdigita.cms.contentassets.SciPublicationsPersonsService; +import com.arsdigita.cms.contenttypes.GenericPerson; +import com.arsdigita.cms.contenttypes.Publication; +import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil; +import com.arsdigita.cms.ui.ItemSearchWidget; +import com.arsdigita.cms.ui.authoring.BasicItemForm; +import com.arsdigita.globalization.GlobalizationHelper; +import com.arsdigita.toolbox.GlobalisationUtil; + +/** + * + * @author Jens Pelzetter + * @version $Id$ + */ +public class SciPublicationsPersonsPersonForm extends BasicItemForm { + + private ItemSearchWidget itemSearch; + private final static String ITEM_SEARCH = "publicationRelatedPersons"; + private final static String RELATION = "relation"; + private final ItemSelectionModel itemModel; + private final GlobalisationUtil globalisationUtil + = new SciPublicationsPersonsGlobalisationUtil(); + + public SciPublicationsPersonsPersonForm(final ItemSelectionModel itemModel) { + + super("SciPublicationsPersonsPersonForm", itemModel); + this.itemModel = itemModel; + + } + + @Override + public void addWidgets() { + + add(new Label(globalisationUtil.globalise( + "com.arsdigita.cms.contentassets.publicationspersons.select_person"))); + itemSearch = new ItemSearchWidget( + ITEM_SEARCH, + ContentType.findByAssociatedObjectType(GenericPerson.class.getName())); + itemSearch.setDisableCreatePane(true); + add(itemSearch); + + add(new Label(globalisationUtil.globalise( + "com.arsdigita.cms.contentassets.publicationspersons.select_person_relation"))); + final ParameterModel relationParam = new StringParameter(RELATION); + final SingleSelect relationSelect = new SingleSelect(relationParam); + relationSelect.addValidationListener(new NotNullValidationListener()); + relationSelect.addOption(new Option("", new Label(ContenttypesGlobalizationUtil.globalize( + "cms.ui.select_one")))); + final RelationAttributeCollection relations = new RelationAttributeCollection( + "publications_persons_relations"); + relations.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().getLanguage()); + while (relations.next()) { + RelationAttribute relation; + relation = relations.getRelationAttribute(); + relationSelect.addOption(new Option(relation.getKey(), relation.getName())); + } + add(relationSelect); + } + + @Override + public void init(final FormSectionEvent event) throws FormProcessException { + + setVisible(event.getPageState(), true); + } + + @Override + public void process(final FormSectionEvent event) throws FormProcessException { + + final FormData data = event.getFormData(); + final PageState state = event.getPageState(); + final Publication publication = (Publication) itemModel.getSelectedObject(state); + final SciPublicationsPersonsService service = new SciPublicationsPersonsService(); + + if (!getSaveCancelSection().getCancelButton().isSelected(state)) { + final GenericPerson person = (GenericPerson) data.get(ITEM_SEARCH); + service.addPublication(person, publication, (String) data.get(RELATION)); + } + + } + + @Override + public void validate(final FormSectionEvent event) throws FormProcessException { + + final FormData data = event.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError(globalisationUtil.globalise( + "com.arsdigita.cms.contentasset.publications_persons.none_selected")); + } + + if ((data.get(RELATION) == null) || ((String) data.get(RELATION)).isEmpty()) { + data.addError(globalisationUtil.globalise( + "com.arsdigita.cms.contentasset.publications_persons.none_relation_selected")); + } + + } + +} diff --git a/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/ui/SciPublicationsPersonsPersonTable.java b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/ui/SciPublicationsPersonsPersonTable.java new file mode 100644 index 000000000..ab2f27658 --- /dev/null +++ b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/ui/SciPublicationsPersonsPersonTable.java @@ -0,0 +1,289 @@ +/* + * Copyright (c) 2014 Jens Pelzetter + * + * 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.SciPublicationsPersonsPersonCollection; +import com.arsdigita.cms.contentassets.SciPublicationsPersonsService; +import com.arsdigita.cms.contenttypes.GenericPerson; +import com.arsdigita.cms.contenttypes.Publication; +import com.arsdigita.cms.dispatcher.ItemResolver; +import com.arsdigita.domain.DataObjectNotFoundException; +import com.arsdigita.globalization.GlobalizedMessage; +import com.arsdigita.util.LockableImpl; +import java.math.BigDecimal; + +/** + * + * @author Jens Pelzetter + * @version $Id$ + */ +public class SciPublicationsPersonsPersonTable extends Table implements TableActionListener { + + private static final String TABLE_COL_DEL = "table_col_del"; + private final ItemSelectionModel itemModel; + private final SciPublicationsPersonsGlobalisationUtil globalisationUtil + = new SciPublicationsPersonsGlobalisationUtil(); + + public SciPublicationsPersonsPersonTable(final ItemSelectionModel itemModel) { + + super(); + + this.itemModel = itemModel; + + setEmptyView(new Label(globalisationUtil.globalise( + "com.arsdigita.cms.contentassets.publications_persons.persons.none"))); + + final TableColumnModel colModel = getColumnModel(); + colModel.add(new TableColumn( + 0, + globalisationUtil.globalise( + "com.arsdigita.cms.contentassets.publications_persons.person"))); + colModel.add(new TableColumn( + 1, + globalisationUtil.globalise( + "com.arsdigita.cms.contentassets.publications_persons.person.relation"))); + colModel.add(new TableColumn( + 2, + globalisationUtil.globalise( + "com.arsdigita.cms.contentassets.publications_persons.person.remove"), + TABLE_COL_DEL)); + + setModelBuilder(new SciPublicationsPersonsTableModelBuilder(itemModel)); + + colModel.get(0).setCellRenderer(new PersonNameCellRenderer()); + colModel.get(1).setCellRenderer(new PersonRelationCellRenderer()); + colModel.get(2).setCellRenderer(new DeleteCellRenderer()); + + addTableActionListener(this); + + } + + private class SciPublicationsPersonsTableModelBuilder extends LockableImpl + implements TableModelBuilder { + + private final ItemSelectionModel itemModel; + + public SciPublicationsPersonsTableModelBuilder(final ItemSelectionModel itemModel) { + + super(); + this.itemModel = itemModel; + + } + + @Override + public TableModel makeModel(final Table table, final PageState state) { + + table.getRowSelectionModel().clearSelection(state); + final Publication publication = (Publication) itemModel.getSelectedObject(state); + return new SciPublicationsPersonsPersonTableModel(table, publication); + + } + + } + + private class SciPublicationsPersonsPersonTableModel implements TableModel { + + private final Table table; + private final SciPublicationsPersonsPersonCollection persons; + private GenericPerson person; + private String relation; + + public SciPublicationsPersonsPersonTableModel(final Table table, + final Publication publication) { + + this.table = table; + + final SciPublicationsPersonsService service = new SciPublicationsPersonsService(); + persons = service.getPersons(publication); + + } + + @Override + public int getColumnCount() { + return table.getColumnModel().size(); + } + + @Override + public boolean nextRow() { + + boolean ret; + + if ((persons != null) && persons.next()) { + person = persons.getPerson(); + relation = persons.getRelation(); + ret = true; + } else { + ret = false; + } + + return ret; + + } + + @Override + public Object getElementAt(final int columnIndex) { + switch (columnIndex) { + case 0: + return person.getFullName(); + case 1: + return relation; + case 2: + return globalisationUtil.globalise( + "com.arsdigita.cms.contentassets.publication_persons.person.remove"); + default: + return null; + } + } + + @Override + public Object getKeyAt(final int columnIndex) { + return person.getID(); + } + + } + + private class PersonNameCellRenderer extends LockableImpl implements TableCellRenderer { + + @Override + public Component getComponent(final Table table, + final PageState state, + final Object value, + final boolean isSelected, + final Object key, + final int row, + final int column) { + + final com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state); + final Publication publication = (Publication) itemModel.getSelectedObject(state); + + final boolean canEdit = securityManager.canAccess( + state.getRequest(), + "com.arsdigita.cms.SecurityManager.EDIT_ITEM", + publication); + + if (canEdit) { + + final GenericPerson person; + try { + person = new GenericPerson((BigDecimal) key); + } catch (DataObjectNotFoundException ex) { + return new Label(value.toString()); + } + + final ContentSection section = person.getContentSection(); + final ItemResolver resolver = section.getItemResolver(); + final Link link = new Link(value.toString(), + resolver.generateItemURL(state, + person, + section, + person.getVersion())); + return link; + + } else { + return new Label(value.toString()); + } + } + + } + + private class PersonRelationCellRenderer extends LockableImpl implements TableCellRenderer { + + @Override + public Component getComponent(final Table table, + final PageState state, + final Object value, + final boolean isSelected, + final Object key, + final int row, + final int column) { + + return new Label(value.toString()); + + } + + } + + private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer { + + @Override + public Component getComponent(final Table table, + final PageState state, + final Object value, + final boolean isSelected, + final Object key, + final int row, + final int column) { + final com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state); + final Publication publication = (Publication) itemModel.getSelectedObject(state); + + final boolean canEdit = securityManager.canAccess( + state.getRequest(), + com.arsdigita.cms.SecurityManager.DELETE_ITEM, + publication); + + if (canEdit) { + final ControlLink link = new ControlLink(new Label((GlobalizedMessage) value)); + link.setConfirmation(globalisationUtil.globalise( + "com.arsdigita.cms.contentassets.publications_persons.person.remove.confirm")); + return link; + } else { + return new Label(value.toString()); + } + } + + } + + @Override + public void cellSelected(final TableActionEvent event) { + + final PageState state = event.getPageState(); + + final GenericPerson person = new GenericPerson(new BigDecimal(event.getRowKey().toString())); + final Publication publication = (Publication) itemModel.getSelectedObject(state); + final SciPublicationsPersonsService service = new SciPublicationsPersonsService(); + + final TableColumn column = getColumnModel().get(event.getColumn().intValue()); + if (TABLE_COL_DEL.equals(column.getHeaderKey())) { + service.removePublication(person, publication); + } + + } + + @Override + public void headSelected(final TableActionEvent event) { + //Nothing to do + } + +} diff --git a/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/ui/SciPublicationsPersonsStep.java b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/ui/SciPublicationsPersonsStep.java new file mode 100644 index 000000000..1c1cb2c03 --- /dev/null +++ b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/ui/SciPublicationsPersonsStep.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2014 Jens Pelzetter + * + * 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; +import com.arsdigita.toolbox.GlobalisationUtil; + +/** + * + * @author Jens Pelzetter + * @version $Id$ + */ +public class SciPublicationsPersonsStep extends SimpleEditStep { + + protected static final String ADD_PUBLICATION_PERSON = "add_publication_person"; + + public SciPublicationsPersonsStep(final ItemSelectionModel itemModel, + final AuthoringKitWizard parent) { + this(itemModel, parent, null); + } + + public SciPublicationsPersonsStep(final ItemSelectionModel itemModel, + final AuthoringKitWizard parent, + final String prefix) { + + super(itemModel, parent, prefix); + + final GlobalisationUtil globalisationUtil = new SciPublicationsPersonsGlobalisationUtil(); + final BasicItemForm addPersonsSheet = new SciPublicationsPersonsPersonForm(itemModel); + add(ADD_PUBLICATION_PERSON, + globalisationUtil.globalise("com.arsdigita.cms.contentassets.publications_persons.person_add"), + new WorkflowLockedComponentAccess(addPersonsSheet, itemModel), + addPersonsSheet.getSaveCancelSection().getCancelButton()); + + final SciPublicationsPersonsPersonTable personsTable = new SciPublicationsPersonsPersonTable(itemModel); + setDisplayComponent(personsTable); + + } + +} diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationExtraXmlGenerator.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationExtraXmlGenerator.java index 3d9ae28dc..c227e1842 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationExtraXmlGenerator.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationExtraXmlGenerator.java @@ -47,7 +47,7 @@ public class PublicationExtraXmlGenerator implements ExtraXMLGenerator { private final static List EXTENDING_GENERATORS = new ArrayList(); private boolean listMode; - public static void addExtentingGenerator(final ExtraXMLGenerator generator) { + public static void addExtendingGenerator(final ExtraXMLGenerator generator) { EXTENDING_GENERATORS.add(generator); }