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);
}
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() {