Salome HOME
Fix for mantis #0022079: Problem in lifecycle of documents: For two steps cycles...
authorrkv <rkv@opencascade.com>
Tue, 5 Feb 2013 05:25:06 +0000 (05:25 +0000)
committerrkv <rkv@opencascade.com>
Tue, 5 Feb 2013 05:25:06 +0000 (05:25 +0000)
Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java

index 21ad0888b99e72b6cb2a2117b73dd8d7d10e5bee..31cf6a069f63a8aa4dddb2861a51ec6e72cd3f6f 100644 (file)
@@ -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) {