Salome HOME
Modifications done to respect PMD rules. Versioning a document is fixed. Validation...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / som / StudyRights.java
index c4bf7f954df64b8fb91f772f224900f61782ee00..7a724e1d1c007328a3270985e258ecc20dd5c769 100644 (file)
@@ -16,23 +16,23 @@ import org.splat.service.ServiceLocatorImpl;
 
 public class StudyRights {
 
-    private User     user;
-    private Study    operand;
-    private boolean  author = false;                    // For optimizing 
-       public StudyRights (User user, Study study) {
+    private final transient User     _user;
+    private final transient Study    _operand;
+    private transient boolean  _author = false;                    // For optimizing 
+       public StudyRights (final User user, final Study study) {
 //  -------------------------------------------
-      this.user    = user;
-      this.operand = study;
+      this._user    = user;
+      this._operand = study;
 
-      if (operand != null && operand.getAuthor() != null) {
-         this.author  = operand.getAuthor().equals(user);  // user may be null
+      if (_operand != null && _operand.getAuthor() != null) {
+         this._author  = _operand.getAuthor().equals(user);  // user may be null
       }
     }
-    public StudyRights (Study study) {
+    public StudyRights (final Study study) {
 //  --------------------------------
-      this.user    = study.getAuthor();
-      this.operand = study;
-      this.author  = true;                              // In order to ignore the author in this context
+      this._user    = study.getAuthor();
+      this._operand = study;
+      this._author  = true;                              // In order to ignore the author in this context
     }
 
 //  ==============================================================================================================================
@@ -41,8 +41,10 @@ public class StudyRights {
 
     public boolean canAddScenario () {
 //  --------------------------------
-      if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
-      return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(operand, user);
+      if (_operand.getProgressState() != ProgressState.inWORK && _operand.getProgressState() != ProgressState.inDRAFT) {
+               return false;
+       }
+      return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(_operand, _user);
     }
 
 /**
@@ -53,12 +55,12 @@ public class StudyRights {
  */
     public boolean canEditDescription () {
 //  ------------------------------------
-      return (operand.getAuthor().equals(user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(operand, user));
+      return (_operand.getAuthor().equals(_user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(_operand, _user));
     }
 
     public boolean canEditProperties () {
 //  -----------------------------------
-      return author;
+      return _author;
     }
 
 /**
@@ -69,26 +71,34 @@ public class StudyRights {
  */
     public boolean canPublish () {
 //  ----------------------------
-      if (!author) return false;
-      return (!operand.isPublic());
+      if (!_author) {
+               return false;
+       }
+      return (!_operand.isPublic());
     }
 
     public boolean canPurge () {
 //  --------------------------
-      if (!author) return false;
-      return operand.isVersioned();
+      if (!_author) {
+               return false;
+       }
+      return _operand.isVersioned();
     }
 
     public boolean canRemove () {
 //  ---------------------------
-      if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
-      return author;
+      if (_operand.getProgressState() != ProgressState.inWORK && _operand.getProgressState() != ProgressState.inDRAFT) {
+               return false;
+       }
+      return _author;
     }
 
     public boolean canVersion () {
 //  ----------------------------
-      if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
-      return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(operand, user);
+      if (_operand.getProgressState() != ProgressState.inWORK && _operand.getProgressState() != ProgressState.inDRAFT) {
+               return false;
+       }
+      return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(_operand, _user);
     }
 
 //  ==============================================================================================================================
@@ -97,6 +107,6 @@ public class StudyRights {
 
     public Study getOperand () {
 //  --------------------------
-      return operand;
+      return _operand;
     }
 }
\ No newline at end of file