Bugfixes for edit step of CollectedVolumeAsset

pull/1/head
Jens Pelzetter 2022-05-31 20:28:25 +02:00
parent 4e03986d45
commit 8d1baa0b58
12 changed files with 103 additions and 48 deletions

View File

@ -111,7 +111,7 @@ public class Publication implements Serializable {
@OneToMany( @OneToMany(
cascade = CascadeType.ALL, cascade = CascadeType.ALL,
fetch = FetchType.LAZY, fetch = FetchType.LAZY,
mappedBy = "author", mappedBy = "publication",
orphanRemoval = true orphanRemoval = true
) )
@OrderBy("authorOrder") @OrderBy("authorOrder")

View File

@ -12,6 +12,7 @@ import org.librecms.contentsection.privileges.ItemPrivileges;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.UUID;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.inject.Inject; import javax.inject.Inject;
@ -79,7 +80,6 @@ public class PublicationManager {
final Publication toPublication, final Publication toPublication,
final boolean asEditor, final boolean asEditor,
final int atPosition) { final int atPosition) {
Objects.requireNonNull(person); Objects.requireNonNull(person);
Objects.requireNonNull(toPublication); Objects.requireNonNull(toPublication);
if (atPosition < 0) { if (atPosition < 0) {
@ -106,6 +106,7 @@ public class PublicationManager {
// Create authorship relation // Create authorship relation
final long numberOfAuthors = toPublication.getAuthorships().size(); final long numberOfAuthors = toPublication.getAuthorships().size();
final Authorship authorship = new Authorship(); final Authorship authorship = new Authorship();
authorship.setUuid(UUID.randomUUID().toString());
authorship.setAuthor(person); authorship.setAuthor(person);
authorship.setPublication(toPublication); authorship.setPublication(toPublication);
authorship.setEditor(asEditor); authorship.setEditor(asEditor);

View File

@ -6,9 +6,11 @@
package org.scientificcms.publications.assets; package org.scientificcms.publications.assets;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
import org.librecms.assets.AssetType;
import org.librecms.contentsection.Asset; import org.librecms.contentsection.Asset;
import org.librecms.ui.contentsections.assets.MvcAssetEditKit; import org.librecms.ui.contentsections.assets.MvcAssetEditKit;
import org.scientificcms.publications.CollectedVolume; import org.scientificcms.publications.CollectedVolume;
import org.scientificcms.publications.SciPublicationsConstants;
import org.scientificcms.publications.ui.assets.CollectedVolumeAssetCreateStep; import org.scientificcms.publications.ui.assets.CollectedVolumeAssetCreateStep;
import org.scientificcms.publications.ui.assets.CollectedVolumeAssetEditStep; import org.scientificcms.publications.ui.assets.CollectedVolumeAssetEditStep;
@ -29,6 +31,12 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
@Entity @Entity
@Table(name = "COLLECTED_VOLUME_ASSETS", schema = DB_SCHEMA) @Table(name = "COLLECTED_VOLUME_ASSETS", schema = DB_SCHEMA)
@Audited @Audited
@AssetType(
labelBundle = SciPublicationsConstants.BUNDLE,
labelKey = "collectedvolume.label",
descriptionBundle = SciPublicationsConstants.BUNDLE,
descriptionKey = "collectedvolume.description"
)
@MvcAssetEditKit( @MvcAssetEditKit(
createStep = CollectedVolumeAssetCreateStep.class, createStep = CollectedVolumeAssetCreateStep.class,
editStep = CollectedVolumeAssetEditStep.class editStep = CollectedVolumeAssetEditStep.class

View File

@ -6,8 +6,10 @@
package org.scientificcms.publications.assets; package org.scientificcms.publications.assets;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
import org.librecms.assets.AssetType;
import org.librecms.contentsection.Asset; import org.librecms.contentsection.Asset;
import org.scientificcms.publications.Proceedings; import org.scientificcms.publications.Proceedings;
import org.scientificcms.publications.SciPublicationsConstants;
import java.util.Objects; import java.util.Objects;
@ -26,6 +28,12 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
@Entity @Entity
@Table(name = "PROCEEDINGS_ASSETS", schema = DB_SCHEMA) @Table(name = "PROCEEDINGS_ASSETS", schema = DB_SCHEMA)
@Audited @Audited
@AssetType(
labelBundle = SciPublicationsConstants.BUNDLE,
labelKey = "proceedings.label",
descriptionBundle = SciPublicationsConstants.BUNDLE,
descriptionKey = "proceedings.description"
)
public class ProceedingsAsset extends Asset { public class ProceedingsAsset extends Asset {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@ -33,9 +33,9 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
@Audited @Audited
@AssetType( @AssetType(
labelBundle = SciPublicationsConstants.BUNDLE, labelBundle = SciPublicationsConstants.BUNDLE,
labelKey = "journal.label", labelKey = "series.label",
descriptionBundle = SciPublicationsConstants.BUNDLE, descriptionBundle = SciPublicationsConstants.BUNDLE,
descriptionKey = "journal.description" descriptionKey = "series.description"
) )
@MvcAssetEditKit( @MvcAssetEditKit(
createStep = SeriesAssetCreateStep.class, createStep = SeriesAssetCreateStep.class,

View File

@ -7,6 +7,7 @@ import org.libreccm.security.AuthorizationRequired;
import org.libreccm.ui.BaseUrl; import org.libreccm.ui.BaseUrl;
import org.librecms.assets.Person; import org.librecms.assets.Person;
import org.librecms.assets.PersonRepository; import org.librecms.assets.PersonRepository;
import org.librecms.contentsection.Asset;
import org.librecms.contentsection.AssetRepository; import org.librecms.contentsection.AssetRepository;
import org.librecms.ui.contentsections.AssetPermissionsChecker; import org.librecms.ui.contentsections.AssetPermissionsChecker;
import org.librecms.ui.contentsections.ContentSectionNotFoundException; import org.librecms.ui.contentsections.ContentSectionNotFoundException;
@ -26,6 +27,7 @@ import org.scientificcms.publications.Publisher;
import org.scientificcms.publications.PublisherManager; import org.scientificcms.publications.PublisherManager;
import org.scientificcms.publications.PublisherRepository; import org.scientificcms.publications.PublisherRepository;
import org.scientificcms.publications.assets.CollectedVolumeAsset; import org.scientificcms.publications.assets.CollectedVolumeAsset;
import org.scientificcms.publications.assets.PublisherAsset;
import org.scientificcms.publications.assets.SeriesAsset; import org.scientificcms.publications.assets.SeriesAsset;
import org.scientificcms.publications.ui.SciPublicationsUiConstants; import org.scientificcms.publications.ui.SciPublicationsUiConstants;
@ -299,9 +301,9 @@ public class CollectedVolumeAssetEditStep extends AbstractMvcAssetEditStep {
if (numberOfVolumesParam != null) { if (numberOfVolumesParam != null) {
if (numberOfVolumesParam.isBlank()) { if (numberOfVolumesParam.isBlank()) {
collectedVolume.setVolume(null); collectedVolume.setNumberOfVolumes(null);
} else { } else {
collectedVolume.setVolume( collectedVolume.setNumberOfVolumes(
Integer.parseInt(numberOfVolumesParam) Integer.parseInt(numberOfVolumesParam)
); );
} }
@ -398,7 +400,7 @@ public class CollectedVolumeAssetEditStep extends AbstractMvcAssetEditStep {
} }
@POST @POST
@Path("/shortdescription/@add") @Path("/shortdescription/add")
@AuthorizationRequired @AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
public String addShortDescription( public String addShortDescription(
@ -563,7 +565,8 @@ public class CollectedVolumeAssetEditStep extends AbstractMvcAssetEditStep {
} }
final Person author = authorResult.get(); final Person author = authorResult.get();
final boolean editor = "true".equals(editorParam); final boolean editor = "true".equals(editorParam)
|| "on".equals(editorParam);
publicationManager.addAuthor(author, getCollectedVolume(), editor); publicationManager.addAuthor(author, getCollectedVolume(), editor);
return buildRedirectPathForStep(); return buildRedirectPathForStep();
@ -614,7 +617,10 @@ public class CollectedVolumeAssetEditStep extends AbstractMvcAssetEditStep {
} }
final Authorship authorship = authorshipResult.get(); final Authorship authorship = authorshipResult.get();
authorship.setEditor("true".equals(editorParam)); authorship.setEditor(
"true".equals(editorParam)
|| "on".equals(editorParam)
);
publicationRepo.save(collectedVolume); publicationRepo.save(collectedVolume);
@ -703,31 +709,35 @@ public class CollectedVolumeAssetEditStep extends AbstractMvcAssetEditStep {
final Identifier identifier = identifierParser.parseIdentifier( final Identifier identifier = identifierParser.parseIdentifier(
publisherIdentifier publisherIdentifier
); );
final Optional<Publisher> publisherResult; final Optional<PublisherAsset> assetResult;
switch (identifier.getType()) { switch (identifier.getType()) {
case ID: case ID:
publisherResult = publisherRepo.findById( assetResult = assetRepo.findById(
Long.parseLong(identifier.getIdentifier()) Long.parseLong(identifier.getIdentifier()),
PublisherAsset.class
); );
break; break;
case UUID: case UUID:
publisherResult = publisherRepo.findByUuid( assetResult = assetRepo.findByUuidAndType(
identifier.getIdentifier() identifier.getIdentifier(),
PublisherAsset.class
); );
break; break;
default: { default: {
final List<Publisher> result = publisherRepo.findByName( final Optional<Asset> result = assetRepo.findByPath(
identifier.getIdentifier() identifier.getIdentifier()
); );
if (result == null || result.isEmpty()) { if (result == null || result.isEmpty()) {
publisherResult = Optional.empty(); assetResult = Optional.empty();
} else if (!(result.get() instanceof PublisherAsset)) {
assetResult = Optional.empty();
} else { } else {
publisherResult = Optional.of(result.get(0)); assetResult = Optional.of((PublisherAsset) result.get());
} }
break; break;
} }
} }
if (!publisherResult.isPresent()) { if (!assetResult.isPresent()) {
return showPublisherNotFound( return showPublisherNotFound(
sectionIdentifier, sectionIdentifier,
assetPath, assetPath,
@ -735,7 +745,7 @@ public class CollectedVolumeAssetEditStep extends AbstractMvcAssetEditStep {
); );
} }
final Publisher publisher = publisherResult.get(); final Publisher publisher = assetResult.get().getPublisher();
publisherManager.addPublicationToPublisher( publisherManager.addPublicationToPublisher(
getCollectedVolume(), getCollectedVolume(),

View File

@ -104,13 +104,15 @@
<c:forEach items="#{SciCmsCollectedVolumeAssetEditStepModel.authors}" <c:forEach items="#{SciCmsCollectedVolumeAssetEditStepModel.authors}"
var="author"> var="author">
<tr class="collectedvolume-author" <tr class="collectedvolume-author"
id="#{author.id}" id="#{author.authorshipId}"
data-id="#{author.authorshipId}"> data-id="#{author.authorshipId}">
<td> <td>
<button class="btn btn-secondary cms-sort-handle mr-2" <button class="btn btn-secondary cms-sort-handle mr-2"
type="button"> type="button">
#{author.authorName} <bootstrap:svgIcon icon="arrows-move" />
<span class="sr-only">#{SciPublicationsUiMessageBundle['collectedvolume.editstep.authors.move']}</span>
</button> </button>
#{author.authorName}
</td> </td>
<td> <td>
<c:choose> <c:choose>
@ -125,7 +127,7 @@
<td> <td>
<button class="btn btn-secondary" <button class="btn btn-secondary"
data-toggle="modal" data-toggle="modal"
data-target="authorship-edit-#{author.authorshipUuid}" data-target="#authorship-edit-#{author.authorshipUuid}"
type="button"> type="button">
<bootstrap:svgIcon icon="pen" /> <bootstrap:svgIcon icon="pen" />
<span class="sr-only"> <span class="sr-only">
@ -155,7 +157,7 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<bootstrap:formCheck <bootstrap:formCheck
checked="#{author.editor ? 'checked' : ''}" checked="#{author.editor}"
inputId="#{author.authorshipUuid}-editor" inputId="#{author.authorshipUuid}-editor"
label="#{SciPublicationsUiMessageBundle['collectedvolume.editstep.authors.editdialog.editor.label']}" label="#{SciPublicationsUiMessageBundle['collectedvolume.editstep.authors.editdialog.editor.label']}"
name="editor" name="editor"
@ -166,11 +168,11 @@
<button class="btn btn-warning" <button class="btn btn-warning"
data-dismiss="modal" data-dismiss="modal"
type="button"> type="button">
{SciPublicationsUiMessageBundle['collectedvolume.editstep.authors.editdialog.cancel']} #{SciPublicationsUiMessageBundle['collectedvolume.editstep.authors.editdialog.cancel']}
</button> </button>
<button class="btn btn-success" <button class="btn btn-success"
type="submit"> type="submit">
{SciPublicationsUiMessageBundle['collectedvolume.editstep.authors.editdialog.submit']} #{SciPublicationsUiMessageBundle['collectedvolume.editstep.authors.editdialog.submit']}
</button> </button>
</div> </div>
</form> </form>
@ -222,15 +224,17 @@
#{SciCmsCollectedVolumeAssetEditStepModel.publisherName} #{SciCmsCollectedVolumeAssetEditStepModel.publisherName}
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
<c:if test="#{SciCmsCollectedVolumeAssetEditStepModel.publisherUuid != null}">
<libreccm:deleteDialog <libreccm:deleteDialog
actionTarget="#{mvc.basePath}/#{ContentSectionModel.sectionName}/assets/#{CmsSelectedAssetModel.assetPath}/@collectedvolume-edit/publisher/@remove" actionTarget="#{mvc.basePath}/#{ContentSectionModel.sectionName}/assets/#{CmsSelectedAssetModel.assetPath}/@collectedvolume-edit/publisher/@remove"
buttonText="#{SciPublicationsUiMessageBundle['collectedvolume.editstep.publisher.remove.label']}" buttonText="#{SciPublicationsUiMessageBundle['collectedvolume.editstep.publisher.remove.label']}"
cancelLabel="#{SciPublicationsUiMessageBundle['collectedvolume.editstep.publisher.cancel']}" cancelLabel="#{SciPublicationsUiMessageBundle['collectedvolume.editstep.publisher.cancel']}"
confirmLabel="#{SciPublicationsUiMessageBundle['collectedvolume.editstep.publisher.confirm']}" confirmLabel="#{SciPublicationsUiMessageBundle['collectedvolume.editstep.publisher.confirm']}"
dialogId="publisher.remove" dialogId="publisher-remove"
dialogTitle="#{SciPublicationsUiMessageBundle['collectedvolume.editstep.publisher.title']}" dialogTitle="#{SciPublicationsUiMessageBundle['collectedvolume.editstep.publisher.title']}"
message="#{SciPublicationsUiMessageBundle['collectedvolume.editstep.publisher.message']}" message="#{SciPublicationsUiMessageBundle['collectedvolume.editstep.publisher.message']}"
/> />
</c:if>
</p> </p>
<h3>#{SciPublicationsUiMessageBundle['collectedvolume.editstep.properties']}</h3> <h3>#{SciPublicationsUiMessageBundle['collectedvolume.editstep.properties']}</h3>
@ -284,10 +288,10 @@
/> />
<bootstrap:formGroupNumber <bootstrap:formGroupNumber
help="#{SciPublicationsUiMessageBundle['collectedvolume.editstep.properties.numberofvolume.help']}" help="#{SciPublicationsUiMessageBundle['collectedvolume.editstep.properties.numberofvolumes.help']}"
inputId="numberOfVolume" inputId="numberOfVolumes"
label="#{SciPublicationsUiMessageBundle['collectedvolume.editstep.properties.numberofvolume.label']}" label="#{SciPublicationsUiMessageBundle['collectedvolume.editstep.properties.numberofvolumes.label']}"
name="numberOfVolume" name="numberOfVolumes"
value="#{SciCmsCollectedVolumeAssetEditStepModel.numberOfVolumes}" value="#{SciCmsCollectedVolumeAssetEditStepModel.numberOfVolumes}"
/> />
</div> </div>
@ -315,7 +319,7 @@
<dd>#{SciCmsCollectedVolumeAssetEditStepModel.volume}</dd> <dd>#{SciCmsCollectedVolumeAssetEditStepModel.volume}</dd>
</div> </div>
<div> <div>
<dt>#{SciPublicationsUiMessageBundle['collectedvolume.editstep.properties.numberofvolume.label']}</dt> <dt>#{SciPublicationsUiMessageBundle['collectedvolume.editstep.properties.numberofvolumes.label']}</dt>
<dd>#{SciCmsCollectedVolumeAssetEditStepModel.numberOfVolumes}</dd> <dd>#{SciCmsCollectedVolumeAssetEditStepModel.numberOfVolumes}</dd>
</div> </div>
</dl> </dl>

View File

@ -0,0 +1,10 @@
series.label=Series
publisher.label=Publisher
series.description=A series of publication.
publisher.description=A publisher.
journal.label=Journal
journal.description=A journal.
proceedings.label=Proceedings
proceedings.description=Proceedings of conference or an other event.
collectedvolume.label=Collected Volume
collectedvolume.description=A collected volume.

View File

@ -0,0 +1,10 @@
series.label=Reihe
publisher.label=Verlag
series.description=Eine Publikations-Reihe.
publisher.description=Ein Verlag.
journal.label=Zeitschrift
journal.description=Eine Zeitschrift
proceedings.label=Tagungsband
proceedings.description=Tagungs (Proceedings) einer Konferenz oder \u00e4hnlichen Veranstaltung.
collectedvolume.label=Sammelband
collectedvolume.description=Ein Sammelband.

View File

@ -137,8 +137,8 @@ collectedvolume.editstep.properties.yearofpublication.help=The year of publicati
collectedvolume.editstep.properties.yearofpublication.label=Year of publication collectedvolume.editstep.properties.yearofpublication.label=Year of publication
collectedvolume.editstep.properties.volume.help=The volume of the publication. collectedvolume.editstep.properties.volume.help=The volume of the publication.
collectedvolume.editstep.properties.volume.label=Volume collectedvolume.editstep.properties.volume.label=Volume
collectedvolume.editstep.properties.numberofvolume.help=The number of volumes of the publication. collectedvolume.editstep.properties.numberofvolumes.help=The number of volumes of the publication.
collectedvolume.editstep.properties.numberofvolume.label=Number of volumes collectedvolume.editstep.properties.numberofvolumes.label=Number of volumes
collectedvolume.editstep.properties.edit.submit=Save collectedvolume.editstep.properties.edit.submit=Save
collectedvolume.editstep.shortdescription.add.label=Add localized description collectedvolume.editstep.shortdescription.add.label=Add localized description
collectedvolume.editstep.shortdescription.add.cancel=Cancel collectedvolume.editstep.shortdescription.add.cancel=Cancel
@ -162,3 +162,5 @@ collectedvolume.editstep.shortdescription.remove.title=Confirm removal of locali
collectedvolume.editstep.shortdescription.title=Description collectedvolume.editstep.shortdescription.title=Description
collectedvolume.createform.yearofpublication.label=Year of publication collectedvolume.createform.yearofpublication.label=Year of publication
createstep.title.error.missing=No title for the collected volume was provided. createstep.title.error.missing=No title for the collected volume was provided.
authors.order.save=Save order
collectedvolume.editstep.authors.move=Sort authors

View File

@ -137,8 +137,8 @@ collectedvolume.editstep.properties.yearofpublication.help=Das Erscheinungsjahr
collectedvolume.editstep.properties.yearofpublication.label=Erscheinungsjahr collectedvolume.editstep.properties.yearofpublication.label=Erscheinungsjahr
collectedvolume.editstep.properties.volume.help=Der Band der Publikation. collectedvolume.editstep.properties.volume.help=Der Band der Publikation.
collectedvolume.editstep.properties.volume.label=Band collectedvolume.editstep.properties.volume.label=Band
collectedvolume.editstep.properties.numberofvolume.help=Die Anzahl der B\u00e4nde der Publikation. collectedvolume.editstep.properties.numberofvolumes.help=Die Anzahl der B\u00e4nde der Publikation.
collectedvolume.editstep.properties.numberofvolume.label=Anzahl der B\u00e4nde collectedvolume.editstep.properties.numberofvolumes.label=Anzahl der B\u00e4nde
collectedvolume.editstep.properties.edit.submit=Speichern collectedvolume.editstep.properties.edit.submit=Speichern
collectedvolume.editstep.shortdescription.add.label=Lokaliserte Beschreibung hinzuf\u00fcgen collectedvolume.editstep.shortdescription.add.label=Lokaliserte Beschreibung hinzuf\u00fcgen
collectedvolume.editstep.shortdescription.add.cancel=Abbrechen collectedvolume.editstep.shortdescription.add.cancel=Abbrechen
@ -162,3 +162,5 @@ collectedvolume.editstep.shortdescription.remove.title=Entfernen einer lokaliser
collectedvolume.editstep.shortdescription.title=Beschreibung collectedvolume.editstep.shortdescription.title=Beschreibung
collectedvolume.createform.yearofpublication.label=Erscheinungsjahr collectedvolume.createform.yearofpublication.label=Erscheinungsjahr
createstep.title.error.missing=Es wurde kein Titel f\u00fcr den Sammelband angegeben. createstep.title.error.missing=Es wurde kein Titel f\u00fcr den Sammelband angegeben.
authors.order.save=Sortierung speichern
collectedvolume.editstep.authors.move=Autoren sortieren

View File

@ -67,7 +67,7 @@ function saveOrder() {
} }
const headers = new Headers(); const headers = new Headers();
headers.append("Cotent-Type", "application/json"); headers.append("Content-Type", "application/json");
fetch(saveUrl, { fetch(saveUrl, {
credentials: "include", credentials: "include",
body: JSON.stringify(authorsSortable.toArray()), body: JSON.stringify(authorsSortable.toArray()),
@ -125,7 +125,7 @@ function saveOrder() {
function showGeneralError(): void { function showGeneralError(): void {
const alertTemplate = document.querySelector( const alertTemplate = document.querySelector(
"authors-sort-error-general" "#authors-sort-error-general"
) as HTMLTemplateElement; ) as HTMLTemplateElement;
const alert = alertTemplate.content.cloneNode(true) as Element; const alert = alertTemplate.content.cloneNode(true) as Element;
@ -137,7 +137,7 @@ function showGeneralError(): void {
function showSaveError(): void { function showSaveError(): void {
const alertTemplate = document.querySelector( const alertTemplate = document.querySelector(
"authors-sort-error-save" "#authors-sort-error-save"
) as HTMLTemplateElement; ) as HTMLTemplateElement;
const alert = alertTemplate.content.cloneNode(true) as Element; const alert = alertTemplate.content.cloneNode(true) as Element;