org.eclipse.birt.report.engine.api.IReportRunnable Java Examples

The following examples show how to use org.eclipse.birt.report.engine.api.IReportRunnable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EngineTask.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public boolean validateParameters( )
{
	IReportRunnable runnable = executionContext.getRunnable( );
	if ( runnable == null )
	{
		return false;
	}

	// set the parameter values into the execution context
	try
	{
		return doValidateParameters( );
	}
	catch(ParameterValidationException ex)
	{
		log.log( Level.SEVERE, ex.getMessage( ), ex );
	}
	return false;
}
 
Example #2
Source File: ReportDocumentTest.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void testDesignStream( )
{
	try
	{
		IReportRunnable runnable = engine
				.openReportDesign( new FileInputStream( new File(
						REPORT_DESIGN ) ) );
		IRunTask runTask = engine.createRunTask( runnable );
		runTask.run( REPORT_DOCUMENT );

		IReportDocument rptDoc = engine
				.openReportDocument( REPORT_DOCUMENT );
		InputStream inputStream = rptDoc.getDesignStream( );
		assertTrue( inputStream != null );
		int streamLength = ( (RAInputStream) inputStream ).available( );
		assertTrue( streamLength > 0 );
		rptDoc.close( );
	}
	catch ( Exception ex )
	{
		ex.printStackTrace( );
		fail( );
	}
}
 
Example #3
Source File: EngineCase.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void createReportDocument( String reportDesign, String reportDocument )
		throws EngineException
{
	// open the report runnable to execute.
	IReportRunnable report = engine.openReportDesign( reportDesign );
	// create an IRunTask
	IRunTask task = engine.createRunTask( report );
	try
	{
		// execute the report to create the report document.
		task.run( reportDocument );
	}
	finally
	{
		// close the task, release the resource.
		task.close( );
	}
}
 
Example #4
Source File: GetParameterDefinitionTaskTest.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void testSortByOnDatasetColumn( ) throws EngineException,
		SemanticException
{
	IReportRunnable report = engine.openReportDesign( REPORT_DESIGN );
	IGetParameterDefinitionTask task = engine
			.createGetParameterDefinitionTask( report );

	Collection list = task.getSelectionListForCascadingGroup(
			"SortBysOfSingleDataSet", new Object[0] );
	Object[] content = list.toArray( );
	assertEquals( "USA", SelectionChoiceUtil.getValue( content[1] ) );

	list = task.getSelectionListForCascadingGroup(
			"SortBysOfSingleDataSet", new Object[]{"USA"} );
	content = list.toArray( );
	assertEquals( "MA", SelectionChoiceUtil.getValue( content[1] ) );
}
 
Example #5
Source File: DataExtractionTaskTest.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * create the report document.
 * 
 * @return
 * @throws Exception
 */
protected String createReportDocument( String reportdesign,
		String reportdocument ) throws Exception
{
	reportdesign = this.genInputFile( reportdesign );
	reportdocument = this.genOutputFile( reportdocument );

	// open an report archive, it is a folder archive.
	IDocArchiveWriter archive = new FileArchiveWriter( reportdocument );
	// open the report runnable to execute.
	IReportRunnable report = engine.openReportDesign( reportdesign );
	// create an IRunTask
	IRunTask runTask = engine.createRunTask( report );
	// execute the report to create the report document.
	runTask.setAppContext( new HashMap( ) );
	runTask.run( archive );
	// close the task, release the resource.
	runTask.close( );
	return reportdocument;
}
 
Example #6
Source File: ReportEngineService.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Run and render a report with certain servlet path
 * 
 * @param request
 * 
 * @param runnable
 * @param outputStream
 * @param format
 * @param locale
 * @param rtl
 * @param parameters
 * @param masterPage
 * @param svgFlag
 * @param displayTexts
 * @param servletPath
 * @param reportTitle
 * @deprecated
 * @throws RemoteException
 * @throws IOException
 */
public void runAndRenderReport( HttpServletRequest request,
		IReportRunnable runnable, OutputStream outputStream, String format,
		Locale locale, boolean rtl, Map parameters, boolean masterPage,
		boolean svgFlag, Map displayTexts, String servletPath,
		String reportTitle ) throws RemoteException
{
	runAndRenderReport( request,
			runnable,
			outputStream,
			format,
			locale,
			rtl,
			parameters,
			masterPage,
			svgFlag,
			null,
			null,
			null,
			displayTexts,
			servletPath,
			reportTitle,
			null );
}
 
