Search in sources :

Example 1 with ParameterDefinitionEntry

use of org.pentaho.reporting.engine.classic.core.parameters.ParameterDefinitionEntry 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 2 with ParameterDefinitionEntry

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

Example 3 with ParameterDefinitionEntry

use of org.pentaho.reporting.engine.classic.core.parameters.ParameterDefinitionEntry in project pentaho-kettle by pentaho.

the class PentahoReportingOutputDialog method get.

private void get() {
    Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
    // See if we need to boot the reporting engine. Since this takes time we do it in the background...
    // 
    Runnable runnable = new Runnable() {

        @Override
        public void run() {
            PentahoReportingOutput.performPentahoReportingBoot(log, input.getClass());
        }
    };
    Thread thread = new Thread(runnable);
    thread.start();
    try {
        // Browse for a PRPT...
        // 
        FileDialog dialog = new FileDialog(shell, SWT.OPEN);
        dialog.setText(BaseMessages.getString(PKG, "PentahoReportingOutputDialog.ExtractParameters.FileDialog"));
        dialog.setFilterExtensions(new String[] { "*.prpt;*.PRPT", "*" });
        if (lastFilename != null) {
            dialog.setFileName(lastFilename);
        }
        dialog.setFilterNames(new String[] { BaseMessages.getString(PKG, "PentahoReportingOutputDialog.PentahoReportingFiles"), BaseMessages.getString(PKG, "System.FileType.AllFiles") });
        if (dialog.open() == null) {
            return;
        }
        thread.join();
        String sourceFilename = dialog.getFilterPath() + System.getProperty("file.separator") + dialog.getFileName();
        lastFilename = sourceFilename;
        shell.setCursor(busy);
        // Load the master report...
        // 
        MasterReport report = PentahoReportingOutput.loadMasterReport(sourceFilename);
        // Extract the definitions...
        // 
        ReportParameterDefinition definition = report.getParameterDefinition();
        RowMetaInterface r = new RowMeta();
        for (int i = 0; i < definition.getParameterCount(); i++) {
            ParameterDefinitionEntry entry = definition.getParameterDefinition(i);
            ValueMetaInterface valueMeta = new ValueMetaString(entry.getName());
            valueMeta.setComments(getParameterDefinitionEntryTypeDescription(entry));
            r.addValueMeta(valueMeta);
        }
        shell.setCursor(null);
        BaseStepDialog.getFieldsFromPrevious(r, wFields, 1, new int[] { 1 }, new int[] {}, -1, -1, new TableItemInsertListener() {

            @Override
            public boolean tableItemInserted(TableItem item, ValueMetaInterface valueMeta) {
                item.setText(2, valueMeta.getComments());
                return true;
            }
        });
    } catch (Exception e) {
        shell.setCursor(null);
        new ErrorDialog(shell, BaseMessages.getString(PKG, "PentahoReportingOutputDialog.ErrorReadingParameters.Title"), BaseMessages.getString(PKG, "PentahoReportingOutputDialog.ErrorReadingParameters.Message"), e);
    } finally {
        shell.setCursor(null);
        busy.dispose();
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) TableItemInsertListener(org.pentaho.di.ui.trans.step.TableItemInsertListener) RowMeta(org.pentaho.di.core.row.RowMeta) TableItem(org.eclipse.swt.widgets.TableItem) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Cursor(org.eclipse.swt.graphics.Cursor) KettleException(org.pentaho.di.core.exception.KettleException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) MasterReport(org.pentaho.reporting.engine.classic.core.MasterReport) ReportParameterDefinition(org.pentaho.reporting.engine.classic.core.parameters.ReportParameterDefinition) ParameterDefinitionEntry(org.pentaho.reporting.engine.classic.core.parameters.ParameterDefinitionEntry) FileDialog(org.eclipse.swt.widgets.FileDialog)

Aggregations

ParameterDefinitionEntry (org.pentaho.reporting.engine.classic.core.parameters.ParameterDefinitionEntry)3 ReportParameterDefinition (org.pentaho.reporting.engine.classic.core.parameters.ReportParameterDefinition)3 AbstractPentahoParameter (org.mifos.reports.pentaho.params.AbstractPentahoParameter)2 ArrayList (java.util.ArrayList)1 Cursor (org.eclipse.swt.graphics.Cursor)1 FileDialog (org.eclipse.swt.widgets.FileDialog)1 TableItem (org.eclipse.swt.widgets.TableItem)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 KettleException (org.pentaho.di.core.exception.KettleException)1 RowMeta (org.pentaho.di.core.row.RowMeta)1 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)1 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)1 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)1 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)1 TableItemInsertListener (org.pentaho.di.ui.trans.step.TableItemInsertListener)1 MasterReport (org.pentaho.reporting.engine.classic.core.MasterReport)1 ReportDataFactoryException (org.pentaho.reporting.engine.classic.core.ReportDataFactoryException)1 DefaultParameterContext (org.pentaho.reporting.engine.classic.core.parameters.DefaultParameterContext)1 ParameterContext (org.pentaho.reporting.engine.classic.core.parameters.ParameterContext)1 ReportParameterValues (org.pentaho.reporting.engine.classic.core.util.ReportParameterValues)1