2015-01-12 124 views
3

我有一个使用ReportLibraries中的组件动态组合BIRT ReportDesigns的环境。这些ReportLibraries存储在数据库中,不会在文件系统的任何位置找到。将BIRT库引入InputStream报告(BIRT DEAPI)

我所试图做的是在一个会话打开一个图书馆,让图书馆的名称,(从测试资源的FileInputStream)的InputStream

SessionHandle session = de.newSessionHandle(ULocale.ENGLISH); 

    LibraryHandle library = session.openLibrary("lib01.rptlibrary", is); 

然后,我创建一个ReportDesign和包括库(由名字?)

ReportDesignHandle reportDesign = session.createDesign(); 

    reportDesign.includeLibrary("lib01.rptlibrary", "lib01"); 

后来我就在库中搜索表元素,并尝试复制到设计:

ElementFactory elementFactory = reportDesign.getElementFactory(); 

    DesignElementHandle deh1 = library.findElement("NewTable"); 

    DesignElementHandle ldeh1 = elementFactory.newElementFrom(deh1, "newTable"); 

在这一点上,我会得到以下异常:

org.eclipse.birt.report.model.api.command.InvalidParentException: The library for the parent element "Table("NewTable")" is not included. 
at org.eclipse.birt.report.model.api.ElementFactoryImpl.newElementFrom(ElementFactoryImpl.java:968) 
at org.eclipse.birt.report.model.api.ElementFactory.newElementFrom(ElementFactory.java:1) 

好像图书馆被发现,DesignElementHandle确实指向,我想复制到设计中的组成部分,但在库中打开ReportDesign无法找到该会话。

有什么办法可以告诉ReportDesign从非FileSystem资源中包含Library,或者从Session中包含Library,因为它具有相同的名称?

我想避免必须将我的FielSystem上的rptlibrary文件不惜一切代价组装ReportDesign。

+0

我不能回答你的问题,但你的环境的想法听起来很有趣。有没有关于它的公开信息? – hvb

+0

@hvb不幸的是,我无法公开比我在这里写的更多。有什么具体的,你想知道这个项目? – mwhs

+0

这只是因为它听起来与我有的想法相似,但缺乏实现的资源:让数据库应用程序中的高级用户通过组装预定义组件创建报告;所有这些都存储在数据库中(包括版本控制,权限管理等)。 – hvb

回答

1

我还没有测试过,我认为你的报告需要首先包含库,然后才能尝试从报告库中获取报告中的元素句柄。

includeLibrary(filename, namespace)该函数只能用于从文件系统加载库。所以我认为你必须从数据库的内容创建一个临时文件,但是你可以在创建报告后删除它。

//add this 
reportDesign.includeLibrary(filename, namespace); 

ElementFactory elementFactory = reportDesign.getElementFactory(); 

DesignElementHandle deh1 = library.findElement("NewTable"); 

DesignElementHandle ldeh1 = elementFactory.newElementFrom(deh1, "newTable");