コード例 #1
0
  /*
   * (non-Javadoc)
   * @see
   * com.sensus.mlc.light.bcf.ILightBCF#updateSchedule(com.sensus.mlc.light.model.request.ScheduleMaintenanceRequest)
   */
  @Override
  public ScheduleMaintenanceResponse updateSchedule(ScheduleMaintenanceRequest request) {
    ScheduleMaintenanceResponse response = new ScheduleMaintenanceResponse();

    try {
      InternalResponse internalResponse = null;

      ValidationContext context =
          new ValidationContext(
              ScheduleMaintenanceRequest.class.getSimpleName(),
              request,
              MLCPersistanceActionEnum.getSlcActionName(),
              MLCPersistanceActionEnum.UPDATE_SCHEDULE);

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

      if (ValidationUtil.isNull(request.getSchedule())
          || ValidationUtil.isNull(request.getSchedule().getParentId())) {
        response.addMessage(
            MessageInfo.createFieldValidationError(SENSUS_MLC_VALIDATOR_PARENT_ID_REQUIRED));
        return response;
      }

      internalResponse = getLightBCL().updateSchedule(request);
      handleOperationStatusAndMessages(response, internalResponse, null, true);

    } catch (Exception ex) {
      SensusInterfaceUtil.handleException(LOG, response, ex, DEFAULT_LIGHT_BCF_EXCEPTION_MSG);
    }
    return response;
  }
コード例 #2
0
  /*
   * (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;
  }
コード例 #3
0
  /*
   * (non-Javadoc)
   * @see com.sensus.mlc.ecomode.bcf.IEcoModeBCF#fetchLightConsumptionsByLightId(com.sensus.mlc.ecomode.model.request.
   * InquiryEcoModeRequest)
   */
  @Override
  public InquiryEcoModeResponse fetchLightConsumptionsByLightId(
      InquiryEcoModeRequest ecoModeRequest) {
    InquiryEcoModeResponse response = new InquiryEcoModeResponse();
    InternalResultsResponse<Consumption> internalResponse = null;

    try {
      ValidationContext context = new ValidationContext();
      context.getValidationArguments().put(getSlcActionName(), FETCH_LIGHT_CONSUMPTION);
      context.putObjectToBeValidated(INQUIRY_ECOMODE_REQUEST_NAME, ecoModeRequest);
      context.putObjectToBeValidated(INITIAL_DATE.getValue(), ecoModeRequest.getInitialDate());
      context.putObjectToBeValidated(END_DATE.getValue(), ecoModeRequest.getEndDate());

      checkDefaultsFetchAll(ecoModeRequest);
      if (getRequestValidationController().validate(context)
          && getInquiryRequestValidationController().validate(context)
          && getLightSelectionRequestValidationController().validate(context)
          && getRangeDateValidationController().validate(context)) {
        // fetch light consumptions
        internalResponse = getEcoModeBCL().fetchLightConsumptionsByLightId(ecoModeRequest);
      }

      handleOperationStatusAndMessages(response, internalResponse, context.getMessages(), true);
    } catch (Exception ex) {
      handleException(LOG, response, ex, SENSUS_MLC_ECOMODEBCLIMPL_DEFAULTEXCEPTION);
    }
    return response;
  }
コード例 #4
0
  /*
   * (non-Javadoc)
   * @see
   * com.sensus.mlc.light.bcf.ILightBCF#updateLightMass(com.sensus.mlc.light.model.request.LightMassUpdateRequest)
   */
  @Override
  public MaintenanceResponse updateLightMass(LightMassUpdateRequest request) {
    MaintenanceResponse response = new MaintenanceResponse();

    try {
      InternalResponse internalResponse = null;

      ValidationContext context = new ValidationContext();
      context.putObjectToBeValidated(LIGHT_MASS_UPDATE_REQUEST_NAME, request);
      context.putObjectToBeValidated(LIGHT_NAME, request.getLight());

      if (getRequestValidationController().validate(context) // Validate Tenant and UserContext
          && getLightValidationController().validate(context)) // Validate light attributes
      {
        internalResponse = getLightBCL().updateLightMass(request);
      }

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

    } catch (Exception ex) {
      handleException(LOG, response, ex, DEFAULT_LIGHT_BCF_EXCEPTION_MSG);
    }

    return response;
  }
