Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » RunReport example does not show image
RunReport example does not show image [message #64324] Wed, 03 August 2005 22:36 Go to next message
Eclipse UserFriend
Originally posted by: jyl.us.ibm.com

I'm a newbie.

I am trying RunReport.java, the command-line utility to generate BIRT
reports as follows:

java RunReport DynamicSeriesPieChart.rptdesign -h sample=Hello

In fact, I run this from Eclipse. It runs and generates a html file, but
the image is missing. When carefully reading the debugging messages
printed in the console (shown below), I see "[INFO]: Successfully deleted
temporary PNG file created at
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\chart26620.PNG."

Will appreciate any help.

Thanks,
Juhnyoung

------------------------------------------------------------ ------------

Aug 3, 2005 6:21:30 PM org.eclipse.birt.core.util.BirtTimer logTimeTaken
INFO: Engine startup takes 591 Milliseconds.
Aug 3, 2005 6:21:32 PM org.eclipse.birt.data.engine.impl.DataEngineImpl
<init>
INFO: Data Engine starts up
Parameter sample not found in the report.
Aug 3, 2005 6:21:32 PM org.eclipse.birt.data.engine.impl.DataEngineImpl
<init>
INFO: Data Engine starts up
[INFO]: getProperty(...) - chart.instance
[INFO]: ChartReportItemQueryImpl: getReportQueries(...) - start
[ERR]: Base series definition (Base Series) will be used as a static
expression
[INFO]: ChartReportItemQueryImpl: getReportQueries(...) - end
Aug 3, 2005 6:21:34 PM
org.eclipse.birt.report.engine.content.impl.MasterPageConten t
initSimpleMasterPage
INFO: The property HeaderHeight is not set. Use Default 1 cm.
Aug 3, 2005 6:21:34 PM
org.eclipse.birt.report.engine.content.impl.MasterPageConten t
initSimpleMasterPage
INFO: The property FooterHeight is not set. Use default 1 cm.
[INFO]: getProperty(...) - chart.instance
[INFO]: ChartReportItemGenerationImpl: onRowSets(...) - start
[ERR]: Base series definition (Base Series) will be used as a static
expression
August, Chris Kwai, 232,
August, Ice Bella, 291,
August, Nola Dicci, 567,
September, Chris Kwai, 312,
September, Ice Bella, 614,
September, Nola Dicci, 212,
[INFO]: (ECLIPSE-ENV) Creating dsp
org.eclipse.birt.chart.datafeed.DataSetProcessorImpl
[INFO]: (ECLIPSE-ENV) Creating dsp
org.eclipse.birt.chart.datafeed.DataSetProcessorImpl
[INFO]: (ECLIPSE-ENV) Creating dsp
org.eclipse.birt.chart.datafeed.DataSetProcessorImpl
[INFO]: ChartReportItemPresentationImpl: onRowSets(...) - building chart
[INFO]: Writing to PNG file at
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\chart26620.PNG
[INFO]: SWING Display Server: Sun Microsystems Inc. v1.4.2
[INFO]: (ECLIPSE-ENV) Creating display server ds.SWING as
org.eclipse.birt.chart.device.swing.SwingDisplayServer
[INFO]: (ECLIPSE-ENV) Creating device dv.PNG as
org.eclipse.birt.chart.device.image.PngRendererImpl
[INFO]: Presentation uses bounds
bo=org.eclipse.birt.chart.model.attribute.impl.BoundsImpl@4eb043 (left:
0.0, top: 0.0, width: 399.75, height: 452.25)
[INFO]: (ECLIPSE-ENV) Creating series renderer
org.eclipse.birt.chart.render.Pie
[INFO]: (ECLIPSE-ENV) Creating series renderer
org.eclipse.birt.chart.render.Pie
[INFO]: Time to compute plot (without axes) = 170 ms
[INFO]: ChartReportItemPresentationImpl: onRowSets(...) - rendering chart
[INFO]: Using graphics context
sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,na me=Dialog,style=plain,size=12],color=java.awt.Color[r=255,g= 255,b=255]]
[INFO]: org.eclipse.birt.chart.render.EmptyWithoutAxes: renderSeries()
[1/3]
[INFO]: {0}: renderSeries() [{1}/{2}]org.eclipse.birt.chart.render.Pie23
[INFO]: {0}: renderSeries() [{1}/{2}]org.eclipse.birt.chart.render.Pie33
[INFO]: Time to render everything = 71 ms
[INFO]: Using {0} image writer
{1}pngcom.sun.imageio.plugins.png.PNGImageWriter
[INFO]: ChartReportItemPresentationImpl: onRowSets(...) - end
[INFO]: ChartReportItemPresentationImpl: finish(...) - start
[INFO]: Successfully deleted temporary PNG file created at
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\chart26620.PNG
[INFO]: ChartReportItemPresentationImpl: finish(...) - end
Aug 3, 2005 6:21:36 PM org.eclipse.birt.data.engine.impl.DataEngineImpl
shutdown
INFO: Data engine shuts down
Re: RunReport example does not show image [message #64349 is a reply to message #64324] Thu, 04 August 2005 01:32 Go to previous messageGo to next message
Nina Li is currently offline Nina LiFriend
Messages: 44
Registered: July 2009
Member
Greeting,

For resolving the issue you mentioned, please add the following code into
RunReport.java.

HTMLRenderContext renderContext = new HTMLRenderContext();
task.setContext(renderContext);

If you'd like to put the output images into a designated folder, please
add: renderContext.setImageDirectory("folderName");

Cheers.

Regards,
Nina
Re: RunReport example does not show image [message #64967 is a reply to message #64349] Thu, 04 August 2005 19:56 Go to previous message
Eclipse UserFriend
Originally posted by: jyl.us.ibm.com

Nina,

Thanks for the info. I tried it, but it did not work. Where in the program
should I insert the statements? Will appreciate your help/advice.

Attached is the printout in the console, and also the current program with
the inserted statements.

Thanks,
Juhnyoung

========================== printout in console
=============================
Aug 4, 2005 3:53:26 PM org.eclipse.birt.core.util.BirtTimer logTimeTaken
INFO: Engine startup takes 621 Milliseconds.
Aug 4, 2005 3:53:28 PM org.eclipse.birt.data.engine.impl.DataEngineImpl
<init>
INFO: Data Engine starts up
Parameter sample not found in the report.
Aug 4, 2005 3:53:29 PM org.eclipse.birt.data.engine.impl.DataEngineImpl
<init>
INFO: Data Engine starts up
line 1 column 1 - Warning: inserting missing 'title' element
[INFO]: getProperty(...) - chart.instance
[INFO]: ChartReportItemQueryImpl: getReportQueries(...) - start
[ERR]: Base series definition (Base Series) will be used as a static
expression
[INFO]: ChartReportItemQueryImpl: getReportQueries(...) - end
Aug 4, 2005 3:53:31 PM
org.eclipse.birt.report.engine.content.impl.MasterPageConten t
initSimpleMasterPage
INFO: The property HeaderHeight is not set. Use Default 1 cm.
Aug 4, 2005 3:53:31 PM
org.eclipse.birt.report.engine.content.impl.MasterPageConten t
initSimpleMasterPage
INFO: The property FooterHeight is not set. Use default 1 cm.
[INFO]: getProperty(...) - chart.instance
Aug 4, 2005 3:53:31 PM
org.eclipse.birt.report.data.oda.sampledb.SampleDBDriver <clinit>
INFO: SampleDB driver loaded.
Url=jdbc:derby:jar:(C:\eclipse\plugins\org.eclipse.birt.repo rt.viewer_1.0.0\birt\WEB-INF\plugins\org.eclipse.birt.report .data.oda.sampledb\db\BirtSample.jar)BirtSample
Aug 4, 2005 3:53:31 PM
org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager
loadDriverExtensions
INFO: Found JDBC driverinfo extension:
driverClass=sun.jdbc.odbc.JdbcOdbcDriver, connectionFactory=null
Aug 4, 2005 3:53:31 PM
org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager
loadDriverExtensions
INFO: Found JDBC driverinfo extension:
driverClass=org.apache.derby.jdbc.EmbeddedDriver, connectionFactory=null
Aug 4, 2005 3:53:31 PM
org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager
loadAndRegisterDriver
INFO: Loading JDBC driver class: org.apache.derby.jdbc.EmbeddedDriver
Aug 4, 2005 3:53:32 PM
org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager
loadAndRegisterDriver
INFO: Loaded JDBC driver class in class path:
org.apache.derby.jdbc.EmbeddedDriver
[INFO]: ChartReportItemGenerationImpl: onRowSets(...) - start
[ERR]: Base series definition (Base Series) will be used as a static
expression
Classic Cars, 3853922.4899999965,
Motorcycles, 1121426.1199999999,
Planes, 954637.5400000003,
Ships, 663998.34,
Trains, 188532.92,
Trucks and Buses, 1024113.5699999998,
Vintage Cars, 1797559.6299999994,
[INFO]: (ECLIPSE-ENV) Creating dsp
org.eclipse.birt.chart.datafeed.DataSetProcessorImpl
[INFO]: (ECLIPSE-ENV) Creating dsp
org.eclipse.birt.chart.datafeed.DataSetProcessorImpl
[INFO]: ChartReportItemPresentationImpl: onRowSets(...) - building chart
[INFO]: Writing to PNG file at
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\chart5103.PNG
[INFO]: SWING Display Server: Sun Microsystems Inc. v1.4.2
[INFO]: (ECLIPSE-ENV) Creating display server ds.SWING as
org.eclipse.birt.chart.device.swing.SwingDisplayServer
[INFO]: (ECLIPSE-ENV) Creating device dv.PNG as
org.eclipse.birt.chart.device.image.PngRendererImpl
[INFO]: Presentation uses bounds
bo=org.eclipse.birt.chart.model.attribute.impl.BoundsImpl@79b177 (left:
0.0, top: 0.0, width: 502.5, height: 256.5)
[INFO]: (ECLIPSE-ENV) Creating series renderer
org.eclipse.birt.chart.render.Pie
[INFO]: Time to compute plot (without axes) = 160 ms
[INFO]: ChartReportItemPresentationImpl: onRowSets(...) - rendering chart
[INFO]: Using graphics context
sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,na me=Dialog,style=plain,size=12],color=java.awt.Color[r=255,g= 255,b=255]]
[INFO]: org.eclipse.birt.chart.render.EmptyWithoutAxes: renderSeries()
[1/2]
[INFO]: {0}: renderSeries() [{1}/{2}]org.eclipse.birt.chart.render.Pie22
[INFO]: Time to render everything = 241 ms
[INFO]: Using {0} image writer
{1}pngcom.sun.imageio.plugins.png.PNGImageWriter
[INFO]: ChartReportItemPresentationImpl: onRowSets(...) - end
[INFO]: ChartReportItemPresentationImpl: finish(...) - start
[INFO]: Successfully deleted temporary PNG file created at
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\chart5103.PNG
[INFO]: ChartReportItemPresentationImpl: finish(...) - end
Aug 4, 2005 3:53:37 PM org.eclipse.birt.data.engine.impl.DataEngineImpl
shutdown
INFO: Data engine shuts down


