/**
   * Process.
   *
   * @param indicator the indicator
   * @param persistType the persist type
   * @param request the request
   * @return the servico response
   */
  private InternalResultsResponse<Servico> processServico(
      ValidationContextIndicator indicator,
      PersistenceActionEnum persistType,
      ServicoMaintenanceRequest request) {
    InternalResultsResponse<Servico> response = null;

    // Persist
    InternalResponse internalResponse = doPersistenceServico(request.getServico(), persistType);
    if (internalResponse.isInError()) {
      response = new InternalResultsResponse<Servico>();
      response.setStatus(internalResponse.getError());
      response.addMessages(internalResponse.getMessageInfoList());
      response.addMessage(
          DEFAULT_SITE_BAC_EXCEPTION_MSG,
          MessageSeverity.Error,
          MessageLevel.Object,
          new Object[] {internalResponse.errorToString()});

      return response;
    }

    // Call maintainReurnList to see if we need to return the servico list and if so whether it
    // should be paged or
    // not
    response =
        maintainReturnListServico(
            request.getReturnList(), request.getReturnListPaged(), new Servico());

    return response;
  }
 /*
  * (non-Javadoc)
  * @see com.qat.samples.sysmgmt.bac.IOrdemServicoBAC#fetchAllOrdemServicos(OrdemServico ordemservico)
  */
 @Override
 public InternalResultsResponse<OrdemServico> fetchAllOrdemServicos(OrdemServico ordemservico) {
   InternalResultsResponse<OrdemServico> response = new InternalResultsResponse<OrdemServico>();
   response
       .getResultsList()
       .addAll(getSiteBAR().fetchAllOrdemServicos(ordemservico).getResultsList());
   return response;
 }
 @Test
 public void testfetchNFStatusById2() throws Exception {
   // check for valid and precount
   FetchByIdRequest request = new FetchByIdRequest();
   request.setFetchId(3);
   InternalResultsResponse<NFStatus> response = getNFStatusDAC().fetchNFStatusById(request);
   assertTrue(response.getResultsSetInfo().getPageSize() == 1);
   assertEquals(response.getStatus(), Status.OperationSuccess);
 }
 @Test
 public void testfetchNFStatusByRequest() throws Exception {
   // check for valid and precount
   PagedInquiryRequest request = new PagedInquiryRequest();
   request.setPreQueryCount(true);
   request.setStartPage(0);
   request.setPageSize(4);
   InternalResultsResponse<NFStatus> response = getNFStatusDAC().fetchNFStatusByRequest(request);
   assertTrue(response.getResultsSetInfo().getPageSize() == 4);
   assertTrue(response.getResultsSetInfo().getTotalRowsAvailable() > 0);
 }
  /*
   * (non-Javadoc)
   * @see
   * com.qat.samples.sysmgmt.bac.IServicoBAC#fetchServicoById(com.qat.samples.sysmgmt.model.request.FetchByIdRequest
   * )
   */
  @Override
  public InternalResultsResponse<Servico> fetchServicoById(FetchByIdRequest request) {
    InternalResultsResponse<Servico> response = new InternalResultsResponse<Servico>();
    // validate fetchId field
    if (ValidationUtil.isNull(request.getFetchId())) {
      response.addFieldErrorMessage(SYSMGMT_BASE_ID_REQUIRED);
      response.setStatus(SystemErrorCategory.SystemValidation);
    } else {
      response.getResultsList().add(getSiteBAR().fetchServicoById(request));
    }

    return response;
  }
    private InternalResultsResponse<Cidade> createFetchResponse() {
      if (EXCEPTION.equals(getReturnResult())) {
        throw new RuntimeException("Boom");
      }

      InternalResultsResponse<Cidade> response = new InternalResultsResponse<Cidade>();
      if (FETCH_FAILURE.equals(getReturnResult())) {
        response.addMessage(getFailureMessageCode(), MessageSeverity.Error, MessageLevel.Other);
        response.setStatus(Status.UnspecifiedError);
        return response;
      }

      response.addResult(new Cidade());
      return response;
    }
  @Test
  public void testupdateNFStatus() throws Exception {

    NFStatus funcionario = new NFStatus();
    funcionario = insertNFStatus(PersistanceActionEnum.INSERT);
    InternalResultsResponse<NFStatus> response = new InternalResultsResponse<NFStatus>();
    Integer a = getNFStatusDAC().insertNFStatus(funcionario, "", response);

    assertEquals(response.getStatus(), Status.OperationSuccess);
    funcionario = response.getFirstResult();
    funcionario.setModelAction(PersistanceActionEnum.UPDATE);
    funcionario.setId(response.getFirstResult().getId());
    response = new InternalResultsResponse<NFStatus>();

    a = getNFStatusDAC().updateNFStatus(funcionario, response);
    assertEquals(response.getStatus(), Status.OperationSuccess);
  }
 /*
  * (non-Javadoc)
  * @see
  * com.prosperitasglobal.sendsolv.dac.IExameDAC#deleteExame(com.prosperitasglobal.sendsolv.model
  * .Exame)
  */
 @Override
 public Integer deleteExame(Exame banco, InternalResultsResponse<?> response) {
   QATMyBatisDacHelper.doRemove(getSqlSession(), EMPRESA_STMT_DELETE, banco, response);
   if (response.isInError()) {
     return null;
   } else {
     return 1;
   }
 }
  @Override
  public Integer insertEventoPessoa(EventoPessoa evento) {
    Integer insertCount = 0;
    InternalResultsResponse<EventoPessoa> response = new InternalResultsResponse<EventoPessoa>();

    // First insert the root
    // Is successful the unique-id will be populated back into the object.
    insertCount =
        QATMyBatisDacHelper.doInsert(
            getSqlSession(), "EventoMap.insertEventoPessoa", evento, response);

    // Finally, if something was inserted then add the Beneficios to the result.
    if (insertCount > 0) {
      response.addResult(evento);
    }

    return insertCount;
  }
  @Override
  public Integer deleteExamePessoa(ExamePessoa banco, InternalResultsResponse<?> response) {

    QATMyBatisDacHelper.doRemove(getSqlSession(), "ExameMap.deleteExamePessoa", banco, response);
    if (response.isInError()) {
      return null;
    } else {
      return 1;
    }
  }
  /*
   * (non-Javadoc)
   * @see
   * com.prosperitasglobal.sendsolv.dac.IExameDAC#insertExame(com.prosperitasglobal.sendsolv.model
   * .Exame)
   */
  @Override
  public Integer insertExame(Exame banco, String string, InternalResultsResponse<?> response1) {
    Integer insertCount = 0;
    InternalResultsResponse<Exame> response = new InternalResultsResponse<Exame>();

    // First insert the root
    // Is successful the unique-id will be populated back into the object.
    insertCount =
        QATMyBatisDacHelper.doInsert(getSqlSession(), EMPRESA_STMT_INSERT, banco, response);

    if (response.isInError()) {
      return null;
    }

    // Finally, if something was inserted then add the Exame to the result.
    if (insertCount > 0) {
      response.addResult(banco);
    }
    response1 = response;
    return insertCount;
  }
  /*
   * (non-Javadoc)
   * @see
   * com.prosperitasglobal.sendsolv.dac.ITelaDAC#insertTela(com.prosperitasglobal.sendsolv.model
   * .Tela)
   */
  @Override
  public InternalResultsResponse<Tela> insertTela(Tela tela) {
    Integer insertCount = 0;
    InternalResultsResponse<Tela> response = new InternalResultsResponse<Tela>();

    // First insert the root
    // Is successful the unique-id will be populated back into the object.
    insertCount = QATMyBatisDacHelper.doInsert(getSqlSession(), TELA_STMT_INSERT, tela, response);

    if (response.isInError()) {
      return response;
    }
    // Next traverse the object graph and "maintain" the associations
    insertCount += maintainTelaAssociations(tela, response);

    // Finally, if something was inserted then add the Tela to the result.
    if (insertCount > 0) {
      response.addResult(tela);
    }

    return response;
  }
  /*
   * (non-Javadoc)
   * @see
   * com.prosperitasglobal.sendsolv.dac.ITelaDAC#updateTela(com.prosperitasglobal.sendsolv.model
   * .Tela)
   */
  @Override
  public InternalResultsResponse<Tela> updateTela(Tela tela) {
    Integer updateCount = 0;
    InternalResultsResponse<Tela> response = new InternalResultsResponse<Tela>();

    // First update the root if necessary.
    if (!ValidationUtil.isNull(tela.getModelAction())
        && (tela.getModelAction() == QATModel.PersistanceActionEnum.UPDATE)) {
      updateCount = QATMyBatisDacHelper.doUpdate(getSqlSession(), TELA_STMT_UPDATE, tela, response);
    }

    if (response.isInError()) {
      return response;
    }
    // Next traverse the object graph and "maintain" the associations
    updateCount += maintainTelaAssociations(tela, response);

    // Finally, if something was updated then add the Person to the result.
    if (updateCount > 0) {
      response.addResult(tela);
    }

    return response;
  }
  @Override
  public Integer updateEventoPessoa(EventoPessoa evento) {
    Integer updateCount = 0;
    InternalResultsResponse<EventoPessoa> response = new InternalResultsResponse<EventoPessoa>();

    // First update the root if necessary.
    if (!ValidationUtil.isNull(evento.getModelAction())
        && (evento.getModelAction() == QATModel.PersistanceActionEnum.UPDATE)) {
      updateCount =
          QATMyBatisDacHelper.doUpdate(
              getSqlSession(), "EventoMap.updateEventoPessoa", evento, response);
    }

    if (response.isInError()) {
      return null;
    }

    // Finally, if something was updated then add the Person to the result.
    if (updateCount > 0) {
      response.addResult(evento);
    }

    return updateCount;
  }
  @Override
  public Integer updateExamePessoa(ExamePessoa banco, InternalResultsResponse<?> response) {
    Integer updateCount = 0;
    response = new InternalResultsResponse<ExamePessoa>();

    // First update the root if necessary.
    if (!ValidationUtil.isNull(banco.getModelAction())
        && (banco.getModelAction() == QATModel.PersistanceActionEnum.UPDATE)) {
      updateCount =
          QATMyBatisDacHelper.doUpdate(
              getSqlSession(), "ExameMap.updateExamePessoa", banco, response);
    }

    if (response.isInError()) {
      return null;
    }

    return updateCount;
  }
  @Test
  public void testdeleteNFStatus() throws Exception {

    NFStatus funcionario = new NFStatus();
    funcionario = insertNFStatus(PersistanceActionEnum.INSERT);
    InternalResultsResponse<NFStatus> response = new InternalResultsResponse<NFStatus>();
    Integer a = getNFStatusDAC().insertNFStatus(funcionario, "", response);
    assertEquals(response.getStatus(), Status.OperationSuccess);
    funcionario = response.getFirstResult();
    response = new InternalResultsResponse<NFStatus>();
    funcionario.setModelAction(PersistanceActionEnum.DELETE);
    Integer b = getNFStatusDAC().deleteNFStatus(funcionario, response);
    assertEquals(response.getStatus(), Status.OperationSuccess);
    FetchByIdRequest request = new FetchByIdRequest();
    request.setFetchId(response.getFirstResult().getId());
    InternalResultsResponse<NFStatus> responseA = getNFStatusDAC().fetchNFStatusById(request);
    assertTrue(
        responseA.getResultsList().get(0).getStatusList().get(0).getStatus()
            == CdStatusTypeEnum.DELETADO);
  }
  /*
   * (non-Javadoc)
   * @see
   * com.prosperitasglobal.sendsolv.dac.IExameDAC#updateExame(com.prosperitasglobal.sendsolv.model
   * .Exame)
   */
  @Override
  public Integer updateExame(Exame banco, InternalResultsResponse<?> response) {
    Integer updateCount = 0;
    response = new InternalResultsResponse<Exame>();

    // First update the root if necessary.
    if (!ValidationUtil.isNull(banco.getModelAction())
        && (banco.getModelAction() == QATModel.PersistanceActionEnum.UPDATE)) {
      updateCount =
          QATMyBatisDacHelper.doUpdate(getSqlSession(), EMPRESA_STMT_UPDATE, banco, response);
    }

    if (response.isInError()) {
      return null;
    }

    // Finally, if something was updated then add the Person to the result.
    // if (updateCount > 0)
    // {
    // response.addResult(banco);
    // }

    return updateCount;
  }
  @Override
  public Integer insertExamePessoa(
      ExamePessoa banco, String string, InternalResultsResponse<?> response) {
    Integer insertCount = 0;
    response = new InternalResultsResponse<ExamePessoa>();

    // First insert the root
    // Is successful the unique-id will be populated back into the object.
    insertCount =
        QATMyBatisDacHelper.doInsert(
            getSqlSession(), "ExameMap.insertExame", banco.getExame(), response);

    // First insert the root
    // Is successful the unique-id will be populated back into the object.
    insertCount =
        QATMyBatisDacHelper.doInsert(
            getSqlSession(), "ExameMap.insertExamePessoa", banco, response);

    if (response.isInError()) {
      return null;
    }

    return insertCount;
  }
  @Test
  public void testinsertNFStatus() throws Exception {

    NFStatus funcionario = new NFStatus();
    funcionario = insertNFStatus(PersistanceActionEnum.INSERT);

    InternalResultsResponse<NFStatus> response = new InternalResultsResponse<NFStatus>();

    Integer a = getNFStatusDAC().insertNFStatus(funcionario, "INSERT", response);
    assertEquals(response.getStatus(), Status.OperationSuccess);

    funcionario = new NFStatus();
    funcionario = insertNFStatus(PersistanceActionEnum.INSERT);
    response = new InternalResultsResponse<NFStatus>();

    a = getNFStatusDAC().insertNFStatus(funcionario, "", response);
    assertEquals(response.getStatus(), Status.OperationSuccess);
    FetchByIdRequest request = new FetchByIdRequest();
    request.setFetchId(response.getFirstResult().getId());
    InternalResultsResponse<NFStatus> responseA = getNFStatusDAC().fetchNFStatusById(request);
    assertTrue(responseA.getResultsList().size() == 1);
    assertEquals(responseA.getStatus(), Status.OperationSuccess);
  }
 /*
  * (non-Javadoc)
  * @see com.qat.samples.sysmgmt.bac.IPlanoBAC#fetchAllPlanos(Plano plano)
  */
 @Override
 public InternalResultsResponse<Plano> fetchAllPlanos(Plano plano) {
   InternalResultsResponse<Plano> response = new InternalResultsResponse<Plano>();
   response.getResultsList().addAll(getSiteBAR().fetchAllPlanos(plano).getResultsList());
   return response;
 }
 /*
  * (non-Javadoc)
  * @see com.qat.samples.sysmgmt.base.bac.ICountyBAC#fetchAllCountys()
  */
 @Override
 public InternalResultsResponse<County> fetchAllCounties() {
   InternalResultsResponse<County> response = new InternalResultsResponse<County>();
   response.getResultsList().addAll(getCountyDAC().fetchAllCounties().getResultsList());
   return response;
 }
 /*
  * (non-Javadoc)
  * @see com.qat.samples.sysmgmt.bac.IContatoBAC#fetchAllContatos(Contato contato)
  */
 @Override
 public InternalResultsResponse<Contato> fetchAllContatos(Contato contato) {
   InternalResultsResponse<Contato> response = new InternalResultsResponse<Contato>();
   response.getResultsList().addAll(getSiteBAR().fetchAllContatos(contato).getResultsList());
   return response;
 }
 /*
  * (non-Javadoc)
  * @see com.qat.samples.sysmgmt.bac.ISiteBAC#fetchAllSites(Site site)
  */
 @Override
 public InternalResultsResponse<Site> fetchAllSites(Site site) {
   InternalResultsResponse<Site> response = new InternalResultsResponse<Site>();
   response.getResultsList().addAll(getSiteBAR().fetchAllSites(site).getResultsList());
   return response;
 }
 /*
  * (non-Javadoc)
  * @see
  * com.qat.samples.sysmgmt.base.bac.ICountyBAC#fetchCountyById(com.qat.samples.sysmgmt.base.model.County
  * )
  */
 @Override
 public InternalResultsResponse<County> fetchCountyById(FetchByIdRequest request) {
   InternalResultsResponse<County> response = new InternalResultsResponse<County>();
   response.getResultsList().add(getCountyDAC().fetchCountyById(request).getFirstResult());
   return response;
 }
 private InternalResultsResponse<CallingCardInfo> returnInsert(CallingCardInfo callingCardInfo) {
   InternalResultsResponse<CallingCardInfo> response =
       new InternalResultsResponse<CallingCardInfo>();
   response.addResult(callingCardInfo);
   return response;
 }
 /*
  * (non-Javadoc)
  * @see com.qat.samples.sysmgmt.base.bac.IListaComprasBAC#fetchAllListaComprass()
  */
 @Override
 public InternalResultsResponse<ListaCompras> fetchAllListaComprass() {
   InternalResultsResponse<ListaCompras> response = new InternalResultsResponse<ListaCompras>();
   response.getResultsList().addAll(getListaComprasDAC().fetchAllListaComprass());
   return response;
 }
 /*
  * (non-Javadoc)
  * @see
  * com.qat.samples.sysmgmt.base.bac.IListaComprasBAC#fetchListaComprasById(com.qat.samples.sysmgmt.base.model.
  * ListaCompras
  * )
  */
 @Override
 public InternalResultsResponse<ListaCompras> fetchListaComprasById(FetchByIdRequest request) {
   InternalResultsResponse<ListaCompras> response = new InternalResultsResponse<ListaCompras>();
   response.getResultsList().add(getListaComprasDAC().fetchListaComprasById(request));
   return response;
 }