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

The following examples show how to use org.eclipse.birt.report.engine.api.EngineException. 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: ReportletExecutor.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public ReportletExecutor( ExecutionContext context, long offset )
		throws BirtException
{
	try
	{
		int version = getVersion( context.getReportDocument( ) );
		switch ( version )
		{
			case EXECUTOR_VERSION_3 :
				executor = new ReportletExecutorV3( context, offset );
				break;
			case EXECUTOR_VERSION_4 :
				executor = new ReportletExecutorV4( context, offset );
				break;
			default :
				throw new EngineException( MessageConstants.UNSUPPORTED_DOCUMENT_VERSION_ERROR
						, version );
		}
	}
	catch ( IOException ex )
	{
		throw new EngineException( ex.getLocalizedMessage( ), ex );
	}
}
 
Example #2
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 #3
Source File: ReportletIVTest.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void setUp( ) throws Exception
{
	super.setUp( );
	new File( "./utest" ).mkdirs( );
	copyResource( RESOURCE_REPORTLET_IV_DESIGN, REPORTLET_IV_DESIGN );
	copyResource( RESOURCE_REPORTLET_QUERY_IV_DESIGN,
			REPORTLET_QUERY_IV_DESIGN );
	copyResource( RESOURCE_REPORTLET_SUBQUERY_IV_DESIGN,
			REPORTLET_SUBQUERY_IV_DESIGN );
	copyResource( RESOURCE_REPORTLET_NESTQUERY_IV_DESIGN,
			REPORTLET_NESTQUERY_IV_DESIGN );
	// create a report document
	try
	{
		createReportDocument( REPORTLET_IV_DESIGN, REPORTLET_IV_DOCUMENT );
	}
	catch ( EngineException ex )
	{
		fail( ex.getMessage( ) );
	}
}
 
Example #4
Source File: ReportDocumentReader.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
synchronized public IReportDocumentExtension getDocumentExtension(
		String name ) throws EngineException
{
	IReportDocumentExtension extension = extensions.get( name );
	if ( extension == null )
	{
		IReportEngineExtension engineExtension = this.engine
				.getEngineExtension( name );
		if ( engineExtension != null )
		{
			extension = engineExtension.createDocumentExtension( this );
			extensions.put( name, extension );
		}
	}
	return extension;
}
 
Example #5
Source File: HTMLEmitterOptimizeTest.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void testPerformanceOptimize( ) throws EngineException, IOException
{
	HTMLRenderOption options = new HTMLRenderOption( );
	options.setEnableAgentStyleEngine( true );
	options.setEmbeddable( true );
	
	ByteArrayOutputStream output = new ByteArrayOutputStream( );
	List instanceIDs = new ArrayList( );
	options.setInstanceIDs( instanceIDs );
	options.setOutputStream( output );
	//options.setEnableMetadata( true );
	IRenderTask task = createRenderTask( designFile );
	task.setRenderOption( options );
	task.render( );
	task.close( );
	String content = new String( output.toByteArray( ) );
	output.close( );
	
	String regex = "text-decoration: underline;";
	Matcher matcher = Pattern.compile( regex ).matcher( content );
	assertEquals( true, matcher.find( ) );
	
	regex = "<div style=\" text-decoration: underline;\">";
	matcher = Pattern.compile( regex ).matcher( content );
	assertEquals( false, matcher.find( ) );
}
 
Example #6
Source File: EngineCase.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Run and render the report, and return the render result.
 * 
 * @param designFile
 * @return render result.
 * @throws EngineException
 * @throws IOException
 */
protected String runAndRender( String designFile ) throws EngineException,
		IOException
{
	IRunAndRenderTask runAndRenderTask = createRunAndRenderTask( designFile );
	HTMLRenderOption options = new HTMLRenderOption( );
	ByteArrayOutputStream out = new ByteArrayOutputStream( );
	options.setOutputStream( out );
	options.setOutputFormat( "html" );
	options.setHtmlPagination( true );
	runAndRenderTask.setRenderOption( options );
	runAndRenderTask.run( );
	runAndRenderTask.close( );
	String result = new String( out.toByteArray( ) );
	out.close( );
	return result;
}
 