コード例 #5
0
  /*
   * (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;
  }
コード例 #6
0
  /*
   * (non-Javadoc)
   * @see com.sensus.mlc.light.bcf.ILightBCF#fetchMapBoundsByRequest(com.sensus.mlc.light.model.request.LightRequest)
   */
  @Override
  public GeocodeLightInfoResponse fetchMapBoundsByRequest(LightRequest request) {
    GeocodeLightInfoResponse response = new GeocodeLightInfoResponse();
    InternalResultsResponse<GeocodeLightInfo> internalResponse =
        new InternalResultsResponse<GeocodeLightInfo>();

    try {
      ValidationContext context =
          new ValidationContext(
              LightRequest.class.getSimpleName(),
              request,
              MLCPersistanceActionEnum.getSlcActionName(),
              MLCPersistanceActionEnum.FETCH_LIGHT_MAP);

      if (getRequestValidationController().validate(context)) // Validate Tenant and UserContext
      {
        internalResponse = getLightBCL().fetchMapBoundsByRequest(request);
      }

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

    } catch (Exception ex) {

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

    return response;
  }
コード例 #7
0
  /*
   * (non-Javadoc)
   * @see com.sensus.mlc.light.bcf.ILightBCF#fetchAllByRequest(com.sensus.mlc.light.model.request.LightRequest)
   */
  @Override
  public FetchAllResponse fetchAllByRequest(LightRequest request) {
    InternalResultsResponse<Light> lightResponse = null;
    FetchAllResponse response = new FetchAllResponse();

    try {
      ValidationContext context =
          new ValidationContext(
              LightRequest.class.getSimpleName(),
              request,
              MLCPersistanceActionEnum.getSlcActionName(),
              MLCPersistanceActionEnum.FETCH);

      checkDefaultsFetchAll(request);
      if (getRequestValidationController().validate(context) // Validate Tenant and UserContext
          && getInquiryRequestValidationController().validate(context)) // Validate pagination
      {
        lightResponse = getLightBCL().fetchAllByRequest(request);
      }

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

    } catch (Exception ex) {

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

    return response;
  }
コード例 #8
0
  /*
   * (non-Javadoc)
   * @see com.sensus.mlc.light.bcf.ILightBCF#countAllByRequest(com.sensus.mlc.light.model.request.LightRequest)
   */
  @Override
  public CountResponse countAllByRequest(LightRequest request) {
    InternalResultsResponse<Integer> response = null;
    CountResponse countResponse = new CountResponse();

    try {
      ValidationContext context =
          new ValidationContext(
              LightRequest.class.getSimpleName(),
              request,
              MLCPersistanceActionEnum.getSlcActionName(),
              MLCPersistanceActionEnum.FETCH);

      if (getRequestValidationController().validate(context) // Validate Tenant and UserContext
          && getInquiryRequestValidationController().validate(context)) // Validate pagination
      {
        response = getLightBCL().countAllByRequest(request);

        if (!ValidationUtil.isNull(response) && !response.isInError()) {
          countResponse.setCount(response.getFirstResult());
        }
      }

      handleOperationStatusAndMessages(countResponse, response, context.getMessages(), false);

    } catch (Exception ex) {

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

    return countResponse;
  }
コード例 #9
0
  /*
   * (non-Javadoc)
   * @see com.sensus.mlc.lflivrofiscal.bcf.ILflivrofiscalBCF#insertLflivrofiscal(com.sensus.mlc.lflivrofiscal.model.request.LflivrofiscalRequest)
   */
  @Override
  public LflivrofiscalResponse insertLflivrofiscal(LflivrofiscalRequest lflivrofiscalRequest) {
    LflivrofiscalResponse response = new LflivrofiscalResponse();
    InternalResultsResponse<Lflivrofiscal> internalResponse = null;
    try {
      ValidationContext context = new ValidationContext();
      context.getValidationArguments().put(getSlcActionName(), INSERT);
      context.putObjectToBeValidated(LFLIVROFISCAL_REQUEST_NAME, lflivrofiscalRequest);
      context.putObjectToBeValidated(LFLIVROFISCAL_NAME, lflivrofiscalRequest.getLflivrofiscal());

      if (getLightingControlRequestValidationController().validate(context)
          && getLflivrofiscalValidationController().validate(context)) {

        if (getLightListValidationController().validate(context)) {
          internalResponse = getLflivrofiscalBCL().insertLflivrofiscal(lflivrofiscalRequest);
          response.setLflivrofiscal(internalResponse.getResultsList());
        }
      }

      handleOperationStatusAndMessages(response, internalResponse, context.getMessages(), true);
    } catch (Exception ex) {
      SensusInterfaceUtil.handleException(
          LOG, response, ex, DEFAULT_LFLIVROFISCAL_BCF_EXCEPTION_MSG);
    }
    return response;
  }
コード例 #10
0
  /*
   * (non-Javadoc)
   * @see com.sensus.mlc.tabela.bcf.ITabelaBCF#insertTabela(com.sensus.mlc.tabela.model.request.TabelaRequest)
   */
  @Override
  public TabelaResponse insertTabela(TabelaRequest tabelaRequest) {
    TabelaResponse response = new TabelaResponse();
    InternalResultsResponse<Tabela> internalResponse = null;
    try {
      ValidationContext context = new ValidationContext();
      context.getValidationArguments().put(getSlcActionName(), INSERT);
      context.putObjectToBeValidated(TABELA_REQUEST_NAME, tabelaRequest);
      context.putObjectToBeValidated(TABELA_NAME, tabelaRequest.getTabela());

      if (getLightingControlRequestValidationController().validate(context)
          && getTabelaValidationController().validate(context)) {

        if (getLightListValidationController().validate(context)) {
          internalResponse = getTabelaBCL().insertTabela(tabelaRequest);
          response.setTabela(internalResponse.getResultsList());
        }
      }

      handleOperationStatusAndMessages(response, internalResponse, context.getMessages(), true);
    } catch (Exception ex) {
      SensusInterfaceUtil.handleException(LOG, response, ex, DEFAULT_TABELA_BCF_EXCEPTION_MSG);
    }
    return response;
  }
コード例 #11
0
  /*
   * (non-Javadoc)
   * @see
   * com.sensus.mlc.ecomode.bcf.IEcoModeBCF#generateFileCSV(com.sensus.mlc.ecomode.model.request.InquiryEcoModeRequest
   * )
   */
  @Override
  public CSVResponse generateFileCSV(EcoModeCSVRequest ecoModeRequest) {
    CSVResponse response = new CSVResponse();
    CSVInternalResponse internalResponse = null;
    try {
      ValidationContext requestContext = new ValidationContext();
      ValidationContext context = new ValidationContext();
      context.putObjectToBeValidated(
          INQUIRY_ECOMODE_REQUEST_NAME, ecoModeRequest.getInquiryEcoModeRequest());
      context.getValidationArguments().put(getSlcActionName(), FETCH_LIGHT_CONSUMPTION);
      requestContext.putObjectToBeValidated(ECOMODE_CSV_REQUEST_NAME, ecoModeRequest);
      context.putObjectToBeValidated(
          INITIAL_DATE.getValue(), ecoModeRequest.getInquiryEcoModeRequest().getInitialDate());
      context.putObjectToBeValidated(
          END_DATE.getValue(), ecoModeRequest.getInquiryEcoModeRequest().getEndDate());

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

      if (getInquiryRequestValidationController().validate(context)
          && getLightSelectionRequestValidationController().validate(context)
          && getRangeDateValidationController().validate(context)) {
        internalResponse = getEcoModeBCL().generateFileCSV(ecoModeRequest);
      }

      handleOperationStatusAndMessages(response, internalResponse, context.getMessages(), false);
    } catch (Exception ex) {
      handleException(LOG, response, ex, SENSUS_MLC_ECOMODEBCLIMPL_DEFAULTEXCEPTION);
    }

    return response;
  }
コード例 #12
0
  /*
   * (non-Javadoc)
   * @see com.sensus.mlc.tabela.bcf.ITabelaBCF#fetchAllTabelas(com.sensus.mlc.tabela.model.request.InquiryTabelaRequest
   */
  @Override
  public InquiryTabelaResponse fetchAllTabela(InquiryTabelaRequest inquiryTabelaRequest) {
    InquiryTabelaResponse response = new InquiryTabelaResponse();
    InternalResultsResponse<Tabela> internalResponse = null;

    try {
      ValidationContext context = new ValidationContext();
      context.putObjectToBeValidated(INQUIRY_TABELA_REQUEST_NAME, inquiryTabelaRequest);

      if (getLightingControlRequestValidationController().validate(context)) {
        internalResponse = getTabelaBCL().fetchAllTabela(inquiryTabelaRequest);
      }

      handleOperationStatusAndMessages(response, internalResponse, context.getMessages(), true);
    } catch (Exception ex) {
      SensusInterfaceUtil.handleException(LOG, response, ex, DEFAULT_TABELA_BCF_EXCEPTION_MSG);
    }

    return response;
  }
コード例 #13
0
  /*
   * (non-Javadoc)
   * @see
   * com.sensus.mlc.ecomode.bcf.IEcoModeBCF#importEcoModeBaselineFromFileCSV(com.sensus.mlc.ecomode.model.request.
   * InquiryEcoModeRequest)
   */
  @Override
  public EcoModeResponse importEcoModeBaselineFromFileCSV(EcoModeRequest ecoModeRequest) {
    EcoModeResponse response = new EcoModeResponse();
    InternalResponse internalResponse = null;

    try {
      ValidationContext context = new ValidationContext();
      context.getValidationArguments().put(getSlcActionName(), IMPORT_CSV_FILE);
      context.putObjectToBeValidated(ECOMODE_REQUEST_NAME, ecoModeRequest);
      context.putObjectToBeValidated(CSV_FILE.getValue(), ecoModeRequest.getEcoModeCSVImport());

      if (getRequestValidationController().validate(context)
          && getCsvFileValidationController().validate(context)) {
        // Import eco mode baseline
        internalResponse = getEcoModeBCL().importEcoModeBaselineFromFileCSV(ecoModeRequest);
      }

      handleOperationStatusAndMessages(response, internalResponse, context.getMessages(), true);
    } catch (Exception ex) {
      handleException(LOG, response, ex, SENSUS_MLC_ECOMODEBCLIMPL_DEFAULTEXCEPTION);
    }
    return response;
  }
コード例 #14
0
  /*
   * (non-Javadoc)
   * @see
   * com.sensus.mlc.ecomode.bcf.IEcoModeBCF#upsertEcoMode(com.sensus.mlc.ecomode.model.request.InquiryEcoModeRequest)
   */
  @Override
  public EcoModeResponse upsertEcoMode(EcoModeRequest ecoModeRequest) {
    EcoModeResponse response = new EcoModeResponse();
    InternalResultsResponse<Light> internalResponse = null;

    try {
      ValidationContext context = new ValidationContext();
      context.getValidationArguments().put(getSlcActionName(), UPSERT_ECOMODE);
      context.putObjectToBeValidated(ECOMODE_REQUEST_NAME, ecoModeRequest);
      context.putObjectToBeValidated(LIGHT_LIST.getValue(), ecoModeRequest.getLights());

      if (getRequestValidationController().validate(context)
          && getLightListValidationController().validate(context)) {
        // upsert EcoMode
        internalResponse = getEcoModeBCL().upsertEcoMode(ecoModeRequest);
      }

      handleOperationStatusAndMessages(response, internalResponse, context.getMessages(), true);
    } catch (Exception ex) {
      handleException(LOG, response, ex, SENSUS_MLC_ECOMODEBCLIMPL_DEFAULTEXCEPTION);
    }
    return response;
  }