Salome HOME
Preliminary version of the "Remove study" action is implemented.
authorrkv <rkv@opencascade.com>
Mon, 11 Mar 2013 13:09:33 +0000 (13:09 +0000)
committerrkv <rkv@opencascade.com>
Mon, 11 Mar 2013 13:09:33 +0000 (13:09 +0000)
Workspace/Siman-Common/src/org/splat/service/StudyService.java
Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java
Workspace/Siman/src/org/splat/simer/ApplicationSettings.java
Workspace/Siman/src/org/splat/simer/EditStudyAction.java
Workspace/Siman/src/org/splat/simer/RemoveStudyAction.java [new file with mode: 0644]
Workspace/Siman/src/spring/applicationContext.xml
Workspace/Siman/src/struts.xml

index ddc4c0f9316f5fa1241288d98bf38cd3094588f9..277ea777f9d3bef4d643fa688fe3e64837dcf168 100644 (file)
@@ -52,6 +52,14 @@ public interface StudyService {
         */
        Study selectStudy(long index);
 
+       /**
+        * Delete the study.
+        * 
+        * @param index
+        *            the study id
+        */
+       public void removeStudy(final long index);
+
        /**
         * Create a new study.
         * 
index 7a48fb602b825423996f1417ddda6d4e35a1e155..2e3fc4538e3f9af18d1473a7f3099a09c8ec20c1 100644 (file)
@@ -177,6 +177,18 @@ public class StudyServiceImpl implements StudyService {
                return result;
        }
 
+       /** 
+        * {@inheritDoc}
+        * @see org.splat.service.StudyService#removeStudy(long)
+        */
+       @Transactional
+       public void removeStudy(final long index) {
+               Study study = getStudyDAO().get(index);
+               if (study != null) {
+                       getStudyDAO().delete(study);
+               }
+       }
+
        /**
         * Get study by its reference.
         * 
index e39cf3d7826075a098e917eb1b6f87377ec0c853..99fdb59a957150f1e90fd2b5ada4162ad75993d9 100644 (file)
@@ -512,7 +512,7 @@ public class ApplicationSettings {
                         * addItem(MNU_PURGE, new PopupItem(MNU_NAME_PURGE) .confirmation("message.purge.study")); addItem("export", new
                         * PopupItem("menu.export") .icon("image.export.png")); // For future needs
                         */addItem(MNU_REMOVE, new PopupItem(MNU_NAME_REMOVE).icon(
-                                       IMG_DELETE).action(ACT_NOT_YET_IMPLEMENTED).confirmation(
+                                       IMG_DELETE).action("remove-study").confirmation(
                                        "message.delete.study"));
                }
 
