public DesignTimeDataFactoryContext( final MasterReport report ) { this( report.getConfiguration(), report.getResourceManager(), report.getContentBase(), MasterReport .computeAndInitResourceBundleFactory( report.getResourceBundleFactory(), report.getReportEnvironment() ), report.getDataFactory() ); }
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 ); }
/** * 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() ); }
if ( report instanceof MasterReport ) { final MasterReport masterReport = (MasterReport) report; final String dataSourceDefFile = writeDataFactoryWrapper( bundle, contentState, masterReport.getDataFactory() ); final String relativePath = IOUtils.getInstance().createRelativePath( dataSourceDefFile, contentState.getFileName() );
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(); }
configuration = masterReport.getConfiguration(); reportEnvironment = masterReport.getReportEnvironment(); reportDataFactory = masterReport.getDataFactory(); resourceManager = masterReport.getResourceManager(); resourceBundleFactory = masterReport.getResourceBundleFactory();
/** * Helper method to invoke a pre-processor outside of the report processing. This is strictly for unit-testing only. * * @param report * @param processor * @return * @throws org.pentaho.reporting.engine.classic.core.ReportProcessingException */ protected MasterReport materialize( final MasterReport report, final ReportPreProcessor processor ) throws ReportProcessingException { final PerformanceMonitorContext pmc = new NoOpPerformanceMonitorContext(); final DefaultProcessingContext processingContext = new DefaultProcessingContext( report ); final DataSchemaDefinition definition = report.getDataSchemaDefinition(); final DefaultFlowController flowController = new DefaultFlowController( processingContext, definition, StateUtilities.computeParameterValueSet( report ), pmc ); final CachingDataFactory dataFactory = new CachingDataFactory( report.getDataFactory(), false ); dataFactory.initialize( new ProcessingDataFactoryContext( processingContext, dataFactory ) ); try { final DefaultFlowController postQueryFlowController = flowController.performQuery( dataFactory, report.getQuery(), report.getQueryLimit(), report.getQueryTimeout(), flowController.getMasterRow().getResourceBundleFactory(), Collections.<SortConstraint>emptyList() ); return processor.performPreProcessing( report, postQueryFlowController ); } finally { dataFactory.close(); } }
report.getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.DATA_CACHE ); final boolean dataCacheEnabled = Boolean.FALSE.equals( dataCacheEnabledRaw ) == false; this.dataFactory = new CachingDataFactory( report.getDataFactory().derive(), dataCacheEnabled ); this.resourceBundleFactory = MasterReport.computeAndInitResourceBundleFactory( report.getResourceBundleFactory(), report