Wednesday, October 19, 2005

BIRT Examples

We are currently in the process of revising the examples section of the BIRT site.
Take a look and let us know what you think. This list of examples will grow, so any suggestions or submissions are appreciated.

134 comments:

Anonymous said...

The URL is wrong, "http://" appears twice. Firefox fails to resolve the "http" address name, so it does a google search and opens the first hit for "http", which is www.microsoft.com!

Jason Weathersby said...

Thanks, should be fixed now.

Anonymous said...

More charting examples! The chart engine in BIRT is super cool on its own, but there is a lack of examples on how to use it.

Anonymous said...

I'm looking for an example to dynamically assign db connection instead of using the connection info in .rtpdesign. The thread
http://www.birt-exchange.com/modules/
vbulletin/showthread.php?mode=hybrid&t=1348 Mr Weathersby has mentioned about an example in birtworld.blogspot.com; however, I wasn't able to find it. Can you provide the link or tell me how I can search it on the website or put the example here?

Jason Weathersby said...

Selene

BIRT supports connection pooling with JNDI. If this does not meet your needs look at:
http://birtworld.blogspot.com/2007/01/birt-connection-pooling-continued.html
and
http://birtworld.blogspot.com/2005/12/using-supplied-connection-with-birt.html

Anonymous said...

Thanks so much for your quick response. Sorry, I'm a new BIRT user. You mentioned that BIRT supports connection pooling with JNDI. I couldn't find this topic in Integrating and Extending BIRT book. Can you point me where I can get more info about it?

Jason Weathersby said...

http://wiki.eclipse.org/BIRT/FAQ/Deployment#Q:_How_do_I_setup_BIRT_to_use_Tomcat_Connection_Pooling

Jason Weathersby said...

http://wiki.eclipse.org/BIRT/FAQ/Deployment

Q:_How_do_I_setup_BIRT_to_use_Tomcat_Connection_Pooling

Anonymous said...

Thanks for the information. I looked into "How do I setup BIRT to use Tomcat Connection Pooling" and tried to do the same but configured it to use Weblogic connection pool. I'm running into an error which I had posted on eclipse newsgroup:
http://www.eclipse.org/newsportal/
article.php?id=25778&
group=eclipse.birt#25778

But that's not exactly what I'm looking for anyway. I need BIRT viewer to read data from different database based on who logs in. I looked into the other links you provided and I got confused. Do I need to develop an eclipse plug-in?
Following the instructions, many terms are new to me. Any help is appreciated. Many thanks!

Jason Weathersby said...

Selene,

You can use either scripting or property binding to do that. Are you wanting to change the db or the username based on the logged in user? Where do you store the username in session?

Anonymous said...

Can you explain further how I can use scripting or property binding to do it? Here is what we need. For example, our company has 3 big branches, they're separated, nothing is shared. Based on who log onto the reporting system (login name), we will map to the person's data resource. So, basically, when the person logs in, data source information is available.

Jason Weathersby said...

Selene,

Take a look at this example:
http://www.eclipse.org/birt/phoenix/examples/reports/birt2.1/querymod/index.php

If you use the scripting method, you could get the user name from a session variable and callout to some external Java class that you write to lookup the data source for the particular user.

Jason

Jason Weathersby said...

http://www.eclipse.org/birt/phoenix/examples/
reports/birt2.1/querymod/index.php

Anonymous said...

Thanks Jason. I can see why you suggested scripting method and property binding now. However, I'm afraid those could not fit in perfectly. I read a web page about "Application Context Object pushed to Web Viewer".
http://www.eclipse.org/birt/phoenix
/project/notable2.2.php#jump_23
It mentioned that 2.2 release supports passing in the context object from an existing Servlet/JSP page. I'm wondering if I can pass in the connection object on a jsp page like what you did in "BIRT Connection Pooling Continued" on RE API. I'm not using RE API, I deployed the BIRT report viewer to a J2EE container.

Jason Weathersby said...

I have not tried it, but it should be possible. I believe there is a bug in the latest release on using this method, but it should be fixed in the 2.3 nightly build.

Anonymous said...

I changed a jsp file to passing in the context object as mentioned in "Application Context Object pushed to Web Viewer", and I added the plugin org.eclipse.birt.report.data.testjdbc in the plugins directory (i.e. WEB-INF\platform\plugins); however, nothing happened. I didn't see MyOdbcDriver was being used. You have mentioned in one of your comments that "If the bridge plugin is in the plugins directory it will intercept all jdbc calls..." Am I missing some steps? Thanks!

Jason Weathersby said...

Selene,

Can you run a standard report that uses JDBC and put logging in the bridge plugin to see if it is being called?

Jason

Anonymous said...

That was what I did but nothing was logged. Thanks!

Jason Weathersby said...

Selene,

What directory did you put the bridge plugin?

Jason

Anonymous said...

I have expanded the zip provided by you org.eclipse.birt.report.data.testjdbc under \webapps\birtviewer\WEB-INF\platform\plugins\

I tried to add the version number to the plugin as well
org.eclipse.birt.report.data.testjdbc_1.0.0
but didn't make any difference.

I also put the deployable plugin in the plugins directory
org.eclipse.birt.report.data.testjdbc_1.0.0.jar
but nothing happened.

Jason Weathersby said...

Selene,

I just tried this and it worked.
What version of birt are you using?
try adding the deployable version to your designer plugins directory and create a simple report that uses the sample db. Add something like the following to getConnection.

try{
PrintWriter out = new PrintWriter( new FileWriter( "c:/test/jdbc.txt", true ) );
out.println( "getConnection " + connectionClassName);
out.close();
}catch(Exception e){
e.printStackTrace();
}
if( passedInConnection != null){
return new appContextDBConnection();
}else{
return new org.eclipse.birt.report.data.oda.jdbc.Connection();
}

Run the report and see if any messages are displayed.

jason

Anonymous said...

Jason, I'm using BIRT 2.2.1. Following your steps, I added the lines in MyJdbcDriver.java getConnection() method, compiled the class and updated the deployable jar. Put the jar under the designer plugins directory. I created a simple report using the sample db. Previewed the report but no c:/test/jdbc.txt file was created.

If it works for you, there must be something I didn't do correctly.

Jason Weathersby said...

Can you email me the deployable jar? use jasonweathersby at alltel.net

Anonymous said...

Hi Jason,
Did you receive my deployable jar? Thanks!

Jason Weathersby said...

Selene,

I got it. Can you send the source you modified?

Thanks

Jason Weathersby said...

Selene,

Your plugin worked fine in my environment. The text file was created.

Jason

Anonymous said...

Thanks for testing it. It's so strange that why it isn't working on my end. I have done a quick test moving the code from the plugin to the base code OdaJdbcDriver class. The database source got picked up. That probably means BIRT didn't see the plugin for some reason.

Jason Weathersby said...

Selene

verify your plugin.xml
driverType="org.eclipse.birt.report.data.oda.jdbc.OdaJdbcDriver"
specifically the driverType setting, which instructs the plugin to run for a specific oda.

Jason

Anonymous said...

Hi Jason,

The plugin.xml looks good to me. I will send it to jasonweathersby at alltel.net.

Thanks,
Selene

Jason Weathersby said...

Selene,

The plugin.xml looks good. I am not certain what is going on. Are you using the allinone download? If not could you download the 2.2.1 allinone and repeat the test?

Jason

Anonymous said...

Hi Jason,

I tried it on both run-time and all-in-one versions. I downloaded the latest version from Eclipse which was already 2.2.2 today. I put the plugin with logging statement in the plugins directory of the new download. However, I'm still out of luck.

Thanks,
Selene

Anonymous said...

Hi Jason,

Thanks for your time. However, I'm still not able to make BIRT recognize the existence of the plugin. Besides putting the plugin (the one I sent to you) in the plugins directory, is there anything else I need to set in order to let BIRT knows the new plugin existence? It seems to me BIRT doesn't know it's there.

Thanks,
Selene

Jason Weathersby said...

Selene,

Any chance you could setup a webex or placeware to look at it?

send me an email at jasonweathersby at alltel.net.

Jason

Anonymous said...

Thank you so much for your help. It's working.

Selene

Anonymous said...

Hi Jason,

The plugin works fine until I run reports that have drop-down (DynamicSelectionChoices) on the parameter screen. This error will disappear after I ran another report which didn't have DynamicSelectionChoices and went back to the one which had the problem.

Here is the error:
SEVERE: Cannot open connection.
org.eclipse.birt.report.data.oda.jdbc.JDBCException: Failed to get connection.
SQL error #1: Login failed for user 'xm70'.
;
com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'xm70
'.
at org.eclipse.birt.report.data.oda.jdbc.Connection.connectByUrl(Connect
ion.java:162)
at org.eclipse.birt.report.data.oda.jdbc.Connection.open(Connection.java
:115)
at org.eclipse.datatools.connectivity.oda.consumer.helper.OdaConnection.
open(OdaConnection.java:235)
at org.eclipse.birt.data.engine.odaconsumer.ConnectionManager.openConnec
tion(ConnectionManager.java:145)
at org.eclipse.birt.data.engine.executor.DataSource.newConnection(DataSo
urce.java:134)
at org.eclipse.birt.data.engine.executor.DataSource.open(DataSource.java
:121)
at org.eclipse.birt.data.engine.impl.DataSourceRuntime.openOdiDataSource
(DataSourceRuntime.java:214)
at org.eclipse.birt.data.engine.impl.QueryExecutor.openDataSource(QueryE
xecutor.java:265)
at org.eclipse.birt.data.engine.impl.QueryExecutor.prepareExecution(Quer
yExecutor.java:210)
at org.eclipse.birt.data.engine.impl.PreparedQuery.doPrepare(PreparedQue
ry.java:500)
at org.eclipse.birt.data.engine.impl.PreparedDataSourceQuery.execute(Pre
paredDataSourceQuery.java:161)
at org.eclipse.birt.data.engine.impl.PreparedOdaDSQuery.execute(Prepared
OdaDSQuery.java:142)
at org.eclipse.birt.data.engine.impl.PreparedDataSourceQuery.execute(Pre
paredDataSourceQuery.java:141)
at org.eclipse.birt.report.engine.api.impl.GetParameterDefinitionTask.cr
eateDynamicSelectionChoices(GetParameterDefinitionTask.java:490)
at org.eclipse.birt.report.engine.api.impl.GetParameterDefinitionTask.ge
tChoicesFromParameterQuery(GetParameterDefinitionTask.java:940)
at org.eclipse.birt.report.engine.api.impl.GetParameterDefinitionTask.ge
tSelectionList(GetParameterDefinitionTask.java:371)
at org.eclipse.birt.report.service.BirtViewerReportService.getParameterS
electionList(Unknown Source)
at org.eclipse.birt.report.presentation.aggregation.parameter.ComboBoxPa
rameterFragment.prepareParameterBean(Unknown Source)
at org.eclipse.birt.report.presentation.aggregation.parameter.ScalarPara
meterFragment.doService(Unknown Source)
at org.eclipse.birt.report.presentation.aggregation.AbstractBaseFragment
.service(Unknown Source)
at jsp_servlet._webcontent._birt._pages._dialog.__parameterdialogfragmen
t._jspService(__parameterdialogfragment.java:149)

I hope this is not the limitation of the plugin because we have many reports that have drop-down parameters.

Thanks,
Selene

Jason Weathersby said...

Selene,

Remember that the plug-in will get called at least twice when using a dynamic parameter. The first time will be when the dynamic parameter is being populated. Just verify that you are not missing anything in your code.

Jason

Anonymous said...

Thanks Jason for your response. Sorry, I guess I'm missing something because I never did anything special to dynamic parameter. Where shall I check the code? How can the plugin be called twice?

Thanks,
Selene

Anonymous said...

Hi Jason,

We found that it could be a bug on BIRT. The problem seems to be resolved if we put a line
ParameterAccessor.pushAppContext( context, request );
in
BirtViewerReportService.getParameterDefinitionTask()

HttpServletRequest request = (HttpServletRequest) options

.getOption( InputOptions.OPT_REQUEST );

HashMap context = new HashMap( );

context.put(

EngineConstants.APPCONTEXT_BIRT_VIEWER_HTTPSERVET_REQUEST,

request );
ParameterAccessor.pushAppContext( context, request ); // ADD THIS LINE

task.setAppContext( context );

Any idea if this will cause any problem.

Thanks,
Selene

Jason Weathersby said...

Selene,

I do not think this will cause a problem, but it would be a good idea to log a bugzilla entry with your change.

Thanks

Jason

Anonymous said...

Thanks Jason. I'll add it in bugzilla.

Anonymous said...

I am looking for resources to completely use the Report Design API to generate report designs files due to the dynamic nature of our reporting implementation. I am using the BIRT source code in addition to the BIRT Integration book, which is good but does not offer enough detail. I am in need of some good examples with explanations. I am stuck trying to create a structure element under the script-data-set - I have been able to create the list-property for resultSetHints and columnHints, but nowI need to create a ...

Please help!!!!!!!!!!!!!!!!!!!!!!!

Jason Weathersby said...

Take a look at:
http://www.birt-exchange.org/devshare/deploying-birt-reports/792-eclipsecon-2009-integrating-birt/#description

It has several DE API examples including a scripted data source.

Jason

Anonymous said...

All,
I am using the report designer API to generation the report design file dynamically based on use input. When I am working with groupings and aggregates I am creating a Table Structure for the information. In this case, I am generating the 1st and 2nd structure, but a 3rd is being created (i think by the system). Therefore, I am unclear on how to resolve this issue because I need to be able to have verbiage out by the aggregate value for example "SUM: " + row["Color"]; as seen in the 2nd structure. However, when my report is generated i have no data just headings. However, if i do not generate the 2nd structure and just use the 3rd i get data, but i cannot specify the custom text since it is generated. I basically using a report design generated in eclipse and then using that as my mockup to generate the report design xml using the API.

