Example usage for org.springframework.validation BindException getCause

List of usage examples for org.springframework.validation BindException getCause

Introduction

In this page you can find the example usage for org.springframework.validation BindException getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:org.openmrs.module.kenyaemr.fragment.controller.developer.DeveloperUtilsFragmentController.java

/**
 * Validate patient records//from w  w w . ja v a  2  s .  c  o m
 */
@AppAction(EmrConstants.APP_DEVELOPER)
public List<SimpleObject> validatePatients(UiUtils ui) {
    List<SimpleObject> problems = new ArrayList<SimpleObject>();

    for (Patient patient : Context.getPatientService().getAllPatients()) {
        BindException errors = new BindException(patient, "");
        Context.getAdministrationService().validate(patient, errors);

        if (errors.hasErrors()) {
            SimpleObject problem = new SimpleObject();
            problem.put("patient", ui.simplifyObject(patient));
            problem.put("errors", uniqueErrorMessages(errors));
            problem.put("cause", errors.getCause());
            problems.add(problem);
        }
    }

    return problems;
}