Missing parts for the controller for the proceedings of Proceedings.
parent
0fd5941c28
commit
a08bbfdb84
|
|
@ -28,7 +28,7 @@ public class ProceedingsManager {
|
|||
@AuthorizationRequired
|
||||
@RequiresPrivilege(ItemPrivileges.EDIT)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public void addPaperToCollectedVolume(final InProceedings paper,
|
||||
public void addPaperToProceedings(final InProceedings paper,
|
||||
final Proceedings proceedings) {
|
||||
Objects.requireNonNull(paper);
|
||||
Objects.requireNonNull(proceedings);
|
||||
|
|
@ -43,7 +43,7 @@ public class ProceedingsManager {
|
|||
@AuthorizationRequired
|
||||
@RequiresPrivilege(ItemPrivileges.EDIT)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public void removeArticleFromCollectedVolume(
|
||||
public void removeArticleFromProceedings(
|
||||
final InProceedings paper,
|
||||
final Proceedings collectedVolume
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
package org.scientificcms.publications.ui.contenttypes;
|
||||
|
||||
import freemarker.template.utility.DateUtil;
|
||||
import org.libreccm.api.Identifier;
|
||||
import org.libreccm.api.IdentifierParser;
|
||||
import org.libreccm.l10n.GlobalizationHelper;
|
||||
import org.libreccm.security.AuthorizationRequired;
|
||||
import org.librecms.assets.Organization;
|
||||
import org.librecms.contentsection.Asset;
|
||||
import org.librecms.contentsection.AssetRepository;
|
||||
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
|
||||
import org.librecms.ui.contentsections.ItemPermissionChecker;
|
||||
import org.librecms.ui.contentsections.assets.OrganizationEditStep;
|
||||
import org.librecms.ui.contentsections.documents.DocumentNotFoundException;
|
||||
import org.librecms.ui.contentsections.documents.DocumentUi;
|
||||
import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef;
|
||||
|
|
@ -14,6 +18,7 @@ import org.scientificcms.publications.InProceedings;
|
|||
import org.scientificcms.publications.Proceedings;
|
||||
import org.scientificcms.publications.ProceedingsManager;
|
||||
import org.scientificcms.publications.PublicationRepository;
|
||||
import org.scientificcms.publications.assets.PublisherAsset;
|
||||
import org.scientificcms.publications.contenttypes.ProceedingsItem;
|
||||
import org.scientificcms.publications.ui.SciPublicationsUiConstants;
|
||||
import org.scientificcms.publications.ui.SciPublicationsUiMessageBundle;
|
||||
|
|
@ -22,6 +27,7 @@ import java.time.LocalDate;
|
|||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -59,6 +65,9 @@ public class ProceedingsPropertiesStep
|
|||
public static final String EDIT_STEP_URL_FRAGMENT
|
||||
= "proceedings-basicproperties";
|
||||
|
||||
@Inject
|
||||
private AssetRepository assetRepo;
|
||||
|
||||
@Inject
|
||||
private DocumentUi documentUi;
|
||||
|
||||
|
|
@ -472,7 +481,59 @@ public class ProceedingsPropertiesStep
|
|||
@FormParam("paperIdentifier")
|
||||
final String paperIdentifier
|
||||
) {
|
||||
throw new UnsupportedOperationException();
|
||||
try {
|
||||
init();
|
||||
} catch (ContentSectionNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
} catch (DocumentNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
}
|
||||
|
||||
if (itemPermissionChecker.canEditItem(getDocument())) {
|
||||
final Identifier identifier = identifierParser.parseIdentifier(
|
||||
paperIdentifier
|
||||
);
|
||||
final Optional<InProceedings> paperResult;
|
||||
switch (identifier.getType()) {
|
||||
case ID:
|
||||
paperResult = publicationRepo.findByIdAndType(
|
||||
Long.parseLong(identifier.getIdentifier()),
|
||||
InProceedings.class
|
||||
);
|
||||
break;
|
||||
case UUID:
|
||||
paperResult = publicationRepo.findByUuidAndType(
|
||||
identifier.getIdentifier(),
|
||||
InProceedings.class
|
||||
);
|
||||
break;
|
||||
default:
|
||||
paperResult = Optional.empty();
|
||||
break;
|
||||
}
|
||||
|
||||
if (paperResult.isEmpty()) {
|
||||
return showPaperNotFound(
|
||||
sectionIdentifier,
|
||||
documentPath,
|
||||
paperIdentifier
|
||||
);
|
||||
}
|
||||
|
||||
final InProceedings paper = paperResult.get();
|
||||
proceedingsManager.addPaperToProceedings(
|
||||
paper,
|
||||
getPublication()
|
||||
);
|
||||
|
||||
return buildRedirectPathForStep();
|
||||
} else {
|
||||
return documentUi.showAccessDenied(
|
||||
getContentSection(),
|
||||
getDocument(),
|
||||
getLabel()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
|
|
@ -487,7 +548,43 @@ public class ProceedingsPropertiesStep
|
|||
@PathParam("paperUuid")
|
||||
final String paperUuid
|
||||
) {
|
||||
throw new UnsupportedOperationException();
|
||||
try {
|
||||
init();
|
||||
} catch (ContentSectionNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
} catch (DocumentNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
}
|
||||
|
||||
if (itemPermissionChecker.canEditItem(getDocument())) {
|
||||
final Optional<InProceedings> paperResult = getPublication()
|
||||
.getPapers()
|
||||
.stream()
|
||||
.filter(paper -> Objects.equals(paper.getUuid(), paperUuid))
|
||||
.findAny();
|
||||
|
||||
if (paperResult.isEmpty()) {
|
||||
return showPaperNotPartOfProceedings(
|
||||
sectionIdentifier,
|
||||
documentPath,
|
||||
sectionIdentifier
|
||||
);
|
||||
}
|
||||
|
||||
final InProceedings paper = paperResult.get();
|
||||
proceedingsManager.removeArticleFromProceedings(
|
||||
paper,
|
||||
getPublication()
|
||||
);
|
||||
|
||||
return buildRedirectPathForStep();
|
||||
} else {
|
||||
return documentUi.showAccessDenied(
|
||||
getContentSection(),
|
||||
getDocument(),
|
||||
getLabel()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
|
|
@ -502,7 +599,69 @@ public class ProceedingsPropertiesStep
|
|||
@FormParam("organizerIdentifier")
|
||||
final String organizerIdentifier
|
||||
) {
|
||||
throw new UnsupportedOperationException();
|
||||
try {
|
||||
init();
|
||||
} catch (ContentSectionNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
} catch (DocumentNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
}
|
||||
|
||||
if (itemPermissionChecker.canEditItem(getDocument())) {
|
||||
final Identifier identifier = identifierParser.parseIdentifier(
|
||||
organizerIdentifier
|
||||
);
|
||||
final Optional<Organization> organizationResult;
|
||||
switch (identifier.getType()) {
|
||||
case ID:
|
||||
organizationResult = assetRepo.findById(
|
||||
Long.parseLong(identifier.getIdentifier()),
|
||||
Organization.class
|
||||
);
|
||||
break;
|
||||
case UUID:
|
||||
organizationResult = assetRepo.findByUuidAndType(
|
||||
identifier.getIdentifier(),
|
||||
Organization.class
|
||||
);
|
||||
break;
|
||||
default:
|
||||
final Optional<Asset> result = assetRepo.findByPath(
|
||||
identifier.getIdentifier()
|
||||
);
|
||||
if (result == null || result.isEmpty()) {
|
||||
organizationResult = Optional.empty();
|
||||
} else if (!(result.get() instanceof Organization)) {
|
||||
organizationResult = Optional.empty();
|
||||
} else {
|
||||
organizationResult = Optional.of(
|
||||
(Organization) result.get()
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (organizationResult.isEmpty()) {
|
||||
return showOrganizerNotFound(
|
||||
sectionIdentifier,
|
||||
documentPath,
|
||||
organizerIdentifier
|
||||
);
|
||||
}
|
||||
|
||||
final Organization organization = organizationResult.get();
|
||||
|
||||
getPublication().setOrganizer(organization);
|
||||
publicationRepo.save(getPublication());
|
||||
|
||||
return buildRedirectPathForStep();
|
||||
} else {
|
||||
return documentUi.showAccessDenied(
|
||||
getContentSection(),
|
||||
getDocument(),
|
||||
getLabel()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
|
|
@ -515,7 +674,26 @@ public class ProceedingsPropertiesStep
|
|||
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
|
||||
final String documentPath
|
||||
) {
|
||||
throw new UnsupportedOperationException();
|
||||
try {
|
||||
init();
|
||||
} catch (ContentSectionNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
} catch (DocumentNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
}
|
||||
|
||||
if (itemPermissionChecker.canEditItem(getDocument())) {
|
||||
getPublication().setOrganizer(null);
|
||||
publicationRepo.save(getPublication());
|
||||
|
||||
return buildRedirectPathForStep();
|
||||
} else {
|
||||
return documentUi.showAccessDenied(
|
||||
getContentSection(),
|
||||
getDocument(),
|
||||
getLabel()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private String showInvalidStartDate(
|
||||
|
|
@ -552,4 +730,31 @@ public class ProceedingsPropertiesStep
|
|||
return row;
|
||||
}
|
||||
|
||||
private String showPaperNotFound(
|
||||
final String sectionIdentifier,
|
||||
final String documentPath,
|
||||
final String paperIdentifier
|
||||
) {
|
||||
models.put("paperNotFound", paperIdentifier);
|
||||
return showStep(sectionIdentifier, documentPath);
|
||||
}
|
||||
|
||||
private String showPaperNotPartOfProceedings(
|
||||
final String sectionIdentifier,
|
||||
final String documentPath,
|
||||
final String paperIdentifier
|
||||
) {
|
||||
models.put("paperNotPartOfProceedings", paperIdentifier);
|
||||
return showStep(sectionIdentifier, documentPath);
|
||||
}
|
||||
|
||||
private String showOrganizerNotFound(
|
||||
final String sectionIdentifier,
|
||||
final String documentPath,
|
||||
final String organizierIdentifier
|
||||
) {
|
||||
models.put("organizerNotFound", organizierIdentifier);
|
||||
return super.showStep(sectionIdentifier, documentPath);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue