]> SALOME platform Git repositories - tools/siman.git/blobdiff - Workspace/Siman/src/org/splat/simer/EditSimulationContextAction.java
Salome HOME
Refactoring continues: UserService is created instead of UserDirectory. Database...
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / EditSimulationContextAction.java
index d133314ec4b1719456cdc4cce7ecc81751d521ac..20ea3c69c6e2f0639ae774f040cf967f5d900411 100644 (file)
@@ -3,10 +3,6 @@ package org.splat.simer;
 import java.util.Arrays;
 import java.util.List;
 
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.splat.dal.dao.som.Database;
 import org.splat.dal.bo.som.ProjectElement;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.SimulationContextType;
@@ -63,14 +59,10 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
        // ==============================================================================================================================
 
        public String doInitialize() {
-               // -----------------------------
-               Session connex = Database.getSession();
-               Transaction transax = connex.beginTransaction();
 
                mystudy = getOpenStudy();
                contype = getInvolvedContexts();
 
-               transax.commit();
                if (contype.isEmpty())
                        return "create";
                else
@@ -78,32 +70,23 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
        }
 
        public String doSelectContext() {
-               // --------------------------------
-               Session connex = Database.getSession();
-               Transaction transax = connex.beginTransaction();
-               try {
-                       mystudy = getOpenStudy();
-                       int typid = Integer.valueOf(selectype);
-                       if (typid == 0)
-                               return "create";
+               mystudy = getOpenStudy();
+               int typid = Integer.valueOf(selectype);
+               if (typid == 0)
+                       return "create";
 
-                       SimulationContext.Properties cprop = new SimulationContext.Properties();
-                       type = getSimulationContextService().selectType(typid);
-                       newtype = type.getName();
-                       contype = getInvolvedContexts();
-                       contelm = getSimulationContextService()
-                                       .selectSimulationContextsWhere(cprop.setType(type));
+               SimulationContext.Properties cprop = new SimulationContext.Properties();
+               type = getSimulationContextService().selectType(typid);
+               newtype = type.getName();
+               contype = getInvolvedContexts();
+               contelm = getSimulationContextService()
+                               .selectSimulationContextsWhere(cprop.setType(type));
 
-                       return "set";
-               } finally {
-                       transax.commit();
-               }
+               return "set";
        }
 
        public String doCreateContext() {
                // --------------------------------
-               Session connex = Database.getSession();
-               Transaction transax = connex.beginTransaction();
                try {
                        mystudy = getOpenStudy();
                        if (newtype.length() == 0 || value.length() == 0)
@@ -124,29 +107,16 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                                contex = getStepService().addSimulationContext(step, cprop); // Re-indexes knowledges only
 
                        mystudy.add(contex);
-                       transax.commit();
                        return SUCCESS;
                } catch (RuntimeException saverror) {
                        logger.error("Reason:", saverror);
-                       if (transax != null && transax.isActive()) {
-                               // 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;
                } catch (Exception error) {
-                       transax.commit();
                        return INPUT;
                }
        }
 
        public String doDeleteContext() {
-               // --------------------------------
-               Session connex = Database.getSession();
-               Transaction transax = connex.beginTransaction();
                try {
                        mystudy = getOpenStudy();
 
@@ -161,18 +131,9 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                                getStepService().removeSimulationContext(step, context); // Re-indexes knowledges only
 
                        mystudy.remove(context);
-                       transax.commit();
                        return SUCCESS;
                } catch (RuntimeException saverror) {
                        logger.error("Reason:", saverror);
-                       if (transax != null && transax.isActive()) {
-                               // 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;
                }
        }
@@ -180,8 +141,8 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
        public String doSetContext() {
                // -----------------------------
                String[] input = value.split(",");
-               Session connex = Database.getSession();
-               Transaction transax = connex.beginTransaction();
+//             Session connex = Database.getCurSession();
+//             Transaction transax = connex.beginTransaction();
                try {
                        mystudy = getOpenStudy();
 
@@ -215,22 +176,13 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                        mystudy.add(contex);
                        contype = getInvolvedContexts();
 
-                       transax.commit();
+//                     transax.commit();
                        return SUCCESS;
                } catch (RuntimeException saverror) {
                        logger.error("Reason:", saverror);
-                       if (transax != null && transax.isActive()) {
-                               // 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;
                } catch (Exception error) {
                        value = input[0];
-                       transax.commit();
                        return INPUT;
                }
        }