From 440f8c1b75a5d2dd3b6a39e846fdeb30871b3307 Mon Sep 17 00:00:00 2001 From: jensp Date: Wed, 21 May 2014 13:59:08 +0000 Subject: [PATCH] - Some formatting and JavaDoc for ccm-sci-assets-publicationsabout - First part of the ccm-sci-assets-publicationspersons git-svn-id: https://svn.libreccm.org/ccm/trunk@2638 8810af33-2d31-482b-a856-94f89814c4df --- .../application.xml | 40 ++--- .../contentassets/SciPublicationsAbout.pdl | 1 + .../contentassets/PublicationCollection.java | 3 +- .../contentassets/SciPublicationsAbout.java | 54 +++++- .../SciPublicationsAboutInitializer.java | 4 +- .../SciPublicationsAboutLoader.java | 1 - .../SciPublicationsAboutService.java | 17 +- .../application.xml | 33 ++++ .../contentassets/SciPublicationsPersons.pdl | 60 +++++++ .../oracle-se-create.sql | 2 + .../postgres-create.sql | 4 + .../contentassets/SciPublicationsPersons.xml | 13 ++ .../ccm-sci-assets-publicationspersons.config | 4 + .../ccm-sci-assets-publicationspersons.load | 21 +++ .../contentassets/SciPublicationsPersons.java | 162 ++++++++++++++++++ .../SciPublicationsPersonsInitializer.java | 87 ++++++++++ .../SciPublicationsPersonsLoader.java | 36 ++++ ...ciPublicationsPersonsPersonCollection.java | 55 ++++++ ...licationsPersonsPublicationCollection.java | 55 ++++++ .../SciPublicationsPersonsService.java | 104 +++++++++++ .../ui/PublicationExtraXmlGenerator.java | 2 +- 21 files changed, 726 insertions(+), 32 deletions(-) create mode 100644 ccm-sci-assets-publicationspersons/application.xml create mode 100644 ccm-sci-assets-publicationspersons/pdl/com/arsdigita/cms/contentassets/SciPublicationsPersons.pdl create mode 100644 ccm-sci-assets-publicationspersons/sql/ccm-sci-assets-publicationspersons/oracle-se-create.sql create mode 100644 ccm-sci-assets-publicationspersons/sql/ccm-sci-assets-publicationspersons/postgres-create.sql create mode 100644 ccm-sci-assets-publicationspersons/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contentassets/SciPublicationsPersons.xml create mode 100644 ccm-sci-assets-publicationspersons/src/ccm-sci-assets-publicationspersons.config create mode 100644 ccm-sci-assets-publicationspersons/src/ccm-sci-assets-publicationspersons.load create mode 100644 ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersons.java create mode 100644 ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsInitializer.java create mode 100644 ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsLoader.java create mode 100644 ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsPersonCollection.java create mode 100644 ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsPublicationCollection.java create mode 100644 ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsService.java diff --git a/ccm-sci-assets-publicationsabout/application.xml b/ccm-sci-assets-publicationsabout/application.xml index 41eccba4e..6c906c8cc 100644 --- a/ccm-sci-assets-publicationsabout/application.xml +++ b/ccm-sci-assets-publicationsabout/application.xml @@ -2,29 +2,29 @@ + version="6.6.0" + release="1" + webapp="ROOT"> - - - - - + + + + + - - - - - + + + + + - - - - + + + + - - This assets for the SciPublications allows it to define associatons between a publication and one or more other publications which are discussed by the publication. - + + This assets for the SciPublications allows it to define associatons between a publication and one or more other publications which are discussed by the publication. + diff --git a/ccm-sci-assets-publicationsabout/pdl/com/arsdigita/cms/contentassets/SciPublicationsAbout.pdl b/ccm-sci-assets-publicationsabout/pdl/com/arsdigita/cms/contentassets/SciPublicationsAbout.pdl index 8151aaa9c..93ae49677 100644 --- a/ccm-sci-assets-publicationsabout/pdl/com/arsdigita/cms/contentassets/SciPublicationsAbout.pdl +++ b/ccm-sci-assets-publicationsabout/pdl/com/arsdigita/cms/contentassets/SciPublicationsAbout.pdl @@ -38,6 +38,7 @@ association { Integer[0..1] publicationsOrder = ca_publications_about.publications_order INTEGER; } +//Helper object to allow efficent filtering object type SciPublicationsAbout extends ACSObject { String[0..1] discusses = ca_publications_about_asset.discusses; diff --git a/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/PublicationCollection.java b/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/PublicationCollection.java index 52a45704f..18074f0f2 100644 --- a/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/PublicationCollection.java +++ b/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/PublicationCollection.java @@ -25,7 +25,8 @@ import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.persistence.DataCollection; /** - * + * A helper collection for use in the classes of the ccm-sci-assets-publicationsabout module. + * * @author Jens Pelzetter * @version $Id$ */ diff --git a/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/SciPublicationsAbout.java b/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/SciPublicationsAbout.java index 9904af47a..804d4e647 100644 --- a/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/SciPublicationsAbout.java +++ b/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/SciPublicationsAbout.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 @@ -25,7 +25,13 @@ import com.arsdigita.kernel.ACSObject; import com.arsdigita.persistence.DataObject; /** - * + * Helper class/asset used to provide an easy and efficient method for filtering publications + * for discussed publications. For this purpose, this asset contains two string properties which + * will contain the concatenated titles of the publications which are discussing the owing + * publications and the concatenated titles of the publications which are discussed by the owing + * publication. This allows it to use a simple substring (LIKE in SQL) to filter a list of + * publications for discussed or discussing publications. + * * @author Jens Pelzetter * @version $Id$ */ @@ -37,19 +43,39 @@ public class SciPublicationsAbout extends ACSObject { public static final String DISCUSSES = "discusses"; public static final String DISCUSSED_BY = "discussedBy"; public static final String OWNER = "owner"; + public static final String PUBLICATIONS_ABOUT = "publicationsAbout"; + /** + * Default constructor for a new item + */ public SciPublicationsAbout() { super(BASE_DATA_OBJECT_TYPE); } + /** + * Constructor which would be called from the parameterless constructor of a subtype. + * + * @param type The base data object type of the new object. + */ public SciPublicationsAbout(final String type) { super(type); } + /** + * Creates a new domain object of this class using the data object provided. + * + * @param dataObject A {@link DataObject} representing an object of this class. + */ public SciPublicationsAbout(final DataObject dataObject) { super(dataObject); } + /** + * Helper method for creating a new asset of this type. + * + * @param owner The owner of the asset + * @return The new asset + */ public static SciPublicationsAbout create(final Publication owner) { final PublicationBundle ownerBundle = owner.getPublicationBundle(); final ItemCollection instances = ownerBundle.getInstances(); @@ -62,24 +88,42 @@ public class SciPublicationsAbout extends ACSObject { return new SciPublicationsAbout((DataObject) owner.get(PUBLICATIONS_ABOUT)); } - public static final String PUBLICATIONS_ABOUT = "publicationsAbout"; - + + /** + * Helper method for {@link #create(com.arsdigita.cms.contenttypes.Publication)}. + * + * @param instance + */ private static void createForInstance(final Publication instance) { final SciPublicationsAbout about = new SciPublicationsAbout(); - about.set("owner", instance); + about.set(OWNER, instance); about.update(); about.save(); } + /** + * + * @return The discussed publications string. + */ public String getDiscussedPublications() { return (String) get(DISCUSSES); } + /** + * + * + * @return The discussing publications string. + */ public String getDiscussingPublications() { return (String) get(DISCUSSED_BY); } + /** + * This method is invoked by the {@link SciPublicationsAboutService} class when a discussing or + * discussed publication is added or removed to update the string properties. + * + */ protected void update() { final Publication owner = new Publication((DataObject) get(OWNER)); 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 a512ac758..012087a1a 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 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 @@ -103,7 +103,7 @@ public class SciPublicationsAboutInitializer extends CompoundInitializer { "com.arsdigita.cms.contentassets.SciPublicationsAboutResources"), 40); - PublicationExtraXmlGenerator.addExteningGenerator(new SciPublicationsAboutExtraXMLGenerator()); + PublicationExtraXmlGenerator.addExtentingGenerator(new SciPublicationsAboutExtraXMLGenerator()); } } diff --git a/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/SciPublicationsAboutLoader.java b/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/SciPublicationsAboutLoader.java index 3be8a1b2a..c447aec1b 100644 --- a/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/SciPublicationsAboutLoader.java +++ b/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/SciPublicationsAboutLoader.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2014 Jens Pelzetter * diff --git a/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/SciPublicationsAboutService.java b/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/SciPublicationsAboutService.java index b93905b36..0368b5fec 100644 --- a/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/SciPublicationsAboutService.java +++ b/ccm-sci-assets-publicationsabout/src/com/arsdigita/cms/contentassets/SciPublicationsAboutService.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 @@ -24,7 +24,7 @@ import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataObject; /** - * This class provides some convenient methods for dealing with the About asset/mixin. + * This class provides some convenient methods for dealing with the About asset/mixin. * * @author Jens Pelzetter * @version $Id$ @@ -92,6 +92,13 @@ public class SciPublicationsAboutService { final PublicationBundle discussedBundle = discussed.getPublicationBundle(); discussingBundle.remove(DISCUSSING, discussedBundle); + final DataObject discussingAboutDobj = (DataObject) discussing.get(PUBLICATIONS_ABOUT); + final SciPublicationsAbout discussingAbout = new SciPublicationsAbout(discussingAboutDobj); + discussingAbout.update(); + final DataObject discussedAboutDobj = (DataObject) discussed.get(PUBLICATIONS_ABOUT); + final SciPublicationsAbout discussedAbout = new SciPublicationsAbout(discussedAboutDobj); + discussedAbout.update(); + } /** @@ -123,6 +130,12 @@ public class SciPublicationsAboutService { final PublicationBundle discussingBundle = discussing.getPublicationBundle(); discussedBundle.remove(DISCUSSED_BY, discussingBundle); + final DataObject discussingAboutDobj = (DataObject) discussing.get(PUBLICATIONS_ABOUT); + final SciPublicationsAbout discussingAbout = new SciPublicationsAbout(discussingAboutDobj); + discussingAbout.update(); + final DataObject discussedAboutDobj = (DataObject) discussed.get(PUBLICATIONS_ABOUT); + final SciPublicationsAbout discussedAbout = new SciPublicationsAbout(discussedAboutDobj); + discussedAbout.update(); } } diff --git a/ccm-sci-assets-publicationspersons/application.xml b/ccm-sci-assets-publicationspersons/application.xml new file mode 100644 index 000000000..af238676f --- /dev/null +++ b/ccm-sci-assets-publicationspersons/application.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + This assets for the SciPublications allows it to define associatons between a publication + and one or more other persons. This asset is not intented as a replacement for the author + field. This assets allows it to define associations to other persons, real or fictional, + which are related to the publication. Examples are interviewed persons, main characters etc. + + + 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 new file mode 100644 index 000000000..712ba2d12 --- /dev/null +++ b/ccm-sci-assets-publicationspersons/pdl/com/arsdigita/cms/contentassets/SciPublicationsPersons.pdl @@ -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 +// +// + +model com.arsdigita.cms.contentassets; + +import com.arsdigita.cms.contenttypes.GenericPersonBundle; +import com.arsdigita.cms.contenttypes.PublicationBundle; +import com.arsdigita.kernel.ACSObject; +import com.arsdigita.cms.ContentItem; + +association { + + PublicationBundle[0..n] publications = join cms_person_bundles.bundle_id + to ca_publications_persons.person_id, + join ca_publications_persons.publication_id + to ct_publication_bundles.bundle_id; + + + GenericPersonBundle[0..n] persons = join ct_publication_bundles.bundle_id + to ca_publications_persons.publication_id, + join ca_publications_persons.person_id + to cms_person_bundles.bundle_id; + + String[0..1] relation = ca_publications_persons.relation; + +} + +object type SciPublicationsPersons extends ACSObject { + + String[0..1] publications = ca_publications_persons_asset.publications; + String[0..1] persons = ca_publications_persons_asset.persons; + + reference key ( ca_publications_persons_asset.asset_id ); + +} + +association { + + composite ContentItem[1..1] owner = join ca_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 diff --git a/ccm-sci-assets-publicationspersons/sql/ccm-sci-assets-publicationspersons/oracle-se-create.sql b/ccm-sci-assets-publicationspersons/sql/ccm-sci-assets-publicationspersons/oracle-se-create.sql new file mode 100644 index 000000000..1dcc59ed8 --- /dev/null +++ b/ccm-sci-assets-publicationspersons/sql/ccm-sci-assets-publicationspersons/oracle-se-create.sql @@ -0,0 +1,2 @@ +@@ ddl/oracle-se/create.sql +@@ ddl/oracle-se/deferred.sql diff --git a/ccm-sci-assets-publicationspersons/sql/ccm-sci-assets-publicationspersons/postgres-create.sql b/ccm-sci-assets-publicationspersons/sql/ccm-sci-assets-publicationspersons/postgres-create.sql new file mode 100644 index 000000000..614b9c240 --- /dev/null +++ b/ccm-sci-assets-publicationspersons/sql/ccm-sci-assets-publicationspersons/postgres-create.sql @@ -0,0 +1,4 @@ +begin; +\i ddl/postgres/create.sql +\i ddl/postgres/deferred.sql +commit; diff --git a/ccm-sci-assets-publicationspersons/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contentassets/SciPublicationsPersons.xml b/ccm-sci-assets-publicationspersons/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contentassets/SciPublicationsPersons.xml new file mode 100644 index 000000000..cf59391c6 --- /dev/null +++ b/ccm-sci-assets-publicationspersons/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contentassets/SciPublicationsPersons.xml @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/ccm-sci-assets-publicationspersons/src/ccm-sci-assets-publicationspersons.config b/ccm-sci-assets-publicationspersons/src/ccm-sci-assets-publicationspersons.config new file mode 100644 index 000000000..87ab51a7b --- /dev/null +++ b/ccm-sci-assets-publicationspersons/src/ccm-sci-assets-publicationspersons.config @@ -0,0 +1,4 @@ + + + + diff --git a/ccm-sci-assets-publicationspersons/src/ccm-sci-assets-publicationspersons.load b/ccm-sci-assets-publicationspersons/src/ccm-sci-assets-publicationspersons.load new file mode 100644 index 000000000..86c86309c --- /dev/null +++ b/ccm-sci-assets-publicationspersons/src/ccm-sci-assets-publicationspersons.load @@ -0,0 +1,21 @@ + + + +
+
+
+ + + + + + +
+ + + + + + + + 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 new file mode 100644 index 000000000..a64daaffa --- /dev/null +++ b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersons.java @@ -0,0 +1,162 @@ +/* + * 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 new file mode 100644 index 000000000..33b359688 --- /dev/null +++ b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsInitializer.java @@ -0,0 +1,87 @@ +/* + * 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.contenttypes.ContentItemTraversalAdapter; +import com.arsdigita.db.DbHelper; +import com.arsdigita.domain.DomainObjectTraversalAdapter; +import com.arsdigita.domain.xml.TraversalHandler; +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 + * @version $Id$ + */ +public class SciPublicationsPersonsInitializer extends CompoundInitializer { + + public SciPublicationsPersonsInitializer() { + final String url = RuntimeConfig.getConfig().getJDBCURL(); + final int database = DbHelper.getDatabaseFromURL(url); + + add(new PDLInitializer(new ManifestSource( + "ccm-sci-assets-publicationspersons.pdl.mf", + new NameFilter(DbHelper.getDatabaseSuffix(database), "pdl")))); + } + + @Override + public void init(final DomainInitEvent event) { + + super.init(event); + +// DomainObjectFactory.registerInstantiator( +// SciPublicationsPersons.BASE_DATA_OBJECT_TYPE, +// new DomainObjectInstantiator() { +// +// @Override +// protected DomainObject doNewInstance( +// final DataObject dataObject) { +// return new SciPublicationsPersons( +// dataObject); +// } +// +// }); + + final String traversal = "/WEB-INF/traversal-adapters/com/arsdigita/cms/contentassets/" + + "SciPublicationsPersons.xml"; + XML.parseResource(traversal, new TraversalHandler() { + + @Override + protected void registerAdapter(final String objectType, + final DomainObjectTraversalAdapter adapter, + final String context) { + ContentItemTraversalAdapter.registerAssetAdapter("publications", adapter, context); + ContentItemTraversalAdapter.registerAssetAdapter("persons", adapter, context); + } + + }); + + //ToDo Add authoring steps + + //ToDo Add extra xml generator + + } + +} diff --git a/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsLoader.java b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsLoader.java new file mode 100644 index 000000000..840117919 --- /dev/null +++ b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsLoader.java @@ -0,0 +1,36 @@ +/* + * 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.loader.PackageLoader; +import com.arsdigita.runtime.ScriptContext; + +/** + * + * @author Jens Pelzetter + * @version $Id$ + */ +public class SciPublicationsPersonsLoader extends PackageLoader { + + @Override + public void run(final ScriptContext ctx) { + //Nothing + } + +} 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 new file mode 100644 index 000000000..4456c48a7 --- /dev/null +++ b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsPersonCollection.java @@ -0,0 +1,55 @@ +/*; + * 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.ContentBundle; +import com.arsdigita.cms.contenttypes.GenericPerson; +import com.arsdigita.domain.DomainCollection; +import com.arsdigita.domain.DomainObjectFactory; +import com.arsdigita.persistence.DataCollection; + +/** + * + * @author Jens Pelzetter + * @version $Id$ + */ +public class SciPublicationsPersonsPersonCollection extends DomainCollection { + + public SciPublicationsPersonsPersonCollection(final DataCollection dataCollection) { + super(dataCollection); + + m_dataCollection.addOrder("name"); + } + + public GenericPerson getPerson() { + final ContentBundle bundle = (ContentBundle) DomainObjectFactory.newInstance( + m_dataCollection.getDataObject()); + + return (GenericPerson) bundle.getPrimaryInstance(); + } + + public GenericPerson getPublication(final String language) { + final ContentBundle bundle = (ContentBundle) DomainObjectFactory.newInstance( + m_dataCollection.getDataObject() + ); + + return (GenericPerson) bundle.getInstance(language); + } + +} diff --git a/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsPublicationCollection.java b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsPublicationCollection.java new file mode 100644 index 000000000..215a4d4ce --- /dev/null +++ b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsPublicationCollection.java @@ -0,0 +1,55 @@ +/*; + * 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.ContentBundle; +import com.arsdigita.cms.contenttypes.Publication; +import com.arsdigita.domain.DomainCollection; +import com.arsdigita.domain.DomainObjectFactory; +import com.arsdigita.persistence.DataCollection; + +/** + * + * @author Jens Pelzetter + * @version $Id$ + */ +public class SciPublicationsPersonsPublicationCollection extends DomainCollection { + + public SciPublicationsPersonsPublicationCollection(final DataCollection dataCollection) { + super(dataCollection); + + m_dataCollection.addOrder("name"); + } + + public Publication getPublication() { + final ContentBundle bundle = (ContentBundle) DomainObjectFactory.newInstance( + m_dataCollection.getDataObject()); + + return (Publication) bundle.getPrimaryInstance(); + } + + public Publication getPublication(final String language) { + final ContentBundle bundle = (ContentBundle) DomainObjectFactory.newInstance( + m_dataCollection.getDataObject() + ); + + return (Publication) bundle.getInstance(language); + } + +} 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 new file mode 100644 index 000000000..08c4e3356 --- /dev/null +++ b/ccm-sci-assets-publicationspersons/src/com/arsdigita/cms/contentassets/SciPublicationsPersonsService.java @@ -0,0 +1,104 @@ +/* + * 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.contenttypes.GenericPerson; +import com.arsdigita.cms.contenttypes.GenericPersonBundle; +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. + * + * @author Jens Pelzetter + * @version $Id$ + */ +public class SciPublicationsPersonsService { + + public static final String PERSONS = "persons"; + public static final String PUBLICATIONS = "publications"; + public static final String RELATION = "relation"; + private static final String PUBLICATIONS_PERSONS = "publicationsPersons"; + + public SciPublicationsPersonsPublicationCollection getPublications(final GenericPerson person) { + + final GenericPersonBundle bundle = person.getGenericPersonBundle(); + + final DataCollection dataCollection = (DataCollection) bundle.get(PUBLICATIONS); + + return new SciPublicationsPersonsPublicationCollection(dataCollection); + } + + public void addPublication(final GenericPerson person, + final Publication publication, + final String relation) { + + final GenericPersonBundle personBundle = person.getGenericPersonBundle(); + final PublicationBundle publicationBundle = publication.getPublicationBundle(); + + final DataObject link = personBundle.add(PUBLICATIONS, publicationBundle); + link.set(RELATION, relation); + link.save(); + + final DataObject asset1 = (DataObject) publication.get(PUBLICATIONS_PERSONS); + if (asset1 == null) { + SciPublicationsPersons.create(publication); + } else { + final SciPublicationsPersons persons = new SciPublicationsPersons(asset1); + persons.update(); + } + + final DataObject asset2 = (DataObject) person.get(PUBLICATIONS_PERSONS); + if (asset2 == null) { + SciPublicationsPersons.create(person); + } else { + final SciPublicationsPersons persons = new SciPublicationsPersons(asset2); + persons.update(); + } + } + + public void removePublication(final GenericPerson person, + final Publication publication) { + final GenericPersonBundle personBundle = person.getGenericPersonBundle(); + 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(); + + } + + public SciPublicationsPersonsPersonCollection getPersons(final Publication publication) { + + final PublicationBundle bundle = publication.getPublicationBundle(); + + final DataCollection dataCollection = (DataCollection) bundle.get(PERSONS); + + return new SciPublicationsPersonsPersonCollection(dataCollection); + } + + +} 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 5b93cd4e8..3d9ae28dc 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 addExteningGenerator(final ExtraXMLGenerator generator) { + public static void addExtentingGenerator(final ExtraXMLGenerator generator) { EXTENDING_GENERATORS.add(generator); }