Example #7
Source File: RenderFolderDocumentTest.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * create folder-based report document
 * 
 * @param design
 *            source report design with absolute path
 * @param folderDoc
 *            folderdocument with absolute path like "c:/doc/"
 * @throws IOException
 * @throws EngineException
 */
private void createFolderDocument( String design, String folderDoc )
		throws IOException, EngineException
{
	IRunTask runTask;
	FolderArchiveWriter writer;
	folderArchive = folderDoc;

	writer = new FolderArchiveWriter( folderArchive );
	IReportRunnable runnable = engine.openReportDesign( design );
	runTask = engine.createRunTask( runnable );
	runTask.run( writer );
	runTask.close( );
	writer.finish( );

}
 
Example #8
Source File: DataExtractionTaskV0.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public DataExtractionTaskV0( ReportEngine engine, IReportDocument reader )
		throws EngineException
{
	super( engine, IEngineTask.TASK_DATAEXTRACTION );
	IReportRunnable runnable = getOnPreparedRunnable( reader );
	setReportRunnable( runnable );
	IInternalReportDocument internalDoc = (IInternalReportDocument)reader;
	Report reportIR = internalDoc.getReportIR( executionContext
			.getReportDesign( ) );
	executionContext.setReport( reportIR );
	this.report = executionContext.getReport( );
	// load the report
	this.reportDocReader = reader;
	executionContext.setReportDocument( reportDocReader );
	executionContext.setFactoryMode( false );
	executionContext.setPresentationMode( true );
}
 
Example #9
Source File: AbstractBirtReportPanel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
private IReportDocument getReportCache(InputStream reportInputStream) throws EngineException{
	IReportEngine engine = getReportEngine();
	IReportRunnable design;
	design = engine.openReportDesign(reportInputStream);
	if (isUseLocalDB()){
		updateDBUriToLocal(design);
	}
	//////////////////////////////////////////////
	 
	//design.getDesignInstance().getDataSource("").set
	//getting available report parameters
	//paramTask = engine.createGetParameterDefinitionTask(design);
	updateParametersDefinitions(design);
	//paramTask.getParameterDefn("my_parameter_name").getHandle().getElement().getProperty(null, "dataType").toString();
	//paramTask.pa
	
	//Create task to run the report - use the task to execute the report and save to disk.
	IRunTask runTask = engine.createRunTask(design);

	runTask.setParameterValues(config.getParameters());
	//HashMap parameters1 = runTask.getParameterValues();
	runTask.run(getReportCachePath());		
	runTask.close();
	IReportDocument cache = engine.openReportDocument(getReportCachePath());
	return cache;
}
 
Example #10
Source File: GetParameterDefinitionTaskTest.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void testDynamicFilterParameters( ) throws EngineException
{
	copyResource( DYNAMIC_FILTER_DESIGN, REPORT_DESIGN );
	IReportRunnable runnable = engine.openReportDesign( REPORT_DESIGN );
	IGetParameterDefinitionTask task = engine
			.createGetParameterDefinitionTask( runnable );

	// get parameter defn
	IParameterDefnBase param = task.getParameterDefn( "Param_1" );
	if ( param instanceof IDynamicFilterParameterDefn )
	{
		IDynamicFilterParameterDefn dynParam = (IDynamicFilterParameterDefn) param;
		assertNotNull( dynParam.getColumn( ) );
	}
	else
		fail( );
}
 
Example #11
Source File: ViewerHTMLActionHandler.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Build URI
 * 
 * @param action
 * @param context
 * @return
 */
private String buildHyperlink( IAction action, IReportContext context )
{
	IReportRunnable runnable = context.getReportRunnable( );
	String actionURL = action.getActionString( );
	if ( runnable != null )
	{
		ModuleHandle moduleHandle = runnable.getDesignHandle( )
				.getModuleHandle( );
		URL url = moduleHandle.findResource( actionURL, -1 );
		if ( url != null )
			actionURL = url.toString( );
	}

	return actionURL;
}
 
Example #12
Source File: PDFLineAreaLMTest.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Test case for bugzilla bug <a
 * href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=157189">157189</a> :
 * HTML BR tags cease to work for text element after page break in PDF
 * 
 * @throws EngineException
 */
