Java Code Examples for org.pentaho.reporting.engine.classic.core.MasterReport#getDataFactory()
The following examples show how to use
org.pentaho.reporting.engine.classic.core.MasterReport#getDataFactory() .
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: Prd5062Test.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testStepNameNull() throws Exception { final KettleDataFactory kettleDataFactory = new KettleDataFactory(); kettleDataFactory.setQuery( "default", new KettleTransFromFileProducer( QUERY, null ) ); MasterReport report = new MasterReport(); report.setDataFactory( kettleDataFactory ); MasterReport r2 = ReportWritingUtil.saveAndLoad( report ); assertTrue( r2.getDataFactory() instanceof KettleDataFactory ); KettleDataFactory kdf = (KettleDataFactory) r2.getDataFactory(); KettleTransformationProducer query = kdf.getQuery( "default" ); assertNotNull( query ); assertNotNull( query.getTransformationFile() ); assertNull( query.getStepName() ); }
Example 2
Source File: MondrianDataFactoryWriteTest.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testWriteDenormalized() throws Exception { final DenormalizedMDXDataFactory df = new DenormalizedMDXDataFactory(); df.setCubeFileProvider( new DefaultCubeFileProvider( "path/to/cube.xml", "test-connection" ) ); df.setDataSourceProvider( new JndiDataSourceProvider( "dummy" ) ); df.setGlobalScript( "GlobalScript" ); df.setGlobalScriptLanguage( "GlobalScriptLanguage" ); df.setQuery( "QueryName", "QueryText", "ScriptLanguage", "Script" ); final MasterReport report = new MasterReport(); report.setDataFactory( df ); final MasterReport masterReport = postProcess( report ); final DenormalizedMDXDataFactory dataFactory = (DenormalizedMDXDataFactory) masterReport.getDataFactory(); assertEquals( "QueryName", dataFactory.getQueryNames()[ 0 ] ); assertEquals( "QueryText", dataFactory.getQuery( "QueryName" ) ); assertEquals( "ScriptLanguage", dataFactory.getScriptingLanguage( "QueryName" ) ); assertEquals( "Script", dataFactory.getScript( "QueryName" ) ); assertEquals( "GlobalScript", dataFactory.getGlobalScript() ); assertEquals( "GlobalScriptLanguage", dataFactory.getGlobalScriptLanguage() ); assertEquals( "test-connection", dataFactory.getCubeFileProvider().getCubeConnectionName() ); assertEquals( "path/to/cube.xml", dataFactory.getCubeFileProvider().getDesignTimeFile() ); }
Example 3
Source File: Prd4606IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testLargeValidTableInExcelMode() throws Exception { if ( DebugReportRunner.isSkipLongRunTest() ) { return; } ClassicEngineBoot.getInstance().getEditableConfig().setConfigProperty( "org.pentaho.reporting.engine.classic.core.layout.process.EnableCountBoxesStep", "true" ); ClassicEngineBoot.getInstance().getEditableConfig().setConfigProperty( "org.pentaho.reporting.engine.classic.core.layout.ParanoidChecks", "false" ); MasterReport report = DebugReportRunner.parseGoldenSampleReport( "Prd-4606-0001.prpt" ); CompoundDataFactory dataFactory = (CompoundDataFactory) report.getDataFactory(); SequenceDataFactory sequenceDf = (SequenceDataFactory) dataFactory.getReference( 0 ); PerformanceTestSequence sequence = (PerformanceTestSequence) sequenceDf.getSequence( "Query 1" ); sequence.setParameter( "limit", 20000 ); StopWatch sw = StopWatch.startNew(); DebugReportRunner.createXmlFlow( report ); DebugLog.log( sw ); }
Example 4
Source File: Prd4606IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testValidTable() throws Exception { MasterReport report = DebugReportRunner.parseGoldenSampleReport( "Prd-4606-0001.prpt" ); CompoundDataFactory dataFactory = (CompoundDataFactory) report.getDataFactory(); SequenceDataFactory sequenceDf = (SequenceDataFactory) dataFactory.getReference( 0 ); PerformanceTestSequence sequence = (PerformanceTestSequence) sequenceDf.getSequence( "Query 1" ); assertEquals( 10, sequence.getParameter( "limit" ) ); LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage( report, 0 ); RenderNode[] tables = MatchFactory.findElementsByNodeType( logicalPageBox, LayoutNodeTypes.TYPE_BOX_TABLE ); RenderNode[] tableRows = MatchFactory.findElementsByNodeType( logicalPageBox, LayoutNodeTypes.TYPE_BOX_TABLE_ROW ); assertEquals( 1, tables.length ); assertEquals( StrictGeomUtility.toInternalValue( 240 ), tables[0].getHeight() ); TableRenderBox table = (TableRenderBox) tables[0]; assertEquals( 1, table.getColumnModel().getColumnCount() ); assertEquals( 12, tableRows.length ); for ( RenderNode tableRow : tableRows ) { assertEquals( StrictGeomUtility.toInternalValue( 20 ), tableRow.getHeight() ); } }
Example 5
Source File: SqlDataFactoryWriteIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testWrite() throws Exception { final JndiConnectionProvider dummy = new JndiConnectionProvider(); dummy.setConnectionPath( "Dummy" ); final SQLReportDataFactory df = new SQLReportDataFactory( dummy ); df.setGlobalScript( "GlobalScript" ); df.setGlobalScriptLanguage( "GlobalScriptLanguage" ); df.setQuery( "QueryName", "QueryText", "ScriptLanguage", "Script" ); final MasterReport report = new MasterReport(); report.setDataFactory( df ); final MasterReport masterReport = postProcess( report ); final SQLReportDataFactory dataFactory = (SQLReportDataFactory) masterReport.getDataFactory(); assertEquals( "QueryName", dataFactory.getQueryNames()[0] ); assertEquals( "QueryText", dataFactory.getQuery( "QueryName" ) ); assertEquals( "ScriptLanguage", dataFactory.getScriptingLanguage( "QueryName" ) ); assertEquals( "Script", dataFactory.getScript( "QueryName" ) ); assertEquals( "GlobalScript", dataFactory.getGlobalScript() ); assertEquals( "GlobalScriptLanguage", dataFactory.getGlobalScriptLanguage() ); }
Example 6
Source File: DataFactoryWriter.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Writes the report definition portion. Every DefinitionWriter handles one or more elements of the JFreeReport object * tree, DefinitionWriter traverse the object tree and write the known objects or forward objects to other definition * writers. * * @throws java.io.IOException * if there is an I/O problem. * @throws ReportWriterException * if the report serialisation failed. */ public void write() throws IOException, ReportWriterException { final AbstractReportDefinition reportDef = getReport(); if ( reportDef instanceof MasterReport == false ) { // subreports have no data-factory at all. return; } // first, try to find a suitable writer implementation. final MasterReport report = (MasterReport) getReport(); final DataFactory dataFactory = report.getDataFactory(); final DataFactoryWriteHandler handler = DataFactoryWriter.lookupWriteHandler( dataFactory ); if ( handler != null ) { handler.write( getReportWriter(), getXmlWriter(), dataFactory ); return; } // then fall back to the default .. DataFactoryWriter.writeDefaultDataFactory( dataFactory, getXmlWriter() ); }
Example 7
Source File: Olap4JDataFactoryWriteT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testWriteLegacy() throws Exception { final JndiConnectionProvider connectionProvider = new JndiConnectionProvider(); connectionProvider.setConnectionPath( "Dummy" ); final LegacyBandedMDXDataFactory df = new LegacyBandedMDXDataFactory( connectionProvider ); df.setGlobalScript( "GlobalScript" ); df.setGlobalScriptLanguage( "GlobalScriptLanguage" ); df.setQuery( "QueryName", "QueryText", "ScriptLanguage", "Script" ); final MasterReport report = new MasterReport(); report.setDataFactory( df ); final MasterReport masterReport = postProcess( report ); final LegacyBandedMDXDataFactory dataFactory = (LegacyBandedMDXDataFactory) masterReport.getDataFactory(); assertEquals( "QueryName", dataFactory.getQueryNames()[ 0 ] ); assertEquals( "QueryText", dataFactory.getQuery( "QueryName" ) ); assertEquals( "ScriptLanguage", dataFactory.getScriptingLanguage( "QueryName" ) ); assertEquals( "Script", dataFactory.getScript( "QueryName" ) ); assertEquals( "GlobalScript", dataFactory.getGlobalScript() ); assertEquals( "GlobalScriptLanguage", dataFactory.getGlobalScriptLanguage() ); }
Example 8
Source File: Olap4JDataFactoryWriteT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testWriteDenormalized() throws Exception { final JndiConnectionProvider connectionProvider = new JndiConnectionProvider(); connectionProvider.setConnectionPath( "Dummy" ); final DenormalizedMDXDataFactory df = new DenormalizedMDXDataFactory( connectionProvider ); df.setGlobalScript( "GlobalScript" ); df.setGlobalScriptLanguage( "GlobalScriptLanguage" ); df.setQuery( "QueryName", "QueryText", "ScriptLanguage", "Script" ); final MasterReport report = new MasterReport(); report.setDataFactory( df ); final MasterReport masterReport = postProcess( report ); final DenormalizedMDXDataFactory dataFactory = (DenormalizedMDXDataFactory) masterReport.getDataFactory(); assertEquals( "QueryName", dataFactory.getQueryNames()[ 0 ] ); assertEquals( "QueryText", dataFactory.getQuery( "QueryName" ) ); assertEquals( "ScriptLanguage", dataFactory.getScriptingLanguage( "QueryName" ) ); assertEquals( "Script", dataFactory.getScript( "QueryName" ) ); assertEquals( "GlobalScript", dataFactory.getGlobalScript() ); assertEquals( "GlobalScriptLanguage", dataFactory.getGlobalScriptLanguage() ); }
Example 9
Source File: MondrianDataFactoryWriteTest.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testWriteLegacy() throws Exception { final LegacyBandedMDXDataFactory df = new LegacyBandedMDXDataFactory(); df.setCubeFileProvider( new DefaultCubeFileProvider( "path/to/cube.xml", "test-connection" ) ); df.setDataSourceProvider( new JndiDataSourceProvider( "dummy" ) ); df.setGlobalScript( "GlobalScript" ); df.setGlobalScriptLanguage( "GlobalScriptLanguage" ); df.setQuery( "QueryName", "QueryText", "ScriptLanguage", "Script" ); final MasterReport report = new MasterReport(); report.setDataFactory( df ); final MasterReport masterReport = postProcess( report ); final LegacyBandedMDXDataFactory dataFactory = (LegacyBandedMDXDataFactory) masterReport.getDataFactory(); assertEquals( "QueryName", dataFactory.getQueryNames()[ 0 ] ); assertEquals( "QueryText", dataFactory.getQuery( "QueryName" ) ); assertEquals( "ScriptLanguage", dataFactory.getScriptingLanguage( "QueryName" ) ); assertEquals( "Script", dataFactory.getScript( "QueryName" ) ); assertEquals( "GlobalScript", dataFactory.getGlobalScript() ); assertEquals( "GlobalScriptLanguage", dataFactory.getGlobalScriptLanguage() ); assertEquals( "test-connection", dataFactory.getCubeFileProvider().getCubeConnectionName() ); assertEquals( "path/to/cube.xml", dataFactory.getCubeFileProvider().getDesignTimeFile() ); }
Example 10
Source File: Prd5062Test.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testTransformationNameEmpty() throws Exception { final KettleDataFactory kettleDataFactory = new KettleDataFactory(); kettleDataFactory.setQuery( "default", new KettleTransFromFileProducer( null, STEP ) ); MasterReport report = new MasterReport(); report.setDataFactory( kettleDataFactory ); MasterReport r2 = ReportWritingUtil.saveAndLoad( report ); assertTrue( r2.getDataFactory() instanceof KettleDataFactory ); KettleDataFactory kdf = (KettleDataFactory) r2.getDataFactory(); KettleTransformationProducer query = kdf.getQuery( "default" ); assertNotNull( query ); assertNull( query.getTransformationFile() ); assertNotNull( query.getStepName() ); }
Example 11
Source File: MondrianDataFactoryWriteTest.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testWriteBandedNullCubeName() throws Exception { final BandedMDXDataFactory df = new BandedMDXDataFactory(); df.setCubeFileProvider( new DefaultCubeFileProvider( "path/to/cube.xml", null ) ); df.setDataSourceProvider( new JndiDataSourceProvider( "dummy" ) ); df.setGlobalScript( "GlobalScript" ); df.setGlobalScriptLanguage( "GlobalScriptLanguage" ); df.setQuery( "QueryName", "QueryText", "ScriptLanguage", "Script" ); final MasterReport report = new MasterReport(); report.setDataFactory( df ); final MasterReport masterReport = postProcess( report ); final BandedMDXDataFactory dataFactory = (BandedMDXDataFactory) masterReport.getDataFactory(); assertEquals( "QueryName", dataFactory.getQueryNames()[ 0 ] ); assertEquals( "QueryText", dataFactory.getQuery( "QueryName" ) ); assertEquals( "ScriptLanguage", dataFactory.getScriptingLanguage( "QueryName" ) ); assertEquals( "Script", dataFactory.getScript( "QueryName" ) ); assertEquals( "GlobalScript", dataFactory.getGlobalScript() ); assertEquals( "GlobalScriptLanguage", dataFactory.getGlobalScriptLanguage() ); assertEquals( null, dataFactory.getCubeFileProvider().getCubeConnectionName() ); assertEquals( "path/to/cube.xml", dataFactory.getCubeFileProvider().getDesignTimeFile() ); }
Example 12
Source File: Prd5062Test.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testStepNameEmpty() throws Exception { final KettleDataFactory kettleDataFactory = new KettleDataFactory(); kettleDataFactory.setQuery( "default", new KettleTransFromFileProducer( QUERY, "" ) ); MasterReport report = new MasterReport(); report.setDataFactory( kettleDataFactory ); MasterReport r2 = ReportWritingUtil.saveAndLoad( report ); assertTrue( r2.getDataFactory() instanceof KettleDataFactory ); KettleDataFactory kdf = (KettleDataFactory) r2.getDataFactory(); KettleTransformationProducer query = kdf.getQuery( "default" ); assertNotNull( query ); assertNotNull( query.getTransformationFile() ); assertEquals( "", query.getStepName() ); }
Example 13
Source File: Prd5062Test.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testQueryNameEmpty() throws Exception { final KettleDataFactory kettleDataFactory = new KettleDataFactory(); kettleDataFactory.setQuery( "", new KettleTransFromFileProducer( QUERY, STEP ) ); MasterReport report = new MasterReport(); report.setDataFactory( kettleDataFactory ); MasterReport r2 = ReportWritingUtil.saveAndLoad( report ); assertTrue( r2.getDataFactory() instanceof KettleDataFactory ); KettleDataFactory kdf = (KettleDataFactory) r2.getDataFactory(); KettleTransformationProducer query = kdf.getQuery( "" ); assertNotNull( query ); assertNotNull( query.getTransformationFile() ); assertNotNull( query.getStepName() ); }
Example 14
Source File: DataSourceTestBase.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public static DataFactory loadAndSaveOnReport( final DataFactory dataFactory ) throws IOException, BundleWriterException, ContentIOException, ResourceException { final MasterReport report = new MasterReport(); report.setDataFactory( dataFactory ); final MemoryByteArrayOutputStream bout = new MemoryByteArrayOutputStream(); BundleWriter.writeReportToZipStream( report, bout ); final ResourceManager mgr = new ResourceManager(); mgr.registerDefaults(); final Resource resource = mgr.createDirectly( bout.toByteArray(), MasterReport.class ); final MasterReport r2 = (MasterReport) resource.getResource(); return r2.getDataFactory(); }
Example 15
Source File: Prd4606IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public void testPageSpanningAcrossPages() throws Exception { ClassicEngineBoot.getInstance().getEditableConfig().setConfigProperty( "org.pentaho.reporting.engine.classic.core.layout.process.EnableCountBoxesStep", "false" ); ClassicEngineBoot.getInstance().getEditableConfig().setConfigProperty( "org.pentaho.reporting.engine.classic.core.layout.ParanoidChecks", "false" ); MasterReport report = DebugReportRunner.parseGoldenSampleReport( "Prd-4606-0003.prpt" ); report.setPageDefinition( new SimplePageDefinition( new PageSize( 500, 100 ) ) ); CompoundDataFactory dataFactory = (CompoundDataFactory) report.getDataFactory(); SequenceDataFactory sequenceDf = (SequenceDataFactory) dataFactory.getReference( 0 ); PerformanceTestSequence sequence = (PerformanceTestSequence) sequenceDf.getSequence( "Query 1" ); sequence.setParameter( "limit", 10 ); LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage( report, 1 ); }
Example 16
Source File: DefaultParameterContext.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public DefaultParameterContext( final MasterReport report, final ReportParameterValues parameterValues ) throws ReportProcessingException { if ( report == null ) { throw new NullPointerException( "Report parameter must not be null" ); } if ( parameterValues == null ) { throw new NullPointerException( "ParameterValues parameter must not be null" ); } this.configuration = report.getConfiguration(); this.resourceBundleFactory = MasterReport.computeAndInitResourceBundleFactory( report.getResourceBundleFactory(), report .getReportEnvironment() ); this.contentBase = report.getContentBase(); this.resourceManager = report.getResourceManager(); this.reportEnvironment = report.getReportEnvironment(); final Object dataCacheEnabledRaw = report.getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.DATA_CACHE ); final boolean dataCacheEnabled = Boolean.FALSE.equals( dataCacheEnabledRaw ) == false; this.dataFactory = new CachingDataFactory( report.getDataFactory(), dataCacheEnabled ); final DocumentBundle bundle = report.getBundle(); if ( bundle != null ) { this.documentMetaData = bundle.getMetaData(); } this.dataFactory.initialize( new DesignTimeDataFactoryContext( configuration, resourceManager, contentBase, resourceBundleFactory, dataFactory ) ); final ReportEnvironmentDataRow envDataRow = new ReportEnvironmentDataRow( reportEnvironment ); this.parameterValues = new CompoundDataRow( envDataRow, parameterValues ); }
Example 17
Source File: SequenceDataFactoryIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public void testSequenceDataSourceInsulation() throws Exception { MasterReport report = DebugReportRunner.parseGoldenSampleReport( "Prd-4606-0001.prpt" ); CompoundDataFactory dataFactory = (CompoundDataFactory) report.getDataFactory(); SequenceDataFactory sequenceDf = (SequenceDataFactory) dataFactory.getReference( 0 ); PerformanceTestSequence sequence = (PerformanceTestSequence) sequenceDf.getSequence( "Query 1" ); sequence.setParameter( "limit", 20000 ); MasterReport reportV = DebugReportRunner.parseGoldenSampleReport( "Prd-4606-0001.prpt" ); CompoundDataFactory dataFactoryV = (CompoundDataFactory) reportV.getDataFactory(); SequenceDataFactory sequenceDfV = (SequenceDataFactory) dataFactoryV.getReference( 0 ); PerformanceTestSequence sequenceV = (PerformanceTestSequence) sequenceDfV.getSequence( "Query 1" ); assertEquals( 10, sequenceV.getParameter( "limit" ) ); }
Example 18
Source File: Prd4843IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testSampleReport() throws Exception { URL resource = getClass().getResource( "Prd-4843.prpt" ); MasterReport report = (MasterReport) new ResourceManager().createDirectly( resource, MasterReport.class ).getResource(); CompoundDataFactory dataFactory = (CompoundDataFactory) report.getDataFactory(); SQLReportDataFactory dataFactory1 = (SQLReportDataFactory) dataFactory.get( 0 ); DriverConnectionProvider conProv1 = (DriverConnectionProvider) dataFactory1.getConnectionProvider(); Assert.assertEquals( "abcdefghijk", conProv1.getProperty( "user" ) ); Assert.assertEquals( "abcdefghijk", conProv1.getProperty( "password" ) ); SQLReportDataFactory dataFactory2 = (SQLReportDataFactory) dataFactory.get( 1 ); DriverConnectionProvider conProv2 = (DriverConnectionProvider) dataFactory2.getConnectionProvider(); Assert.assertEquals( "abcdefghijkl", conProv2.getProperty( "user" ) ); Assert.assertEquals( "abcdefghijkl", conProv2.getProperty( "password" ) ); }
Example 19
Source File: DesignTimeDataFactoryContext.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public DesignTimeDataFactoryContext( final MasterReport report ) { this( report.getConfiguration(), report.getResourceManager(), report.getContentBase(), MasterReport .computeAndInitResourceBundleFactory( report.getResourceBundleFactory(), report.getReportEnvironment() ), report.getDataFactory() ); }
Example 20
Source File: SequenceDataSourceWriteIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public void testWriteAndLoad() throws IOException, ContentIOException, BundleWriterException, ResourceException { final NumberSequence numberSequence = new NumberSequence(); numberSequence.setParameter( "limit", 1234 ); numberSequence.setParameter( "step", new BigDecimal( "1.2" ) ); numberSequence.setParameter( "start", new BigDecimal( "4.5" ) ); numberSequence.setParameter( "ascending", Boolean.FALSE ); final PrinterNamesSequence printerSequence = new PrinterNamesSequence(); final PerformanceTestSequence performanceSequence = new PerformanceTestSequence(); performanceSequence.setParameter( "limit", 4567 ); performanceSequence.setParameter( "seed", 1234l ); final PerformanceTestSequence performanceSequence2 = new PerformanceTestSequence(); final SequenceDataFactory sdf = new SequenceDataFactory(); sdf.addSequence( "one", numberSequence ); sdf.addSequence( "two", printerSequence ); sdf.addSequence( "three", performanceSequence ); sdf.addSequence( "four", performanceSequence2 ); final MasterReport report = new MasterReport(); report.setDataFactory( sdf ); final ByteArrayOutputStream reportDefOutputStream = new ByteArrayOutputStream(); BundleWriter.writeReportToZipStream( report, reportDefOutputStream ); final byte[] reportDefBits = reportDefOutputStream.toByteArray(); final ResourceManager mgr = new ResourceManager(); mgr.registerDefaults(); final Resource directly = mgr.createDirectly( reportDefBits, MasterReport.class ); final MasterReport report2 = (MasterReport) directly.getResource(); final DataFactory dataFactory = report2.getDataFactory(); assertTrue( dataFactory instanceof SequenceDataFactory ); final SequenceDataFactory fac2 = (SequenceDataFactory) dataFactory; final String[] queryNames = fac2.getQueryNames(); assertTrue( ObjectUtilities.equalArray( queryNames, sdf.getQueryNames() ) ); for ( int i = 0; i < queryNames.length; i++ ) { final String queryName = queryNames[i]; assertEqual( sdf.getSequence( queryName ), fac2.getSequence( queryName ) ); } }