- 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-94f89814c4dfmaster
parent
18be8f11c6
commit
440f8c1b75
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ 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 <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
|
|
|
|||
|
|
@ -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,6 +25,12 @@ 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 <jens@jp-digital.de>
|
||||
* @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));
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2014 Jens Pelzetter
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0"?>
|
||||
<ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project"
|
||||
name="ccm-sci-assets-publicationspersons"
|
||||
prettyName="ScientificCMS Publications module asset for relatating publications and persons"
|
||||
version="6.6.0"
|
||||
release="1"
|
||||
webapp="ROOT">
|
||||
|
||||
<ccm:dependencies>
|
||||
<ccm:requires name="ccm-core" version="6.6.0" release="ge"/>
|
||||
<ccm:requires name="ccm-cms" version="6.6.0" release="ge"/>
|
||||
<ccm:requires name="ccm-sci-publications" version="6.6.5" 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.scientificcms.org" type="website"/>
|
||||
<ccm:contact uri="mailto:info@scientificcms.org" type="support"/>
|
||||
</ccm:contacts>
|
||||
|
||||
<ccm:description>
|
||||
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.
|
||||
</ccm:description>
|
||||
|
||||
</ccm:application>
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
@@ ddl/oracle-se/create.sql
|
||||
@@ ddl/oracle-se/deferred.sql
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
begin;
|
||||
\i ddl/postgres/create.sql
|
||||
\i ddl/postgres/deferred.sql
|
||||
commit;
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xrd:adapters
|
||||
xmlns:xrd="http://xmlns.redhat.com/schemas/waf/xml-renderer-rules"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://rhea.redhat.com/schemas/waf/xml-renderer-rules xml-renderer-rules.xsd">
|
||||
|
||||
<xrd:context name="com.arsdigita.cms.dispatcher.SimpleXMLGenerator">
|
||||
<xrd:adapter objectType="com.arsdigita.cms.contentassets.SciPublicationsPersons">
|
||||
|
||||
</xrd:adapter>
|
||||
</xrd:context>
|
||||
|
||||
</xrd:adapters>
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<registry>
|
||||
<!--Nothing yet-->
|
||||
</registry>
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<load>
|
||||
<requires>
|
||||
<table name="inits"/>
|
||||
<table name="acs_objects"/>
|
||||
<table name="cms_items"/>
|
||||
<table name="ct_publications"/>
|
||||
|
||||
<initializer class="com.arsdigita.cms.Initializer"/>
|
||||
<initializer class="com.arsdigita.cms.contenttypes.PublicationInitializer"/>
|
||||
</requires>
|
||||
|
||||
<provides>
|
||||
<table name="ca_publications_persons"/>
|
||||
<initializer class="com.arsdigita.cms.contentassets.SciPublicationsPersonsInitializer"/>
|
||||
</provides>
|
||||
|
||||
<scripts>
|
||||
<schema directory="ccm-sci-assets-publicationspersons"/>
|
||||
<data class="com.arsdigita.cms.contentassets.SciPublicationsPersonsLoader"/>
|
||||
</scripts>
|
||||
</load>
|
||||
|
|
@ -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 <jens@jp-digital.de>
|
||||
* @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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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 <jens@jp-digital.de>
|
||||
* @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
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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 <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsPersonsLoader extends PackageLoader {
|
||||
|
||||
@Override
|
||||
public void run(final ScriptContext ctx) {
|
||||
//Nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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 <jens@jp-digital.de>
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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 <jens@jp-digital.de>
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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 <jens@jp-digital.de>
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ public class PublicationExtraXmlGenerator implements ExtraXMLGenerator {
|
|||
private final static List<ExtraXMLGenerator> EXTENDING_GENERATORS = new ArrayList<ExtraXMLGenerator>();
|
||||
private boolean listMode;
|
||||
|
||||
public static void addExteningGenerator(final ExtraXMLGenerator generator) {
|
||||
public static void addExtentingGenerator(final ExtraXMLGenerator generator) {
|
||||
EXTENDING_GENERATORS.add(generator);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue