Пример #1
0
  private ExperimentSeriesRun getRun(ExperimentSeries series, Long timestamp)
      throws DataNotFoundException {
    for (ExperimentSeriesRun run : series.getExperimentSeriesRuns()) {
      System.out.println(run.getTimestamp() + " " + timestamp);
      if (timestamp.equals(run.getTimestamp())) {
        return run;
      }
    }

    throw new DataNotFoundException(
        "No ExperimentSeriesRun with timestamp '" + timestamp + "' found..");
  }
  static Collection<? extends ExperimentSeriesRun> createDummyExperimentSeriesRuns(
      int numberOfRunsToCreate) {
    ArrayList<ExperimentSeriesRun> runs = new ArrayList<ExperimentSeriesRun>();
    for (int i = 0; i < numberOfRunsToCreate; i++) {

      ExperimentSeriesRun run = EntityFactory.createExperimentSeriesRun();
      run.setSuccessfulResultDataSet(createDummyResultDataSet());
      runs.add(run);
    }

    return runs;
  }
  private static List<ExperimentSeries> createDummyExperimentSeries() {
    List<ExperimentSeries> seriesList = new LinkedList<ExperimentSeries>();
    for (ExperimentSeriesDefinition esd :
        scenarioDefinition.getMeasurementSpecifications().get(0).getExperimentSeriesDefinitions()) {
      ExperimentSeries es = EntityFactory.createExperimentSeries(esd);

      for (ExperimentSeriesRun run : createDummyExperimentSeriesRuns(_10)) {
        es.getExperimentSeriesRuns().add(run);
        run.setExperimentSeries(es);
      }

      seriesList.add(es);
    }

    return seriesList;
  }
Пример #4
0
  /**
   * Creates a SharedScenarioInstance out of a ScenarioInstance which can send to the FrontEnd.
   *
   * @param instance
   * @return
   */
  private SharedScenarioInstance convertInstance(ScenarioInstance instance) {
    SharedScenarioInstance retInstance = new SharedScenarioInstance();

    retInstance.setScenarioName(instance.getName());
    retInstance.setControllerUrl(instance.getMeasurementEnvironmentUrl());

    for (ExperimentSeries series : instance.getExperimentSeriesList()) {
      SharedExperimentSeries sharedSeries = new SharedExperimentSeries();
      sharedSeries.setExperimentName(series.getName());

      for (ExperimentSeriesRun run : series.getExperimentSeriesRuns()) {
        SharedExperimentRuns sharedRun = new SharedExperimentRuns();
        sharedRun.setTimestamp(run.getTimestamp());
        sharedRun.setLabel(run.getLabel());

        sharedSeries.addExperimentRun(sharedRun);
      }

      retInstance.addExperimentSeries(sharedSeries);
    }

    return retInstance;
  }
Пример #5
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";
    }
  }