Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » [SOLVED] How to configure Dataset using DE API(DE API Dataset creation columns specification)
[SOLVED] How to configure Dataset using DE API [message #727573] Wed, 21 September 2011 14:37 Go to next message
Jean-Baptiste Guillois is currently offline Jean-Baptiste GuilloisFriend
Messages: 33
Registered: August 2011
Member
Hello,

I create BIRT reports using the DE API.
Using this API, i can create reports, datasets, tables, pie charts, etc..

I need to be able to configure precisely datasets, that is, not only to specify the SQL query but also the output columns name. In the Designer, this maps to the "Output Columns" tab of the Dataset editor.

How can i do this using the DE API?

Here is the code i currently use to create my datasets:
    StringBuffer query = new StringBuffer();
    query.append("SELECT * FROM MY_TABLE");
    OdaDataSetHandle dataSet = design.getElementFactory().newOdaDataSet("Main_Dataset",
        "org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet");
    dataSet.setDataSource(DATASOURCE_NAME);
    dataSet.setQueryText(query.toString());


Many thanks for your help,

Best Regards,

PS: I am using BIRT 3.7.

[Updated on: Thu, 22 September 2011 11:42]

Report message to a moderator

Re: How to configure Dataset using DE API [message #727645 is a reply to message #727573] Wed, 21 September 2011 18:18 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Try something like:


void buildDataSet3( ) throws SemanticException
{

OdaDataSetHandle dsHandle = designFactory.newOdaDataSet( "dscols",
"org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );
dsHandle.setDataSource( "Data Source" );
String qry = "Select * from orderdetails where ordernumber = ?";

dsHandle.setQueryText( qry );

OdaResultSetColumn column = StructureFactory.createOdaResultSetColumn( );
column.setNativeName( "ORDERNUMBER" );
column.setColumnName( "ORDERNUMBER" );
OdaResultSetColumnHandle columnHandle = (OdaResultSetColumnHandle)
dsHandle
.getPropertyHandle( OdaDataSetHandle.RESULT_SET_PROP ).addItem(
column );

OdaResultSetColumn column2 = StructureFactory.createOdaResultSetColumn( );
column2.setNativeName( "PRODUCTCODE" );
column2.setColumnName( "PRODUCTCODE" );
OdaResultSetColumnHandle columnHandle2 = (OdaResultSetColumnHandle)
dsHandle
.getPropertyHandle( OdaDataSetHandle.RESULT_SET_PROP ).addItem(
column2 );

OdaResultSetColumn column3 = StructureFactory.createOdaResultSetColumn( );
column3.setNativeName( "QUANTITYORDERED" );
column3.setColumnName( "QUANTITYORDERED" );
OdaResultSetColumnHandle columnHandle3 = (OdaResultSetColumnHandle)
dsHandle
.getPropertyHandle( OdaDataSetHandle.RESULT_SET_PROP ).addItem(
column3 );

OdaResultSetColumn column4 = StructureFactory.createOdaResultSetColumn( );
column4.setNativeName( "PRICEEACH" );
column4.setColumnName( "PRICEEACH" );
OdaResultSetColumnHandle columnHandle4 = (OdaResultSetColumnHandle)
dsHandle
.getPropertyHandle( OdaDataSetHandle.RESULT_SET_PROP ).addItem(
column4 );
OdaResultSetColumn column5 = StructureFactory.createOdaResultSetColumn( );
column5.setNativeName( "ORDERLINENUMBER" );
column5.setColumnName( "ORDERLINENUMBER" );
OdaResultSetColumnHandle columnHandle5 = (OdaResultSetColumnHandle)
dsHandle
.getPropertyHandle( OdaDataSetHandle.RESULT_SET_PROP ).addItem(
column5 );
designHandle.getDataSets( ).add( dsHandle );

}


Jason

On 9/21/2011 10:37 AM, jeanbaptiste.guillois wrote:
> Hello,
>
> I create BIRT reports using the DE API.
> Using this API, i can create reports, datasets, tables, pie charts, etc..
>
> I need to be able to configure precisely datasets, that is, not only to
> specify the SQL query but also the output columns name. In the Designer,
> this maps to the "Output Columns" tab of the Dataset editor.
>
> How can i do this using the DE API?
>
> Many thanks for your help,
>
> Best Regards,
>
> PS: I am using BIRT 3.7.
Re: How to configure Dataset using DE API [message #728014 is a reply to message #727645] Thu, 22 September 2011 11:39 Go to previous message
Jean-Baptiste Guillois is currently offline Jean-Baptiste GuilloisFriend
Messages: 33
Registered: August 2011
Member
Thank you Jason for your feedback!

I now have something which is working as expected!

Actually, i now use the following code, create ColumnHint and create also OdaResultSetColumn.

PropertyHandle resultSet = dataSet.getPropertyHandle(OdaDataSetHandle.RESULT_SET_PROP);
    PropertyHandle colHints = dataSet.getPropertyHandle(OdaDataSetHandle.COLUMN_HINTS_PROP);

    OdaResultSetColumn rs = null;
    ColumnHint resultHint = null;
      resultHint = new ColumnHint();
      resultHint.setProperty(ColumnHint.COLUMN_NAME_MEMBER, VALUE);
      resultHint.setProperty(ColumnHint.COLUMN_NAME_MEMBER, "decimal");
      colHints.addItem(resultHint);

      rs = StructureFactory.createOdaResultSetColumn();
      rs.setNativeName(VALUE);
      rs.setColumnName(VALUE);
      rs.setPosition(new Integer(1));
      rs.setDataType("decimal");
      resultSet.addItem(rs);


Thanks again for your help,
Previous Topic:[SOLVED] Problem with OSGI platform (BIRT 3.7 on JBoss AS 6)
Next Topic:How to get input from user?
Goto Forum:
  


Current Time: Sun Dec 21 21:00:42 GMT 2014

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

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