Optimierung Assoziationen Publication <-> Series und Series <-> GenericPerson
git-svn-id: https://svn.libreccm.org/ccm/trunk@1574 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
f80728caa4
commit
23bfac769b
|
|
@ -20,6 +20,7 @@
|
|||
model com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.ContentPage;
|
||||
import com.arsdigita.cms.ContentBundle;
|
||||
|
||||
// The contenttype described in this PDL file represents a series of publications.
|
||||
object type Series extends ContentPage {
|
||||
|
|
@ -27,21 +28,24 @@ object type Series extends ContentPage {
|
|||
reference key (ct_series.series_id);
|
||||
|
||||
String[0..1] abstract = ct_series.abstract VARCHAR(4096);
|
||||
}
|
||||
|
||||
object type SeriesBundle extends ContentBundle {
|
||||
reference key (ct_series_bundles.bundle_id);
|
||||
}
|
||||
|
||||
//Assoication for the editship of a series
|
||||
association {
|
||||
|
||||
Series[0..n] series = join cms_persons.person_id
|
||||
to ct_series_editship.person_id,
|
||||
join ct_series_editship.series_id
|
||||
to ct_series.series_id;
|
||||
SeriesBundle[0..n] series = join cms_person_bundles.bundle_id
|
||||
to ct_series_editship.person_id,
|
||||
join ct_series_editship.series_id
|
||||
to ct_series_bundles.bundle_id;
|
||||
|
||||
GenericPerson[0..n] editors = join ct_series.series_id
|
||||
to ct_series_editship.series_id,
|
||||
join ct_series_editship.person_id
|
||||
to cms_persons.person_id;
|
||||
GenericPersonBundle[0..n] editors = join ct_series_bundles.bundle_id
|
||||
to ct_series_editship.series_id,
|
||||
join ct_series_editship.person_id
|
||||
to cms_person_bundles.bundle_id;
|
||||
|
||||
// Additional attributes for the editship
|
||||
Date[0..1] dateFrom = ct_series_editship.dateFrom DATE;
|
||||
|
|
@ -55,15 +59,15 @@ association {
|
|||
//Assoication for the volumes in the series
|
||||
association {
|
||||
|
||||
Series[0..n] series = join ct_publications.publication_id
|
||||
to ct_publications_volume_in_series.publication_id,
|
||||
join ct_publications_volume_in_series.series_id
|
||||
to ct_series.series_id;
|
||||
SeriesBundle[0..n] series = join ct_publication_bundles.bundle_id
|
||||
to ct_publications_volume_in_series.publication_id,
|
||||
join ct_publications_volume_in_series.series_id
|
||||
to ct_series_bundles.bundle_id;
|
||||
|
||||
Publication[0..n] publications = join ct_series.series_id
|
||||
to ct_publications_volume_in_series.series_id,
|
||||
join ct_publications_volume_in_series.publication_id
|
||||
to ct_publications.publication_id;
|
||||
PublicationBundle[0..n] publications = join ct_series_bundles.bundle_id
|
||||
to ct_publications_volume_in_series.series_id,
|
||||
join ct_publications_volume_in_series.publication_id
|
||||
to ct_publication_bundles.bundle_id;
|
||||
// Additional attributes
|
||||
Integer[0..1] volumeOfSeries = ct_publications_volume_in_series.volumeOfSeries INTEGER;
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
objectType="com.arsdigita.cms.contenttypes.Series"
|
||||
classname="com.arsdigita.cms.contenttypes.Series">
|
||||
|
||||
<ctd:authoring-kit createComponent="com.arsdigita.cms.ui.authoring.PageCreate">
|
||||
<ctd:authoring-kit createComponent="com.arsdigita.cms.ui.authoring.SeriesCreate">
|
||||
|
||||
<ctd:authoring-step
|
||||
labelKey="publications.ui.series_properties.title"
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.domain.DomainCollection;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import java.util.Date;
|
||||
|
|
@ -200,6 +201,7 @@ public class EditshipCollection extends DomainCollection {
|
|||
}
|
||||
|
||||
public GenericPerson getEditor() {
|
||||
return new GenericPerson(m_dataCollection.getDataObject());
|
||||
final GenericPersonBundle bundle = (GenericPersonBundle) DomainObjectFactory.newInstance(m_dataCollection.getDataObject());
|
||||
return (GenericPerson) bundle.getPrimaryInstance();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,22 +71,32 @@ public class Series extends ContentPage {
|
|||
set(ABSTRACT, abstractStr);
|
||||
}
|
||||
|
||||
public SeriesBundle getSeriesBundle() {
|
||||
return (SeriesBundle) getContentBundle();
|
||||
}
|
||||
|
||||
public EditshipCollection getEditors() {
|
||||
return new EditshipCollection((DataCollection) get(EDITORS));
|
||||
//return new EditshipCollection((DataCollection) get(EDITORS));
|
||||
return getSeriesBundle().getEditors();
|
||||
}
|
||||
|
||||
public void addEditor(GenericPerson editor, Date from, Date to) {
|
||||
Assert.exists(editor, GenericPerson.class);
|
||||
public void addEditor(final GenericPerson editor,
|
||||
final Date from,
|
||||
final Date to) {
|
||||
// Assert.exists(editor, GenericPerson.class);
|
||||
//
|
||||
// DataObject link = add(EDITORS, editor);
|
||||
// link.set(EDITOR_FROM, from);
|
||||
// link.set(EDITOR_TO, to);
|
||||
// link.set(EDITOR_ORDER, Integer.valueOf((int)getEditors().size()));
|
||||
|
||||
DataObject link = add(EDITORS, editor);
|
||||
link.set(EDITOR_FROM, from);
|
||||
link.set(EDITOR_TO, to);
|
||||
link.set(EDITOR_ORDER, Integer.valueOf((int)getEditors().size()));
|
||||
getSeriesBundle().addEditor(editor, from, to);
|
||||
}
|
||||
|
||||
public void removeEditor(GenericPerson editor) {
|
||||
Assert.exists(editor, GenericPerson.class);
|
||||
remove(EDITORS, editor);
|
||||
public void removeEditor(final GenericPerson editor) {
|
||||
//Assert.exists(editor, GenericPerson.class);
|
||||
//remove(EDITORS, editor);
|
||||
getSeriesBundle().removeEditor(editor);
|
||||
}
|
||||
|
||||
public boolean hasEditors() {
|
||||
|
|
@ -94,20 +104,23 @@ public class Series extends ContentPage {
|
|||
}
|
||||
|
||||
public VolumeInSeriesCollection getVolumes() {
|
||||
return new VolumeInSeriesCollection((DataCollection) get(PUBLICATIONS));
|
||||
//return new VolumeInSeriesCollection((DataCollection) get(PUBLICATIONS));
|
||||
return getSeriesBundle().getVolumes();
|
||||
}
|
||||
|
||||
public void addVolume(Publication publication, Integer volume) {
|
||||
Assert.exists(publication, Publication.class);
|
||||
|
||||
DataObject link = add(PUBLICATIONS, publication);
|
||||
|
||||
link.set(VOLUME_OF_SERIES, volume);
|
||||
public void addVolume(final Publication publication, final Integer volume) {
|
||||
// Assert.exists(publication, Publication.class);
|
||||
//
|
||||
// DataObject link = add(PUBLICATIONS, publication);
|
||||
//
|
||||
// link.set(VOLUME_OF_SERIES, volume);
|
||||
getSeriesBundle().addVolume(publication, volume);
|
||||
}
|
||||
|
||||
public void removeVolume(Publication publication) {
|
||||
Assert.exists(publication, Publication.class);
|
||||
remove(PUBLICATIONS, publication);
|
||||
public void removeVolume(final Publication publication) {
|
||||
//Assert.exists(publication, Publication.class);
|
||||
//remove(PUBLICATIONS, publication);
|
||||
getSeriesBundle().removeVolume(publication);
|
||||
}
|
||||
|
||||
public boolean hasVolumes() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,226 @@
|
|||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.ContentBundle;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.CustomCopy;
|
||||
import com.arsdigita.cms.ItemCopier;
|
||||
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;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SeriesBundle extends ContentBundle {
|
||||
|
||||
public static final String BASE_DATA_OBJECT_TYPE =
|
||||
"com.arsdigita.cms.contenttypes.SeriesBundle";
|
||||
public static final String EDITORS = "editors";
|
||||
public static final String EDITOR_FROM = "dateFrom";
|
||||
public static final String EDITOR_TO = "dateTo";
|
||||
public static final String EDITOR_ORDER = "editor_order";
|
||||
public static final String PUBLICATIONS = "publications";
|
||||
public static final String VOLUME_OF_SERIES = "volumeOfSeries";
|
||||
|
||||
public SeriesBundle(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 SeriesBundle(final OID oid) throws DataObjectNotFoundException {
|
||||
super(oid);
|
||||
}
|
||||
|
||||
public SeriesBundle(final BigDecimal id) throws DataObjectNotFoundException {
|
||||
super(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||
}
|
||||
|
||||
public SeriesBundle(final DataObject dobj) {
|
||||
super(dobj);
|
||||
}
|
||||
|
||||
public SeriesBundle(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 SeriesBundle seriesBundle = (SeriesBundle) source;
|
||||
|
||||
if (EDITORS.equals(attribute)) {
|
||||
final DataCollection editors =
|
||||
(DataCollection) seriesBundle.get(EDITORS);
|
||||
|
||||
while (editors.next()) {
|
||||
createEditorAssoc(editors);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (PUBLICATIONS.equals(attribute)) {
|
||||
final DataCollection publications =
|
||||
(DataCollection) seriesBundle.get(
|
||||
PUBLICATIONS);
|
||||
|
||||
while (publications.next()) {
|
||||
createPublicationAssoc(publications);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return super.copyProperty(source, property, copier);
|
||||
}
|
||||
} else {
|
||||
return super.copyProperty(source, property, copier);
|
||||
}
|
||||
}
|
||||
|
||||
private void createEditorAssoc(final DataCollection editors) {
|
||||
final GenericPersonBundle draftPerson =
|
||||
(GenericPersonBundle) DomainObjectFactory.
|
||||
newInstance(editors.getDataObject());
|
||||
final GenericPersonBundle livePerson =
|
||||
(GenericPersonBundle) draftPerson.
|
||||
getLiveVersion();
|
||||
|
||||
if (livePerson != null) {
|
||||
final DataObject link = add(EDITORS, livePerson);
|
||||
|
||||
link.set(EDITOR_FROM, editors.get("link." + EDITOR_FROM));
|
||||
link.set(EDITOR_TO, editors.get("link." + EDITOR_TO));
|
||||
link.set(EDITOR_ORDER, editors.get("link." + EDITOR_ORDER));
|
||||
|
||||
link.save();
|
||||
}
|
||||
}
|
||||
|
||||
private void createPublicationAssoc(final DataCollection publications) {
|
||||
final PublicationBundle draftPublication =
|
||||
(PublicationBundle) DomainObjectFactory.
|
||||
newInstance(publications.getDataObject());
|
||||
final PublicationBundle livePublication =
|
||||
(PublicationBundle) draftPublication.
|
||||
getLiveVersion();
|
||||
|
||||
if (livePublication != null) {
|
||||
final DataObject link = add(PUBLICATIONS, livePublication);
|
||||
|
||||
link.set(VOLUME_OF_SERIES,
|
||||
publications.get("link." + VOLUME_OF_SERIES));
|
||||
|
||||
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 (("series".equals(attribute))
|
||||
&& (source instanceof GenericPersonBundle)) {
|
||||
|
||||
final GenericPersonBundle editorBundle =
|
||||
(GenericPersonBundle) source;
|
||||
final DataCollection series = (DataCollection) editorBundle.get(
|
||||
"series");
|
||||
|
||||
while (series.next()) {
|
||||
createSeriesAssoc(series,
|
||||
(GenericPersonBundle) liveItem);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return super.copyReverseProperty(source,
|
||||
liveItem,
|
||||
property,
|
||||
copier);
|
||||
}
|
||||
} else {
|
||||
return super.copyReverseProperty(source, liveItem, property, copier);
|
||||
}
|
||||
}
|
||||
|
||||
private void createSeriesAssoc(final DataCollection series,
|
||||
final GenericPersonBundle editor) {
|
||||
final SeriesBundle draftSeries = (SeriesBundle) DomainObjectFactory.
|
||||
newInstance(series.getDataObject());
|
||||
final SeriesBundle liveSeries = (SeriesBundle) draftSeries.
|
||||
getLiveVersion();
|
||||
|
||||
if (liveSeries != null) {
|
||||
final DataObject link = editor.add("series", liveSeries);
|
||||
|
||||
link.set(EDITOR_FROM, series.get("link." + EDITOR_FROM));
|
||||
link.set(EDITOR_TO, series.get("link." + EDITOR_TO));
|
||||
link.set(EDITOR_ORDER, series.get("link." + EDITOR_ORDER));
|
||||
|
||||
link.save();
|
||||
}
|
||||
}
|
||||
|
||||
public EditshipCollection getEditors() {
|
||||
return new EditshipCollection((DataCollection) get(EDITORS));
|
||||
}
|
||||
|
||||
public void addEditor(final GenericPerson editor,
|
||||
final Date from,
|
||||
final Date to) {
|
||||
Assert.exists(editor, GenericPerson.class);
|
||||
|
||||
final DataObject link = add(EDITORS, editor.getGenericPersonBundle());
|
||||
|
||||
link.set(EDITOR_FROM, from);
|
||||
link.set(EDITOR_TO, to);
|
||||
link.set(EDITOR_ORDER, Integer.valueOf((int) getEditors().size()));
|
||||
|
||||
link.save();
|
||||
}
|
||||
|
||||
public void removeEditor(final GenericPerson editor) {
|
||||
Assert.exists(editor, GenericPerson.class);
|
||||
|
||||
remove(EDITORS, editor.getGenericPersonBundle());
|
||||
}
|
||||
|
||||
public VolumeInSeriesCollection getVolumes() {
|
||||
return new VolumeInSeriesCollection((DataCollection) get(PUBLICATIONS));
|
||||
}
|
||||
|
||||
public void addVolume(final Publication publication,
|
||||
final Integer volume) {
|
||||
Assert.exists(publication, Publication.class);
|
||||
|
||||
DataObject link = add(PUBLICATIONS, publication.getPublicationBundle());
|
||||
|
||||
link.set(VOLUME_OF_SERIES, volume);
|
||||
}
|
||||
|
||||
public void removeVolume(Publication publication) {
|
||||
Assert.exists(publication, Publication.class);
|
||||
remove(PUBLICATIONS, publication.getPublicationBundle());
|
||||
}
|
||||
}
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.domain.DomainCollection;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -51,15 +52,13 @@ public class VolumeInSeriesCollection extends DomainCollection {
|
|||
link.set(VOLUME_OF_SERIES, volumeOfSeries);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the current data object. Because the class
|
||||
* {@link Publication} is abstract, it is not possible to create the
|
||||
* real object here. The caller must check the type of the data object
|
||||
* and create an real object from the returned data object.
|
||||
*
|
||||
* @return The current data object.
|
||||
*/
|
||||
public Publication getPublication() {
|
||||
return new Publication(m_dataCollection.getDataObject());
|
||||
final PublicationBundle bundle = (PublicationBundle) DomainObjectFactory.newInstance(m_dataCollection.getDataObject());
|
||||
return (Publication) bundle.getPrimaryInstance();
|
||||
}
|
||||
|
||||
public Publication getPublication(final String language) {
|
||||
final PublicationBundle bundle = (PublicationBundle) DomainObjectFactory.newInstance(m_dataCollection.getDataObject());
|
||||
return (Publication) bundle.getInstance(language);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,13 +9,11 @@ import com.arsdigita.bebop.event.FormSectionEvent;
|
|||
import com.arsdigita.bebop.parameters.DateParameter;
|
||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
import com.arsdigita.bebop.util.GlobalizationUtil;
|
||||
import com.arsdigita.cms.ContentBundle;
|
||||
import com.arsdigita.cms.ContentPage;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.ContentType;
|
||||
import com.arsdigita.cms.Folder;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitBundle;
|
||||
import com.arsdigita.cms.contenttypes.Publisher;
|
||||
import com.arsdigita.cms.contenttypes.PublisherBundle;
|
||||
import com.arsdigita.cms.ui.authoring.ApplyWorkflowFormSection;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.FormData;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.cms.ContentPage;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.Folder;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.SeriesBundle;
|
||||
import com.arsdigita.cms.ui.authoring.CreationSelector;
|
||||
import com.arsdigita.cms.ui.authoring.PageCreate;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SeriesCreate extends PageCreate {
|
||||
|
||||
public SeriesCreate(final ItemSelectionModel itemModel,
|
||||
final CreationSelector parent) {
|
||||
super(itemModel, parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(final FormSectionEvent fse) throws FormProcessException {
|
||||
final FormData data = fse.getFormData();
|
||||
final PageState state = fse.getPageState();
|
||||
final ContentSection section = m_parent.getContentSection(state);
|
||||
final Folder folder = m_parent.getFolder(state);
|
||||
|
||||
final ContentPage item = createContentPage(state);
|
||||
item.setLanguage((String) data.get(LANGUAGE));
|
||||
item.setName((String) data.get(NAME));
|
||||
item.setTitle((String) data.get(TITLE));
|
||||
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||
item.setLaunchDate((Date) data.get(LAUNCH_DATE));
|
||||
}
|
||||
|
||||
final SeriesBundle bundle = new SeriesBundle(item);
|
||||
bundle.setParent(folder);
|
||||
bundle.setContentSection(section);
|
||||
bundle.save();
|
||||
|
||||
m_workflowSection.applyWorkflow(state, item);
|
||||
|
||||
m_parent.editItem(state, item);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue