Search in sources :

Example 1 with ValidationResult

use of org.pentaho.reporting.engine.classic.core.parameters.ValidationResult in project head by mifos.

the class PentahoReportsServiceImpl method validate.

private void validate(MasterReport report, List<PentahoValidationError> errors) throws ReportProcessingException {
    ReportParameterDefinition paramDefinition = report.getParameterDefinition();
    ReportParameterValidator validator = paramDefinition.getValidator();
    ParameterContext paramContext = new DefaultParameterContext(report);
    ValidationResult validationResult = validator.validate(null, paramDefinition, paramContext);
    for (ValidationMessage msg : validationResult.getErrors()) {
        PentahoValidationError error = new PentahoValidationError(msg.getMessage());
        errors.add(error);
    }
    String[] properties = validationResult.getProperties();
    for (String prop : properties) {
        for (ValidationMessage msg : validationResult.getErrors(prop)) {
            PentahoValidationError error = new PentahoValidationError(prop, msg.getMessage());
            errors.add(error);
        }
    }
}
Also used : ReportParameterDefinition(org.pentaho.reporting.engine.classic.core.parameters.ReportParameterDefinition) ValidationMessage(org.pentaho.reporting.engine.classic.core.parameters.ValidationMessage) DefaultParameterContext(org.pentaho.reporting.engine.classic.core.parameters.DefaultParameterContext) ParameterContext(org.pentaho.reporting.engine.classic.core.parameters.ParameterContext) DefaultParameterContext(org.pentaho.reporting.engine.classic.core.parameters.DefaultParameterContext) ReportParameterValidator(org.pentaho.reporting.engine.classic.core.parameters.ReportParameterValidator) ValidationResult(org.pentaho.reporting.engine.classic.core.parameters.ValidationResult) PentahoValidationError(org.mifos.reports.pentaho.PentahoValidationError)

Aggregations

PentahoValidationError (org.mifos.reports.pentaho.PentahoValidationError)1 DefaultParameterContext (org.pentaho.reporting.engine.classic.core.parameters.DefaultParameterContext)1 ParameterContext (org.pentaho.reporting.engine.classic.core.parameters.ParameterContext)1 ReportParameterDefinition (org.pentaho.reporting.engine.classic.core.parameters.ReportParameterDefinition)1 ReportParameterValidator (org.pentaho.reporting.engine.classic.core.parameters.ReportParameterValidator)1 ValidationMessage (org.pentaho.reporting.engine.classic.core.parameters.ValidationMessage)1 ValidationResult (org.pentaho.reporting.engine.classic.core.parameters.ValidationResult)1