CPD Results

The following document contains the results of PMD's CPD 5.2.1.

Duplications

File Line
org/wattdepot/server/http/api/DepositoryDailyValuesServer.java 117
org/wattdepot/server/http/api/DepositoryHourlyValuesServer.java 119
                  ret.getInterpolatedValues().add(value);
                }
                else { // try SensorGroup.
                  SensorGroup group = depot.getSensorGroup(sensorId, orgId, false);
                  if (group != null) {
                    value = new InterpolatedValue(sensorId, val, depository.getMeasurementType(), beginDate, endDate);
                    for (String s : group.getSensors()) {
                      value.addDefinedSensor(s);
                      sensor = depot.getSensor(s, orgId, false);
                      if (sensor != null) {
                        try {
                          value.setValue(value.getValue() + getValueForSensor(depositoryId, orgId, s, beginDate, endDate, dataType));
                          value.addReportingSensor(s);
                        }
                        catch (IdNotFoundException e) { // NOPMD
                        }
                        catch (NoMeasurementException e) { // NOPMD
                        }
                      }
                    }
                    ret.getInterpolatedValues().add(value);
                  }
                }
              }
            }
          }
        }
        catch (ParseException e) {
          setStatus(Status.CLIENT_ERROR_BAD_REQUEST, e.getMessage());
          return null;
        }
        catch (DatatypeConfigurationException e) {
          setStatus(Status.SERVER_ERROR_INTERNAL, e.getMessage());
          return null;
        }
        catch (IdNotFoundException e) {
          setStatus(Status.CLIENT_ERROR_BAD_REQUEST, e.getMessage());
          return null;
        }
        catch (MisMatchedOwnerException e) {
          setStatus(Status.CLIENT_ERROR_BAD_REQUEST, e.getMessage());
          return null;
        }
        return ret;
      }
      else {
        setStatus(Status.CLIENT_ERROR_BAD_REQUEST, "Missing start and/or end times or value type.");
        return null;
      }
    }
    else {
      setStatus(Status.CLIENT_ERROR_BAD_REQUEST, "Bad credentials.");
      return null;
    }
  }

  /**
   * Gets the value for the Sensor or SensorGroup.
   * @param depositoryId The depository id.
   * @param orgId The organization id.
   * @param sensorId The sensor or sensor group id.
   * @param beginDate The beginning date.
   * @param endDate The ending date.
   * @param dataType Either 'point' or difference.
   * @return The average for point values or the difference for difference values.
   * @throws IdNotFoundException If the sensor or depository are not defined.
   * @throws NoMeasurementException If there are no measurements for the time period.
   */
  private Double getValueForSensor(String depositoryId, String orgId, String sensorId, Date beginDate, Date endDate, String dataType) throws IdNotFoundException, NoMeasurementException {
    Double val = 0.0;
    if (dataType.equals("point")) {  // need to calculate the average value for the hourly intervals
      List<Measurement> measurements = depot.getMeasurements(depositoryId, orgId, sensorId, beginDate, endDate, false);
      if (measurements.size() > 0) {
        for (Measurement m : measurements) {
          val += m.getValue();
        }
        val = val / measurements.size();
      }
      else {
        val = Double.NaN;
      }
    }
    else {  // calculate the difference
      val = depot.getValue(depositoryId, orgId, sensorId, beginDate, endDate, false);
    }
    return val;
  }

}
File Line
org/wattdepot/server/http/api/DepositoryMeasurementsServer.java 77
org/wattdepot/server/http/api/SensorMeasurementServerResource.java 113
    if (isInRole(orgId)) {
      if (start != null && end != null) {
        MeasurementList ret = new MeasurementList();
        try {
          Depository depository = depot.getDepository(depositoryId, orgId, true);
          if (depository != null) {
            Date startDate = DateConvert.parseCalStringToDate(start);
            Date endDate = DateConvert.parseCalStringToDate(end);
            if (startDate != null && endDate != null) {
              try {
                Sensor sensor = depot.getSensor(sensorId, orgId, true);
                for (Measurement meas : depot.getMeasurements(depositoryId, orgId, sensor.getId(),
                    startDate, endDate, true)) {
                  ret.getMeasurements().add(meas);
                }
              }
              catch (IdNotFoundException nf) {
                try {
                  SensorGroup group = depot.getSensorGroup(sensorId, orgId, true);
                  for (String s : group.getSensors()) {
                    Sensor sensor = depot.getSensor(s, orgId, true);
                    for (Measurement meas : depot.getMeasurements(depositoryId, orgId,
                        sensor.getId(), startDate, endDate, true)) {
                      ret.getMeasurements().add(meas);
                    }
                  }
                }
                catch (IdNotFoundException nf1) {
                  setStatus(Status.CLIENT_ERROR_BAD_REQUEST, sensorId + " is not defined");
                }
              }
            }
            else {
              setStatus(Status.CLIENT_ERROR_BAD_REQUEST, "Start date and/or end date missing.");
            }
          }
          else {
            setStatus(Status.CLIENT_ERROR_BAD_REQUEST, depositoryId + " is not defined.");
          }
        }
        catch (IdNotFoundException e) {
          setStatus(Status.CLIENT_ERROR_BAD_REQUEST, e.getMessage());
        }
        catch (ParseException e) {
          setStatus(Status.CLIENT_ERROR_BAD_REQUEST, e.getMessage());
        }
        catch (DatatypeConfigurationException e) {
          setStatus(Status.SERVER_ERROR_INTERNAL, e.getMessage());
        }
        catch (MisMatchedOwnerException e) {
          setStatus(Status.CLIENT_ERROR_BAD_REQUEST, e.getMessage());
        }
File Line
org/wattdepot/client/http/api/collector/EGaugeCollector.java 345
org/wattdepot/client/http/api/collector/NOAAWeatherCollector.java 324
      formatter.printHelp("EGaugeCollector", options);
      System.exit(0);
    }
    if (cmd.hasOption("s")) {
      serverUri = cmd.getOptionValue("s");
    }
    else {
      serverUri = "http://localhost:8119/";
    }
    if (cmd.hasOption("u")) {
      username = cmd.getOptionValue("u");
    }
    else {
      username = UserInfo.ROOT.getUid();
    }
    if (cmd.hasOption("o")) {
      organizationId = cmd.getOptionValue("o");
    }
    else {
      organizationId = Organization.ADMIN_GROUP.getId();
    }
    if (cmd.hasOption("p")) {
      password = cmd.getOptionValue("p");
    }
    else {
      password = "default";
    }
    if (cmd.hasOption("c")) {
      collectorId = cmd.getOptionValue("c");
    }
    else {
      collectorId = "ilima_6th_power";
    }

    debug = cmd.hasOption("d");

    if (debug) {
      System.out.println("WattDepot Server: " + serverUri);
      System.out.println("Username: " + username);
      System.out.println("OrganizationID: " + organizationId);
      System.out.println("Password: " + password);
      System.out.println("Collector Process Definition Id: " + collectorId);
      System.out.println("debug: " + debug);
      System.out.println();
    }
    try {
      if (!MultiThreadedCollector.start(serverUri, username, organizationId, password, collectorId,
          debug)) {
        System.exit(1);
      }
    }
    catch (InterruptedException e) {
      e.printStackTrace();
      System.exit(1);
    }
    catch (BadCredentialException e) {
      e.printStackTrace();
      System.exit(1);
    }
  }
}
File Line
org/wattdepot/client/http/api/performance/PutCollectorRate.java 70
org/wattdepot/client/http/api/performance/PutRate.java 68
    options.addOption("cpd", "collector", true, "The collector process definition");
    options.addOption("d", "debug", false, "Displays statistics as the Measurements are stored.");
    CommandLineParser parser = new PosixParser();
    HelpFormatter formatter = new HelpFormatter();
    try {
      cmd = parser.parse(options, args);
    }
    catch (ParseException e) {
      System.err.println("Command line parsing failed. Reason: " + e.getMessage() + ". Exiting.");
      System.exit(1);
    }
    if (cmd.hasOption("h")) {
      formatter.printHelp("PutRate", options);
      System.exit(0);
    }
    if (cmd.hasOption("s")) {
      serverUri = cmd.getOptionValue("s");
    }
    else {
      serverUri = "http://server.wattdepot.org/";
    }
    if (cmd.hasOption("u")) {
      username = cmd.getOptionValue("u");
    }
    else {
      username = "user";
    }
    if (cmd.hasOption("p")) {
      password = cmd.getOptionValue("p");
    }
    else {
      password = "default";
    }
    if (cmd.hasOption("o")) {
      organizationId = cmd.getOptionValue("o");
    }
    else {
      organizationId = "organization";
    }
    if (cmd.hasOption("mps")) {
      measPerSec = Integer.parseInt(cmd.getOptionValue("mps"));
    }
    else {
      measPerSec = 13;
    }
    debug = cmd.hasOption("d");
    if (cmd.hasOption("cpd")) {
File Line
org/wattdepot/server/depository/impl/hibernate/WattDepotPersistenceImpl.java 2972
org/wattdepot/server/depository/impl/hibernate/WattDepotPersistenceImpl.java 3152
        .setParameter("sensor", sensor).setMaxResults(1).list();
    if (result.size() > 0) {
      ret = result.get(0).getValue();
    }
    else {
      // need to get the stradle
      @SuppressWarnings("unchecked")
      List<MeasurementImpl> before = (List<MeasurementImpl>) session
          .createQuery(
              "FROM MeasurementImpl WHERE timestamp <= :time AND depository = :depot AND sensor = :sensor ORDER BY timestamp desc")
          .setParameter("time", timestamp).setParameter("depot", depot)
          .setParameter("sensor", sensor).setMaxResults(1).list();
      @SuppressWarnings("unchecked")
      List<MeasurementImpl> after = (List<MeasurementImpl>) session
          .createQuery(
              "FROM MeasurementImpl WHERE timestamp >= :time AND depository = :depot AND sensor = :sensor ORDER BY timestamp asc")
          .setParameter("time", timestamp).setMaxResults(1).setParameter("depot", depot)
          .setParameter("sensor", sensor).list();
      MeasurementImpl justBefore = null;
      for (MeasurementImpl b : before) {
        if (b.getSensor().getId().equals(sensorId)) {
          if (justBefore == null) {
            justBefore = b;
          }
          else if (b.getTimestamp().compareTo(justBefore.getTimestamp()) > 0) {
            justBefore = b;
          }
        }
      }
      if (justBefore == null) {
        session.getTransaction().commit();
        session.close();
        throw new NoMeasurementException("Cannot find measurement before " + timestamp);
File Line
org/wattdepot/server/depository/impl/hibernate/Manager.java 56
org/wattdepot/server/depository/impl/hibernate/Manager.java 104
          .addAnnotatedClass(org.wattdepot.server.depository.impl.hibernate.RowCount.class)
          .addAnnotatedClass(org.wattdepot.server.depository.impl.hibernate.SensorImpl.class)
          .addAnnotatedClass(org.wattdepot.server.depository.impl.hibernate.SensorGroupImpl.class)
          .addAnnotatedClass(org.wattdepot.server.depository.impl.hibernate.SensorModelImpl.class)
          .addAnnotatedClass(org.wattdepot.server.depository.impl.hibernate.OrganizationImpl.class)
          .addAnnotatedClass(org.wattdepot.server.depository.impl.hibernate.UserInfoImpl.class)
          .addAnnotatedClass(org.wattdepot.server.depository.impl.hibernate.UserPasswordImpl.class)
          .setProperty("hibernate.connection.driver_class",
              properties.get(ServerProperties.DB_CONNECTION_DRIVER))
          .setProperty("hibernate.connection.url",
              properties.get(ServerProperties.DB_CONNECTION_URL))
          .setProperty("hibernate.connection.username",
              properties.get(ServerProperties.DB_USER_NAME))
          .setProperty("hibernate.connection.password",
              properties.get(ServerProperties.DB_PASSWORD))
          .setProperty("hibernate.c3p0.min_size", "5").setProperty("hibernate.c3p0.max_size", "20")
          .setProperty("hibernate.c3p0.timeout", "1800")
          .setProperty("hibernate.c3p0.max_statements", "50")
          .setProperty("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect")
          .setProperty("hibernate.show_sql", properties.get(ServerProperties.DB_SHOW_SQL))
          .setProperty("hibernate.hbm2ddl.auto", properties.get(ServerProperties.DB_TABLE_UPDATE));
File Line
org/wattdepot/client/http/api/WattDepotClient.java 462
org/wattdepot/client/http/api/WattDepotClient.java 902
      sb.append(Labels.DAILY);
      sb.append("/");
      sb.append(Labels.VALUES);
      sb.append("/?");
      sb.append(Labels.SENSOR);
      sb.append("=");
      sb.append(sensor.getId());
      sb.append("&");
      sb.append(Labels.START);
      sb.append("=");
      sb.append(DateConvert.convertDate(start));
      sb.append("&");
      sb.append(Labels.END);
      sb.append("=");
      sb.append(DateConvert.convertDate(end));
      sb.append("&");
      sb.append(Labels.VALUE_TYPE);
      sb.append("=");
      if (usePointValues) {
        sb.append(Labels.POINT);
      }
      else {
        sb.append(Labels.DIFFERENCE);
      }
      client = makeClient(sb.toString());
      DepositoryValuesResource resource = client.wrap(DepositoryValuesResource.class);
      InterpolatedValueList ret = resource.retrieve();
      client.release();
      return ret;
    }
    catch (DatatypeConfigurationException e) {
      e.printStackTrace();
    }
    finally {
      if (client != null) {
        client.release();
      }
    }
    return null;
  }

  @Override
  public InterpolatedValueList getDailyValues(Depository depository, SensorGroup group, Date start, Date end, Boolean usePointValues) {
File Line
org/wattdepot/client/http/api/WattDepotClient.java 514
org/wattdepot/client/http/api/WattDepotClient.java 954
      sb.append(Labels.DAILY);
      sb.append("/");
      sb.append(Labels.VALUES);
      sb.append("/?");
      sb.append(Labels.SENSOR);
      sb.append("=");
      sb.append(group.getId());
      sb.append("&");
      sb.append(Labels.START);
      sb.append("=");
      sb.append(DateConvert.convertDate(start));
      sb.append("&");
      sb.append(Labels.END);
      sb.append("=");
      sb.append(DateConvert.convertDate(end));
      sb.append("&");
      sb.append(Labels.VALUE_TYPE);
      sb.append("=");
      if (usePointValues) {
        sb.append(Labels.POINT);
      }
      else {
        sb.append(Labels.DIFFERENCE);
      }
      client = makeClient(sb.toString());
      DepositoryValuesResource resource = client.wrap(DepositoryValuesResource.class);
      InterpolatedValueList ret = resource.retrieve();
      client.release();
      return ret;
    }
    catch (DatatypeConfigurationException e) {
      e.printStackTrace();
    }
    finally {
      if (client != null) {
        client.release();
      }
    }
    return null;
  }

  /*
   * (non-Javadoc)
   *
   * @see org.wattdepot.client.WattDepotInterface#getDepositories()
   */
  @Override
  public DepositoryList getDepositories() {
File Line
org/wattdepot/client/http/api/performance/GetIntervalValueThroughput.java 137
org/wattdepot/client/http/api/performance/GetLatestValueThroughput.java 136
      formatter.printHelp("GetIntervalValueThroughput", options);
      System.exit(0);
    }
    if (cmd.hasOption("s")) {
      serverUri = cmd.getOptionValue("s");
    }
    else {
      serverUri = "http://server.wattdepot.org/";
    }
    if (cmd.hasOption("u")) {
      username = cmd.getOptionValue("u");
    }
    else {
      username = "user";
    }
    if (cmd.hasOption("p")) {
      password = cmd.getOptionValue("p");
    }
    else {
      password = "default";
    }
    if (cmd.hasOption("o")) {
      organizationId = cmd.getOptionValue("o");
    }
    else {
      organizationId = "organization";
    }
    if (cmd.hasOption("n")) {
      numSamples = Integer.parseInt(cmd.getOptionValue("n"));
    }
    else {
      numSamples = 13;
    }
    debug = cmd.hasOption("d");
    if (debug) {
      System.out.println("GetLatestValue Throughput:");
      System.out.println("    WattDepotServer: " + serverUri);
      System.out.println("    Username: " + username);
      System.out.println("    OrganizationId: " + organizationId);
      System.out.println("    Password: ********");
      System.out.println("    Samples: " + numSamples);
    }

    Timer t = new Timer("monitoring");
    t.schedule(
        new GetIntervalValueThroughput(serverUri, username, organizationId, password, debug), 0,
File Line
org/wattdepot/extension/openeis/util/OpenEISGvizHelper.java 61
org/wattdepot/extension/openeis/util/OpenEISGvizHelper.java 181
      table = getRow24HourPerDayDataTable(list);
      StringBuilder sb = new StringBuilder();
      sb.append("google.visualization.Query.setResponse");

      String reqId = null;
      if (tqxString != null) {
        String[] tqxArray = tqxString.split(";");
        for (String s : tqxArray) {
          if (s.contains("reqId")) {
            reqId = s.substring(s.indexOf(":") + 1, s.length());
          }
        }
      }

      String tableString = JsonRenderer.renderDataTable(table, true, true, true).toString();
      if (list.getMissingData().size() > 0) {
        sb.append("({status:'warning',");
      }
      else {
        sb.append("({status:'ok',");
      }
      if (reqId != null) {
        sb.append("reqId:'" + reqId + "',");
      }
      if (list.getMissingData().size() > 0) {
        sb.append("warnings:[");
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
        for (InterpolatedValue v : list.getMissingData()) {
          sb.append("{reason: 'missing data " + df.format(v.getStart()) + " to " + df.format(v.getEnd()) + "'},");
        }
File Line
org/wattdepot/client/http/api/collector/MeasurementSummaryClient.java 116
org/wattdepot/client/http/api/collector/StressTestCollector.java 140
    boolean windowP = false;

    CommandLineParser parser = new PosixParser();
    HelpFormatter formatter = new HelpFormatter();
    try {
      cmd = parser.parse(options, args);
    }
    catch (ParseException e) {
      System.err.println("Command line parsing failed. Reason: " + e.getMessage() + ". Exiting.");
      System.exit(1);
    }
    if (cmd.hasOption("h")) {
      formatter.printHelp("StressTestCollector", options);
      System.exit(0);
    }
    if (cmd.hasOption("s")) {
      serverUri = cmd.getOptionValue("s");
    }
    else {
      serverUri = "http://server.wattdepot.org/";
    }
    if (cmd.hasOption("u")) {
      username = cmd.getOptionValue("u");
    }
    else {
      username = "user";
    }
    if (cmd.hasOption("p")) {
      password = cmd.getOptionValue("p");
    }
    else {
      password = "default";
    }
    if (cmd.hasOption("o")) {
      organizationId = cmd.getOptionValue("o");
    }
    else {
      organizationId = "organization";
    }
    if (cmd.hasOption("c")) {
      collectorId = cmd.getOptionValue("c");
    }
    else {
      collectorId = "stress_test";
    }
    if (cmd.hasOption("m")) {
File Line
org/wattdepot/client/http/api/WattDepotClient.java 1740
org/wattdepot/client/http/api/WattDepotClient.java 1801
      sb.append(sensor.getId());
      sb.append("&");
      sb.append(Labels.START);
      sb.append("=");
      sb.append(DateConvert.convertDate(start));
      sb.append("&");
      sb.append(Labels.END);
      sb.append("=");
      sb.append(DateConvert.convertDate(end));
      sb.append("&");
      sb.append(Labels.INTERVAL);
      sb.append("=");
      sb.append(interval);
      sb.append("&");
      sb.append(Labels.VALUE_TYPE);
      sb.append("=");
      if (usePointValues) {
        sb.append(Labels.POINT);
      }
      else {
        sb.append(Labels.DIFFERENCE);
      }
      client = makeClient(sb.toString());
      DepositoryValuesResource resource = client.wrap(DepositoryValuesResource.class);
      InterpolatedValueList ret = resource.retrieve();
      client.release();
      return ret;
    }
    catch (DatatypeConfigurationException e) {
      e.printStackTrace();
    }
    finally {
      if (client != null) {
        client.release();
      }
    }
    return null;
  }
File Line
org/wattdepot/common/domainmodel/InterpolatedValue.java 132
org/wattdepot/common/domainmodel/IntervalValue.java 87
    InterpolatedValue other = (InterpolatedValue) obj;
    if (start == null) {
      if (other.start != null) {
        return false;
      }
    }
    else if (!start.equals(other.start)) {
      return false;
    }
    if (end == null) {
      if (other.end != null) {
        return false;
      }
    }
    else if (!end.equals(other.end)) {
      return false;
    }
    if (measurementType == null) {
      if (other.measurementType != null) {
        return false;
      }
    }
    else if (!measurementType.equals(other.measurementType)) {
      return false;
    }
    if (sensorId == null) {
      if (other.sensorId != null) {
        return false;
      }
    }
    else if (!sensorId.equals(other.sensorId)) {
      return false;
    }
    if (value == null) {
      if (other.value != null) {
        return false;
      }
    }
    else if (!value.equals(other.value)) {
      return false;
    }
    return true;
  }

  /**
   * @param meas a Measurement
   * @return true if this InterpolatedValue has the same sensorId, time,
   *         MeasurementType, and value as the Measurement.
   */
  public boolean equivalent(Measurement meas) {
File Line
org/wattdepot/client/http/api/WattDepotClient.java 642
org/wattdepot/client/http/api/WattDepotClient.java 701
    stringBuilder.append(sensor.getId());
    stringBuilder.append("&");
    stringBuilder.append(Labels.TIMESTAMP);
    stringBuilder.append("=");
    try {
      stringBuilder.append(DateConvert.convertDate(timestamp).toXMLFormat());
    }
    catch (DatatypeConfigurationException e) {
      e.printStackTrace();
    }
    stringBuilder.append("&");
    stringBuilder.append(Labels.VALUE_TYPE);
    stringBuilder.append("=");
    if (pointValues) {
      stringBuilder.append(Labels.POINT);
    }
    else {
      stringBuilder.append(Labels.DIFFERENCE);
    }
    stringBuilder.append("&");
    stringBuilder.append(Labels.SAMPLES);
    stringBuilder.append("=");
    stringBuilder.append(samples);
    ClientResource client = makeClient(stringBuilder.toString());
    DepositoryDescriptiveStatsResource resource = client.wrap(DepositoryDescriptiveStatsResource.class);
    DescriptiveStats values = null;
    try {
      values = resource.retrieve();
    }
    catch (ResourceException re) {
      throw re;
    }
    finally {
      client.release();
    }
    return values;
  }

