/** * 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; }
/** * Validate parent status. * * @param list the list * @param empresa the empresa */ private void validateParentStatus(List<MessageInfo> list, Empresa empresa) { InternalResponse applyStatusResponse = new InternalResponse(); FetchByIdRequest request = new FetchByIdRequest(); // request.setId(empresa.getParentOrganizationId()); // InternalResultsResponse<Organization> response = // getOrganizationDAC().fetchOrganizationById(request); // if (response.isInError()) // { // applyStatusResponse.merge(response); // } // if (StatusEnum.SETUP.equals(response.getFirstResult().getStatus())) // { // list.add( // new MessageInfo(CBOF_BASE_APPLYSTATUS_STATUS_DENIED, // Message.MessageSeverity.Error, // Message.MessageLevel.Field, // new Object[] {String.valueOf(BusinessTypeEnum.LOCATION).toLowerCase(), // empresa.getStatus()})); // } if (!ValidationUtil.isNull(applyStatusResponse)) { list.addAll(applyStatusResponse.getMessageInfoList()); } }
/** * Common method for handling the processing of a persistence type operation. Including * validation, the actual persistence operation and the optional retrieval of data. * * @param indicator the indicator * @param persistType the persist type * @param request the request * @param getList the get list * @return the county response */ protected Response process( ValidationContextIndicator indicator, PersistanceActionEnum persistType, Request request, Response response) { InternalResponse internalResponse = null; Object objectToBeValidated = getObjectToBeValidated(request); // Validate ValidationContext context = new ValidationContext( objectToBeValidated.getClass().getSimpleName(), objectToBeValidated, indicator); if (!getValidationController().validate(context)) { return handleReturn(response, internalResponse, context.getMessages(), true); } // Persist internalResponse = doPersistance(request, persistType); if (internalResponse.getStatus() != Status.OperationSuccess) { return handleReturn(response, internalResponse, context.getMessages(), true); } // Call maintainReturnList to see if we need to return the object list and if so whether it // should be paged or // not maintainReturnList(request, response); // Handle the processing for all previous methods regardless of them failing or succeeding. return handleReturn(response, internalResponse, context.getMessages(), false); }
@Override public Integer deleteEventoPessoa(EventoPessoa evento) { InternalResponse response = new InternalResponse(); QATMyBatisDacHelper.doRemove( getSqlSession(), "EventoMap.deleteEventoPessoaById", evento, response); if (response.isInError()) { return null; } else { return 1; } }
private InternalResponse createInternalResponse(Cidade cidade) { if (EXCEPTION.equals(getReturnResult())) { throw new RuntimeException("Boom"); } InternalResponse response = new InternalResponse(); if (FAILURE.equals(getReturnResult())) { response.addMessage(getFailureMessageCode(), MessageSeverity.Error, MessageLevel.Other); response.setStatus(Status.UnspecifiedError); } return response; }
/* * (non-Javadoc) * @see * com.qat.samples.sysmgmt.base.bac.ICountyBAC#deleteCounty(com.qat.samples.sysmgmt.base.model.County) */ @Override public InternalResponse deleteCounty(County county) { InternalResponse internalResponse = getCountyDAC().deleteCountyById(county); // Check for error because in business case all non-success returns are failures (removal of // zero rows) according to the business if (internalResponse.getStatus() != Status.OperationSuccess) { internalResponse.addMessage( DEFAULT_COUNTY_BAC_EXCEPTION_MSG, Message.MessageSeverity.Error, Message.MessageLevel.Object, new Object[] {internalResponse.getStatus().toString()}); } return internalResponse; }
/* * (non-Javadoc) * @see * com.qat.samples.sysmgmt.base.bac.IListaComprasBAC#deleteListaCompras(com.qat.samples.sysmgmt.base.model. * ListaCompras) */ @Override public InternalResponse deleteListaCompras(ListaCompras cidade) { InternalResponse internalResponse = getListaComprasDAC().deleteListaCompras(cidade); // Check for error because in business case all non-success returns are failures (removal of // zero rows) // according to the business if (internalResponse.getStatus() != Status.OperationSuccess) { internalResponse.addMessage( DEFAULT_PROCEDURE_BAC_EXCEPTION_MSG, Message.MessageSeverity.Error, Message.MessageLevel.Object, new Object[] {internalResponse.getStatus().toString()}); } return internalResponse; }
/* * (non-Javadoc) * @see * com.qat.samples.sysmgmt.base.bac.IListaComprasBAC#updateListaCompras(com.qat.samples.sysmgmt.base.model. * ListaCompras) */ @Override public InternalResponse updateListaCompras(ListaCompras cidade) { // cidade.setPrice(ListaComprasBAD.calculatePrice(UPDATE_SEED)); InternalResponse internalResponse = getListaComprasDAC().updateListaCompras(cidade); // Check for error because in business case all non-success returns are failures (updating of // zero rows or // optimistic locking error) according to the business if (internalResponse.getStatus() != Status.OperationSuccess) { internalResponse.addMessage( DEFAULT_PROCEDURE_BAC_EXCEPTION_MSG, Message.MessageSeverity.Error, Message.MessageLevel.Object, new Object[] {internalResponse.getStatus().toString()}); } return internalResponse; }