======================== current source of RunReport.java
===================


/*
* Example command-line utility to generate BIRT reports. Shows the basics
* of integrating the BIRT report engine into a simple Java application.
*
* http://www.eclipse.org/birt/index.php?page=deploy/engine.htm l
* Example java RunReport test.rptdesign -h sample=Hello
* Example java RunReport test.rptdesign -i
*/
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;

import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.EngineException;
import org.eclipse.birt.report.engine.api.HTMLCompleteImageHandler;
import org.eclipse.birt.report.engine.api.HTMLEmitterConfig;
import org.eclipse.birt.report.engine.api.HTMLRenderContext;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.IGetParameterDefinitionTa sk;
import org.eclipse.birt.report.engine.api.IParameterDefnBase;
import org.eclipse.birt.report.engine.api.IParameterGroupDefn;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import org.eclipse.birt.report.engine.api.IScalarParameterDefn;
import org.eclipse.birt.report.engine.api.ReportEngine;


/**
* Runs a BIRT report and writes the output to a directory.
*
* RunReport report-name -[h|p] [-i] param=value
*
* -h HTML (default)
* -p PDF
* -i Display report info.
*
* param=value Set parameter "param" to the value "value".
*/

public class RunReport
{

// Command-line main to parse arguments described above.

public static void main(String[] args)
{
int i = 0;
if ( i >= args.length )
{
System.out.println( "No report specified." );
return;
}
String reportName = args[i++];
String format = null;
boolean showInfo = false;

// Stoare parameter values into a hash map to later pass to the
// BIRT report engine.

HashMap params = new HashMap( );
for ( ; i < args.length; i++ )
{
if ( args[i].charAt(0) == '-' )
{
char flag = Character.toLowerCase( args[i].charAt( 1 ) );
if ( flag == 'p' )
{
format = HTMLRenderOption.OUTPUT_FORMAT_PDF;
}
else if ( flag == 'h' )
{
format = HTMLRenderOption.OUTPUT_FORMAT_HTML;
}
else if ( flag == 'i' )
{
showInfo = true;
}
else
{
usage( );
return;
}
}
else
{
// Get a parameter value. Note, this example code only works
// for string parameters. If you have date or number parameters,
// your application should parse them, then put the corresponding
// objects into the hash map.

String arg = args[i];
int posn = arg.indexOf( '=' );
if ( posn == -1 )
{
usage( );
return;
}
String param = arg.substring( 0, posn );
String value = arg.substring( posn + 1 );
params.put( param, value );
}
}
run( reportName, params, format, showInfo );
}

public static void usage( )
{
System.out.println( "java RunReport rptName [-h|p]\n" );
System.out.println( " param=value ..." );
}

// Example function to run a report given the report name, parameters and
// output type. The output is put into a file in the same directory as the
// report itself.

public static void run( String name, HashMap params,
String format, boolean showInfo )
{
// The EngineConfig is used to set up engine-wide configuration
// information.

EngineConfig config = new EngineConfig( );

// The Engine home is the location of the BIRT engine runtime.
// M3 Note: Use the report engine installed as part of the BIRT web app
// used to preview reports. Alter this path to the location of your
// Eclipse installation.
config.setEngineHome(" C://eclipse//plugins//org.eclipse.birt.report.viewer_1.0.0// birt//WEB-INF");
//config.setEngineHome(
" C:/eclipse/plugins/org.eclipse.birt.report.viewer_0.0.1/birt /WEB-INF " );

// HTML reports can have embedded images or charts. Set up the
configuration
// required to write these into a directory in the output directory.
// The HTMLCompleteImageHandler is one provided by BIRT for this purpose.
// Your application can create a customized version to provide
alternative
// ways to handle images.

HTMLEmitterConfig hc = new HTMLEmitterConfig( );
HTMLCompleteImageHandler imageHandler = new HTMLCompleteImageHandler( );
hc.setImageHandler( imageHandler );
config.setEmitterConfiguration( HTMLRenderOption.OUTPUT_FORMAT_HTML, hc
);

// Create the report engine itself. This engine can be used to run
// multiple reports.

ReportEngine engine = new ReportEngine( config );

// Open the report design.

IReportRunnable report = null;
try
{
report = engine.openReportDesign( name );
}
catch ( EngineException e )
{
System.err.println( "Report " + name + " not found!\n" );
engine.destroy( );
return;
}

if ( showInfo )
{
showReportInfo( engine, report );
}

// Create a task to run the report and convert the output to HTML
// or PDF.

if ( format != null )
{

parseParams( engine, report, params );

IRunAndRenderTask task = engine.createRunAndRenderTask( report );
HTMLRenderOption options = new HTMLRenderOption( );
options.setOutputFormat( format );
String output = name.replaceFirst( ".rptdesign", "." + format );
options.setOutputFileName( output );
task.setRenderOption( options );
task.setParameterValues( params );

HTMLRenderContext renderContext = new HTMLRenderContext();
task.setContext(renderContext);

// Run the report.

try
{
task.run( );
}
catch ( EngineException e1 )
{
System.err.println( "Report " + name + " run failed.\n" );
System.err.println( e1.toString( ) );
}
}

engine.destroy( );
}

