From 2e173f3ec90926c69e6a0962c1b339b08ded5ca9 Mon Sep 17 00:00:00 2001 From: mka Date: Wed, 14 Nov 2012 15:25:22 +0000 Subject: [PATCH] createConfigFile method is implemented --- .../service/salome/SimanSalomeService.java | 11 ++- .../salome/SimanSalomeServiceImpl.java | 80 ++++++++++++++++++- 2 files changed, 81 insertions(+), 10 deletions(-) diff --git a/Workspace/Siman-WS/src/org/splat/ws_server/service/salome/SimanSalomeService.java b/Workspace/Siman-WS/src/org/splat/ws_server/service/salome/SimanSalomeService.java index c277e99..f85c9b1 100644 --- a/Workspace/Siman-WS/src/org/splat/ws_server/service/salome/SimanSalomeService.java +++ b/Workspace/Siman-WS/src/org/splat/ws_server/service/salome/SimanSalomeService.java @@ -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); } diff --git a/Workspace/Siman-WS/src/org/splat/ws_server/service/salome/SimanSalomeServiceImpl.java b/Workspace/Siman-WS/src/org/splat/ws_server/service/salome/SimanSalomeServiceImpl.java index 9073305..99c9c6e 100644 --- a/Workspace/Siman-WS/src/org/splat/ws_server/service/salome/SimanSalomeServiceImpl.java +++ b/Workspace/Siman-WS/src/org/splat/ws_server/service/salome/SimanSalomeServiceImpl.java @@ -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 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 stepIter = listSteps.iterator(); + Iterator docIter; + Iterator 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() { -- 2.39.2