diff --git a/sci-publications/src/main/java/org/scientificcms/publications/GreyLiterature.java b/sci-publications/src/main/java/org/scientificcms/publications/GreyLiterature.java index b79cbda..4f248e2 100644 --- a/sci-publications/src/main/java/org/scientificcms/publications/GreyLiterature.java +++ b/sci-publications/src/main/java/org/scientificcms/publications/GreyLiterature.java @@ -1,8 +1,3 @@ -/* - * 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; diff --git a/sci-publications/src/main/java/org/scientificcms/publications/ui/contenttypes/ExpertisePropertiesStep.java b/sci-publications/src/main/java/org/scientificcms/publications/ui/contenttypes/ExpertisePropertiesStep.java index 6c5cffe..dc919dd 100644 --- a/sci-publications/src/main/java/org/scientificcms/publications/ui/contenttypes/ExpertisePropertiesStep.java +++ b/sci-publications/src/main/java/org/scientificcms/publications/ui/contenttypes/ExpertisePropertiesStep.java @@ -52,19 +52,17 @@ public class ExpertisePropertiesStep extends AbstractPublicationPropertiesStep { public static final String EDIT_STEP_URL_FRAGMENT - = "expertise-basicproperties"; + = "expertise-basicproperties"; @Inject private AssetRepository assetRepo; + @Inject private DocumentUi documentUi; @Inject private ExpertisePropertiesStepModel propertiesStepModel; - @Inject - private GlobalizationHelper globalizationHelper; - @Inject private IdentifierParser identifierParser; diff --git a/sci-publications/src/main/java/org/scientificcms/publications/ui/contenttypes/GreyLiteratureItemCreateStep.java b/sci-publications/src/main/java/org/scientificcms/publications/ui/contenttypes/GreyLiteratureItemCreateStep.java new file mode 100644 index 0000000..f2cc4a1 --- /dev/null +++ b/sci-publications/src/main/java/org/scientificcms/publications/ui/contenttypes/GreyLiteratureItemCreateStep.java @@ -0,0 +1,55 @@ +package org.scientificcms.publications.ui.contenttypes; + +import org.libreccm.l10n.GlobalizationHelper; +import org.scientificcms.publications.GreyLiterature; +import org.scientificcms.publications.contenttypes.GreyLiteratureItem; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("SciPublicationsGreyLiteratureCreateStep") +public class GreyLiteratureItemCreateStep + extends AbstractPublicationItemCreateStep { + + @Inject + private GlobalizationHelper globalizationHelper; + + @Override + public String getDocumentType() { + return GreyLiteratureItem.class.getName(); + } + + @Override + public String getDescription() { + return globalizationHelper + .getLocalizedTextsUtil(getBundle()) + .getText("greyliteratureitem.createstep.description"); + } + + @Override + public String showCreateStep() { + return "org/scientificcms/contenttypes/ui/greyliterature/create-greyliterature.xhtml"; + } + + @Override + public Class getPublicationItemClass() { + return GreyLiteratureItem.class; + } + + @Override + public GreyLiterature createPublication() { + return new GreyLiterature(); + } + + @Override + public String getEditStepName() { + return GreyLiteraturePropertiesStep.EDIT_STEP_URL_FRAGMENT; + } + +} diff --git a/sci-publications/src/main/java/org/scientificcms/publications/ui/contenttypes/GreyLiteraturePropertiesStep.java b/sci-publications/src/main/java/org/scientificcms/publications/ui/contenttypes/GreyLiteraturePropertiesStep.java new file mode 100644 index 0000000..66060a3 --- /dev/null +++ b/sci-publications/src/main/java/org/scientificcms/publications/ui/contenttypes/GreyLiteraturePropertiesStep.java @@ -0,0 +1,364 @@ +package org.scientificcms.publications.ui.contenttypes; + +import org.libreccm.api.IdentifierParser; +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.GreyLiterature; +import org.scientificcms.publications.PublicationRepository; +import org.scientificcms.publications.SciPublicationsConstants; +import org.scientificcms.publications.contenttypes.GreyLiteratureItem; +import org.scientificcms.publications.ui.SciPublicationsUiMessageBundle; + +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 Jens Pelzetter + */ +@RequestScoped +@Path( + MvcAuthoringSteps.PATH_PREFIX + + GreyLiteraturePropertiesStep.EDIT_STEP_URL_FRAGMENT +) +@Controller +@MvcAuthoringStepDef( + bundle = SciPublicationsConstants.BUNDLE, + descriptionKey = "authoringsteps.basicproperties.description", + labelKey = "authoringsteps.basicproperties.label", + supportedDocumentType = GreyLiteratureItem.class +) +public class GreyLiteraturePropertiesStep + extends AbstractPublicationPropertiesStep { + + public static final String EDIT_STEP_URL_FRAGMENT + = "grepliterature-basicproperties"; + + @Inject + private DocumentUi documentUi; + + @Inject + private GreyLiteraturePropertiesStepModel propertiesStepModel; + + @Inject + private IdentifierParser identifierParser; + + @Inject + private ItemPermissionChecker itemPermissionChecker; + + @Inject + private Models models; + + @Inject + private PublicationRepository publicationRepo; + + @Inject + private SciPublicationsUiMessageBundle messageBundle; + + @Override + public Class getStepClass() { + return GreyLiteraturePropertiesStep.class; + } + + @Override + protected String getEditStepUrlFragment() { + return EDIT_STEP_URL_FRAGMENT; + } + + @Override + protected String getStepTemplatePath() { + return "org/scientificcms/contenttypes/ui/greyliterature/edit-greyliterature.xhtml"; + } + + @Override + public Class getPublicationClass() { + return GreyLiterature.class; + } + + @Override + @Transactional(Transactional.TxType.REQUIRED) + protected void init() throws ContentSectionNotFoundException, + DocumentNotFoundException { + super.init(); + + 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("/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("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 + ); + + if (startPageParam.matches("\\d*")) { + getPublication().setStartPage(Integer.parseInt(startPageParam)); + } + + if (endPageParam.matches("\\d*")) { + getPublication().setEndPage(Integer.parseInt(endPageParam)); + } + + publicationRepo.save(getPublication()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDocument(), + messageBundle.getMessage("publication.edit.denied") + ); + } + } + +} diff --git a/sci-publications/src/main/java/org/scientificcms/publications/ui/contenttypes/GreyLiteraturePropertiesStepModel.java b/sci-publications/src/main/java/org/scientificcms/publications/ui/contenttypes/GreyLiteraturePropertiesStepModel.java new file mode 100644 index 0000000..6069895 --- /dev/null +++ b/sci-publications/src/main/java/org/scientificcms/publications/ui/contenttypes/GreyLiteraturePropertiesStepModel.java @@ -0,0 +1,34 @@ +package org.scientificcms.publications.ui.contenttypes; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("SciCmsGreyLiteraturePropertiesStepModel") +public class GreyLiteraturePropertiesStepModel { + + private int startPage; + + private int endPage; + + public int getStartPage() { + return startPage; + } + + public void setStartPage(final int startPage) { + this.startPage = startPage; + } + + public int getEndPage() { + return endPage; + } + + public void setEndPage(final int endPage) { + this.endPage = endPage; + } + +} diff --git a/sci-publications/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/ui/greyliterature/create-greyliterature.xhtml b/sci-publications/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/ui/greyliterature/create-greyliterature.xhtml new file mode 100644 index 0000000..693df3b --- /dev/null +++ b/sci-publications/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/ui/greyliterature/create-greyliterature.xhtml @@ -0,0 +1,48 @@ +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sci-publications/src/main/resources/org/scientificcms/publications/ui/SciPublicationsBundle.properties b/sci-publications/src/main/resources/org/scientificcms/publications/ui/SciPublicationsBundle.properties index 4580858..66a1dc8 100644 --- a/sci-publications/src/main/resources/org/scientificcms/publications/ui/SciPublicationsBundle.properties +++ b/sci-publications/src/main/resources/org/scientificcms/publications/ui/SciPublicationsBundle.properties @@ -590,3 +590,6 @@ experise.basicproperties.organization.confirm=Remove organization experise.basicproperties.organization.title=Confirm Removal of organization experise.basicproperties.organization.message=Are you sure to remove the organization {1} from the experise {0}? expertise.extendedproperties.header=Extended properties of Expertise {0} +greyliteratureitem.createstep.description=Creates a new grey literature publication item. +greyliterature.createform.title=Create a new grey literature item +greyliterature.createform.submit=Create grey literature publication diff --git a/sci-publications/src/main/resources/org/scientificcms/publications/ui/SciPublicationsBundle_de.properties b/sci-publications/src/main/resources/org/scientificcms/publications/ui/SciPublicationsBundle_de.properties index 59bb1ec..5caa34d 100644 --- a/sci-publications/src/main/resources/org/scientificcms/publications/ui/SciPublicationsBundle_de.properties +++ b/sci-publications/src/main/resources/org/scientificcms/publications/ui/SciPublicationsBundle_de.properties @@ -590,3 +590,6 @@ experise.basicproperties.organization.confirm=Organization entfernen experise.basicproperties.organization.title=Entfernen der Organization best\u00e4tigen experise.basicproperties.organization.message=Sind Sie sicher, dass Sie die Organisation {1} vom Gutachten {0} entfernen wollen? expertise.extendedproperties.header=Erweiterte Eigenschaften des Gutachtens {0} +greyliteratureitem.createstep.description=Erstellt eine neue "Graue Literatur"-Publikation +greyliterature.createform.title=Neue "Graue Literatur"-Publikation anlegen +greyliterature.createform.submit="Graue Literatur"-Publikation anlegen