//http://mopsa.ics.hawaii.edu:8192/wattdepot/uh/depository/energy/historical-values/daily/?sensor=lehua-total&timestamp=2015-08-15T12:00:00.000-10:00&value-type=difference&samples=5
  @Override
  public DescriptiveStats getDescriptiveStats(Depository depository, SensorGroup group, Date timestamp, Boolean daily, Integer samples, Boolean pointValues) {
File Line
org/wattdepot/client/http/api/WattDepotClient.java 468
org/wattdepot/client/http/api/WattDepotClient.java 520
org/wattdepot/client/http/api/WattDepotClient.java 908
org/wattdepot/client/http/api/WattDepotClient.java 960
      sb.append(sensor.getId());
      sb.append("&");
      sb.append(Labels.START);
      sb.append("=");
      sb.append(DateConvert.convertDate(start));
      sb.append("&");
      sb.append(Labels.END);
      sb.append("=");
      sb.append(DateConvert.convertDate(end));
      sb.append("&");
      sb.append(Labels.VALUE_TYPE);
      sb.append("=");
      if (usePointValues) {
        sb.append(Labels.POINT);
      }
      else {
        sb.append(Labels.DIFFERENCE);
      }
      client = makeClient(sb.toString());
      DepositoryValuesResource resource = client.wrap(DepositoryValuesResource.class);
      InterpolatedValueList ret = resource.retrieve();
      client.release();
      return ret;
    }
    catch (DatatypeConfigurationException e) {
      e.printStackTrace();
    }
    finally {
      if (client != null) {
        client.release();
      }
    }
    return null;
  }

  @Override
  public InterpolatedValueList getDailyValues(Depository depository, SensorGroup group, Date start, Date end, Boolean usePointValues) {
File Line
org/wattdepot/client/http/api/WattDepotClient.java 631
org/wattdepot/client/http/api/WattDepotClient.java 785
    stringBuilder.append(Labels.DESCRIPTIVE_STATS);
    stringBuilder.append("/");
    if (daily) {
      stringBuilder.append(Labels.DAILY);
    }
    else {
      stringBuilder.append(Labels.HOURLY);
    }
    stringBuilder.append("/?");
    stringBuilder.append(Labels.SENSOR);
    stringBuilder.append("=");
    stringBuilder.append(sensor.getId());
    stringBuilder.append("&");
    stringBuilder.append(Labels.TIMESTAMP);
    stringBuilder.append("=");
    try {
      stringBuilder.append(DateConvert.convertDate(timestamp).toXMLFormat());
    }
    catch (DatatypeConfigurationException e) {
      e.printStackTrace();
    }
    stringBuilder.append("&");
    stringBuilder.append(Labels.VALUE_TYPE);
    stringBuilder.append("=");
    if (pointValues) {
      stringBuilder.append(Labels.POINT);
    }
    else {
      stringBuilder.append(Labels.DIFFERENCE);
    }
    stringBuilder.append("&");
    stringBuilder.append(Labels.SAMPLES);
    stringBuilder.append("=");
    stringBuilder.append(samples);
File Line
org/wattdepot/client/http/api/WattDepotClient.java 690
org/wattdepot/client/http/api/WattDepotClient.java 843
    stringBuilder.append(Labels.DESCRIPTIVE_STATS);
    stringBuilder.append("/");
    if (daily) {
      stringBuilder.append(Labels.DAILY);
    }
    else {
      stringBuilder.append(Labels.HOURLY);
    }
    stringBuilder.append("/?");
    stringBuilder.append(Labels.SENSOR);
    stringBuilder.append("=");
    stringBuilder.append(group.getId());
    stringBuilder.append("&");
    stringBuilder.append(Labels.TIMESTAMP);
    stringBuilder.append("=");
    try {
      stringBuilder.append(DateConvert.convertDate(timestamp).toXMLFormat());
    }
    catch (DatatypeConfigurationException e) {
      e.printStackTrace();
    }
    stringBuilder.append("&");
    stringBuilder.append(Labels.VALUE_TYPE);
    stringBuilder.append("=");
    if (pointValues) {
      stringBuilder.append(Labels.POINT);
    }
    else {
      stringBuilder.append(Labels.DIFFERENCE);
    }
    stringBuilder.append("&");
    stringBuilder.append(Labels.SAMPLES);
    stringBuilder.append("=");
    stringBuilder.append(samples);
File Line
org/wattdepot/extension/openeis/server/LoadAnalysisServerResource.java 70
org/wattdepot/extension/openeis/server/LoadDurationCurveServer.java 72
        "GET /wattdepot/{" + orgId + "}/" + OpenEISLabels.OPENEIS + "/" + OpenEISLabels.LOAD_ANALYSIS +
            "/?" + Labels.DEPOSITORY + "={" + depositoryId + "}&" + Labels.SENSOR + "={" + sensorId + "}&" +
            Labels.START + "={" + startString + "}&" + Labels.END + "={" + endString + "}");
    try {
      Depository depository = depot.getDepository(depositoryId, orgId, true);
      Date start = Tstamp.makeTimestamp(startString).toGregorianCalendar().getTime();
      Date end = Tstamp.makeTimestamp(endString).toGregorianCalendar().getTime();
      InterpolatedValueList values;
      if (depository.getMeasurementType().getName().startsWith("Power")) {
        values = getHourlyPointData(depositoryId, sensorId, start, end, false);
      }
      else if (depository.getMeasurementType().getName().startsWith("Energy")) {
        values = getHourlyDifferenceData(depositoryId, sensorId, start, end, false);
      }
      else {
        setStatus(Status.CLIENT_ERROR_BAD_REQUEST, depositoryId + " is not a Power Depository.");
        return null;
      }
      InterpolatedValueValueComparator c = new InterpolatedValueValueComparator();
File Line
org/wattdepot/client/http/api/WattDepotClient.java 796
org/wattdepot/client/http/api/WattDepotClient.java 854
    stringBuilder.append(sensor.getId());
    stringBuilder.append("&");
    stringBuilder.append(Labels.TIMESTAMP);
    stringBuilder.append("=");
    try {
      stringBuilder.append(DateConvert.convertDate(timestamp).toXMLFormat());
    }
    catch (DatatypeConfigurationException e) {
      e.printStackTrace();
    }
    stringBuilder.append("&");
    stringBuilder.append(Labels.VALUE_TYPE);
    stringBuilder.append("=");
    if (pointValues) {
      stringBuilder.append(Labels.POINT);
    }
    else {
      stringBuilder.append(Labels.DIFFERENCE);
    }
    stringBuilder.append("&");
    stringBuilder.append(Labels.SAMPLES);
    stringBuilder.append("=");
    stringBuilder.append(samples);
    try {
      client = makeClient(stringBuilder.toString());
      DepositoryHistoricalValuesResource resource = client.wrap(DepositoryHistoricalValuesResource.class);
      InterpolatedValueList ret = resource.retrieve();
      return ret;
    }
    catch (ResourceException re) {
      throw re;
    }
    finally {
      client.release();
    }
  }

  @Override
  public InterpolatedValueList getHistoricalValues(Depository depository, SensorGroup group, Date timestamp, Boolean daily, Integer samples, Boolean pointValues) {
File Line
org/wattdepot/client/http/api/collector/EGaugeCollector.java 319
org/wattdepot/client/http/api/collector/NOAAWeatherCollector.java 298
org/wattdepot/client/http/api/collector/StressCollector.java 135
        "Usage: EGaugeCollector <server uri> <username> <password> <collectorid>");
    options.addOption("s", "server", true, "WattDepot Server URI. (http://server.wattdepot.org)");
    options.addOption("u", "username", true, "Username");
    options.addOption("o", "organizationId", true, "User's Organization id.");
    options.addOption("p", "password", true, "Password");
    options.addOption("c", "collector", true, "Collector Process Definition Id");
    options.addOption("d", "debug", false, "Displays sensor data as it is sent to the server.");

    CommandLine cmd = null;
    String serverUri = null;
    String username = null;
    String organizationId = null;
    String password = null;
    String collectorId = null;
    boolean debug = false;

    CommandLineParser parser = new PosixParser();
    HelpFormatter formatter = new HelpFormatter();
    try {
      cmd = parser.parse(options, args);
    }
    catch (ParseException e) {
      System.err.println("Command line parsing failed. Reason: " + e.getMessage() + ". Exiting.");
      System.exit(1);
    }
    if (cmd.hasOption("h")) {
      formatter.printHelp("EGaugeCollector", options);
File Line
org/wattdepot/client/http/api/performance/GetDateValueRate.java 80
org/wattdepot/client/http/api/performance/GetEarliestValueRate.java 80
org/wattdepot/client/http/api/performance/GetIntervalValueRate.java 80
org/wattdepot/client/http/api/performance/GetLatestValueRate.java 80
      formatter.printHelp("GetDateValueRate", options);
      System.exit(0);
    }
    if (cmd.hasOption("s")) {
      serverUri = cmd.getOptionValue("s");
    }
    else {
      serverUri = "http://server.wattdepot.org/";
    }
    if (cmd.hasOption("u")) {
      username = cmd.getOptionValue("u");
    }
    else {
      username = "user";
    }
    if (cmd.hasOption("p")) {
      password = cmd.getOptionValue("p");
    }
    else {
      password = "default";
    }
    if (cmd.hasOption("o")) {
      organizationId = cmd.getOptionValue("o");
    }
    else {
      organizationId = "organization";
    }
    if (cmd.hasOption("gps")) {
      getsPerSec = Integer.parseInt(cmd.getOptionValue("gps"));
    }
    else {
      getsPerSec = 13;
    }
    debug = cmd.hasOption("d");
    if (debug) {
      System.out.println("Get Value(date) Rate:");
File Line
org/wattdepot/client/http/api/performance/GetDateValueThroughput.java 136
org/wattdepot/client/http/api/performance/GetEarliestValueThroughput.java 137
org/wattdepot/client/http/api/performance/GetIntervalValueThroughput.java 137
org/wattdepot/client/http/api/performance/GetLatestValueThroughput.java 136
org/wattdepot/client/http/api/performance/PutThroughput.java 137
      formatter.printHelp("GetDateValueThroughput", options);
      System.exit(0);
    }
    if (cmd.hasOption("s")) {
      serverUri = cmd.getOptionValue("s");
    }
    else {
      serverUri = "http://server.wattdepot.org/";
    }
    if (cmd.hasOption("u")) {
      username = cmd.getOptionValue("u");
    }
    else {
      username = "user";
    }
    if (cmd.hasOption("p")) {
      password = cmd.getOptionValue("p");
    }
    else {
      password = "default";
    }
    if (cmd.hasOption("o")) {
      organizationId = cmd.getOptionValue("o");
    }
    else {
      organizationId = "organization";
    }
    if (cmd.hasOption("n")) {
      numSamples = Integer.parseInt(cmd.getOptionValue("n"));
    }
    else {
      numSamples = 13;
    }
    debug = cmd.hasOption("d");
    if (debug) {
      System.out.println("GetDateValue Throughput:");
File Line
org/wattdepot/common/domainmodel/InterpolatedValue.java 267
org/wattdepot/common/domainmodel/IntervalValue.java 176
    result = prime * result + ((end == null) ? 0 : end.hashCode());
    result = prime * result + ((measurementType == null) ? 0 : measurementType.hashCode());
    result = prime * result + ((sensorId == null) ? 0 : sensorId.hashCode());
    result = prime * result + ((value == null) ? 0 : value.hashCode());
    return result;
  }

  /**
   * @param end end date to set.
   */
  public void setEnd(Date end) {
    this.end = new Date(end.getTime());
  }

  /**
   * @param measurementType the measurementType to set
   */
  public void setMeasurementType(MeasurementType measurementType) {
    this.measurementType = measurementType;
  }

  /**
   * @param sensorId the sensorId to set
   */
  public void setSensorId(String sensorId) {
    this.sensorId = sensorId;
  }

  /**
   * @param start the start date to set.
   */
  public void setStart(Date start) {
    this.start = new Date(start.getTime());
  }

  /**
   * @param value the value to set
   */
  public void setValue(Double value) {
    this.value = value;
  }
