Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Design ideas, using BIRT only as viewer ?(Use BIRT on top of a query function only for report-viewing and pdf-rendering, not dw-access, authoring etc)
Design ideas, using BIRT only as viewer ? [message #560090] Tue, 21 September 2010 07:49 Go to next message
jerome k is currently offline jerome kFriend
Messages: 5
Registered: September 2010
Junior Member
We have built a quite successful query function to a production system that primarily returns fully drillable tables, almost like pivottables.

Select page/row/value-fields, prompts, subtotals, getting the dw-data by SQL, authority issues per user etc works real fine, but we want to add a report version för nicer formatting, PDF's, emailing/printing/scheduling (or just on the fly switching to "report mode"). This mode should expand drillable fields.

Our query table classes are easy to convert to XML-data. Is it a good idea to use BIRT to read the XML-data and process a report with the viewer ? Since there are unlimited different queries (and the dw-model are different for all customers and concurrently changing ! ) that can be changed anytime the XML-data as well as the report XML including the data sets must be built and passed on the fly.

So: Is it possible AND a good idea to temporary pass XML-data and a matching XML report descriptions to BIRT viewer for rendering ?

Or should we build our own formatting/style sheets and PDF rendering etc ?


Re: Design ideas, using BIRT only as viewer ? [message #560221 is a reply to message #560090] Tue, 21 September 2010 15:20 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

This definitely possible. You have a couple of choices. You can use the de api to create the report on the fly from a custom jsp/servlet and then forward to the viewer or use the re api in a servlet and call the de api from the re api to create the report on the fly all in the same servlet. Another option is to call the de api in the beforeFactory script of a blank report to create the entire report on the fly in the viewer. I am attaching some simple de api code to show you how to create the report. Note that the birt platform should only be started once for the life of the app. The example just starts and stops it everytime.


package DEAPI;

import org.eclipse.birt.core.framework.Platform;
import ;
import ants;
import edColumn;
import ry;
import mModel;
import l;


public class XMLReport

ReportDesignHandle reportDesignHandle = null;

ElementFactory elementFactory = null;

IMetaDataDictionary dict = null;

ComputedColumn cs1, cs2, cs3 = null;

public static void main( String[] args ) throws SemanticException,
new XMLReport( ).createReport( );

void createReport( ) throws SemanticException, IOException
//Configure the Engine and start the Platform
DesignConfig config = new DesignConfig( );

config.setBIRTHome("C:/birt/birt-runtime-2_5_1/birt-runtime-2_5_1/ReportEngine ");
IDesignEngine engine = null;

Platform.startup( config );
IDesignEngineFactory factory = (IDesignEngineFactory) Platform
engine = factory.createDesignEngine( config );

}catch( Exception ex){

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

// Create a new report
reportDesignHandle = session.createDesign( );

// Element factory is used to create instances of BIRT elements.
elementFactory = reportDesignHandle.getElementFactory( );

dict = new DesignEngine( null ).getMetaData( );

createMasterPages( );
createDataSources( );
createDataSets( );
createBody( );

//OdaDataSourceHandle dataSourceHandle = (OdaDataSourceHandle)reportDesignHandle.findDataSource("myxmldatasource ");

String outputPath = "output";//$NON-NLS-1$
File outputFolder = new File( outputPath );
if ( !outputFolder.exists( ) && !outputFolder.mkdir( ) )
throw new IOException( "Can not create the output folder" );//$NON-NLS-1$
reportDesignHandle.saveAs( "output/desample/XMLReport.rptdesign" );//$NON-NLS-1$//$NON-NLS-2$

private void createDataSources( ) throws SemanticException
OdaDataSourceHandle dataSourceHandle =
elementFactory.newOdaDataSource("Data Source",
dataSourceHandle.setProperty("FILELIST", "C:/temp/xmltest2.xml");
reportDesignHandle.getDataSources( ).add( dataSourceHandle );

private void createDataSets( ) throws SemanticException
// Data Set

OdaDataSetHandle dsHandle = elementFactory.newOdaDataSet( "Data Set",
"" );
dsHandle.setDataSource( "Data Source" );
" table0#-TNAME-#table0#:#[/people/person/name]#:#{name;String ;} " );

reportDesignHandle.getDataSets( ).add( dsHandle );


private void createMasterPages( ) throws ContentException, NameException
DesignElementHandle simpleMasterPage =
elementFactory.newSimpleMasterPage( "Master Page" );//$NON-NLS-1$
reportDesignHandle.getMasterPages( ).add( simpleMasterPage );

private void createBody( ) throws SemanticException

TableHandle table = elementFactory.newTableItem( null, 3, 1, 1, 1 );
table.setProperty( IStyleModel.TEXT_ALIGN_PROP,
DesignChoiceConstants.TEXT_ALIGN_CENTER );
table.setWidth( "80%" );//$NON-NLS-1$
table.setProperty( IReportItemModel.DATA_SET_PROP, "Data Set" );//$NON-NLS-1$

PropertyHandle computedSet = table.getColumnBindings( );
cs1 = StructureFactory.createComputedColumn( );

cs1.setExpression( "dataSetRow[\"name\"]" );//$NON-NLS-1$
computedSet.addItem( cs1 );

// Header
RowHandle header = (RowHandle) table.getHeader( ).get( 0 );

CellHandle tcell = (CellHandle) header.getCells( ).get( 0 );
LabelHandle label = elementFactory.newLabel( null );
label.setText( "Name" );//$NON-NLS-1$
tcell.getContent( ).add( label );

DataItemHandle data = null;
// Detail
RowHandle detail = (RowHandle) table.getDetail( ).get( 0 );
tcell = (CellHandle) detail.getCells( ).get( 0 );
data = elementFactory.newDataItem( null );
data.setResultSetColumn( cs1.getName( ) );
tcell.getContent( ).add( data );

reportDesignHandle.getBody( ).add( table );


Previous Topic:Help with external css
Next Topic:Page number always 1 in the masterpage of the report generated by program
Goto Forum:

Current Time: Sat Jun 23 20:04:39 GMT 2018

Powered by FUDForum. Page generated in 0.01584 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top