// Display properties of the report and the list of report parameters.

static void showReportInfo( ReportEngine engine, IReportRunnable report )
{
// Display some of the general report properties.
// See the ROM Design specification for a list of properties.

System.out.print( "Report Name: " + report.getReportName() +
"\nTitle: " + report.getProperty( "title" ) +
"\nComments: " + report.getProperty( "comments" ) +
"\nDescription: " + report.getProperty( "description" ) +
"\nAuthor: " + report.getProperty( "author" ) +
"\nCreated By: " + report.getProperty( "createdBy" ) +
"\n" );

// Display the list of report parameters with their groups.
// Parameters defined outside a group appear inside a default, unnamed
// group.

IGetParameterDefinitionTask task =
engine.createGetParameterDefinitionTask( report );
Collection params = task.getParameterDefns( true );

HTMLRenderContext renderContext = new HTMLRenderContext();
task.setContext(renderContext);

if ( params.isEmpty() )
{
System.out.print( "This report has no parameters.\n" );
return;
}

Iterator iter = params.iterator( );
while ( iter.hasNext( ) )
{
IParameterDefnBase param = (IParameterDefnBase) iter.next( );
if ( param instanceof IParameterGroupDefn )
{
IParameterGroupDefn group = (IParameterGroupDefn) param;
System.out.println( "Parameter Group: " + group.getDisplayName( ) );
Iterator i2 = group.getContents( ).iterator( );
while ( iter.hasNext( ) )
{
IScalarParameterDefn member = (IScalarParameterDefn) i2.next( );
showParam( task, member, " " );
}
}
else
showParam( task, param, "" );
}
}

