public static void writeReportToZipFile( final MasterReport report, final File file ) throws IOException, BundleWriterException, ContentIOException { if ( report == null ) { throw new NullPointerException(); } if ( file == null ) { throw new NullPointerException(); } final MemoryDocumentBundle outputBundle = new MemoryDocumentBundle(); final BundleWriter writer = new BundleWriter(); writer.writeReport( outputBundle, report ); BundleUtilities.writeAsZip( file, outputBundle ); }
public static void writeReportToDirectory( final MasterReport report, final File file ) throws IOException, BundleWriterException, ContentIOException { if ( report == null ) { throw new NullPointerException(); } if ( file == null ) { throw new NullPointerException(); } final MemoryDocumentBundle documentBundle = new MemoryDocumentBundle(); final BundleWriter writer = new BundleWriter(); writer.writeReport( documentBundle, report ); BundleUtilities.writeToDirectory( file, documentBundle ); }
public static void writeReportToZipStream( final MasterReport report, final OutputStream out ) throws IOException, BundleWriterException, ContentIOException { if ( report == null ) { throw new NullPointerException(); } if ( out == null ) { throw new NullPointerException(); } final MemoryDocumentBundle documentBundle = new MemoryDocumentBundle(); final BundleWriter writer = new BundleWriter(); writer.writeReport( documentBundle, report ); BundleUtilities.writeAsZip( out, documentBundle ); }
public void writeReport( final WriteableDocumentBundle bundle, final MasterReport report ) throws IOException, BundleWriterException { if ( bundle == null ) { throw new NullPointerException(); } if ( report == null ) { throw new NullPointerException(); } if ( bundle == report.getBundle() ) { throw new IllegalArgumentException( "Cannot write to the originating bundle." ); } final DocumentBundle reportBundle = report.getBundle(); if ( reportBundle == null ) { this.writeReport( bundle, report, new MemoryDocumentBundle() ); } else { this.writeReport( bundle, report, reportBundle ); } }
/** * A helper method that serializes the element object. * * @param stream * the stream to which the element should be serialized. * @throws IOException * if an IO error occured or a property was not serializable. */ private void writeObject( final ObjectOutputStream stream ) throws IOException { stream.defaultWriteObject(); try { final DocumentBundle bundle = getBundle(); stream.writeObject( bundle.getMetaData().getBundleType() ); final MemoryDocumentBundle mem = new MemoryDocumentBundle(); BundleUtilities.copyStickyInto( mem, bundle ); BundleUtilities.copyInto( mem, bundle, LegacyBundleResourceRegistry.getInstance().getRegisteredFiles(), true ); BundleUtilities.copyMetaData( mem, bundle ); mem.getWriteableDocumentMetaData().setBundleType( "application/vnd.pentaho.serialized-bundle" ); final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); BundleUtilities.writeAsZip( outputStream, mem ); stream.writeObject( outputStream.toByteArray() ); } catch ( ContentIOException e ) { throw new IOException( "Unable to serialize the bundle", e ); } }
public static void writeReportToZipStream( final MasterReport report, final OutputStream out, final DocumentMetaData metaData ) throws IOException, BundleWriterException, ContentIOException { if ( report == null ) { throw new NullPointerException(); } if ( out == null ) { throw new NullPointerException(); } final MemoryDocumentBundle documentBundle = new MemoryDocumentBundle(); final BundleWriter writer = new BundleWriter(); writer.writeReport( documentBundle, report ); // restore the metadata to match the metadata of the original bundle. final WriteableDocumentMetaData targetMetaData = (WriteableDocumentMetaData) documentBundle.getMetaData(); for ( final String namespace : metaData.getMetaDataNamespaces() ) { for ( final String name : metaData.getMetaDataNames( namespace ) ) { targetMetaData.setBundleAttribute( namespace, name, metaData.getBundleAttribute( namespace, name ) ); } } BundleUtilities.writeAsZip( out, documentBundle ); }
final DocumentBundle bundle = (DocumentBundle) bundleResource.getResource(); final MemoryDocumentBundle mem = new MemoryDocumentBundle( getContentBase() ); BundleUtilities.copyStickyInto( mem, bundle ); BundleUtilities.copyInto( mem, bundle, LegacyBundleResourceRegistry.getInstance().getRegisteredFiles(), true );
/** * 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(); }