/*
   * (non-Javadoc)
   * @see com.sensus.mlc.light.bcf.ILightBCF#resetMinMaxValue(com.sensus.mlc.light.model.request.LightRequest)
   */
  @Override
  public LightResponse resetMinMaxValue(LightRequest request) {
    LightResponse response = new LightResponse();
    InternalResultsResponse<Light> internalResponse = null;

    try {
      ValidationContext context =
          new ValidationContext(
              LightRequest.class.getSimpleName(),
              request,
              MLCPersistanceActionEnum.getSlcActionName(),
              MLCPersistanceActionEnum.RESET_MIN_MAX);
      checkDefaultsFetchAll(request);
      if (getRequestValidationController().validate(context) // Validate Tenant and UserContext
          && getInquiryRequestValidationController().validate(context)) // Validate pagination
      {
        internalResponse = getLightBCL().resetMinMaxValue(request);
        response.setLights(internalResponse.getResultsList());
      }

      handleOperationStatusAndMessages(response, internalResponse, context.getMessages(), true);

    } catch (Exception ex) {

      handleException(LOG, response, ex, DEFAULT_LIGHT_BCF_EXCEPTION_MSG);
    }

    return response;
  }
  /*
   * (non-Javadoc)
   * @see com.sensus.mlc.light.bcf.ILightBCF#fetchById(com.sensus.mlc.light.model.request.FetchByIdRequest)
   */
  @Override
  public LightResponse fetchById(FetchByIdRequest request) {
    LightResponse response = new LightResponse();

    try {
      InternalResultsResponse<Light> lightResponse = null;

      ValidationContext context =
          new ValidationContext(
              LightRequest.class.getSimpleName(),
              request,
              MLCPersistanceActionEnum.getSlcActionName(),
              MLCPersistanceActionEnum.FETCH_BY_ID);

      if (!getRequestValidationController().validate(context)) // Validate Tenant and UserContext
      {
        handleOperationStatusAndMessages(response, lightResponse, context.getMessages(), false);
        return response;
      }

      if (ValidationUtil.isNull(request.getLightId())
          && ValidationUtil.isNull(request.getRniId())) {
        response.addMessage(
            MessageInfo.createFieldValidationError(SENSUS_MLC_VALIDATOR_ID_RNI_REQUIRED));
        return response;
      }

      lightResponse = getLightBCL().fetchById(request);
      response.setLight(lightResponse.getFirstResult());
      handleOperationStatusAndMessages(response, lightResponse, context.getMessages(), false);
    } catch (Exception ex) {
      handleException(LOG, response, ex, DEFAULT_LIGHT_BCF_EXCEPTION_MSG);
    }
    return response;
  }