Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Pojo possibilities / limitations
garberfc
<p>Hello,</p><p> </p><p>I'm very new to BIRT so please forgive my lack of knowledge. I've been looking through the tutorials and have been searching the web and finding answers to my questions. But there are still a few things I've yet to find out.</p><p> </p><p>I'm working on an established J2EE web application and we're planning on incorporating BIRT into the mix to provide online reports. We plan to stream PDF data for the user to view, print or save.</p><p> </p><p>We'd like to use pojos and keep as much common code and data manipulation on the server. Using the tutorials and examples on the web I've been able to create a report using pojos as my data source and data set and it's working fine. The report just iterates over the collection of pojo objects calling methods to populate a BIRT table.</p><p> </p><p><em><strong>What I haven't been able to find</strong></em> are examples where pojos can be used for more typical / detailed reports with grouping for example. The examples I have found use the Java Object Data Type, but that seems to lead to a lot of scripting which I'd like to stay away from.</p><p> </p><p>Can someone please point me to an example of using pojos w/ grouping that doesn't rely on a lot of hand coded scripting?</p><p> </p><p>Thanks in advance,</p><p>F</p><p> </p><p> </p>
Find more posts tagged with
Comments
garberfc
<p>In a 6/26/2013 <a data-ipb='nomediaparse' href='
http://www.actuate.com/uk/company/news/press-release/?articleid=24802'>news
release from Acutate</a> they mention "BIRT 4.3 also introduces easy access to JavaScript libraries, [color=#ff0000;]<em><strong>access to POJO (Plain Old Java Object)</strong></em>[/color] data sources...".</p><p> </p><p>Does anyone have a reference to these data sources??</p>
garberfc
<p>Or is the new driver just for the Designer Pro ($$$)?: <a data-ipb='nomediaparse' href='
http://www.actuate.com/products/birt-design/birt-designer-pro/features-benefits/'>http://www.actuate.com/products/birt-design/birt-designer-pro/features-benefits/</a></p>
;
mwilliams
<p>The POJO data source and head.js were added to open-source BIRT in 4.3. You can download BIRT on the "<a data-ipb='nomediaparse' href='
http://www.birt-exchange.org/get-birt/'>Get
BIRT</a>" page and you can read about the new features in this <a data-ipb='nomediaparse' href='
http://www.birt-exchange.org/forum/index.php?/blog/14/entry-494-a-look-at-the-new-features-in-birt-43/'>blog</a>.</p>
;
garberfc
<blockquote class="ipsBlockquote" data-author="mwilliams" data-cid="118821" data-time="1375128969"><div><p>The POJO data source and head.js were added to open-source BIRT in 4.3. You can download BIRT on the "<a data-ipb='nomediaparse' href='
http://www.birt-exchange.org/get-birt/'>Get
BIRT</a>" page and you can read about the new features in this <a data-ipb='nomediaparse' href='
http://www.birt-exchange.org/forum/index.php?/blog/14/entry-494-a-look-at-the-new-features-in-birt-43/'>blog</a>.</p></div></blockquote><p>Thanks
for the info and link...</p>
garberfc
<p>Since my original posting I got quite a bit of code up and running. I'm going to post some of it here so that others may benefit from it. It was all done with BIRT 4.3, Eclipse Kepler, and pojos.</p><p> </p><p><strong>A class for invoking a report from Java:</strong></p><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]package report;[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import java.io.FileOutputStream;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import java.util.Date;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import java.util.logging.Level;[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.apache.commons.io.output.ByteArrayOutputStream;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.core.exception.BirtException;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.core.framework.Platform;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.engine.api.EngineConfig;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.engine.api.EngineException;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.engine.api.HTMLRenderOption;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.engine.api.IReportEngine;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.engine.api.IReportEngineFactory;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.engine.api.IReportRunnable;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.engine.api.IRunAndRenderTask;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.engine.api.PDFRenderOption;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.engine.api.RenderOption;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.core.internal.registry.RegistryProviderFactory;[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]public class ReportRunner1 {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] IReportEngine engine = null;[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] public static void main(String[] args) {[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] ReportRunner1 reportRunner = new ReportRunner1();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] String outputFileSpec = "C:/Temp/OutputFO1.html";[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] String inputDesignFileSpec = "C:/_Workplace43/JavaProj-Birt/dynamic.rptdesign";[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]// String inputDesignFileSpec = "C:/_Workplace43/JavaProj-Birt/Pojo1.rptdesign";[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] String renderOptionType = HTMLRenderOption.OUTPUT_FORMAT_HTML; // "pdf"[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] reportRunner.create(outputFileSpec, inputDesignFileSpec, renderOptionType);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] } // of main[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] public void create(String outputFileSpec, String inputDesignFileSpec, String renderOptionType) {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] System.out.println("Top of create: " + new Date());[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] try {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] setupReportEngine();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] // The output stream can be written to a file or streamed to a viewer[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] ByteArrayOutputStream outputStream = new ByteArrayOutputStream(10 * 1024);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] RenderOption renderOption = null;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] if (HTMLRenderOption.OUTPUT_FORMAT_HTML.equals(renderOptionType)) {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] HTMLRenderOption htmlRenderOption = new HTMLRenderOption();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] htmlRenderOption.setOutputFormat(renderOptionType);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] renderOption = htmlRenderOption;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] } else if ("pdf".equals(renderOptionType)){[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] PDFRenderOption pdfRenderOption = new PDFRenderOption();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] pdfRenderOption.setOutputFormat("pdf");[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] renderOption = pdfRenderOption;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] }[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] // Set generic options[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] renderOption.setOutputStream(outputStream);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] generateReport(inputDesignFileSpec, renderOption);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] byte[] byteArray = outputStream.toByteArray();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]// System.out.println("Size of byteArray: " + byteArray.length);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]// System.out.println(outputStream.toString());[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] // Dump the output to a file[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] FileOutputStream fileOutputStream = new FileOutputStream(outputFileSpec, false);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] fileOutputStream.write(byteArray);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] fileOutputStream.close();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] tearDownReportEngine();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] } catch (Exception e) {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] e.printStackTrace();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] }[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] System.out.println("Done with create: " + new Date());[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] }[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] protected void setupReportEngine() throws BirtException {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] EngineConfig config = new EngineConfig();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] config.setLogConfig("C:/temp", Level.INFO);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] config.setEngineHome("C:/java/birt-runtime-4_3_0/ReportEngine");[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] Platform.startup(config); [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] engine = factory.createReportEngine(config);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] }[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] protected void tearDownReportEngine() {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] System.out.println("Start tear down. " + new Date());[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] if (engine != null) {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] engine.destroy();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] }[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] Platform.shutdown();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] RegistryProviderFactory.releaseDefault();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] System.out.println("Done with tear down. " + new Date());[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] }[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] protected void generateReport(String reportDesignPath, RenderOption renderOption) throws EngineException {[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] IReportRunnable report = engine.openReportDesign(reportDesignPath);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] IRunAndRenderTask task = engine.createRunAndRenderTask(report); [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] task.setRenderOption(renderOption);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] task.run();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] task.close();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] }[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]} // of class[/font]</span></div>
garberfc
<p><strong>Open a 'blank' report and add a table filled w/ pojo data:</strong></p><p> </p><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]package report;[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import java.io.IOException;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import java.util.ArrayList;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import java.util.List;[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.core.framework.Platform;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.model.api.CellHandle;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.model.api.DataItemHandle;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.model.api.DesignConfig;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.model.api.ElementFactory;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.model.api.IDesignEngine;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.model.api.IDesignEngineFactory;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.model.api.LabelHandle;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.model.api.OdaDataSetHandle;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.model.api.OdaDataSourceHandle;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.model.api.PropertyHandle;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.model.api.ReportDesignHandle;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.model.api.RowHandle;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.model.api.SessionHandle;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.model.api.StructureFactory;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.model.api.TableHandle;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.model.api.activity.SemanticException;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import org.eclipse.birt.report.model.api.elements.structures.ComputedColumn;[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]import com.ibm.icu.util.ULocale;[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]/**[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] * Dynamic Table BIRT Design Engine API (DEAPI) demo. <a data-ipb='nomediaparse' href='
http://wiki.eclipse.org/Java_-_Build_Dynamic_Table_(BIRT)#Source'>http://wiki.eclipse.org/Java_-_Build_Dynamic_Table_(BIRT)#Source</a>[/font]</span></div><div><span
style="font-size:12px;">[font="'courier new', courier, monospace;"] */[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]public class CreateDynamicTable {[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] ReportDesignHandle designHandle = null;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] ElementFactory designFactory = null;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] StructureFactory structFactory = null;[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] public static void main(String[] args) {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] try {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] CreateDynamicTable de = new CreateDynamicTable();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] List<String> al = new ArrayList<String>();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] al.add("Name");[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] al.add("Rank");[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] al.add("SerialNumber");[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] de.buildReport(al, "From Offices");[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] } catch (Exception e) {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] e.printStackTrace();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] }[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] }[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] /**[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] * Generates:[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] * <ColumnMapping index="1" name="City" odaDataType="String">[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] * <Method name="getCity"/>[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] * </ColumnMapping>[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] */[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] protected static String getColumnMapping(String colName, String colType, int index) {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] return "<ColumnMapping index="" + index + "" name="" + colName + "" odaDataType="" + colType + "">" + [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] "<Method name="get" + colName + ""/></ColumnMapping>";[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] }[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] void buildDataSource() throws SemanticException {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] OdaDataSourceHandle dsHandle = designFactory.newOdaDataSource("Data Source", "org.eclipse.birt.data.oda.pojo");[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] dsHandle.setProperty("pojoDataSetClassPath", "C:/_Workplace43/JavaProj-Birt/bin/JavaProj-Birt.jar;" );[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] dsHandle.setPrivateDriverProperty("pojoClassPath", "C:/_Workplace43/JavaProj-Birt/bin/JavaProj-Birt.jar;");[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] designHandle.getDataSources().add(dsHandle);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] }[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] protected String getQueryPrefix(String dataSource) {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] /* <?xml version="1.0" encoding="UTF-8" standalone="no"?>[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] <PojoQuery appContextKey="APP_CONTEXT_KEY_POJO_DATA_SET" dataSetClass="pojo.Pojo1DaoMock" version="1.0">[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] *[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] */[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] return "<?xml version="1.0" encoding="UTF-8" standalone="no"?>" +[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] "<PojoQuery appContextKey="APP_CONTEXT_KEY_POJO_DATA_SET" dataSetClass="pojo.Pojo1DaoMock" version="1.0">";[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] }[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] void buildDataSet(List<String> cols, String fromClause)[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] throws SemanticException {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] OdaDataSetHandle dsHandle = designFactory.newOdaDataSet("ds", "org.eclipse.birt.data.oda.pojo.dataSet");[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] dsHandle.setDataSource("Data Source");[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] dsHandle.setPrivateDriverProperty("methodNameRegx", "get*");[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] dsHandle.setPrivateDriverProperty("pojoClass", "pojo.Pojo1");[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] String qry = getQueryPrefix(null);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] for (int i = 0; i < cols.size(); i++) {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] qry += getColumnMapping(cols.get(i), "String", i + 1);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] }[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] // Add the suffix[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] qry += "</PojoQuery>";[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] System.out.println("qry=" + qry);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] dsHandle.setQueryText(qry);[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] designHandle.getDataSets().add(dsHandle);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] }[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] void buildReport(List<String> cols, String fromClause) throws IOException,[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] SemanticException {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] // Configure the Engine and start the Platform[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] DesignConfig config = new DesignConfig();[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] config.setProperty("BIRT_HOME", "C:/java/birt-runtime-4_3_0/ReportEngine");[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] IDesignEngine engine = null;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] try {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] Platform.startup(config);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] IDesignEngineFactory factory = (IDesignEngineFactory) Platform.createFactoryObject(IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] engine = factory.createDesignEngine(config);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] } catch (Exception ex) {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] ex.printStackTrace();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] }[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] SessionHandle session = engine.newSessionHandle(ULocale.ENGLISH);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] try {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] // open a design or a template[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] designHandle = session.openDesign("C:/_Workplace43/JavaProj-Birt/blankTemplate.rptdesign");[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] designFactory = designHandle.getElementFactory();[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] buildDataSource();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] buildDataSet(cols, fromClause);[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] TableHandle table = designFactory[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] .newTableItem("table", cols.size());[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] table.setWidth("100%");[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] table.setDataSet(designHandle.findDataSet("ds"));[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] PropertyHandle computedSet = table.getColumnBindings();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] ComputedColumn cs1 = null;[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] for (int i = 0; i < cols.size(); i++) {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] cs1 = StructureFactory.createComputedColumn();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] cs1.setName((String) cols.get(i));[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] cs1.setExpression("dataSetRow["" + (String) cols.get(i)[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] + ""]");[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] computedSet.addItem(cs1);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] }[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] // table header[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] RowHandle tableheader = (RowHandle) table.getHeader().get(0);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] for (int i = 0; i < cols.size(); i++) {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] LabelHandle label1 = designFactory.newLabel((String) cols.get(i));[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] label1.setText((String) cols.get(i));[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] CellHandle cell = (CellHandle) tableheader.getCells().get(i);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] cell.getContent().add(label1);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] }[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] // table detail[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] RowHandle tabledetail = (RowHandle) table.getDetail().get(0);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] for (int i = 0; i < cols.size(); i++) {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] CellHandle cell = (CellHandle) tabledetail.getCells().get(i);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] DataItemHandle data = designFactory.newDataItem("data_" + (String) cols.get(i));[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] data.setResultSetColumn((String) cols.get(i));[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] cell.getContent().add(data);[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] }[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] designHandle.getBody().add(table);[/font]</span></div><div> </div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] // Save the design and close it.[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] designHandle.saveAs("C:/_Workplace43/JavaProj-Birt/dynamic.rptdesign"); [/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] designHandle.close();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] System.out.println("Finished");[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] } catch (Exception e) {[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] e.printStackTrace();[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] }[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"] }[/font]</span></div><div><span style="font-size:12px;">[font="'courier new', courier, monospace;"]}[/font]</span></div>
mwilliams
<p>Thanks for the update! Glad it's working for you!</p>