More work on the authoring steps for publications.
parent
0cb2b814ff
commit
137d31bfc9
|
|
@ -0,0 +1,211 @@
|
||||||
|
package org.scientificcms.publications.ui.contenttypes;
|
||||||
|
|
||||||
|
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.AbstractMvcAuthoringStep;
|
||||||
|
import org.librecms.ui.contentsections.documents.DocumentNotFoundException;
|
||||||
|
import org.librecms.ui.contentsections.documents.DocumentUi;
|
||||||
|
import org.librecms.ui.contentsections.documents.MvcAuthoringSteps;
|
||||||
|
import org.scientificcms.publications.Publication;
|
||||||
|
import org.scientificcms.publications.PublicationRepository;
|
||||||
|
import org.scientificcms.publications.VolumeInSeries;
|
||||||
|
import org.scientificcms.publications.assets.PublicationAsset;
|
||||||
|
import org.scientificcms.publications.contenttypes.PublicationItem;
|
||||||
|
import org.scientificcms.publications.ui.SciPublicationsUiMessageBundle;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
* @param <T> Subtype of {@link PublicationAsset}.
|
||||||
|
* @param <P> Subtype of {@link Publication}
|
||||||
|
*/
|
||||||
|
public abstract class AbstractPublicationExtentedPropertiesStep<T extends PublicationItem<P>, P extends Publication>
|
||||||
|
extends AbstractMvcAuthoringStep {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private DocumentUi documentUi;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private GlobalizationHelper globalizationHelper;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ItemPermissionChecker itemPermissionChecker;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private PublicationExtendedPropertiesStepModel propertiesStepModel;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private PublicationRepository publicationRepo;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private SciPublicationsUiMessageBundle messageBundle;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
protected T getPublicationItem() {
|
||||||
|
return (T) getDocument();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected P getPublication() {
|
||||||
|
return getPublicationItem().getPublication();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
protected void init() throws ContentSectionNotFoundException,
|
||||||
|
DocumentNotFoundException {
|
||||||
|
super.init();
|
||||||
|
|
||||||
|
if (!(getDocument() instanceof PublicationItem)) {
|
||||||
|
throw new DocumentNotFoundException(
|
||||||
|
documentUi.showDocumentNotFound(
|
||||||
|
getContentSection(),
|
||||||
|
getDocumentPath()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
final P publication = getPublication();
|
||||||
|
|
||||||
|
propertiesStepModel.setLanguageOfPublication(
|
||||||
|
publication.getLanguageOfPublication().toString()
|
||||||
|
);
|
||||||
|
propertiesStepModel.setPeerReviewed(publication.getPeerReviewed());
|
||||||
|
propertiesStepModel.setVolumeInSeries(
|
||||||
|
publication
|
||||||
|
.getSeries()
|
||||||
|
.stream()
|
||||||
|
.map(this::buildVolumeInSeriesRow)
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
);
|
||||||
|
propertiesStepModel.setYearFirstPublished(
|
||||||
|
publication.getYearFirstPublished()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String showStep(
|
||||||
|
@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())) {
|
||||||
|
return getStepTemplatePath();
|
||||||
|
} else {
|
||||||
|
return documentUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getDocument(),
|
||||||
|
messageBundle.getMessage("publication.edit.denied")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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("languageOfPublication")
|
||||||
|
final String languageOfPublicationParam,
|
||||||
|
@FormParam("peerReviewed")
|
||||||
|
final String peerReviewedParam,
|
||||||
|
@FormParam("yearFirstPublished")
|
||||||
|
final String yearFirstPublishedParam
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
} catch (ContentSectionNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
} catch (DocumentNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemPermissionChecker.canEditItem(getDocument())) {
|
||||||
|
final Locale languageOfPublication = Optional
|
||||||
|
.ofNullable(languageOfPublicationParam)
|
||||||
|
.filter(param -> !param.isBlank())
|
||||||
|
.map(param -> new Locale(param))
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
final boolean peerReviewed = Optional
|
||||||
|
.ofNullable(peerReviewedParam)
|
||||||
|
.map(param -> "true".equals(param) || "on".equals(param))
|
||||||
|
.orElse(false);
|
||||||
|
|
||||||
|
final Integer yearFirstPublished = Optional
|
||||||
|
.ofNullable(yearFirstPublishedParam)
|
||||||
|
.filter(param -> !param.isBlank())
|
||||||
|
.filter(param -> param.matches("\\d*"))
|
||||||
|
.map(param -> Integer.parseInt(param))
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
final P publication = getPublication();
|
||||||
|
if (languageOfPublication != null) {
|
||||||
|
publication.setLanguageOfPublication(languageOfPublication);
|
||||||
|
}
|
||||||
|
publication.setPeerReviewed(peerReviewed);
|
||||||
|
|
||||||
|
if (yearFirstPublished != null) {
|
||||||
|
publication.setYearOfPublication(yearFirstPublished);
|
||||||
|
}
|
||||||
|
|
||||||
|
publicationRepo.save(publication);
|
||||||
|
|
||||||
|
return buildRedirectPathForStep();
|
||||||
|
} else {
|
||||||
|
return documentUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getDocument(),
|
||||||
|
messageBundle.getMessage("publication.edit.denied")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract String getStepTemplatePath();
|
||||||
|
|
||||||
|
private VolumeInSeriesRow buildVolumeInSeriesRow(
|
||||||
|
final VolumeInSeries volume
|
||||||
|
) {
|
||||||
|
final VolumeInSeriesRow row = new VolumeInSeriesRow();
|
||||||
|
row.setSeriesTitle(
|
||||||
|
globalizationHelper.getValueFromLocalizedString(
|
||||||
|
volume.getSeries().getTitle()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
row.setSeriesUuid(volume.getSeries().getUuid());
|
||||||
|
row.setVolumeInSeries(volume.getVolumeOfSeries());
|
||||||
|
row.setVolumeInSeriesUuid(volume.getUuid());
|
||||||
|
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -10,7 +10,6 @@ import org.librecms.contentsection.AssetRepository;
|
||||||
import org.librecms.contentsection.ContentItemRepository;
|
import org.librecms.contentsection.ContentItemRepository;
|
||||||
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
|
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
|
||||||
import org.librecms.ui.contentsections.ItemPermissionChecker;
|
import org.librecms.ui.contentsections.ItemPermissionChecker;
|
||||||
import org.librecms.ui.contentsections.assets.AssetNotFoundException;
|
|
||||||
import org.librecms.ui.contentsections.documents.AbstractMvcAuthoringStep;
|
import org.librecms.ui.contentsections.documents.AbstractMvcAuthoringStep;
|
||||||
import org.librecms.ui.contentsections.documents.DocumentNotFoundException;
|
import org.librecms.ui.contentsections.documents.DocumentNotFoundException;
|
||||||
import org.librecms.ui.contentsections.documents.DocumentUi;
|
import org.librecms.ui.contentsections.documents.DocumentUi;
|
||||||
|
|
@ -114,6 +113,10 @@ public abstract class AbstractPublicationPropertiesStep<T extends PublicationIte
|
||||||
|
|
||||||
propertiesStepModel.setName(item.getDisplayName());
|
propertiesStepModel.setName(item.getDisplayName());
|
||||||
|
|
||||||
|
propertiesStepModel.setYearOfPublication(
|
||||||
|
publication.getYearOfPublication()
|
||||||
|
);
|
||||||
|
|
||||||
final Set<Locale> titleLocales = publication
|
final Set<Locale> titleLocales = publication
|
||||||
.getTitle()
|
.getTitle()
|
||||||
.getAvailableLocales();
|
.getAvailableLocales();
|
||||||
|
|
@ -177,22 +180,6 @@ public abstract class AbstractPublicationPropertiesStep<T extends PublicationIte
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AuthorsTableRow buildAuthorsTableRow(final Authorship authorship) {
|
|
||||||
final AuthorsTableRow row = new AuthorsTableRow();
|
|
||||||
row.setAuthorName(
|
|
||||||
String.format(
|
|
||||||
"%s, %s",
|
|
||||||
authorship.getAuthor().getPersonName().getSurname(),
|
|
||||||
authorship.getAuthor().getPersonName().getGivenName()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
row.setAuthorshipId(authorship.getAuthorshipId());
|
|
||||||
row.setAuthorshipUuid(authorship.getUuid());
|
|
||||||
row.setEditor(authorship.isEditor());
|
|
||||||
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
|
|
@ -240,7 +227,8 @@ public abstract class AbstractPublicationPropertiesStep<T extends PublicationIte
|
||||||
final String sectionIdentifier,
|
final String sectionIdentifier,
|
||||||
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
|
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
|
||||||
final String documentPath,
|
final String documentPath,
|
||||||
@FormParam("name") @DefaultValue("") final String name
|
@FormParam("name") @DefaultValue("")
|
||||||
|
final String name
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
init();
|
init();
|
||||||
|
|
@ -272,6 +260,49 @@ public abstract class AbstractPublicationPropertiesStep<T extends PublicationIte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
} catch (ContentSectionNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
} catch (DocumentNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemPermissionChecker.canEditItem(getDocument())) {
|
||||||
|
final Integer yearOfPublication = Optional
|
||||||
|
.ofNullable(yearOfPublicationParam)
|
||||||
|
.filter(param -> param.isBlank())
|
||||||
|
.filter(param -> param.matches("\\d*"))
|
||||||
|
.map(param -> Integer.parseInt(param))
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
if (yearOfPublication != null) {
|
||||||
|
getPublication().setYearOfPublication(yearOfPublication);
|
||||||
|
publicationRepo.save(getPublication());
|
||||||
|
}
|
||||||
|
|
||||||
|
return buildRedirectPathForStep();
|
||||||
|
} else {
|
||||||
|
return documentUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getDocument(),
|
||||||
|
messageBundle.getMessage("publication.edit.denied")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a localized title of a publication.
|
* Updates a localized title of a publication.
|
||||||
*
|
*
|
||||||
|
|
@ -696,6 +727,22 @@ public abstract class AbstractPublicationPropertiesStep<T extends PublicationIte
|
||||||
|
|
||||||
protected abstract String getStepTemplatePath();
|
protected abstract String getStepTemplatePath();
|
||||||
|
|
||||||
|
private AuthorsTableRow buildAuthorsTableRow(final Authorship authorship) {
|
||||||
|
final AuthorsTableRow row = new AuthorsTableRow();
|
||||||
|
row.setAuthorName(
|
||||||
|
String.format(
|
||||||
|
"%s, %s",
|
||||||
|
authorship.getAuthor().getPersonName().getSurname(),
|
||||||
|
authorship.getAuthor().getPersonName().getGivenName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
row.setAuthorshipId(authorship.getAuthorshipId());
|
||||||
|
row.setAuthorshipUuid(authorship.getUuid());
|
||||||
|
row.setEditor(authorship.isEditor());
|
||||||
|
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
private String showAuthorNotFound(
|
private String showAuthorNotFound(
|
||||||
final String sectionIdentifier,
|
final String sectionIdentifier,
|
||||||
final String documentPath,
|
final String documentPath,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,149 @@
|
||||||
|
package org.scientificcms.publications.ui.contenttypes;
|
||||||
|
|
||||||
|
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.MvcAuthoringSteps;
|
||||||
|
import org.scientificcms.publications.PublicationRepository;
|
||||||
|
import org.scientificcms.publications.PublicationWithPublisher;
|
||||||
|
import org.scientificcms.publications.contenttypes.PublicationWithPublisherItem;
|
||||||
|
import org.scientificcms.publications.ui.SciPublicationsUiMessageBundle;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
import javax.ws.rs.FormParam;
|
||||||
|
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>
|
||||||
|
* @param <T> Subtype of {@link PublicationWithPublisherItem}
|
||||||
|
* @param <P> Subtype of {@link PublicationWithPublisher}.
|
||||||
|
*/
|
||||||
|
public abstract class AbstractPublicationWithPublisherExtendedPropertiesStep<T extends PublicationWithPublisherItem<P>, P extends PublicationWithPublisher>
|
||||||
|
extends AbstractPublicationExtentedPropertiesStep<T, P> {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private DocumentUi documentUi;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ItemPermissionChecker itemPermissionChecker;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private PublicationRepository publicationRepo;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private PublicationWithPublisherExtendedPropertiesStepModel propertiesStepModel;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private SciPublicationsUiMessageBundle messageBundle;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
protected void init() throws ContentSectionNotFoundException,
|
||||||
|
DocumentNotFoundException {
|
||||||
|
super.init();
|
||||||
|
|
||||||
|
final P publication = getPublication();
|
||||||
|
|
||||||
|
propertiesStepModel.setIsbn10(publication.getIsbn10());
|
||||||
|
propertiesStepModel.setIsbn13(publication.getIsbn13());
|
||||||
|
propertiesStepModel.setNumberOfPages(publication.getNumberOfPages());
|
||||||
|
propertiesStepModel.setNumberOfVolumes(
|
||||||
|
publication.getNumberOfVolumes()
|
||||||
|
);
|
||||||
|
propertiesStepModel.setVolume(publication.getVolume());
|
||||||
|
}
|
||||||
|
|
||||||
|
@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("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
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
} catch (ContentSectionNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
} catch (DocumentNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemPermissionChecker.canEditItem(getDocument())) {
|
||||||
|
super.updateProperties(
|
||||||
|
sectionIdentifier,
|
||||||
|
documentPath,
|
||||||
|
languageOfPublicationParam,
|
||||||
|
peerReviewedParam,
|
||||||
|
yearFirstPublishedParam
|
||||||
|
);
|
||||||
|
|
||||||
|
final P publication = getPublication();
|
||||||
|
|
||||||
|
publication.setIsbn10(isbn10);
|
||||||
|
publication.setIsbn13(isbn13);
|
||||||
|
|
||||||
|
final Integer numberOfPages = Optional
|
||||||
|
.ofNullable(numberOfPagesParam)
|
||||||
|
.filter(param -> param.matches("\\d*"))
|
||||||
|
.map(param -> Integer.parseInt(param))
|
||||||
|
.orElse(null);
|
||||||
|
publication.setNumberOfPages(numberOfPages);
|
||||||
|
|
||||||
|
final Integer numberOfVolumes = Optional
|
||||||
|
.ofNullable(numberOfVolumesParam)
|
||||||
|
.filter(param -> param.matches("\\d*"))
|
||||||
|
.map(param -> Integer.parseInt(param))
|
||||||
|
.orElse(null);
|
||||||
|
if (numberOfVolumes != null) {
|
||||||
|
publication.setNumberOfVolumes(numberOfVolumes);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Integer volume = Optional
|
||||||
|
.ofNullable(volumeParam)
|
||||||
|
.filter(param -> param.matches("\\d*"))
|
||||||
|
.map(param -> Integer.parseInt(param))
|
||||||
|
.orElse(null);
|
||||||
|
if (volume != null) {
|
||||||
|
publication.setVolume(volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
publicationRepo.save(publication);
|
||||||
|
|
||||||
|
return buildRedirectPathForStep();
|
||||||
|
} else {
|
||||||
|
return documentUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getDocument(),
|
||||||
|
messageBundle.getMessage("publication.edit.denied")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -6,7 +6,6 @@ import org.librecms.contentsection.Asset;
|
||||||
import org.librecms.contentsection.AssetRepository;
|
import org.librecms.contentsection.AssetRepository;
|
||||||
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
|
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
|
||||||
import org.librecms.ui.contentsections.ItemPermissionChecker;
|
import org.librecms.ui.contentsections.ItemPermissionChecker;
|
||||||
import org.librecms.ui.contentsections.documents.AbstractMvcAuthoringStep;
|
|
||||||
import org.librecms.ui.contentsections.documents.DocumentNotFoundException;
|
import org.librecms.ui.contentsections.documents.DocumentNotFoundException;
|
||||||
import org.librecms.ui.contentsections.documents.DocumentUi;
|
import org.librecms.ui.contentsections.documents.DocumentUi;
|
||||||
import org.librecms.ui.contentsections.documents.MvcAuthoringSteps;
|
import org.librecms.ui.contentsections.documents.MvcAuthoringSteps;
|
||||||
|
|
@ -31,7 +30,7 @@ import javax.ws.rs.PathParam;
|
||||||
* @param <T> Subtype of {@link PublicationWithPublisherItem}
|
* @param <T> Subtype of {@link PublicationWithPublisherItem}
|
||||||
* @param <P> Subtype of {@link PublicationWithPublisher}.
|
* @param <P> Subtype of {@link PublicationWithPublisher}.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractPublicationWithPublisherPropertiesStep<T extends PublicationItem<P>, P extends PublicationWithPublisher>
|
public abstract class AbstractPublicationWithPublisherPropertiesStep<T extends PublicationWithPublisherItem<P>, P extends PublicationWithPublisher>
|
||||||
extends AbstractPublicationPropertiesStep<T, P> {
|
extends AbstractPublicationPropertiesStep<T, P> {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
@ -55,8 +54,6 @@ public abstract class AbstractPublicationWithPublisherPropertiesStep<T extends P
|
||||||
@Inject
|
@Inject
|
||||||
private PublicationWithPublisherPropertiesStepModel propertiesStepModel;
|
private PublicationWithPublisherPropertiesStepModel propertiesStepModel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
protected void init() throws ContentSectionNotFoundException,
|
protected void init() throws ContentSectionNotFoundException,
|
||||||
|
|
@ -195,4 +192,5 @@ public abstract class AbstractPublicationWithPublisherPropertiesStep<T extends P
|
||||||
models.put("publisherNotFound", publisherIdentifier);
|
models.put("publisherNotFound", publisherIdentifier);
|
||||||
return super.showStep(sectionIdentifier, documentPath);
|
return super.showStep(sectionIdentifier, documentPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,27 @@
|
||||||
package org.scientificcms.publications.ui.contenttypes;
|
package org.scientificcms.publications.ui.contenttypes;
|
||||||
|
|
||||||
import org.librecms.contenttypes.Event;
|
import org.libreccm.security.AuthorizationRequired;
|
||||||
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
|
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.DocumentNotFoundException;
|
||||||
|
import org.librecms.ui.contentsections.documents.DocumentUi;
|
||||||
import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef;
|
import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef;
|
||||||
import org.librecms.ui.contentsections.documents.MvcAuthoringSteps;
|
import org.librecms.ui.contentsections.documents.MvcAuthoringSteps;
|
||||||
import org.librecms.ui.contenttypes.event.EventStepsConstants;
|
import org.librecms.ui.contenttypes.event.EventStepsConstants;
|
||||||
import org.scientificcms.publications.Monograph;
|
import org.scientificcms.publications.Monograph;
|
||||||
import org.scientificcms.publications.contenttypes.MonographItem;
|
import org.scientificcms.publications.contenttypes.MonographItem;
|
||||||
|
import org.scientificcms.publications.ui.SciPublicationsUiMessageBundle;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
import javax.mvc.Controller;
|
import javax.mvc.Controller;
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
import javax.ws.rs.FormParam;
|
||||||
|
import javax.ws.rs.POST;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -27,9 +36,20 @@ import javax.ws.rs.Path;
|
||||||
labelKey = "monograph.authoringsteps.basicproperties.label",
|
labelKey = "monograph.authoringsteps.basicproperties.label",
|
||||||
supportedDocumentType = MonographItem.class
|
supportedDocumentType = MonographItem.class
|
||||||
)
|
)
|
||||||
|
|
||||||
public class MonographPropertiesStep extends AbstractPublicationWithPublisherPropertiesStep<MonographItem, Monograph> {
|
public class MonographPropertiesStep extends AbstractPublicationWithPublisherPropertiesStep<MonographItem, Monograph> {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private DocumentUi documentUi;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ItemPermissionChecker itemPermissionChecker;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private MonographPropertiesStepModel propertiesStepModel;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private SciPublicationsUiMessageBundle messageBundle;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<MonographPropertiesStep> getStepClass() {
|
public Class<MonographPropertiesStep> getStepClass() {
|
||||||
return MonographPropertiesStep.class;
|
return MonographPropertiesStep.class;
|
||||||
|
|
@ -41,6 +61,60 @@ public class MonographPropertiesStep extends AbstractPublicationWithPublisherPro
|
||||||
DocumentNotFoundException {
|
DocumentNotFoundException {
|
||||||
super.init();
|
super.init();
|
||||||
|
|
||||||
|
propertiesStepModel.setReviewed(
|
||||||
|
getPublication().getReviewed()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getStepTemplatePath() {
|
||||||
|
return "/org/scientificcms/contenttypes/monograph/ui/edit-monograph.xhtml";
|
||||||
|
}
|
||||||
|
|
||||||
|
@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
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
} catch (ContentSectionNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
} catch (DocumentNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemPermissionChecker.canEditItem(getDocument())) {
|
||||||
|
updateProperties(
|
||||||
|
sectionIdentifier,
|
||||||
|
documentPath,
|
||||||
|
yearOfPublicationParam
|
||||||
|
);
|
||||||
|
|
||||||
|
getPublication().setReviewed(
|
||||||
|
Optional
|
||||||
|
.ofNullable(reviewedParam)
|
||||||
|
.map(param -> "true".equals(param) || "on".equals("param"))
|
||||||
|
.orElse(false)
|
||||||
|
);
|
||||||
|
|
||||||
|
return buildRedirectPathForStep();
|
||||||
|
} else {
|
||||||
|
return documentUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getDocument(),
|
||||||
|
messageBundle.getMessage("publication.edit.denied")
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,345 @@
|
||||||
|
package org.scientificcms.publications.ui.contenttypes;
|
||||||
|
|
||||||
|
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.AbstractMvcAuthoringStep;
|
||||||
|
import org.librecms.ui.contentsections.documents.CmsEditorUtil;
|
||||||
|
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.Publication;
|
||||||
|
import org.scientificcms.publications.PublicationRepository;
|
||||||
|
import org.scientificcms.publications.SciPublicationsConstants;
|
||||||
|
import org.scientificcms.publications.contenttypes.PublicationItem;
|
||||||
|
import org.scientificcms.publications.ui.SciPublicationsUiMessageBundle;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
@Path(MvcAuthoringSteps.PATH_PREFIX + "publication-abstract")
|
||||||
|
@Controller
|
||||||
|
@MvcAuthoringStepDef(
|
||||||
|
bundle = SciPublicationsConstants.BUNDLE,
|
||||||
|
descriptionKey = "authoringsteps.abstract.description",
|
||||||
|
labelKey = "authoringsteps.abstract.label",
|
||||||
|
supportedDocumentType = PublicationItem.class
|
||||||
|
)
|
||||||
|
public class PublicationAbstractStep extends AbstractMvcAuthoringStep {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private DocumentUi documentUi;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private GlobalizationHelper globalizationHelper;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ItemPermissionChecker itemPermissionChecker;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private SciPublicationsUiMessageBundle messageBundle;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private PublicationAbstractStepModel abstractStepModel;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private PublicationRepository publicationRepo;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<PublicationAbstractStep> getStepClass() {
|
||||||
|
return PublicationAbstractStep.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/")
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
@AuthorizationRequired
|
||||||
|
public String showStep(
|
||||||
|
@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(getPublicationItem())) {
|
||||||
|
return "/org/scientificcms/contenttypes/publications/ui/publication/abstract.xhtml";
|
||||||
|
} else {
|
||||||
|
return documentUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getPublicationItem(),
|
||||||
|
messageBundle.getMessage("publication.edit.denied")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/abstract/view/{locale}")
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
@AuthorizationRequired
|
||||||
|
public String viewAbstract(
|
||||||
|
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||||
|
final String sectionIdentifier,
|
||||||
|
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
|
||||||
|
final String documentPath,
|
||||||
|
@PathParam("locale") final String localeParam
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
} catch (ContentSectionNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
} catch (DocumentNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemPermissionChecker.canEditItem(getPublicationItem())) {
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
} catch (ContentSectionNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
} catch (DocumentNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
abstractStepModel.setSelectedLocale(
|
||||||
|
new Locale(localeParam).toString()
|
||||||
|
);
|
||||||
|
|
||||||
|
return "/org/scientificcms/contenttypes/publications/ui/publication/abstract/view.xhtml";
|
||||||
|
} else {
|
||||||
|
return documentUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getPublicationItem(),
|
||||||
|
messageBundle.getMessage("publication.edit.denied")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/abstract/add")
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
@AuthorizationRequired
|
||||||
|
public String addAbstractValue(
|
||||||
|
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||||
|
final String sectionIdentifier,
|
||||||
|
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
|
||||||
|
final String documentPath,
|
||||||
|
@FormParam("locale") final String localeParam
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
} catch (ContentSectionNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
} catch (DocumentNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemPermissionChecker.canEditItem(getPublicationItem())) {
|
||||||
|
final String value;
|
||||||
|
if (getPublication().getPublicationAbstract().getAvailableLocales()
|
||||||
|
.isEmpty()) {
|
||||||
|
value = "";
|
||||||
|
} else {
|
||||||
|
value = globalizationHelper.getValueFromLocalizedString(
|
||||||
|
getPublication().getPublicationAbstract()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Locale locale = new Locale(localeParam);
|
||||||
|
getPublication().getPublicationAbstract().putValue(locale, value);
|
||||||
|
publicationRepo.save(getPublication());
|
||||||
|
|
||||||
|
return buildRedirectPathForStep();
|
||||||
|
} else {
|
||||||
|
return documentUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getPublicationItem(),
|
||||||
|
messageBundle.getMessage("publication.edit.denied")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/abstract/edit/{locale}")
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
@AuthorizationRequired
|
||||||
|
public String editAbstractValue(
|
||||||
|
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||||
|
final String sectionIdentifier,
|
||||||
|
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
|
||||||
|
final String documentPath,
|
||||||
|
@PathParam("locale") final String localeParam
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
} catch (ContentSectionNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
} catch (DocumentNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemPermissionChecker.canEditItem(getPublicationItem())) {
|
||||||
|
abstractStepModel.setSelectedLocale(
|
||||||
|
new Locale(localeParam).toString()
|
||||||
|
);
|
||||||
|
|
||||||
|
return "/org/scientificcms/contenttypes/publications/ui/publication/abstract/edit.xhtml";
|
||||||
|
} else {
|
||||||
|
return documentUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getPublicationItem(),
|
||||||
|
messageBundle.getMessage("publication.edit.denied")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/abstract/edit/{locale}")
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
@AuthorizationRequired
|
||||||
|
public String editAbstractValue(
|
||||||
|
@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
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
} catch (ContentSectionNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
} catch (DocumentNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemPermissionChecker.canEditItem(getPublicationItem())) {
|
||||||
|
final Locale locale = new Locale(localeParam);
|
||||||
|
getPublication().getPublicationAbstract().putValue(locale, value);
|
||||||
|
publicationRepo.save(getPublication());
|
||||||
|
|
||||||
|
return buildRedirectPathForStep();
|
||||||
|
} else {
|
||||||
|
return documentUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getPublicationItem(),
|
||||||
|
messageBundle.getMessage("publication.edit.denied")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/abstract/remove/{locale}")
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
@AuthorizationRequired
|
||||||
|
public String removeAbstractValue(
|
||||||
|
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||||
|
final String sectionIdentifier,
|
||||||
|
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
|
||||||
|
final String documentPath,
|
||||||
|
@PathParam("locale") final String localeParam
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
} catch (ContentSectionNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
} catch (DocumentNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemPermissionChecker.canEditItem(getPublicationItem())) {
|
||||||
|
final Locale locale = new Locale(localeParam);
|
||||||
|
getPublication().getPublicationAbstract().removeValue(locale);
|
||||||
|
publicationRepo.save(getPublication());
|
||||||
|
|
||||||
|
return buildRedirectPathForStep();
|
||||||
|
} else {
|
||||||
|
return documentUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getPublicationItem(),
|
||||||
|
messageBundle.getMessage("publication.edit.denied")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() throws ContentSectionNotFoundException,
|
||||||
|
DocumentNotFoundException {
|
||||||
|
super.init();
|
||||||
|
|
||||||
|
final boolean canEdit = itemPermissionChecker.canEditItem(
|
||||||
|
getPublicationItem()
|
||||||
|
);
|
||||||
|
if (canEdit) {
|
||||||
|
abstractStepModel.setCanEdit(canEdit);
|
||||||
|
abstractStepModel.setAbstractValues(
|
||||||
|
getPublication()
|
||||||
|
.getPublicationAbstract()
|
||||||
|
.getValues()
|
||||||
|
.entrySet()
|
||||||
|
.stream()
|
||||||
|
.collect(
|
||||||
|
Collectors.toMap(
|
||||||
|
entry -> entry.getKey().toString(),
|
||||||
|
entry -> entry.getValue()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
abstractStepModel.setVariants(
|
||||||
|
getPublication()
|
||||||
|
.getPublicationAbstract()
|
||||||
|
.getValues()
|
||||||
|
.entrySet()
|
||||||
|
.stream()
|
||||||
|
.map(CmsEditorUtil::buildVariantRow)
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final Set<Locale> abstractLocales = getPublication()
|
||||||
|
.getPublicationAbstract()
|
||||||
|
.getAvailableLocales();
|
||||||
|
abstractStepModel.setUnusedLocales(
|
||||||
|
globalizationHelper
|
||||||
|
.getAvailableLocales()
|
||||||
|
.stream()
|
||||||
|
.filter(locale -> !abstractLocales.contains(locale))
|
||||||
|
.map(Locale::toString)
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private PublicationItem<?> getPublicationItem() {
|
||||||
|
return (PublicationItem<?>) getDocument();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Publication getPublication() {
|
||||||
|
return getPublicationItem().getPublication();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -25,6 +25,8 @@ public class PublicationPropertiesStepModel {
|
||||||
|
|
||||||
private List<String> unusedTitleLocales;
|
private List<String> unusedTitleLocales;
|
||||||
|
|
||||||
|
private int yearOfPublication;
|
||||||
|
|
||||||
private Map<String, String> shortDecriptionValues;
|
private Map<String, String> shortDecriptionValues;
|
||||||
|
|
||||||
private List<String> unusedShortDescriptionLocales;
|
private List<String> unusedShortDescriptionLocales;
|
||||||
|
|
@ -55,6 +57,14 @@ public class PublicationPropertiesStepModel {
|
||||||
this.unusedTitleLocales = new ArrayList<>(unusedTitleLocales);
|
this.unusedTitleLocales = new ArrayList<>(unusedTitleLocales);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getYearOfPublication() {
|
||||||
|
return yearOfPublication;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setYearOfPublication(final int yearOfPublication) {
|
||||||
|
this.yearOfPublication = yearOfPublication;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, String> getShortDecriptionValues() {
|
public Map<String, String> getShortDecriptionValues() {
|
||||||
return Collections.unmodifiableMap(shortDecriptionValues);
|
return Collections.unmodifiableMap(shortDecriptionValues);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import javax.inject.Named;
|
||||||
*/
|
*/
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
@Named("SciCmsPublicationWithPublisherExtendedPropertiesStep")
|
@Named("SciCmsPublicationWithPublisherExtendedPropertiesStep")
|
||||||
public class PublicationWithPublisherExtentedPropertiesStep {
|
public class PublicationWithPublisherExtendedPropertiesStepModel {
|
||||||
|
|
||||||
private String isbn10;
|
private String isbn10;
|
||||||
|
|
||||||
|
|
@ -186,8 +186,9 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemPermissionChecker.canEditItem(getProject())) {
|
if (itemPermissionChecker.canEditItem(getProject())) {
|
||||||
descriptionModel.setSelectedLocale(new Locale(localeParam)
|
descriptionModel.setSelectedLocale(
|
||||||
.toString());
|
new Locale(localeParam).toString()
|
||||||
|
);
|
||||||
|
|
||||||
return "org/scientificcms/contenttypes/sciproject/ui/description/view.xhtml";
|
return "org/scientificcms/contenttypes/sciproject/ui/description/view.xhtml";
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue