4

I have an environment where I dynamically assemble BIRT ReportDesigns using components in ReportLibraries. These ReportLibraries are stored in a Database, and are not to be found anywhere on the file system.

What I am trying to do is to open a Library in a Session, giving the Library a name, and an InputStream (FileInputStream from a test resource)

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

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

Then I create a ReportDesign and include the Library (by name?)

    ReportDesignHandle reportDesign = session.createDesign();

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

Later I would search for a Table Element in the Library and try to copy that to the Design:

    ElementFactory elementFactory = reportDesign.getElementFactory();

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

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

At this point I would get the following Exception:

 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)

It seems like the Library is found and the DesignElementHandle is indeed pointing to the component that I want to copy into the Design, but the Library opened in the session cannot be found by the ReportDesign.

Is there any way to tell the ReportDesign to include the Library from a non-FileSystem resource, or to include the Library from the Session, since it has the same name?

I want to avoid having to put rptlibrary Files on my FielSystem to assemble a ReportDesign at all costs.

Cœur
  • 37,241
  • 25
  • 195
  • 267
mwhs
  • 5,878
  • 2
  • 28
  • 34
  • I cannot answer your question, but the idea of your environment sounds very interesting. Is there any public information about it? – hvb Jan 13 '15 at 07:18
  • @hvb Unfortunately I cannot make public much more than what I wrote here. Is there anything specific that you would like to know about the project? – mwhs Jan 13 '15 at 09:04
  • It's just because it sounds similar to an idea I have, but lack the resources to implement: Let power-users in a DB app create reports from assembling predefined components; all of which are stored in the DB (including version control, rights management etc). – hvb Jan 15 '15 at 07:36

1 Answers1

1

I have not tested it by I think your Report needs to include the Library first, before you can try to get element Handles inside the report out of the Library.

includeLibrary(filename, namespace) the function can only be used to load a library from the file system. So I think you have to create a temporary file from the content of your database, but you can delete it after creating your report.

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

ElementFactory elementFactory = reportDesign.getElementFactory();

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

DesignElementHandle ldeh1 = elementFactory.newElementFrom(deh1, "newTable");
Simulant
  • 19,190
  • 8
  • 63
  • 98