Java Code Examples for org.pentaho.reporting.engine.classic.core.MasterReport#setParameterDefinition()
The following examples show how to use
org.pentaho.reporting.engine.classic.core.MasterReport#setParameterDefinition() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Prd5169IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testSameParametersName() throws Exception { final TypedTableModel model = createTestData(); final MasterReport report = new MasterReport(); report.setQuery( "default" ); report.setDataFactory( new TableDataFactory( "default", model ) ); DefaultParameterDefinition mdef = new DefaultParameterDefinition(); mdef.addParameterDefinition( new PlainParameter( "Rows", String.class ) ); report.setParameterDefinition( mdef ); report.getParameterValues().put( "Rows", "ALL" ); final RelationalGroup group = new RelationalGroup(); group.addField( "Rows" ); report.setRootGroup( group ); report.addExpression( new ValidateExpression() ); DebugReportRunner.execGraphics2D( report ); }
Example 2
Source File: Prd4579IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testParameterLoadSave() throws Exception { DefaultListParameter param = new DefaultListParameter( "dummy-query", "", "", "parameter", false, false, String.class ); DefaultParameterDefinition pdef = new DefaultParameterDefinition(); pdef.addParameterDefinition( param ); MasterReport report = new MasterReport(); report.setParameterDefinition( pdef ); MasterReport result = ReportWritingUtil.saveAndLoad( report ); ReportParameterDefinition parameterDefinition = result.getParameterDefinition(); assertEquals( 1, parameterDefinition.getParameterCount() ); ParameterDefinitionEntry resultParam = parameterDefinition.getParameterDefinition( 0 ); assertTrue( resultParam instanceof DefaultListParameter ); DefaultListParameter lp = (DefaultListParameter) resultParam; assertEquals( "", lp.getKeyColumn() ); assertEquals( "", lp.getTextColumn() ); assertEquals( "dummy-query", lp.getQueryName() ); }
Example 3
Source File: DefaultReportParameterValidatorTest.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testSelectDefault() throws ReportProcessingException { final DefaultTableModel tableModel = new DefaultTableModel( new String[] { "key", "value" }, 1 ); tableModel.setValueAt( "key-entry", 0, 0 ); tableModel.setValueAt( "value-entry", 0, 1 ); final DefaultListParameter listParameter = new DefaultListParameter( "test", "key", "value", "name", false, true, String.class ); listParameter.setParameterAutoSelectFirstValue( true ); listParameter.setMandatory( true ); final DefaultParameterDefinition definition = new DefaultParameterDefinition(); definition.addParameterDefinition( listParameter ); final MasterReport report = new MasterReport(); report.setParameterDefinition( definition ); report.setDataFactory( new TableDataFactory( "test", tableModel ) ); final DefaultParameterContext paramContext = new DefaultParameterContext( report ); final ValidationResult result = validator.validate( new ValidationResult(), definition, paramContext ); assertTrue( result.isEmpty() ); }
Example 4
Source File: FieldMappingTest.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testParameterMapping() { final PlainParameter parameter = new PlainParameter( "P", Number.class ); final DefaultParameterDefinition defaultParameterDefinition = new DefaultParameterDefinition(); defaultParameterDefinition.addParameterDefinition( parameter ); final MasterReport report = new MasterReport(); report.setParameterDefinition( defaultParameterDefinition ); final DefaultDesignTimeContext context = new DefaultDesignTimeContext( report ); final DataSchema dataSchema = context.getDataSchemaModel().getDataSchema(); final DataAttributes attributes = dataSchema.getAttributes( "P" ); final Object o = attributes.getMetaAttribute( MetaAttributeNames.Core.NAMESPACE, MetaAttributeNames.Core.TYPE, Class.class, new DefaultDataAttributeContext() ); assertEquals( "Number.class expected", Number.class, o ); }
Example 5
Source File: InlineSubReportDemo.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Creates the report. For XML reports, this will most likely call the ReportGenerator, while API reports may use this * function to build and return a new, fully initialized report object. * * @return the fully initialized JFreeReport object. * @throws ReportDefinitionException if an error occured preventing the report definition. */ public MasterReport createReport() throws ReportDefinitionException { final MasterReport report = parseReport(); final DefaultParameterDefinition parameterDefinition = new DefaultParameterDefinition(); parameterDefinition.addParameterDefinition(new PlainParameter("REGION")); report.setParameterDefinition(parameterDefinition); return report; }
Example 6
Source File: SQLSubReportDemo.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Creates the report. For XML reports, this will most likely call the ReportGenerator, while API reports may use this * function to build and return a new, fully initialized report object. * * @return the fully initialized JFreeReport object. * @throws org.pentaho.reporting.engine.classic.demo.util.ReportDefinitionException * if an error occured preventing the report definition. */ public MasterReport createReport() throws ReportDefinitionException { final MasterReport report = parseReport(); final DefaultParameterDefinition parameterDefinition = new DefaultParameterDefinition(); parameterDefinition.addParameterDefinition(new PlainParameter("REGION")); report.setParameterDefinition(parameterDefinition); return report; }
Example 7
Source File: PropertiesDataSetBulkReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Done parsing. * * @throws SAXException if there is a parsing error. */ protected void doneParsing() throws SAXException { final Object o = getRootHandler().getHelperObject( ReportParserUtil.HELPER_OBJ_REPORT_NAME ); if ( o instanceof MasterReport == false ) { return; } final MasterReport report = (MasterReport) o; final DefaultParameterDefinition parameterDefinition = new DefaultParameterDefinition(); for ( int i = 0; i < properties.size(); i++ ) { final TypedPropertyReadHandler readHandler = (TypedPropertyReadHandler) properties.get( i ); final String parameterName = readHandler.getName(); if ( "report.date".equals( parameterName ) ) { continue; } if ( "report.name".equals( parameterName ) ) { continue; } final PlainParameter parameter = new PlainParameter( parameterName ); parameter.setValueType( readHandler.getType() ); parameter.setParameterAttribute ( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, "textbox" ); parameter.setDefaultValue( readHandler.getObject() ); parameterDefinition.addParameterDefinition( parameter ); } report.setParameterDefinition( parameterDefinition ); }
Example 8
Source File: Prd3174IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public void testParameterValidation() throws ReportProcessingException { final TypedTableModel model = new TypedTableModel(); model.addColumn( "key", String.class ); model.addColumn( "value", String.class ); model.addRow( "K1", "V1" ); model.addRow( "K2", "V2" ); model.addRow( "K3", "V3" ); final TableDataFactory dataFactory = new TableDataFactory(); dataFactory.addTable( "query", model ); final DefaultListParameter listParameter = new DefaultListParameter( "query", "key", "value", "parameter", true, false, String.class ); final DefaultParameterDefinition parameterDefinition = new DefaultParameterDefinition(); parameterDefinition.addParameterDefinition( listParameter ); final MasterReport report = new MasterReport(); final DefaultReportParameterValidator validator = new DefaultReportParameterValidator(); report.setDataFactory( dataFactory ); report.setParameterDefinition( parameterDefinition ); report.getParameterValues().put( "parameter", new Object[] { "K1", new Integer( 1 ) } ); ValidationResult validate = validator.validate( null, parameterDefinition, new DefaultParameterContext( report ) ); assertFalse( validate.isEmpty() ); report.getParameterValues().put( "parameter", new Object[] { "K1", "K2" } ); validate = validator.validate( null, parameterDefinition, new DefaultParameterContext( report ) ); assertTrue( validate.isEmpty() ); report.getParameterValues().put( "parameter", new Object[] { "K1", "K2", "K5" } ); validate = validator.validate( null, parameterDefinition, new DefaultParameterContext( report ) ); assertTrue( validate.isEmpty() ); }
Example 9
Source File: Prd3174IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public void testStrictParameterValidation() throws ReportProcessingException { final TypedTableModel model = new TypedTableModel(); model.addColumn( "key", String.class ); model.addColumn( "value", String.class ); model.addRow( "K1", "V1" ); model.addRow( "K2", "V2" ); model.addRow( "K3", "V3" ); final TableDataFactory dataFactory = new TableDataFactory(); dataFactory.addTable( "query", model ); final DefaultListParameter listParameter = new DefaultListParameter( "query", "key", "value", "parameter", true, true, String.class ); final DefaultParameterDefinition parameterDefinition = new DefaultParameterDefinition(); parameterDefinition.addParameterDefinition( listParameter ); final MasterReport report = new MasterReport(); final DefaultReportParameterValidator validator = new DefaultReportParameterValidator(); report.setDataFactory( dataFactory ); report.setParameterDefinition( parameterDefinition ); report.getParameterValues().put( "parameter", new Object[] { "K1", new Integer( 1 ) } ); ValidationResult validate = validator.validate( null, parameterDefinition, new DefaultParameterContext( report ) ); assertFalse( validate.isEmpty() ); report.getParameterValues().put( "parameter", new Object[] { "K1", "K2" } ); validate = validator.validate( null, parameterDefinition, new DefaultParameterContext( report ) ); assertTrue( validate.isEmpty() ); report.getParameterValues().put( "parameter", new Object[] { "K1", "K2", "K5" } ); validate = validator.validate( null, parameterDefinition, new DefaultParameterContext( report ) ); assertFalse( validate.isEmpty() ); }
Example 10
Source File: Prd4922IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testEvaluationOrderEnvBeforeParameter() { MasterReport report = new MasterReport(); report.setReportEnvironment( new TestEnv( report.getConfiguration() ) ); DefaultParameterDefinition mdef = new DefaultParameterDefinition(); mdef.addParameterDefinition( new PlainParameter( "test-column", String.class ) ); report.setParameterDefinition( mdef ); report.getParameterValues().put( "test-column", "parameter" ); report.addExpression( new ValidateValueExpression( "parameter" ) ); DebugReportRunner.execGraphics2D( report ); }
Example 11
Source File: Prd4922IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testEvaluationOrderParameterBeforeTable() { MasterReport report = new MasterReport(); DefaultParameterDefinition mdef = new DefaultParameterDefinition(); mdef.addParameterDefinition( new PlainParameter( "test-column", String.class ) ); report.setParameterDefinition( mdef ); report.getParameterValues().put( "test-column", "parameter" ); report.setDataFactory( create() ); report.setQuery( "query" ); report.addExpression( new ValidateValueExpression( "table" ) ); DebugReportRunner.execGraphics2D( report ); }
Example 12
Source File: Prd4579IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testStaticLoadSave() throws Exception { StaticListParameter param = new StaticListParameter( "parameter", false, false, String.class ); DefaultParameterDefinition pdef = new DefaultParameterDefinition(); pdef.addParameterDefinition( param ); MasterReport report = new MasterReport(); report.setParameterDefinition( pdef ); MasterReport result = ReportWritingUtil.saveAndLoad( report ); ReportParameterDefinition parameterDefinition = result.getParameterDefinition(); assertEquals( 1, parameterDefinition.getParameterCount() ); ParameterDefinitionEntry resultParam = parameterDefinition.getParameterDefinition( 0 ); assertTrue( resultParam instanceof StaticListParameter ); }
Example 13
Source File: Prd3795IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Create a report with a StaticListParameter containing specified defaultValue. */ private MasterReport createMultiValueParamReport( final Class valueType, final Object defaultValue, final boolean mandatory ) { final StaticListParameter listParameter = new StaticListParameter( "name", true, false, valueType ); listParameter.setMandatory( mandatory ); listParameter.setDefaultValue( defaultValue ); final DefaultParameterDefinition parameterDefinition = new DefaultParameterDefinition(); parameterDefinition.addParameterDefinition( listParameter ); final MasterReport report = new MasterReport(); report.setParameterDefinition( parameterDefinition ); return report; }
Example 14
Source File: SparklineAPIDemo.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
/** * Creates the report. For XML reports, this will most likely call the ReportGenerator, while API reports may use this * function to build and return a new, fully initialized report object. * * @return the fully initialized JFreeReport object. * @throws ReportDefinitionException if an error occured preventing the report definition. */ public MasterReport createReport() throws ReportDefinitionException { final MasterReport report = new MasterReport(); report.setName("Sparkline Demo"); final DefaultParameterDefinition paramDef = new DefaultParameterDefinition(); final PlainParameter plainParameter = new PlainParameter("sparkline-data", Number[].class); plainParameter.setDefaultValue(new Number[] {new Integer(10), new Integer(5), new Integer(6), new Integer(3), new Integer(1), new Integer(2), new Integer(7), new Integer(9)}); paramDef.addParameterDefinition(plainParameter); report.setParameterDefinition(paramDef); // using the field sparkline-data final BarSparklineElementFactory elementFactory = new BarSparklineElementFactory(); elementFactory.setFieldname("sparkline-data"); elementFactory.setAbsolutePosition(new Point2D.Float(0, 0)); elementFactory.setMinimumSize(new Dimension(100, 10)); elementFactory.setColor(Color.black); elementFactory.setHighColor(Color.red); elementFactory.setLastColor(Color.blue); elementFactory.setBackgroundColor(Color.orange); final ReportFooter footer = report.getReportFooter(); footer.addElement(elementFactory.createElement()); // using a formula final BarSparklineElementFactory itemsSparkFactory = new BarSparklineElementFactory(); itemsSparkFactory.setFormula ("={[January]|[February]|[March]|[April]|[May]|[June]|" + "[July]|[August]|[September]|[October]|[November]|[December]}"); itemsSparkFactory.setAbsolutePosition(new Point2D.Float(0, 0)); itemsSparkFactory.setMinimumSize(new Dimension(100, 10)); itemsSparkFactory.setHighColor(Color.green); itemsSparkFactory.setLastColor(Color.blue); //itemsSparkFactory.setBackgroundColor(Color.yellow); final ItemBand itemBand = report.getItemBand(); itemBand.addElement(itemsSparkFactory.createElement()); itemBand.addElement(HorizontalLineElementFactory.createHorizontalLine (15, null, new BasicStroke(5))); report.setDataFactory(new TableDataFactory("default", data)); return report; }