public static MasterReport loadMasterReport( String sourceFilename ) throws Exception { ResourceManager manager = new ResourceManager(); manager.registerDefaults(); FileObject fileObject = KettleVFS.getFileObject( sourceFilename ); URL url = new URL( fileObject.getName().getURI() ); Resource resource = manager.createDirectly( url, MasterReport.class ); MasterReport report = (MasterReport) resource.getResource(); return report; }
public static void performPentahoReportingBoot( LogChannelInterface log, Class<?> referenceClass ) { // Boot the Pentaho reporting engine! // if ( ClassicEngineBoot.getInstance().isBootDone() == false ) { ObjectUtilities.setClassLoader( referenceClass.getClassLoader() ); ObjectUtilities.setClassLoaderSource( ObjectUtilities.CLASS_CONTEXT ); LibLoaderBoot.getInstance().start(); LibFontBoot.getInstance().start(); ClassicEngineBoot.getInstance().start(); Exception exception = ClassicEngineBoot.getInstance().getBootFailureReason(); if ( exception != null ) { log.logError( "Error booting the Pentaho reporting engine", exception ); } } }
@Test public void testExportReportWithSupportedLocale() { when( masterReport.getConfiguration() ).thenReturn( mock( Configuration.class ) ); when( masterReport.getResourceManager() ).thenReturn( new ResourceManager() ); when( swingGuiContext.getLocale() ).thenReturn( Locale.US ); when( swingGuiContext.getStatusListener() ).thenReturn( mock( StatusListener.class ) ); Runnable exportTask = new ReportExportTask( masterReport, swingGuiContext, targetPath, createParentFolder ) { protected ReportProcessor createReportProcessor( OutputStream fout ) throws Exception { PdfOutputProcessor outputProcessor = new PdfOutputProcessor( masterReport.getConfiguration(), fout, masterReport.getResourceManager() ); return new PageableReportProcessor( masterReport, outputProcessor ); } }; assertNotNull( exportTask ); exportTask.run(); assertThat( swingGuiContext.getStatusType(), not( StatusType.ERROR ) ); }
private StyleSheet parseStyleSheet( final ResourceKey key, final ResourceKey context ) { try { final Resource resource = resourceManager.create ( key, context, StyleSheet.class ); return (StyleSheet) resource.getResource(); } catch ( ResourceException e ) { // Log.info("Unable to parse StyleSheet: " + e.getLocalizedMessage()); } return null; }
public ResourceKey deserialize( final ResourceKey bundleKey, final String stringKey ) throws ResourceKeyCreationException { // Parse the data final ResourceKeyData keyData = ResourceKeyUtils.parse( stringKey ); // Validate the data if ( SCHEMA_NAME.equals( keyData.getSchema() ) == false ) { throw new ResourceKeyCreationException( "Serialized version of key does not contain correct schema" ); } // Create a new file based on the path provided final File file = new File( keyData.getIdentifier() ); return new ResourceKey( SCHEMA_NAME, file, keyData.getFactoryParameters() ); }
public long getVersion( final ResourceManager caller ) throws ResourceLoadingException { final ResourceKey parentKey = key.getParent(); final ResourceData data = caller.load( parentKey ); return data.getVersion( caller ); } }
public static File getContextAsFile( ResourceKey key ) { while ( key != null ) { final Object identifier = key.getIdentifier(); if ( identifier instanceof File ) { return (File) identifier; } key = key.getParent(); } return null; }
public long getVersion( final ResourceKey key ) { if ( key.equals( this.key ) ) { return version; } // -1 is the placeholder for: not known. return -1; }
public static LibLoaderInfo getInstance() { if ( instance == null ) { instance = new LibLoaderInfo(); instance.initialize(); } return instance; }
public Resource create( final ResourceManager caller, final ResourceData data, final ResourceKey context ) throws ResourceLoadingException, ResourceCreationException { throw new ContentNotRecognizedException(); } }
/** * The primary source is also included in this set. The dependencies are given as ResourceKey objects. The keys itself * do not hold any state information. * <p/> * The dependencies do not track deep dependencies. So if Resource A depends on Resource B which depends on Resource * C, then A only knows about B, not C. * * @return */ public ResourceKey[] getDependencies() { return dependencies.getDependencies(); }
/** * Default Constructor. */ public ResourceManager() { this( new DefaultResourceManagerBackend() ); }
/** * The primary source is also included in this set. The dependencies are given as ResourceKey objects. The keys itself * do not hold any state information. * <p/> * The dependencies do not track deep dependencies. So if Resource A depends on Resource B which depends on Resource * C, then A only knows about B, not C. * * @return */ public ResourceKey[] getDependencies() { return new ResourceKey[] { getSource() }; }
public static MasterReport parseReport( final Object file ) throws ResourceException { final ResourceManager manager = new ResourceManager(); manager.registerDefaults(); final Resource resource = manager.createDirectly( file, MasterReport.class ); return (MasterReport) resource.getResource(); }
private ElementStyleDefinition parseStyleSheet( final ResourceKey key, final ResourceKey context ) { try { final Resource resource = resourceManager.create( key, context, ElementStyleDefinition.class ); return (ElementStyleDefinition) resource.getResource(); } catch ( ResourceException e ) { // Log.info("Unable to parse StyleSheet: " + e.getLocalizedMessage()); } return null; }
@Test public void testExportReportWithUnsupportedLocale() { when( masterReport.getConfiguration() ).thenReturn( mock( Configuration.class ) ); when( masterReport.getResourceManager() ).thenReturn( new ResourceManager() ); when( swingGuiContext.getLocale() ).thenReturn( Locale.UK ); when( swingGuiContext.getStatusListener() ).thenReturn( mock( StatusListener.class ) ); Runnable exportTask = new ReportExportTask( masterReport, swingGuiContext, targetPath, createParentFolder ) { protected ReportProcessor createReportProcessor( OutputStream fout ) throws Exception { PdfOutputProcessor outputProcessor = new PdfOutputProcessor( masterReport.getConfiguration(), fout, masterReport.getResourceManager() ); return new PageableReportProcessor( masterReport, outputProcessor ); } }; assertNotNull( exportTask ); exportTask.run(); assertThat( swingGuiContext.getStatusType(), not( StatusType.ERROR ) ); } }
ObjectUtilities.setClassLoaderSource( ObjectUtilities.CLASS_CONTEXT ); LibLoaderBoot.getInstance().start(); LibFontBoot.getInstance().start(); ClassicEngineBoot.getInstance().start();
public static MasterReport parseLocalReport( final String name, Class<?> context ) throws ResourceException { final URL file = context.getResource( name ); if ( file == null ) { throw new ResourceException( "Unable to locate report '" + name + "' near class " + context ); } final ResourceManager mgr = new ResourceManager(); mgr.registerDefaults(); return (MasterReport) mgr.createDirectly( file, MasterReport.class ).getResource(); }
public static MasterReport parseGoldenSampleReport( final String name ) throws ResourceException { final File file = GoldTestBase.locateGoldenSampleReport( name ); if ( file == null ) { throw new ResourceException( "Unable to locate report '" + name + "' in the golden samples." ); } final ResourceManager mgr = new ResourceManager(); mgr.registerDefaults(); return (MasterReport) mgr.createDirectly( file, MasterReport.class ).getResource(); }