Ejemplo n.º 1
0
 public static Long loadLastModifiedTime(MappingTool tool) throws DAOException {
   Long last;
   try {
     logger.debug("Tool properties loaded");
     Properties prop = loadToolProperties(tool.getDirectory());
     last = Long.parseLong(prop.getProperty(tool.getName() + ".last_modified"));
   } catch (Exception ex) {
     logger.error("loadLastModifiedTime error: " + ex.getLocalizedMessage());
     return new Long(0);
   }
   return last;
 }
Ejemplo n.º 2
0
 public static void createDirectory(MappingTool tool, Scenario sc) throws DAOException {
   try {
     File directoryTool = new File(sc.getOutPath() + File.separator + tool.getName());
     directoryTool.mkdirs();
     //            if (tool.getFileScript() != null && !tool.getFileScript().equals("")) {
     //                logger.debug("There is File script");
     //                String script =
     // tool.getFileScript().substring(tool.getFileScript().lastIndexOf(File.separator) + 1);
     //                copyFile(directoryTool, script);
     //            }
     createFileProperties(tool, directoryTool);
     tool.setDirectory(directoryTool.getAbsolutePath());
   } catch (Exception ex) {
     logger.error(ex.getMessage());
     throw new DAOException(ex);
   }
 }
Ejemplo n.º 3
0
 public static void saveLastModifiedTime(long lastModified, MappingTool tool) throws DAOException {
   FileOutputStream out = null;
   try {
     Properties prop = loadToolProperties(tool.getDirectory());
     logger.info(tool.getName() + ".last_modified " + lastModified + "");
     prop.setProperty(tool.getName() + ".last_modified", lastModified + "");
     out = new FileOutputStream(tool.getDirectory() + "/tool.properties");
     prop.store(out, null);
     out.close();
   } catch (Exception ex) {
     logger.error("saveLastModifiedTime error: " + ex.getLocalizedMessage());
     throw new DAOException(ex);
   } finally {
     try {
       if (out != null) {
         out.close();
       }
     } catch (IOException ex) {
     }
   }
 }
Ejemplo n.º 4
0
 private void createSeries(final XYChart chart) {
   // populating the series with data
   XYChart.Series series;
   Scenario scenario =
       (Scenario) Applicazione.getInstance().getModello().getBean(Scenario.class.getName());
   for (MappingTool tool : scenario.getToolsList()) {
     if (logger.isTraceEnabled()) logger.trace("Tool Scan : " + tool.getName());
     if (tool.getNumberExecutions() > 0) {
       series = new XYChart.Series();
       series.setName(tool.getName());
       if (!mapColor.containsKey(tool.getName())) {
         mapColor.put(tool.getName(), PropertiesLoader.loadColorName(tool.getName()));
         if (logger.isTraceEnabled())
           logger.trace(
               "map color put" + tool.getName() + " value " + mapColor.get(tool.getName()));
       }
       series.getData().add(new XYChart.Data(0, 0));
       List<MappingExecution> listExecution = new ArrayList<MappingExecution>();
       listExecution.addAll(tool.getExecutionsList());
       Collections.sort(listExecution);
       if (logger.isTraceEnabled()) logger.trace("Mapping executions: " + listExecution.size());
       for (MappingExecution mappingTask : listExecution) {
         int effort = 0;
         if (logger.isTraceEnabled()) logger.trace("Mapping: " + mappingTask);
         if (mappingTask.getEffortRecording() != null) {
           if (logger.isTraceEnabled())
             logger.trace("Updating effort:" + mappingTask.getEffortRecording());
           effort = mappingTask.getEffortRecording().getTotalInteraction();
         }
         series
             .getData()
             .add(new XYChart.Data(mappingTask.getQuality().getFmeasure() * 100, effort));
       }
       chart.getData().add(series);
     }
   }
   setColors();
   //        printNodes(chart, 0);
 }
Ejemplo n.º 5
0
 public static MappingTool loadTool(String toolDirectory) throws DAOException {
   MappingTool tool = new MappingTool();
   Properties prop = new Properties();
   FileInputStream in = null;
   try {
     // load a properties file
     in = new FileInputStream(toolDirectory + "/" + "tool.properties");
     prop.load(in);
     tool.setName(toolDirectory.substring(toolDirectory.lastIndexOf(File.separator) + 1));
     tool.setMappingFilePath(
         Utils.toAbsolutePath(toolDirectory, prop.getProperty(tool.getName() + ".mapping_file")));
     tool.setTranslatedInstancePath(
         Utils.toAbsolutePath(
             toolDirectory, prop.getProperty(tool.getName() + ".instance_translated_file")));
     String script = prop.getProperty(tool.getName() + ".script_file");
     if (script != null) {
       tool.setFileScript(Utils.toAbsolutePath(toolDirectory, script));
     }
     tool.setDirectory(toolDirectory);
     in.close();
     return tool;
   } catch (FileNotFoundException fe) {
     logger.error("File tool.properties not found: " + fe.getLocalizedMessage());
     return null;
   } catch (IOException ex) {
     logger.error(ex.getLocalizedMessage());
     throw new DAOException("Problem to load the tool.properties file");
   } finally {
     if (in != null) {
       try {
         in.close();
       } catch (IOException ex) {
       }
     }
   }
 }
Ejemplo n.º 6
0
 private static void createFileProperties(MappingTool tool, File directory) throws DAOException {
   Properties prop = new Properties();
   FileOutputStream out = null;
   try {
     prop.setProperty(
         tool.getName() + ".mapping_file",
         Utils.toRelativePath(directory.getAbsolutePath(), tool.getMappingFilePath()));
     prop.setProperty(
         tool.getName() + ".instance_translated_file",
         Utils.toRelativePath(directory.getAbsolutePath(), tool.getTranslatedInstancePath()));
     if (tool.getFileScript() != null && !tool.getFileScript().equals("")) {
       prop.setProperty(
           tool.getName() + ".script_file",
           Utils.toRelativePath(directory.getAbsolutePath(), tool.getFileScript()));
     }
     // save properties to project root folder
     logger.trace(
         "Path for File properties: "
             + directory.getAbsolutePath()
             + File.separator
             + "tool.properties");
     File file = new File(directory.getAbsolutePath() + File.separator + "tool.properties");
     out = new FileOutputStream(file.getAbsolutePath(), true);
     prop.store(out, Constant.MESSAGE_FILE_PROPERTIES + "Mapping Tool");
     // out.close();
   } catch (IOException ex) {
     logger.error(ex.getLocalizedMessage());
     throw new DAOException("Problem to build the tool.properties file", ex);
   } finally {
     try {
       if (out != null) {
         out.close();
       }
     } catch (IOException ex) {
     }
   }
 }