Example #7
Source File: ReportExtensionExecutor.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
void startReportProcess( IReportContent report )
{
	if ( report != null )
	{
		for ( IContentProcessor processor : processors )
		{
			try
			{
				processor.start( report );
			}
			catch ( EngineException ex )
			{
				context.addException( ex );
			}
		}
	}
}
 
Example #8
Source File: ReportItemReader.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public IContent execute( )
{
	try
	{
		// load it from the content stream
		loadContent( );
		// setup the report design
		initializeContent( );
	}
	catch ( IOException ex )
	{
		context.addException( new EngineException(
				ex.getLocalizedMessage( ), ex ) );
	}
	catch ( BirtException bex )
	{
		context.addException( bex );
	}
	return content;
}
 
Example #9
Source File: MetadataEmitterTest.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void testDataItemWithoutBookmark( ) throws EngineException,
		IOException
{
	String designFile = "org/eclipse/birt/report/engine/emitter/html/dataItemWithoutBookmarkMetadata_Test.xml";
	String[][] bookmarksWithMetadata = {
			{"AUTOGENBOOKMARK_1","DATA","176"},
			{"__bookmark_1","TABLE","177"},
			{"AUTOGENBOOKMARK_2","DATA","192"},
			{"AUTOGENBOOKMARK_4","DATA","204"},
			{"AUTOGENBOOKMARK_5","DATA","190"},
			{"AUTOGENBOOKMARK_8","DATA","214"},
			{"AUTOGENBOOKMARK_9","DATA","191"},
			{"AUTOGENBOOKMARK_10","DATA","193"},
			{"__bookmark_2","LIST","228"}};
	String[][] bookmarksWithoutMetadata = {};
	checkAllTask( designFile, bookmarksWithMetadata,
			bookmarksWithoutMetadata );
}
 
Example #10
Source File: PDFPageLMTest.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void testFitToPageTrue() throws EngineException
{
	/* FIXME support this case
	List pages = getPages(true, false);
	float[] scales = new float[]{0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f};
	assertTrue(pages.size( )==scales.length);
	for(int i=0; i<pages.size( ); i++)
	{
		PageArea page = (PageArea) pages.get( i );
		assertEquals(new Float(scales[i]), new Float(page.getScale( )));
	}
	*/
	
	List pages = getPages(true, true);
	float[] scales = new float[]{0.75f, 0.75f, 0.75f, 0.24f};
	assertTrue(pages.size( )==scales.length);
	for(int i=0; i<pages.size( ); i++)
	{
		PageArea page = (PageArea) pages.get( i );
		float delta = scales[i]-page.getScale( );
		assertTrue(delta>-0.01 && delta<0.01);
	}
}
 
Example #11
Source File: RenderTask.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private ArrayList<long[]> getPhysicalPageSequence(
		ArrayList<long[]> logicalPages ) throws EngineException
{
	LogicalPageSequence visiblePages = loadVisiblePages( );
	if ( visiblePages != null )
	{
		long[][] pages = visiblePages.getPhysicalPageNumbers( logicalPages
				.toArray( new long[logicalPages.size( )][] ) );
		ArrayList<long[]> physicalPages = new ArrayList<long[]>(
				pages.length );
		for ( int i = 0; i < pages.length; i++ )
		{
			physicalPages.add( pages[i] );
		}
		return physicalPages;
	}
	return logicalPages;
}
 
