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;
}
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;
}
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());
}
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);
}
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);
}
}
Aggregations