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; }
@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 ) ); }
@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 ) ); } }
public ResourceManager getResourceManager() { if ( resourceManager == null ) { resourceManager = new ResourceManager(); } return resourceManager; }
ElementTypeRegistry() { this.resourceManager = new ResourceManager(); this.backend = new HashMap<String, DefaultElementMetaData>(); this.namespaceMapping = new HashMap<String, String>(); }
public ResourceManager getResourceManager() { if ( resourceManager == null ) { resourceManager = new ResourceManager(); resourceManager.registerDefaults(); } return resourceManager; }
public ImageMap parseFromString( final String imageMapXml ) throws ResourceKeyCreationException, ResourceCreationException, ResourceLoadingException { final ResourceManager resourceManager = new ResourceManager(); final ImageMapXmlResourceFactory resourceFactory = new ImageMapXmlResourceFactory(); final InputSource source = new InputSource(); source.setCharacterStream( new StringReader( imageMapXml ) ); return (ImageMap) resourceFactory.parseDirectly( resourceManager, source, null, Collections.EMPTY_MAP ); } }
public static DocumentBundle getBundle( final File file ) throws ResourceException { if ( file == null ) { throw new NullPointerException(); } final ResourceManager resManager = new ResourceManager(); final Resource directly = resManager.createDirectly( file, DocumentBundle.class ); return (DocumentBundle) directly.getResource(); }
public static ResourceManager getResourceManager( final AbstractReportDefinition reportDefinition ) { ReportDefinition e = reportDefinition.getMasterReport(); if ( e instanceof MasterReport ) { final MasterReport report = (MasterReport) e; return report.getResourceManager(); } return new ResourceManager(); }
public MemoryDocumentBundle( final ResourceKey parent ) { this.zipRepository = new ZipRepository(); this.metaData = new MemoryDocumentMetaData(); final ResourceManager defaultResourceManager = new ResourceManager(); final BundleResourceManagerBackend backend = new BundleResourceManagerBackend( zipRepository, defaultResourceManager.getBackend(), parent ); this.bundleKey = backend.getBundleMainKey(); this.resourceManager = new ResourceManager( defaultResourceManager, backend ); }
private EncodingRegistry() { this.manager = new ResourceManager(); this.manager.registerFactoryCache(); this.manager.registerDataCache(); this.manager.registerDefaultLoaders(); this.manager.registerFactory( new EncodingFactory() ); this.manager.registerFactory( new PropertiesResourceFactory() ); this.encodingsMapping = new HashMap(); this.generatedMapping = new HashMap(); this.fallbackMapping = new HashMap(); this.aliases = new HashMap(); }
public ResourceManager deriveManager( final ResourceManager parent ) throws ResourceLoadingException { return new ResourceManager( parent, new BundleResourceManagerBackend( repository, parent.getBackend(), bundleKey ) ); } }
public DesignTimeDataFactoryContext() { configuration = ClassicEngineBoot.getInstance().getGlobalConfig(); resourceManager = new ResourceManager(); resourceBundleFactory = new DefaultResourceBundleFactory(); formulaContext = new DefaultFormulaContext(); }
public void initialize() { try { final ResourceManager resourceManager = new ResourceManager(); resourceManager.registerDefaults(); final Resource resource = resourceManager.createDirectly( "res://fonts.xml", FontMetricsCollection.class ); this.fontMetricsCollection = (FontMetricsCollection) resource.getResource(); } catch ( ResourceException e ) { throw new IllegalStateException( e ); } }
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(); }
static List<LogicalPageBox> loadPages( String file, int expectedPages ) throws Exception { ResourceManager resourceManager = new ResourceManager(); resourceManager.registerDefaults(); Resource resource = resourceManager .createDirectly( LayoutValidationUtils.class.getResource( "pagination/" + file ), MasterReport.class ); MasterReport report = (MasterReport) resource.getResource(); int[] pages = new int[ expectedPages ]; for ( int i = 0; i < expectedPages; i++ ) { pages[ i ] = i; } return DebugReportRunner.layoutPagesStrict( report, expectedPages, pages ); }
private MasterReport saveAndLoad( final MasterReport originalReport ) throws Exception { final MemoryByteArrayOutputStream bout = new MemoryByteArrayOutputStream(); BundleWriter.writeReportToZipStream( originalReport, bout ); assertTrue( bout.getLength() > 0 ); /* * final File f = File.createTempFile("test-output-", ".prpt", new File ("test-output")); final FileOutputStream * outputStream = new FileOutputStream(f); outputStream.write(bout.toByteArray()); outputStream.close(); */ final ResourceManager mgr = new ResourceManager(); final Resource reportRes = mgr.createDirectly( bout.toByteArray(), MasterReport.class ); return (MasterReport) reportRes.getResource(); }
private InternalParameterContext() { this.resourceManager = new ResourceManager(); dataFactory = new TableDataFactory(); resourceBundleFactory = new DefaultResourceBundleFactory(); configuration = ClassicEngineBoot.getInstance().getGlobalConfig(); documentMetaData = new MemoryDocumentMetaData(); reportEnvironment = new DefaultReportEnvironment( configuration ); final ReportEnvironmentDataRow envDataRow = new ReportEnvironmentDataRow( reportEnvironment ); parameterData = new CompoundDataRow( envDataRow, new ParameterDataRow() ); }
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(); }
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(); }