index afff22ef816af044e684e2ff66c55913cc5dd4be..928ba6ed5f52b1e9ccd4d1acbe606091aecdea32 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,11 +8,6 @@ public class EditStudyAction extends DisplayStudyStepAction {
         * Serial version ID.
         */
        private static final long serialVersionUID = -4865668290514118396L;
-       
-       /**
-        * Injected study service.
-        */
-       private StudyService _studyService;
 
        private enum Execute {
                publish, protect, promote
@@ -52,7 +46,7 @@ public class EditStudyAction extends DisplayStudyStepAction {
                _openStudy = getOpenStudy();
                Study study = _openStudy.getStudyObject();
                
-               _studyService.markStudyAsReference(study);
+               getStudyService().markStudyAsReference(study);
                
                return SUCCESS;
        }
@@ -66,30 +60,8 @@ public class EditStudyAction extends DisplayStudyStepAction {
                _openStudy = getOpenStudy();
                Study study = _openStudy.getStudyObject();
                
-               _studyService.removeStudyAsReference(study);
+               getStudyService().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;
-       }
-
 }
\ No newline at end of file
diff --git a/Workspace/Siman/src/org/splat/simer/RemoveStudyAction.java b/Workspace/Siman/src/org/splat/simer/RemoveStudyAction.java
new file mode 100644 (file)
index 0000000..85cf487
--- /dev/null
@@ -0,0 +1,64 @@
+/*****************************************************************************
+ * Company         OPEN CASCADE
+ * Application     SIMAN
+ * File            $Id$ 
+ * Creation date   11.03.2013
+ * @author         $Author$
+ * @version        $Revision$
+ * @copyright      OPEN CASCADE 2012
+ *****************************************************************************/
+
+package org.splat.simer;
+
+import org.splat.service.StudyService;
+
+/**
+ * The action for removing a study.
+ * 
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ */
+public class RemoveStudyAction extends Action {
+       /**
+        * Serialization version UID.
+        */
+       private static final long serialVersionUID = -6914581042309013794L;
+       /**
+        * Injected study service.
+        */
+       private StudyService _studyService;
+
+       /**
+        * Remove the selected study.
+        * 
+        * @return SUCCESS
+        */
+       public String doRemove() {
+               OpenStudy openStudy = getOpenStudy();
+               if (openStudy != null && openStudy.isOpenForWriting()) {
+                       long id = openStudy.getIndex();
+                       getStudyService().removeStudy(id);
+               }
+               closeStudy();
+               initializationScreenContext("none");
+               return SUCCESS;
+       }
+
+       /**
+        * Get the studyService.
+        * 
+        * @return the studyService
+        */
+       public StudyService getStudyService() {
+               return _studyService;
+       }
+
+       /**
+        * Set the studyService.
+        * 
+        * @param studyService
+        *            the studyService to set
+        */
+       public void setStudyService(final StudyService studyService) {
+               _studyService = studyService;
+       }
+}
index 643374cdb757d747ba1ec5446074897963927514..a7ce2df303515eec1ab9eff97b06b4f132df67ba 100644 (file)
@@ -156,6 +156,11 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                <property name="studyService" ref="studyService" />
        </bean>
 
+    <bean id="removeStudyAction" class="org.splat.simer.RemoveStudyAction"
+        scope="prototype" parent="baseAction">
+        <property name="studyService" ref="studyService" />
+    </bean>
+
        <!--========= Inherited from displayStudyStepAction ========= -->
 
        <bean id="studyPropertiesAction"
@@ -165,11 +170,10 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                <property name="userService" ref="userService" />
        </bean>
 
-       <bean id="editStudyAction" class="org.splat.simer.EditStudyAction"
-               scope="prototype" parent="displayStudyStepAction">
-               <property name="studyService" ref="studyService" />
-       </bean>
-
+    <bean id="editStudyAction" class="org.splat.simer.EditStudyAction"
+        scope="prototype" parent="displayStudyStepAction">
+    </bean>
+    
        <bean id="editScenarioPropertiesAction"
                class="org.splat.simer.EditScenarioPropertiesAction" scope="prototype"
                parent="displayStudyStepAction">
@@ -292,6 +296,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                <property name="projectSettings" ref="projectSettings" />
                <property name="publicationService" ref="publicationService" />
                <property name="stepService" ref="stepService" />
+        <property name="studyService" ref="studyService" />
                <property name="repositoryService" ref="repositoryService" />
        </bean>
 
index 00271a70ed2ff8afae5ce9419ac2e5c27dc86bbb..ffebe53a57da246a688fdbb1eb6c0c729a6a0f2d 100644 (file)
                                page.displaystudy
                        </result>
                </action>
-               <action name="close-study" class="displayStudyStepAction"
-                       method="close">
-                       <result name="success" type="tiles">page.home</result>
-               </action>
+        <action name="close-study" class="displayStudyStepAction"
+            method="close">
+            <result name="success" type="tiles">page.home</result>
+        </action>
+        <action name="remove-study" class="removeStudyAction"
+            method="remove">
+            <result name="success" type="tiles">page.home</result>
+        </action>
                <action name="prop-study" class="studyPropertiesAction"
                        method="initialize">
                        <result name="display" type="tiles">