File Line
org/wattdepot/common/domainmodel/MeasurementPruningDefinition.java 141
org/wattdepot/server/depository/impl/hibernate/MeasurementPruningDefinitionImpl.java 130
    else if (!depositoryId.equals(other.depositoryId)) {
      return false;
    }
    if (id == null) {
      if (other.id != null) {
        return false;
      }
    }
    else if (!id.equals(other.id)) {
      return false;
    }
    if (ignoreWindowDays == null) {
      if (other.ignoreWindowDays != null) {
        return false;
      }
    }
    else if (!ignoreWindowDays.equals(other.ignoreWindowDays)) {
      return false;
    }
    if (minGapSeconds == null) {
      if (other.minGapSeconds != null) {
        return false;
      }
    }
    else if (!minGapSeconds.equals(other.minGapSeconds)) {
      return false;
    }
    if (name == null) {
      if (other.name != null) {
        return false;
      }
    }
    else if (!name.equals(other.name)) {
      return false;
    }
    if (sensorId == null) {
File Line
org/wattdepot/client/http/api/collector/EGaugeCollector.java 270
org/wattdepot/client/http/api/collector/NOAAWeatherCollector.java 256
      System.err.format("URI %s was invalid leading to malformed URL%n", eGaugeUri);
    }
    catch (XPathExpressionException e) {
      System.err.println("Bad XPath expression, this should never happen.");
    }
    catch (ParserConfigurationException e) {
      System.err.println("Unable to configure XML parser, this is weird.");
    }
    catch (SAXException e) {
      System.err.format(
          "%s: Got bad XML from eGauge sensor %s (%s), hopefully this is temporary.%n",
          Tstamp.makeTimestamp(), sensor.getName(), e);
    }
    catch (IOException e) {
      System.err.format(
          "%s: Unable to retrieve data from eGauge sensor %s (%s), hopefully this is temporary.%n",
          Tstamp.makeTimestamp(), sensor.getName(), e);
    }

    if (meas != null) {
      try {
        this.client.putMeasurement(depository, meas);
      }
      catch (MeasurementTypeException e) {
        System.err.format("%s does not store %s measurements%n", depository.getName(),
            meas.getMeasurementType());
      }
      if (debug) {
        System.out.println(meas);
      }
    }
  }