Any direction would be appreciated or any good sites besides the standard sites.

Thanks
-----------------------------------------------------------

<structure>
<property name="name">Color_SUM</property>
<property name="dataType">float</property>
<simple-property-list name="aggregateOn">
<value>groupByColor</value>
</simple-property-list>
<property name="aggregateFunction">SUM</property>
<list-property name="arguments">
<structure>
<property name="name">Expression</property>
<expression name="value" type="string">row["Color"]</expression>
</structure>
</list-property>
</structure>
<structure>
<property name="name">Color_structure</property>
<expression name="expression">"SUM: " + row["Color_SUM"]</expression>
<property name="dataType">string</property>
</structure>

<structure>
<property name="name">Color_1</property>
<expression name="expression">dataSetRow["Color"]</expression>
<simple-property-list name="aggregateOn">
<value>groupByColor</value>
</simple-property-list>
</structure>

arthurj said...

Are there any moderately complex to complex examples of using the report design API to create simple aggregates? For example, SUM, MIN, MAX, etc.? The reason I asked is that I have generated a SUM/COUNT aggrgrate, which works, but I am use eclipse to create the report design file and then using the API to determine what I need to do. However, the reason for my question is I saw an example that used Total.sum(row["somecolumn"]), and that is not how I am doing it. Thus, I am looking for the easiest but correct way (best practices).

Jason Weathersby said...

Take a look at this example:

TableHandle table = designFactory.newTableItem( "table", 3 );
table.setWidth( "100%" );
table.setDataSet( designHandle.findDataSet( "ds" ) );

//table.getColumnBindings().clearValue();

//StructureFactory.createIncludedCssStyleSheet()


PropertyHandle computedSet = table.getColumnBindings( );
ComputedColumn cs1, cs2, cs3, cs4, cs5;

cs1 = StructureFactory.createComputedColumn();
cs1.setName("CustomerName");
cs1.setExpression("dataSetRow[\"CUSTOMERNAME\"]");
computedSet.addItem(cs1);
cs2 = StructureFactory.createComputedColumn();
cs2.setName("CustomerCity");
cs2.setExpression("dataSetRow[\"CITY\"]");
//cs2.setDataType(dataType)
computedSet.addItem(cs2);
cs3 = StructureFactory.createComputedColumn();
cs3.setName("CustomerCountry");
cs3.setExpression("dataSetRow[\"COUNTRY\"]");
computedSet.addItem(cs3);
cs4 = StructureFactory.createComputedColumn();
cs4.setName("CustomerCreditLimit");
cs4.setExpression("dataSetRow[\"CREDITLIMIT\"]");
computedSet.addItem(cs4);

cs5 = StructureFactory.createComputedColumn();
cs5.setName("CustomerCreditLimitSum");
cs5.setExpression("dataSetRow[\"CREDITLIMIT\"]");
cs5.setAggregateFunction("sum");
computedSet.addItem(cs5);




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

ColumnHandle ch = (ColumnHandle)table.getColumns().get(0);
ch.setProperty("width", "50%");

LabelHandle label1 = designFactory.newLabel("Label1" );
label1.setOnRender("var x = 3;");
addBottomBorder(label1);
label1.setText("Customer");
CellHandle cell = (CellHandle) tableheader.getCells( ).get( 0 );

cell.getContent( ).add( label1 );
LabelHandle label2 = designFactory.newLabel("Label2" );
label2.setText("City");
cell = (CellHandle) tableheader.getCells( ).get( 1 );
cell.getContent( ).add( label2 );
LabelHandle label3 = designFactory.newLabel("Label3" );
label3.setText("Credit Limit");
cell = (CellHandle) tableheader.getCells( ).get( 2 );

cell.getContent( ).add( label3 );


// table detail
RowHandle tabledetail = (RowHandle) table.getDetail( ).get( 0 );


cell = (CellHandle) tabledetail.getCells( ).get( 0 );
DataItemHandle data = designFactory.newDataItem( "data1" );
data.setResultSetColumn("CustomerName");

addToc( data );


cell.getContent( ).add( data );
cell = (CellHandle) tabledetail.getCells( ).get( 1 );
data = designFactory.newDataItem( "data2" );
data.setResultSetColumn("CustomerCity");
cell.getContent( ).add( data );
cell = (CellHandle) tabledetail.getCells( ).get( 2 );
data = designFactory.newDataItem( "data3" );
data.setResultSetColumn("CustomerCreditLimit");
cell.getContent( ).add( data );


RowHandle tablefooter = (RowHandle) table.getFooter().get( 0 );
cell = (CellHandle) tablefooter.getCells( ).get( 0 );


cell = (CellHandle) tablefooter.getCells( ).get( 2 );
data = designFactory.newDataItem( "datasum" );
data.setResultSetColumn("CustomerCreditLimitSum");
cell.getContent( ).add( data );

Jason Weathersby said...

comment out the addToc function

arthurj said...

Thanks for the quick response Jason - reviewing now!

arthurj said...

Jason, I was able to take a couple of tidbits from your example and get my code to work. However, I am unable to follow what and how it is working, as I am not seeing what I expected to see. For example, I added the following code

dataItem = createDataItem(factory, column, DesignContants.DATA_ITEM);
dataItem.setResultSetColumn(column);
cell.getContent().add(dataItem);

This code above generates the following xml and it is added to the footer and this is the output
<footer>
<row id="27">
<cell id="28"/>
<cell id="29"/>
<cell id="30">
<data name="Color_dataItem" id="31">
<property name="resultSetColumn">Color_1</property>
</data>
</cell>
</row>
</footer>

However, in the table definition, I see that my group agg is (above) is referring to the structure in the table def, and I am not creating the structure as seen below. Does the engine generate any code at all.
<structure>
<property name="name">Color_1</property>
<expression name="expression">dataSetRow["Color"]</expression>
<simple-property-list name="aggregateOn">
<value>groupByColor</value>
</simple-property-list>
</structure>

I appreciate your example, however, are there any complete examples out there (web) that you can point me to? I am really trying to understand what is going on before I move forward. I have both BIRT books (integration & reporting design...), but neither book gives specific details.

Any info will greatly be appreciated.

arthurj said...

Take that back. The group footer is showing in my report but the calculations are incorrect.

Jason Weathersby said...

Take a look at Birt Exchange which has a lot of different types of examples in the dev share. You can search it. Here is one that I posted to it:
http://www.birt-exchange.org/devshare/deploying-birt-reports/792-eclipsecon-2009-integrating-birt/#description

This section of the code:
PropertyHandle computedSet = table.getColumnBindings( );
ComputedColumn cs1, cs2, cs3, cs4, cs5;

Is getting the bound column names. Open any report with a table and select the table and the binding tab and you will see them. BIRT items uses bound column names that are associated with the dataset columns. There can be bound columns that are not associated with data set columns as well. There is section in the integrating book that talks about this. It is in the overview of scripting chapter I believe. The engine should not be adding anything unless it adds for missing items like bound columns that are not defined completely. In the example I posted this should not be the case.

Jason

arthurj said...

I am researching how to color individual cells during runtime and here is what I have come up with.

<cell id="17">
<method name="onRender">
<![CDATA[if (this.getRowData().getColumnValue("ColorC"))
{
this.getStyle().backgroundColor = this.getRowData().getColumnValue("ColorC");
}
]]>
</method>

However, here is my dilemma - Each cell will correspond to a field/column of data and each cell can have a completely different
color from the next cell. Hence my dilemma. Is this even possible, and if so is it just a matter of how I create my objects?
I am using a scripted datasource and the origin of the data is in the http session. I will have a list of rows (each row made up
of a Map of data and the colors are customized colors are present in the map), but the color for each cell is not apart of the
row data. In my application, I need to evaluate each row and color my cells based on configured conditions. I see in
Integration and Extending book on page 135 that the session can be accessed via the request (http), which is accessed via the reportContext.

I can do the research, but need a little guidance in terms of resources and reading up on things besides the Integration and Extending book.

Jason Weathersby said...

If the color is not defined in the row map where is it defined?

arthurj said...

Jason, the color will be defined in the row map for each field and if no color is defined the default color will be white.
Thanks

Jason Weathersby said...

Maybe the best option is to get the session object store it in a persistent gloabl variable and then use the row count to index into the ojbect to get the color. I can send you a report design that works on the session object. If you want it what email should I send it to?

arthurj said...

Jason,
that would be great arthurjosephf@gmail.com. I have am experimenting with a CellEventAdapter and randomly selecting and setting the background color for each cell which is working. However, the example you sending will be of great help.

arthurj said...

Jason,
Thanks for the sample you provided. It was very helpful.

I am looking for pointers on getting the Birt platform integrated into a web application that will use design engine to generate report designs and that will use the report engine to generate formatted reports. However, I am not using the WEBVIEWER. I have tried several combinations and for whatever things are blowing up because I cannot start the platform etc. Any pointers would be great.

arthurj said...

To provide a bit more detail. I was attempting to use a ServletContextListener to initialize the Design and Report Engines, and this was causing issues. If I deploy the application and invoke the process at a different time it seems to work.

Jason Weathersby said...

You can always get the design handle from the report design using the engine like:

Platform.startup( config );
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
engine = factory.createReportEngine( config );


IReportRunnable design = null;
//Open the report design
design = engine.openReportDesign("Reports/TopNPercent.rptdesign");
ReportDesignHandle report = (ReportDesignHandle) design.getDesignHandle( );
ImageHandle report.findElement("MyImage");
image.setURL( "\"http://www.eclipse.org/birt/phoenix/tutorial/basic/multichip-4.jpg\"" );
report.findElement("NewChart").drop();
//Create task to run and render the report,
IRunAndRenderTask task = engine.createRunAndRenderTask(design);

arthurj said...

Jason,
Thanks for your response. So there should not be an issue deploying the Birt platform without the web viewer application.
The issue that I am seeing is that I am trying to initialize the engines during servlet context startup and for whatever reason when i attempt to start the Platform it is not starting and therefore subsequent invocations fail. For example: factory.createDesignEngine(config); & factory.createReportEngine(config);.
The issue is I need to be able to deploy this to multiple app servers Websphere, Weblogic, & Tomcat, so I need to use a relative path for the platform because I do not necessarily know the absolute paths once my application war file is exploded. I will keep plugging at it, but if you can offer "Best Practices" on how to deploy the platform without the web viewer or point me in the right direction that will be great. I do not mind doing the leg work.

Jason Weathersby said...

Take a look at this example:
http://wiki.eclipse.org/Servlet_Example_%28BIRT%29_2.1

Make sure to look at the modified WebReport class located at the bottom. If you use a PlatformServletContext class the platform can be found relatively as long as you war it with the directory structure described in the wiki page.

arthurj said...

Jason,
Thanks for the guidance - I have it working.
I have a question surrounding deployment. As I mentioned I am using the Report Engine and Design Engine to generate designs and reports and I am wondering if it is possible to avoid using OSGI? I realize that I would need to move the necessary jars to the WEB-INF/lib directory etc. However, during some research I came across some information for charting, which was setting a property "STANDALONE". My guess is that OSGi is needed because as I debugged the code I noticed in the Platform class which invokes a startup method in the OSGILauncher class the code is searching for the .../plugins directory and throws an FrameworkException because it cannot find the Framework. Here is my objective. I am trying to keep things as lean as possible and would like to exclude any jar files which are not needed. Thanks!

Jason Weathersby said...

The Chart Engine can be ran standalone but not the report or design engines. You can look at the plugins folder and remove plugins that you do not require like emitters that you do not want, the sample db, oda drivers that you do not use, etc.

arthurj said...

I am receiving the following error after deploying a standalone java application onto a mainframe UNIX environement. I have other applications running in this environment and I assume because we are using pure java (in BIRT) that it would run with no issues. This is an IBM implmentation of the JRE, and I initially assumed there were some issues with a jar file for the SAX parsing and have not ruled that out.

NOTE: This sample project runs in a windows env. with no issues and produces a simple pdf report.
Any tips? I know that this is not much of a log, but this is all I can capture. I am working on piping all the output to a log file. My objective is to ensure we can run in this env, hence the test.

ERROR
==========================
Message:SAX detected an eror with the basic XML syntax of the file.
. . .
The design file <stream> has error and can not be run.
at org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.openReportDesign(ReportEngineHelper.java:260)
. . .
Caused by: Error.DesignFileException.INVALID_XML - 2 errors found!
1.) ( line = 0, tag = null) org.eclipse.birt.report.model.util.XMLParserException . . .
Content is not allowed in prolog

arthurj said...

Just another note on the report design issue. If i use a sample design file provided with the birt platform the process works. However, when using the report design api to generate a report design i have this error.
Any tips on this or gotchas?
Any info would greatly be apprecitated

arthurj said...

Just a note regarding the report design and the "prolog" xml error. I was able to resolve this issue.

arthurj said...

Anyone know what types of images are supported for the various types of reports? I will be producing XLS, PDF, HTML, CSV, and XML reports. I know that HTML must use a image with a URL, and I have tested an embedded image with PDF. I am trying to keep from having various report designs for the different types of reports. Just a note: I am creating report designs on the fly using the report design API. I suppose I could replace the embedded image if it is an HTML report type with an image containing a URL. Thanks in advance for any input. I have searched a couple of places, but with no success.

Thanks

arthurj said...

I am generating my report designs on the fly, so I think I need to create 2 design streams 1 for HTML and 1 for 1 NONHTML because the images used for HTML will not be embedded and the other NONHTML will be embedded. I am trying to basically write 2 streams and I am planning on modifying 1 stream to update the image information. However, I am not sure this will work, but I am researching and wanted to ask if this is even possible.
Thanks

Jason Weathersby said...

If you want to produce two outputs you should use a run task to create the rptdocument and then two render tasks. One for each output format you want to create.

Jason

arthurj said...

That makes sense. When I attempt to remove the image used for html and add an element for an embedded image my new image is not making it to the report (this would be for pdf). I have debugged and it seems to be making through to add the new image (embedded) after dropping the image element used for html, but my image is not showing up. Based on what i have read i should be able to perform this type of action?
Thanks

Jason Weathersby said...

Can you send me the code at jasonweathersby at windstream.net

arthurj said...

Jason email sent with code.

Thanks

arthurj said...

Jason,
I am looking into writing out my report design after modifications have taken place, but it seems as though the inputstream has been closed because I am unable to write it out as it shows empty. Anyway, to further detail my crux. I have multiple report formats (say HTML and PDF), and each format will have a different type of image (non-embedded and embedded respectively) because HTML cannot display an embedded image. Hence, I want to use 1 report design to write out multiple report formats, but I need to modify the image elements. The reason is performance obviously - because I do not want to generate 2 report designs (for both HTML and PDF). What I now have working is the following:
I create a rpt design with the embedded image; and before creating the report for the HTML version - I perform the following (which seems to work)

// DROP ALL EMBEDDED IMAGES
ReportDesignHandle report = (ReportDesignHandle) runnable.getDesignHandle();
report.dropImage(report.getAllImages());

// GET REFERENCE TO EMBEDDED IMAGE
IImage image = (IImage) runnable.getDesignInstance().getImage("logoImage");
// CHANGE SOURCE
image.setSource(DesignContants.IMAGE_REF_TYPE_URL);
// SET URL
image.setURL("\"http://localhost:8080/SomeServer/reportimages/logoImage.jog");

NOTE: the image has already been created in a folder location
What are your thoughts on this approach. This will only be done where HTML exist with another type of report output.

Jason Weathersby said...

Arthur,

I do not think anything is wrong with this approach, but I am not certain why you say HTML has a problem with embedded images. Take a look at this page:
http://www.eclipse.org/birt/phoenix/deploy/reportEngineAPI.php#miscellaneous

Specifically look at the HTMLServerImageHandler code.

Jason

arthurj said...

Jason,
I understood the following when working with the report designer. Since I am creating my report designs on the fly (based on user input); my design would not really what type of image element to create unless I tell it (embedded vs non). For a single report design, I can have PDF, HTML, and XLS (etc.). Thus, when I open my design to emit the output I may have built the report design with an embedded image - based on some logic, and since I only want to build the design once; I thought I would need to remove the embedded references and create/modify the image information with the HTML "version". I have verified when I serialize my report design to a stream for later processing the following element exists:
<image name="logoImage" id="11">
<property name="source">embed</property>
<property name="imageName">logoImage</property>
</image>


so I thought I would need to remove and update the image information. I am unable to see how to do it any other way. I can see how the code sample you are pointing me to would work if I was working with 1 report design and one type of output (HTML), but I fail to see how to use this code if my design has been created with embedded images without updating the image informaiton. Please let me know if I am on the wrong track.

Jason Weathersby said...

Arthur,

If you use an HTMLServerImageHander this will only happen to html reports. So the other reports should function fine even if you specify this. BTW you may want to look at using a runtask and then additional rendertask for each of your output formats.

arthurj said...

Jason,
Let me restate to ensure I understand. I apologize for being dense. So if I have a report design, which has been created with embedded image element like such:

<image name="logoImage" id="11">
<property name="source">embed</property>
<property name="imageName">logoImage</property>
</image>
------------------------------
and a list property like such
------------------------------
<list-property name="images">
<structure>
<property name="name">logoImage</property>
<property name="type">image/jpeg</property>
<property name="data">/9j/4AAQSkZJRgABAgAAZ. . .
</list-property>

---------------------------------
and if I use the HTMLServerImageHander code ... to which you are referring that the embedded information will render properly if the report format is HTML? If this is true maybe I am doing something wrong - because I tried the using the example, but I will review again if what I restated is true.

What is the benefit of using the runntask and then the rendertask as you have stated.

Jason Weathersby said...

That is correct.

arthurj said...

Jason,
Thanks I was able to get it to work.
Thanks again for your promptness.

arthurj said...

Jason,
I am unable to figure out why the second structure is being created during my aggregate structure creation. The structure with a name of Color_1 is somehow getting created. I am creating the Color_SUM, but cannot pinpoint why the other is being created.

<structure>
<property name="name">Color_SUM</property>
<expression name="expression">Total.sum(row["Color"])</expression>
<property name="dataType">float</property>
<simple-property-list name="aggregateOn">
<value>groupByColor</value>
</simple-property-list>
</structure>
<structure>
<property name="name">Color_1</property>
<expression name="expression">dataSetRow["Color"]</expression>
<simple-property-list name="aggregateOn">
<value>groupByColor</value>
</simple-property-list>
</structure>


Here is my code

You can see i have it hard coded for the column of Color.

public static void createListAggregatePropertyBoundedDataColumns(TableHandle tableHandle, ReportDesign rptDesign) throws ReportException
{
DataSetHandle dataSetHandle = null;
ResultSetColumn resultSetHandle = null;
ComputedColumn column = null;
List resultSetCols = null;
PropertyHandle boundColumn = null;

try
{
dataSetHandle = (DataSetHandle) rptDesign.getDesign().getDataSets().get(0);

resultSetCols = dataSetHandle.getListProperty(DataSetHandle.RESULT_SET_HINTS_PROP);
boundColumn = tableHandle.getColumnBindings();

for (Iterator<ResultSetColumn> iterator = resultSetCols.iterator(); iterator.hasNext();)
{
resultSetHandle = (ResultSetColumn) iterator.next();
if(resultSetHandle.getColumnName().equalsIgnoreCase("Color"))
{
column = StructureFactory.createComputedColumn();

column.setName(resultSetHandle.getColumnName()+DesignContants.AGG_SUM_SUF);
column.setExpression("Total.sum(row["Color"])");
column.setDataType(resultSetHandle.getDataType());
column.setAggregateOn(DesignContants.GROUP_PREFIX+resultSetHandle.getColumnName());
boundColumn.addItem(column);
}
}
}
catch (SemanticException e) {. . . }
}

Jason Weathersby said...

Arthur,

I am not sure if this is the issue but drop the total function from your expression and just use row["Color"] and then add

columnHandle.setAggregateFunction("sum")

Jason

arthurj said...

Jason,
I figured out what was causing causing the following structure.

<structure>
<property name="name">Color_1</property>
<expression name="expression">dataSetRow["Color"]</expression>
<simple-property-list name="aggregateOn">
<value>groupByColor</value>
</simple-property-list>
</structure>

When i am setting properties for my groupName, sortDirection, etc. I am creating an expression in the following manner:
Expression expression = new Expression(ReportHelper.format(row["Color"], "string");
groupElement.setExpressionProperty("keyExpr", expression);

and this was adding the structure above. My objective here is that I was using eclipse to create sample reports and then using the API creating my elements in order to create a report design since i am generating all of my designs on the fly. Thus, I am creating the group properties as seen below, but this in turn was adding the structure that i asked about. When I remove the expression code the structure is not created, but then i do not have my expression property below. i believe i need that for the grouping to work.
So my question is am i doing something wrong when creating my expression for my group, or am i creating my structures incorrectly as seen in the code above? I am very confused at this point and would appreciate any feedback.

<property name="groupName">groupByColumnName</property>
<property name="interval">none</property>
<property name="sortDirection">desc</property>
<expression name="keyExpr" type="string">row["ColumnName"]</expression>

Thanks

arthurj said...

Sorry the expression should read

Expression expression = new Expression(row["Color"], "string");
groupElement.setExpressionProperty("keyExpr", expression);

arthurj said...

Jason,
Ok - up until now i was not able to generate a report, due to some issues with my structure generation for my aggregates. However, once corrected i now have a report.
At a closer glance, the structure being generated by the expression above are actually for the grouped columns and not the aggregates, which is fine. I actually have a project requirment which does not allow for aggregates to be generated for grouped columns (columns included in the group). However, when using eclipse, i do not see those extra structures being generated for the grouped columns that is, so now i am wondering if i should actually generate the structures rather than allowing the system to generate. You can actually see the structures here (sorry for all the code) adn the grouped columns are "ColumnName" and "Color".
I am just trying to do this the correct way as I learn.
Any feedback?
<structure>
<property name="name">AVE_COLUMNNUMBER_GROUP1</property>
<expression name="expression">Total.ave(row["ColumnNumber"])</expression>
<simple-property-list name="aggregateOn">
<value>groupByColumnName</value>
</simple-property-list>
</structure>
<structure>
<property name="name">SUM_COLOR_GROUP1</property>
<expression name="expression">Total.sum(row["Color"])</expression>
<simple-property-list name="aggregateOn">
<value>groupByColumnName</value>
</simple-property-list>
</structure>
-----------------------------------------------------------------------------
<structure>
<property name="name">AVE_COLUMNNUMBER_GROUP2</property>
<expression name="expression">Total.ave(row["ColumnNumber"])</expression>
<simple-property-list name="aggregateOn">
<value>groupByColumnValue</value>
</simple-property-list>
</structure>
<structure>
<property name="name">SUM_COLOR_GROUP2</property>
<expression name="expression">Total.sum(row["Color"])</expression>
<simple-property-list name="aggregateOn">
<value>groupByColumnValue</value>
</simple-property-list>
</structure>
-----------------------------------------------------------------------------
<structure>
<property name="name">ColumnName_1</property>
<expression name="expression">dataSetRow["ColumnName"]</expression>
<simple-property-list name="aggregateOn">
<value>groupByColumnName</value>
</simple-property-list>
</structure>
<structure>
<property name="name">ColumnValue_1</property>
<expression name="expression">dataSetRow["ColumnValue"]</expression>
<simple-property-list name="aggregateOn">
<value>groupByColumnValue</value>
</simple-property-list>
</structure>

Jason Weathersby said...

Arthur,

I am not sure what you are asking. Can you send me your code in email and further state the question? Also why are you using the Total functions in the expression. Use
columnHandle.setAggregateFunction("sum")


Jason

arthurj said...

I have a question. I need to access data across phases. I am using a custom EventHandler written in java to access my data (class extends ScriptedDataSetEventEventAdapter), and I have written a custom java cell event handler (extends CellEventAdapter). What is the proper way to do this: AppContext, setGlobalVariable, or setPersistentGlobalVariable().

Jason Weathersby said...

Use
setPersistentGlobalVariable() which persist the variable in a reportdocument.

arthurj said...

Thanks for the last response Jason! I am wondering if there is a simple way to make the value for a grouped column only appear once in the cell that is spanning multiple rows? For example, if I have 2 groups - I want the outer group text to appear once (either at the top in the middle or at the bottom of a group). The best i can do is to span across multiple rows, change the grids to not show, but the text appears twice, one for each subgroup. Any ideas? i have been expirmenting in eclipse as well by changing various properties, but to no avail.

Thanks
Arthur

Jason Weathersby said...

Arthur,

I am not sure what you need. Can you email me a report that has the issue? You can always use an onRender script with a counter that does
this.getStyle().display = "none";

arthurj said...

Thanks for the suggestion. I can try something like this. Basically, I am trying get the value to only show up once; at the top, in the middle, or at the bottom - spanning multiple row.

arthurj said...

I am getting the following error when i take a report design generated using the api and drop it into eclipse.
The report is generating ok for html; but i have not tried all formats, and i am wondering about all the negatives of this error.

Error code indicating the table has inconsistent column count. The column count should match the maximum cell count in header, detail, and foot slots.

I am creating my table like this
newTableItem("somename", 8, 3, 1, 1);
- 8 can be 50 or 3 as it is dynamic

The java docs talks about the header, detail and footer params as being the num of rows which will be added to the respective band (header row will have 3 rows, detail 1, etc.). Is this causing it?

Thanks

arthurj said...

The empty elements here which are used to pad the rowspan i think in the xml below. I am not adding these empty elements, all i am doing here is adding
the colspan property during one of the calls to the setCustomProps(..) below. Anything seem incorrect with the code below? The emtpy elements once
removed and reviewed in eclipse the report actually appears to be formatted much better. With the empty elements the report is skrunched. Any ideas
would be great on how to prevent the empty elements.

<cell id="12"/>
<cell id="13"/>
<cell id="14"/>
<cell id="15"/>
<cell id="16"/>
<cell id="17"/>
<cell id="18"/>

<header>
<row id="9">
<property name="repeatable">true</property>
<property name="backgroundColor">#FFFFFF</property>
<property name="backgroundRepeat">repeat</property>
<cell id="10">
<property name="colSpan">8</property>
<property name="rowSpan">1</property>
. . .
<image name="logoImage" id="11">
<property name="source">embed</property>
<property name="imageName">logoImage</property>
</image>
</cell>
<cell id="12"/>
<cell id="13"/>
<cell id="14"/>
<cell id="15"/>
<cell id="16"/>
<cell id="17"/>
<cell id="18"/>
</row>
<row id="19">
<property name="repeatable">false</property>
<property name="backgroundColor">#FFFFFF</property>
<property name="backgroundRepeat">repeat</property>
<cell id="20">
<property name="colSpan">8</property>
<property name="rowSpan">1</property>
<property name="backgroundColor">#FFFFFF</property>
<property name="backgroundRepeat">repeat</property>
<property name="fontSize">9pt</property>
. . .
<label name="titleLabel" id="21">
<property name="backgroundColor">#FFFFFF</property>
<property name="fontSize">18pt</property>
<property name="fontWeight">bold</property>
<property name="paddingTop">20pt</property>
<property name="paddingBottom">20pt</property>
<property name="textAlign">center</property>
<text-property name="text">Test Report</text-property>
</label>
</cell>
<cell id="22"/>
<cell id="23"/>
<cell id="24"/>
<cell id="25"/>
<cell id="26"/>
<cell id="27"/>
<cell id="28"/>
</row>
. . .
</header>


public void someMethod(TableHandle table) throws ReportException
{
RowHandle row = null;
CellHandle cell = null;
LabelHandle titleLabel = null;
int rowIndex = 1;

try
{
row = (RowHandle) table.getHeader().get(rowIndex);

setCustomProps(row, getReportDef(this.getRptDesign()), HEADER_ROW_REPORT_TITLE);

cell = (CellHandle) row.getCells().get(0);

setCustomProps(cell, getReportDef(this.getRptDesign()), HEADER_ROW_CELL_TITLE);

/** Create new Label. */
titleLabel = this.getRptDesign().getDesign().getElementFactory().newLabel(TITLE_LABEL);

titleLabel.setText(this.getRptDesign().getRptDefWrapper().getReportDefinition().getTitle());

setCustomProps(titleLabel, getReportDef(this.getRptDesign()), HEADER_REPORT_TITLE_LABEL);

cell.getSlot(TableRow.CONTENT_SLOT).add(titleLabel);
}
catch (Exception ex)
{
...
}
}

arthurj said...

Please disregard the last 2 posts. After several hours i have solved the issue. Thanks Arthur

arthurj said...

Is there a way to set a width property to "auto" that will adjust accordingly? I realize i can set the column property like this, but i could have many columns and i do not want to set all of the columns to a specific width size. Is there a way to set the columns to auto adjust based on the text in the column?

<column id="118">
<property name="width">40%</property>
</column>

Unknown said...

Pdf reports generated on Linux server, generates report in half page leaving half page blank. The same report works fine on windows setup. Noticed one semantic error inconsistent column count error in the generated design file. is this causing the issue?

Jason Weathersby said...

Vijay,

Sorry for the delay. Did you get a resolution to the problem?

Jason

arthurj said...

I have a couple of questions if someone could point me in the right direction.
1. Does the CSV emitter generate grouping and aggregates in the final report.
2. Does XLS emitter support images?

Jason Weathersby said...

1 - if you mean the data export the default one does not. This is an extension point so you could customize it. If you mean the XLS emitter the aggregations and groups do show in the export.

2 - Not currently.

arthurj said...

Jason,
Could you elaborate a bit more on the CSV emitter, and if I have a chart image being generated; I will be unable to display in EXCEL using the XLS emitter. Just trying to make sure I am clear on this. I am not using the WEB view or I would have tried some tests.
Thanks in advance

arthurj said...

Jason,
The last post was extremely vague and somewhat confusing.

Are there plans to support images (like charts) in excel in future releases. I am using 2.5.

Or is there a back door approach that I could use.
We are using the API to generate images and if I could add the image at render time that might work.

Thanks

Jason Weathersby said...

Sorry if it was confusing. There are two ways to get the data out. You can use an emitter or use a data extraction task on the engine. The XLS emitter currently does not handle images. We have plans to make this better, but I am not sure when it will happen.

Jason

arthurj said...

Jason,

I am researching an issue with the html output. I have a report that has several columns and i am researching the report design generation.
What i am seeing is that when i review the html output i see a "global" table that i being created which i assume is part of the emitter generation. The table with a width of 10.5 seems to be cause at least one issue and i am wondering if this can be controlled up front during design or during the output generation. I will look at the latter until i hear back from you.


<pre>
<table cellpadding="0" style=" border-collapse: collapse; empty-cells: show; width:10.5in; overflow: hidden; table-layout:fixed;">
<col></col>
<tr>
<td>
<table style="border-collapse: collapse; empty-cells: show; width: 100%; table-layout:fixed;" id="AUTOGENBOOKMARK_1">
<col></col>
<col></col>
<col></col>
<tr valign="top" align="left">
<td style="overflow:hidden;">
<div class="style_1" id="AUTOGENBOOKMARK_2" style=" text-align:left;"> </div>
</td>
<td style="overflow:hidden;">
<div class="style_2" id="AUTOGENBOOKMARK_3" style=" text-align:center;"> </div>
</td>
<td style="overflow:hidden;">
<div class="style_1" id="AUTOGENBOOKMARK_4" style=" text-align:left;"> </div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top">
<table style="border-collapse: collapse; empty-cells: show; width: 100%;" id="AUTOGENBOOKMARK_5">
<col style=" width: 75px;"></col>
<col style=" width: 85px;"></col>
</pre>

arthurj said...

Jason,
So i am using a custom pageType when creating the SimpleMasterPage and setting my width based on the number of pixels for the total report.
Is this the best way to do this and i do i need to do this based on a specific value as i am doing pixels (or some other measure)? Another words I am unable to use 100% for the custom pageType - is that correct?

Thanks

Jason Weathersby said...

Arthur,

Are you trying to use the whole master page?

Jason

arthurj said...

Jason,
Yes I am trying to use the whole master page - I think. However, I am not completely sure what you mean. I tried my approach and it is working in terms of not causing the 10.5in width on the table. However, when I pull my report design into eclipse just to view the editor is complaining about "fromUnits"must be one of the absolute units(CM, IN, MM, PT). because I am only setting the width property to the totals number of pixels.
However, I do not care as long as my reports are getting generated, but I do wonder about future issues if I am not using something correctly.

I do think I need to use the custom page type.

Please let me know your thoughts.

Thanks

Jason Weathersby said...

Arthur

Can you send me a report that uses the sample db that shows what you have done?

Jason

arthurj said...

Jason,
Should i sent it to your email account?

arthurj said...

Jason,
Here is my code

SimpleMasterPageHandle simpleMasterPage = null;
ReportDefinition rptDef = getReportDef();
String reportPixels = null;

reportPixels = String.valueOf(super.getRptDesign().getRptDefWrapper().getTotalReportPixels());
simpleMasterPage = super.getRptDesign().getFactory().newSimpleMasterPage(MASTER_PAGE);
simpleMasterPage.setOrientation(PAGE_ORIENTATION_LANDSCAPE);// TODO from RD
simpleMasterPage.setShowHeaderOnFirst(true);
simpleMasterPage.setShowFooterOnLast(true);

/** Set Custom Page size based on calculated values. */
simpleMasterPage.setPageType(PAGE_SIZE_CUSTOM);
simpleMasterPage.setProperty(WIDTH, getReportPixels(reportPixels));

/** Add header and footer to report.*/
addContentToReportHeaderFooter(simpleMasterPage, MASTER_PAGE_HEADER);
addContentToReportHeaderFooter(simpleMasterPage, MASTER_PAGE_FOOTER);

arthurj said...

Jason,
Sent the mock report along with basi code

arthurj said...

Jason,
I am going to research the various forums, but was wondering if you knew of an issue with embedded png images being corrupted when emitting to report outputs. The image shows about 1/3 of the image and black for the other 2/3s of the image for pdf, and will not show at all in the html output and i am assuming this is because the image is corrupt. This does not occur for jpg images.
Could it be an issue with multiple images on the same report? I have a logo image as well as a chart image that i am embedding and the chart image (png) is the corrupted image.

arthurj said...

Problem solved. png data was truncated because of my buffer size hard coded value. After making dynamic based on inputstream all is well. Just forgot to change the hard code value to a dyn value

arthurj said...

I need to turn off suppressduplicates for columns which are grouped when i am writing out the xml output. I think the emitter is too late to do this so i am trying to do this when i generate the report output stream from the report document tasks. Is this correct and if so I can see in the debugger the objects with the suppressduplicates of true, but i cannot seem to figure out what object to extract and what object i use the. Do i use the IDataExtractionTask or the IReportDocument? ideas

arthurj said...

I have tried all i can think of and actually see that the data is still in the report document because i can see the column data which shows the suppressed duplicate information, so i am assuming that it is during the report generation which suppresses the duplicates based on the report design. I have tried the following code but i am still missing the data. I can see that the properties are changed in my print statements, but still missing data. Please help with some direction. Thanks

DesignElementHandle d = super.document.getReportDesign().findElement("dataTable");

TableHandle t = (TableHandle) d;
SlotHandle columnSlot = t.getColumns();
int count = columnSlot.getCount();
for(int i = 0; i< count; i++)
{
DesignElementHandle columnElement = columnSlot.get(i);

System.out.println("columnElement " + columnElement.getProperty("suppressDuplicates"));

columnElement.setProperty("suppressDuplicates", "false");

System.out.println("columnElement " + columnElement.getProperty("suppressDuplicates"));

}

Jason Weathersby said...

If you use code like:

TableHandle table = designFactory.newTableItem( "table", 3 );

//add data elements and bind
//dataset. Add computed columns

You should be able to suppress duplicates like:
ColumnHandle ch2 = (ColumnHandle)table.getColumns().get(1);
ch2.setSuppressDuplicates(true);

arthurj said...

Jason,
Thanks for the information. However, can I reverse that during the time when I generate the XML report using the Report Document? The problem is that (using the xml emitter downloaded from Birt-exchange site) the data is missing from the xml documents because of the duplicate suppression. so some of my records where the grouping is the same are missing the data because of suppression. I would like to reverse it for xml output so i can get all of the data, but i am unclear how to do that and i have tried everything and nothing has worked. in fact i am not even sure it can be done??? Ideas?

Thanks

arthurj said...

The suppressed data is still apart of the report docoument because i can see it in the extraction using the IDataExtractionTask, and i can see the report design inside the report document object - i am stumpped on how to make the data show up in the xml.

arthurj said...

I was finally able to get the TableHandle in the XMLReportEmitter, and change it at least based on the output in the console, but i am still missing my data. I am either doing something wrong or this cannot be done to the report document. The Integrating and Extending book says you can access the report document items, but i guess you cannot change those items on the fly. However, you can modify the the report design, but before the report document is generated? Please let me know so I know.

Thanks

Jason Weathersby said...

I am not sure what you are trying to do. Are you trying to hide data in a data extraction task? If so you may want to look at developing your data extraction extension.
org.eclipse.birt.report.engine.dataExtraction

arthurj said...

Actually, i am trying to show data that has duplicate suppression for xml output. I am trying to reverse duplicate suppress (set it false) so my data will show up in the xml output.

arthurj said...

My columns have duplicate suppression set to true for grouped columns, but i do not want that for xml output.

Jason Weathersby said...

What XML Emitter are you using?
Are you re running the report for the xml output?

arthurj said...

I am using the xml emitter downloaded from the following site.
http://www.actuate.com/download/birt/contributions/birt2.2.1/org.eclipse.birt.report.engine.emitter.xml.zip

arthurj said...

Yes I am running the report using the emitter that i mentioned above. I have literally tried everything i know, and the data is still missing.

thanks

Jason Weathersby said...

Can you build a sample report that shows the issue and email it to me?

arthurj said...

Jason,
Sent - thanks

arthurj said...

Jason,
Thanks for offering to review my issue. I was finally able to resolve this issue in the startData(...) method of the emitter. I have successfully tested this approach.

private void turnOffSuppresedDuplicates(IDataContent data)
{
DataItemDesign dataItem = (DataItemDesign) data.getGenerateBy();
if(dataItem instanceof DataItemDesign)
{
if(dataItem.getSuppressDuplicate())
{
dataItem.setSuppressDuplicate(false);
}
}
}

Jason Weathersby said...

Good to read. It would be good if you could post your emitter to birt-exchange dev share. It sounds like a great example.

Unknown said...

Hi,

I have deployed BIRT report after generating it through Report Engine API.

But while creating the Report , i am getting the following error :

Line Number:1 Error Code:Error.XMLParserException.SAX_ERROR Exception:org.xml.sax.SAXParseException: Content is not allowed in prolog. Message:SAX detected an error with the basic XML syntax of the file.


Error.DesignFileException.INVALID_XML - 2 errors found!
1.) ( line = 1, tag = null) org.eclipse.birt.report.model.util.XMLParserException (code = Error.XMLParserException.SAX_ERROR, message : Line Number:1 Error Code:Error.XMLParserException.SAX_ERROR Exception:org.xml.sax.SAXParseException: Content is not allowed in prolog. Message:SAX detected an error with the basic XML syntax of the file. )
2.) ( line = 1) org.xml.sax.SAXParseException (message : Content is not allowed in prolog.)

