Esempio n. 1
0
  /**
   * Returns the dimensions and rows.
   *
   * @return the dimensions and rows
   */
  public ArrayList<DimRow> getDimensions() {
    // checks whether a request against configuration is allowed
    if (!isInitialized()) {
      Printer.pproblem("Configurations not initalized!");
      Printer.print("-> Request on it possible!");
      return null;
    }

    return currentConfig.getDims();
  }
Esempio n. 2
0
  /**
   * Initializes this facade with a ConfigWrap, what is necessary to post requests to it.
   *
   * @param path of the configuration file (.json)
   * @return whether initialization was successful
   */
  public boolean init(final String path) {
    if (path == null) {
      throw new IllegalArgumentException();
    }

    // tries to build a new ConfigWrap
    ConfigWrap config = ConfigWrap.buildConfig(path);
    if (config == null) {
      Printer.pfail("Building ConfigWrap with the given path failed");
      return false;
    } else {
      Printer.psuccess("Building ConfigWrap for: " + config.getNameOfDB());
    }

    // set all the attributes
    currentConfig = config;
    dataMedi = new DataMediator(config);
    chartMedi = new ChartMediator(config, dataMedi);
    parsMedi = new ParserMediator(config, dataMedi);

    // testing
    // Printer.ptest(config.toString());

    // create tables for the configuration if necessary
    if (!(tablesAreCreated())) {
      Printer.print("Tables not created for this configuration. Will happen now.");
      if (!(createDBTables())) {
        Printer.pfail("Creating tables for this configuration");
        return false;
      } else {
        Printer.psuccess("Creating tables for this configuration");
      }
    }

    // pre-compute strings for the web page selection boxes
    computeDimensionData();

    Printer.psuccess("Initialize facade.");
    return true;
  }