File Line
org/wattdepot/client/http/api/collector/EGaugeCollector.java 353
org/wattdepot/client/http/api/collector/NOAAWeatherCollector.java 332
org/wattdepot/client/http/api/collector/SharkCollector.java 232
    }
    if (cmd.hasOption("u")) {
      username = cmd.getOptionValue("u");
    }
    else {
      username = UserInfo.ROOT.getUid();
    }
    if (cmd.hasOption("o")) {
      organizationId = cmd.getOptionValue("o");
    }
    else {
      organizationId = Organization.ADMIN_GROUP.getId();
    }
    if (cmd.hasOption("p")) {
      password = cmd.getOptionValue("p");
    }
    else {
      password = "default";
    }
    if (cmd.hasOption("c")) {
      collectorId = cmd.getOptionValue("c");
    }
    else {
      collectorId = "ilima_6th_power";
    }

    debug = cmd.hasOption("d");

    if (debug) {
      System.out.println("WattDepot Server: " + serverUri);
      System.out.println("Username: " + username);
      System.out.println("OrganizationID: " + organizationId);
File Line
org/wattdepot/server/depository/impl/hibernate/DepositoryImpl.java 95
org/wattdepot/server/depository/impl/hibernate/SensorGroupImpl.java 182
    DepositoryImpl other = (DepositoryImpl) obj;
    if (id == null) {
      if (other.id != null) {
        return false;
      }
    }
    else if (!id.equals(other.id)) {
      return false;
    }
    if (name == null) {
      if (other.name != null) {
        return false;
      }
    }
    else if (!name.equals(other.name)) {
      return false;
    }
    if (org == null) {
      if (other.org != null) {
        return false;
      }
    }
    else if (!org.equals(other.org)) {
      return false;
    }
    if (pk == null) {
      if (other.pk != null) {
        return false;
      }
    }
    else if (!pk.equals(other.pk)) {
      return false;
    }
    if (type == null) {
File Line
org/wattdepot/client/http/api/collector/EGaugeCollector.java 377
org/wattdepot/client/http/api/collector/NOAAWeatherCollector.java 356
org/wattdepot/client/http/api/collector/StressCollector.java 193
    }

    debug = cmd.hasOption("d");

    if (debug) {
      System.out.println("WattDepot Server: " + serverUri);
      System.out.println("Username: " + username);
      System.out.println("OrganizationID: " + organizationId);
      System.out.println("Password: " + password);
      System.out.println("Collector Process Definition Id: " + collectorId);
      System.out.println("debug: " + debug);
      System.out.println();
    }
    try {
      if (!MultiThreadedCollector.start(serverUri, username, organizationId, password, collectorId,
          debug)) {
        System.exit(1);
      }
    }
    catch (InterruptedException e) {
      e.printStackTrace();
      System.exit(1);
    }
    catch (BadCredentialException e) {
      e.printStackTrace();
      System.exit(1);
    }
  }
}
File Line
org/wattdepot/server/depository/impl/hibernate/CollectorProcessDefinitionImpl.java 121
org/wattdepot/server/depository/impl/hibernate/DepositoryImpl.java 96
org/wattdepot/server/depository/impl/hibernate/SensorGroupImpl.java 183
    if (id == null) {
      if (other.id != null) {
        return false;
      }
    }
    else if (!id.equals(other.id)) {
      return false;
    }
    if (name == null) {
      if (other.name != null) {
        return false;
      }
    }
    else if (!name.equals(other.name)) {
      return false;
    }
    if (org == null) {
      if (other.org != null) {
        return false;
      }
    }
    else if (!org.equals(other.org)) {
      return false;
    }
    if (pk == null) {
      if (other.pk != null) {
        return false;
      }
    }
    else if (!pk.equals(other.pk)) {
      return false;
    }
    if (pollingInterval == null) {
File Line
org/wattdepot/client/http/api/collector/SharkCollector.java 224
org/wattdepot/client/http/api/collector/StressCollector.java 161
      formatter.printHelp("SharkCollector", options);
      System.exit(0);
    }
    if (cmd.hasOption("s")) {
      serverUri = cmd.getOptionValue("s");
    }
    else {
      serverUri = "http://localhost:8192/";
    }
    if (cmd.hasOption("u")) {
      username = cmd.getOptionValue("u");
    }
    else {
      username = UserInfo.ROOT.getUid();
    }
    if (cmd.hasOption("o")) {
      organizationId = cmd.getOptionValue("o");
    }
    else {
      organizationId = Organization.ADMIN_GROUP.getId();
    }
    if (cmd.hasOption("p")) {
      password = cmd.getOptionValue("p");
    }
    else {
      password = "default";
    }
    if (cmd.hasOption("c")) {
      collectorId = cmd.getOptionValue("c");
    }
    else {
      collectorId = "ilima_6th_power";
File Line
org/wattdepot/client/http/api/performance/GetDateValueRate.java 62
org/wattdepot/client/http/api/performance/GetEarliestValueRate.java 62
org/wattdepot/client/http/api/performance/GetIntervalValueRate.java 62
org/wattdepot/client/http/api/performance/GetLatestValueRate.java 62
        + " -p <password> -o <orgId> -gps <getsPerSecond> [-d]");
    options.addOption("s", "server", true, "WattDepot Server URI. (http://server.wattdepot.org)");
    options.addOption("u", "username", true, "Username");
    options.addOption("o", "organizationId", true, "User's Organization id.");
    options.addOption("p", "password", true, "Password");
    options.addOption("gps", "getsPerSecond", true,
        "Number of gets per second.");
    options.addOption("d", "debug", false, "Displays statistics as the Measurements are stored.");
    CommandLineParser parser = new PosixParser();
    HelpFormatter formatter = new HelpFormatter();
    try {
      cmd = parser.parse(options, args);
    }
    catch (ParseException e) {
      System.err.println("Command line parsing failed. Reason: " + e.getMessage() + ". Exiting.");
      System.exit(1);
    }
    if (cmd.hasOption("h")) {
      formatter.printHelp("GetDateValueRate", options);
File Line
org/wattdepot/client/http/api/performance/GetDateValueThroughput.java 119
org/wattdepot/client/http/api/performance/GetEarliestValueThroughput.java 120
org/wattdepot/client/http/api/performance/PutThroughput.java 120
        + " -p <password> -o <orgId> [-d]");
    options.addOption("s", "server", true, "WattDepot Server URI. (http://server.wattdepot.org)");
    options.addOption("u", "username", true, "Username");
    options.addOption("o", "organizationId", true, "User's Organization id.");
    options.addOption("p", "password", true, "Password");
    options.addOption("n", "numSamples", true, "Number of puts to sample.");
    options.addOption("d", "debug", false, "Displays statistics as the Measurements are stored.");
    CommandLineParser parser = new PosixParser();
    HelpFormatter formatter = new HelpFormatter();
    try {
      cmd = parser.parse(options, args);
    }
    catch (ParseException e) {
      System.err.println("Command line parsing failed. Reason: " + e.getMessage() + ". Exiting.");
      System.exit(1);
    }
    if (cmd.hasOption("h")) {
      formatter.printHelp("GetDateValueThroughput", options);
File Line
org/wattdepot/client/http/api/performance/GetIntervalValueThroughput.java 120
org/wattdepot/client/http/api/performance/GetLatestValueThroughput.java 119
        + " -p <password> -o <orgId> [-d]");
    options.addOption("s", "server", true, "WattDepot Server URI. (http://server.wattdepot.org)");
    options.addOption("u", "username", true, "Username");
    options.addOption("o", "organizationId", true, "User's Organization id.");
    options.addOption("p", "password", true, "Password");
    options.addOption("n", "numSamples", true, "Number of puts to sample.");
    options.addOption("d", "debug", false, "Displays statistics as the Gets are made.");
    CommandLineParser parser = new PosixParser();
    HelpFormatter formatter = new HelpFormatter();
    try {
      cmd = parser.parse(options, args);
    }
    catch (ParseException e) {
      System.err.println("Command line parsing failed. Reason: " + e.getMessage() + ". Exiting.");
      System.exit(1);
    }
    if (cmd.hasOption("h")) {
      formatter.printHelp("GetIntervalValueThroughput", options);
File Line
org/wattdepot/server/http/api/DepositoryDailyValuesServer.java 95
org/wattdepot/server/http/api/DepositoryHourlyValuesServer.java 99
            List<XMLGregorianCalendar> times = Tstamp.getTimestampList(startTime, endTime, DAY_MINUTES);
            if (times != null) {
              for (int i = 1; i < times.size(); i++) {
                XMLGregorianCalendar begin = times.get(i - 1);
                Date beginDate = begin.toGregorianCalendar().getTime();
                XMLGregorianCalendar end = times.get(i);
                Date endDate = end.toGregorianCalendar().getTime();
                Sensor sensor = depot.getSensor(sensorId, orgId, false);
                Double val = 0.0;
                InterpolatedValue value = new InterpolatedValue(sensorId, val, depository.getMeasurementType(), beginDate, endDate);
                value.addDefinedSensor(sensorId);
                if (sensor != null) {
                  try {
                    val = getValueForSensor(depositoryId, orgId, sensorId, beginDate, endDate, dataType);
                    value.addReportingSensor(sensorId);
File Line
org/wattdepot/common/domainmodel/SensorModel.java 105
org/wattdepot/server/depository/impl/hibernate/SensorModelImpl.java 113
    else if (!name.equals(other.name)) {
      return false;
    }
    if (protocol == null) {
      if (other.protocol != null) {
        return false;
      }
    }
    else if (!protocol.equals(other.protocol)) {
      return false;
    }
    if (type == null) {
      if (other.type != null) {
        return false;
      }
    }
    else if (!type.equals(other.type)) {
      return false;
    }
    if (version == null) {
      if (other.version != null) {
        return false;
      }
    }
    else if (!version.equals(other.version)) {
      return false;
    }
    return true;
  }

  /**
   * @return the id
   */
  public String getId() {
    return id;
  }

  /**
   * @return the name
   */
  public String getName() {
    return name;
  }

  /**
   * @return the protocol
   */
  public String getProtocol() {
File Line
org/wattdepot/extension/openeis/server/OpenEISServer.java 159
org/wattdepot/extension/openeis/server/OpenEISServer.java 225
          catch (NoMeasurementException e) { // if there are no measurements just add null
            val = null;
          }
          InterpolatedValue iv = new InterpolatedValue(sensorId, val, depository.getMeasurementType(), beginDate, endDate);
          if (!keepNulls) {
            if (val != null) {
              ret.getInterpolatedValues().add(iv);
            }
            else {
              ret.getMissingData().add(iv);
            }
          }
          else {
            ret.getInterpolatedValues().add(iv);
            if (val == null) {
              ret.getMissingData().add(iv);
            }
          }
        }
        return ret;
      }
      catch (IdNotFoundException e) {
        setStatus(Status.CLIENT_ERROR_BAD_REQUEST, e.getMessage());
        return null;
      }
    }
    else {
      setStatus(Status.CLIENT_ERROR_BAD_REQUEST, "Bad credentials.");
      return null;
    }
  }
File Line
org/wattdepot/server/http/api/DepositoryAverageValuesServer.java 60
org/wattdepot/server/http/api/DepositoryValuesServer.java 56
  private String dataType;

  /*
   * (non-Javadoc)
   * 
   * @see org.restlet.resource.Resource#doInit()
   */
  @Override
  protected void doInit() throws ResourceException {
    super.doInit();
    this.sensorId = getQuery().getValues(Labels.SENSOR);
    this.start = getQuery().getValues(Labels.START);
    this.end = getQuery().getValues(Labels.END);
    this.depositoryId = getAttribute(Labels.DEPOSITORY_ID);
    this.interval = getQuery().getValues(Labels.INTERVAL);
    this.dataType = getQuery().getValues(Labels.VALUE_TYPE);
  }

  /**
   * retrieve the depository measurement list for a sensor.
   * 
   * @return measurement list.
   */
  public InterpolatedValueList doRetrieve() {
    getLogger().log(
        Level.INFO,
        "GET /wattdepot/{" + orgId + "}/" + Labels.DEPOSITORY + "/{" + depositoryId + "}/"
            + Labels.VALUES + "/" + Labels.AVERAGE + "/?" + Labels.SENSOR + "={" + sensorId + "}&"
File Line
org/wattdepot/server/depository/impl/hibernate/WattDepotPersistenceImpl.java 3059
org/wattdepot/server/depository/impl/hibernate/WattDepotPersistenceImpl.java 3104
    Double startVal = getValue(depotId, orgId, sensorId, start, check);
    if (endVal != null && startVal != null) {
      Double returnVal = endVal - startVal;
      if (returnVal < 0 && !generatePower) {
        Double max = Double.MIN_NORMAL;
        Double min = Double.MAX_VALUE;
        List<Measurement> measurements = getMeasurements(depotId, orgId, sensorId, start, end, false);
        for (Measurement m : measurements) {
          Double value = m.getValue();
          if (max < value) {
            max = value;
          }
          if (min > value) {
            min = value;
          }
          returnVal = endVal - startVal + max - min;
        }
      }
      return returnVal;
    }
    return null;
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.wattdepot.server.WattDepotPersistence#getValue(java.lang.String,
   * java.lang.String, java.util.Date, java.util.Date, java.lang.Long)
   */
  @Override
  public Double getValue(String depotId, String orgId, String sensorId, Date start, Date end,
File Line
org/wattdepot/server/measurement/pruning/MeasurementPruner.java 374
org/wattdepot/server/measurement/pruning/MeasurementPruner.java 405
            System.out.println("Sensor " + s + ": " + windowStart + " to " + windowEnd + " has "
                + size + " measurements");
          }
          int index = 1;
          int baseIndex = 0;
          while (index < size - 1) {
            long secondsBetween = Math.abs((check.get(index).getDate().getTime() - check
                .get(baseIndex).getDate().getTime()) / 1000);
            if (secondsBetween < definition.getMinGapSeconds()) {
              this.persistance.deleteMeasurement(this.definition.getDepositoryId(),
                  this.definition.getOrganizationId(), check.get(index++).getId());
              deleted++;
            }
            else {
              baseIndex = index;
              index++;
            }
          }
        }

      }
