Salome HOME
Fix for the bug: reviewer couldn't demote a promoted document.
authorrkv <rkv@opencascade.com>
Thu, 6 Dec 2012 11:39:27 +0000 (11:39 +0000)
committerrkv <rkv@opencascade.com>
Thu, 6 Dec 2012 11:39:27 +0000 (11:39 +0000)
Workspace/Siman-Common/src/org/splat/som/DocumentRights.java

index 6b50fe0520b1ccb27ee4e96ddc9e645f5a8bb052..93e5bcea16737dd9ad824c498f39c68a40ee022b 100644 (file)
@@ -1,16 +1,16 @@
 package org.splat.som;
+
 /**
- * Class providing services for checking the rights related to operations on a given document.
- * These rights are partially driven by the validation cycle associated to documents.
+ * Class providing services for checking the rights related to operations on a given document. These rights are partially driven by the
+ * validation cycle associated to documents.
  * 
  * @see ValidationCycle
- * @author    Daniel Brunier-Coulin
+ * @author Daniel Brunier-Coulin
  * @copyright OPEN CASCADE 2012
  */
-//TODO: Review this rights in the following contexts:
-//      - Document shared by several scenarios
-//      - Document out-dated following a modification of a document it uses
-
+// TODO: Review this rights in the following contexts:
+// - Document shared by several scenarios
+// - Document out-dated following a modification of a document it uses
 import java.util.Iterator;
 import java.util.List;
 
@@ -26,60 +26,63 @@ import org.splat.dal.bo.som.ValidationStep;
 import org.splat.dal.bo.som.VersionsRelation;
 import org.splat.service.ServiceLocatorImpl;
 
