Salome HOME
More business logic has been moved from BO to services. ServiceLocator is created...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / dal / bo / som / ValidationCycle.java
index 8803d52e3799926583b07e4529ac16f471eaace4..989cd25befc67f1f08cbc9749647dbbf16e91d05 100644 (file)
@@ -100,44 +100,41 @@ public class ValidationCycle extends Persistent {
       { 
         if (doctype == null) throw new MissedPropertyException("type");
       }
+
+       /**
+        * Get the publisher.
+        * @return the publisher
+        */
+       public User getPublisher() {
+               return publisher;
+       }
+
+       /**
+        * Get the reviewer.
+        * @return the reviewer
+        */
+       public User getReviewer() {
+               return reviewer;
+       }
+
+       /**
+        * Get the approver.
+        * @return the approver
+        */
+       public User getApprover() {
+               return approver;
+       }
+
+       /**
+        * Get the signatory.
+        * @return the signatory
+        */
+       public User getSignatory() {
+               return signatory;
+       }
     }
 //  Database fetch constructor
-    protected ValidationCycle () {
-    }
-//  Internal constructors
-    protected ValidationCycle (Study from, ProjectSettingsServiceImpl.ProjectSettingsValidationCycle cycle) {
-//  -----------------------------------------------------------------------------
-      Actor[]         actype = cycle.getActorTypes();
-      User.Properties uprop  = new User.Properties();
-
-      mytype  = Document.selectType(cycle.getName());     // Null in case of default validation cycle
-//    context = new ValidationCycleRelation(from, this);
-      context = null;                                     // Validation cycle defined in the workflow
-      for (int i=0; i<actype.length; i++) {
-        User actor = null;
-        if (actype[i] != null)
-        try {
-          if (actype[i] == Actor.manager) {
-            actor = from.getAuthor();
-          } else
-          if (actype[i] == Actor.Nx1) {
-            List<User> manager = UserDirectory.selectUsersWhere(uprop.setOrganizationName("Nx1"));
-            if (manager.size() == 1) actor = manager.get(0);
-          } else
-          if (actype[i] == Actor.Nx2) {
-            List<User> manager = UserDirectory.selectUsersWhere(uprop.setOrganizationName("Nx2"));
-            if (manager.size() == 1) actor = manager.get(0);
-          } else {      /* Actor.customer */
-            actor = from.getAuthor();
-//TODO: Get the customer of the study, if exists
-          }
-        } catch (Exception e) {      // Should not happen
-          actor = null;
-        }
-        if      (i == 0) reviewer  = actor;
-        else if (i == 1) approver  = actor;
-        else if (i == 2) signatory = actor;
-      }
+    public ValidationCycle () {
     }
     public ValidationCycle (Study from, Properties vprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
 //  --------------------------------------------------------
@@ -214,8 +211,16 @@ public class ValidationCycle extends Persistent {
  * @see    #isDefault()
  */
     public DocumentType getDocumentType () {
-//  --------------------------------------
-      return mytype;                    // May be null
+    //  --------------------------------------
+          return mytype;                    // May be null
+        }
+
+    /**
+     * Set a document type for the validation cycle.
+     * @param aType the document type
+     */
+    public void setDocumentType (DocumentType aType) {
+          mytype = aType;                    // May be null
     }
 
 /**
@@ -252,30 +257,32 @@ public class ValidationCycle extends Persistent {
 //  -----------------------------------------------
       return context;
     }
-
-    protected void remove (ValidationStep step) {
-//  ------------------------------------------
-      if      (step == ValidationStep.REVIEW)     reviewer  = null;
-      else if (step == ValidationStep.APPROVAL)   approver  = null;
-      else if (step == ValidationStep.ACCEPTANCE || step == ValidationStep.REFUSAL) signatory = null;
-      if (this.isSaved()) Database.getSession().update(this);
-    }
-
-    public void resetActors (Properties vprop) {
-//  ---------------------------------------------
-      publisher = vprop.publisher;   // May be null
-      reviewer  = vprop.reviewer;    // May be null
-      approver  = vprop.approver;    // May be null
-      signatory = vprop.signatory;   // May be null
-      if (this.isSaved()) Database.getSession().update(this);
-    }
-
-    protected void setActor (ValidationStep step, 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 (this.isSaved()) Database.getSession().update(this);
-    }
+       /**
+        * Set the publisher.
+        * @param publisher the publisher to set
+        */
+       public void setPublisher(User publisher) {
+               this.publisher = publisher;
+       }
+       /**
+        * Set the reviewer.
+        * @param reviewer the reviewer to set
+        */
+       public void setReviewer(User reviewer) {
+               this.reviewer = reviewer;
+       }
+       /**
+        * Set the approver.
+        * @param approver the approver to set
+        */
+       public void setApprover(User approver) {
+               this.approver = approver;
+       }
+       /**
+        * Set the signatory.
+        * @param signatory the signatory to set
+        */
+       public void setSignatory(User signatory) {
+               this.signatory = signatory;
+       }
 }
\ No newline at end of file