Salome HOME
ImportDocumentAction got rid of Database class usage. EditSimulationContextAction...
authorrkv <rkv@opencascade.com>
Mon, 22 Oct 2012 10:16:36 +0000 (10:16 +0000)
committerrkv <rkv@opencascade.com>
Mon, 22 Oct 2012 10:16:36 +0000 (10:16 +0000)
Workspace/Siman/src/org/splat/simer/EditSimulationContextAction.java
Workspace/Siman/src/org/splat/simer/ImportDocumentAction.java
Workspace/Siman/src/spring/applicationContext.xml

index 20ea3c69c6e2f0639ae774f040cf967f5d900411..79718e2123d70ebef0c827b3c4536cfa37d85798 100644 (file)
@@ -7,6 +7,7 @@ import org.splat.dal.bo.som.ProjectElement;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.SimulationContextType;
 import org.splat.service.SimulationContextService;
+import org.splat.service.SimulationContextTypeService;
 import org.splat.service.StepService;
 import org.splat.service.StudyService;
 import org.splat.som.Step;
@@ -32,6 +33,10 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
         * Injected simulation context service.
         */
        private SimulationContextService _simulationContextService;
+       /**
+        * Injected simulation context type service.
+        */
+       private SimulationContextTypeService _simulationContextTypeService;
 
        /**
         * Get the stepService.
@@ -97,7 +102,7 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
 
                        SimulationContext.Properties cprop = new SimulationContext.Properties();
                        SimulationContext contex = null;
-                       type = getSimulationContextService().createType(newtype,
+                       type = getSimulationContextTypeService().createType(newtype,
                                        step.getStep());
                        cprop.setType(type).setValue(value);
                        if (owner instanceof Study)
@@ -304,4 +309,21 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                        SimulationContextService simulationContextService) {
                _simulationContextService = simulationContextService;
        }
+
+       /**
+        * Get the simulationContextTypeService.
+        * @return the simulationContextTypeService
+        */
+       public SimulationContextTypeService getSimulationContextTypeService() {
+               return _simulationContextTypeService;
+       }
+
+       /**
+        * Set the simulationContextTypeService.
+        * @param simulationContextTypeService the simulationContextTypeService to set
+        */
+       public void setSimulationContextTypeService(
+                       SimulationContextTypeService simulationContextTypeService) {
+               _simulationContextTypeService = simulationContextTypeService;
+       }
 }
\ No newline at end of file
index e35e72d9e44fd80fb7ea1071d08bae0fb57acb07..e03049272e1d8f7e7b20ac8ea8ca6684e2ae01b7 100644 (file)
@@ -10,13 +10,9 @@ import java.util.List;
 import java.util.ResourceBundle;
 import java.util.Vector;
 
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
 import org.splat.dal.bo.kernel.User;
 import org.splat.manox.Reader;
 import org.splat.manox.Toolbox;
-import org.splat.dal.dao.som.Database;
 import org.splat.dal.bo.som.Document;
 import org.splat.dal.bo.som.ProgressState;
 import org.splat.service.DocumentService;
@@ -30,6 +26,9 @@ import org.splat.dal.bo.som.DocumentType;
 import org.splat.som.Revision;
 import org.splat.som.Step;
 
+/**
+ * Action for adding a document into a study step.
+ */
 public class ImportDocumentAction extends UploadBaseNextAction {
 
        /**
@@ -76,9 +75,6 @@ public class ImportDocumentAction extends UploadBaseNextAction {
         * @return SUCCESS in success, otherwise - ERROR
         */
        public String doInitialize() {
-               // -----------------------------
-               Session connex = Database.getCurSession();
-               Transaction transax = connex.beginTransaction();
                User user = getConnectedUser();
                File updir = getRepositoryService().getDownloadDirectory(user);
                File upfile = new File(updir.getPath() + "/" + filename);
@@ -166,7 +162,6 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                Arrays.sort(types, compare);
                doctypes = Arrays.asList(types);
 
-               transax.commit();
                return SUCCESS;
        }
 
@@ -182,8 +177,6 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                        setErrorCode("import.type");
                        return ERROR;
                }
-               Session connex = Database.getCurSession();
-               Transaction transax = connex.beginTransaction();
                try {
                        // Getting user inputs
                        mystudy = getOpenStudy();
@@ -263,7 +256,6 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                        // Converter send = ApplicationSettings.getConverter(ndoc.getType(), ndoc.getFormat());
                        //
                        // if (send != null) send.converts(addoc); // Asynchronous process
-                       transax.commit();
 
                        mystudy.add(addoc); // Updates the presentation
                        return SUCCESS;
@@ -274,14 +266,6 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                        logger.error("Reason:", error);
                        setErrorCode("internal");
                }
-               if (transax != null && transax.isActive()) { // Probably useless test
-               // Second try-catch as the rollback could fail as well
-                       try {
-                               transax.rollback();
-                       } catch (HibernateException backerror) {
-                               logger.debug("Error rolling back transaction", backerror);
-                       }
-               }
                return ERROR;
        }
 
index 33a9369a91003067b8cea740cbf356586c2d12d6..c7f34a55ecfb26c90725e2eaf70923668bf7d15d 100644 (file)
@@ -114,7 +114,8 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                <property name="projectSettings" ref="projectSettings" />
                <property name="publicationService" ref="publicationService" />
                <property name="repositoryService" ref="repositoryService" />
-               <property name="documentTypeService" ref="documentTypeService" />
+        <property name="documentService" ref="documentService" />
+        <property name="documentTypeService" ref="documentTypeService" />
        </bean>
 
        <bean id="displayStudyStepAction"
@@ -148,8 +149,10 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                class="org.splat.simer.EditSimulationContextAction" scope="prototype"
                parent="displayStudyStepAction">
                <property name="stepService" ref="stepService" />
-               <property name="simulationContextService"
-                       ref="simulationContextService" />
+        <property name="simulationContextService"
+            ref="simulationContextService" />
+        <property name="simulationContextTypeService"
+            ref="simulationContextTypeService" />
        </bean>
 
        <bean id="editDocumentAction"