/*
   * (non-Javadoc)
   * @see com.sensus.mlc.process.bcl.IProcessCommunicationGateway#sendAction(com.sensus.mlc.process.model.request.
   * ProcessRequest)
   */
  @Override
  public MlcGatewayResponse sendAction(ProcessRequest processRequest) {
    Tenant tenant = processRequest.getUserContext().<Tenant>getTenant();
    Process process = processRequest.getProcess();
    setRemoteUserCredentials(tenant);

    List<DimmedSmartpoint> wsDimmedSmartPointList = generateWsDimmedSmartPointList(processRequest);
    if (ValidationUtil.isNullOrEmpty(wsDimmedSmartPointList)) {
      return null;
    }

    InitiateApplyLightLevelRequest request = getFactory().createInitiateApplyLightLevelRequest();
    request.setCustomerID(tenant.getRniCode());
    request.setTransactionID(process.getRniCorrelationId());

    request.getDimmedSmartpoint().addAll(wsDimmedSmartPointList);
    persistLog(processRequest, wsDimmedSmartPointList);
    return getMlcGatewayWs().setLightIntensity(request);
  }
  /*
   * (non-Javadoc)
   * @see com.sensus.mlc.process.bcl.IProcessCommunicationGateway#sendAction(com.sensus.mlc.process.model.request.
   * ProcessRequest)
   */
  @Override
  public MlcGatewayResponse sendAction(ProcessRequest processRequest) {
    Tenant tenant = processRequest.getUserContext().<Tenant>getTenant();
    Process process = processRequest.getProcess();
    setRemoteUserCredentials(tenant);

    List<Smartpoint> wsSmartPointList = generateWsSmartPointList(process, tenant);
    if (ValidationUtil.isNullOrEmpty(wsSmartPointList)) {
      return null;
    }

    InitiateApplySmartpointPropertiesRequest request =
        getFactory().createInitiateApplySmartpointPropertiesRequest();

    request.setCustomerID(tenant.getRniCode());
    request.setTransactionID(process.getRniCorrelationId());
    request.getSmartpoint().addAll(wsSmartPointList);
    request.setPoleId(process.getProcessItems().get(0).getLight().getPoleId());

    persistLog(processRequest, wsSmartPointList);

    // Call Web Service
    return getMlcGatewayWs().applySmartpointProperties(request);
  }