File Line
org/wattdepot/client/http/api/WattDepotClient.java 776
org/wattdepot/client/http/api/WattDepotClient.java 834
  public InterpolatedValueList getHistoricalValues(Depository depository, Sensor sensor, Date timestamp, Boolean daily, Integer samples, Boolean pointValues) {
    ClientResource client = null;
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append(this.organizationId);
    stringBuilder.append("/");
    stringBuilder.append(Labels.DEPOSITORY);
    stringBuilder.append("/");
    stringBuilder.append(depository.getId());
    stringBuilder.append("/");
    stringBuilder.append(Labels.HISTORICAL_VALUES);
    stringBuilder.append("/");
    if (daily) {
      stringBuilder.append(Labels.DAILY);
    }
    else {
      stringBuilder.append(Labels.HOURLY);
    }
    stringBuilder.append("/?");
    stringBuilder.append(Labels.SENSOR);
    stringBuilder.append("=");
    stringBuilder.append(sensor.getId());
File Line
org/wattdepot/server/depository/impl/hibernate/WattDepotPersistenceImpl.java 1354
org/wattdepot/server/depository/impl/hibernate/WattDepotPersistenceImpl.java 1599
            "FROM MeasurementImpl WHERE depository = :depot AND sensor = :sensor ORDER BY timestamp asc")
        .setParameter("depot", depot).setParameter("sensor", sensor).setMaxResults(1).list();
    // List<MeasurementImpl> result = (List<MeasurementImpl>) session
    // .createQuery(
    // "FROM MeasurementImpl WHERE depository = :depot AND sensor = :sensor "
    // + "AND timestamp IN (SELECT min(timestamp) FROM MeasurementImpl WHERE "
    // + "depository = :depot AND sensor = :sensor)").setParameter("depot",
    // depot)
    // .setParameter("sensor", sensor).list();
    if (result.size() > 0) {
      MeasurementImpl meas = result.get(0);
      value = new InterpolatedValue(sensorId, meas.getValue(), depot.getType().toMeasurementType(),
          meas.getTimestamp());
    }
    session.getTransaction().commit();
    session.close();
    if (timingp) {
      endTime = System.nanoTime();
      diff = endTime - startTime;
      padding = padding.substring(0, padding.length() - 2);
      timingLogger.log(Level.SEVERE, padding + "getEarliestMeasuredValueNoCheck(" + depotId + ", "
File Line
org/wattdepot/server/http/api/DepositoryDailyValuesServer.java 51
org/wattdepot/server/http/api/DepositoryHourlyValuesServer.java 50
  private String depositoryId;
  private String sensorId;
  private String start;
  private String end;
  private String dataType;

  /*
   * (non-Javadoc)
   *
   * @see org.restlet.resource.Resource#doInit()
   */
  @Override
  protected void doInit() throws ResourceException {
    super.doInit();
    this.sensorId = getQuery().getValues(Labels.SENSOR);
    this.start = getQuery().getValues(Labels.START);
    this.end = getQuery().getValues(Labels.END);
    this.depositoryId = getAttribute(Labels.DEPOSITORY_ID);
    this.dataType = getQuery().getValues(Labels.VALUE_TYPE);
  }

  /**
   * retrieve the daily depository value list for a sensor.
   *
   * @return measurement list.
   */
  public InterpolatedValueList doRetrieve() {
    getLogger().log(
        Level.INFO,
        "GET /wattdepot/{" + orgId + "}/" + Labels.DEPOSITORY + "/{" + depositoryId + "}/" + Labels.DAILY + "/"
File Line
org/wattdepot/client/http/api/performance/GetEarliestValueThroughput.java 237
org/wattdepot/client/http/api/performance/GetIntervalValueThroughput.java 237
org/wattdepot/client/http/api/performance/GetLatestValueThroughput.java 235
            this.timer.schedule(new GetEarliestValueTask(serverUri, username, orgId, password, debug),
                0, 1000);
            if (debug) {
              System.out.println("Starting task " + i);
            }
          }
          Thread.sleep(10);
        }
        catch (BadCredentialException e) { // NOPMD
          // should not happen.
          e.printStackTrace();
        }
        catch (IdNotFoundException e) { // NOPMD
          // should not happen.
          e.printStackTrace();
        }
        catch (BadSensorUriException e) { // NOPMD
          // should not happen
          e.printStackTrace();
        }
        catch (InterruptedException e) {  // NOPMD
          // should not happen
          e.printStackTrace();
        }
      }
    }
  }

  /**
   * @param stats the DescriptiveStatistics to calculate the mean put time.
   * @return The estimated put rate based upon the time it takes to put a single
   *         measurement.
   */
  private Long calculateGetRate(DescriptiveStatistics stats) {
    double putTime = stats.getMean();
    Long ret = null;
    double numPuts = 1.0 / putTime;
    ret = Math.round(numPuts);
    return ret;
  }
}
File Line
org/wattdepot/client/http/api/WattDepotClient.java 623
org/wattdepot/client/http/api/WattDepotClient.java 682
  public DescriptiveStats getDescriptiveStats(Depository depository, Sensor sensor, Date timestamp, Boolean daily, Integer samples, Boolean pointValues) {
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append(this.organizationId);
    stringBuilder.append("/");
    stringBuilder.append(Labels.DEPOSITORY);
    stringBuilder.append("/");
    stringBuilder.append(depository.getId());
    stringBuilder.append("/");
    stringBuilder.append(Labels.DESCRIPTIVE_STATS);
    stringBuilder.append("/");
    if (daily) {
      stringBuilder.append(Labels.DAILY);
    }
    else {
      stringBuilder.append(Labels.HOURLY);
    }
    stringBuilder.append("/?");
    stringBuilder.append(Labels.SENSOR);
    stringBuilder.append("=");
    stringBuilder.append(sensor.getId());
File Line
org/wattdepot/client/http/api/performance/GetIntervalValueThroughput.java 182
org/wattdepot/client/http/api/performance/GetLatestValueThroughput.java 180
        new GetIntervalValueThroughput(serverUri, username, organizationId, password, debug), 0,
        numSamples * 1000);
  }

  /*
   * (non-Javadoc)
   * 
   * @see java.util.TimerTask#run()
   */
  @Override
  public void run() {
    // wake up to check the stats.
    if (this.numChecks == 0) {
      // haven't actually run so do nothing.
      this.numChecks++;
      // should I put a bogus first rate so we don't start too fast?
      this.averageGetTime.addValue(1.0); // took 1 second per so we start with a
                                         // low average.
    }
    else {
      this.timer.cancel();
      this.numChecks++;
      Double aveTime = sampleTask.getAverageTime();
      this.averageGetTime.addValue(aveTime / 1E9);
      this.averageMinGetTime.addValue(sampleTask.getMinTime() / 1E9);
      this.averageMaxGetTime.addValue(sampleTask.getMaxTime() / 1E9);
      this.calculatedGetsPerSec = calculateGetRate(averageGetTime);
      this.getsPerSec = calculatedGetsPerSec;
      // System.out.println("Min put time = " + (sampleTask.getMinGetTime() /
      // 1E9));
      System.out.println("Ave get value (date, date) time = " + (aveTime / 1E9) + " => "
File Line
org/wattdepot/client/http/api/WattDepotClient.java 642
org/wattdepot/client/http/api/WattDepotClient.java 854
    stringBuilder.append(sensor.getId());
    stringBuilder.append("&");
    stringBuilder.append(Labels.TIMESTAMP);
    stringBuilder.append("=");
    try {
      stringBuilder.append(DateConvert.convertDate(timestamp).toXMLFormat());
    }
    catch (DatatypeConfigurationException e) {
      e.printStackTrace();
    }
    stringBuilder.append("&");
    stringBuilder.append(Labels.VALUE_TYPE);
    stringBuilder.append("=");
    if (pointValues) {
      stringBuilder.append(Labels.POINT);
    }
    else {
      stringBuilder.append(Labels.DIFFERENCE);
    }
    stringBuilder.append("&");
    stringBuilder.append(Labels.SAMPLES);
    stringBuilder.append("=");
    stringBuilder.append(samples);
File Line
org/wattdepot/client/http/api/WattDepotClient.java 701
org/wattdepot/client/http/api/WattDepotClient.java 796
    stringBuilder.append(group.getId());
    stringBuilder.append("&");
    stringBuilder.append(Labels.TIMESTAMP);
    stringBuilder.append("=");
    try {
      stringBuilder.append(DateConvert.convertDate(timestamp).toXMLFormat());
    }
    catch (DatatypeConfigurationException e) {
      e.printStackTrace();
    }
    stringBuilder.append("&");
    stringBuilder.append(Labels.VALUE_TYPE);
    stringBuilder.append("=");
    if (pointValues) {
      stringBuilder.append(Labels.POINT);
    }
    else {
      stringBuilder.append(Labels.DIFFERENCE);
    }
    stringBuilder.append("&");
    stringBuilder.append(Labels.SAMPLES);
    stringBuilder.append("=");
    stringBuilder.append(samples);
File Line
org/wattdepot/server/depository/impl/hibernate/WattDepotPersistenceImpl.java 2956
org/wattdepot/server/depository/impl/hibernate/WattDepotPersistenceImpl.java 3135
      boolean check) throws NoMeasurementException, IdNotFoundException {
    if (check) {
      getOrganization(orgId, check);
      getDepository(depotId, orgId, check);
      getSensor(sensorId, orgId, check);
    }
    Double ret = null;
    Session session = Manager.getFactory(getServerProperties()).openSession();
    session.beginTransaction();
    DepositoryImpl depot = retrieveDepository(session, depotId, orgId);
    SensorImpl sensor = retrieveSensor(session, sensorId, orgId);
    @SuppressWarnings("unchecked")
    List<MeasurementImpl> result = (List<MeasurementImpl>) session
        .createQuery(
            "FROM MeasurementImpl WHERE timestamp = :time AND depository = :depot AND sensor = :sensor")
        .setParameter("time", timestamp).setParameter("depot", depot)
        .setParameter("sensor", sensor).setMaxResults(1).list();
File Line
org/wattdepot/client/http/api/WattDepotClient.java 462
org/wattdepot/client/http/api/WattDepotClient.java 902
org/wattdepot/client/http/api/WattDepotClient.java 1734
      sb.append(Labels.DAILY);
      sb.append("/");
      sb.append(Labels.VALUES);
      sb.append("/?");
      sb.append(Labels.SENSOR);
      sb.append("=");
      sb.append(sensor.getId());
      sb.append("&");
      sb.append(Labels.START);
      sb.append("=");
      sb.append(DateConvert.convertDate(start));
      sb.append("&");
      sb.append(Labels.END);
      sb.append("=");
      sb.append(DateConvert.convertDate(end));
      sb.append("&");
      sb.append(Labels.VALUE_TYPE);
File Line
org/wattdepot/client/http/api/WattDepotClient.java 514
org/wattdepot/client/http/api/WattDepotClient.java 954
org/wattdepot/client/http/api/WattDepotClient.java 1795
      sb.append(Labels.DAILY);
      sb.append("/");
      sb.append(Labels.VALUES);
      sb.append("/?");
      sb.append(Labels.SENSOR);
      sb.append("=");
      sb.append(group.getId());
      sb.append("&");
      sb.append(Labels.START);
      sb.append("=");
      sb.append(DateConvert.convertDate(start));
      sb.append("&");
      sb.append(Labels.END);
      sb.append("=");
      sb.append(DateConvert.convertDate(end));
      sb.append("&");
      sb.append(Labels.VALUE_TYPE);
File Line
org/wattdepot/client/http/api/collector/EGaugeCollector.java 153
org/wattdepot/client/http/api/collector/NOAAWeatherCollector.java 130
  public EGaugeCollector(String serverUri, String username, String orgId, String password,
      Sensor sensor, Long pollingInterval, Depository depository, boolean debug)
      throws BadCredentialException, BadSensorUriException, IdNotFoundException {
    super(serverUri, username, orgId, password, sensor.getId(), pollingInterval, depository,
        debug);
    this.measType = depository.getMeasurementType();
    this.measUnit = Unit.valueOf(measType.getUnits());
    this.sensor = client.getSensor(definition.getSensorId());

    Property prop = this.definition.getProperty("registerName");
    if (prop != null) {
      this.registerName = prop.getValue();
    }
File Line
org/wattdepot/client/http/api/performance/GetDateValueThroughput.java 180
org/wattdepot/client/http/api/performance/GetEarliestValueThroughput.java 182
    t.schedule(new GetDateValueThroughput(serverUri, username, organizationId, password, debug), 0,
        numSamples * 1000);
  }

  /*
   * (non-Javadoc)
   * 
   * @see java.util.TimerTask#run()
   */
  @Override
  public void run() {
    // wake up to check the stats.
    if (this.numChecks == 0) {
      // haven't actually run so do nothing.
      this.numChecks++;
      // should I put a bogus first rate so we don't start too fast?
      // this.averageGetTime.addValue(1.0); // took 1 second per so we start with a
                                         // low average.
    }
    else {
      this.timer.cancel();
      this.numChecks++;
      Double aveTime = sampleTask.getAverageTime();
      this.averageGetTime.addValue(aveTime / 1E9);
      this.averageMinGetTime.addValue(sampleTask.getMinTime() / 1E9);
      this.averageMaxGetTime.addValue(sampleTask.getMaxTime() / 1E9);
      this.calculatedGetsPerSec = calculateGetRate(averageGetTime);
      this.getsPerSec = calculatedGetsPerSec;
      // System.out.println("Min put time = " + (sampleTask.getMinTime() /
      // 1E9));
      System.out.println("Ave get value (date) time = " + (aveTime / 1E9) + " => "
File Line
org/wattdepot/extension/openeis/server/HeatMapServer.java 64
org/wattdepot/extension/openeis/server/TimeSeriesLoadProfileServer.java 64
        "GET /wattdepot/{" + orgId + "}/" + OpenEISLabels.OPENEIS + "/" + OpenEISLabels.HEAT_MAP +
            "/?" + Labels.DEPOSITORY + "={" + depositoryId + "}&" + Labels.SENSOR + "={" + sensorId + "}&" +
            OpenEISLabels.DURATION + "={" + interval + "}");
    try {
      Depository depository = depot.getDepository(depositoryId, orgId, true);
      if (depository.getMeasurementType().getName().startsWith("Power")) {
        return getHourlyPointData(depositoryId, sensorId, interval, true);
      }
      else if (depository.getMeasurementType().getName().startsWith("Energy")) {
        return getHourlyDifferenceData(depositoryId, sensorId, interval, true);
      }
      else {
        setStatus(Status.CLIENT_ERROR_BAD_REQUEST, depositoryId + " is not a Power Depository.");
File Line
org/wattdepot/server/depository/impl/hibernate/CollectorProcessDefinitionImpl.java 126
org/wattdepot/server/depository/impl/hibernate/DepositoryImpl.java 101
org/wattdepot/server/depository/impl/hibernate/SensorGroupImpl.java 188
org/wattdepot/server/depository/impl/hibernate/SensorImpl.java 238
    else if (!id.equals(other.id)) {
      return false;
    }
    if (name == null) {
      if (other.name != null) {
        return false;
      }
    }
    else if (!name.equals(other.name)) {
      return false;
    }
    if (org == null) {
      if (other.org != null) {
        return false;
      }
    }
    else if (!org.equals(other.org)) {
      return false;
    }
    if (pk == null) {
      if (other.pk != null) {
        return false;
      }
    }
    else if (!pk.equals(other.pk)) {
      return false;
    }
    if (pollingInterval == null) {
File Line
org/wattdepot/client/http/api/WattDepotClient.java 476
org/wattdepot/client/http/api/WattDepotClient.java 916
org/wattdepot/client/http/api/WattDepotClient.java 1752
      sb.append(DateConvert.convertDate(end));
      sb.append("&");
      sb.append(Labels.VALUE_TYPE);
      sb.append("=");
      if (usePointValues) {
        sb.append(Labels.POINT);
      }
      else {
        sb.append(Labels.DIFFERENCE);
      }
      client = makeClient(sb.toString());
      DepositoryValuesResource resource = client.wrap(DepositoryValuesResource.class);
      InterpolatedValueList ret = resource.retrieve();
      client.release();
      return ret;
    }
    catch (DatatypeConfigurationException e) {
      e.printStackTrace();
    }
    finally {
      if (client != null) {
        client.release();
      }
    }
    return null;
  }

  @Override
  public InterpolatedValueList getDailyValues(Depository depository, SensorGroup group, Date start, Date end, Boolean usePointValues) {
File Line
org/wattdepot/client/http/api/collector/NOAAWeatherCollector.java 97
org/wattdepot/client/http/api/collector/NOAAWeatherCollector.java 133
    super(serverUri, username, orgId, password, collectorId, debug);
    this.measType = depository.getMeasurementType();
    this.measUnit = Unit.valueOf(measType.getUnits());
    this.sensor = client.getSensor(definition.getSensorId());

    Property prop = this.definition.getProperty("registerName");
    if (prop != null) {
      this.registerName = prop.getValue();
    }
    try {
      new URL(sensor.getUri());
      this.noaaWeatherUri = sensor.getUri();
    }
    catch (MalformedURLException e) {
      throw new BadSensorUriException(client.getSensor(definition.getSensorId()).getUri()
          + " is not a valid URI.");
    }
  }
File Line
org/wattdepot/client/http/api/WattDepotClient.java 528
org/wattdepot/client/http/api/WattDepotClient.java 968
org/wattdepot/client/http/api/WattDepotClient.java 1752
      sb.append(DateConvert.convertDate(end));
      sb.append("&");
      sb.append(Labels.VALUE_TYPE);
      sb.append("=");
      if (usePointValues) {
        sb.append(Labels.POINT);
      }
      else {
        sb.append(Labels.DIFFERENCE);
      }
      client = makeClient(sb.toString());
      DepositoryValuesResource resource = client.wrap(DepositoryValuesResource.class);
      InterpolatedValueList ret = resource.retrieve();
      client.release();
      return ret;
    }
    catch (DatatypeConfigurationException e) {
      e.printStackTrace();
    }
    finally {
      if (client != null) {
        client.release();
      }
    }
    return null;
  }

  /*
   * (non-Javadoc)
   *
   * @see org.wattdepot.client.WattDepotInterface#getDepositories()
   */
  @Override
  public DepositoryList getDepositories() {
File Line
org/wattdepot/client/http/api/collector/MultiThreadedCollector.java 194
org/wattdepot/client/http/api/collector/MultiThreadedCollector.java 218
          SharkCollector collector = new SharkCollector(serverUri, username, orgId, password,
              collectorId, debug);
          if (collector.isValid()) {
            System.out.format("Started polling %s sensor at %s%n", sensor.getName(),
                Tstamp.makeTimestamp());
            t.schedule(collector, 0, definition.getPollingInterval() * 1000);
          }
          else {
            System.err.format("Cannot poll %s sensor%n", sensor.getName());
            return false;
          }
        }
        catch (IdNotFoundException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        catch (BadSensorUriException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
      else if (model.getName().equals(SensorModelHelper.STRESS)) {
File Line
org/wattdepot/client/http/api/WattDepotClient.java 354
org/wattdepot/client/http/api/WattDepotClient.java 1232
          + "/" + Labels.VALUES + "/" + Labels.AVERAGE + "/" + "?sensor=" + sensor.getId() + "&start="
          + DateConvert.convertDate(start) + "&end=" + DateConvert.convertDate(end) + "&interval=" + interval + "&value-type=" + valueType);
      DepositoryMinimumValuesResource resource = client.wrap(DepositoryMinimumValuesResource.class);
      InterpolatedValueList ret = resource.retrieve();
      client.release();
      return ret;
    }
    catch (ResourceException e1) {
      throw new NoMeasurementException(e1.getCause());
    }
    catch (DatatypeConfigurationException e) {
      e.printStackTrace();
    }
    finally {
      if (client != null) {
        client.release();
      }
    }
    return null;
  }

  @Override
  public InterpolatedValueList getAverageValues(Depository depository, SensorGroup group, Date start, Date end, Integer interval, Boolean usePointValues) throws NoMeasurementException {
File Line
org/wattdepot/client/http/api/collector/MeasurementSummaryClient.java 128
org/wattdepot/client/http/api/collector/StressTestCollector.java 153
org/wattdepot/client/http/api/csv/OrganizationDomainMain.java 85
org/wattdepot/client/http/api/performance/GetDateValueRate.java 80
org/wattdepot/client/http/api/performance/GetDateValueThroughput.java 136
org/wattdepot/client/http/api/performance/GetEarliestValueRate.java 80
org/wattdepot/client/http/api/performance/GetEarliestValueThroughput.java 137
org/wattdepot/client/http/api/performance/GetIntervalValueRate.java 80
org/wattdepot/client/http/api/performance/GetIntervalValueThroughput.java 137
org/wattdepot/client/http/api/performance/GetLatestValueRate.java 80
org/wattdepot/client/http/api/performance/GetLatestValueThroughput.java 136
org/wattdepot/client/http/api/performance/PutCollectorRate.java 82
org/wattdepot/client/http/api/performance/PutRate.java 80
org/wattdepot/client/http/api/performance/PutThroughput.java 137
      formatter.printHelp("StressTestCollector", options);
      System.exit(0);
    }
    if (cmd.hasOption("s")) {
      serverUri = cmd.getOptionValue("s");
    }
    else {
      serverUri = "http://server.wattdepot.org/";
    }
    if (cmd.hasOption("u")) {
      username = cmd.getOptionValue("u");
    }
    else {
      username = "user";
    }
    if (cmd.hasOption("p")) {
      password = cmd.getOptionValue("p");
    }
    else {
      password = "default";
    }
    if (cmd.hasOption("o")) {
      organizationId = cmd.getOptionValue("o");
    }
    else {
      organizationId = "organization";
    }
    if (cmd.hasOption("c")) {
File Line
org/wattdepot/client/http/api/WattDepotClient.java 354
org/wattdepot/client/http/api/WattDepotClient.java 1069
org/wattdepot/client/http/api/WattDepotClient.java 1232
          + "/" + Labels.VALUES + "/" + Labels.AVERAGE + "/" + "?sensor=" + sensor.getId() + "&start="
          + DateConvert.convertDate(start) + "&end=" + DateConvert.convertDate(end) + "&interval=" + interval + "&value-type=" + valueType);
      DepositoryMinimumValuesResource resource = client.wrap(DepositoryMinimumValuesResource.class);
      InterpolatedValueList ret = resource.retrieve();
      client.release();
      return ret;
    }
    catch (ResourceException e1) {
      throw new NoMeasurementException(e1.getCause());
    }
    catch (DatatypeConfigurationException e) {
      e.printStackTrace();
    }
    finally {
      if (client != null) {
        client.release();
      }
    }
    return null;
  }

  @Override
  public InterpolatedValueList getAverageValues(Depository depository, SensorGroup group, Date start, Date end, Integer interval, Boolean usePointValues) throws NoMeasurementException {
File Line
org/wattdepot/client/http/api/WattDepotClient.java 384
org/wattdepot/client/http/api/WattDepotClient.java 1039
          + "/" + Labels.VALUES + "/" + Labels.AVERAGE + "/" + "?sensor=" + group.getId() + "&start="
          + DateConvert.convertDate(start) + "&end=" + DateConvert.convertDate(end) + "&interval=" + interval + "&value-type=" + valueType);
      DepositoryMinimumValuesResource resource = client.wrap(DepositoryMinimumValuesResource.class);
      InterpolatedValueList ret = resource.retrieve();
      client.release();
      return ret;
    }
    catch (ResourceException e1) {
      throw new NoMeasurementException(e1.getCause());
    }
    catch (DatatypeConfigurationException e) {
      e.printStackTrace();
    }
    finally {
      if (client != null) {
        client.release();
      }
    }
    return null;
  }

  /*
   * (non-Javadoc)
   *
   * @see
   * org.wattdepot.client.WattDepotInterface#getCollectorProcessDefinition(java
   * .lang .String)
   */
  @Override
  public CollectorProcessDefinition getCollectorProcessDefinition(String id)
