Current status sci-publications. Warning: Does not compile
parent
3e4a3019d1
commit
9364e43bd2
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
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.FormInitListener;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.form.TextField;
|
||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.ui.assets.AssetSearchWidget;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.scientificcms.publications.SciPublicationsConfig;
|
||||
import org.scientificcms.publications.SciPublicationsConstants;
|
||||
import org.scientificcms.publications.contenttypes.PublicationItem;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class PublicationSeriesAddForm
|
||||
extends BasicItemForm
|
||||
implements FormProcessListener, FormInitListener {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(
|
||||
PublicationSeriesAddForm.class
|
||||
);
|
||||
|
||||
private static final String SERIES_SEARCH = "series";
|
||||
|
||||
private final static SciPublicationsConfig CONFIG = SciPublicationsConfig
|
||||
.getConfig();
|
||||
|
||||
private PublicationPropertiesStep step;
|
||||
|
||||
private AssetSearchWidget seriesSearchWidget;
|
||||
|
||||
private ItemSelectionModel itemModel;
|
||||
|
||||
private TextField volumeOfSeries;
|
||||
|
||||
public PublicationSeriesAddForm(final ItemSelectionModel itemModel,
|
||||
final StringParameter selectedLanguageParam) {
|
||||
super("SeriesEntryForm", itemModel, selectedLanguageParam);
|
||||
this.itemModel = itemModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWidgets() {
|
||||
|
||||
seriesSearchWidget = new AssetSearchWidget(
|
||||
SERIES_SEARCH,
|
||||
Series.class
|
||||
);
|
||||
seriesSearchWidget.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.series.select_series",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
add(seriesSearchWidget);
|
||||
|
||||
final ParameterModel volumeOfSeriesParam = new StringParameter(
|
||||
SciPublicationsController.VOLUME_OF_SERIES
|
||||
);
|
||||
volumeOfSeries = new TextField(volumeOfSeriesParam);
|
||||
volumeOfSeries.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.series.volume_of_series",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
add(volumeOfSeries);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FormSectionEvent event) throws FormProcessException {
|
||||
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
setVisible(state, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(final FormSectionEvent event)
|
||||
throws FormProcessException {
|
||||
|
||||
final FormData data = event.getFormData();
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
final PublicationItem<?> item
|
||||
= (PublicationItem<?>) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
|
||||
if (!(getSaveCancelSection().getCancelButton().isSelected(state))) {
|
||||
|
||||
Series series = (Series) data.get(ITEM_SEARCH);
|
||||
series = (Series) series.getContentBundle().getInstance(item.
|
||||
getLanguage());
|
||||
|
||||
item.addSeries(series, (String) data.get(
|
||||
VolumeInSeriesCollection.VOLUME_OF_SERIES));
|
||||
m_itemSearch.publishCreatedItem(data, series);
|
||||
}
|
||||
|
||||
init(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -117,7 +117,7 @@ public class Publication implements Serializable {
|
|||
joinTable = @JoinTable(name = "PUBLICATION_TITLES",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "OBJECT_ID")
|
||||
@JoinColumn(name = "PUBLICATION_ID")
|
||||
})
|
||||
)
|
||||
private LocalizedString title;
|
||||
|
|
@ -128,7 +128,7 @@ public class Publication implements Serializable {
|
|||
joinTable = @JoinTable(name = "PUBLICATION_SHORT_DESCS",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "OBJECT_ID")
|
||||
@JoinColumn(name = "PUBLICATION_ID")
|
||||
})
|
||||
)
|
||||
private LocalizedString shortDescription;
|
||||
|
|
@ -139,7 +139,7 @@ public class Publication implements Serializable {
|
|||
joinTable = @JoinTable(name = "PUBLICATION_ABSTRACTS",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "OBJECT_ID")
|
||||
@JoinColumn(name = "PUBLICATION_ID")
|
||||
})
|
||||
)
|
||||
private LocalizedString publicationAbstract;
|
||||
|
|
@ -150,7 +150,7 @@ public class Publication implements Serializable {
|
|||
joinTable = @JoinTable(name = "PUBLICATION_MISC",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "OBJECT_ID")
|
||||
@JoinColumn(name = "PUBLICATION_ID")
|
||||
})
|
||||
)
|
||||
private LocalizedString misc;
|
||||
|
|
@ -164,12 +164,16 @@ public class Publication implements Serializable {
|
|||
@Column(name = "LANGUAGE_OF_PUBLICATION")
|
||||
private Locale languageOfPublication;
|
||||
|
||||
@OneToMany(mappedBy = "publication")
|
||||
private List<VolumeInSeries> series;
|
||||
|
||||
public Publication() {
|
||||
authorships = new ArrayList<>();
|
||||
title = new LocalizedString();
|
||||
shortDescription = new LocalizedString();
|
||||
publicationAbstract = new LocalizedString();
|
||||
misc = new LocalizedString();
|
||||
series = new ArrayList<>();
|
||||
}
|
||||
|
||||
public long getPublicationId() {
|
||||
|
|
@ -276,6 +280,26 @@ public class Publication implements Serializable {
|
|||
this.languageOfPublication = languageOfPublication;
|
||||
}
|
||||
|
||||
public List<VolumeInSeries> getSeries() {
|
||||
if (series == null) {
|
||||
return null;
|
||||
} else {
|
||||
return Collections.unmodifiableList(series);
|
||||
}
|
||||
}
|
||||
|
||||
protected void addSeries(final VolumeInSeries series) {
|
||||
this.series.add(series);
|
||||
}
|
||||
|
||||
protected void removeSeries(final VolumeInSeries series) {
|
||||
this.series.remove(series);
|
||||
}
|
||||
|
||||
protected void setSeries(final List<VolumeInSeries> series) {
|
||||
this.series = series;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
|
|
|
|||
|
|
@ -309,4 +309,41 @@ public class PublicationManager {
|
|||
publicationRepository.save(publication);
|
||||
}
|
||||
|
||||
@AuthorizationRequired
|
||||
@RequiresPrivilege(ItemPrivileges.EDIT)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public void addSeries(
|
||||
final Series series,
|
||||
final Publication publication,
|
||||
final String volumeInSeries
|
||||
) {
|
||||
Objects.requireNonNull(series);
|
||||
Objects.requireNonNull(publication);
|
||||
|
||||
final boolean alreadyAdded = publication
|
||||
.getSeries()
|
||||
.stream()
|
||||
.map(VolumeInSeries::getSeries)
|
||||
.anyMatch(obj -> obj.equals(series));
|
||||
|
||||
if (alreadyAdded) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"Publication %s is already a volume of series %s.",
|
||||
Objects.toString(publication),
|
||||
Objects.toString(series)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
final VolumeInSeries volume = new VolumeInSeries();
|
||||
volume.setPublication(publication);
|
||||
volume.setSeries(series);
|
||||
volume.setVolumeOfSeries(volumeInSeries);
|
||||
publication.addSeries(volume);
|
||||
series.addVolume(volumeInSeries);
|
||||
seriesRepository.save(series);
|
||||
publicationRepository.save(publication);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,205 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.scientificcms.publications;
|
||||
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.persistence.AssociationOverride;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "SERIES", schema = DB_SCHEMA)
|
||||
@Audited
|
||||
@NamedQueries({})
|
||||
public class Series implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@Column(name = "SERIES_ID")
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long seriesId;
|
||||
|
||||
@Column(name = "UUID", unique = true, nullable = false)
|
||||
private String uuid;
|
||||
|
||||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(
|
||||
name = "SERIES_TITLES",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "SERIES_ID")
|
||||
}
|
||||
)
|
||||
)
|
||||
private LocalizedString title;
|
||||
|
||||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(
|
||||
name = "SERIES_DESCRIPTIONS",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "SERIES_ID")
|
||||
}
|
||||
)
|
||||
)
|
||||
private LocalizedString description;
|
||||
|
||||
@OneToMany(mappedBy = "series")
|
||||
private List<VolumeInSeries> volumes;
|
||||
|
||||
public Series() {
|
||||
title = new LocalizedString();
|
||||
description = new LocalizedString();
|
||||
volumes = new ArrayList<>();
|
||||
}
|
||||
|
||||
public long getSeriesId() {
|
||||
return seriesId;
|
||||
}
|
||||
|
||||
protected void setSeriesId(final long seriesId) {
|
||||
this.seriesId = seriesId;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
protected void setUuid(final String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public LocalizedString getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(final LocalizedString title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public LocalizedString getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(final LocalizedString description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public List<VolumeInSeries> getVolumes() {
|
||||
if (volumes == null) {
|
||||
return null;
|
||||
} else {
|
||||
return Collections.unmodifiableList(volumes);
|
||||
}
|
||||
}
|
||||
|
||||
protected void addVolume(final VolumeInSeries volume) {
|
||||
volumes.add(volume);
|
||||
}
|
||||
|
||||
protected void removeVolume(final VolumeInSeries volume) {
|
||||
volumes.remove(volume);
|
||||
}
|
||||
|
||||
protected void setVolumes(final List<VolumeInSeries> volumes) {
|
||||
this.volumes = new ArrayList<>(volumes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 71 * hash + (int) (seriesId ^ (seriesId >>> 32));
|
||||
hash = 71 * hash + Objects.hashCode(uuid);
|
||||
hash = 71 * hash + Objects.hashCode(title);
|
||||
hash = 71 * hash + Objects.hashCode(description);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof Series)) {
|
||||
return false;
|
||||
}
|
||||
final Series other = (Series) obj;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
if (seriesId != other.getSeriesId()) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(uuid, other.getUuid())) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(title, other.getTitle())) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(description, other.getDescription());
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object obj) {
|
||||
return obj instanceof Series;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return toString("");
|
||||
}
|
||||
|
||||
public String toString(final String data) {
|
||||
|
||||
return String.format(
|
||||
"%s{ "
|
||||
+ "seriesId = %d, "
|
||||
+ "uuid = %s, "
|
||||
+ "title = %s, "
|
||||
+ "description = %s, "
|
||||
+ "volumes = %s%s"
|
||||
+ " }",
|
||||
super.toString(),
|
||||
seriesId,
|
||||
uuid,
|
||||
Objects.toString(title),
|
||||
Objects.toString(description),
|
||||
Objects.toString(volumes),
|
||||
data
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.scientificcms.publications;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "VOLUMES_IN_SERIES", schema = DB_SCHEMA)
|
||||
public class VolumeInSeries implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@Column(name = "VOLUME_ID")
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long volumeId;
|
||||
|
||||
@Column(name = "UUID", unique = true, nullable = false)
|
||||
private String uuid;
|
||||
|
||||
@Column(name = "VOLUME_OF_SERIES")
|
||||
private String volumeOfSeries;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "PUBLICATION_ID")
|
||||
private Publication publication;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "SERIES_ID")
|
||||
private Series series;
|
||||
|
||||
public long getVolumeId() {
|
||||
return volumeId;
|
||||
}
|
||||
|
||||
protected void setVolumeId(long volumeId) {
|
||||
this.volumeId = volumeId;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
protected void setUuid(final String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getVolumeOfSeries() {
|
||||
return volumeOfSeries;
|
||||
}
|
||||
|
||||
public void setVolumeOfSeries(final String volumeOfSeries) {
|
||||
this.volumeOfSeries = volumeOfSeries;
|
||||
}
|
||||
|
||||
public Publication getPublication() {
|
||||
return publication;
|
||||
}
|
||||
|
||||
protected void setPublication(final Publication publication) {
|
||||
this.publication = publication;
|
||||
}
|
||||
|
||||
public Series getSeries() {
|
||||
return series;
|
||||
}
|
||||
|
||||
protected void setSeries(final Series series) {
|
||||
this.series = series;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 3;
|
||||
hash = 29 * hash + (int) (volumeId ^ (volumeId >>> 32));
|
||||
hash = 29 * hash + Objects.hashCode(uuid);
|
||||
hash = 29 * hash + Objects.hashCode(volumeOfSeries);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof VolumeInSeries)) {
|
||||
return false;
|
||||
}
|
||||
final VolumeInSeries other = (VolumeInSeries) obj;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
if (volumeId != other.getVolumeId()) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(uuid, other.getUuid())) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(volumeOfSeries, other.getVolumeOfSeries());
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object obj) {
|
||||
return obj instanceof VolumeInSeries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return toString("");
|
||||
}
|
||||
|
||||
public String toString(final String data) {
|
||||
return String.format(
|
||||
"%s{ "
|
||||
+ "volumeId = %d, "
|
||||
+ "uuid = %s, "
|
||||
+ "volumeInSeries = \"%s\"%s"
|
||||
+ " }",
|
||||
super.toString(),
|
||||
volumeId,
|
||||
uuid,
|
||||
volumeOfSeries,
|
||||
data
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.scientificcms.publications.assets;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@Entity
|
||||
public class SeriesAsset {
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue