Salome HOME
Study validation cycle operations are implemented according to the specification.
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / EditStudyAction.java
index 7c77a53a78883d36b5c402e1104585548c49850d..73c5c95f364bd76734e69447a4096823aee117e3 100644 (file)
 package org.splat.simer;
 
 import org.splat.dal.bo.som.Study;
-import org.splat.service.StudyService;
-
 
 public class EditStudyAction extends DisplayStudyStepAction {
-    
+
        /**
         * Serial version ID.
         */
-    private static final long serialVersionUID = -4865668290514118396L;
-
-       private enum Execute { publish, promote }
+       private static final long serialVersionUID = -4865668290514118396L;
 
-       private StudyService _studyService;
-       
-       /**
-        * Value of the menu property. 
-        * It can be: none, create, open, study, knowledge, sysadmin, help.
-        */
-       private String _menuProperty;
-       
-       /**
-        * Value of the title bar property. 
-        * It can be: study, knowledge.
-        */
-       private String _titleProperty;
-       
-       /**
-        * Value of the tool bar property. 
-        * It can be: none, standard, study, back.
-        */
-       private String _toolProperty;
-       
        /**
-        * Property that indicates whether the current open study is editable or not.
-        * On the screen it looks like pen on the status icon, pop-up menu also can be called.
-        * It is necessary for correct building the title bar.
+        * Possible operations on a study.
         */
-       private String _editDisabledProperty = "false";
-
-//  ==============================================================================================================================
-//  Action methods
-//  ==============================================================================================================================
-
-    public String doEdition () {
-         try {
-        mystudy = getOpenStudy();
-
-        Execute  todo   = Execute.valueOf(action);
-        Study    study  = mystudy.getStudyObject();
-        
-        if      (todo == Execute.publish) getStudyService().moveToPublic(study);
-        else if (todo == Execute.promote) getStudyService().moveToReference(study);
-        mystudy.getPopup().setContext("study", mystudy.getStudyRights());   // The context has changed
-        
-        setMenuProperty("study");
-        setTitleProperty("study");
-        if ("true".equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
-                       setToolProperty("study");
-               } else {
-                       setToolProperty("standard");
-               }
-               initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty);
-
-        return SUCCESS;
-         }
-      catch (RuntimeException saverror) {
-        logger.error("Reason:", saverror);
-        return ERROR;
-      }
-    }
-       /**
-        * Get the studyService.
-        * 
-        * @return the studyService
-        */
-       public StudyService getStudyService() {
-               return _studyService;
+       private enum Execute {
+               /**
+                * 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
+       // =========================================================================
+
        /**
-        * Set the studyService.
+        * Perform operation on the selected study.
         * 
-        * @param studyService
-        *            the studyService to set
-        */
-       public void setStudyService(StudyService studyService) {
-               _studyService = studyService;
-       }
-       
-       /**
-        * Get the menuProperty.
-        * @return the menuProperty
+        * @return SUCCESS
         */
-       public String getMenuProperty() {
-               return _menuProperty;
-       }
+       public String doEdition() {
+               _openStudy = getOpenStudy();
 
-       /**
-        * Set the menuProperty.
-        * @param menuProperty the menuProperty to set
-        */
-       public void setMenuProperty(String menuProperty) {
-               this._menuProperty = menuProperty;
-       }
-       
-       /**
-        * Get the _titleProperty.
-        * @return the _titleProperty
-        */
-       public String getTitleProperty() {
-               return _titleProperty;
-       }
+               Execute todo = Execute.valueOf(_action);
+               Study study = _openStudy.getStudyObject();
 
-       /**
-        * Set the _titleProperty.
-        * @param _titleProperty the titleProperty to set
-        */
-       public void setTitleProperty(String titleProperty) {
-               _titleProperty = titleProperty;
-       }
-       /**
-        * Get the editDisabledProperty.
-        * @return the editDisabledProperty
-        */
-       public final String getEditDisabledProperty() {
-               return _editDisabledProperty;
-       }
-       /**
-        * Set the editDisabledProperty.
-        * @param editDisabledProperty the editDisabledProperty to set
-        */
-       public final void setEditDisabledProperty(String editDisabledProperty) {
-               _editDisabledProperty = editDisabledProperty;
+               if (todo == Execute.publish) {
+                       getStudyService().moveToPublic(study);
+               } else if (todo == Execute.protect) {
+                       getStudyService().moveToPrivate(study);
+               } else if (todo == Execute.promote) {
+                       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;
        }
-       
+
        /**
-        * Get the toolProperty.
-        * @return the toolProperty
+        * Mark study as reference functionality.
+        * 
+        * @return SUCCESS
         */
-       public String getToolProperty() {
-               return _toolProperty;
+       public String doMarkAsReference() {
+
+               _openStudy = getOpenStudy();
+               Study study = _openStudy.getStudyObject();
+
+               getStudyService().markStudyAsReference(study);
+
+               _myindex = null;
+               _selection = _openStudy.getSelection(); // actually, value doesn't matter, it just has to be not null
+               doOpen();
+               return SUCCESS;
        }
 
        /**
-        * Set the toolProperty.
-        * @param toolProperty the toolProperty to set
+        * Remove study as reference functionality.
+        * 
+        * @return SUCCESS
         */
-       public void setToolProperty(final String toolProperty) {
-               _toolProperty = toolProperty;
-       }
+       public String doRemoveAsReference() {
+
+               _openStudy = getOpenStudy();
+               Study study = _openStudy.getStudyObject();
 
+               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