Salome HOME
Study validation cycle operations are implemented according to the specification.
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / EditStudyAction.java
index afff22ef816af044e684e2ff66c55913cc5dd4be..73c5c95f364bd76734e69447a4096823aee117e3 100644 (file)
@@ -1,7 +1,6 @@
 package org.splat.simer;
 
 import org.splat.dal.bo.som.Study;
-import org.splat.service.StudyService;
 
 public class EditStudyAction extends DisplayStudyStepAction {
 
@@ -9,20 +8,38 @@ public class EditStudyAction extends DisplayStudyStepAction {
         * Serial version ID.
         */
        private static final long serialVersionUID = -4865668290514118396L;
-       
+
        /**
-        * Injected study service.
+        * Possible operations on a study.
         */
-       private StudyService _studyService;
-
        private enum Execute {
-               publish, protect, promote
+               /**
+                * Publish a study.
+                */
+               publish,
+               /**
+                * Make published study private.
+                */
+               protect,
+               /**
+                * Promote a study to the next state.
+                */
+               promote,
+               /**
+                * Demote a study from In-Draft or In-Check to In-Work.
+                */
+               demote
        }
 
-       // ==============================================================================================================================
+       // =========================================================================
        // Action methods
-       // ==============================================================================================================================
+       // =========================================================================
 
+       /**
+        * Perform operation on the selected study.
+        * 
+        * @return SUCCESS
+        */
        public String doEdition() {
                _openStudy = getOpenStudy();
 
@@ -34,62 +51,54 @@ public class EditStudyAction extends DisplayStudyStepAction {
                } else if (todo == Execute.protect) {
                        getStudyService().moveToPrivate(study);
                } else if (todo == Execute.promote) {
-                       getStudyService().moveToReference(study);
+                       getStudyService().promote(study);
+               } else if (todo == Execute.demote) {
+                       getStudyService().demote(study);
                }
+//             _openStudy.getMenu().refreshSelectedItem(); // Updates the menu icon, in case of other documents in approved state
                _openStudy.getPopup().setContext("study", _openStudy.getStudyRights()); // The context has changed
 
                setMenu();
 
+               _myindex = null;
+               _selection = _openStudy.getSelection(); // actually, value doesn't matter, it just has to be not null
+               doOpen();
                return SUCCESS;
        }
-       
+
        /**
         * Mark study as reference functionality.
+        * 
         * @return SUCCESS
         */
        public String doMarkAsReference() {
-               
+
                _openStudy = getOpenStudy();
                Study study = _openStudy.getStudyObject();
-               
-               _studyService.markStudyAsReference(study);
-               
+
+               getStudyService().markStudyAsReference(study);
+
+               _myindex = null;
+               _selection = _openStudy.getSelection(); // actually, value doesn't matter, it just has to be not null
+               doOpen();
                return SUCCESS;
        }
-       
+
        /**
         * Remove study as reference functionality.
+        * 
         * @return SUCCESS
         */
        public String doRemoveAsReference() {
-               
+
                _openStudy = getOpenStudy();
                Study study = _openStudy.getStudyObject();
-               
-               _studyService.removeStudyAsReference(study);
-               
-               return SUCCESS;
-       }
-       
-       /**
-        * Get the studyService.
-        * 
-        * @return the studyService
-        */
-       @Override
-       public StudyService getStudyService() {
-               return _studyService;
-       }
 
-       /**
-        * Set the studyService.
-        * 
-        * @param studyService
-        *            the studyService to set
-        */
-       @Override
-       public void setStudyService(final StudyService studyService) {
-               _studyService = studyService;
-       }
+               getStudyService().removeStudyAsReference(study);
 
+               _myindex = null;
+               _selection = _openStudy.getSelection(); // actually, value doesn't matter, it just has to be not null
+               doOpen();
+               return SUCCESS;
+       }
 }
\ No newline at end of file