]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
Fix for enabling Demote operation when approver and reviewer are null in validation...
authorrkv <rkv@opencascade.com>
Tue, 16 Apr 2013 16:16:05 +0000 (16:16 +0000)
committerrkv <rkv@opencascade.com>
Tue, 16 Apr 2013 16:16:05 +0000 (16:16 +0000)
Workspace/Siman-Common/src/org/splat/som/DocumentRights.java
Workspace/Siman-Common/src/org/splat/som/StudyRights.java

index cb2e3fc6f06fe465a8cf202767f63138710c1d18..2d0399e3919206464eb0fc25f504471d10f99f97 100644 (file)
@@ -168,38 +168,36 @@ public class DocumentRights {
                User approver = _cycle.getActor(ValidationStep.APPROVAL); // May be null if not approvable
                ProgressState mystate = _operand.value().getProgressState();
 
-               if (mystate == ProgressState.inDRAFT) {
-                       if (publisher == null) {
-                               if ((!_isauthor) && (!_user.equals(manager))
-                                               && (!_user.equals(reviewer))) {
-                                       return false;
-                               }
-                       } else if ((!_user.equals(publisher)) && (!_user.equals(reviewer))) {
-                               return false;
-                       }
-               } else if (mystate == ProgressState.inCHECK) {
-                       if (!_user.equals(approver)) {
-                               return false;
-                       }
-               } else {
-                       return false;
-               }
+               boolean res = (((mystate != ProgressState.inDRAFT || publisher != null
+                               || _isauthor || _user.equals(manager))
+                               && (publisher == null || _user.equals(publisher)) || _user
+                               .equals(reviewer))
 
-               List<Relation> use = _operand.value()
-                               .getRelations(UsedByRelation.class);
-               for (Iterator<Relation> i = use.iterator(); i.hasNext();) {
-                       Document depend = (Document) i.next().getTo();
-                       ProgressState state = depend.getProgressState();
-                       if (mystate == ProgressState.inDRAFT
-                                       && state != ProgressState.inWORK) {
-                               return false;
-                       }
-                       if (mystate == ProgressState.inCHECK
-                                       && (state != ProgressState.inDRAFT && state != ProgressState.inWORK)) {
-                               return false;
+                               && (mystate != ProgressState.inCHECK
+
+                               || ((approver == null || _user.equals(approver) || _user
+                                               .equals(reviewer))
+
+                               && (approver != null || _user.equals(publisher) || (reviewer == null || _user
+                                               .equals(reviewer))
+                                               && (reviewer != null || _user.equals(manager)))))
+
+               && (mystate == ProgressState.inCHECK || mystate == ProgressState.inDRAFT));
+
+               if (res) {
+                       List<Relation> use = _operand.value().getRelations(
+                                       UsedByRelation.class);
+                       for (Relation rel : use) {
+                               Document depend = (Document) rel.getTo();
+                               ProgressState state = depend.getProgressState();
+                               if (((mystate == ProgressState.inDRAFT) || (mystate == ProgressState.inCHECK && (state != ProgressState.inDRAFT)))
+                                               && state != ProgressState.inWORK) {
+                                       res = false;
+                                       break;
+                               }
                        }
                }
-               return true;
+               return res;
        }
 
        /**
index 8782dab987bea5869b1380af0bc4f6c62b897cee..ac98a65ae93aec26ed1a2a5f8eec91ca00a0af74 100644 (file)
@@ -216,24 +216,23 @@ public class StudyRights {
                User approver = _cycle.getActor(ValidationStep.APPROVAL); // May be null if not approvable
                ProgressState mystate = _operand.getProgressState();
 
-               if (mystate == ProgressState.inDRAFT) {
-                       if (publisher == null) {
-                               if ((!_isauthor) && (!_user.equals(manager))
-                                               && (!_user.equals(reviewer))) {
-                                       return false;
-                               }
-                       } else if ((!_user.equals(publisher)) && (!_user.equals(reviewer))) {
-                               return false;
-                       }
-               } else if (mystate == ProgressState.inCHECK) {
-                       if (!_user.equals(approver)) {
-                               return false;
-                       }
-               } else {
-                       return false;
-               }
+               boolean res = (((mystate != ProgressState.inDRAFT || publisher != null
+                               || _isauthor || _user.equals(manager))
+                               && (publisher == null || _user.equals(publisher)) || _user
+                               .equals(reviewer))
+
+                               && (mystate != ProgressState.inCHECK
+
+                               || ((approver == null || _user.equals(approver) || _user
+                                               .equals(reviewer))
 
-               return true;
+                               && (approver != null || _user.equals(publisher) || (reviewer == null || _user
+                                               .equals(reviewer))
+                                               && (reviewer != null || _user.equals(manager)))))
+
+               && (mystate == ProgressState.inCHECK || mystate == ProgressState.inDRAFT));
+
+               return res;
        }
 
        /**