Some bugfixes

pull/1/head
Jens Pelzetter 2022-06-30 20:06:47 +02:00
parent a5325c2c2e
commit 995d3ed63a
6 changed files with 170 additions and 37 deletions

View File

@ -60,9 +60,24 @@ public abstract class AbstractPublicationExtentedPropertiesStep<T extends Public
}
protected P getPublication() {
return getPublicationItem().getPublication();
final long publicationId = getPublicationItem()
.getPublication()
.getPublicationId();
return publicationRepo
.findByIdAndType(publicationId, getPublicationClass())
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"PublicationItem %s has no associated publication",
getPublicationItem().getUuid()
)
)
);
}
protected abstract Class<P> getPublicationClass();
@Override
@Transactional(Transactional.TxType.REQUIRED)
protected void init() throws ContentSectionNotFoundException,
@ -81,9 +96,16 @@ public abstract class AbstractPublicationExtentedPropertiesStep<T extends Public
final P publication = getPublication();
propertiesStepModel.setLanguageOfPublication(
publication.getLanguageOfPublication().toString()
Optional
.ofNullable(publication.getLanguageOfPublication())
.map(lang -> lang.toString())
.orElse(null)
);
propertiesStepModel.setPeerReviewed(
Optional
.ofNullable(publication.getPeerReviewed())
.orElse(false)
);
propertiesStepModel.setPeerReviewed(publication.getPeerReviewed());
propertiesStepModel.setVolumeInSeries(
publication
.getSeries()
@ -92,12 +114,12 @@ public abstract class AbstractPublicationExtentedPropertiesStep<T extends Public
.collect(Collectors.toList())
);
propertiesStepModel.setYearFirstPublished(
publication.getYearFirstPublished()
Optional
.ofNullable(publication.getYearFirstPublished())
.orElse(null)
);
}
@GET
@Path("/")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public String showStep(
@ -170,7 +192,7 @@ public abstract class AbstractPublicationExtentedPropertiesStep<T extends Public
final P publication = getPublication();
if (languageOfPublication != null) {
publication.setLanguageOfPublication(languageOfPublication);
publication.setLanguageOfPublication(languageOfPublication);
}
publication.setPeerReviewed(peerReviewed);

View File

@ -94,8 +94,6 @@ public abstract class AbstractPublicationWithPublisherExtendedPropertiesStep<T e
);
}
@POST
@Path("/properties")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public String updateProperties(
@ -179,8 +177,6 @@ public abstract class AbstractPublicationWithPublisherExtendedPropertiesStep<T e
}
}
@POST
@Path("/edition/@add")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public String addEditionValue(
@ -215,8 +211,6 @@ public abstract class AbstractPublicationWithPublisherExtendedPropertiesStep<T e
}
}
@POST
@Path("/edition/@edit/{locale}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public String editEditionValue(
@ -251,8 +245,6 @@ public abstract class AbstractPublicationWithPublisherExtendedPropertiesStep<T e
}
}
@POST
@Path("/edition/@remove/{locale}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public String removeEditionValue(

View File

@ -1,5 +1,6 @@
package org.scientificcms.publications.ui.contenttypes;
import org.libreccm.security.AuthorizationRequired;
import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef;
import org.librecms.ui.contentsections.documents.MvcAuthoringSteps;
import org.scientificcms.publications.Monograph;
@ -8,7 +9,12 @@ import org.scientificcms.publications.ui.SciPublicationsUiConstants;
import javax.enterprise.context.RequestScoped;
import javax.mvc.Controller;
import javax.transaction.Transactional;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
/**
*
@ -30,9 +36,122 @@ public class MonographExtendedPropertiesStep extends AbstractPublicationWithPubl
return MonographExtendedPropertiesStep.class;
}
@Override
protected Class<Monograph> getPublicationClass() {
return Monograph.class;
}
@Override
protected String getStepTemplatePath() {
return "/org/scientificcms/contenttypes/monograph/ui/edit-extended.xhtml";
return "org/scientificcms/contenttypes/ui/monograph/edit-extended-properties.xhtml";
}
@GET
@Path("/")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
@Override
public String showStep(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
final String documentPath
) {
return super.showStep(sectionIdentifier, documentPath);
}
@POST
@Path("/properties")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
@Override
public String updateProperties(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
final String documentPath,
@FormParam("languageOfPublication")
final String languageOfPublicationParam,
@FormParam("peerReviewed")
final String peerReviewedParam,
@FormParam("yearFirstPublished")
final String yearFirstPublishedParam,
@FormParam("isbn10")
final String isbn10,
@FormParam("isbn13")
final String isbn13,
@FormParam("numberOfPages")
final String numberOfPagesParam,
@FormParam("numberOfVolumes")
final String numberOfVolumesParam,
@FormParam("volume")
final String volumeParam
) {
return super.updateProperties(
sectionIdentifier,
documentPath,
languageOfPublicationParam,
peerReviewedParam,
yearFirstPublishedParam,
isbn10,
isbn13,
numberOfPagesParam,
numberOfVolumesParam,
volumeParam
);
}
@POST
@Path("/edition/@add")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
@Override
public String addEditionValue(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
final String documentPath,
@FormParam("locale") final String localeParam,
@FormParam("value") final String value
) {
return super.addEditionValue(
sectionIdentifier, documentPath, localeParam, value
);
}
@POST
@Path("/edition/@edit/{locale}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
@Override
public String editEditionValue(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
final String documentPath,
@PathParam("locale") final String localeParam,
@FormParam("value") final String value
) {
return super.editEditionValue(
sectionIdentifier, documentPath, localeParam, value
);
}
@POST
@Path("/edition/@remove/{locale}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
@Override
public String removeEditionValue(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
final String documentPath,
@PathParam("locale") final String localeParam
) {
return super.removeEditionValue(
sectionIdentifier, documentPath, localeParam
);
}
}

View File

@ -17,7 +17,7 @@ public class PublicationExtendedPropertiesStepModel {
private boolean peerReviewed;
private int yearFirstPublished;
private Integer yearFirstPublished;
private String languageOfPublication;
@ -31,11 +31,11 @@ public class PublicationExtendedPropertiesStepModel {
this.peerReviewed = peerReviewed;
}
public int getYearFirstPublished() {
public Integer getYearFirstPublished() {
return yearFirstPublished;
}
public void setYearFirstPublished(final int yearFirstPublished) {
public void setYearFirstPublished(final Integer yearFirstPublished) {
this.yearFirstPublished = yearFirstPublished;
}

View File

@ -21,11 +21,11 @@ public class PublicationWithPublisherExtendedPropertiesStepModel {
private String isbn13;
private int volume;
private Integer volume;
private int numberOfVolumes;
private Integer numberOfVolumes;
private int numberOfPages;
private Integer numberOfPages;
private Map<String, String> editionValues;
@ -47,27 +47,27 @@ public class PublicationWithPublisherExtendedPropertiesStepModel {
this.isbn13 = isbn13;
}
public int getVolume() {
public Integer getVolume() {
return volume;
}
public void setVolume(final int volume) {
public void setVolume(final Integer volume) {
this.volume = volume;
}
public int getNumberOfVolumes() {
public Integer getNumberOfVolumes() {
return numberOfVolumes;
}
public void setNumberOfVolumes(final int numberOfVolumes) {
public void setNumberOfVolumes(final Integer numberOfVolumes) {
this.numberOfVolumes = numberOfVolumes;
}
public int getNumberOfPages() {
public Integer getNumberOfPages() {
return numberOfPages;
}
public void setNumberOfPages(final int numberOfPages) {
public void setNumberOfPages(final Integer numberOfPages) {
this.numberOfPages = numberOfPages;
}

View File

@ -5,7 +5,7 @@
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:librecms="http://xmlns.jcp.org/jsf/composite/components/librecms"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="/WEB-INF/views/org/scientificcms/contenttypes/ui/edit-publication-with-publisher-extended-properties.xhtml">
<ui:composition template="/WEB-INF/views/org/scientificcms/contenttypes/ui/edit-publication-with-publisher-extented-properties.xhtml">
<ui:param name="authoringStep"
value="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@monograph-extendedproperties" />