Пример #1
0
  @Override
  public void getResults() {
    // getUser().getCurrentPersistenceProvider().loadAllScenarioInstances().get(0).getExperimentSeriesList().get(0).getLatestExperimentSeriesRun().getSuccessfulResultDataSet().

    try {
      List<ScenarioInstance> instances =
          getUser().getCurrentPersistenceProvider().loadAllScenarioInstances();

      System.out.println("");

      DataSetAggregated d = new DataSetAggregated();

      SimpleDataSet sd = d.convertToSimpleDataSet();

      DataSetCsvHandler handler = new DataSetCsvHandler(';', '#', true);
      // handler.store(dataset, fileName)
      // handler.
    } catch (DataNotFoundException e) {
      throw new RuntimeException(e);
    }
  }
Пример #2
0
  @Override
  public String getResultAsR(String scenario, String exoerimentSeries, String url, long timestamp) {
    try {
      ScenarioInstance instance = getScenarioInstance(getSessionId(), scenario, url);
      ExperimentSeries series = getSeries(instance, exoerimentSeries);
      ExperimentSeriesRun run = getRun(series, timestamp);

      DataSetAggregated dataset = run.getSuccessfulResultDataSet();
      SimpleDataSet simpleDataset = dataset.convertToSimpleDataSet();

      StringBuffer rValue = new StringBuffer();

      int i = 0;
      // for (SimpleDataSetRow row : simpleDataset.getRowList()) {
      for (Iterator<SimpleDataSetRow> rowIter = simpleDataset.getRowList().iterator();
          rowIter.hasNext();
          i++) {
        rValue.append("r");
        rValue.append(i);
        rValue.append(" <- c(");

        for (Iterator<ParameterValue> colIter = rowIter.next().getRowValues().iterator();
            colIter.hasNext(); ) {
          Object val = colIter.next().getValue();
          if (val instanceof String) {
            rValue.append("\"");
            rValue.append(val.toString());
            rValue.append("\"");
          } else {
            rValue.append(val.toString());
          }
          if (colIter.hasNext()) {
            rValue.append(", ");
          }
        }

        rValue.append(")\n");
      }

      rValue.append("myframe <- data.frame(");
      for (int n = 0; n < i; n++) {
        rValue.append("r");
        rValue.append(n);
        if (n + 1 < i) {
          rValue.append(", ");
        }
      }
      rValue.append(")\ncolnames(myframe) <- c(");

      for (Iterator<SimpleDataSetColumn> iter = simpleDataset.getColumns().iterator();
          iter.hasNext(); ) {
        rValue.append("\"");
        rValue.append(iter.next().getParameter().getName());
        rValue.append("\"");
        if (iter.hasNext()) {
          rValue.append(", ");
        }
      }
      rValue.append(")");

      return rValue.toString();
    } catch (DataNotFoundException e) {
      return "No Data Found";
    }
  }