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;
// ==============================================================================================================================
public String doInitialize() {
- // -----------------------------
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
mystudy = getOpenStudy();
contype = getInvolvedContexts();
- transax.commit();
if (contype.isEmpty())
return "create";
else
}
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)
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();
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;
}
}
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();
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;
}
}