コード例 #1
0
  /**
   * Fetch objects by request.
   *
   * @param sqlSession the sql session
   * @param request the request
   * @param countStatement the count statement
   * @param fetchPagedStatement the fetch paged statement
   * @param response the response
   */
  @SuppressWarnings("unchecked")
  public static Integer maintainCnaeAssociations(
      List<Cnae> cnaeList,
      InternalResultsResponse<?> response,
      Integer parentId,
      TypeEnum type,
      AcaoEnum acaoType,
      TabelaEnum tabelaEnum,
      ICnaeDAC cnaeDAC,
      IStatusDAC statusDAC,
      IHistoricoDAC historicoDAC,
      Integer empId,
      String UserId,
      Integer processId) {
    Integer count = 0;
    // First Maintain Empresa
    if (ValidationUtil.isNullOrEmpty(cnaeList)) {
      return count;
    }
    // For Each Contact...
    for (Cnae cnae : cnaeList) {
      // Make sure we set the parent key
      cnae.setParentId(parentId);

      if (ValidationUtil.isNull(cnae.getModelAction())) {
        continue;
      }
      switch (cnae.getModelAction()) {
        case INSERT:
          // count = cnaeDAC.insertCnae(cnae,
          // "insertCnae", response);
          if (count > 0) {
            Status status = new Status();
            status.setStatus(CdStatusTypeEnum.ATIVO);
            List<Status> statusList = new ArrayList<Status>();
            count =
                StatusDACD.maintainStatusAssociations(
                    statusList,
                    response,
                    count,
                    null,
                    AcaoEnum.INSERT,
                    UserId,
                    empId,
                    TabelaEnum.CNAE,
                    statusDAC,
                    historicoDAC,
                    processId,
                    null);
          }
          break;
        case UPDATE:
          // count = cnaeDAC.updateCnae(cnae, response);
          if (count > 0) {
            count =
                StatusDACD.maintainStatusAssociations(
                    cnae.getStatusList(),
                    response,
                    cnae.getId(),
                    null,
                    AcaoEnum.UPDATE,
                    UserId,
                    empId,
                    TabelaEnum.CNAE,
                    statusDAC,
                    historicoDAC,
                    processId,
                    null);
          }
          break;
        case DELETE:
          Status status = new Status();
          status.setStatus(CdStatusTypeEnum.DELETADO);
          List<Status> statusList = new ArrayList<Status>();
          count =
              StatusDACD.maintainStatusAssociations(
                  statusList,
                  response,
                  cnae.getId(),
                  null,
                  AcaoEnum.DELETE,
                  UserId,
                  empId,
                  TabelaEnum.CNAE,
                  statusDAC,
                  historicoDAC,
                  processId,
                  null);

          break;
      }
    }

    return count;
  }
コード例 #2
0
  /**
   * Fetch objects by request.
   *
   * @param sqlSession the sql session
   * @param request the request
   * @param countStatement the count statement
   * @param fetchPagedStatement the fetch paged statement
   * @param response the response
   */
  @SuppressWarnings("unchecked")
  public static Integer maintainConecimentoTransporteAssociations(
      ConhecimentoTransporte conhecimentoTransporte,
      InternalResultsResponse<?> response,
      Integer parentId,
      TypeEnum type,
      AcaoEnum acaoType,
      TabelaEnum tabelaEnum,
      IConhecimentoTransporteDAC conecimentoTransporteDAC,
      IStatusDAC statusDAC,
      IHistoricoDAC historicoDAC,
      Integer empId,
      String UserId,
      Integer processId,
      Integer historicoId) {
    Integer count = 0;
    // First Maintain Empresa
    if (ValidationUtil.isNull(conhecimentoTransporte)) {
      return count;
    } else {
      // Make sure we set the parent key
      conhecimentoTransporte.setParentId(parentId);
      conhecimentoTransporte.setProcessId(processId);
      conhecimentoTransporte.setIdNota(parentId);

      switch (conhecimentoTransporte.getModelAction()) {
        case INSERT:
          count =
              conecimentoTransporteDAC.insertConhecimentoTransporte(
                  conhecimentoTransporte, "insertConhecimentoTransporte", response);
          if (count > 0) {
            Status status = new Status();
            status.setStatus(CdStatusTypeEnum.ATIVO);
            List<Status> statusList = new ArrayList<Status>();
            count =
                StatusDACD.maintainStatusAssociations(
                    statusList,
                    response,
                    count,
                    null,
                    AcaoEnum.INSERT,
                    UserId,
                    empId,
                    TabelaEnum.PROFISSAO,
                    statusDAC,
                    historicoDAC,
                    processId,
                    historicoId);
          }
          break;
        case UPDATE:
          count =
              conecimentoTransporteDAC.updateConhecimentoTransporte(
                  conhecimentoTransporte, response);
          if (count > 0) {
            count =
                StatusDACD.maintainStatusAssociations(
                    conhecimentoTransporte.getStatusList(),
                    response,
                    conhecimentoTransporte.getId(),
                    null,
                    AcaoEnum.UPDATE,
                    UserId,
                    empId,
                    TabelaEnum.PROFISSAO,
                    statusDAC,
                    historicoDAC,
                    processId,
                    historicoId);
          }
          break;
        case DELETE:
          Status status = new Status();
          status.setStatus(CdStatusTypeEnum.DELETADO);
          List<Status> statusList = new ArrayList<Status>();
          count =
              StatusDACD.maintainStatusAssociations(
                  statusList,
                  response,
                  conhecimentoTransporte.getId(),
                  null,
                  AcaoEnum.DELETE,
                  UserId,
                  empId,
                  TabelaEnum.PROFISSAO,
                  statusDAC,
                  historicoDAC,
                  processId,
                  historicoId);

          break;
      }
    }

    return count;
  }