public void estForeignContent( ) throws EngineException
{
	String designFile = "org/eclipse/birt/report/engine/layout/pdf/LineAreaLMTest-157189.xml";
	IReportRunnable report = openReportDesign( designFile );
	List pageAreas = getPageAreas( report );
	
		assertEquals( 2, pageAreas.size( ) );
	PageArea pageArea = (PageArea)pageAreas.get( 1 );
	Iterator logicContainers = pageArea.getBody( ).getChildren( );
	IContainerArea blockContains = (IContainerArea) logicContainers
				.next( );
	logicContainers = blockContains.getChildren( );
	IContainerArea blockContains1 = (IContainerArea) logicContainers
				.next( );
	Iterator lineAreas = blockContains1.getChildren( );
	lineAreas.next( );
	LineArea emptyLine = (LineArea)lineAreas.next( );
	assertTrue( "Second line is not an empty line.", isEmpty( emptyLine ) );
	LineArea lineArea = (LineArea)lineAreas.next( );
	assertEquals( " ", getText( lineArea, 2 ) );
	assertEquals( "paragraph 22.", getText( lineArea, 5 ) );
}
 
Example #13
Source File: ReportDocumentReader.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public synchronized IReportRunnable getReportRunnable( )
{
	if ( reportRunnable == null )
	{
		reportRunnable = loadReportRunnable( systemId,
				ORIGINAL_DESIGN_STREAM );
		if ( reportRunnable != null )
		{
			reportRunnable.setPrepared( false );
		}
		else
		{
			reportRunnable = getOnPreparedRunnable( );
		}
	}
	if ( reportRunnable != null )
	{
		return reportRunnable.cloneRunnable( );
	}
	return null;
}
 
Example #14
Source File: ReportEngineService.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * createGetParameterDefinitionTask.
 * 
 * @param runnable
 * @deprecated
 * @return the get parameter definition task
 */
public IGetParameterDefinitionTask createGetParameterDefinitionTask(
		IReportRunnable runnable )
{
	IGetParameterDefinitionTask task = null;

	try
	{
		task = engine.createGetParameterDefinitionTask( runnable );
	}
	catch ( Exception e )
	{
	}

	return task;
}
 
Example #15
Source File: ExecutionContext.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void updateRunnable( IReportRunnable newRunnable )
{
	if ( originalRunnable == null )
	{
		this.originalRunnable = this.runnable;
	}
	this.runnable = (ReportRunnable) newRunnable;
	if ( scriptContext != null )
	{
		registerDesign( runnable );
	}
	reportIR = null;
}
 
Example #16
Source File: EngineCase.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * create the report document.
 * 
 * @throws Exception
 */
protected void createReportDocument( ) throws EngineException
{
	// open the report runnable to execute.
	IReportRunnable report = engine.openReportDesign( REPORT_DESIGN );
	// create an IRunTask
	IRunTask task = engine.createRunTask( report );
	// execute the report to create the report document.
	task.run( REPORT_DOCUMENT );
	// close the task, release the resource.
	task.close( );
}
 
Example #17
Source File: ReportEngineHelper.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public IReportRunnable openReportDesign( String designName,
		IResourceLocator locator ) throws EngineException
{
	File file = new File( designName );
	if ( !file.exists( ) )
	{
		logger
				.log( Level.SEVERE,
						"{0} not found!", file.getAbsolutePath( ) ); //$NON-NLS-1$
		throw new EngineException(
				MessageConstants.DESIGN_FILE_NOT_FOUND_EXCEPTION,
				designName );
	}

	try
	{
		InputStream in = new FileInputStream( file );
		String systemId = designName;
		try
		{
			systemId = file.toURI( ).toURL( ).toString( );
		}
		catch ( MalformedURLException ue )
		{
			systemId = designName;
		}
		return openReportDesign( systemId, in, locator);
	}
	catch ( FileNotFoundException ioe)
	{
		logger
		.log( Level.SEVERE,
				"{0} not found!", file.getAbsolutePath( ) ); //$NON-NLS-1$
		throw new EngineException(
				MessageConstants.DESIGN_FILE_NOT_FOUND_EXCEPTION,
				designName );
	}
}
 
Example #18
Source File: ReportEngineService.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * createGetParameterDefinitionTask.
 * 
 * @param runnable
 * @return the get parameter definition task
 */
public IGetParameterDefinitionTask createGetParameterDefinitionTask(
		IReportRunnable runnable, InputOptions options )
{
	IGetParameterDefinitionTask task = null;

	try
	{
		HttpServletRequest request = (HttpServletRequest) options.getOption( InputOptions.OPT_REQUEST );
		Locale locale = (Locale) options.getOption( InputOptions.OPT_LOCALE );
		TimeZone timeZone = (TimeZone) options.getOption( InputOptions.OPT_TIMEZONE );

		task = engine.createGetParameterDefinitionTask( runnable );
		task.setLocale( locale );

		com.ibm.icu.util.TimeZone tz = BirtUtility.toICUTimeZone( timeZone );
		if ( tz != null )
		{
			task.setTimeZone( tz );
		}

		// set app context
		Map context = BirtUtility.getAppContext( request );
		task.setAppContext( context );
	}
	catch ( Exception e )
	{
	}

	return task;
}
 