-
 public class DocumentRights {
 
-    private transient final User            _user;
-    private transient Publication           _operand;
-    private transient final ValidationCycle _cycle;
-    private transient boolean               _isauthor;     // True if the user is author of the document
-
-//  ==============================================================================================================================
-//  Constructors
-//  ==============================================================================================================================
-
-    public DocumentRights (final User user, final Publication tag) {
-      this._user     = user;
-      this._operand  = tag;
-//RKV      this.cycle    = operand.getOwnerStudy().getValidationCycleOf(operand.value().getType());
-      this._cycle    = ServiceLocatorImpl.getInstance().getStudyService().getValidationCycleOf(_operand.getOwnerStudy(), _operand.value().getType());
-      this._isauthor = _operand.value().getAuthor().equals(user);
-//TODO: all contributors of the given document (when supported) must also behave as author
-    }
-    protected DocumentRights (final Publication tag) {
-      this._operand  = tag;
-      this._user     = _operand.value().getAuthor();
-      this._operand  = tag;
-      this._cycle    = ServiceLocatorImpl.getInstance().getStudyService().getValidationCycleOf(_operand.getOwnerStudy(), _operand.value().getType());
-      this._isauthor = true;           // In order to ignore the author state in the context of any user
-//TODO: all contributors of the given document (when supported) must also behave as author
-    }
-
-//  ==============================================================================================================================
-//  Public member functions
-//  ==============================================================================================================================
+       private transient final User _user;
+       private transient Publication _operand;
+       private transient final ValidationCycle _cycle;
+       private transient boolean _isauthor; // True if the user is author of the document
+
+       // ==============================================================================================================================
+       // Constructors
+       // ==============================================================================================================================
+
+       public DocumentRights(final User user, final Publication tag) {
+               this._user = user;
+               this._operand = tag;
+               // RKV this.cycle = operand.getOwnerStudy().getValidationCycleOf(operand.value().getType());
+               this._cycle = ServiceLocatorImpl.getInstance().getStudyService()
+                               .getValidationCycleOf(_operand.getOwnerStudy(),
+                                               _operand.value().getType());
+               this._isauthor = _operand.value().getAuthor().equals(user);
+               // TODO: all contributors of the given document (when supported) must also behave as author
+       }
 
-/**
- * Checks if the user has right to accept the modifications of documents depending on the selected document.
- * This operation applies to out-dated documents following a modification of documents they use.
- * Only the author of the document has such right.
- * 
- * @return true if the user has right to accept the modifications of dependencies of the document.
- * @see    Publication#accept()
- */
-    public boolean canAccept() {
+       protected DocumentRights(final Publication tag) {
+               this._operand = tag;
+               this._user = _operand.value().getAuthor();
+               this._operand = tag;
+               this._cycle = ServiceLocatorImpl.getInstance().getStudyService()
+                               .getValidationCycleOf(_operand.getOwnerStudy(),
+                                               _operand.value().getType());
+               this._isauthor = true; // In order to ignore the author state in the context of any user
+               // TODO: all contributors of the given document (when supported) must also behave as author
+       }
+
+       // ==============================================================================================================================
+       // Public member functions
+       // ==============================================================================================================================
+
+       /**
+        * Checks if the user has right to accept the modifications of documents depending on the selected document. This operation applies to
+        * out-dated documents following a modification of documents they use. Only the author of the document has such right.
+        * 
+        * @return true if the user has right to accept the modifications of dependencies of the document.
+        * @see Publication#accept()
+        */
+       public boolean canAccept() {
                return _isauthor && _operand.isOutdated();
        }
 
-/**
- * Checks if the user has right to approve the selected document. Only the approver of the type of selected document has such right,
- * providing that the document is candidate for approval and all document dependencies have already been approved.
- * 
- * @return true if the user has right to approve the document.
- * @see Publication#approve()
- * @see ValidationCycle
- */
-    public boolean canApprove() {
+       /**
       * Checks if the user has right to approve the selected document. Only the approver of the type of selected document has such right,
       * providing that the document is candidate for approval and all document dependencies have already been approved.
       
       * @return true if the user has right to approve the document.
       * @see Publication#approve()
       * @see ValidationCycle
       */
+       public boolean canApprove() {
                User approver = _cycle.getActor(ValidationStep.APPROVAL); // May be null if not approvable
                boolean res = (_user.equals(approver))
                                && (_operand.getProgressState() == ProgressState.inCHECK);
@@ -101,15 +104,15 @@ public class DocumentRights {
                return res;
        }
 
-/**
- * Checks if the user has right to attach a file to the selected document. Both, the author, during the elaboration of the document, and the
* reviewer of the document, during the review process, have such right.
- * 
- * @return true if the user has right to attach a file to the document.
- * @see Publication#attach(String)
- * @see Publication#attach(String, String)
- */
-    public boolean canAttach() {
+       /**
+        * Checks if the user has right to attach a file to the selected document. Both, the author, during the elaboration of the document, and
       * the reviewer of the document, during the review process, have such right.
       
       * @return true if the user has right to attach a file to the document.
       * @see Publication#attach(String)
       * @see Publication#attach(String, String)
       */
+       public boolean canAttach() {
                User manager = _operand.getOwnerStudy().getAuthor();
                User reviewer = _cycle.getActor(ValidationStep.REVIEW); // May be null if not reviewable
                ProgressState state = _operand.value().getProgressState();
@@ -119,323 +122,323 @@ public class DocumentRights {
                                                .equals(reviewer)));
        }
 
-/**
- * Checks if the user has right to demote the selected document. A document can be demoted providing that it is In-Draft or In-Check and all
- * documents using it have previously been demoted. In-Draft documents can be demoted by default by both, the author of the document and the
- * responsible of study, while documents in approval process can be demoted by their approver only.
- * 
- * @return true if the user has right to demote the document.
- * @see #canInvalidate()
- * @see #canPromote()
- * @see Publication#demote()
- * @see ValidationCycle
- */
-    public boolean canDemote () {
-      User           manager   = _operand.getOwnerStudy().getAuthor();
-      User           publisher = _cycle.getActor(ValidationStep.PROMOTION);  // Null if the default users are involved
-      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)) {
+       /**
+        * Checks if the user has right to demote the selected document. A document can be demoted providing that it is In-Draft or In-Check and
+        * all documents using it have previously been demoted. In-Draft documents can be demoted by default by both, the author of the document
+        * and the responsible of study, while documents in approval process can be demoted by their approver only.
+        * 
+        * @return true if the user has right to demote the document.
+        * @see #canInvalidate()
+        * @see #canPromote()
+        * @see Publication#demote()
+        * @see ValidationCycle
+        */
+       public boolean canDemote() {
+               User manager = _operand.getOwnerStudy().getAuthor();
+               User publisher = _cycle.getActor(ValidationStep.PROMOTION); // Null if the default users are involved
+               User reviewer = _cycle.getActor(ValidationStep.REVIEW); // May be null if not reviewable
+               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;
                }
-        } else                   if (!_user.equals(publisher)) {
-                       return false;
+
+               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;
+                       }
                }
-      } else
-      if (mystate == ProgressState.inCHECK) {
-       if (!_user.equals(approver)) {
-                       return false;
+               return true;
+       }
+
+       /**
+        * Checks if the user has right to check-out the selected document for editing. In-Work documents can be checked-out by both, the author
+        * of the document and the responsible of study, while documents In-Draft can be checked-out by the reviewer only.
+        * 
+        * @return true if the user has right to edit the document.
+        */
+       public boolean canEdit() {
+               User manager = _operand.getOwnerStudy().getAuthor();
+               User reviewer = _cycle.getActor(ValidationStep.REVIEW); // May be null if not reviewable
+               ProgressState state = _operand.value().getProgressState();
+
+               // TODO: Should be restricted by the application if no editor available
+               if (state == ProgressState.inWORK) {
+                       if (_isauthor || _user.equals(manager)) {
+                               return true;
+                       }
+               } else if (state == ProgressState.inDRAFT) {
+                       if (_user.equals(reviewer)) {
+                               return true;
+                       }
                }
-      } else {
                return false;
        }
-      
-      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)) {
+
+       /**
+        * Checks if the user has right to promote the selected document. A document can be promoted providing that it is In-Work and all its
+        * dependencies have previously been promoted. By default, both the author of the document and the responsible of study has right to
+        * promote such document. Otherwise, only the user involved in the Promotion step of validation cycle of the selected document has such
+        * right.
+        * 
+        * @return true if the user has right to promote the document.
+        * @see #canDemote()
+        * @see Publication#promote()
+        * @see ValidationCycle
+        */
+       public boolean canPromote() {
+               User manager = _operand.getOwnerStudy().getAuthor();
+               User publisher = _cycle.getActor(ValidationStep.PROMOTION); // Null if the default users are involved
+
+               if (_operand.getProgressState() != ProgressState.inWORK) {
                        return false;
                }
-      }
-      return true;
-    }
-
-/**
- * Checks if the user has right to check-out the selected document for editing.
- * In-Work documents can be checked-out by both, the author of the document and the responsible of study, while
- * documents In-Draft can be checked-out by the reviewer only.
- * 
- * @return true if the user has right to edit the document.
- */
-    public boolean canEdit () {
-      User           manager  = _operand.getOwnerStudy().getAuthor();
-      User           reviewer = _cycle.getActor(ValidationStep.REVIEW);      // May be null if not reviewable
-      ProgressState  state    = _operand.value().getProgressState();
-
-//TODO: Should be restricted by the application if no editor available
-      if (state == ProgressState.inWORK) {
-        if (_isauthor || _user.equals(manager)) {
-                       return true;
+               if (publisher == null) {
+                       if (!_isauthor && !_user.equals(manager)) {
+                               return false;
+                       }
+               } else {
+                       if (!_user.equals(publisher)) {
+                               return false;
+                       }
                }
-      } else
-      if (state == ProgressState.inDRAFT) {
-        if (_user.equals(reviewer)) {
-                       return true;
+               List<Relation> use = _operand.value().getRelations(UsesRelation.class);
+               for (Iterator<Relation> i = use.iterator(); i.hasNext();) {
+                       Document depend = (Document) i.next().getTo();
+                       ProgressState state = depend.getProgressState();
+                       if (state == ProgressState.EXTERN) {
+                               continue; // External documents do not follow this progress state
+                       }
+                       if (state == ProgressState.inWORK) {
+                               return false;
+                       }
                }
-      }
-      return false;
-    }
+               return true;
+       }
 
-/**
- * Checks if the user has right to promote the selected document.
- * A document can be promoted providing that it is In-Work and all its dependencies have previously been promoted.
- * By default, both the author of the document and the responsible of study has right to promote such document. Otherwise,
- * only the user involved in the Promotion step of validation cycle of the selected document has such right.
- * 
- * @return true if the user has right to promote the document.
- * @see    #canDemote()
- * @see    Publication#promote()
- * @see    ValidationCycle
- */
-    public boolean canPromote () {
-      User manager   = _operand.getOwnerStudy().getAuthor();
-      User publisher = _cycle.getActor(ValidationStep.PROMOTION);            // Null if the default users are involved
+       /**
+        * Checks if the user has right to remove the history of the selected document, if exists. Only the responsible of the study have such
+        * right.
+        * 
+        * @return true if the user has right to purge the document.
+        */
+       public boolean canPurge() {
+               User manager = _operand.getOwnerStudy().getAuthor();
+               Document doc = _operand.value();
 
-      if (_operand.getProgressState() != ProgressState.inWORK) {
-               return false;
-       }
-      if (publisher == null) { if (!_isauthor && !_user.equals(manager)) {
-               return false;
-       }
-      } else {                 if (!_user.equals(publisher)) {
-               return false;
-       }
-      }
-      List<Relation>            use = _operand.value().getRelations(UsesRelation.class);
-      for (Iterator<Relation> i=use.iterator(); i.hasNext();) {
-       Document      depend = (Document)i.next().getTo();
-       ProgressState state  = depend.getProgressState();
-       if (state == ProgressState.EXTERN) {
-                       continue;                        // External documents do not follow this progress state
+               if (!_user.equals(manager)) {
+                       return false;
                }
-       if (state == ProgressState.inWORK) {
+               if (doc.isShared()) {
                        return false;
                }
-      }
-      return true;
-    }
-
-/**
- * Checks if the user has right to remove the history of the selected document, if exists.
- * Only the responsible of the study have such right.
- * 
- * @return true if the user has right to purge the document.
- */
-    public boolean canPurge () {
-      User      manager = _operand.getOwnerStudy().getAuthor();
-      Document  doc     = _operand.value();
-      
-      if (!_user.equals(manager)) {
-               return false;
-       }
-      if (doc.isShared()) {
-               return false;
-       }
-      if (doc.getFirstRelation(VersionsRelation.class) == null) {
-               return false;
-       }
-      return true;
-    }
-
-/**
- * Checks if the user has right to remove the selected document from the study.
- * Both, the author of the document and the responsible of the study, have such right, providing that:
- * - the document is neither in review or in approval process
- * - the document is not used by any other document
- * 
- * @return true if the user has right to remove the document.
- * @see    Step#removeDocument(Publication)
- */
-    public boolean canRemove () {
-      User          manager = _operand.getOwnerStudy().getAuthor();
-      ProgressState state   = _operand.getProgressState();
-
-      if (!_isauthor && !_user.equals(manager)) {
-               return false;
-       }
-      if (state != ProgressState.inWORK && state != ProgressState.EXTERN) {
-               return false;
+               if (doc.getFirstRelation(VersionsRelation.class) == null) {
+                       return false;
+               }
+               return true;
        }
 
-      List<Publication> using = _operand.getRelations(UsedByRelation.class);
-      return using.isEmpty();
-    }
+       /**
+        * Checks if the user has right to remove the selected document from the study. Both, the author of the document and the responsible of
+        * the study, have such right, providing that: - the document is neither in review or in approval process - the document is not used by
+        * any other document
+        * 
+        * @return true if the user has right to remove the document.
+        * @see Step#removeDocument(Publication)
+        */
+       public boolean canRemove() {
+               User manager = _operand.getOwnerStudy().getAuthor();
+               ProgressState state = _operand.getProgressState();
 
-/**
- * Checks if the user has right to rename the selected document.
- * Only the author of the document has such right, providing that the document is neither in review nor in approval process.
- * 
- * @return true if the user has right to rename the document.
- * @see    Publication#rename(String)
- */
-    public boolean canRename () {
-      ProgressState state = _operand.getProgressState();
+               if (!_isauthor && !_user.equals(manager)) {
+                       return false;
+               }
+               if (state != ProgressState.inWORK && state != ProgressState.EXTERN) {
+                       return false;
+               }
 
-      if (!_isauthor) {
-               return false;     // In case of external document, the author is the one who has imported the document.
+               List<Publication> using = _operand.getRelations(UsedByRelation.class);
+               return using.isEmpty();
        }
-      if (state != ProgressState.inWORK && state != ProgressState.EXTERN) {
-               return false;
+
+       /**
+        * Checks if the user has right to rename the selected document. Only the author of the document has such right, providing that the
+        * document is neither in review nor in approval process.
+        * 
+        * @return true if the user has right to rename the document.
+        * @see Publication#rename(String)
+        */
+       public boolean canRename() {
+               ProgressState state = _operand.getProgressState();
+
+               if (!_isauthor) {
+                       return false; // In case of external document, the author is the one who has imported the document.
+               }
+               if (state != ProgressState.inWORK && state != ProgressState.EXTERN) {
+                       return false;
+               }
+               return (!_operand.value().isShared());
        }
-      return (!_operand.value().isShared());
-    }
 
-/**
- * Checks if the user has right to replace the source file of the selected document.
- * Both, the author of the document and the responsible of study has such right, providing that the document is neither in review
- * nor in approval process.
- * 
- * @return true if the user has right to replace the document.
- */
-    public boolean canReplace () {
-      User          manager = _operand.getOwnerStudy().getAuthor();
-      ProgressState state   = _operand.getProgressState();
+       /**
+        * Checks if the user has right to replace the source file of the selected document. Both, the author of the document and the
+        * responsible of study has such right, providing that the document is neither in review nor in approval process.
+        * 
+        * @return true if the user has right to replace the document.
+        */
+       public boolean canReplace() {
+               User manager = _operand.getOwnerStudy().getAuthor();
+               ProgressState state = _operand.getProgressState();
 
-      if (!_isauthor && !_user.equals(manager)) {
-               return false;                 // Supposed to work also in case of external document.
-       }
-      if (state != ProgressState.inWORK && state != ProgressState.EXTERN) {
-               return false;
+               if (!_isauthor && !_user.equals(manager)) {
+                       return false; // Supposed to work also in case of external document.
+               }
+               if (state != ProgressState.inWORK && state != ProgressState.EXTERN) {
+                       return false;
+               }
+               return !_operand.value().isShared();
        }
-      return !_operand.value().isShared();
-    }
 
-/**
- * Checks if the user has right to validate the selected document.
- * Only the reviewer of the type of selected document has such right, providing that the document is being reviewed and
- * all document dependencies have already been validated.
- * 
- * @return true if the user has right to validate the document
- * @see    #canUnvalidate()
- * @see    Publication#review()
- * @see    ValidationCycle
- */
-    public boolean canReview () {
-      User  reviewer = _cycle.getActor(ValidationStep.REVIEW);               // May be null if not reviewable
+       /**
+        * Checks if the user has right to validate the selected document. Only the reviewer of the type of selected document has such right,
+        * providing that the document is being reviewed and all document dependencies have already been validated.
+        * 
+        * @return true if the user has right to validate the document
+        * @see #canUnvalidate()
+        * @see Publication#review()
+        * @see ValidationCycle
+        */
+       public boolean canReview() {
+               User reviewer = _cycle.getActor(ValidationStep.REVIEW); // May be null if not reviewable
 
-      if (!_user.equals(reviewer)) {
-               return false;
-       }
-      if (_operand.getProgressState() != ProgressState.inDRAFT) {
-               return false;
-       }
-      
-      List<Relation>            use = _operand.value().getRelations(UsesRelation.class);
-      for (Iterator<Relation> i=use.iterator(); i.hasNext();) {
-       Document      depend = (Document)i.next().getTo();
-       ProgressState state  = depend.getProgressState();
-       if (state == ProgressState.EXTERN) {
-                       continue;                        // External documents do not follow this progress state
+               if (!_user.equals(reviewer)) {
+                       return false;
                }
-       if (state == ProgressState.inWORK || state == ProgressState.inDRAFT) {
+               if (_operand.getProgressState() != ProgressState.inDRAFT) {
                        return false;
                }
-      }
-      return true;
-    }
-
-/**
- * Checks if the user has right to undo the validation operation of the selected document.
- * Both, the author and the reviewer of a validated document, have such right.
- * 
- * @return true if the user has right to undo the validation operation
- * @see    #canDemote()
- * @see    #canReview()
- * @see    Publication#invalidate()
- * @see    ValidationCycle
- */
-    public boolean canInvalidate () {
-      User           reviewer = _cycle.getActor(ValidationStep.REVIEW);      // May be null if not reviewable
-      ProgressState  mystate  = _operand.value().getProgressState();
 
-      if (mystate != ProgressState.inCHECK) {
-               return false;
-       }
-      if (!_isauthor && !_user.equals(reviewer)) {
-               return false;
+               List<Relation> use = _operand.value().getRelations(UsesRelation.class);
+               for (Iterator<Relation> i = use.iterator(); i.hasNext();) {
+                       Document depend = (Document) i.next().getTo();
+                       ProgressState state = depend.getProgressState();
+                       if (state == ProgressState.EXTERN) {
+                               continue; // External documents do not follow this progress state
+                       }
+                       if (state == ProgressState.inWORK || state == ProgressState.inDRAFT) {
+                               return false;
+                       }
+               }
+               return true;
        }
-        
-      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) {
+
+       /**
+        * Checks if the user has right to undo the validation operation of the selected document. Both, the author and the reviewer of a
+        * validated document, have such right.
+        * 
+        * @return true if the user has right to undo the validation operation
+        * @see #canDemote()
+        * @see #canReview()
+        * @see Publication#invalidate()
+        * @see ValidationCycle
+        */
+       public boolean canInvalidate() {
+               User reviewer = _cycle.getActor(ValidationStep.REVIEW); // May be null if not reviewable
+               ProgressState mystate = _operand.value().getProgressState();
+
+               if (mystate != ProgressState.inCHECK) {
                        return false;
                }
-        if (mystate == ProgressState.inCHECK && (state != ProgressState.inDRAFT && state != ProgressState.inWORK)) {
+               if (!_isauthor && !_user.equals(reviewer)) {
                        return false;
                }
-      }
-      return true;
-    }
 
-/**
- * Checks if the user has right to version the selected document.
- * In-Work documents can be versioned by both, the author of the document and the responsible of study, while
- * documents In-Draft can be versioned by the reviewer only.
- * Additionally, Approved documents can also be versioned by their author in order to enter in a new modification validation cycle.
- * 
- * @return true if the user has right to version the document.
- * @see    Step#versionDocument(Publication)
- * @see    Step#versionDocument(Publication, Document.Properties)
- * @see    Step#versionDocument(Publication, String)
- */
-    public boolean canVersion () {
-      User           manager  = _operand.getOwnerStudy().getAuthor();
-      User           reviewer = _cycle.getActor(ValidationStep.REVIEW);      // May be null if not reviewable
-      ProgressState  state    = _operand.value().getProgressState();
-
-      if (state == ProgressState.inWORK) {
-        if (_isauthor || _user.equals(manager)) {
-                       return true;
-               }
-      } else
-      if (state == ProgressState.inDRAFT) {
-        if (_user.equals(reviewer)) {
-                       return true;
+               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;
+                       }
                }
-      } else
-      if (state == ProgressState.APPROVED) {
-       if (_isauthor) {
-                       return true;
+               return true;
+       }
+
+       /**
+        * Checks if the user has right to version the selected document. In-Work documents can be versioned by both, the author of the document
+        * and the responsible of study, while documents In-Draft can be versioned by the reviewer only. Additionally, Approved documents can
+        * also be versioned by their author in order to enter in a new modification validation cycle.
+        * 
+        * @return true if the user has right to version the document.
+        * @see Step#versionDocument(Publication)
+        * @see Step#versionDocument(Publication, Document.Properties)
+        * @see Step#versionDocument(Publication, String)
+        */
+       public boolean canVersion() {
+               User manager = _operand.getOwnerStudy().getAuthor();
+               User reviewer = _cycle.getActor(ValidationStep.REVIEW); // May be null if not reviewable
+               ProgressState state = _operand.value().getProgressState();
+
+               if (state == ProgressState.inWORK) {
+                       if (_isauthor || _user.equals(manager)) {
+                               return true;
+                       }
+               } else if (state == ProgressState.inDRAFT) {
+                       if (_user.equals(reviewer)) {
+                               return true;
+                       }
+               } else if (state == ProgressState.APPROVED) {
+                       if (_isauthor) {
+                               return true;
+                       }
+                       // MKA TODO:
+                       // Will be returned when "Version the external document" functionality is implemented
+                       /*
+                        * else if (state == ProgressState.EXTERN) { if (_isauthor || _user.equals(manager)) { return true; }
+                        */
                }
-      //MKA TODO:
-      //Will be returned when "Version the external document" functionality is implemented
-      /*else 
-      if (state == ProgressState.EXTERN) {
-       if (_isauthor || _user.equals(manager)) {
-               return true;
-       }*/
-      }   
-      return false;
- }
-
-//  ==============================================================================================================================
-//  Getter
-//  ==============================================================================================================================
+               return false;
+       }
 
-/**
- * Returns the document subject of checks according to this user rights.
- * 
- * @return the document subject of checks.
- */
-    public Document getOperand () {
-      return _operand.value();
-    }
+       // ==============================================================================================================================
+       // Getter
+       // ==============================================================================================================================
+
+       /**
+        * Returns the document subject of checks according to this user rights.
+        * 
+        * @return the document subject of checks.
+        */
+       public Document getOperand() {
+               return _operand.value();
+       }
 }
\ No newline at end of file