use of org.mifos.platform.validations.ValidationException 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.validations.ValidationException in project head by mifos.
the class QuestionnaireValidatorImpl method sectionsHaveInvalidOrders.
private boolean sectionsHaveInvalidOrders(List<SectionDto> sections, ValidationException parentException) {
boolean invalid = false;
if (!allSectionsHaveOrders(sections)) {
parentException.addChildException(new ValidationException(SECTION_ORDER_NOT_PROVIDED));
invalid = true;
} else if (!allSectionsHaveUniqueOrders(sections)) {
parentException.addChildException(new ValidationException(SECTION_ORDER_DUPLICATE));
invalid = true;
}
return invalid;
}
use of org.mifos.platform.validations.ValidationException in project head by mifos.
the class QuestionnaireValidatorImpl method sectionsHaveInvalidNames.
private boolean sectionsHaveInvalidNames(List<SectionDto> sections, ValidationException parentException) {
boolean invalid = false;
if (!allSectionsHaveNames(sections)) {
parentException.addChildException(new ValidationException(SECTION_TITLE_NOT_PROVIDED));
invalid = true;
} else if (!allSectionsHaveUniqueNames(sections)) {
parentException.addChildException(new ValidationException(SECTION_TITLE_DUPLICATE));
invalid = true;
}
return invalid;
}
use of org.mifos.platform.validations.ValidationException in project head by mifos.
the class QuestionnaireValidatorImpl method validateForDefineQuestionGroup.
@Override
public void validateForDefineQuestionGroup(QuestionGroupDto questionGroupDto, boolean withDuplicateQuestionTextCheck) {
ValidationException parentException = new ValidationException(GENERIC_VALIDATION);
validateQuestionGroupTitle(questionGroupDto, parentException);
List<EventSourceDto> eventSourceDtos = questionGroupDto.getEventSourceDtos();
if (eventSourceDtos == null || eventSourceDtos.size() == 0) {
throw new SystemException(INVALID_EVENT_SOURCE);
} else {
for (EventSourceDto eventSourceDto : eventSourceDtos) {
validateEventSource(eventSourceDto, parentException);
}
}
validateSections(questionGroupDto.getSections(), parentException, withDuplicateQuestionTextCheck);
if (parentException.hasChildExceptions()) {
throw parentException;
}
}
use of org.mifos.platform.validations.ValidationException in project head by mifos.
the class ValidationExceptionTest method generateValidationException.
private ValidationException generateValidationException() {
ValidationException validationException = new ValidationException(TOP_LEVEL_EXCEPTION);
validationMethod1(validationException);
validationMethod2(validationException);
validationMethod3(validationException);
return validationException;
}
Aggregations