Example #12
Source File: ReportPageReader.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public IReportItemExecutor getNextChild( )
{
	if ( hasNextChild( ) )
	{
		try
		{
			if ( paged )
			{
				long pageNumber = pageIter.next( );
				Fragment fragment = loadPageFragment( pageNumber );
				return new BodyReader( this, fragment );
			}
			else
			{
				return bodyExecutor.getNextChild( );
			}
		}
		catch ( IOException ex )
		{
			context.addException( new EngineException(
					MessageConstants.PAGES_LOADING_ERROR, ex ) );
		}
	}
	return null;
}
 
Example #13
Source File: ReportQueryBuilder.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected IGroupDefinition getGroupDefinition( GroupDesign design,
		IBaseQueryDefinition query )
{
	String name = design.getName( );
	List groups = query.getGroups( );
	if ( groups != null && groups.size( ) > 0 )
	{
		for ( int i = 0; i < groups.size( ); i++ )
		{
			IGroupDefinition group = (IGroupDefinition) groups.get( i );
			if ( group.getName( ).equals( name ) )
			{
				return group;
			}
		}
	}
	EngineException ex = new EngineException( MessageConstants.INVALID_GROUP_ERROR, name );
	logger.log( Level.WARNING, ex.getMessage( ), ex );
	context.addException( design.getHandle( ), ex );
	return null;
}
 
Example #14
Source File: EngineExtensionManager.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected IReportEngineExtension getEngineExtension( String name )
		throws EngineException
{
	ReportEngine engine = context.getEngine( );
	if ( engine != null )
	{
		IReportEngineExtension ext = engine.getEngineExtension( name );
		if ( ext == null )
		{
			throw new EngineException( MessageConstants.UNSUPPORTED_ENGINE_EXTENSION,
					new Object[]{name} );
		}
		return ext;
	}
	return null;
}
 
Example #15
Source File: RenderTask.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected IReportExecutor createRenderExtensionExecutor(
		IReportExecutor executor ) throws EngineException
{
	// prepare the extension executor
	ArrayList<IRenderExtension> renderExtensions = loadRenderExtensions( );
	if ( renderExtensions != null )
	{
		ArrayList<IContentProcessor> processors = new ArrayList<IContentProcessor>( );
		for ( IRenderExtension extension : renderExtensions )
		{
			IContentProcessor processor = extension.getRenderProcessor( );
			if ( processor != null )
			{
				processors.add( processor );
			}
		}
		if ( !processors.isEmpty( ) )
		{
			return new ReportExtensionExecutor( executionContext, executor,
					processors.toArray( new IContentProcessor[processors
							.size( )] ) );
		}
	}
	return executor;
}
 
Example #16
Source File: EngineCase.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Run and render the report, and return the render result.
 * 
 * @param designFile
 * @return render result.
 * @throws EngineException
 * @throws IOException
 */
protected String runAndRender( String designFile ) throws EngineException,
		IOException
{
	IRunAndRenderTask runAndRenderTask = createRunAndRenderTask( designFile );
	HTMLRenderOption options = new HTMLRenderOption( );
	ByteArrayOutputStream out = new ByteArrayOutputStream( );
	options.setOutputStream( out );
	options.setOutputFormat( "html" );
	options.setHtmlPagination( true );
	runAndRenderTask.setRenderOption( options );
	runAndRenderTask.run( );
	runAndRenderTask.close( );
	String result = new String( out.toByteArray( ) );
	out.close( );
	return result;
}
 
Example #17
Source File: QueryUtil.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public static List<IBaseResultSet> getResultSet( ReportContent report,
		InstanceID instanceID )
{
	Report design = report.getDesign( );
	ExecutionContext context = report.getExecutionContext( );
	try
	{
		ArrayList<QueryTask> plan = createPlan( design, instanceID );

		return executePlan( context, plan );
	}
	catch ( EngineException ex )
	{
		context.addException( ex );
	}
	return null;
}
 
Example #18
Source File: BookmarkManager.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public boolean exist( String bookmark )
{
	try
	{
		return hashset.exist( bookmark );
	}
	catch ( IOException ex )
	{
		context.addException( new EngineException( ex.getMessage( ), ex ) );
	}
	return false;

}
 
