Salome HOME
Modifications done to respect PMD rules. Versioning a document is fixed. Validation...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / dal / bo / som / ValidationCycle.java
index 989cd25befc67f1f08cbc9749647dbbf16e91d05..072130a233394b6deef911728410c8e6b78422e3 100644 (file)
@@ -26,17 +26,13 @@ package org.splat.dal.bo.som;
  * @copyright OPEN CASCADE 2012
  */
 
-import java.util.List;
 import java.util.Vector;
 
 import org.splat.dal.bo.kernel.Persistent;
 import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.som.Database;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
 import org.splat.kernel.MultiplyDefinedException;
-import org.splat.kernel.UserDirectory;
-import org.splat.service.technical.ProjectSettingsServiceImpl;
 
 public class ValidationCycle extends Persistent {
 
@@ -69,7 +65,8 @@ public class ValidationCycle extends Persistent {
 
 //  - Public services
 
-      public void clear () {
+      @Override
+       public void clear () {
         super.clear();
         doctype   = null;
         publisher = null;
@@ -79,26 +76,33 @@ public class ValidationCycle extends Persistent {
       }
 //  - Protected services
 
-      public Properties setDocumentType (DocumentType type)
+      public Properties setDocumentType (final DocumentType type)
       {
         doctype = type;
        return this;
       }
 //  - Properties setter
 
-      public Properties setActor (ValidationStep step, User actor)
+      public Properties setActor (final ValidationStep step, final User actor)
       {
-        if      (step == ValidationStep.PROMOTION) publisher = actor;
-        else if (step == ValidationStep.REVIEW)    reviewer  = actor;
-        else if (step == ValidationStep.APPROVAL)  approver  = actor;
-        else if (step == ValidationStep.ACCEPTANCE || step == ValidationStep.REFUSAL) signatory = actor;
+        if      (step == ValidationStep.PROMOTION) {
+                       publisher = actor;
+               } else if (step == ValidationStep.REVIEW) {
+                       reviewer  = actor;
+               } else if (step == ValidationStep.APPROVAL) {
+                       approver  = actor;
+               } else if (step == ValidationStep.ACCEPTANCE || step == ValidationStep.REFUSAL) {
+                       signatory = actor;
+               }
         return this;
       }
 //  - Global validity check
         
       public void checkValidity() throws MissedPropertyException
       { 
-        if (doctype == null) throw new MissedPropertyException("type");
+        if (doctype == null) {
+                       throw new MissedPropertyException("type");
+               }
       }
 
        /**
@@ -136,8 +140,7 @@ public class ValidationCycle extends Persistent {
 //  Database fetch constructor
     public ValidationCycle () {
     }
-    public ValidationCycle (Study from, Properties vprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
-//  --------------------------------------------------------
+    public ValidationCycle (final Study from, final Properties vprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
       super(vprop);                  // Throws one of the above exception if not valid
       mytype    = vprop.doctype;
       publisher = vprop.publisher;   // May be null
@@ -156,12 +159,16 @@ public class ValidationCycle extends Persistent {
  * @param  step the validation step checked.
  * @return true if the given validation step is enabled.
  */
-    public boolean enables (ValidationStep step) {
-//  -------------------------------------------
-      if      (step == ValidationStep.PROMOTION) return true;
-      else if (step == ValidationStep.REVIEW)    return (reviewer  != null);
-      else if (step == ValidationStep.APPROVAL)  return (approver  != null);
-      else if (step == ValidationStep.ACCEPTANCE || step == ValidationStep.REFUSAL) return (signatory != null);
+    public boolean enables (final ValidationStep step) {
+      if      (step == ValidationStep.PROMOTION) {
+               return true;
+       } else if (step == ValidationStep.REVIEW) {
+               return (reviewer  != null);
+       } else if (step == ValidationStep.APPROVAL) {
+               return (approver  != null);
+       } else if (step == ValidationStep.ACCEPTANCE || step == ValidationStep.REFUSAL) {
+               return (signatory != null);
+       }
       return false;
     }
 
@@ -176,12 +183,16 @@ public class ValidationCycle extends Persistent {
  * @see    #getAllActors()
  * @see    #enables
  */
-    public User getActor (ValidationStep step) {
-//  -----------------------------------------
-      if      (step == ValidationStep.PROMOTION) return publisher;
-      else if (step == ValidationStep.REVIEW)    return reviewer;
-      else if (step == ValidationStep.APPROVAL)  return approver;
-      else if (step == ValidationStep.ACCEPTANCE || step == ValidationStep.REFUSAL) return signatory;
+    public User getActor (final ValidationStep step) {
+      if      (step == ValidationStep.PROMOTION) {
+               return publisher;
+       } else if (step == ValidationStep.REVIEW) {
+               return reviewer;
+       } else if (step == ValidationStep.APPROVAL) {
+               return approver;
+       } else if (step == ValidationStep.ACCEPTANCE || step == ValidationStep.REFUSAL) {
+               return signatory;
+       }
       return null;
     }
 
@@ -196,10 +207,18 @@ public class ValidationCycle extends Persistent {
     public User[] getAllActors () {
 //  -----------------------------
       Vector<User> result = new Vector<User>();
-      if (publisher != null) result.add(publisher);
-      if (reviewer  != null) result.add(reviewer);
-      if (approver  != null) result.add(approver);
-      if (signatory != null) result.add(signatory);
+      if (publisher != null) {
+               result.add(publisher);
+       }
+      if (reviewer  != null) {
+               result.add(reviewer);
+       }
+      if (approver  != null) {
+               result.add(approver);
+       }
+      if (signatory != null) {
+               result.add(signatory);
+       }
       return  result.toArray(new User[result.size()]);
     }
 
@@ -211,7 +230,6 @@ public class ValidationCycle extends Persistent {
  * @see    #isDefault()
  */
     public DocumentType getDocumentType () {
-    //  --------------------------------------
           return mytype;                    // May be null
         }
 
@@ -219,7 +237,7 @@ public class ValidationCycle extends Persistent {
      * Set a document type for the validation cycle.
      * @param aType the document type
      */
-    public void setDocumentType (DocumentType aType) {
+    public void setDocumentType (final DocumentType aType) {
           mytype = aType;                    // May be null
     }
 
@@ -230,7 +248,6 @@ public class ValidationCycle extends Persistent {
  * @return true if this validation cycle is assigned to a study.
  */
     public boolean isAssigned () {
-//  ----------------------------
       return (context != null);
     }
 
@@ -242,17 +259,11 @@ public class ValidationCycle extends Persistent {
  * 
  * @return true if this validation cycle is a default one.
  * @see    #getDocumentType()
- * @see    ProjectSettingsServiceImpl#getNewValidationCycle()
  */
     public boolean isDefault () {
-//  ---------------------------
      return (mytype == null);
     }
 
-//  ==============================================================================================================================
-//  Protected services
-//  ==============================================================================================================================
-
     public ValidationCycleRelation getContext () {
 //  -----------------------------------------------
       return context;
@@ -261,28 +272,28 @@ public class ValidationCycle extends Persistent {
         * Set the publisher.
         * @param publisher the publisher to set
         */
-       public void setPublisher(User publisher) {
+       public void setPublisher(final User publisher) {
                this.publisher = publisher;
        }
        /**
         * Set the reviewer.
         * @param reviewer the reviewer to set
         */
-       public void setReviewer(User reviewer) {
+       public void setReviewer(final User reviewer) {
                this.reviewer = reviewer;
        }
        /**
         * Set the approver.
         * @param approver the approver to set
         */
-       public void setApprover(User approver) {
+       public void setApprover(final User approver) {
                this.approver = approver;
        }
        /**
         * Set the signatory.
         * @param signatory the signatory to set
         */
-       public void setSignatory(User signatory) {
+       public void setSignatory(final User signatory) {
                this.signatory = signatory;
        }
 }
\ No newline at end of file