Exemplo n.º 1
0
  public void analyze() throws Exception {
    HashMap<String, ArrayList<String>> outputDataPaths = new HashMap<String, ArrayList<String>>();

    File outDir = new File(_outputPath);

    File reportDir = new File(_reportPath);
    if (!reportDir.exists()) reportDir.mkdirs();

    FilenameFilter filter =
        new FilenameFilter() {

          public boolean accept(File arg0, String arg1) {
            if (arg1.equals(".svn")) return false;
            else return true;
          }
        };

    // delete all in Statistics directory
    for (String s : reportDir.list(filter)) new File(_reportPath + "/" + s).delete();

    DataNode report = new DataNode("report");
    // list all Output|s directories
    for (String s : outDir.list(filter)) {
      String config = _outputPath + "/" + s + "/config.xml";
      if (new File(config).exists()) {
        List<DataNode> runs =
            processDirectorySet(
                new File(_outputPath + "/" + s).listFiles(), _outputPath, _reportPath, s);

        DataNode batch = new DataNode("batch");
        for (DataNode dn : runs) batch.putDataNode(dn);

        batch.putValue("id", s);

        String[] date = s.split("-");
        batch.putValue("date", date[0] + "-" + date[1]);
        batch.putDataNode(XmlHelper.readXml(new File(config)));

        report.putDataNode(batch);
      }
    }

    XmlHelper.writeXml(report, _reportPath + "/report.xml");

    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer =
        tFactory.newTransformer(
            new javax.xml.transform.stream.StreamSource(
                getClass().getResourceAsStream("report.xsl")));

    transformer.transform(
        new javax.xml.transform.stream.StreamSource(_reportPath + "/report.xml"),
        new javax.xml.transform.stream.StreamResult(
            new FileOutputStream(_reportPath + "/report.html")));
  }