Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Java - Execute Modified Report (BIRT)"

m (ExecuteModifedReport .java)
 
(4 intermediate revisions by the same user not shown)
Line 14: Line 14:
 
== Source ==
 
== Source ==
 
===ExecuteModifedReport .java===
 
===ExecuteModifedReport .java===
 
 
  
 
  import java.util.ArrayList;
 
  import java.util.ArrayList;
Line 48: Line 46:
 
  import org.eclipse.birt.report.model.api.elements.structures.ComputedColumn;
 
  import org.eclipse.birt.report.model.api.elements.structures.ComputedColumn;
 
   
 
   
 +
public class ExecuteModifedReport
 +
{
 +
    public void runReport() throws EngineException
 +
    {
 +
        IReportEngine engine=null;
 +
        EngineConfig config = null;
 +
       
 +
        try
 +
        {
 +
            //Configure the Engine and start the Platform
 +
            config = new EngineConfig( );
 +
            config.setEngineHome( "C:/birt-runtime-2_1_1/birt-runtime-2_1_1/ReportEngine" );
 +
            config.setLogConfig(null, Level.FINE);
 +
       
 +
            Platform.startup( config );
 +
            IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
 +
            engine = factory.createReportEngine( config );
 +
            engine.changeLogLevel( Level.WARNING );
 +
        }
 +
        catch( Exception ex )
 +
        {
 +
            ex.printStackTrace();
 +
        }
 +
       
 +
        //Configure the emitter to handle actions and images
 +
        HTMLEmitterConfig emitterConfig = new HTMLEmitterConfig( );
 +
        emitterConfig.setActionHandler( new HTMLActionHandler( ) );
 +
        HTMLServerImageHandler imageHandler = new HTMLServerImageHandler( );
 +
        emitterConfig.setImageHandler( imageHandler );
 +
        config.getEmitterConfigs( ).put( "html", emitterConfig ); //$NON-NLS-1$
 +
       
 +
        IReportRunnable design = null;
 
   
 
   
+
        //Open the report design  
public class ExecuteModifedReport {
+
        design = engine.openReportDesign("C:/tmp/testde.rptdesign");  
+
       
public void runReport() throws EngineException
+
        ReportDesignHandle report = (ReportDesignHandle) design.getDesignHandle( );
{
+
        buildReport( report );  
+
       
IReportEngine engine=null;
+
        //Create task to run and render the report,
EngineConfig config = null;
+
        IRunAndRenderTask task = engine.createRunAndRenderTask(design);  
+
       
try{
+
        //Set Render context to handle url and image locataions
+
        HTMLRenderContext renderContext = new HTMLRenderContext();
+
        //Set the Base URL for all actions
//Configure the Engine and start the Platform
+
        renderContext.setBaseURL("baseurl");
config = new EngineConfig( );
+
        //Tell the Engine to prepend all images with this URL - Note this requires using the HTMLServerImageHandler
config.setEngineHome( "C:/birt-runtime-2_1_1/birt-runtime-2_1_1/ReportEngine" );
+
        renderContext.setBaseImageURL("urltoimages");
config.setLogConfig(null, Level.FINE);
+
        //Tell the Engine where to write the images to
+
        renderContext.setImageDirectory("C:/xampplite/htdocs/myimages");
Platform.startup( config );
+
        //Tell the Engine what image formats are supported.  Note you must have SVG in the string  
IReportEngineFactory factory = (IReportEngineFactory) Platform
+
        //to render charts in SVG.
.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
+
        renderContext.setSupportedImageFormats("JPG;PNG;BMP;SVG");
engine = factory.createReportEngine( config );
+
        HashMap contextMap = new HashMap();
engine.changeLogLevel( Level.WARNING );
+
        contextMap.put( EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT, renderContext );
+
        task.setAppContext( contextMap );
}catch( Exception ex){
+
        //Set parameters for the report
ex.printStackTrace();
+
        //task.setParameterValues(parameters);
}
+
        //Alternatively set each seperately
+
        //task.setParameterValue("Top Count", new Integer(12));
//Configure the emitter to handle actions and images
+
        //task.validateParameters();
HTMLEmitterConfig emitterConfig = new HTMLEmitterConfig( );
+
       
emitterConfig.setActionHandler( new HTMLActionHandler( ) );
+
        HTMLRenderOption options = new HTMLRenderOption();
HTMLServerImageHandler imageHandler = new HTMLServerImageHandler( );
+
       
emitterConfig.setImageHandler( imageHandler );
+
        //Set ouptut location
config.getEmitterConfigs( ).put( "html", emitterConfig ); //$NON-NLS-1$
+
        options.setOutputFileName("C:/tmp/output.html");
+
       
IReportRunnable design = null;
+
        //Set output format
+
        options.setOutputFormat("html");
//Open the report design  
+
        task.setRenderOption(options);
design = engine.openReportDesign("C:/tmp/testde.rptdesign");  
+
       
+
        //run the report and destroy the engine
+
        //Note - If the program stays resident do not shutdown the Platform or the Engine
ReportDesignHandle report = (ReportDesignHandle) design.getDesignHandle( );
+
        task.run();
buildReport( report );  
+
        task.close();
+
        engine.shutdown();
//Create task to run and render the report,
+
        Platform.shutdown();
IRunAndRenderTask task = engine.createRunAndRenderTask(design);  
+
        System.out.println("Finished");  
+
    }
+
 
//Set Render context to handle url and image locataions
+
    public void buildReport(ReportDesignHandle designHandle)
HTMLRenderContext renderContext = new HTMLRenderContext();
+
    {
//Set the Base URL for all actions
+
        try
renderContext.setBaseURL("baseurl");
+
        {
//Tell the Engine to prepend all images with this URL - Note this requires using the HTMLServerImageHandler
+
            ElementFactory designFactory = designHandle.getElementFactory( );
renderContext.setBaseImageURL("urltoimages");
+
            buildDataSource(designFactory, designHandle);
//Tell the Engine where to write the images to
+
           
renderContext.setImageDirectory("C:/xampplite/htdocs/myimages");
+
            ArrayList cols = new ArrayList();
//Tell the Engine what image formats are supported.  Note you must have SVG in the string  
+
            cols.add("OFFICECODE");
//to render charts in SVG.
+
            cols.add("CITY");
renderContext.setSupportedImageFormats("JPG;PNG;BMP;SVG");
+
            cols.add("COUNTRY");
  HashMap contextMap = new HashMap();
+
contextMap.put( EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT, renderContext );
+
task.setAppContext( contextMap );
+
//Set parameters for the report
+
//task.setParameterValues(parameters);
+
//Alternatively set each seperately
+
//task.setParameterValue("Top Count", new Integer(12));
+
//task.validateParameters();
+
+
HTMLRenderOption options = new HTMLRenderOption();
+
+
+
//Set ouptut location
+
options.setOutputFileName("C:/tmp/output.html");
+
+
//Set output format
+
options.setOutputFormat("html");
+
task.setRenderOption(options);
+
+
//run the report and destroy the engine
+
//Note - If the program stays resident do not shutdown the Platform or the Engine
+
task.run();
+
task.close();
+
engine.shutdown();
+
Platform.shutdown();
+
System.out.println("Finished");  
+
}
+
+
public void buildReport(ReportDesignHandle designHandle){
+
+
+
try{
+
ElementFactory designFactory = designHandle.getElementFactory( );
+
+
buildDataSource(designFactory, designHandle);
+
+
 
+
ArrayList cols = new ArrayList();
+
cols.add("OFFICECODE");
+
  cols.add("CITY");
+
  cols.add("COUNTRY");
+
 
    
 
    
buildDataSet(cols, "From Offices", designFactory, designHandle);
+
            buildDataSet(cols, "From Offices", designFactory, designHandle);
 
   
 
   
TableHandle table = designFactory.newTableItem( "table", cols.size() );
+
            TableHandle table = designFactory.newTableItem( "table", cols.size() );
table.setWidth( "100%" );
+
            table.setWidth( "100%" );
table.setDataSet( designHandle.findDataSet( "ds" ) );
+
            table.setDataSet( designHandle.findDataSet( "ds" ) );
 
   
 
   
+
            PropertyHandle computedSet = table.getColumnBindings( );  
    PropertyHandle computedSet = table.getColumnBindings( );  
+
            ComputedColumn  cs1 = null;
ComputedColumn  cs1 = null;
+
 
    
 
    
  for( int i=0; i < cols.size(); i++){
+
            for( int i=0; i < cols.size(); i++ )
  cs1 = StructureFactory.createComputedColumn();
+
            {
  cs1.setName((String)cols.get(i));  
+
                cs1 = StructureFactory.createComputedColumn();
cs1.setExpression("dataSetRow[\"" + (String)cols.get(i) + "\"]");
+
                cs1.setName((String)cols.get(i));  
computedSet.addItem(cs1);
+
                cs1.setExpression("dataSetRow[\"" + (String)cols.get(i) + "\"]");
}
+
                computedSet.addItem(cs1);
 +
            }
 
   
 
   
 
+
            // table header
// table header
+
            RowHandle tableheader = (RowHandle) table.getHeader( ).get( 0 );
RowHandle tableheader = (RowHandle) table.getHeader( ).get( 0 );
+
 
   
 
   
 +
            for( int i=0; i < cols.size(); i++ )
 +
            {
 +
                LabelHandle label1 = designFactory.newLabel( (String)cols.get(i) );
 +
                label1.setText((String)cols.get(i));
 +
                CellHandle cell = (CellHandle) tableheader.getCells( ).get( i );
 +
                cell.getContent( ).add( label1 );
 +
            }
 
   
 
   
for( int i=0; i < cols.size(); i++){
+
            // table detail
LabelHandle label1 = designFactory.newLabel( (String)cols.get(i) );
+
            RowHandle tabledetail = (RowHandle) table.getDetail( ).get( 0 );
label1.setText((String)cols.get(i));
+
 
CellHandle cell = (CellHandle) tableheader.getCells( ).get( i );
+
            for( int i=0; i < cols.size(); i++ )
cell.getContent( ).add( label1 );
+
            {
}
+
                CellHandle cell = (CellHandle) tabledetail.getCells( ).get( i );
 +
                DataItemHandle data = designFactory.newDataItem( "data_"+(String)cols.get(i) );
 +
                data.setResultSetColumn( (String)cols.get(i));
 +
                cell.getContent( ).add( data );
 +
            }
 
   
 
   
// table detail
+
            designHandle.getBody( ).add( table );
RowHandle tabledetail = (RowHandle) table.getDetail( ).get( 0 );
+
        }
  for( int i=0; i < cols.size(); i++){
+
        catch(Exception e)
CellHandle cell = (CellHandle) tabledetail.getCells( ).get( i );
+
        {
DataItemHandle data = designFactory.newDataItem( "data_"+(String)cols.get(i) );
+
            e.printStackTrace();
data.setResultSetColumn( (String)cols.get(i));
+
        }
cell.getContent( ).add( data );
+
    }
}
+
 
 +
    void buildDataSource( ElementFactory designFactory, ReportDesignHandle designHandle ) throws SemanticException
 +
    {
 +
        OdaDataSourceHandle dsHandle = designFactory.newOdaDataSource( "Data Source", "org.eclipse.birt.report.data.oda.jdbc" );
 +
        dsHandle.setProperty( "odaDriverClass", "org.eclipse.birt.report.data.oda.sampledb.Driver" );
 +
        dsHandle.setProperty( "odaURL", "jdbc:classicmodels:sampledb" );
 +
        dsHandle.setProperty( "odaUser", "ClassicModels" );
 +
        dsHandle.setProperty( "odaPassword", "" );
 
   
 
   
 +
        designHandle.getDataSources( ).add( dsHandle );
 +
    }
 
   
 
   
 +
    void buildDataSet(ArrayList cols, String fromClause, ElementFactory designFactory, ReportDesignHandle designHandle ) throws SemanticException
 +
    {
 +
        OdaDataSetHandle dsHandle = designFactory.newOdaDataSet( "ds", "org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );
 +
        dsHandle.setDataSource( "Data Source" );
 +
        String qry = "Select ";
 +
 +
        for( int i=0; i < cols.size(); i++ )
 +
        {
 +
            qry += " " + cols.get(i);
 +
 +
            if( i != (cols.size() -1) )
 +
            {
 +
                qry += ",";
 +
            }
 +
        }
 +
 +
        qry += " " + fromClause;
 +
        dsHandle.setQueryText( qry );
 +
        designHandle.getDataSets( ).add( dsHandle );
 +
    }
 
   
 
   
designHandle.getBody( ).add( table );
+
    /**
}catch(Exception e){
+
      * @param args
e.printStackTrace();
+
      */
}
+
    public static void main(String[] args)  
+
    {
}
+
        try
+
        {
void buildDataSource( ElementFactory designFactory, ReportDesignHandle designHandle ) throws SemanticException
+
            ExecuteModifedReport ex = new ExecuteModifedReport( );
{
+
            ex.runReport();
+
        }
OdaDataSourceHandle dsHandle = designFactory.newOdaDataSource(
+
        catch ( Exception e )
"Data Source", "org.eclipse.birt.report.data.oda.jdbc" );
+
        {
dsHandle.setProperty( "odaDriverClass",
+
            e.printStackTrace();
"org.eclipse.birt.report.data.oda.sampledb.Driver" );
+
        }
dsHandle.setProperty( "odaURL", "jdbc:classicmodels:sampledb" );
+
    }
dsHandle.setProperty( "odaUser", "ClassicModels" );
+
 
dsHandle.setProperty( "odaPassword", "" );
+
+
  designHandle.getDataSources( ).add( dsHandle );
+
+
}
+
+
void buildDataSet(ArrayList cols, String fromClause, ElementFactory designFactory, ReportDesignHandle designHandle ) throws SemanticException
+
{
+
+
OdaDataSetHandle dsHandle = designFactory.newOdaDataSet( "ds",
+
"org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );
+
dsHandle.setDataSource( "Data Source" );
+
String qry = "Select ";
+
for( int i=0; i < cols.size(); i++){
+
qry += " " + cols.get(i);
+
if( i != (cols.size() -1) ){
+
qry += ",";
+
}
+
+
}
+
qry += " " + fromClause;
+
+
dsHandle.setQueryText( qry );
+
+
designHandle.getDataSets( ).add( dsHandle );
+
+
+
}
+
+
/**
+
  * @param args
+
*/
+
  public static void main(String[] args) {
+
  try
+
{
+
+
ExecuteModifedReport ex = new ExecuteModifedReport( );
+
ex.runReport();
+
+
}
+
catch ( Exception e )
+
{
+
e.printStackTrace();
+
}
+
}
+
 
  }
 
  }
----
 
  
 
== Comments ==
 
== Comments ==
Line 258: Line 240:
  
 
----
 
----
 +
 +
This example adds data source, data set, and elements.  To modify existing elements use the find methods of the ReportDesignHandle.
 +
For example to modify an existing Data Source use code similar to:
 +
 +
 +
ReportDesignHandle report = (ReportDesignHandle) design.getDesignHandle();
 +
OdaDataSourceHandle dsHandle = (OdaDataSourceHandle) report.findDataSource( "Data Source" );
 +
 +
dsHandle.setProperty( "odaDriverClass","mydriverclass" );
 +
dsHandle.setProperty( "odaURL", "mydriverurl" );
 +
dsHandle.setProperty( "odaUser", "user" );
 +
dsHandle.setProperty( "odaPassword", "pass" );
 +
 +
  
 
[[Category:BIRT]]
 
[[Category:BIRT]]
 
[[Category:BIRT Example]]
 
[[Category:BIRT Example]]
 
[[Category:BIRT Example Integration]]
 
[[Category:BIRT Example Integration]]
 +
 +
----
 +
Please note that the Class name in the above example code is misspelled and should be ExecuteModifiedReport instead of ExecuteModifedReport.

Latest revision as of 23:28, 24 July 2012

< To: Integration Examples (BIRT)

Execute Modifed Report

This example opens an existing report and adds a data source, data set and a table. The example also uses the Report Engine API (RE API) to execute the modified report. The table columns are dynamically created based on an ArrayList that is passed in. The columns must exist in the query that is passed in.

Add comments at the bottom of the example.

Moved from the old examples area BIRT Design Engine API

Source

ExecuteModifedReport .java

import java.util.ArrayList;
import java.util.HashMap;
import java.util.logging.Level; 

import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.EngineConstants;
import org.eclipse.birt.report.engine.api.EngineException;
import org.eclipse.birt.report.engine.api.HTMLActionHandler;
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.HTMLServerImageHandler;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import org.eclipse.birt.report.model.api.CellHandle;
import org.eclipse.birt.report.model.api.DataItemHandle;
import org.eclipse.birt.report.model.api.ElementFactory;
import org.eclipse.birt.report.model.api.LabelHandle;
import org.eclipse.birt.report.model.api.OdaDataSetHandle;
import org.eclipse.birt.report.model.api.OdaDataSourceHandle;
import org.eclipse.birt.report.model.api.PropertyHandle;
import org.eclipse.birt.report.model.api.ReportDesignHandle;
import org.eclipse.birt.report.model.api.RowHandle;
import org.eclipse.birt.report.model.api.StructureFactory;
import org.eclipse.birt.report.model.api.TableHandle;
import org.eclipse.birt.report.model.api.activity.SemanticException;
import org.eclipse.birt.report.model.api.elements.structures.ComputedColumn;

public class ExecuteModifedReport {

   public void runReport() throws EngineException
   {
       IReportEngine engine=null;
       EngineConfig config = null;
        	
       try
       {
           //Configure the Engine and start the Platform
           config = new EngineConfig( );
           config.setEngineHome( "C:/birt-runtime-2_1_1/birt-runtime-2_1_1/ReportEngine" );
           config.setLogConfig(null, Level.FINE);
        
           Platform.startup( config );
           IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
           engine = factory.createReportEngine( config );
           engine.changeLogLevel( Level.WARNING );
       }
       catch( Exception ex )
       {
           ex.printStackTrace();
       }
        
       //Configure the emitter to handle actions and images
       HTMLEmitterConfig emitterConfig = new HTMLEmitterConfig( );
       emitterConfig.setActionHandler( new HTMLActionHandler( ) );
       HTMLServerImageHandler imageHandler = new HTMLServerImageHandler( );
       emitterConfig.setImageHandler( imageHandler );
       config.getEmitterConfigs( ).put( "html", emitterConfig ); //$NON-NLS-1$
        
       IReportRunnable design = null;

       //Open the report design 
       design = engine.openReportDesign("C:/tmp/testde.rptdesign"); 
        
       ReportDesignHandle report = (ReportDesignHandle) design.getDesignHandle( );
       buildReport( report ); 
        
       //Create task to run and render the report,
       IRunAndRenderTask task = engine.createRunAndRenderTask(design); 
        
       //Set Render context to handle url and image locataions
       HTMLRenderContext renderContext = new HTMLRenderContext();
       //Set the Base URL for all actions
       renderContext.setBaseURL("baseurl");
       //Tell the Engine to prepend all images with this URL - Note this requires using the HTMLServerImageHandler
       renderContext.setBaseImageURL("urltoimages");
       //Tell the Engine where to write the images to
       renderContext.setImageDirectory("C:/xampplite/htdocs/myimages");
       //Tell the Engine what image formats are supported.  Note you must have SVG in the string 
       //to render charts in SVG.
       renderContext.setSupportedImageFormats("JPG;PNG;BMP;SVG");
       HashMap contextMap = new HashMap();
       contextMap.put( EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT, renderContext );
       task.setAppContext( contextMap );
       //Set parameters for the report
       //task.setParameterValues(parameters);
       //Alternatively set each seperately
       //task.setParameterValue("Top Count", new Integer(12));
       //task.validateParameters();
        
       HTMLRenderOption options = new HTMLRenderOption();
        
       //Set ouptut location
       options.setOutputFileName("C:/tmp/output.html");
        
       //Set output format
       options.setOutputFormat("html");
       task.setRenderOption(options);
        
       //run the report and destroy the engine
       //Note - If the program stays resident do not shutdown the Platform or the Engine
       task.run();
       task.close();
       engine.shutdown();
       Platform.shutdown();
       System.out.println("Finished"); 
   }	
  
   public void buildReport(ReportDesignHandle designHandle)
   {
       try
       {
           ElementFactory designFactory = designHandle.getElementFactory( );
           buildDataSource(designFactory, designHandle);
           
           ArrayList cols = new ArrayList();
           cols.add("OFFICECODE");
           cols.add("CITY");
           cols.add("COUNTRY");
  
           buildDataSet(cols, "From Offices", designFactory, designHandle);

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

           PropertyHandle computedSet = table.getColumnBindings( ); 
           ComputedColumn  cs1 = null;
 
           for( int i=0; i < cols.size(); i++ )
           {
               cs1 = StructureFactory.createComputedColumn();
               cs1.setName((String)cols.get(i)); 
               cs1.setExpression("dataSetRow[\"" + (String)cols.get(i) + "\"]");
               computedSet.addItem(cs1);
           }

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

           for( int i=0; i < cols.size(); i++ )
           {
               LabelHandle label1 = designFactory.newLabel( (String)cols.get(i) );	
               label1.setText((String)cols.get(i));
               CellHandle cell = (CellHandle) tableheader.getCells( ).get( i );
               cell.getContent( ).add( label1 );
           }							

           // table detail
           RowHandle tabledetail = (RowHandle) table.getDetail( ).get( 0 );
           for( int i=0; i < cols.size(); i++ )
           {
               CellHandle cell = (CellHandle) tabledetail.getCells( ).get( i );
               DataItemHandle data = designFactory.newDataItem( "data_"+(String)cols.get(i) );
               data.setResultSetColumn( (String)cols.get(i));
               cell.getContent( ).add( data );
           }

           designHandle.getBody( ).add( table );
       }
       catch(Exception e)
       {
           e.printStackTrace();
       }
   }
  
   void buildDataSource( ElementFactory designFactory, ReportDesignHandle designHandle ) throws SemanticException
   {
       OdaDataSourceHandle dsHandle = designFactory.newOdaDataSource( "Data Source", "org.eclipse.birt.report.data.oda.jdbc" );
       dsHandle.setProperty( "odaDriverClass", "org.eclipse.birt.report.data.oda.sampledb.Driver" );
       dsHandle.setProperty( "odaURL", "jdbc:classicmodels:sampledb" );
       dsHandle.setProperty( "odaUser", "ClassicModels" );
       dsHandle.setProperty( "odaPassword", "" );

       designHandle.getDataSources( ).add( dsHandle );
   }

   void buildDataSet(ArrayList cols, String fromClause, ElementFactory designFactory, ReportDesignHandle designHandle ) throws SemanticException
   {
       OdaDataSetHandle dsHandle = designFactory.newOdaDataSet( "ds", "org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );
       dsHandle.setDataSource( "Data Source" );
       String qry = "Select ";
       for( int i=0; i < cols.size(); i++ )
       {
           qry += " " + cols.get(i);
           if( i != (cols.size() -1) )
           {
               qry += ",";
           }
       }
       qry += " " + fromClause;
       dsHandle.setQueryText( qry );
        designHandle.getDataSets( ).add( dsHandle );
    }

   /**
      * @param args
      */
   public static void main(String[] args) 
   {
       try
       {
           ExecuteModifedReport ex = new ExecuteModifedReport( );
           ex.runReport();
       }
       catch ( Exception e )
       {
           e.printStackTrace();
       }
   }
}

Comments

Please enter comments below by selecting the edit icon to the right. You will need a Bugzilla account to add comments.


This example adds data source, data set, and elements. To modify existing elements use the find methods of the ReportDesignHandle. For example to modify an existing Data Source use code similar to:


ReportDesignHandle report = (ReportDesignHandle) design.getDesignHandle();
OdaDataSourceHandle dsHandle = (OdaDataSourceHandle) report.findDataSource( "Data Source" );

dsHandle.setProperty( "odaDriverClass","mydriverclass" );
dsHandle.setProperty( "odaURL", "mydriverurl" );
dsHandle.setProperty( "odaUser", "user" );
dsHandle.setProperty( "odaPassword", "pass" );

Please note that the Class name in the above example code is misspelled and should be ExecuteModifiedReport instead of ExecuteModifedReport.

Back to the top