File Line
org/wattdepot/server/depository/impl/hibernate/MeasurementTypeImpl.java 84
org/wattdepot/server/depository/impl/hibernate/OrganizationImpl.java 97
org/wattdepot/server/depository/impl/hibernate/SensorModelImpl.java 91
    MeasurementTypeImpl other = (MeasurementTypeImpl) obj;
    if (id == null) {
      if (other.id != null) {
        return false;
      }
    }
    else if (!id.equals(other.id)) {
      return false;
    }
    if (name == null) {
      if (other.name != null) {
        return false;
      }
    }
    else if (!name.equals(other.name)) {
      return false;
    }
    if (pk == null) {
      if (other.pk != null) {
        return false;
      }
    }
    else if (!pk.equals(other.pk)) {
      return false;
    }
    if (units == null) {
File Line
org/wattdepot/client/http/api/WattDepotClient.java 452
org/wattdepot/client/http/api/WattDepotClient.java 504
  public InterpolatedValueList getDailyValues(Depository depository, Sensor sensor, Date start, Date end, Boolean usePointValues) {
    ClientResource client = null;
    try {
      StringBuilder sb = new StringBuilder();
      sb.append(this.organizationId);
      sb.append("/");
      sb.append(Labels.DEPOSITORY);
      sb.append("/");
      sb.append(depository.getId());
      sb.append("/");
      sb.append(Labels.DAILY);
      sb.append("/");
      sb.append(Labels.VALUES);
      sb.append("/?");
      sb.append(Labels.SENSOR);
      sb.append("=");
      sb.append(sensor.getId());
File Line
org/wattdepot/client/http/api/WattDepotClient.java 476
org/wattdepot/client/http/api/WattDepotClient.java 528
org/wattdepot/client/http/api/WattDepotClient.java 916
org/wattdepot/client/http/api/WattDepotClient.java 968
org/wattdepot/client/http/api/WattDepotClient.java 1813
      sb.append(DateConvert.convertDate(end));
      sb.append("&");
      sb.append(Labels.VALUE_TYPE);
      sb.append("=");
      if (usePointValues) {
        sb.append(Labels.POINT);
      }
      else {
        sb.append(Labels.DIFFERENCE);
      }
      client = makeClient(sb.toString());
      DepositoryValuesResource resource = client.wrap(DepositoryValuesResource.class);
      InterpolatedValueList ret = resource.retrieve();
      client.release();
      return ret;
    }
    catch (DatatypeConfigurationException e) {
      e.printStackTrace();
    }
    finally {
      if (client != null) {
        client.release();
      }
    }
    return null;
  }
File Line
org/wattdepot/client/http/api/WattDepotClient.java 892
org/wattdepot/client/http/api/WattDepotClient.java 944
  public InterpolatedValueList getHourlyValues(Depository depository, Sensor sensor, Date start, Date end, Boolean usePointValues) {
    ClientResource client = null;
    try {
      StringBuilder sb = new StringBuilder();
      sb.append(this.organizationId);
      sb.append("/");
      sb.append(Labels.DEPOSITORY);
      sb.append("/");
      sb.append(depository.getId());
      sb.append("/");
      sb.append(Labels.HOURLY);
      sb.append("/");
      sb.append(Labels.VALUES);
      sb.append("/?");
      sb.append(Labels.SENSOR);
      sb.append("=");
      sb.append(sensor.getId());
File Line
org/wattdepot/client/http/api/WattDepotClient.java 384
org/wattdepot/client/http/api/WattDepotClient.java 1039
org/wattdepot/client/http/api/WattDepotClient.java 1262
          + "/" + Labels.VALUES + "/" + Labels.AVERAGE + "/" + "?sensor=" + group.getId() + "&start="
          + DateConvert.convertDate(start) + "&end=" + DateConvert.convertDate(end) + "&interval=" + interval + "&value-type=" + valueType);
      DepositoryMinimumValuesResource resource = client.wrap(DepositoryMinimumValuesResource.class);
      InterpolatedValueList ret = resource.retrieve();
      client.release();
      return ret;
    }
    catch (ResourceException e1) {
      throw new NoMeasurementException(e1.getCause());
    }
    catch (DatatypeConfigurationException e) {
      e.printStackTrace();
    }
    finally {
      if (client != null) {
        client.release();
      }
    }
    return null;
  }