Example #19
Source File: CubeResultSet.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void skipTo( String cellIndex ) throws BirtException
{
	try
	{
		CubeUtil.positionCursor( cube, cellIndex );
	}
	catch ( OLAPException e )
	{
		throw new EngineException( MessageConstants.SKIP_ERROR, e );
	}
}
 
Example #20
Source File: HTMLLayoutTest.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Tests a container will be output in the same page as the first
 * non-container descent. Refer to <a
 * href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=157411">Bugzilla bug
 * 157411</a>
 * @throws EngineException 
 */
public void testPageBreak() throws EngineException{
	String designFile = "org/eclipse/birt/report/engine/layout/html/HTMLLayoutTest_1.xml";
	IReportDocument document = createReportDocument( designFile );
	assertEquals( 1l, getPageNumber(document,  "Australia" ));
	assertEquals( 1l, getPageNumber(document,  "France" ));
	assertEquals( 2l, getPageNumber(document,  "Japan" ));
	assertEquals( 2l, getPageNumber(document,  "UK" ));
	assertEquals( 3l, getPageNumber(document,  "USA" ));
	document.close( );
}
 
Example #21
Source File: AbstractViewer.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected long createReportOutput( String reportDocumentFile,
		String outputFile, long pageNumber ) throws EngineException,
		IOException
{
	IReportDocument document = engine.openReportDocument( reportDocumentFile );
	long pageCount = document.getPageCount( );
	IRenderTask task = engine.createRenderTask( document );

	IRenderOption renderOption = getRenderOption( );
	renderOption.setOutputFileName( outputFile );

	try
	{
		task.setRenderOption( renderOption );
		task.setPageNumber( pageNumber );
		Map appContext = Collections.EMPTY_MAP;
		if(ExtendedDataModelUIAdapterHelper.getInstance( ).getAdapter( ) != null)
		{
			appContext = ExtendedDataModelUIAdapterHelper.getInstance( ).getAdapter( ).getAppContext( );
		}
		task.setAppContext( appContext );
		task.render( );
	}
	catch ( EngineException e )
	{
		throw e;
	}
	finally
	{
		task.close( );
		task = null;
		document.close( );
		document = null;
	}
	return pageCount;
}
 
Example #22
Source File: TOCViewTest.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void testTocViewWithFormat( ) throws EngineException, IOException
{
	ITreeNode tree = createTocWithFormat( );
	System.out.println( toString( tree ) );
	TOCView view = new TOCView( tree, null, ULocale.ENGLISH, TimeZone
			.getTimeZone( "GMT+08:00" ), "html" );
	String output = toString( view.getRoot( ) );
	System.out.println( output );
	assertEquals( TOC_WITH_FORMAT_GOLDEN.replaceAll( "\\s", "" ), output
			.replaceAll( "\\s", "" ) );
}
 
Example #23
Source File: OdpRender.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public OdpRender( IEmitterServices services, OdpContext context, OutputStream out, OutputStream mpOut ) throws EngineException
{
	initialize( services );
	this.odfContext = context;
	this.bodyOut = out;
	this.mpOut = mpOut;
}
 
Example #24
Source File: ExecutionContext.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void openDataEngine( ) throws EngineException
{
	if ( dataEngine == null )
	{
		try
		{
			dataEngine = engine.getDataEngineFactory( ).createDataEngine(
					this, needOutputResultSet );
		}
		catch ( Exception e )
		{
			throw new EngineException( MessageConstants.CANNOT_CREATE_DATA_ENGINE, e );
		}
	}
}
 
Example #25
Source File: DrillThroughActionScriptTest.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 
 * @throws EngineException
 * @throws IOException
 */
public void testActionScript( ) throws EngineException, IOException
{
	//the default cell to place the group icon is the first cell.
	String designFile = "org/eclipse/birt/report/engine/emitter/html/DrillThroughActionScriptTest.xml";
	HTMLRenderOption options = new HTMLRenderOption( );

	ByteArrayOutputStream output = new ByteArrayOutputStream( );
	List instanceIDs = new ArrayList( );
	options.setInstanceIDs( instanceIDs );
	options.setOutputStream( output );
	options.setEnableMetadata( true );
	IRenderTask task = createRenderTask( designFile );
	task.setRenderOption( options );
	task.render( );
	task.close( );
	String content = new String( output.toByteArray( ) );
	output.close( );
	
	content = content.replaceAll( "\n", "\"\n\"+\\\\n" );
	String regex = "report-document";
	Matcher matcher = Pattern.compile( regex ).matcher( content );
	assertEquals( true, matcher.find( ) );
	
	regex = "report-design";
	matcher = Pattern.compile( regex ).matcher( content );
	assertEquals( true, matcher.find( ) );
	

}
 
Example #26
Source File: EngineTask.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected IReportExecutor createReportExtensionExecutor(
		IReportExecutor executor ) throws EngineException
{
	// prepare the extension executor
	String[] extensions = executionContext.getEngineExtensions( );
	if ( extensions != null )
	{
		ArrayList<IContentProcessor> processors = new ArrayList<IContentProcessor>( );
		EngineExtensionManager manager = executionContext
				.getEngineExtensionManager( );
		for ( String extName : extensions )
		{
			IGenerateExtension genExt = manager
					.getGenerateExtension( extName );
			if ( genExt != null )
			{
				IContentProcessor processor = genExt
						.createGenerateProcessor( );
				if ( processor != null )
				{
					processors.add( processor );
				}
			}
		}
		if ( !processors.isEmpty( ) )
		{
			return new ReportExtensionExecutor( executionContext, executor,
					processors.toArray( new IContentProcessor[processors
							.size( )] ) );
		}
	}
	return executor;
}
 
Example #27
Source File: ReportBodyExecutor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
void initializeReportlet( )
{
	if ( reportlet == null )
	{
		IReportDocument document = context.getReportDocument( );

		if ( document instanceof IReportletDocument )
		{
			IReportletDocument reportletDocument = (IReportletDocument) document;
			try
			{
				if ( reportletDocument.isReporltetDocument( ) )
				{
					InstanceID iid = reportletDocument
							.getReportletInstanceID( );
					if ( iid != null )
					{
						long id = iid.getComponentID( );
						if ( id != -1 )
						{
							reportlet = new ReportletBodyExecutor( context,
									iid );
						}
					}
				}
			}
			catch ( IOException ex )
			{
				context.addException( new EngineException( ex
						.getLocalizedMessage( ), ex ) );
			}
		}
	}
}
 
Example #28
Source File: EngineCase.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Create run and render result for the design file.
 * 
 * @param designFile
 * @return run and render task.
 * @throws EngineException
 */
protected IRunAndRenderTask createRunAndRenderTask( String designFile )
		throws EngineException
{
	useDesignFile( designFile );
	IReportRunnable reportDesign = engine.openReportDesign( REPORT_DESIGN );
	IRunAndRenderTask runAndRenderTask = engine
			.createRunAndRenderTask( reportDesign );
	return runAndRenderTask;
}
 
Example #29
Source File: ExecutionContext.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @return Returns the dataEngine.
 */
public IDataEngine getDataEngine( ) throws EngineException
{
	if ( dataEngine == null )
	{
		openDataEngine( );
	}
	return dataEngine;
}
 
Example #30
Source File: MetadataEmitterTest.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void checkRenderTask( String designFile,
		String[][] bookmarksWithMetadata, String[][] bookmarksWithoutMetadata )
		throws EngineException, IOException
{
	checkTask( designFile, bookmarksWithMetadata, bookmarksWithoutMetadata,
			true );
}