protected ReportProcessor createReportProcessor( OutputStream fout ) throws Exception { PdfOutputProcessor outputProcessor = new PdfOutputProcessor( report.getConfiguration(), fout, report.getResourceManager() ); return new PageableReportProcessor( report, outputProcessor ); } };
public void createReport() throws Exception { report = new MasterReport(); report.setDataFactory( dataFactory ); report.setReportHeader( reportHeader ); ReportFooter reportFooter = new ReportFooter(); report.setReportFooter( reportFooter ); groupData.setItemBand( itemBand ); group.setBody( groupData ); report.setRootGroup( group ); bshExpression.setExpression( bshCode ); bshExpression.setName( "getImage" ); report.addExpression( bshExpression ); report.setPageDefinition( pageDefinition );
ReportParameterValues values = report.getParameterValues(); ReportParameterDefinition definition = report.getParameterDefinition();
public void testCreate() throws Exception { final MasterReport report = new MasterReport(); // Report name is null report.setName( "MyTestReport" ); assertNotNull( report.getPageDefinition() ); assertNotNull( report.getExpressions() ); assertNotNull( report.getRootGroup() ); assertEquals( report.getGroupCount(), 1 ); assertNotNull( report.getItemBand() ); assertNotNull( report.getName() ); assertNotNull( report.getPageFooter() ); assertNotNull( report.getPageHeader() ); assertNotNull( report.getReportConfiguration() ); assertNotNull( report.getReportFooter() ); assertNotNull( report.getReportHeader() ); assertNotNull( report.getGroup( 0 ) ); // the default group must be defined ... assertNotNull( report.clone() ); }
report = new MasterReport(); report.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.SOURCE, rootHandler.getSource() ); } else { report = (MasterReport) maybeReport; final int groupCount = report.getGroupCount(); for ( int i = 0; i < groupCount; i++ ) { final Group g = report.getGroup( i ); if ( g instanceof RelationalGroup ) { groupList.add( (RelationalGroup) g ); final String query = attrs.getValue( getUri(), "query" ); if ( query != null ) { report.setQuery( query ); report.setName( name ); PageFormat format = report.getPageDefinition().getPageFormat( 0 ); float defTopMargin = (float) format.getImageableY(); float defBottomMargin = (float) ( format.getHeight() - format.getImageableHeight() - format.getImageableY() ); report.setPageDefinition( new SimplePageDefinition( format, pageSpan, 1 ) ); report.getStyle().setStyleProperty( ElementStyleKeys.USE_MIN_CHUNKWIDTH, ReportParserUtil.parseBoolean( useMinChunkWidth, getLocator() ) ); report.setCompatibilityLevel( ClassicEngineBoot.computeVersionId( 3, 8, 0 ) ); this.report = report;
final ReportParameterDefinition parameters = report.getParameterDefinition(); final DefaultParameterContext parameterContext = new DefaultParameterContext( report ); new DefaultFlowController( processingContext, report.getDataSchemaDefinition(), StateUtilities.computeParameterValueSet( report, parameterValues ), performanceMonitorContext ); processedReport.getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.DATA_CACHE ); final boolean dataCacheEnabled = designtime == false && Boolean.FALSE.equals( dataCacheEnabledRaw ) == false; final Integer queryLimitDefault = IntegerCache.getInteger( processedReport.getQueryLimit() ); final Integer queryTimeoutDefault = IntegerCache.getInteger( processedReport.getQueryTimeout() ); final String queryDefined = designtime ? "design-time-query" : processedReport.getQuery(); final Object queryRaw = evaluateExpression( processedReport.getAttributeExpression( AttributeNames.Internal.NAMESPACE, AttributeNames.Internal.QUERY ), queryDefined ); final Object queryLimitRaw = evaluateExpression( processedReport.getAttributeExpression( AttributeNames.Internal.NAMESPACE, AttributeNames.Internal.QUERY_LIMIT ), queryLimitDefault ); final Object queryTimeoutRaw = evaluateExpression( processedReport.getAttributeExpression( AttributeNames.Internal.NAMESPACE, AttributeNames.Internal.QUERY_TIMEOUT ), queryTimeoutDefault ); final List<SortConstraint> sortOrder = lookupSortOrder( processedReport ); this.query = (String) ConverterRegistry.convert( queryRaw, String.class, processedReport.getQuery() ); this.queryLimit = (Integer) ConverterRegistry.convert( queryLimitRaw, Integer.class, queryLimitDefault ); this.queryTimeout = (Integer) ConverterRegistry.convert( queryTimeoutRaw, Integer.class, queryTimeoutDefault ); expressions = new Expression[ 0 ];
public DefaultProcessingContext( final MasterReport report, final OutputProcessorMetaData metaData ) throws ReportProcessingException { this( metaData, report.getResourceBundleFactory(), report.getConfiguration(), report.getResourceManager(), report .getContentBase(), report.getBundle().getMetaData(), report.getReportEnvironment(), -1 ); final Integer comLev = report.getCompatibilityLevel(); if ( comLev != null ) { compatibilityLevel = comLev; } }
protected MasterReport createCrosstabReport( final TableModel tableModel ) { Expression dummy = create( "dummy", null, null ); if ( dummy instanceof AggregationFunction == false ) { return null; } AggregationFunction function = (AggregationFunction) dummy; final MasterReport report = new MasterReport(); report.setPageDefinition( new SimplePageDefinition( PageSize.A3, PageFormat.LANDSCAPE, new Insets( 0, 0, 0, 0 ) ) ); report.setDataFactory( new TableDataFactory( "query", tableModel ) ); report.setQuery( "query" ); final ContextAwareDataSchemaModel dataSchemaModel = new DesignTimeDataSchemaModel( report ); final CrosstabBuilder builder = new CrosstabBuilder( dataSchemaModel ); builder.addRowDimension( ROW_DIMENSION_A ); builder.addRowDimension( ROW_DIMENSION_B ); builder.addColumnDimension( COLUMN_DIMENSION_A ); builder.addColumnDimension( COLUMN_DIMENSION_B ); builder.addDetails( VALUE, function.getClass() ); report.setRootGroup( builder.create() ); return report; }
@Test public void testIsQueryLimitNotReachedForNumberOfRowsEqualQueryLimit() throws Exception { final MasterReport report = new MasterReport(); final DefaultTableModel model = new DefaultTableModel( 500, 10 ); report.setDataFactory( new TableDataFactory( "default", model ) ); report.setQueryLimit( 500 ); final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report ); reportProcessor.prepareReportProcessing(); assertEquals( reportProcessor.isQueryLimitReached(), false ); }
/** * The default constructor. Creates an empty but fully initialized report. */ public MasterReport() { setElementType( new MasterReportType() ); setResourceBundleFactory( new LibLoaderResourceBundleFactory() ); this.reportConfiguration = new HierarchicalConfiguration( ClassicEngineBoot.getInstance().getGlobalConfig() ); this.parameterValues = new ReportParameterValues(); setPageDefinition( null ); final TableDataFactory dataFactory = new TableDataFactory(); dataFactory.addTable( "default", new DefaultTableModel() ); this.dataFactory = dataFactory; setQuery( "default" ); // Add a listener that will handle keeping the ResourceManager in sync with changes to the Document Bundle addReportModelListener( new DocumentBundleChangeHandler() ); this.reportEnvironment = new DefaultReportEnvironment( getConfiguration() ); this.parameterDefinition = new DefaultParameterDefinition(); final MemoryDocumentBundle documentBundle = new MemoryDocumentBundle(); documentBundle.getWriteableDocumentMetaData().setBundleType( ClassicEngineBoot.BUNDLE_TYPE ); documentBundle.getWriteableDocumentMetaData().setBundleAttribute( ODFMetaAttributeNames.Meta.NAMESPACE, ODFMetaAttributeNames.Meta.CREATION_DATE, new Date() ); setBundle( documentBundle ); setContentBase( documentBundle.getBundleMainKey() ); addReportModelListener( new ResourceBundleChangeHandler() ); updateResourceBundleFactoryInternal(); }
public DesignTimeDataFactoryContext( final MasterReport report ) { this( report.getConfiguration(), report.getResourceManager(), report.getContentBase(), MasterReport .computeAndInitResourceBundleFactory( report.getResourceBundleFactory(), report.getReportEnvironment() ), report.getDataFactory() ); }
(DataDefinition) performExternalParsing( parameterFile, DataDefinition.class, parameters ); report.setQuery( dataDefinition.getQuery() ); report.setQueryLimit( dataDefinition.getQueryLimit() ); report.setQueryTimeout( dataDefinition.getQueryTimeout() ); report.setDataFactory( dataFactory ); report.setParameterDefinition( definition ); for ( int i = 0; i < expressions.length; i++ ) { final Expression expression = expressions[i]; report.addExpression( expression );
@PerfTest( duration = PerfBenchmarkingTest.MAX_DURATION, threads = PerfBenchmarkingTest.MAX_THREADS, rampUp = PerfBenchmarkingTest.MAX_RAMPUP, warmUp = PerfBenchmarkingTest.MAX_WARMUP ) @Test public void perfDataSource() throws Exception { if ( !isExecutePerformanceTest ) { return; } final MasterReport master = new MasterReport(); final TableDataFactory tableDataFactory = new TableDataFactory(); tableDataFactory.addTable( "fruit", createFruitTableModel() ); master.setQuery( "Query Fruit" ); master.setDataFactory( tableDataFactory ); final CompoundDataFactory cdf = new CompoundDataFactory(); cdf.add( tableDataFactory ); master.setDataFactory( cdf ); final CachingDataFactory caDf = new CachingDataFactory( cdf, true ); master.setDataFactory( caDf ); final CompoundDataFactory ccdf = new CascadingDataFactory(); ccdf.add( caDf ); ccdf.add( tableDataFactory ); master.setDataFactory( ccdf ); // assertTrue(ccdf.isQueryExecutable("Query Fruit", new StaticDataRow())); }
public void testDerive() throws CloneNotSupportedException { final MasterReport report = new MasterReport(); report.setQueryLimit( 10 ); report.setQueryTimeout( 10 ); final MasterReport element = (MasterReport) report.derive(); assertEquals( 10, element.getQueryLimit() ); assertEquals( 10, element.getQueryTimeout() ); }
public Configuration getConfiguration() { return report.getConfiguration(); }
@Test( expected = ReportInterruptedException.class ) public void testInterruptedNew() throws Exception { final MasterReport report = new MasterReport(); final DefaultTableModel model = new DefaultTableModel( 500, 10 ); report.setDataFactory( new TableDataFactory( "default", model ) ); final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report ); final ReportProgressListener reportProgressListener = mock( ReportProgressListener.class ); doAnswer( new Answer() { @Override public Object answer( final InvocationOnMock invocation ) throws Throwable { reportProcessor.cancel(); return null; } } ).when( reportProgressListener ).reportProcessingUpdate( any( ReportProgressEvent.class ) ); reportProcessor.addReportProgressListener( reportProgressListener ); reportProcessor.processReport(); }
ReportParameterDefinition definition = report.getParameterDefinition(); RowMetaInterface r = new RowMeta(); for ( int i = 0; i < definition.getParameterCount(); i++ ) {
public MasterReport createReport() { final MasterReport report = new MasterReport(); report.setRootGroup( create() ); return report; }
protected static MasterReport createDummyReport( final Band band ) { ReportDefinition masterReport = band.getMasterReport(); MasterReport dummy = new MasterReport(); dummy.copyAttributes( masterReport.getAttributes() ); dummy.setPageDefinition( masterReport.getPageDefinition() ); SimpleStyleResolver simpleStyleResolver = new SimpleStyleResolver( true ); ResolverStyleSheet resolveStyleSheet = new ResolverStyleSheet(); simpleStyleResolver.resolve( dummy, resolveStyleSheet ); dummy.setComputedStyle( new SimpleStyleSheet( resolveStyleSheet ) ); return dummy; } }
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(); }