Example #19
Source File: EngineCase.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * create the report document.
 * 
 * @throws Exception
 */
protected void createReportDocument( ) throws EngineException
{
	// open the report runnable to execute.
	IReportRunnable report = engine.openReportDesign( REPORT_DESIGN );
	// create an IRunTask
	IRunTask task = engine.createRunTask( report );
	// execute the report to create the report document.
	task.run( REPORT_DOCUMENT );
	// close the task, release the resource.
	task.close( );
}
 
Example #20
Source File: ReportEngine.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * creates a task that renders the report to a specific output format.
 * 
 * @param reportDocument
 *            a handle to an IReportDocument object
 * @param reportRunnable
 *            the runnable report design object
 * @return a task that renders a report to an output format
 */
public IRenderTask createRenderTask( IReportDocument reportDocument,
		IReportRunnable reportRunnable )
{
	logger
			.log(
					Level.FINE,
					"ReportEngine.createRenderTask: reportDocument={0}, runnable={1}",
					new Object[]{reportDocument, reportRunnable} );
	return helper.createRenderTask( reportDocument, reportRunnable );
}
 
Example #21
Source File: ApplicationClassLoader.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public ApplicationClassLoader( ReportEngine engine,
		IReportRunnable reportRunnable, Map<String, Object> appContext )
{
	this.runnable = reportRunnable;
	this.engine = engine;
	this.appContext = appContext;
}
 
Example #22
Source File: FixedRenderTask.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param engine
 *            the report engine
 * @param runnable
 *            the report runnable object
 * @param reportDoc
 *            the report document instance
 */
public FixedRenderTask( ReportEngine engine, IReportRunnable runnable,
		IReportDocument reportDoc )
{
	super( engine, IEngineTask.TASK_RENDER );
	this.reportDocument = reportDoc;
	this.reportRunnable = runnable;
	initRenderTask();
}
 
Example #23
Source File: ReportEngine.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * creates an engine task for obtaining report parameter definitions
 * 
 * @param reportRunnable
 *            the runnable report design object
 * @return a GetParameterDefinitionTask
 */
public IGetParameterDefinitionTask createGetParameterDefinitionTask(
		IReportRunnable reportRunnable )
{
	logger
			.log(
					Level.FINE,
					"ReportEngine.createGetParameterDefinitionTask: reportRunnable={0} ",
					reportRunnable );
	return helper
			.createGetParameterDefinitionTask( (ReportRunnable) reportRunnable );
}
 
Example #24
Source File: GetParameterDefinitionTaskTest.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void testMultipleValues( ) throws EngineException
{
	copyResource( REPORT_DESIGN_RESOURCE, REPORT_DESIGN );
	IReportRunnable runnable = engine.openReportDesign( REPORT_DESIGN );
	IGetParameterDefinitionTask task = engine
			.createGetParameterDefinitionTask( runnable );

	/** test the MultiValueSingleDatasetCPG
	 *  USA
	 *  		NV
	 *  				Las Vegas
	 *  		NY
	 *  				NYC
	 *  				White Plains
	 *  		PA
	 *  				Allentown
	 *  				Philadelphia
	 *  Japan
	 *  		Osaka
	 *  				Kita-ku
	 *  		Tokyo
	 *  				Minato-ku
	 */
	String cpg1 = "MultiValueSingleDatasetCPG";
	String[][] values = {{"USA"}, {"NV", "PA"}};
	Collection col = task.getSelectionListForCascadingGroup( cpg1, values );
	assertEquals( 3, col.size( ) );
	values = new String[][]{{"USA", "Japan"},
			{"NV", "NY", "PA", "Osaka", "Tokyo"}};
	col = task.getSelectionListForCascadingGroup( cpg1, values );
	assertEquals( 7, col.size( ) );
	values = new String[][]{{"USA", "Japan"}, {"PA"}};
	col = task.getSelectionListForCascadingGroup( cpg1, values );
	assertEquals( 2, col.size( ) );
}
 
Example #25
Source File: BirtUtility.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns report title from design
 * 
 * @param reportDesignHandle
 * @return
 * @throws ReportServiceException
 */
