Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » iDataExtract.getResultSetList() gives empty list
iDataExtract.getResultSetList() gives empty list [message #1386679] Thu, 19 June 2014 12:17 Go to next message
Al Pac is currently offline Al PacFriend
Messages: 5
Registered: June 2014
Junior Member
Hi, I try to get a list of results according to the documentation, but for some reason I am getting empty ArrayList of results though reports shows results, and I can get normal file using web viewer.
rptdocument is not empty though it is full of not readable characters and I am not sure whether it has data or not.
My code is below + I am attaching rpt document

import java.util.ArrayList;
import java.util.logging.Level;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.data.engine.core.DataException;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.EngineException;
import org.eclipse.birt.report.engine.api.IDataExtractionTask;
import org.eclipse.birt.report.engine.api.IDataIterator;
import org.eclipse.birt.report.engine.api.IExtractionResults;
import org.eclipse.birt.report.engine.api.IReportDocument;
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.IResultMetaData;
import org.eclipse.birt.report.engine.api.IResultSetItem;
import org.eclipse.birt.report.engine.api.IRunTask;


public class DataExtract {

	static void executeReport() throws EngineException
	{
	 IReportEngine engine=null;
	 EngineConfig config = null;
	 try{
	  config = new EngineConfig( );
	  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();
	 }

	 //open the report design
	 IReportRunnable design = null;

	 design = engine.openReportDesign("C:\\Users\\hpsa\\workspace\\My Reports\\new_report_1.rptdesign"); 

	 //Create task to run the report - use the task to run the report,
	 IRunTask task = engine.createRunTask(design); 

	 //Run the report and create the rptdocument
	 task.run("C:\\Users\\hpsa\\workspace\\My Reports\\new_report_1.rptdocument");

	 //Open the rptdocument
	 IReportDocument rptdoc = engine.openReportDocument("C:\\Users\\hpsa\\workspace\\My Reports\\new_report_1.rptdocument"); 

	 //Create the data extraction task
	 IDataExtractionTask iDataExtract = engine.createDataExtractionTask(rptdoc);

	 /**
	  * returns the metadata corresponding to the data stored in the report
	  * document.  Could specify a component.
	  */

	 ArrayList resultSetList = (ArrayList)iDataExtract.getResultSetList( );

	 //Get the first result set.  Note this is a table elemenent
	 IResultSetItem resultItem = (IResultSetItem)resultSetList.get( 0 );

	 //Set the name of the element you want to retrieve.  
	 //This will usually be ELEMENT_something if you do not name your elements.
	 //If you name a table for example "MyTable"  this will be the resultset name
	 String dispName = resultItem.getResultSetName( );
	 iDataExtract.selectResultSet( dispName );

	 IExtractionResults iExtractResults = iDataExtract.extract();
	 IDataIterator iData = null;

	 //Iterate the results
	 try{
	  if ( iExtractResults != null ) {
	    iData = iExtractResults.nextResultIterator( );
	    if ( iData != null  ){
	      //Get metadata on retrieved results
	      IResultMetaData irmd = iData.getResultMetaData();
	      int colCount = irmd.getColumnCount();
	      System.out.println("Column Count =" + colCount );
	      for( int j=0; j< colCount; j++){
	        System.out.println("Column Name =" + irmd.getColumnName(j) );
	        System.out.println("Column Type =" + irmd.getColumnTypeName(j) );
	      }

	      while ( iData.next( ) ) { 
	        //Just disply the first two columns
	        Object objColumn1;
	        Object objColumn2;
	        try{
	          objColumn1 = iData.getValue(0);
	        } catch(DataException e) {
	          objColumn1 = new String("");
	        }
	      
	        try{
	          objColumn2 = iData.getValue(1);
	        } catch(DataException e){
	          objColumn2 = new String("");
	        } 
	        
	        System.out.println( objColumn1 + " , " + objColumn2 );
	      }
	      iData.close();
	    }
	  }
	 }catch( Exception e){
	  e.printStackTrace();
	 }
	 //close the task and showdown the engine and Platform
	 //Note - If the program stays resident do not shutdown the Platform or the Engine  
	 iDataExtract.close();
	 engine.destroy();
	 Platform.shutdown();
	 System.out.println("Finished");
	}


	public static void main(String[] args) {
	 try
	 {
	  executeReport( );
	 }
	 catch ( Exception e )
	 {
	  e.printStackTrace();
	 }
	}
}

[Updated on: Fri, 20 June 2014 10:41]

Report message to a moderator

Re: iDataExtract.getResultSetList() gives empty list [message #1386769 is a reply to message #1386679] Fri, 20 June 2014 10:42 Go to previous messageGo to next message
Al Pac is currently offline Al PacFriend
Messages: 5
Registered: June 2014
Junior Member
Somehow I found the problem by importing additional libs.
I am not sure what I did, but it works now.
Re: iDataExtract.getResultSetList() gives empty list [message #1795334 is a reply to message #1386769] Thu, 20 September 2018 13:56 Go to previous message
saksham agarwal is currently offline saksham agarwalFriend
Messages: 2
Registered: September 2018
Junior Member
can we apply filters over IDataExtractionTask iDataExtract = engine.createDataExtractionTask(rptdoc);
something like IDataExtractionTask iDataExtract = engine.createDataExtractionTask(rptdoc).setFilter();
Previous Topic:Using two dataset and Two nested tables
Next Topic:Maximo BIRT with Stored Procedure
Goto Forum:
  


Current Time: Tue Nov 12 19:32:21 GMT 2019

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

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

Back to the top