コード例 #1
0
  /*
   * Remove Meter to the southbound plugin and our internal database
   *
   * @param path
   *
   * @param dataObject
   */
  private Status removeMeter(InstanceIdentifier<?> path, Meter meterRemoveDataObject) {
    MeterKey meterKey = meterRemoveDataObject.getKey();

    if (null != meterKey && validateMeter(meterRemoveDataObject).isSuccess()) {
      RemoveMeterInputBuilder meterBuilder = new RemoveMeterInputBuilder();
      meterBuilder.fieldsFrom(meterRemoveDataObject);
      meterBuilder.setNode(meterRemoveDataObject.getNode());
      meterBuilder.setMeterId(new MeterId(meterRemoveDataObject.getId()));
      meterService.removeMeter(meterBuilder.build());
    } else {
      return new Status(StatusCode.BADREQUEST, "Meter Key or attribute validation failed");
    }

    return new Status(StatusCode.SUCCESS);
  }
コード例 #2
0
  /*
   * Update Meter to the southbound plugin and our internal database
   *
   * @param path
   *
   * @param dataObject
   */
  private Status updateMeter(InstanceIdentifier<?> path, Meter updatedMeter, Meter originalMeter) {
    UpdatedMeterBuilder updateMeterBuilder = null;

    if (validateMeter(updatedMeter).isSuccess()) {
      UpdateMeterInputBuilder updateMeterInputBuilder = new UpdateMeterInputBuilder();
      updateMeterInputBuilder.setNode(updatedMeter.getNode());
      updateMeterBuilder = new UpdatedMeterBuilder();
      updateMeterBuilder.fieldsFrom(updatedMeter);
      updateMeterBuilder.setMeterId(new MeterId(updatedMeter.getId()));
      updateMeterInputBuilder.setUpdatedMeter(updateMeterBuilder.build());
      OriginalMeterBuilder originalMeterBuilder = new OriginalMeterBuilder(originalMeter);
      updateMeterInputBuilder.setOriginalMeter(originalMeterBuilder.build());
      meterService.updateMeter(updateMeterInputBuilder.build());
    } else {
      return new Status(StatusCode.BADREQUEST, "Meter Key or attribute validation failed");
    }

    return new Status(StatusCode.SUCCESS);
  }