File Line
org/wattdepot/server/http/api/DepositoryDailyValuesServer.java 80
org/wattdepot/server/http/api/DepositoryHourlyValuesServer.java 80
        "GET /wattdepot/{" + orgId + "}/" + Labels.DEPOSITORY + "/{" + depositoryId + "}/" + Labels.DAILY + "/"
            + Labels.VALUES + "/?" + Labels.SENSOR + "={" + sensorId + "}&" + Labels.START + "={"
            + start + "}&" + Labels.END + "={" + end + "}&" + Labels.VALUE_TYPE + "={" + dataType + "}");
    if (isInRole(orgId)) {
      if (start != null && end != null && dataType != null) {
        InterpolatedValueList ret = new InterpolatedValueList();
        try {
          Depository depository = depot.getDepository(depositoryId, orgId, true);
          if (depository != null) {
            XMLGregorianCalendar startTime = DateConvert.parseCalString(start);
            // set start time to beginning of day.
            startTime.setTime(0, 0, 0, 0);
File Line
org/wattdepot/client/http/api/collector/EGaugeCollector.java 324
org/wattdepot/client/http/api/collector/NOAAWeatherCollector.java 303
org/wattdepot/client/http/api/collector/SharkCollector.java 203
org/wattdepot/client/http/api/collector/StressCollector.java 140
    options.addOption("c", "collector", true, "Collector Process Definition Id");
    options.addOption("d", "debug", false, "Displays sensor data as it is sent to the server.");

    CommandLine cmd = null;
    String serverUri = null;
    String username = null;
    String organizationId = null;
    String password = null;
    String collectorId = null;
    boolean debug = false;

    CommandLineParser parser = new PosixParser();
    HelpFormatter formatter = new HelpFormatter();
    try {
      cmd = parser.parse(options, args);
    }
    catch (ParseException e) {
      System.err.println("Command line parsing failed. Reason: " + e.getMessage() + ". Exiting.");
      System.exit(1);
    }
    if (cmd.hasOption("h")) {
      formatter.printHelp("EGaugeCollector", options);
File Line
org/wattdepot/client/http/api/collector/EGaugeCollector.java 353
org/wattdepot/client/http/api/collector/NOAAWeatherCollector.java 332
org/wattdepot/client/http/api/collector/StressCollector.java 169
    }
    if (cmd.hasOption("u")) {
      username = cmd.getOptionValue("u");
    }
    else {
      username = UserInfo.ROOT.getUid();
    }
    if (cmd.hasOption("o")) {
      organizationId = cmd.getOptionValue("o");
    }
    else {
      organizationId = Organization.ADMIN_GROUP.getId();
    }
    if (cmd.hasOption("p")) {
      password = cmd.getOptionValue("p");
    }
    else {
      password = "default";
    }
    if (cmd.hasOption("c")) {
      collectorId = cmd.getOptionValue("c");
    }
    else {
      collectorId = "ilima_6th_power";
File Line
org/wattdepot/client/http/api/WattDepotClient.java 354
org/wattdepot/client/http/api/WattDepotClient.java 1039
org/wattdepot/client/http/api/WattDepotClient.java 1232
          + "/" + Labels.VALUES + "/" + Labels.AVERAGE + "/" + "?sensor=" + sensor.getId() + "&start="
          + DateConvert.convertDate(start) + "&end=" + DateConvert.convertDate(end) + "&interval=" + interval + "&value-type=" + valueType);
      DepositoryMinimumValuesResource resource = client.wrap(DepositoryMinimumValuesResource.class);
      InterpolatedValueList ret = resource.retrieve();
      client.release();
      return ret;
    }
    catch (ResourceException e1) {
      throw new NoMeasurementException(e1.getCause());
    }
    catch (DatatypeConfigurationException e) {
      e.printStackTrace();
    }
    finally {
      if (client != null) {
        client.release();
      }
    }
    return null;
  }

  @Override
  public InterpolatedValueList getAverageValues(Depository depository, SensorGroup group, Date start, Date end, Integer interval, Boolean usePointValues) throws NoMeasurementException {
File Line
org/wattdepot/client/http/api/collector/AllOrganizationCollectors.java 76
org/wattdepot/client/http/api/collector/MeasurementSummaryClient.java 128
org/wattdepot/client/http/api/collector/StressTestCollector.java 153
org/wattdepot/client/http/api/csv/OrganizationDomainMain.java 85
org/wattdepot/client/http/api/performance/GetDateValueRate.java 80
org/wattdepot/client/http/api/performance/GetDateValueThroughput.java 136
org/wattdepot/client/http/api/performance/GetEarliestValueRate.java 80
org/wattdepot/client/http/api/performance/GetEarliestValueThroughput.java 137
org/wattdepot/client/http/api/performance/GetIntervalValueRate.java 80
org/wattdepot/client/http/api/performance/GetIntervalValueThroughput.java 137
org/wattdepot/client/http/api/performance/GetLatestValueRate.java 80
org/wattdepot/client/http/api/performance/GetLatestValueThroughput.java 136
org/wattdepot/client/http/api/performance/PutCollectorRate.java 82
org/wattdepot/client/http/api/performance/PutRate.java 80
org/wattdepot/client/http/api/performance/PutThroughput.java 137
      formatter.printHelp("AllOrganizationCollectors", options);
      System.exit(0);
    }
    if (cmd.hasOption("s")) {
      serverUri = cmd.getOptionValue("s");
    }
    else {
      serverUri = "http://server.wattdepot.org/";
    }
    if (cmd.hasOption("u")) {
      username = cmd.getOptionValue("u");
    }
    else {
      username = "user";
    }
    if (cmd.hasOption("p")) {
      password = cmd.getOptionValue("p");
    }
    else {
      password = "default";
    }
    if (cmd.hasOption("o")) {
      organizationId = cmd.getOptionValue("o");
    }
    else {
      organizationId = "organization";
    }
File Line
org/wattdepot/server/depository/impl/hibernate/DepositoryImpl.java 173
org/wattdepot/server/depository/impl/hibernate/SensorGroupImpl.java 147
  }

  /*
   * (non-Javadoc)
   * 
   * @see java.lang.Object#hashCode()
   */
  @Override
  public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((id == null) ? 0 : id.hashCode());
    result = prime * result + ((name == null) ? 0 : name.hashCode());
    result = prime * result + ((org == null) ? 0 : org.hashCode());
    result = prime * result + ((pk == null) ? 0 : pk.hashCode());
    result = prime * result + ((type == null) ? 0 : type.hashCode());
File Line
org/wattdepot/client/http/api/WattDepotClient.java 354
org/wattdepot/client/http/api/WattDepotClient.java 384
org/wattdepot/client/http/api/WattDepotClient.java 1039
org/wattdepot/client/http/api/WattDepotClient.java 1069
org/wattdepot/client/http/api/WattDepotClient.java 1232
          + "/" + Labels.VALUES + "/" + Labels.AVERAGE + "/" + "?sensor=" + sensor.getId() + "&start="
          + DateConvert.convertDate(start) + "&end=" + DateConvert.convertDate(end) + "&interval=" + interval + "&value-type=" + valueType);
      DepositoryMinimumValuesResource resource = client.wrap(DepositoryMinimumValuesResource.class);
      InterpolatedValueList ret = resource.retrieve();
      client.release();
      return ret;
    }
    catch (ResourceException e1) {
      throw new NoMeasurementException(e1.getCause());
    }
    catch (DatatypeConfigurationException e) {
      e.printStackTrace();
    }
    finally {
      if (client != null) {
        client.release();
      }
    }
    return null;
  }

  @Override
  public InterpolatedValueList getAverageValues(Depository depository, SensorGroup group, Date start, Date end, Integer interval, Boolean usePointValues) throws NoMeasurementException {
File Line
org/wattdepot/client/http/api/collector/EGaugeCollector.java 384
org/wattdepot/client/http/api/collector/NOAAWeatherCollector.java 363
org/wattdepot/client/http/api/collector/SharkCollector.java 262
org/wattdepot/client/http/api/collector/StressCollector.java 200
      System.out.println("OrganizationID: " + organizationId);
      System.out.println("Password: " + password);
      System.out.println("Collector Process Definition Id: " + collectorId);
      System.out.println("debug: " + debug);
      System.out.println();
    }
    try {
      if (!MultiThreadedCollector.start(serverUri, username, organizationId, password, collectorId,
          debug)) {
        System.exit(1);
      }
    }
    catch (InterruptedException e) {
      e.printStackTrace();
      System.exit(1);
    }
    catch (BadCredentialException e) {
      e.printStackTrace();
      System.exit(1);
    }
  }
