本文整理汇总了Java中org.pentaho.reporting.libraries.resourceloader.ResourceManager类的典型用法代码示例。如果您正苦于以下问题:Java ResourceManager类的具体用法?Java ResourceManager怎么用?Java ResourceManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResourceManager类属于org.pentaho.reporting.libraries.resourceloader包,在下文中一共展示了ResourceManager类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSaveAndLoad
import org.pentaho.reporting.libraries.resourceloader.ResourceManager; //导入依赖的package包/类
public void testSaveAndLoad() throws Exception
{
MasterReport report = new MasterReport();
report.getReportHeader().addElement(createElement());
ByteArrayOutputStream bout = new ByteArrayOutputStream();
BundleWriter.writeReportToZipStream(report, bout);
ResourceManager mgr = new ResourceManager();
MasterReport loadedReport = (MasterReport) mgr.createDirectly(bout.toByteArray(), MasterReport.class).getResource();
assertEquals(1, loadedReport.getReportHeader().getElementCount());
Element element = loadedReport.getReportHeader().getElement(0);
assertTrue(element.getElementType() instanceof SampleTextElementType);
assertEquals("Test message for validation: {0}",
element.getAttribute(SampleElementModule.NAMESPACE, SampleTextElementType.TEMPLATE_STRING));
runAndValidateReport(loadedReport);
}
示例2: doPost
import org.pentaho.reporting.libraries.resourceloader.ResourceManager; //导入依赖的package包/类
@Override
public void doPost(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
try {
// Getting the report.
ResourceManager manager = new ResourceManager();
manager.registerDefaults();
Resource res = manager.createDirectly(
new URL("file:resources/interactive_report_2.prpt"),
MasterReport.class);
MasterReport report = (MasterReport) res.getResource();
// Mandatory parameter.
report.getParameterValues().put("LINE", request.getParameter("line"));
// Conversion to HTML and rendering.
response.setContentType("text/html");
HtmlReportUtil.createStreamHTML(report, response.getOutputStream());
}
catch (Exception e)
{
e.printStackTrace();
}
}
示例3: testPrptSetMasterReport
import org.pentaho.reporting.libraries.resourceloader.ResourceManager; //导入依赖的package包/类
@Test
public void testPrptSetMasterReport() throws Exception{
if(ClassicEngineBoot.getInstance().isBootDone() == false){
ClassicEngineBoot engineBoot = ClassicEngineBoot.getInstance();
engineBoot.start();
}
SwtXulLoader loader = new SwtXulLoader();
loader.register("PRPT", PrptViewerTag.class.getCanonicalName());
XulDomContainer container = loader.loadXul("org/pentaho/agilebi/test/res/prpt.xul");
PrptViewerTag prpt = (PrptViewerTag) container.getDocumentRoot().getElementById("prptViewer");
ResourceManager theResourceManager = new ResourceManager();
theResourceManager.registerDefaults();
File theReportFile = new File("test-res/test.prpt");
Resource theResource = theResourceManager.createDirectly(theReportFile, MasterReport.class);
MasterReport masterReport = (MasterReport) theResource.getResource();
prpt.setMasterReport(masterReport);
}
示例4: testSaveAndLoad
import org.pentaho.reporting.libraries.resourceloader.ResourceManager; //导入依赖的package包/类
public void testSaveAndLoad() throws Exception
{
MasterReport report = new MasterReport();
report.getReportHeader().addElement(createElement());
ByteArrayOutputStream bout = new ByteArrayOutputStream();
BundleWriter.writeReportToZipStream(report, bout);
ResourceManager mgr = new ResourceManager();
MasterReport loadedReport = (MasterReport) mgr.createDirectly(bout.toByteArray(), MasterReport.class).getResource();
assertEquals(1, loadedReport.getReportHeader().getElementCount());
Element element = loadedReport.getReportHeader().getElement(0);
assertTrue(element.getElementType() instanceof SampleGraphicsElementType);
assertEquals("Test message for validation: {0}",
element.getAttribute(SampleElementModule.NAMESPACE, SampleGraphicsElementType.TEMPLATE_STRING));
assertEquals(0.5f,element.getStyle().getStyleProperty(SampleElementStyleKeys.IMAGE_BACKGROUND_ALPHA));
runAndValidateReport(loadedReport);
}
示例5: doPost
import org.pentaho.reporting.libraries.resourceloader.ResourceManager; //导入依赖的package包/类
@Override
public void doPost(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
try {
// Getting the report.
ResourceManager manager = new ResourceManager();
manager.registerDefaults();
Resource res = manager.createDirectly(
new URL("file:resources/interactive_report_1.prpt"),
MasterReport.class);
MasterReport report = (MasterReport) res.getResource();
// Conversion to HTML and rendering.
response.setContentType("text/html");
HtmlReportUtil.createStreamHTML(report, response.getOutputStream());
}
catch (Exception e)
{
e.printStackTrace();
}
}
示例6: doPost
import org.pentaho.reporting.libraries.resourceloader.ResourceManager; //导入依赖的package包/类
@Override
public void doPost(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
// Prpt file.
String reportPath = "file:" + this.getServletContext().getRealPath("WEB-INF/classes/reports/my_first_report.prpt");
try
{
// Resource manager.
ResourceManager manager = new ResourceManager();
manager.registerDefaults();
// Get report.
Resource res = manager.createDirectly(new URL(reportPath), MasterReport.class);
MasterReport report = (MasterReport) res.getResource();
// Generate report in PDF into the response.
response.setContentType("application/pdf");
PdfReportUtil.createPDF(report, response.getOutputStream());
}
catch (Exception e)
{
e.printStackTrace();
}
}
示例7: loadMasterReport
import org.pentaho.reporting.libraries.resourceloader.ResourceManager; //导入依赖的package包/类
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;
}
示例8: loadMasterReport
import org.pentaho.reporting.libraries.resourceloader.ResourceManager; //导入依赖的package包/类
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;
}
示例9: getReferencedResources
import org.pentaho.reporting.libraries.resourceloader.ResourceManager; //导入依赖的package包/类
public ResourceReference[] getReferencedResources(final DataFactoryMetaData dataFactoryMetaData,
final DataFactory dataFactory,
final ResourceManager resourceManager,
final String query,
final DataRow dataRow)
{
return new ResourceReference[0];
}
示例10: open
import org.pentaho.reporting.libraries.resourceloader.ResourceManager; //导入依赖的package包/类
public boolean open(Node transNode, String fname, boolean importfile) {
try {
if(ClassicEngineBoot.getInstance().isBootDone() == false){
ObjectUtilities.setClassLoader(getClass().getClassLoader());
ObjectUtilities.setClassLoaderSource(ObjectUtilities.CLASS_CONTEXT);
LibLoaderBoot.getInstance().start();
LibFontBoot.getInstance().start();
ClassicEngineBoot.getInstance().start();
}
ResourceManager theResourceManager = new ResourceManager();
theResourceManager.registerDefaults();
File theReportFile = new File(fname);
Resource theResource = theResourceManager.createDirectly(theReportFile, MasterReport.class);
MasterReport masterReport = (MasterReport) theResource.getResource();
XulTabAndPanel tabAndPanel = AgileBiVisualizationPerspective.getInstance().createTab();
AgileBiVisualizationPerspective.getInstance().setNameForTab(tabAndPanel.tab, getPathAndFilename(fname)[1].replace(".prpt", "")); //$NON-NLS-1$ //$NON-NLS-2$
SpoonPerspectiveManager.getInstance().activatePerspective(AgileBiVisualizationPerspective.class);
SwtXulLoader theXulLoader = new SwtXulLoader();
theXulLoader.registerClassLoader(getClass().getClassLoader());
theXulLoader.register("PRPT", "org.pentaho.agilebi.spoon.visualizations.xul.PrptViewerTag"); //$NON-NLS-1$ //$NON-NLS-2$
XulDomContainer theXulContainer = theXulLoader.loadXul("org/pentaho/agilebi/spoon/visualizations/prpt/prptVisualization.xul", new PDIMessages(IVisualization.class)); //$NON-NLS-1$
PRPTMeta meta = new PRPTMeta();
meta.setTab(tabAndPanel.tab);
AgileBiVisualizationPerspective.getInstance().setMetaForTab(tabAndPanel.tab, meta);
PRPTVisualizationController controller = new PRPTVisualizationController(meta, masterReport);
controller.setFileName(fname);
controller.setDirty(false);
PmdDataFactory theDataFactory = (PmdDataFactory) masterReport.getDataFactory();
String theXmiFile = theDataFactory.getXmiFile();
ModelerWorkspace model = new ModelerWorkspace(new SpoonModelerWorkspaceHelper(), SpoonModelerWorkspaceHelper.initGeoContext());
XmiParser parser = new XmiParser();
FileInputStream inputStream = new FileInputStream(new File(theXmiFile));
Domain domain = parser.parseXmi(inputStream);
inputStream.close();
LogicalModel logical = domain.getLogicalModels().get(0);
Object property = logical.getProperty("source_type"); //$NON-NLS-1$
if( property != null ) {
IModelerSource theSource = ModelerSourceFactory.generateSource(property.toString());
theSource.initialize(domain);
model.setModelSource(theSource);
}
model.setDomain(domain);
model.setModelName(domain.getId());
model.setFileName(theXmiFile);
model.setTemporary(false);
controller.setModel(model);
theXulContainer.addEventHandler(controller);
Composite theMainBox = (Composite) theXulContainer.getDocumentRoot().getElementById("mainContainer").getManagedObject(); //$NON-NLS-1$
SwtXulRunner theRunner = new SwtXulRunner();
theRunner.addContainer(theXulContainer);
theRunner.initialize();
theMainBox.setParent((Composite) tabAndPanel.panel.getManagedObject());
((Composite) tabAndPanel.panel.getManagedObject()).layout(true);
AgileBiVisualizationPerspective.getInstance().setSelectedMeta(meta);
return true;
} catch(Exception e){
e.printStackTrace();
}
return false;
}
示例11: main
import org.pentaho.reporting.libraries.resourceloader.ResourceManager; //导入依赖的package包/类
public static void main(String[] args)
{
try
{
// Initialize the reporting engine. The reporting engine wont work without it.
// You have to do that only once before you first use any functionality or class
// of the reporting engine. If you don't, errors will happen.
ClassicEngineBoot.getInstance().start();
// Locate the report file
final URL url = UseReportingGui.class.getResource("sdk-sample-report.prpt");
// and use a resource-manager to load it. Pentaho Reporting loads all
// its resources via the resource-manager. This manager will cache resources
// for you and will invalidate the cache when the resources changed on disk.
final ResourceManager mgr = new ResourceManager();
// The master-report object is the actual report definition.
final MasterReport report = (MasterReport) mgr.createDirectly(url, MasterReport.class).getResource();
// Bring up the preview-dialog. We have to do this on the AWT-event-dispatcher thread
// or all sorts of strange errors can happen.
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
final PreviewDialog d = new PreviewDialog(report);
d.pack();
d.setModal(true);
LibSwingUtil.centerFrameOnScreen(d);
d.setVisible(true);
System.exit(0);
}
});
}
catch (ResourceException e)
{
System.err.println("Failed to load the report");
e.printStackTrace(System.err);
}
}
示例12: processReport
import org.pentaho.reporting.libraries.resourceloader.ResourceManager; //导入依赖的package包/类
private static void processReport(String sourceText, String targetText)
throws ResourceException, IOException, BundleWriterException, ContentIOException {
File sourceFile = new File(sourceText);
MasterReport report = (MasterReport) new ResourceManager().createDirectly(sourceFile, MasterReport.class).getResource();
MasterReport processedReport = manipulateReport(report);
BundleWriter.writeReportToZipFile(report, new File(targetText));
}