Authoring steps for GreyLiteratureItem part I
parent
0fbd762c19
commit
716d660ac5
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -57,14 +57,12 @@ public class ExpertisePropertiesStep
|
|||
@Inject
|
||||
private AssetRepository assetRepo;
|
||||
|
||||
@Inject
|
||||
private DocumentUi documentUi;
|
||||
|
||||
@Inject
|
||||
private ExpertisePropertiesStepModel propertiesStepModel;
|
||||
|
||||
@Inject
|
||||
private GlobalizationHelper globalizationHelper;
|
||||
|
||||
@Inject
|
||||
private IdentifierParser identifierParser;
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@Named("SciPublicationsGreyLiteratureCreateStep")
|
||||
public class GreyLiteratureItemCreateStep
|
||||
extends AbstractPublicationItemCreateStep<GreyLiteratureItem, GreyLiterature> {
|
||||
|
||||
@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<GreyLiteratureItem> getPublicationItemClass() {
|
||||
return GreyLiteratureItem.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GreyLiterature createPublication() {
|
||||
return new GreyLiterature();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEditStepName() {
|
||||
return GreyLiteraturePropertiesStep.EDIT_STEP_URL_FRAGMENT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@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<GreyLiteratureItem, GreyLiterature> {
|
||||
|
||||
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<GreyLiteraturePropertiesStep> 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<GreyLiterature> 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")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
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("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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
<!DOCTYPE html [<!ENTITY times '×'>]>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:bootstrap="http://xmlns.jcp.org/jsf/composite/components/bootstrap"
|
||||
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
|
||||
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
|
||||
<ui:composition template="/WEB-INF/views/org/scientificcms/contenttypes/ui/create-publication.xhtml">
|
||||
|
||||
<ui:param name="availableLocales"
|
||||
value="#{SciPublicationsGreyLiteratureCreateStep.availableLocales}"
|
||||
/>
|
||||
|
||||
<ui:param name="availableWorkflows"
|
||||
value="#{SciPublicationsGreyLiteratureCreateStep.availableWorkflows}" />
|
||||
|
||||
<ui:param name="contentSection"
|
||||
value="#{SciPublicationsGreyLiteratureCreateStep.contentSectionLabel}" />
|
||||
|
||||
<ui:param name="createFormSubmitLabel"
|
||||
value="#{SciPublicationsUiMessageBundle['greyliterature.createform.submit']}" />
|
||||
|
||||
<ui:param name="documentType"
|
||||
value="#{SciPublicationsGreyLiteratureCreateStep.documentType}" />
|
||||
|
||||
<ui:param name="folderPath"
|
||||
value="#{SciPublicationsGreyLiteratureCreateStep.folderPath}" />
|
||||
|
||||
<ui:param name="initialLocale"
|
||||
value="#{SciPublicationsGreyLiteratureCreateStep.initialLocale}" />
|
||||
|
||||
<ui:param name="messages"
|
||||
value="#{SciPublicationsGreyLiteratureCreateStep.messages}" />
|
||||
|
||||
<ui:param name="nameValue"
|
||||
value="#{SciPublicationsGreyLiteratureCreateStep.name}" />
|
||||
|
||||
<ui:param name="publicationCreateStepTitle"
|
||||
value="#{SciPublicationsUiMessageBundle['greyliterature.createform.title']}" />
|
||||
|
||||
<ui:param name="selectedWorkflow"
|
||||
value="#{SciPublicationsGreyLiteratureCreateStep.selectedWorkflow}" />
|
||||
|
||||
<ui:param name="title"
|
||||
value="#{SciPublicationsGreyLiteratureCreateStep.title}" />
|
||||
|
||||
</ui:composition>
|
||||
|
||||
</html>
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue