Search in sources :

Example 1 with ReportParameterDefinition

use of org.pentaho.reporting.engine.classic.core.parameters.ReportParameterDefinition 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)

Example 2 with ReportParameterDefinition

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

the class PentahoParamParser method parseReportParams.

public List<AbstractPentahoParameter> parseReportParams(MasterReport report, HttpServletRequest request, Map<String, AbstractPentahoParameter> selectedValues, boolean update) {
    ParameterContext paramContext = null;
    try {
        paramContext = new DefaultParameterContext(report);
        ReportParameterDefinition paramDefinition = report.getParameterDefinition();
        List<AbstractPentahoParameter> result = new ArrayList<AbstractPentahoParameter>();
        for (ParameterDefinitionEntry paramDefEntry : paramDefinition.getParameterDefinitions()) {
            result.add(parseParam(paramDefEntry, paramContext, selectedValues, update));
        }
        return result;
    } catch (ReportDataFactoryException ex) {
        throw new JNDIException("Problem with Pentaho Reports", request);
    } catch (Exception ex) {
        throw new MifosRuntimeException(ex);
    } finally {
        if (paramContext != null) {
            try {
                paramContext.close();
            } catch (ReportDataFactoryException ex) {
                logger.error("Exception while closing parameter context", ex);
            }
        }
    }
}
Also used : ReportParameterDefinition(org.pentaho.reporting.engine.classic.core.parameters.ReportParameterDefinition) AbstractPentahoParameter(org.mifos.reports.pentaho.params.AbstractPentahoParameter) DefaultParameterContext(org.pentaho.reporting.engine.classic.core.parameters.DefaultParameterContext) ParameterDefinitionEntry(org.pentaho.reporting.engine.classic.core.parameters.ParameterDefinitionEntry) ArrayList(java.util.ArrayList) ReportDataFactoryException(org.pentaho.reporting.engine.classic.core.ReportDataFactoryException) DefaultParameterContext(org.pentaho.reporting.engine.classic.core.parameters.DefaultParameterContext) ParameterContext(org.pentaho.reporting.engine.classic.core.parameters.ParameterContext) ReportDataFactoryException(org.pentaho.reporting.engine.classic.core.ReportDataFactoryException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 3 with ReportParameterDefinition

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

the class PentahoReportsServiceImpl method addParametersToReport.

private void addParametersToReport(MasterReport report, Map<String, AbstractPentahoParameter> params) throws ReflectionException, IOException {
    ReportParameterValues rptParamValues = report.getParameterValues();
    ReportParameterDefinition paramsDefinition = report.getParameterDefinition();
    params.put("mifosLogoPath", getLogoParameterForReport());
    for (ParameterDefinitionEntry paramDefEntry : paramsDefinition.getParameterDefinitions()) {
        String paramName = paramDefEntry.getName();
        AbstractPentahoParameter parameter = params.get(paramName);
        if (parameter != null) {
            Object val = this.paramParser.parseParamValue(parameter, paramDefEntry);
            if (val != null && (!val.getClass().isArray() || Array.getLength(val) > 0)) {
                rptParamValues.put(paramName, val);
            }
        }
    }
}
Also used : ReportParameterDefinition(org.pentaho.reporting.engine.classic.core.parameters.ReportParameterDefinition) AbstractPentahoParameter(org.mifos.reports.pentaho.params.AbstractPentahoParameter) ParameterDefinitionEntry(org.pentaho.reporting.engine.classic.core.parameters.ParameterDefinitionEntry) ReportParameterValues(org.pentaho.reporting.engine.classic.core.util.ReportParameterValues)

Aggregations

ReportParameterDefinition (org.pentaho.reporting.engine.classic.core.parameters.ReportParameterDefinition)3 AbstractPentahoParameter (org.mifos.reports.pentaho.params.AbstractPentahoParameter)2 DefaultParameterContext (org.pentaho.reporting.engine.classic.core.parameters.DefaultParameterContext)2 ParameterContext (org.pentaho.reporting.engine.classic.core.parameters.ParameterContext)2 ParameterDefinitionEntry (org.pentaho.reporting.engine.classic.core.parameters.ParameterDefinitionEntry)2 ArrayList (java.util.ArrayList)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 PentahoValidationError (org.mifos.reports.pentaho.PentahoValidationError)1 ReportDataFactoryException (org.pentaho.reporting.engine.classic.core.ReportDataFactoryException)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 ReportParameterValues (org.pentaho.reporting.engine.classic.core.util.ReportParameterValues)1