Пример #1
0
  /**
   * Directs a chart request to a ChartMediator.<br>
   * Referring to a given configuration (id), it directs a request for a chart to a ChartMediator
   * and returns the result.
   *
   * @param json String path to a .json file where request information are stored
   * @return a json-object which contains all information about the requested chart
   * @see ChartMediator
   */
  public JSONObject computeChart(JSONObject json) {
    if (json == null) {
      throw new IllegalArgumentException();
    }

    // checks whether a request is allowed
    if (!isInitialized()) {
      Printer.pproblem("Configurations & mediators not initalized!");
      Printer.print("-> Chart creation not possible!");
      return null;
    }

    if (!(tablesAreCreated())) {
      Printer.pproblem("Tables not created. Request not possible");
      return null;
    }

    // direct request and hopefully receive a JSON object
    JSONObject chart = chartMedi.computeChart(json);

    if (chart == null) {
      Printer.pfail("Computing chart.");
      return null;
    } else {
      Printer.psuccess("Computing chart.");
    }

    return chart;
  }