From c52b422b6884a46eb30428da1422723e9d711a44 Mon Sep 17 00:00:00 2001 From: rkv Date: Tue, 5 Feb 2013 05:25:06 +0000 Subject: [PATCH] Fix for mantis #0022079: Problem in lifecycle of documents: For two steps cycles documents from inCheck status must be demoted into inWork status instead of inDraft. --- .../splat/service/PublicationServiceImpl.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java index 21ad088..31cf6a0 100644 --- a/Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java @@ -382,15 +382,23 @@ public class PublicationServiceImpl implements PublicationService { @Transactional public boolean invalidate(final Publication aPublication) { boolean res = false; - if ((aPublication.value().getProgressState() == ProgressState.inCHECK) - && getDocumentService().demote(aPublication.value())) { + if ((aPublication.value().getProgressState() == ProgressState.inCHECK)) { DocumentType type = aPublication.value().getType(); Study owner = aPublication.getOwnerStudy(); - if (getDocumentService().isStudyResult(type) - && owner.getProgressState() == ProgressState.inCHECK) { - getStudyService().demote(owner); + + ValidationCycle cycle = getStudyService().getValidationCycleOf( + owner, type); + // Check if the validation cycle allows the review step + if (cycle.enables(ValidationStep.REVIEW)) { + if (getDocumentService().demote(aPublication.value()) + && getDocumentService().isStudyResult(type) + && owner.getProgressState() == ProgressState.inCHECK) { + getStudyService().demote(owner); + } + res = true; + } else { // If the validation cycle has no inDraft step + res = demote(aPublication); } - res = true; } return res; } @@ -501,7 +509,8 @@ public class PublicationServiceImpl implements PublicationService { "Cannot save a Publication object refering an undefined Document"); } if (!aPublication.value().getSourceFile().exists()) { - throw new FileNotFoundException(aPublication.value().getSourceFile().asFile().getAbsolutePath()); + throw new FileNotFoundException(aPublication.value() + .getSourceFile().asFile().getAbsolutePath()); } if (state == ProgressState.inWORK || state == ProgressState.EXTERN) { -- 2.30.2