/** * 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 copyMetaData( final MemoryDocumentBundle memoryDocumentBundle, final DocumentBundle bundle ) { final WriteableDocumentMetaData memMeta = memoryDocumentBundle.getWriteableDocumentMetaData(); final DocumentMetaData metaData = bundle.getMetaData(); memMeta.setBundleType( metaData.getBundleType() ); final String[] metaNamespaces = metaData.getMetaDataNamespaces(); for ( int i = 0; i < metaNamespaces.length; i++ ) { final String metaNamespace = metaNamespaces[ i ]; final String[] metaDataNames = metaData.getMetaDataNames( metaNamespace ); for ( int j = 0; j < metaDataNames.length; j++ ) { final String metaDataName = metaDataNames[ j ]; final Object value = metaData.getBundleAttribute( metaNamespace, metaDataName ); memMeta.setBundleAttribute( metaNamespace, metaDataName, value ); } } } }
BundleUtilities.copyInto( mem, bundle, LegacyBundleResourceRegistry.getInstance().getRegisteredFiles(), true ); BundleUtilities.copyMetaData( mem, bundle ); mem.getWriteableDocumentMetaData().setBundleType( bundleType ); setBundle( mem ); } catch ( ResourceException e ) {
/** * 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(); }