Search in sources :

Example 1 with QuestionnaireServiceFacade

use of org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade in project head by mifos.

the class QuestionnaireFlowAdapter method validateResponses.

public ActionErrors validateResponses(HttpServletRequest request, QuestionResponseCapturer form) {
    List<QuestionGroupDetail> groups = form.getQuestionGroups();
    QuestionnaireServiceFacade questionnaireServiceFacade = serviceLocator.getService(request);
    if ((groups == null) || (questionnaireServiceFacade == null)) {
        return null;
    }
    ActionErrors errors = new ActionErrors();
    try {
        questionnaireServiceFacade.validateResponses(groups);
    } catch (ValidationException e) {
        if (e.hasChildExceptions()) {
            for (ValidationException ve : e.getChildExceptions()) {
                if (ve instanceof MandatoryAnswerNotFoundException) {
                    errors.add(ClientConstants.ERROR_REQUIRED, new ActionMessage(ClientConstants.ERROR_REQUIRED, ve.getIdentifier()));
                } else if (ve instanceof BadNumericResponseException) {
                    populateNumericError((BadNumericResponseException) ve, errors);
                }
            }
        }
    }
    setQuestionnaireAttributesToRequest(request, form);
    return errors;
}
Also used : BadNumericResponseException(org.mifos.platform.questionnaire.exceptions.BadNumericResponseException) QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) ValidationException(org.mifos.platform.validations.ValidationException) MandatoryAnswerNotFoundException(org.mifos.platform.questionnaire.exceptions.MandatoryAnswerNotFoundException) ActionMessage(org.apache.struts.action.ActionMessage) QuestionnaireServiceFacade(org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade) ActionErrors(org.apache.struts.action.ActionErrors)

Example 2 with QuestionnaireServiceFacade

use of org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade in project head by mifos.

the class QuestionnaireFlowAdapter method getQuestionGroups.

private List<QuestionGroupDetail> getQuestionGroups(HttpServletRequest request) {
    QuestionnaireServiceFacade questionnaireServiceFacade = serviceLocator.getService(request);
    Criteria<QuestionGroupDetail> criteria = new Criteria<QuestionGroupDetail>() {

        @Override
        public QuestionGroupDetail filter(Integer questionGroupId, List<QuestionGroupDetail> questionGroupDetails) {
            QuestionGroupDetail result = null;
            for (QuestionGroupDetail questionGroupDetail : questionGroupDetails) {
                if (questionGroupId.equals(questionGroupDetail.getId())) {
                    result = questionGroupDetail;
                    break;
                }
            }
            return result;
        }
    };
    return questionnaireServiceFacade != null ? questionGroupFilter.doFilter(questionnaireServiceFacade.getQuestionGroups(event, source), criteria) : null;
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) ArrayList(java.util.ArrayList) List(java.util.List) Criteria(org.mifos.accounts.loan.struts.action.Criteria) QuestionnaireServiceFacade(org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade)

Example 3 with QuestionnaireServiceFacade

use of org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade in project head by mifos.

the class PictureFormFile method get.

