From 163fffba7be007562e7eab68a4391151a89ff2a7 Mon Sep 17 00:00:00 2001 From: rkv Date: Mon, 22 Oct 2012 10:16:36 +0000 Subject: [PATCH] ImportDocumentAction got rid of Database class usage. EditSimulationContextAction is fixed as some methods have been moved from SimulationContextService to SimulationContextTypeService. --- .../simer/EditSimulationContextAction.java | 24 ++++++++++++++++++- .../org/splat/simer/ImportDocumentAction.java | 22 +++-------------- .../Siman/src/spring/applicationContext.xml | 9 ++++--- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/Workspace/Siman/src/org/splat/simer/EditSimulationContextAction.java b/Workspace/Siman/src/org/splat/simer/EditSimulationContextAction.java index 20ea3c6..79718e2 100644 --- a/Workspace/Siman/src/org/splat/simer/EditSimulationContextAction.java +++ b/Workspace/Siman/src/org/splat/simer/EditSimulationContextAction.java @@ -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 diff --git a/Workspace/Siman/src/org/splat/simer/ImportDocumentAction.java b/Workspace/Siman/src/org/splat/simer/ImportDocumentAction.java index e35e72d..e030492 100644 --- a/Workspace/Siman/src/org/splat/simer/ImportDocumentAction.java +++ b/Workspace/Siman/src/org/splat/simer/ImportDocumentAction.java @@ -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; } diff --git a/Workspace/Siman/src/spring/applicationContext.xml b/Workspace/Siman/src/spring/applicationContext.xml index 33a9369..c7f34a5 100644 --- a/Workspace/Siman/src/spring/applicationContext.xml +++ b/Workspace/Siman/src/spring/applicationContext.xml @@ -114,7 +114,8 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - + + class="org.splat.simer.EditSimulationContextAction" scope="prototype" parent="displayStudyStepAction"> - + +