I have seen the same error posted at different sites but with no solutions replied....

Could some one help me out , How to resolve this issue ?
Thanks

Jason Weathersby said...

Can you send me the report design at:
jasonweathersby at windstream dot net?

Jason

Unknown said...

Hi jason,

I sent you the design file via mail.

Could you please check if something is wrong ???

ESWAR-SVCCAM said...

Hi there. i have plenty of fields in the table. when i try to open in report as html format it is giving nice look with.when i done with pdf format , the fields are getting merged and collapsed. how to avoid this ?

Jason Weathersby said...

What version of BIRT are you using? Do you have the layout set to fixed or auto?

Justin said...

Is there any way we can support multi value list box in BIRT Query?

Anonymous said...

Hi Jason,

Is there any way of dynamically changing the contents of the report (In my case need to customize few reports images) based on user preferences.

I have standard rptdesign file which includes links to shared resources folder which contain images for default reports.

I am setting EngineConfig with default report images path through setResourcePath. Before the design file is passed to the report engine, I manually change the image path, traversing through the designElementHandle and setting the customized absolute iamge path for ImageHandle.

I see below exception during report generation.

18-Dec-2013 17:33:41 org.eclipse.birt.report.engine.api.impl.RunAndRenderTask doRun
SEVERE: An error happened while running the report. Cause:
org.mozilla.javascript.EvaluatorException: illegal character (#1)
at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:109)
at org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:96)
at org.mozilla.javascript.Parser.addError(Parser.java:146)


Is there any way i can override the resourcePath for which ever image i wish

shubhu said...

hi,
i have details for a particular day.
and i know how to create BIRT report for it. but now i wanna create the same report for bulk of data (say from 1st jan 2014 to 1st feb 2014)

will you plz guide me regarding this...?
it there any method by which i can apply loop over the complete birt report..