// Show information for one parameter.
// Release 1 supports only scalar (single-value) parameters.

static void showParam( IGetParameterDefinitionTask task,
IParameterDefnBase defn,
String prefix )
{
IScalarParameterDefn param = (IScalarParameterDefn) defn;
System.out.println( prefix + "Parameter: " + param.getName( ) );
System.out.println( prefix + " Display Name: " + param.getDisplayName(
) );
System.out.println( prefix + " Type: " + param.getDataType( ) );
System.out.print( prefix + " Default Value: " );

// The default value is an expression. Evaluate it.

Object value = task.getDefaultValue( param );
System.out.println( value == null ? "none" : value.toString( ) );
}

static void parseParams( ReportEngine engine, IReportRunnable report,
HashMap values )
{
if ( values.isEmpty( ) )
return;

IGetParameterDefinitionTask task =
engine.createGetParameterDefinitionTask( report );
Collection params = task.getParameterDefns( false );
Iterator iter = values.keySet( ).iterator( );

HTMLRenderContext renderContext = new HTMLRenderContext();
task.setContext(renderContext);

while ( iter.hasNext( ) )
{
String name = (String) iter.next( );

IScalarParameterDefn found = null;
Iterator i2 = params.iterator( );
while ( i2.hasNext( ) )
{
IParameterDefnBase param = (IParameterDefnBase) i2.next( );
if ( param instanceof IParameterGroupDefn )
continue;
if ( param.getName( ).equals( name ) )
{
found = (IScalarParameterDefn) param;
break;
}
}
if ( found == null )
{
System.err.println( "Parameter " + name + " not found in the report."
);
continue;
}
String value = (String) values.get( name );
// ReportParameterConverter cfgConverter = new ReportParameterConverter(
"", Locale.getDefault( ) );
// Object obj = cfgConverter.parse( value, found.getDataType( ) );
// values.put( name, obj );
values.put( name, value );
}
}
}
Previous Topic:Print services
Next Topic:Table Width in pdf
Goto Forum:
  


Current Time: Mon Sep 16 23:16:45 GMT 2024

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

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

Back to the top