From: rkv Date: Tue, 16 Apr 2013 16:16:05 +0000 (+0000) Subject: Fix for enabling Demote operation when approver and reviewer are null in validation... X-Git-Tag: Root_Delivery2_2013_04_22~27 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c4c0b1dd47eaeb8483cc64a57a3a9cb7f7d44e9e;p=tools%2Fsiman.git Fix for enabling Demote operation when approver and reviewer are null in validation cycle. --- diff --git a/Workspace/Siman-Common/src/org/splat/som/DocumentRights.java b/Workspace/Siman-Common/src/org/splat/som/DocumentRights.java index cb2e3fc..2d0399e 100644 --- a/Workspace/Siman-Common/src/org/splat/som/DocumentRights.java +++ b/Workspace/Siman-Common/src/org/splat/som/DocumentRights.java @@ -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 use = _operand.value() - .getRelations(UsedByRelation.class); - for (Iterator 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 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; } /** diff --git a/Workspace/Siman-Common/src/org/splat/som/StudyRights.java b/Workspace/Siman-Common/src/org/splat/som/StudyRights.java index 8782dab..ac98a65 100644 --- a/Workspace/Siman-Common/src/org/splat/som/StudyRights.java +++ b/Workspace/Siman-Common/src/org/splat/som/StudyRights.java @@ -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; } /**