]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
createConfigFile method is implemented
authormka <mka@opencascade.com>
Wed, 14 Nov 2012 15:25:22 +0000 (15:25 +0000)
committermka <mka@opencascade.com>
Wed, 14 Nov 2012 15:25:22 +0000 (15:25 +0000)
Workspace/Siman-WS/src/org/splat/ws_server/service/salome/SimanSalomeService.java
Workspace/Siman-WS/src/org/splat/ws_server/service/salome/SimanSalomeServiceImpl.java

index c277e99d34168b1ebefc15282c1b1a5a220cf5aa..f85c9b1d00c937361abd070f30606b4dca6c295a 100644 (file)
@@ -5,13 +5,12 @@ import java.io.File;
 public interface SimanSalomeService {
        
        /** Create the siman-salome.conf file.
-     * @param studyID the study ID
-     * @param scenarioID the scenario ID
-     * @param userID the user ID
-     * @param uploadPath the upload path
+     * @param studyId the study ID
+     * @param scenarioId the scenario ID
+     * @param userId the user ID
      * @return the siman-salome.conf
      */
 
-       public File createConfigFile(final Long studyID, final Long scenarioID,
-                       final Long userID, final String uploadPath);
+       public File createConfigFile(final Long studyId, final Long scenarioId,
+                       final Long userId);
 }
index 907330548c94e4ae4699fd285ea054044f50f9ac..99c9c6ee3fa49d42645a10abb7ecdb28b73fdea7 100644 (file)
@@ -1,17 +1,89 @@
 package org.splat.ws_server.service.salome;
 
+import java.io.BufferedWriter;
 import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
 import org.splat.service.ScenarioService;
+import org.splat.service.dto.DocumentDTO;
+import org.splat.service.dto.FileDTO;
+import org.splat.service.dto.StepDTO;
 
 public class SimanSalomeServiceImpl implements SimanSalomeService {
 
        private ScenarioService _scenarioService;
 
-       public File createConfigFile(final Long studyID, final Long scenarioID,
-                       final Long userID, final String uploadPath) {
+       @Override
+       public File createConfigFile(final Long studyId, final Long scenarioId,
+                       final Long userId) {
 
-               return _scenarioService.createConfigFile(studyID, scenarioID, userID,
-                               uploadPath);
+               List<StepDTO> listSteps = _scenarioService.getScenarioInfo(scenarioId);
+               
+               File configFile = new File("W:\\siman-salome.conf");
+               
+               //build the result file.
+        FileWriter fstream;
+        try {
+              fstream = new FileWriter(configFile);
+              BufferedWriter out = new BufferedWriter(fstream);  
+              
+              out.write("Study ID : " + studyId + "\n");
+              out.write("Scenario ID : " + scenarioId + "\n");
+              out.write("User ID : " + userId + "\n");
+              out.write("\n");
+              
+              Iterator<StepDTO> stepIter = listSteps.iterator();
+              Iterator<DocumentDTO> docIter;
+              Iterator<FileDTO> fileIter;
+              
+              StepDTO stepValue;
+              DocumentDTO docValue;
+              FileDTO fileValue;
+              char fileState;
+              
+              for ( ; stepIter.hasNext(); ) {
+                 stepValue = stepIter.next();
+                 out.write("Activity : " + stepValue.getKey() + "\n");
+                 out.write("Activity ID : " + stepValue.getNumber() + "\n");
+                 out.write("SALOME module : " + stepValue.getModule() + "\n");
+                 
+                 docIter = stepValue.getDocs().iterator();
+                 for ( ; docIter.hasNext(); ) {
+                         docValue = docIter.next();
+                         out.write("    Document : " + docValue.getTitle() + "\n");
+                         out.write("    Document ID: " + docValue.getId() + "\n");
+                         
+                         fileIter = docValue.getFiles().iterator();
+                         for ( ; fileIter.hasNext(); ) {
+                                 fileValue = fileIter.next();
+                                 if (fileValue.isResult() == false) {
+                                         out.write("        Source file : " + fileValue.getPath() + "\n");
+                                 } else {
+                                         out.write("        Result file : " + fileValue.getPath() + "\n");
+                                 }
+                                 
+                                 out.write("            Automatic processing : " + fileValue.getProcessing() + "\n");
+                                 fileState = fileValue.getState();
+                                 if ((fileState == 'Y') || (fileState == 'N')) {
+                                         out.write("            State : file-actual\n");
+                                 } else if (fileState == 'O') {
+                                         out.write("            State : file-outdated\n");
+                                 }
+                         }
+                 }
+              }
+              
+              
+              out.close();
+        } catch (IOException e) {
+              // TODO Auto-generated catch block
+              e.printStackTrace();
+        }
+               
+               return configFile;
        }
 
        public ScenarioService getScenarioService() {