]> SALOME platform Git repositories - tools/siman.git/blobdiff - Workspace/Siman/src/org/splat/module/SaveDocumentAction.java
Salome HOME
Refactoring of Database, replacing SQL by DAOs calls. Methods for search by criteria...
[tools/siman.git] / Workspace / Siman / src / org / splat / module / SaveDocumentAction.java
index d9d7bf1e72d810b89b1afe2814b7837089a101c4..a534902b1aefc45cb2979bb862d475de690cd774 100644 (file)
@@ -13,7 +13,9 @@ import org.splat.kernel.Do;
 import org.splat.dal.bo.kernel.User;
 import org.splat.service.PublicationService;
 import org.splat.service.ScenarioService;
+import org.splat.service.SimulationContextService;
 import org.splat.service.StepService;
+import org.splat.service.technical.RepositoryService;
 import org.splat.simer.Action;
 import org.splat.simer.OpenStudy;
 import org.splat.dal.bo.som.ConvertsRelation;
@@ -29,6 +31,14 @@ import org.splat.som.Step;
 
 public class SaveDocumentAction extends Action {
 
+       /**
+        * Serial version ID.
+        */
+       private static final long serialVersionUID = -3364960833373200115L;
+
+       /**
+        * Current open study.
+        */
        private OpenStudy mystudy = null;
        private int doctype = 0;
        private String filename = null;
@@ -36,11 +46,26 @@ public class SaveDocumentAction extends Action {
        private ProgressState state = null;
        private List<Document> defuses = null;
        private String summary = null; // Summary of changes in the new version
+       /**
+        * Injected scenario service.
+        */
        private ScenarioService _scenarioService;
+       /**
+        * Injected publication service.
+        */
        private PublicationService _publicationService;
+       /**
+        * Injected step service.
+        */
        private StepService _stepService;
-
-       private static final long serialVersionUID = -3364960833373200115L;
+       /**
+        * Injected repository service.
+        */
+       private RepositoryService _repositoryService;
+       /**
+        * Injected simulation context service.
+        */
+       private SimulationContextService _simulationContextService;
 
        // ==============================================================================================================================
        // Action methods
@@ -58,7 +83,8 @@ public class SaveDocumentAction extends Action {
                        DocumentType type = Document.selectType(doctype);
                        // File updir = Database.getDownloadDirectory(user);
                        // File upfile = new File(updir.getPath() + "/" + filename);
-                       String upath = Database.getTemplatePath(); // Instead of DownloadDirectory for sharing the "uploaded" file between users
+                       String upath = getRepositoryService().getTemplatePath(); // Instead of DownloadDirectory for sharing the "uploaded" file
+                                                                                                                                               // between users
                        File upfile = new File(upath + filename);
                        String[] table = filename.split("\\x2E");
                        String format = table[table.length - 1];
@@ -68,8 +94,10 @@ public class SaveDocumentAction extends Action {
                        connex.flush();
 
                        Document.Properties dprop = new Document.Properties();
-                       Publication credoc = getStepService().createDocument(step, dprop.setName(docname)
-                                       .setType(type).setFormat(format).setAuthor(user));
+                       Publication credoc = getStepService().createDocument(
+                                       step,
+                                       dprop.setName(docname).setType(type).setFormat(format)
+                                                       .setAuthor(user));
                        // Writing the uploaded file into the created document
                        File target = credoc.getSourceFile().asFile();
                        if (target.exists())
@@ -102,26 +130,28 @@ public class SaveDocumentAction extends Action {
                        // 2. Addition of simulation contexts
                        if (type.equals("model")) { // Set the characteristics of the mesh
                                SimulationContext.Properties cprop = new SimulationContext.Properties();
-                               SimulationContextType ctype = SimulationContext
+                               SimulationContextType ctype = getSimulationContextService()
                                                .selectType("model");
-                               SimulationContext context = Database.selectSimulationContext(
-                                               ctype, "Éléments finis");
+                               SimulationContext context = getSimulationContextService()
+                                               .selectSimulationContext(ctype, "Éléments finis");
                                if (context == null) {
                                        getStepService().addSimulationContext(step,
                                                        cprop.setType(ctype).setValue("Éléments finis"));
                                } else {
                                        getStepService().addSimulationContext(step, context);
                                }
-                               ctype = SimulationContext.selectType("element");
-                               context = Database.selectSimulationContext(ctype, "Surfacique");
+                               ctype = getSimulationContextService().selectType("element");
+                               context = getSimulationContextService()
+                                               .selectSimulationContext(ctype, "Surfacique");
                                if (context == null) {
                                        getStepService().addSimulationContext(step,
                                                        cprop.setType(ctype).setValue("Surfacique"));
                                } else {
                                        getStepService().addSimulationContext(step, context);
                                }
-                               ctype = SimulationContext.selectType("shape");
-                               context = Database.selectSimulationContext(ctype, "Triangles");
+                               ctype = getSimulationContextService().selectType("shape");
+                               context = getSimulationContextService()
+                                               .selectSimulationContext(ctype, "Triangles");
                                if (context == null) {
                                        getStepService().addSimulationContext(step,
                                                        cprop.setType(ctype).setValue("Triangles"));
@@ -222,7 +252,8 @@ public class SaveDocumentAction extends Action {
                        Step step = mystudy.getSelectedStep();
                        // File updir = Database.getDownloadDirectory(user);
                        // File upfile = new File(updir.getPath() + "/" + filename);
-                       String upath = Database.getTemplatePath(); // Instead of DownloadDirectory for sharing the "uploaded" file between users
+                       String upath = getRepositoryService().getTemplatePath(); // Instead of DownloadDirectory for sharing the "uploaded" file
+                                                                                                                                               // between users
                        File upfile = new File(upath + filename);
                        String[] table = filename.split("\\x2E");
                        String format = table[table.length - 1];
@@ -234,7 +265,8 @@ public class SaveDocumentAction extends Action {
                        if (summary.length() > 0)
                                dprop.setDescription(summary);
 
-                       Publication next = getStepService().versionDocument(step, current, dprop);
+                       Publication next = getStepService().versionDocument(step, current,
+                                       dprop);
 
                        // Writing the uploaded file into the created document
                        File target = next.getSourceFile().asFile();
@@ -338,4 +370,43 @@ public class SaveDocumentAction extends Action {
                                defuses.addAll(usedoc);
                }
        }
+
+       /**
+        * Get the repositoryService.
+        * 
+        * @return the repositoryService
+        */
+       public RepositoryService getRepositoryService() {
+               return _repositoryService;
+       }
+
+       /**
+        * Set the repositoryService.
+        * 
+        * @param repositoryService
+        *            the repositoryService to set
+        */
+       public void setRepositoryService(RepositoryService repositoryService) {
+               _repositoryService = repositoryService;
+       }
+
+       /**
+        * Get the simulationContextService.
+        * 
+        * @return the simulationContextService
+        */
+       public SimulationContextService getSimulationContextService() {
+               return _simulationContextService;
+       }
+
+       /**
+        * Set the simulationContextService.
+        * 
+        * @param simulationContextService
+        *            the simulationContextService to set
+        */
+       public void setSimulationContextService(
+                       SimulationContextService simulationContextService) {
+               _simulationContextService = simulationContextService;
+       }
 }
\ No newline at end of file