/**
  * Validate additional fields.
  *
  * @param list the list
  * @param empresa Runs all validation methods for the Empresa.
  */
 private void validateAdditionalFields(List<MessageInfo> list, Empresa empresa) {
   // validateParentOrganizationId(list, empresa);
   if (ValidationUtil.isNullOrEmpty(list)) {
     return;
   }
   validateParentStatus(list, empresa);
 }
  /**
   * 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;
  }