public static String getTitleFromDesign(
		IViewerReportDesignHandle reportDesignHandle )
		throws ReportServiceException
{
	String reportTitle = null;
	if ( reportDesignHandle != null )
	{
		Object design = reportDesignHandle.getDesignObject( );
		if ( design instanceof IReportRunnable )
		{
			IReportRunnable runnable = (IReportRunnable) design;
			if ( runnable.getDesignHandle( ) != null )
			{
				ModuleHandle moduleHandle = runnable.getDesignHandle( )
						.getModuleHandle( );
				String key = moduleHandle.getStringProperty( ReportDesignHandle.TITLE_ID_PROP );
				if ( key != null && moduleHandle.getMessage( key ) != null )
				{
					reportTitle = moduleHandle.getMessage( key );
				}
				else
				{
					reportTitle = (String) runnable.getProperty( IReportRunnable.TITLE );
				}
			}
			else
				reportTitle = (String) runnable.getProperty( IReportRunnable.TITLE );
		}
	}

	return reportTitle;
}
 
Example #26
Source File: ReportEngineService.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Open report design.
 * 
 * @param report
 * @param options
 *            the config options in the report design
 * @return the report runnable
 * @throws EngineException
 */
public IReportRunnable openReportDesign( String report, Map options )
		throws EngineException
{
	File file = new File( report );
	if ( !file.exists( ) )
	{
		throw new EngineException( MessageConstants.DESIGN_FILE_NOT_FOUND_EXCEPTION,
				report );
	}

	try
	{
		InputStream in = new FileInputStream( file );
		String systemId = report;
		try
		{
			systemId = file.toURI( ).toURL( ).toString( );
		}
		catch ( MalformedURLException ue )
		{
			systemId = report;
		}
		return engine.openReportDesign( systemId, in, options );
	}
	catch ( FileNotFoundException ioe )
	{
		throw new EngineException( MessageConstants.DESIGN_FILE_NOT_FOUND_EXCEPTION,
				report );
	}
}
 
Example #27
Source File: ReportDocumentReader.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public synchronized IReportRunnable getPreparedRunnable( )
{
	ReportRunnable runnable = getOnPreparedRunnable( );
	if ( runnable != null )
	{
		return runnable.cloneRunnable( );
	}
	return null;
}
 
Example #28
Source File: RunAndRenderTaskTest.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Test methods in RunAndRenderTask class
 */
public void testRunAndRenderTask( ) throws EngineException
{

	String input = this.genInputFile( "report_engine.rptdesign" );

	try
	{
		IReportRunnable runnable = engine
				.openReportDesign( new FileInputStream( new File( input ) ) );
		IRunAndRenderTask task = engine.createRunAndRenderTask( runnable );
		// validateParameters
		assertTrue( task.validateParameters( ) );
		// set/getRenderOption
		RenderOptionBase option = new RenderOptionBase( ), optionGet;
		task.setRenderOption( option );
		optionGet = (RenderOptionBase) task.getRenderOption( );
		assertEquals( "set/getRenderOption fail", option, optionGet );

		// parameters
		HashMap hm = new HashMap( ), hmGet;
		task.setParameterValues( hm );
		hmGet = task.getParameterValues( );
		assertEquals( "set/getParameterValues(hashmap) fail", hm, hmGet );

		task.setParameterValue( "p1", "p1value" );
		assertEquals( "Set/getParameterValues fail", task
				.getParameterValues( )
				.get( "p1" ), "p1value" );
	}
	catch ( FileNotFoundException e )
	{
		e.printStackTrace( );
	}
}
 
Example #29
Source File: PDFImageLMTest.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Test case for bugzilla bug <a
 * href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=168899">168899</a> :
 * Report does not output to PDF with a chart inside of a grid.
 * 
 * @throws EngineException
 */
public void testOversizedImageInGrid( ) throws EngineException
{
	String designFile = "org/eclipse/birt/report/engine/layout/pdf/168899.xml";
	IReportRunnable report = openReportDesign( designFile );
	List pageAreas = getPageAreas( report );

	assertEquals( 1, pageAreas.size( ) );
	PageArea pageArea = (PageArea) pageAreas.get( 0 );
	Iterator logicContainers = pageArea.getBody( ).getChildren( );
	assertTrue( logicContainers.hasNext( ) );
	ContainerArea blockContainer = (ContainerArea) logicContainers.next( );
	assertTrue( "Page body is not empty", !isEmpty( blockContainer ) );
}
 
Example #30
Source File: ReportEngine.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public IReportRunnable openReportDesign( String designName, IResourceLocator locator ) throws EngineException
{
	logger.log( Level.FINE,
			"ReportEngine.openReportDesign: design={0}, locator={1} ", 
			new Object[]{designName, locator}  );
	return helper.openReportDesign( designName, locator);
}