File Line
org/wattdepot/server/depository/impl/hibernate/WattDepotPersistenceImpl.java 3046
org/wattdepot/server/depository/impl/hibernate/WattDepotPersistenceImpl.java 3090
      boolean check) throws NoMeasurementException, IdNotFoundException {
    Boolean generatePower = false;
    Session session = Manager.getFactory(getServerProperties()).openSession();
    session.beginTransaction();
    SensorImpl sensor = retrieveSensor(session, sensorId, orgId);
    for (PropertyImpl p : sensor.getProperties()) {
      if (p.getKey().equals(Labels.GENERATE_POWER)) {
        generatePower = Boolean.parseBoolean(p.getValue());
      }
    }
    session.getTransaction().commit();
    session.close();
    Double endVal = getValue(depotId, orgId, sensorId, end, check);
File Line
org/wattdepot/client/http/api/WattDepotClient.java 354
org/wattdepot/client/http/api/WattDepotClient.java 1069
org/wattdepot/client/http/api/WattDepotClient.java 1232
org/wattdepot/client/http/api/WattDepotClient.java 1262
          + "/" + Labels.VALUES + "/" + Labels.AVERAGE + "/" + "?sensor=" + sensor.getId() + "&start="
          + DateConvert.convertDate(start) + "&end=" + DateConvert.convertDate(end) + "&interval=" + interval + "&value-type=" + valueType);
      DepositoryMinimumValuesResource resource = client.wrap(DepositoryMinimumValuesResource.class);
      InterpolatedValueList ret = resource.retrieve();
      client.release();
      return ret;
    }
    catch (ResourceException e1) {
      throw new NoMeasurementException(e1.getCause());
    }
    catch (DatatypeConfigurationException e) {
      e.printStackTrace();
    }
    finally {
      if (client != null) {
        client.release();
      }
    }
    return null;
  }
File Line
org/wattdepot/client/http/api/WattDepotClient.java 1726
org/wattdepot/client/http/api/WattDepotClient.java 1787
  public InterpolatedValueList getValues(Depository depository, Sensor sensor, Date start, Date end, Integer interval, Boolean usePointValues) throws NoMeasurementException {
    ClientResource client = null;
    try {
      StringBuilder sb = new StringBuilder();
      sb.append(this.organizationId);
      sb.append("/");
      sb.append(Labels.DEPOSITORY);
      sb.append("/");
      sb.append(depository.getId());
      sb.append("/");
      sb.append(Labels.VALUES);
      sb.append("/?");
      sb.append(Labels.SENSOR);
      sb.append("=");
      sb.append(sensor.getId());
File Line
org/wattdepot/client/http/api/collector/EGaugeCollector.java 104
org/wattdepot/client/http/api/collector/NOAAWeatherCollector.java 94
  public EGaugeCollector(String serverUri, String username, String orgId, String password,
      String collectorId, boolean debug) throws BadCredentialException, IdNotFoundException,
      BadSensorUriException {
    super(serverUri, username, orgId, password, collectorId, debug);
    this.measType = depository.getMeasurementType();
    this.measUnit = Unit.valueOf(measType.getUnits());
    this.sensor = client.getSensor(definition.getSensorId());

    Property prop = this.definition.getProperty("registerName");
    if (prop != null) {
      this.registerName = prop.getValue();
    }
File Line
org/wattdepot/extension/openeis/server/HeatMapServer.java 38
org/wattdepot/extension/openeis/server/TimeSeriesLoadProfileServer.java 38
public class HeatMapServer extends OpenEISServer {
  private String depositoryId;
  private String sensorId;
  private TimeInterval interval;

  /*
   * (non-Javadoc)
   *
   * @see org.restlet.resource.Resource#doInit()
   */
  @Override
  protected void doInit() throws ResourceException {
    super.doInit();
    this.depositoryId = getQuery().getValues(Labels.DEPOSITORY);
    this.sensorId = getQuery().getValues(Labels.SENSOR);
    this.interval = TimeInterval.fromParameter(getQuery().getValues(OpenEISLabels.DURATION));
  }

  /**
   * Retrieves the last year's hourly power data for the given depository and sensor.
   *
   * @return An InterpolatedValueList of the hourly power data.
   */
  public InterpolatedValueList doRetrieve() {
    getLogger().log(
        Level.INFO,
        "GET /wattdepot/{" + orgId + "}/" + OpenEISLabels.OPENEIS + "/" + OpenEISLabels.HEAT_MAP +
File Line
org/wattdepot/client/http/api/collector/MultiThreadedCollector.java 194
org/wattdepot/client/http/api/collector/MultiThreadedCollector.java 218
org/wattdepot/client/http/api/collector/MultiThreadedCollector.java 241
          SharkCollector collector = new SharkCollector(serverUri, username, orgId, password,
              collectorId, debug);
          if (collector.isValid()) {
            System.out.format("Started polling %s sensor at %s%n", sensor.getName(),
                Tstamp.makeTimestamp());
            t.schedule(collector, 0, definition.getPollingInterval() * 1000);
          }
          else {
            System.err.format("Cannot poll %s sensor%n", sensor.getName());
            return false;
          }
        }
        catch (IdNotFoundException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        catch (BadSensorUriException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
File Line
org/wattdepot/server/http/api/DepositoryMaximumValuesServerResource.java 41
org/wattdepot/server/http/api/DepositoryMinimumValuesServerResource.java 39
    implements DepositoryMaximumValuesResource {

  /*
   * (non-Javadoc)
   * 
   * @see
   * org.wattdepot.common.http.api.DepositoryMaximumValuesResource#retrieve()
   */
  @Override
  public InterpolatedValueList retrieve() {
    InterpolatedValueList ret = new InterpolatedValueList();
    // loop from start till end getting the measurements in the interval
    Date tempStart = startDate;
    Date tempEnd = incrementMinutes(tempStart, interval);
    try {
      Depository deposit = depot.getDepository(depositoryId, orgId, true);
      while (tempEnd.before(endDate)) {
        InterpolatedValue interpolatedValue = new InterpolatedValue(sensorId, 0.0, deposit.getMeasurementType(),
            tempStart);
        MeasurementList meas = getMeasurements(depositoryId, orgId, sensorId, tempStart, tempEnd, interpolatedValue);
        DescriptiveStats stat = new DescriptiveStats(meas, valueType);
        Double value = stat.getMax();
File Line
org/wattdepot/client/http/api/performance/GetDateValueThroughput.java 80
org/wattdepot/client/http/api/performance/GetEarliestValueThroughput.java 80
org/wattdepot/client/http/api/performance/GetIntervalValueThroughput.java 80
org/wattdepot/client/http/api/performance/GetLatestValueThroughput.java 80
  public GetDateValueThroughput(String serverUri, String username, String orgId, String password,
      boolean debug) throws BadCredentialException, IdNotFoundException, BadSensorUriException {
    this.serverUri = serverUri;
    this.username = username;
    this.orgId = orgId;
    this.password = password;
    this.debug = debug;
    this.numChecks = 0;
    this.getsPerSec = 1l;
    this.calculatedGetsPerSec = 1l;
    this.averageMaxGetTime = new DescriptiveStatistics();
    this.averageMinGetTime = new DescriptiveStatistics();
    this.averageGetTime = new DescriptiveStatistics();
    this.timer = new Timer("throughput");
    this.sampleTask = new GetDateValueTask(serverUri, username, orgId, password, debug);
File Line
org/wattdepot/server/http/api/DepositoryDescriptiveStatsServer.java 207
org/wattdepot/server/http/api/DepositoryHistoricalValuesServer.java 166
    }
    return null;
  }

  /*
   * (non-Javadoc)
   *
   * @see org.restlet.resource.Resource#doInit()
   */
  @Override
  protected void doInit() throws ResourceException {
    super.doInit();
    this.depositoryId = getAttribute(Labels.DEPOSITORY_ID);
    this.hourlyDailyChoice = getAttribute(Labels.HOURLY_DAILY);
    this.sensorId = getQuery().getValues(Labels.SENSOR);
    this.timestamp = getQuery().getValues(Labels.TIMESTAMP);
    this.valueType = getQuery().getValues(Labels.VALUE_TYPE);
    this.samples = Integer.parseInt(getQuery().getValues(Labels.SAMPLES));
  }