@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    String clientSystemId = ((ClientCustActionForm) form).getGlobalCustNum();
    ClientInformationDto clientInformationDto;
    try {
        clientInformationDto = clientServiceFacade.getClientInformationDto(clientSystemId);
    } catch (MifosRuntimeException e) {
        if (e.getCause() instanceof ApplicationException) {
            throw (ApplicationException) e.getCause();
        }
        throw e;
    }
    // John W - for breadcrumb or another other action downstream that exists business_key set (until refactored)
    ClientBO clientBO = (ClientBO) this.customerDao.findCustomerById(clientInformationDto.getClientDisplay().getCustomerId());
    SessionUtils.removeThenSetAttribute(Constants.BUSINESS_KEY, clientBO, request);
    SessionUtils.setAttribute(ClientConstants.IS_PHOTO_FIELD_HIDDEN, FieldConfig.getInstance().isFieldHidden("Client.Photo"), request);
    setCurrentPageUrl(request, clientBO);
    setQuestionGroupInstances(request, clientBO);
    InformationOrderServiceFacade informationOrderServiceFacade = ApplicationContextProvider.getBean(InformationOrderServiceFacade.class);
    SessionUtils.removeThenSetAttribute("clientInformationDto", clientInformationDto, request);
    request.getSession().setAttribute("guarantyClientInformation", loanAccountServiceFacade.retrieveGuarantyClientInformation(clientInformationDto));
    QuestionnaireServiceFacade questionnaireServiceFacade = questionnaireServiceFacadeLocator.getService(request);
    List<QuestionGroupInstanceDetail> questions = new ArrayList<QuestionGroupInstanceDetail>();
    questions.addAll(questionnaireServiceFacade.getQuestionGroupInstancesWithUnansweredQuestionGroups(clientInformationDto.getClientDisplay().getCustomerId(), "Create", "Client"));
    questions.addAll(questionnaireServiceFacade.getQuestionGroupInstancesWithUnansweredQuestionGroups(clientInformationDto.getClientDisplay().getCustomerId(), "View", "Client"));
    questions.addAll(questionnaireServiceFacade.getQuestionGroupInstancesWithUnansweredQuestionGroups(clientInformationDto.getClientDisplay().getCustomerId(), "Close", "Client"));
    SessionUtils.setCollectionAttribute("questionGroups", questions, request);
    SessionUtils.setCollectionAttribute("personalInformationOrder", informationOrderServiceFacade.getInformationOrder("Client"), request);
    return mapping.findForward(ActionForwards.get_success.toString());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) InformationOrderServiceFacade(org.mifos.platform.questionnaire.service.InformationOrderServiceFacade) ApplicationException(org.mifos.framework.exceptions.ApplicationException) ClientBO(org.mifos.customers.client.business.ClientBO) ArrayList(java.util.ArrayList) ClientInformationDto(org.mifos.dto.screen.ClientInformationDto) QuestionnaireServiceFacade(org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade) MifosRuntimeException(org.mifos.core.MifosRuntimeException) QuestionGroupInstanceDetail(org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 4 with QuestionnaireServiceFacade

use of org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade in project head by mifos.

the class PictureFormFile method setQuestionGroupInstances.

private void setQuestionGroupInstances(HttpServletRequest request, ClientBO clientBO) throws PageExpiredException {
    QuestionnaireServiceFacade questionnaireServiceFacade = questionnaireServiceFacadeLocator.getService(request);
    boolean containsQGForCloseClient = false;
    if (questionnaireServiceFacade != null) {
        setQuestionGroupInstances(questionnaireServiceFacade, request, clientBO.getCustomerId());
        if (clientBO.getCustomerStatus().getId().equals(CustomerStatus.CLIENT_CLOSED.getValue())) {
            containsQGForCloseClient = questionnaireServiceFacade.getQuestionGroupInstances(clientBO.getCustomerId(), "Close", "Client").size() > 0;
        }
    }
    SessionUtils.removeThenSetAttribute("containsQGForCloseClient", containsQGForCloseClient, request);
}
Also used : QuestionnaireServiceFacade(org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade)

Example 5 with QuestionnaireServiceFacade

use of org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade in project head by mifos.

the class PPITestDataGenerator method loadTestDataFiles.

public void loadTestDataFiles(String[] args) throws IOException, TaskSystemException, PersistenceException, ConfigurationException, FinancialException {
    parseOptions(args);
    ApplicationContext applicationContext = initializeSpring();
    customerDao = applicationContext.getBean(CustomerDaoHibernate.class);
    questionnaireServiceFacade = applicationContext.getBean(QuestionnaireServiceFacade.class);
    if (testDataDirectoryName != null) {
        File directory = new File(testDataDirectoryName);
        File[] listOfFiles = directory.listFiles();
        if (listOfFiles != null) {
            int totalFilesToLoad = countFilesToUpgrade(listOfFiles);
            int filesLoaded = 0;
            for (File listOfFile : listOfFiles) {
                String currentFilename = listOfFile.getName();
                if (listOfFile.isFile() && currentFilename.endsWith("Testing.properties")) {
                    String dataFileName = testDataDirectoryName + File.separator + currentFilename;
                    loadData(dataFileName, applicationContext);
                    filesLoaded++;
                    System.out.println("Finished " + filesLoaded + "/" + totalFilesToLoad);
                }
            }
        } else {
            fail("No files found in directory: " + testDataDirectoryName);
        }
    } else {
        loadData(dataSetName, applicationContext);
    }
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) QuestionnaireServiceFacade(org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade) File(java.io.File) CustomerDaoHibernate(org.mifos.customers.persistence.CustomerDaoHibernate)

Aggregations

QuestionnaireServiceFacade (org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade)13 ArrayList (java.util.ArrayList)5 QuestionGroupInstanceDetail (org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail)4 MifosRuntimeException (org.mifos.core.MifosRuntimeException)3 ApplicationException (org.mifos.framework.exceptions.ApplicationException)3 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)3 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)3 UserContext (org.mifos.security.util.UserContext)3 HashSet (java.util.HashSet)2 List (java.util.List)2 Before (org.junit.Before)2 LoanBO (org.mifos.accounts.loan.business.LoanBO)2 Criteria (org.mifos.accounts.loan.struts.action.Criteria)2 LoanAccountActionForm (org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm)2 RepaymentScheduleInstallment (org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment)2 MessageLookup (org.mifos.application.master.MessageLookup)2 CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)2 LoanAccountDetailsDto (org.mifos.dto.domain.LoanAccountDetailsDto)2 LoanActivityDto (org.mifos.dto.domain.LoanActivityDto)2 ValueListElement (org.mifos.dto.domain.ValueListElement)2