Additional authoring steps for Collected Volume and Article in Collected

Volume (Java Part)
pull/1/head
Jens Pelzetter 2022-07-21 20:24:26 +02:00
parent 03ac3cbd95
commit 6c0986d70b
9 changed files with 705 additions and 12 deletions

View File

@ -8,7 +8,13 @@ package org.scientificcms.publications.contenttypes;
import org.hibernate.envers.Audited;
import org.librecms.contenttypes.ContentTypeDescription;
import org.librecms.ui.contentsections.documents.MvcAuthoringKit;
import org.scientificcms.publications.ArticleInCollectedVolume;
import org.scientificcms.publications.ui.contenttypes.ArticleInCollectedVolumeExtendedPropertiesStep;
import org.scientificcms.publications.ui.contenttypes.ArticleInCollectedVolumeItemCreateStep;
import org.scientificcms.publications.ui.contenttypes.ArticleInCollectedVolumePropertiesStep;
import org.scientificcms.publications.ui.contenttypes.PublicationAbstractStep;
import org.scientificcms.publications.ui.contenttypes.PublicationMiscStep;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -26,6 +32,15 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
labelBundle = "org.scientificcms.publications.contenttypes.ArticleInCollectedVolume",
descriptionBundle = "org.scientificcms.publications.contenttypes.ArticleInCollectedVolume"
)
@MvcAuthoringKit(
createStep = ArticleInCollectedVolumeItemCreateStep.class,
authoringSteps = {
ArticleInCollectedVolumePropertiesStep.class,
ArticleInCollectedVolumeExtendedPropertiesStep.class,
PublicationAbstractStep.class,
PublicationMiscStep.class
}
)
public class ArticleInCollectedVolumeItem
extends PublicationItem<ArticleInCollectedVolume> {

View File

@ -5,10 +5,15 @@
*/
package org.scientificcms.publications.contenttypes;
import org.hibernate.envers.Audited;
import org.librecms.contenttypes.ContentTypeDescription;
import org.librecms.ui.contentsections.documents.MvcAuthoringKit;
import org.scientificcms.publications.CollectedVolume;
import org.scientificcms.publications.ui.contenttypes.CollectedVolumeExtendedPropertiesStep;
import org.scientificcms.publications.ui.contenttypes.CollectedVolumeItemCreateStep;
import org.scientificcms.publications.ui.contenttypes.CollectedVolumePropertiesStep;
import org.scientificcms.publications.ui.contenttypes.PublicationAbstractStep;
import org.scientificcms.publications.ui.contenttypes.PublicationMiscStep;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -24,7 +29,17 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
@Audited
@ContentTypeDescription(
labelBundle = "org.scientificcms.publications.contenttypes.CollectedVolume",
descriptionBundle = "org.scientificcms.publications.contenttypes.CollectedVolume"
descriptionBundle
= "org.scientificcms.publications.contenttypes.CollectedVolume"
)
@MvcAuthoringKit(
createStep = CollectedVolumeItemCreateStep.class,
authoringSteps = {
CollectedVolumePropertiesStep.class,
CollectedVolumeExtendedPropertiesStep.class,
PublicationAbstractStep.class,
PublicationMiscStep.class
}
)
public class CollectedVolumeItem
extends PublicationWithPublisherItem<CollectedVolume> {
@ -48,7 +63,6 @@ public class CollectedVolumeItem
// protected void setPublication(final CollectedVolume collectedVolume) {
// this.collectedVolume = collectedVolume;
// }
@Override
public int hashCode() {
int hash = super.hashCode();
@ -89,5 +103,4 @@ return other.canEqual(this);
// Objects.toString(collectedVolume),
// data));
// }
}

View File

@ -0,0 +1,55 @@
package org.scientificcms.publications.ui.contenttypes;
import org.libreccm.l10n.GlobalizationHelper;
import org.scientificcms.publications.ArticleInCollectedVolume;
import org.scientificcms.publications.contenttypes.ArticleInCollectedVolumeItem;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
@Named("SciPublicationsArticleInCollectedVolumeCreateStep")
public class ArticleInCollectedVolumeItemCreateStep
extends AbstractPublicationItemCreateStep<ArticleInCollectedVolumeItem, ArticleInCollectedVolume>{
@Inject
private GlobalizationHelper globalizationHelper;
@Override
public String getDocumentType() {
return ArticleInCollectedVolumeItem.class.getName();
}
@Override
public String getDescription() {
return globalizationHelper
.getLocalizedTextsUtil(getBundle())
.getText("articleincollectedvolumeitem.createstep.description");
}
@Override
public String showCreateStep() {
return "org/scientificcms/contenttypes/ui/articleincollectedvolume/create-articleincollectedvolume.xhtml";
}
@Override
public Class<ArticleInCollectedVolumeItem> getPublicationItemClass() {
return ArticleInCollectedVolumeItem.class;
}
@Override
public ArticleInCollectedVolume createPublication() {
return new ArticleInCollectedVolume();
}
@Override
protected String getEditStepName() {
return ArticleInCollectedVolumePropertiesStep.EDIT_STEP_URL_FRAGMENT;
}
}

View File

@ -0,0 +1,499 @@
package org.scientificcms.publications.ui.contenttypes;
import org.libreccm.api.Identifier;
import org.libreccm.api.IdentifierParser;
import org.libreccm.l10n.GlobalizationHelper;
import org.libreccm.security.AuthorizationRequired;
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
import org.librecms.ui.contentsections.ItemPermissionChecker;
import org.librecms.ui.contentsections.documents.DocumentNotFoundException;
import org.librecms.ui.contentsections.documents.DocumentUi;
import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef;
import org.librecms.ui.contentsections.documents.MvcAuthoringSteps;
import org.scientificcms.publications.ArticleInCollectedVolume;
import org.scientificcms.publications.ArticleInCollectedVolumeManager;
import org.scientificcms.publications.CollectedVolume;
import org.scientificcms.publications.PublicationRepository;
import org.scientificcms.publications.contenttypes.ArticleInCollectedVolumeItem;
import org.scientificcms.publications.ui.SciPublicationsUiConstants;
import org.scientificcms.publications.ui.SciPublicationsUiMessageBundle;
import java.util.Optional;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.mvc.Controller;
import javax.mvc.Models;
import javax.transaction.Transactional;
import javax.ws.rs.DefaultValue;
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;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
@Path(
MvcAuthoringSteps.PATH_PREFIX
+ ArticleInCollectedVolumePropertiesStep.EDIT_STEP_URL_FRAGMENT
)
@Controller
@MvcAuthoringStepDef(
bundle = SciPublicationsUiConstants.BUNDLE,
descriptionKey = "authoringsteps.basicproperties.description",
labelKey = "authoringsteps.basicproperties.label",
supportedDocumentType = ArticleInCollectedVolumeItem.class
)
public class ArticleInCollectedVolumePropertiesStep
extends AbstractPublicationPropertiesStep<ArticleInCollectedVolumeItem, ArticleInCollectedVolume> {
public static final String EDIT_STEP_URL_FRAGMENT
= "articleincollectedvolume";
@Inject
private ArticleInCollectedVolumeManager articleManager;
@Inject
private DocumentUi documentUi;
@Inject
private GlobalizationHelper globalizationHelper;
@Inject
private IdentifierParser identifierParser;
@Inject
private ItemPermissionChecker itemPermissionChecker;
@Inject
private Models models;
@Inject
private ArticleInCollectedVolumePropertiesStepModel propertiesStepModel;
@Inject
private PublicationRepository publicationRepo;
@Inject
private SciPublicationsUiMessageBundle messageBundle;
@Override
public Class<ArticleInCollectedVolumePropertiesStep> getStepClass() {
return ArticleInCollectedVolumePropertiesStep.class;
}
@Override
protected String getEditStepUrlFragment() {
return EDIT_STEP_URL_FRAGMENT;
}
@Override
protected String getStepTemplatePath() {
return "org/scientificcms/contenttypes/ui/articleincollectedvolume/edit-articleincollectedvolume.xhtml";
}
@Override
public Class<ArticleInCollectedVolume> getPublicationClass() {
return ArticleInCollectedVolume.class;
}
@Override
@Transactional(Transactional.TxType.REQUIRED)
protected void init() throws ContentSectionNotFoundException,
DocumentNotFoundException {
super.init();
propertiesStepModel.setChapter(getPublication().getChapter());
propertiesStepModel.setCollectedVolumeTitle(
globalizationHelper.getValueFromLocalizedString(
getPublication().getTitle())
);
propertiesStepModel.setEndPage(getPublication().getEndPage());
propertiesStepModel.setStartPage(getPublication().getStartPage());
}
@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("/name")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
@Override
public String updateName(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
final String documentPath,
@FormParam("name") @DefaultValue("")
final String name
) {
return super.updateName(sectionIdentifier, documentPath, name);
}
@POST
@Path("/title/@add")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
@Override
public String addTitle(
@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.addTitle(
sectionIdentifier,
documentPath,
localeParam,
value
);
}
@POST
@Path("/title/@edit/{locale}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
@Override
public String editTitle(
@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.editTitle(
sectionIdentifier,
documentPath,
localeParam,
value
);
}
@POST
@Path("/title/@remove/{locale}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
@Override
public String removeTitle(
@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.removeTitle(sectionIdentifier, documentPath, localeParam);
}
@POST
@Path("/shortdescription/@add")
@Transactional(Transactional.TxType.REQUIRED)
@Override
public String addShortDescription(
@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.addShortDescription(
sectionIdentifier,
documentPath,
localeParam,
value
);
}
@POST
@Path("/shortdescription/@edit/{locale}")
@Transactional(Transactional.TxType.REQUIRED)
@Override
public String editShortDescription(
@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.editShortDescription(
sectionIdentifier,
documentPath,
localeParam,
value
);
}
@POST
@Path("/shortdescription/@remove/{locale}")
@Transactional(Transactional.TxType.REQUIRED)
@Override
public String removeShortDescription(
@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.removeShortDescription(
sectionIdentifier,
documentPath,
localeParam
);
}
@POST
@Path("/authors")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
@Override
public String addAuthor(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
final String documentPath,
@FormParam("authorIdentifier")
final String authorIdentifier,
@FormParam("editor")
final String editorParam
) {
return super.addAuthor(
sectionIdentifier,
documentPath,
authorIdentifier,
editorParam
);
}
@POST
@Path("/authors/{authorshipUuid}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
@Override
public String editAuthorship(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
final String documentPath,
@PathParam("authorshipUuid")
final String authorshipUuid,
@FormParam("editor")
final String editorParam
) {
return super.editAuthorship(
sectionIdentifier,
documentPath,
authorshipUuid,
editorParam
);
}
@POST
@Path("/authors/{authorshipUuid}/remove")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
@Override
public String removeAuthorship(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
final String documentPath,
@PathParam("authorshipUuid")
final String authorshipUuid
) {
return super.removeAuthorship(
sectionIdentifier,
documentPath,
authorshipUuid
);
}
@POST
@Path("/collectedvolume")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public String setCollectedVolume(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
final String documentPath,
@FormParam("collectedVolumeIdentifier")
final String collectedVolumeIdentifier
) {
try {
init();
} catch (ContentSectionNotFoundException ex) {
return ex.showErrorMessage();
} catch (DocumentNotFoundException ex) {
return ex.showErrorMessage();
}
if (itemPermissionChecker.canEditItem(getDocument())) {
final Identifier identifier = identifierParser.parseIdentifier(
collectedVolumeIdentifier
);
final Optional<CollectedVolume> collectedVolumeResult;
switch (identifier.getType()) {
case ID:
collectedVolumeResult = publicationRepo.findByIdAndType(
Long.parseLong(identifier.getIdentifier()),
CollectedVolume.class
);
break;
case UUID:
collectedVolumeResult = publicationRepo
.findByUuidAndType(
identifier.getIdentifier(),
CollectedVolume.class
);
break;
default:
collectedVolumeResult = Optional.empty();
break;
}
if (collectedVolumeResult.isEmpty()) {
return showCollectedVolumeNotFound(
sectionIdentifier,
documentPath,
collectedVolumeIdentifier
);
}
final CollectedVolume collectedVolume = collectedVolumeResult.get();
articleManager.setCollectedVolume(
getPublication(),
collectedVolume
);
return buildRedirectPathForStep();
} else {
return documentUi.showAccessDenied(
getContentSection(),
getDocument(),
getLabel()
);
}
}
@POST
@Path("/collectedvolume/remove")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public String removeArticle(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
final String documentPath
) {
try {
init();
} catch (ContentSectionNotFoundException ex) {
return ex.showErrorMessage();
} catch (DocumentNotFoundException ex) {
return ex.showErrorMessage();
}
if (itemPermissionChecker.canEditItem(getDocument())) {
articleManager.unsetCollectedVolume(getPublication());
return buildRedirectPathForStep();
} else {
return documentUi.showAccessDenied(
getContentSection(),
getDocument(),
getLabel()
);
}
}
@POST()
@Path("/properties")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public String updateProperties(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
final String documentPath,
@FormParam("yearOfPublication")
final String yearOfPublicationParam,
@FormParam("reviewed")
final String reviewedParam,
@FormParam("chapter")
final String chapter,
@FormParam("startPage")
final String startPageParam,
@FormParam("endPage")
final String endPageParam
) {
try {
init();
} catch (ContentSectionNotFoundException ex) {
return ex.showErrorMessage();
} catch (DocumentNotFoundException ex) {
return ex.showErrorMessage();
}
if (itemPermissionChecker.canEditItem(getDocument())) {
updateProperties(
sectionIdentifier,
documentPath,
yearOfPublicationParam
);
getPublication().setChapter(chapter);
if (endPageParam.matches("\\d*")) {
getPublication().setEndPage(
Integer.parseInt(endPageParam)
);
}
if (startPageParam.matches("\\d*")) {
getPublication().setStartPage(
Integer.parseInt(startPageParam)
);
}
return buildRedirectPathForStep();
} else {
return documentUi.showAccessDenied(
getContentSection(),
getDocument(),
messageBundle.getMessage("publication.edit.denied")
);
}
}
private String showCollectedVolumeNotFound(
final String sectionIdentifier,
final String documentPath,
final String collectedVolumeIdentifier
) {
models.put("articleNotFound", collectedVolumeIdentifier);
return showStep(sectionIdentifier, documentPath);
}
}

View File

@ -0,0 +1,54 @@
package org.scientificcms.publications.ui.contenttypes;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
@Named("SciCmsArticleInCollectedVolumePropertiesStepModel")
public class ArticleInCollectedVolumePropertiesStepModel {
private String collectedVolumeTitle;
private Integer startPage;
private Integer endPage;
private String chapter;
public String getCollectedVolumeTitle() {
return collectedVolumeTitle;
}
public void setCollectedVolumeTitle(final String collectedVolumeTitle) {
this.collectedVolumeTitle = collectedVolumeTitle;
}
public Integer getStartPage() {
return startPage;
}
public void setStartPage(final Integer startPage) {
this.startPage = startPage;
}
public Integer getEndPage() {
return endPage;
}
public void setEndPage(final Integer endPage) {
this.endPage = endPage;
}
public String getChapter() {
return chapter;
}
public void setChapter(final String chapter) {
this.chapter = chapter;
}
}

View File

@ -0,0 +1,55 @@
package org.scientificcms.publications.ui.contenttypes;
import org.libreccm.l10n.GlobalizationHelper;
import org.scientificcms.publications.CollectedVolume;
import org.scientificcms.publications.contenttypes.CollectedVolumeItem;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
@Named("SciPublicationsCollecetedVolumeCreateStep")
public class CollectedVolumeItemCreateStep
extends AbstractPublicationWithPublisherItemCreateStep<CollectedVolumeItem, CollectedVolume> {
@Inject
private GlobalizationHelper globalizationHelper;
@Override
public String getDocumentType() {
return CollectedVolumeItem.class.getName();
}
@Override
public String getDescription() {
return globalizationHelper
.getLocalizedTextsUtil(getBundle())
.getText("collectedvolume.createstep.description");
}
@Override
public String showCreateStep() {
return "org/scientificcms/contenttypes/ui/collectedvolue/create-collectedvolume.xhtml";
}
@Override
public Class<CollectedVolumeItem> getPublicationItemClass() {
return CollectedVolumeItem.class;
}
@Override
public CollectedVolume createPublication() {
return new CollectedVolume();
}
@Override
protected String getEditStepName() {
return CollectedVolumePropertiesStep.EDIT_STEP_URL_FRAGMENT;
}
}

View File

@ -62,6 +62,11 @@ public class MonographPropertiesStep extends AbstractPublicationWithPublisherPro
return "monograph-basicproperties";
}
@Override
protected String getStepTemplatePath() {
return "org/scientificcms/contenttypes/ui/monograph/edit-monograph.xhtml";
}
@Override
public Class<Monograph> getPublicationClass() {
return Monograph.class;
@ -110,8 +115,6 @@ public class MonographPropertiesStep extends AbstractPublicationWithPublisherPro
return super.updateName(sectionIdentifier, documentPath, name);
}
@POST
@Path("/title/@add")
@AuthorizationRequired
@ -327,11 +330,6 @@ public class MonographPropertiesStep extends AbstractPublicationWithPublisherPro
return super.removePublisher(sectionIdentifier, documentPath);
}
@Override
protected String getStepTemplatePath() {
return "org/scientificcms/contenttypes/ui/monograph/edit-monograph.xhtml";
}
@POST()
@Path("/properties")
@AuthorizationRequired

View File

@ -429,3 +429,5 @@ publicationpicker.select=Select
publicationpicker.column.name=Name
publicationpicker.column.type=Type
publicationpicker.column.action=Action
articleincollectedvolumeitem.createstep.description=Create a new article in a collected volume.
collectedvolume.createstep.description=Create a new collected volume.

View File

@ -429,3 +429,5 @@ publicationpicker.select=Ausw\u00e4hlen
publicationpicker.column.name=Name
publicationpicker.column.type=Typ
publicationpicker.column.action=Aktion
articleincollectedvolumeitem.createstep.description=Einen neuen Sammelbandartikel anlegen.
collectedvolume.createstep.description=Einen neuen Sammelband anlegen.