First part of the ccm-sci-publications-dramaticarts module which provides two new publication types for managing movies and plays using the ccm-sci-publications module and its features (developed for the Fiction Meets Science project).
git-svn-id: https://svn.libreccm.org/ccm/trunk@2655 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
fca3bbaf8a
commit
01b4b5b7bf
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0"?>
|
||||
<ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project"
|
||||
name="ccm-sci-publications-dramaticarts"
|
||||
prettyName="SciPublications Dramatic Arts"
|
||||
version="6.6.3"
|
||||
release="1"
|
||||
webapp="ROOT">
|
||||
<ccm:dependencies>
|
||||
<ccm:requires name="ccm-core" version="6.6.4" relation="ge"/>
|
||||
<ccm:requires name="ccm-cms" version="6.6.7" relation="ge"/>
|
||||
<ccm:requires name="ccm-sci-publications" version="6.6.3" relation="ge"/>
|
||||
</ccm:dependencies>
|
||||
<ccm:directories>
|
||||
<ccm:directory name="pdl"/>
|
||||
<ccm:directory name="sql"/>
|
||||
<ccm:directory name="src"/>
|
||||
</ccm:directories>
|
||||
<ccm:contacts>
|
||||
<ccm:contact uri="http://www.redhat.com/software/rhea" type="website"/>
|
||||
<ccm:contact uri="mailto:rhea@redhat.com" type="support"/>
|
||||
</ccm:contacts>
|
||||
<ccm:description>
|
||||
Additional content types for the ccm-sci-publications for storing informations about movies
|
||||
and plays. Developed for the Fiction Meets Science project
|
||||
(http://www.fictionmeetsscience.org).
|
||||
</ccm:description>
|
||||
</ccm:application>
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
//
|
||||
// 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.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.ContentPage;
|
||||
|
||||
object type SciPublicationsMovie extends Publication {
|
||||
|
||||
reference key (ct_scipublications_movie.movie_id);
|
||||
}
|
||||
|
||||
object type SciPublicationMovieBundle extends PublicationBundle {
|
||||
|
||||
reference key (ct_scipublications_movie_bundles.bundle_id);
|
||||
}
|
||||
|
||||
//Association for director(s)
|
||||
association {
|
||||
|
||||
PublicationBundle[0..n] directedMovie = join cms_person_bundles.bundle_id
|
||||
to ct_scipublications_movie_directorship.person_id,
|
||||
join ct_scipublications_movie_directorship.movie_id
|
||||
to ct_scipublications_movie_bundles.bundle_id;
|
||||
|
||||
GenericPersonBundle[0..n] director = join ct_scipublications_movie_bundles.bundle_id
|
||||
to ct_scipublications_movie_directorship.movie_id,
|
||||
join ct_scipublications_movie_directorship.person_id
|
||||
to cms_person_bundles.bundle_id;
|
||||
|
||||
Integer[0..1] directorOrder = ct_scipublications_movie_directorship.director_order INTEGER;
|
||||
}
|
||||
|
||||
//Association for production companies
|
||||
association {
|
||||
|
||||
PublicationBundle[0..n] producedMovie = join cms_orgaunit_bundles.bundle_id
|
||||
to ct_scipublications_movie_productioncompanies.producationcompany_id,
|
||||
join ct_scipublications_movie_productioncompanies.movie_id
|
||||
to ct_scipublications_movie_bundles.bundle_id;
|
||||
|
||||
GenericOrganizationalUnitBundle[0..n] productionCompany = join ct_scipublications_movie_bundles.bundle_id
|
||||
to ct_scipublications_movie_productioncompanies.movie_id,
|
||||
join ct_scipublications_movie_productioncompanies.producationcompany_id
|
||||
to cms_orgaunit_bundles.bundle_id;
|
||||
|
||||
Integer[0..1] companyOrder = ct_scipublications_movie_productioncompanies.company_order INTEGER;
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
//
|
||||
// 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.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.ContentPage;
|
||||
|
||||
object type SciPublicationsPlay extends PublicationWithPublisher {
|
||||
|
||||
Integer[0..1] firstProductionYear = ct_scipublications_plays.first_production_year INTEGER;
|
||||
reference key (ct_scipublications_plays.play_id);
|
||||
}
|
||||
|
||||
object type SciPublicationPlayBundle extends PublicationWithPublisherBundle {
|
||||
|
||||
reference key (ct_scipublications_play_bundles.bundle_id);
|
||||
}
|
||||
|
||||
//Association for first production theater
|
||||
association {
|
||||
|
||||
PublicationBundle[0..n] producedPlay = join cms_orgaunit_bundles.bundle_id
|
||||
to ct_scipublications_play_firstproductiontheather.theater_id,
|
||||
join ct_scipublications_play_firstproductiontheather.play_id
|
||||
to ct_scipublications_play_bundles.bundle_id;
|
||||
|
||||
GenericOrganizationalUnitBundle[0..n] productionTheater = join ct_scipublications_play_bundles.bundle_id
|
||||
to ct_scipublications_play_firstproductiontheather.play_id,
|
||||
join ct_scipublications_play_firstproductiontheather.theather_id
|
||||
to cms_orgaunit_bundles.bundle_id;
|
||||
|
||||
Integer[0..1] theaterOrder = ct_scipublications_play_productiontheater.theater_order INTEGER;
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
begin;
|
||||
\i ddl/postgres/create.sql
|
||||
\i ddl/postgres/deferred.sql
|
||||
end;
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<registry>
|
||||
<!-- Nothing yet -->
|
||||
</registry>
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<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="ct_scipublications_movies"/>
|
||||
<table name="ct_scipublications_plays"/>
|
||||
<initializer class="com.arsdigita.cms.contenttypes.SciPublicationsMoviesInitalizer"/>
|
||||
<initializer class="com.arsdigita.cms.contenttypes.SciPublicationsPlayInitalizer"/>
|
||||
</provides>
|
||||
<scripts>
|
||||
<schema directory="ccm-sci-publications-dramaticarts"/>
|
||||
<data class="com.arsdigita.cms.contenttypes.SciPublicationsMovieLoader"/>
|
||||
<data class="com.arsdigita.cms.contenttypes.SciPublicationsPlayLoader"/>
|
||||
</scripts>
|
||||
|
||||
</load>
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
* 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.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.ContentBundle;
|
||||
import com.arsdigita.domain.DomainCollection;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.sun.istack.internal.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsDirectorCollection extends DomainCollection {
|
||||
|
||||
private final static Logger LOGGER = Logger.getLogger(SciPublicationsDirectorCollection.class);
|
||||
public static final String ORDER = "directorOrder";
|
||||
public static final String LINK_ORDER = "link.directorOrder";
|
||||
|
||||
public SciPublicationsDirectorCollection(final DataCollection dataCollection) {
|
||||
|
||||
super(dataCollection);
|
||||
m_dataCollection.addOrder(LINK_ORDER);
|
||||
}
|
||||
|
||||
public Integer getDirectorOrder() {
|
||||
return (Integer) m_dataCollection.get(LINK_ORDER);
|
||||
}
|
||||
|
||||
public void setDirectorOrder(final Integer order) {
|
||||
final DataObject link = (DataObject) get("link");
|
||||
link.set(ORDER, order);
|
||||
}
|
||||
|
||||
public GenericPerson getDirector() {
|
||||
final ContentBundle bundle = (ContentBundle) DomainObjectFactory.newInstance(
|
||||
m_dataCollection.getDataObject());
|
||||
return (GenericPerson) bundle.getPrimaryInstance();
|
||||
}
|
||||
|
||||
public String getSurname() {
|
||||
return getDirector().getSurname();
|
||||
}
|
||||
|
||||
public String getGivenName() {
|
||||
return getDirector().getGivenName();
|
||||
}
|
||||
|
||||
public void swapWithNext(final GenericPerson director) {
|
||||
|
||||
int currentPos = 0;
|
||||
int currentIndex = 0;
|
||||
int nextIndex = 0;
|
||||
|
||||
rewind();
|
||||
while (next()) {
|
||||
currentPos = getPosition();
|
||||
currentIndex = getDirectorOrder();
|
||||
if (getDirector().equals(director)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentPos == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("The provided person is not a director "
|
||||
+ "of this movie."));
|
||||
}
|
||||
|
||||
if (next()) {
|
||||
nextIndex = getDirectorOrder();
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("The provided person is the last in the"
|
||||
+ "collection, so threre is no next object to swap with."));
|
||||
}
|
||||
|
||||
this.rewind();
|
||||
|
||||
while (getPosition() != currentPos) {
|
||||
next();
|
||||
}
|
||||
|
||||
setDirectorOrder(nextIndex);
|
||||
next();
|
||||
setDirectorOrder(currentIndex);
|
||||
rewind();
|
||||
|
||||
normalizeOrder();
|
||||
|
||||
}
|
||||
|
||||
public void swapWithPrevious(GenericPerson director) {
|
||||
|
||||
int previousPos = 0;
|
||||
int previousIndex = 0;
|
||||
int currentPos = 0;
|
||||
int currentIndex = 0;
|
||||
|
||||
this.rewind();
|
||||
while (next()) {
|
||||
currentPos = getPosition();
|
||||
currentIndex = getDirectorOrder();
|
||||
if (this.getDirector().equals(director)) {
|
||||
break;
|
||||
}
|
||||
|
||||
previousPos = currentPos;
|
||||
previousIndex = currentIndex;
|
||||
}
|
||||
|
||||
if (currentPos == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("The provided person is not an director "
|
||||
+ "of this movie."));
|
||||
}
|
||||
|
||||
if (previousPos == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"The provided author is the first one in this "
|
||||
+ "collection, so there is no previous one to switch "
|
||||
+ "with."));
|
||||
}
|
||||
|
||||
this.rewind();
|
||||
while (this.getPosition() != previousPos) {
|
||||
this.next();
|
||||
}
|
||||
|
||||
this.setDirectorOrder(currentIndex);
|
||||
this.next();
|
||||
this.setDirectorOrder(previousIndex);
|
||||
this.rewind();
|
||||
|
||||
normalizeOrder();
|
||||
}
|
||||
|
||||
private void normalizeOrder() {
|
||||
this.rewind();
|
||||
|
||||
int i = 1;
|
||||
while (this.next()) {
|
||||
setDirectorOrder(i);
|
||||
i++;
|
||||
}
|
||||
this.rewind();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
* 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.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.contenttypes.ui.SciPublicationsMovieExtraXMLGenerator;
|
||||
import com.arsdigita.cms.ExtraXMLGenerator;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.OID;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsMovie extends Publication {
|
||||
|
||||
public static final String BASE_DATA_OBJECT_TYPE
|
||||
= "com.arsdigita.cms.contenttypes.SciPublicationsMovie";
|
||||
public static final String DIRECTORS_STR = "directorsStr";
|
||||
|
||||
public SciPublicationsMovie() {
|
||||
super(BASE_DATA_OBJECT_TYPE);
|
||||
}
|
||||
|
||||
public SciPublicationsMovie(final BigDecimal id) throws DataObjectNotFoundException {
|
||||
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||
}
|
||||
|
||||
public SciPublicationsMovie(final OID oid) throws DataObjectNotFoundException {
|
||||
super(oid);
|
||||
}
|
||||
|
||||
public SciPublicationsMovie(final DataObject obj) {
|
||||
super(obj);
|
||||
}
|
||||
|
||||
public SciPublicationsMovie(final String type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public SciPublicationsMovieBundle getSciPublicationsMovieBundle() {
|
||||
return (SciPublicationsMovieBundle) getContentBundle();
|
||||
}
|
||||
|
||||
public SciPublicationsDirectorCollection getDirectors() {
|
||||
return getSciPublicationsMovieBundle().getDirectors();
|
||||
}
|
||||
|
||||
public void addDirector(final GenericPerson director) {
|
||||
getSciPublicationsMovieBundle().addDirector(director);
|
||||
}
|
||||
|
||||
public void removeDirector(final GenericPerson director) {
|
||||
getSciPublicationsMovieBundle().removeDirector(director);
|
||||
}
|
||||
|
||||
public void swapWithPreviousDirector(final GenericPerson director) {
|
||||
|
||||
getDirectors().swapWithPrevious(director);
|
||||
getSciPublicationsMovieBundle().updateDirectorsStr();
|
||||
|
||||
}
|
||||
|
||||
public void swapWithNextDirector(final GenericPerson director) {
|
||||
|
||||
getDirectors().swapWithNext(director);
|
||||
getSciPublicationsMovieBundle().updateDirectorsStr();
|
||||
|
||||
}
|
||||
|
||||
public boolean hasDirectors() {
|
||||
return !getDirectors().isEmpty();
|
||||
}
|
||||
|
||||
public SciPublicationsProductionCompanyCollection getProductionCompanies() {
|
||||
return getSciPublicationsMovieBundle().getProductionCompanies();
|
||||
}
|
||||
|
||||
public void addProductionCompany(final GenericOrganizationalUnit company) {
|
||||
getSciPublicationsMovieBundle().addProducationCompany(company);
|
||||
}
|
||||
|
||||
public void removeProductionCompany(final GenericOrganizationalUnit company) {
|
||||
getSciPublicationsMovieBundle().removeProductionCompany(company);
|
||||
}
|
||||
|
||||
public boolean hasProductionCompanies() {
|
||||
return !getProductionCompanies().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExtraXMLGenerator> getExtraXMLGenerators() {
|
||||
final List<ExtraXMLGenerator> generators = super.getExtraXMLGenerators();
|
||||
generators.add(new SciPublicationsMovieExtraXMLGenerator());
|
||||
return generators;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExtraXMLGenerator> getExtraListXMLGenerators() {
|
||||
final List<ExtraXMLGenerator> generators = super.getExtraListXMLGenerators();
|
||||
generators.add(new SciPublicationsMovieExtraXMLGenerator());
|
||||
return generators;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSearchSummary() {
|
||||
return String.format("%s %s", super.getSearchSummary(), get(DIRECTORS_STR));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,341 @@
|
|||
/*
|
||||
* 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.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.CustomCopy;
|
||||
import com.arsdigita.cms.ItemCollection;
|
||||
import com.arsdigita.cms.ItemCopier;
|
||||
import com.arsdigita.cms.XMLDeliveryCache;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.OID;
|
||||
import com.arsdigita.persistence.metadata.Property;
|
||||
import com.arsdigita.util.Assert;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsMovieBundle extends PublicationBundle {
|
||||
|
||||
public static final String BASE_BASE_OBJECT_TYPE
|
||||
= "com.arsdigita.cms.contenttypes.SciPublicationsMovieBundle";
|
||||
public static final String DIRECTOR = "director";
|
||||
public static final String DIRECTOR_ORDER = "directorOrder";
|
||||
public static final String PRODUCATION_COMPANY
|
||||
= "producationCompany";
|
||||
public static final String PRODUCATION_COMPANY_ORDER = "companyOrder";
|
||||
|
||||
public SciPublicationsMovieBundle(final ContentItem primary) {
|
||||
|
||||
super(BASE_DATA_OBJECT_TYPE);
|
||||
|
||||
Assert.exists(primary, ContentItem.class);
|
||||
|
||||
setDefaultLanguage(primary.getLanguage());
|
||||
setContentType(primary.getContentType());
|
||||
addInstance(primary);
|
||||
|
||||
setName(primary.getName());
|
||||
}
|
||||
|
||||
public SciPublicationsMovieBundle(final OID oid) throws DataObjectNotFoundException {
|
||||
super(oid);
|
||||
}
|
||||
|
||||
public SciPublicationsMovieBundle(final BigDecimal id) {
|
||||
this(new OID(BASE_BASE_OBJECT_TYPE, id));
|
||||
}
|
||||
|
||||
public SciPublicationsMovieBundle(final DataObject dataObject) {
|
||||
super(dataObject);
|
||||
}
|
||||
|
||||
public SciPublicationsMovieBundle(final String type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean copyProperty(final CustomCopy source,
|
||||
final Property property,
|
||||
final ItemCopier copier) {
|
||||
|
||||
final String attribute = property.getName();
|
||||
if (copier.getCopyType() == ItemCopier.VERSION_COPY) {
|
||||
|
||||
final PublicationBundle pubBundle = (PublicationBundle) source;
|
||||
|
||||
if (DIRECTOR.equals(attribute)) {
|
||||
|
||||
final DataCollection directors = (DataCollection) pubBundle.get(DIRECTOR);
|
||||
|
||||
while (directors.next()) {
|
||||
createDirectorAssoc(directors);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} else if (PRODUCATION_COMPANY.equals(attribute)) {
|
||||
|
||||
final DataCollection companies = (DataCollection) pubBundle.get(PRODUCATION_COMPANY);
|
||||
|
||||
while (companies.next()) {
|
||||
createProductionCompanyAssoc(companies);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
return super.copyProperty(source, null, copier);
|
||||
}
|
||||
} else {
|
||||
return super.copyProperty(source, null, copier);
|
||||
}
|
||||
}
|
||||
|
||||
private void createDirectorAssoc(final DataCollection directors) {
|
||||
|
||||
final GenericPersonBundle draftDirector = (GenericPersonBundle) DomainObjectFactory
|
||||
.newInstance(
|
||||
directors.getDataObject());
|
||||
final GenericPersonBundle liveDirector = (GenericPersonBundle) draftDirector
|
||||
.getLiveVersion();
|
||||
|
||||
if (liveDirector != null) {
|
||||
final DataObject link = add(DIRECTOR, liveDirector);
|
||||
|
||||
link.set(DIRECTOR_ORDER, directors.get(SciPublicationsDirectorCollection.LINK_ORDER));
|
||||
|
||||
link.save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void createProductionCompanyAssoc(final DataCollection companies) {
|
||||
|
||||
final GenericOrganizationalUnitBundle draftCompany
|
||||
= (GenericOrganizationalUnitBundle) DomainObjectFactory
|
||||
.newInstance(
|
||||
companies.getDataObject());
|
||||
final GenericOrganizationalUnitBundle liveCompany
|
||||
= (GenericOrganizationalUnitBundle) draftCompany
|
||||
.getLiveVersion();
|
||||
|
||||
if (liveCompany != null) {
|
||||
final DataObject link = add(PRODUCATION_COMPANY, liveCompany);
|
||||
|
||||
link.set(PRODUCATION_COMPANY_ORDER, companies.get(
|
||||
SciPublicationsProductionCompanyCollection.LINK_ORDER));
|
||||
|
||||
link.save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean copyReverseProperty(final CustomCopy source,
|
||||
final ContentItem liveItem,
|
||||
final Property property,
|
||||
final ItemCopier copier) {
|
||||
|
||||
final String attribute = property.getName();
|
||||
if (copier.getCopyType() == ItemCopier.VERSION_COPY) {
|
||||
|
||||
if (("directedMovie".equals(attribute)) && (source instanceof GenericPersonBundle)) {
|
||||
|
||||
final GenericPersonBundle directorBundle = (GenericPersonBundle) source;
|
||||
final DataCollection movies = (DataCollection) directorBundle.get("directedMovie");
|
||||
|
||||
while (movies.next()) {
|
||||
createDirectorMovieAssociation(movies, (GenericPersonBundle) liveItem);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (("producedMovie".equals(attribute))
|
||||
&& (source instanceof GenericOrganizationalUnitBundle)) {
|
||||
|
||||
final GenericOrganizationalUnitBundle companyBundle
|
||||
= (GenericOrganizationalUnitBundle) source;
|
||||
final DataCollection movies = (DataCollection) companyBundle.get("producedMovie");
|
||||
|
||||
while (movies.next()) {
|
||||
createCompanyMovieAssociation(movies, (GenericOrganizationalUnitBundle) liveItem);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return super.copyReverseProperty(source, liveItem, property, copier);
|
||||
}
|
||||
|
||||
} else {
|
||||
return super.copyReverseProperty(source, liveItem, property, copier);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void createDirectorMovieAssociation(final DataCollection movies,
|
||||
final GenericPersonBundle director) {
|
||||
|
||||
final PublicationBundle draftMovie = (PublicationBundle) DomainObjectFactory.newInstance(
|
||||
movies.getDataObject());
|
||||
final PublicationBundle liveMovie = (PublicationBundle) draftMovie.getLiveVersion();
|
||||
|
||||
if (liveMovie != null) {
|
||||
final DataObject link = director.add("directedMovie", liveMovie);
|
||||
link.set("directorOrder", movies.get("link.directorOrder"));
|
||||
link.save();
|
||||
|
||||
XMLDeliveryCache.getInstance().removeFromCache(liveMovie.getOID());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void createCompanyMovieAssociation(final DataCollection movies,
|
||||
final GenericOrganizationalUnitBundle company) {
|
||||
|
||||
final PublicationBundle draftMovie = (PublicationBundle) DomainObjectFactory
|
||||
.newInstance(movies.getDataObject());
|
||||
final PublicationBundle liveMovie = (PublicationBundle) draftMovie
|
||||
.getLiveVersion();
|
||||
|
||||
if (liveMovie != null) {
|
||||
|
||||
final DataObject link = company.add("producedMovie", liveMovie);
|
||||
link.set("companyOrder", movies.get("link.companyOrder"));
|
||||
link.save();
|
||||
|
||||
XMLDeliveryCache.getInstance().removeFromCache(liveMovie.getOID());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public SciPublicationsDirectorCollection getDirectors() {
|
||||
return new SciPublicationsDirectorCollection((DataCollection) get(DIRECTOR));
|
||||
}
|
||||
|
||||
public void addDirector(final GenericPerson director) {
|
||||
Assert.exists(director, GenericPerson.class);
|
||||
|
||||
final DataObject link = add(DIRECTOR, director.getGenericPersonBundle());
|
||||
|
||||
link.set(DIRECTOR_ORDER, Integer.valueOf((int) getDirectors().size()));
|
||||
|
||||
updateDirectorsStr();
|
||||
}
|
||||
|
||||
public void removeDirector(final GenericPerson director) {
|
||||
Assert.exists(director, GenericPerson.class);
|
||||
|
||||
remove(DIRECTOR, director.getContentBundle());
|
||||
|
||||
updateDirectorsStr();
|
||||
}
|
||||
|
||||
protected void updateDirectorsStr() {
|
||||
|
||||
final SciPublicationsDirectorCollection directors = getDirectors();
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
while(directors.next()) {
|
||||
if (builder.length() > 0) {
|
||||
builder.append("; ");
|
||||
}
|
||||
builder.append(directors.getSurname());
|
||||
builder.append(", ");
|
||||
builder.append(directors.getGivenName());
|
||||
}
|
||||
|
||||
final String directorStr = builder.toString();
|
||||
|
||||
final ItemCollection instances = getInstances();
|
||||
|
||||
SciPublicationsMovie movie;
|
||||
while(instances.next()) {
|
||||
movie = (SciPublicationsMovie) instances.getDomainObject();
|
||||
movie.set(SciPublicationsMovie.DIRECTORS_STR, directorStr);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public SciPublicationsProductionCompanyCollection getProductionCompanies() {
|
||||
|
||||
return new SciPublicationsProductionCompanyCollection((DataCollection) get(PRODUCATION_COMPANY));
|
||||
|
||||
}
|
||||
|
||||
public void addProducationCompany(final GenericOrganizationalUnit company) {
|
||||
|
||||
Assert.exists(company, GenericOrganizationalUnit.class);
|
||||
|
||||
final DataObject link = add(PRODUCATION_COMPANY,
|
||||
company.getGenericOrganizationalUnitBundle());
|
||||
link.set(PRODUCATION_COMPANY, Integer.valueOf((int) getProductionCompanies().size()));
|
||||
link.save();
|
||||
|
||||
}
|
||||
|
||||
public void removeProductionCompany(final GenericOrganizationalUnit company) {
|
||||
|
||||
Assert.exists(company, GenericOrganizationalUnit.class);
|
||||
|
||||
remove(PRODUCATION_COMPANY, company.getGenericOrganizationalUnitBundle());
|
||||
|
||||
}
|
||||
|
||||
public static PublicationBundleCollection getDirectedMovies(final GenericPerson director) {
|
||||
|
||||
final GenericPersonBundle directorBundle = director.getGenericPersonBundle();
|
||||
|
||||
final DataCollection collection = (DataCollection) directorBundle.get("directedMovie");
|
||||
|
||||
return new PublicationBundleCollection(collection);
|
||||
|
||||
}
|
||||
|
||||
public static PublicationBundleCollection getProducedMovies(
|
||||
final GenericOrganizationalUnit company) {
|
||||
|
||||
final GenericOrganizationalUnitBundle companyBundle = company.getGenericOrganizationalUnitBundle();
|
||||
|
||||
final DataCollection collection = (DataCollection) companyBundle.get("producedMovie");
|
||||
|
||||
return new PublicationBundleCollection(collection);
|
||||
|
||||
}
|
||||
|
||||
public SciPublicationsMovie getMovie() {
|
||||
return (SciPublicationsMovie) getPrimaryInstance();
|
||||
}
|
||||
|
||||
public SciPublicationsMovie getMovie(final String language) {
|
||||
|
||||
SciPublicationsMovie result = (SciPublicationsMovie) getInstance(language);
|
||||
if (result == null) {
|
||||
result = getMovie();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Jens Pelzetter,
|
||||
* ScientificCMS Team, http://www.scientificcms.org
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsMovieInitializer extends ContentTypeInitializer {
|
||||
|
||||
public SciPublicationsMovieInitializer() {
|
||||
super("empty.pdl.mf", SciPublicationsMovie.BASE_DATA_OBJECT_TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getStylesheets() {
|
||||
return new String[]{INTERNAL_THEME_TYPES_DIR + "sci/SciPublicationsMovie.xsl"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTraversalXML() {
|
||||
return "/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciPublicationsMovie.xml";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Jens Pelzetter,
|
||||
* ScientificCMS Team, http://www.scientificcms.org
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsMovieLoader extends AbstractContentTypeLoader {
|
||||
|
||||
private static final String[] TYPES = {
|
||||
"/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SciPublicationsMovie.xml"};
|
||||
|
||||
public SciPublicationsMovieLoader() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTypes() {
|
||||
return TYPES;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* 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.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.ExtraXMLGenerator;
|
||||
import com.arsdigita.cms.contenttypes.ui.SciPublicationsPlayExtraXMLGenerator;
|
||||
import com.arsdigita.domain.DomainCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.OID;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsPlay extends PublicationWithPublisher {
|
||||
|
||||
public static final String BASE_DATA_OBJECT_TYPE
|
||||
= "com.arsdigita.cms.contenttypes.SciPublicationsPlay";
|
||||
public static final String FIRST_PRODUCTION_YEAR = "firstProductionYear";
|
||||
|
||||
public SciPublicationsPlay() {
|
||||
super(BASE_DATA_OBJECT_TYPE);
|
||||
}
|
||||
|
||||
public SciPublicationsPlay(final BigDecimal id) {
|
||||
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||
}
|
||||
|
||||
public SciPublicationsPlay(final OID oid) {
|
||||
super(oid);
|
||||
}
|
||||
|
||||
public SciPublicationsPlay(final DataObject obj) {
|
||||
super(obj);
|
||||
}
|
||||
|
||||
public SciPublicationsPlay(final String type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public SciPublicationsPlayBundle getSciPublicationsPlayBundle() {
|
||||
return (SciPublicationsPlayBundle) getContentBundle();
|
||||
}
|
||||
|
||||
public Integer getFirstProductionYear() {
|
||||
return (Integer) get(FIRST_PRODUCTION_YEAR);
|
||||
}
|
||||
|
||||
public void setFirstProductionYear(final Integer year) {
|
||||
set(FIRST_PRODUCTION_YEAR, year);
|
||||
}
|
||||
|
||||
public DomainCollection getProductionTheateres() {
|
||||
return getSciPublicationsPlayBundle().getProductionTheateres();
|
||||
}
|
||||
|
||||
public void addProductionTheater(final GenericOrganizationalUnit theater) {
|
||||
getSciPublicationsPlayBundle().addProducationTheater(theater);
|
||||
}
|
||||
|
||||
public void removeProductionTheater(final GenericOrganizationalUnit theater) {
|
||||
getSciPublicationsPlayBundle().removeProductionTheater(theater);
|
||||
}
|
||||
|
||||
public boolean hasProductionTheaters() {
|
||||
return !getProductionTheateres().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExtraXMLGenerator> getExtraXMLGenerators() {
|
||||
final List<ExtraXMLGenerator> generators = super.getExtraXMLGenerators();
|
||||
generators.add(new SciPublicationsPlayExtraXMLGenerator());
|
||||
return generators;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExtraXMLGenerator> getExtraListXMLGenerators() {
|
||||
final List<ExtraXMLGenerator> generators = super.getExtraListXMLGenerators();
|
||||
generators.add(new SciPublicationsPlayExtraXMLGenerator());
|
||||
return generators;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,226 @@
|
|||
/*
|
||||
* 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.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.CustomCopy;
|
||||
import com.arsdigita.cms.ItemCopier;
|
||||
import com.arsdigita.cms.XMLDeliveryCache;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.domain.DomainCollection;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.OID;
|
||||
import com.arsdigita.persistence.metadata.Property;
|
||||
import com.arsdigita.util.Assert;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsPlayBundle extends PublicationWithPublisherBundle {
|
||||
|
||||
public static final String BASE_BASE_OBJECT_TYPE
|
||||
= "com.arsdigita.cms.contenttypes.SciPublicationsPlayBundle";
|
||||
public static final String PRODUCTION_THEATER = "productionTheater";
|
||||
public static final String PRODUCTION_THEATER_ORDER = "theaterOrder";
|
||||
|
||||
public SciPublicationsPlayBundle(final ContentItem primary) {
|
||||
|
||||
super(BASE_BASE_OBJECT_TYPE);
|
||||
|
||||
Assert.exists(primary, ContentItem.class);
|
||||
|
||||
setDefaultLanguage(primary.getLanguage());
|
||||
setContentType(primary.getContentType());
|
||||
addInstance(primary);
|
||||
|
||||
setName(primary.getName());
|
||||
}
|
||||
|
||||
public SciPublicationsPlayBundle(final OID oid) throws DataObjectNotFoundException {
|
||||
super(oid);
|
||||
}
|
||||
|
||||
public SciPublicationsPlayBundle(final BigDecimal id) throws DataObjectNotFoundException {
|
||||
this(new OID(BASE_BASE_OBJECT_TYPE, id));
|
||||
}
|
||||
|
||||
public SciPublicationsPlayBundle(final DataObject dataObject) {
|
||||
super(dataObject);
|
||||
}
|
||||
|
||||
public SciPublicationsPlayBundle(final String type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean copyProperty(final CustomCopy source,
|
||||
final Property property,
|
||||
final ItemCopier copier) {
|
||||
|
||||
final String attribute = property.getName();
|
||||
if (copier.getCopyType() == ItemCopier.VERSION_COPY) {
|
||||
|
||||
final PublicationBundle pubBundle = (PublicationBundle) source;
|
||||
|
||||
if (PRODUCTION_THEATER.equals(attribute)) {
|
||||
|
||||
final DataCollection theatres = (DataCollection) pubBundle.get(PRODUCTION_THEATER);
|
||||
|
||||
while (theatres.next()) {
|
||||
createProductionTheaterAssoc(theatres);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
return super.copyProperty(source, property, copier);
|
||||
}
|
||||
|
||||
} else {
|
||||
return super.copyProperty(source, property, copier);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void createProductionTheaterAssoc(final DataCollection theatres) {
|
||||
|
||||
final GenericOrganizationalUnitBundle draftTheater
|
||||
= (GenericOrganizationalUnitBundle) DomainObjectFactory
|
||||
.newInstance(theatres.getDataObject());
|
||||
final GenericOrganizationalUnitBundle liveTheater
|
||||
= (GenericOrganizationalUnitBundle) draftTheater
|
||||
.getLiveVersion();
|
||||
|
||||
if (liveTheater != null) {
|
||||
final DataObject link = add(PRODUCTION_THEATER, liveTheater);
|
||||
|
||||
link.set(PRODUCTION_THEATER_ORDER, theatres.get("link." + PRODUCTION_THEATER_ORDER));
|
||||
|
||||
link.save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean copyReverseProperty(final CustomCopy source,
|
||||
final ContentItem liveItem,
|
||||
final Property property,
|
||||
final ItemCopier copier) {
|
||||
|
||||
final String attribute = property.getName();
|
||||
if (copier.getCopyType() == ItemCopier.VERSION_COPY) {
|
||||
|
||||
if ("producedPlay".equals(attribute)
|
||||
&& (source instanceof GenericOrganizationalUnitBundle)) {
|
||||
|
||||
final GenericOrganizationalUnitBundle theaterBundle
|
||||
= (GenericOrganizationalUnitBundle) source;
|
||||
final DataCollection plays = (DataCollection) theaterBundle.get("producedPlay");
|
||||
|
||||
while (plays.next()) {
|
||||
createTheaterPlayAssoc(plays, (GenericOrganizationalUnitBundle) liveItem);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
return super.copyReverseProperty(source, liveItem, property, copier);
|
||||
}
|
||||
|
||||
} else {
|
||||
return super.copyReverseProperty(source, liveItem, property, copier);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void createTheaterPlayAssoc(final DataCollection plays,
|
||||
final GenericOrganizationalUnitBundle theater) {
|
||||
|
||||
final PublicationBundle draftPlay = (PublicationBundle) DomainObjectFactory.newInstance(
|
||||
plays.getDataObject());
|
||||
final PublicationBundle livePlay = (PublicationBundle) draftPlay.getLiveVersion();
|
||||
|
||||
if (livePlay != null) {
|
||||
|
||||
final DataObject link = theater.add("producedPlay", livePlay);
|
||||
link.set(PRODUCTION_THEATER_ORDER, plays.get("link." + PRODUCTION_THEATER_ORDER));
|
||||
link.save();
|
||||
|
||||
XMLDeliveryCache.getInstance().removeFromCache(livePlay.getOID());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public DomainCollection getProductionTheateres() {
|
||||
|
||||
return new DomainCollection((DataCollection) get(PRODUCTION_THEATER));
|
||||
|
||||
}
|
||||
|
||||
public void addProducationTheater(final GenericOrganizationalUnit theater) {
|
||||
|
||||
Assert.exists(theater, GenericOrganizationalUnit.class);
|
||||
|
||||
final DataObject link = add(PRODUCTION_THEATER,
|
||||
theater.getGenericOrganizationalUnitBundle());
|
||||
link.set(PRODUCTION_THEATER, Integer.valueOf((int) getProductionTheateres().size()));
|
||||
link.save();
|
||||
}
|
||||
|
||||
public void removeProductionTheater(final GenericOrganizationalUnit theater) {
|
||||
|
||||
Assert.exists(theater, GenericOrganizationalUnit.class);
|
||||
|
||||
remove(PRODUCTION_THEATER, theater.getContentBundle());
|
||||
|
||||
}
|
||||
|
||||
public static PublicationBundleCollection getProducedPlays(
|
||||
final GenericOrganizationalUnit theater) {
|
||||
|
||||
final GenericOrganizationalUnitBundle theaterBundle = theater
|
||||
.getGenericOrganizationalUnitBundle();
|
||||
|
||||
final DataCollection collection = (DataCollection) theaterBundle.get("producedPlay");
|
||||
|
||||
return new PublicationBundleCollection(collection);
|
||||
|
||||
}
|
||||
|
||||
public SciPublicationsPlay getPlay() {
|
||||
return (SciPublicationsPlay) getPrimaryInstance();
|
||||
}
|
||||
|
||||
public SciPublicationsPlay getPlay(final String language) {
|
||||
|
||||
SciPublicationsPlay result = (SciPublicationsPlay) getInstance(language);
|
||||
if (result == null) {
|
||||
result = getPlay();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Jens Pelzetter,
|
||||
* ScientificCMS Team, http://www.scientificcms.org
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsPlayInitializer extends ContentTypeInitializer {
|
||||
|
||||
public SciPublicationsPlayInitializer() {
|
||||
super("empty.pdl.mf", SciPublicationsPlay.BASE_DATA_OBJECT_TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getStylesheets() {
|
||||
return new String[]{INTERNAL_THEME_TYPES_DIR + "sci/SciPublicationsPlay.xsl"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTraversalXML() {
|
||||
return "/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciPublicationsPlay.xml";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Jens Pelzetter,
|
||||
* ScientificCMS Team, http://www.scientificcms.org
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsPlayLoader extends AbstractContentTypeLoader {
|
||||
|
||||
private static final String[] TYPES = {
|
||||
"/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SciPublicationsPlay.xml"};
|
||||
|
||||
public SciPublicationsPlayLoader() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTypes() {
|
||||
return TYPES;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,165 @@
|
|||
/*
|
||||
* 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.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.ContentBundle;
|
||||
import com.arsdigita.domain.DomainCollection;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsProductionCompanyCollection extends DomainCollection {
|
||||
|
||||
public static final String ORDER = "companyOrder";
|
||||
public static final String LINK_ORDER = "link.companyOrder";
|
||||
|
||||
public SciPublicationsProductionCompanyCollection(final DataCollection dataCollection) {
|
||||
|
||||
super(dataCollection);
|
||||
m_dataCollection.addOrder(LINK_ORDER);
|
||||
|
||||
}
|
||||
|
||||
public Integer getCompanyOrder() {
|
||||
return (Integer) m_dataCollection.get(LINK_ORDER);
|
||||
}
|
||||
|
||||
public void setCompanyOrder(final Integer order) {
|
||||
final DataObject link = (DataObject) get("link");
|
||||
link.set(ORDER, order);
|
||||
}
|
||||
|
||||
public GenericOrganizationalUnit getCompany() {
|
||||
final ContentBundle bundle = (ContentBundle) DomainObjectFactory.newInstance(
|
||||
m_dataCollection.getDataObject());
|
||||
return (GenericOrganizationalUnit) bundle.getPrimaryInstance();
|
||||
}
|
||||
|
||||
public String getCompanyName() {
|
||||
return getCompany().getTitle();
|
||||
}
|
||||
|
||||
public void swapWithNext(final GenericOrganizationalUnit company) {
|
||||
|
||||
int currentPos = 0;
|
||||
int currentIndex = 0;
|
||||
int nextIndex = 0;
|
||||
|
||||
rewind();
|
||||
while (next()) {
|
||||
currentPos = getPosition();
|
||||
currentIndex = getCompanyOrder();
|
||||
if (getCompany().equals(company)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentPos == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("The provided organisation is not a producation company "
|
||||
+ "of this movie."));
|
||||
}
|
||||
|
||||
if (next()) {
|
||||
nextIndex = getCompanyOrder();
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("The provided organisation is the last in the"
|
||||
+ "collection, so threre is no next object to swap with."));
|
||||
}
|
||||
|
||||
this.rewind();
|
||||
|
||||
while (getPosition() != currentPos) {
|
||||
rewind();
|
||||
}
|
||||
|
||||
setCompanyOrder(nextIndex);
|
||||
next();
|
||||
setCompanyOrder(currentIndex);
|
||||
rewind();
|
||||
|
||||
normalizeOrder();
|
||||
|
||||
}
|
||||
|
||||
public void swapWithPrevious(final GenericOrganizationalUnit company) {
|
||||
|
||||
int previousPos = 0;
|
||||
int previousIndex = 0;
|
||||
int currentPos = 0;
|
||||
int currentIndex = 0;
|
||||
|
||||
this.rewind();
|
||||
while (next()) {
|
||||
currentPos = getPosition();
|
||||
currentIndex = getCompanyOrder();
|
||||
if (this.getCompany().equals(company)) {
|
||||
break;
|
||||
}
|
||||
|
||||
previousPos = currentPos;
|
||||
previousIndex = currentIndex;
|
||||
}
|
||||
|
||||
if (currentPos == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("The provided organisation is not an production company "
|
||||
+ "of this movie."));
|
||||
}
|
||||
|
||||
if (previousPos == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"The provided organisation is the first one in this "
|
||||
+ "collection, so there is no previous one to switch "
|
||||
+ "with."));
|
||||
}
|
||||
|
||||
this.rewind();
|
||||
while (this.getPosition() != previousPos) {
|
||||
this.next();
|
||||
}
|
||||
|
||||
this.setCompanyOrder(currentIndex);
|
||||
this.next();
|
||||
this.setCompanyOrder(previousIndex);
|
||||
this.rewind();
|
||||
|
||||
normalizeOrder();
|
||||
|
||||
}
|
||||
|
||||
private void normalizeOrder() {
|
||||
this.rewind();
|
||||
|
||||
int i = 1;
|
||||
while (this.next()) {
|
||||
setCompanyOrder(i);
|
||||
i++;
|
||||
}
|
||||
this.rewind();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) 2010 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.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.Page;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.ExtraXMLGenerator;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsMovieExtraXMLGenerator implements ExtraXMLGenerator {
|
||||
|
||||
private boolean listMode;
|
||||
|
||||
@Override
|
||||
public void generateXML(final ContentItem item,
|
||||
final Element element,
|
||||
final PageState state) {
|
||||
|
||||
}
|
||||
|
||||
public void addGlobalStateParams(final Page page) {
|
||||
//nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListMode(final boolean listMode) {
|
||||
this.listMode = listMode;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* 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.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.Page;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.ExtraXMLGenerator;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsPlayExtraXMLGenerator implements ExtraXMLGenerator {
|
||||
|
||||
private boolean listMode;
|
||||
|
||||
@Override
|
||||
public void generateXML(final ContentItem item,
|
||||
final Element element,
|
||||
final PageState state) {
|
||||
|
||||
}
|
||||
|
||||
public void addGlobalStateParams(final Page page) {
|
||||
//nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListMode(final boolean listMode) {
|
||||
this.listMode = listMode;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,25 +1,25 @@
|
|||
<?xml version="1.0"?>
|
||||
<ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project"
|
||||
name="ccm-sci-publications-researchreport"
|
||||
prettyName="SciPublications ResearchReport"
|
||||
version="6.6.3"
|
||||
release="1"
|
||||
webapp="ROOT">
|
||||
<ccm:dependencies>
|
||||
<ccm:requires name="ccm-core" version="6.6.4" relation="ge"/>
|
||||
<ccm:requires name="ccm-cms" version="6.6.7" relation="ge"/>
|
||||
<ccm:requires name="ccm-sci-publications" version="6.6.3" relation="ge"/>
|
||||
</ccm:dependencies>
|
||||
<ccm:directories>
|
||||
<ccm:directory name="pdl"/>
|
||||
<ccm:directory name="sql"/>
|
||||
<ccm:directory name="src"/>
|
||||
</ccm:directories>
|
||||
<ccm:contacts>
|
||||
<ccm:contact uri="http://www.redhat.com/software/rhea" type="website"/>
|
||||
<ccm:contact uri="mailto:rhea@redhat.com" type="support"/>
|
||||
</ccm:contacts>
|
||||
<ccm:description>
|
||||
Additional content type Research Report for the ccm-sci-publications module.
|
||||
</ccm:description>
|
||||
name="ccm-sci-publications-researchreport"
|
||||
prettyName="SciPublications ResearchReport"
|
||||
version="6.6.3"
|
||||
release="1"
|
||||
webapp="ROOT">
|
||||
<ccm:dependencies>
|
||||
<ccm:requires name="ccm-core" version="6.6.4" relation="ge"/>
|
||||
<ccm:requires name="ccm-cms" version="6.6.7" relation="ge"/>
|
||||
<ccm:requires name="ccm-sci-publications" version="6.6.3" relation="ge"/>
|
||||
</ccm:dependencies>
|
||||
<ccm:directories>
|
||||
<ccm:directory name="pdl"/>
|
||||
<ccm:directory name="sql"/>
|
||||
<ccm:directory name="src"/>
|
||||
</ccm:directories>
|
||||
<ccm:contacts>
|
||||
<ccm:contact uri="http://www.redhat.com/software/rhea" type="website"/>
|
||||
<ccm:contact uri="mailto:rhea@redhat.com" type="support"/>
|
||||
</ccm:contacts>
|
||||
<ccm:description>
|
||||
Additional content type Research Report for the ccm-sci-publications module.
|
||||
</ccm:description>
|
||||
</ccm:application>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
@ ddl/oracle-se/create.sql
|
||||
|
||||
@ ddl/oracle-se/deferred.sql
|
||||
|
|
@ -36,6 +36,7 @@ import com.arsdigita.xml.Element;
|
|||
public class PublicationWithPublisherExtraXmlGenerator
|
||||
implements ExtraXMLGenerator {
|
||||
|
||||
@Override
|
||||
public void generateXML(final ContentItem item,
|
||||
final Element element,
|
||||
final PageState state) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue