Java Code Examples for org.eclipse.birt.report.engine.api.IReportRunnable#getDesignHandle()

The following examples show how to use org.eclipse.birt.report.engine.api.IReportRunnable#getDesignHandle() . 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: PostscriptRender.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Initializes the pdfEmitter.
 * 
 * @param services
 *            the emitter svervices object.
 * @throws EngineException 
 */
private void initialize( IEmitterServices services ) throws EngineException
{
	this.services = services;
	renderOption = (RenderOption)services.getRenderOption( );
	// Gets the output file name from RenderOptionBase.OUTPUT_FILE_NAME.
	// It has the top preference.
	IReportRunnable reportRunnable = services.getReportRunnable( );
	if ( reportRunnable != null )
	{
		reportDesign = (ReportDesignHandle) reportRunnable
				.getDesignHandle( );
	}

	this.context = services.getReportContext( );
	this.output = EmitterUtil.getOuputStream( services, "report.ps" );
}
 
Example 2
Source File: DataExtractionTaskTest.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void testExtractionFromInstanceId( ) throws Exception
{
	// get the instance id
	// open the document in the archive.
	// create an RenderTask using the report document
	Set<InstanceID> instanceIds = getAllInstanceIds( document );
	for ( InstanceID iid : instanceIds )
	{
		long designId = iid.getComponentID( );
		IReportRunnable runnable = document.getReportRunnable( );
		ReportDesignHandle report = (ReportDesignHandle) runnable
				.getDesignHandle( );
		DesignElementHandle element = report.getElementByID( designId );
		if ( element instanceof TableHandle )
		{
			// we get the report let
			dataExTask.setInstanceID( iid );
			ArrayList resultSetList = (ArrayList) dataExTask
					.getResultSetList( );
			assertEquals( 1, resultSetList.size( ) );
			IExtractionResults results = dataExTask.extract( );
			int rowCount = checkExtractionResults( results );
			assertTrue( rowCount > 0 );
		}
	}
}
 
Example 3
Source File: AbstractBirtReportPanel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("rawtypes")
private static void updateDBUriToLocal(IReportRunnable design){
	ReportDesignHandle handle = (ReportDesignHandle) design.getDesignHandle();
	SlotHandle datasources = handle.getDataSources();
	Iterator dsiterator = datasources.iterator();
	for (;dsiterator.hasNext();) {
		DesignElementHandle dsHandle = (DesignElementHandle) dsiterator.next();
		if (dsHandle instanceof OdaDataSourceHandle ) {
			OdaDataSourceHandle odash = (OdaDataSourceHandle)dsHandle;
			if (odash.getExtensionID().equals(Driver.ODA_DATA_SOURCE_ID)){
				try {
					odash.setProperty(Connection.DB_URI_PROPERTY, OrientDbWebApplication.get().getOrientDbSettings().getDBUrl());
					odash.setProperty(Connection.DB_USER_PROPERTY, OrientDbWebSession.get().getUsername());
					odash.setProperty(Connection.DB_PASSWORD_PROPERTY, OrientDbWebSession.get().getPassword());
				} catch (SemanticException e) {
					LOG.error("Cen't part BIRT xml file", e);
				}
			}
		}
	}		
}
 
Example 4
Source File: ReportDocumentReader.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public ReportDesignHandle getReportDesign( )
{
	IReportRunnable reportRunnable = getReportRunnable( );
	if ( reportRunnable != null )
	{
		return (ReportDesignHandle) reportRunnable.getDesignHandle( );
	}
	return null;
}
 
Example 5
Source File: EngineTask.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected void updateRtLFlag( ) throws EngineException
{
	//get RtL flag from renderOptions
	if ( renderOptions == null )
		return;
	IReportRunnable runnable = executionContext.getRunnable( );
	if ( runnable == null )
		return;
	ReportDesignHandle handle = (ReportDesignHandle) runnable
			.getDesignHandle( );
	if ( handle != null )
	{
		Object bidiFlag = renderOptions.getOption( IRenderOption.RTL_FLAG );
		if ( Boolean.TRUE.equals( bidiFlag ) )
		{
			if ( !handle.isDirectionRTL( ) )
			{
				updateBidiStyle( true );
			}
		}
		else if ( Boolean.FALSE.equals( bidiFlag ) )
		{
			if ( handle.isDirectionRTL( ) )
			{
				updateBidiStyle( false );
			}
		}
	}
}
 
Example 6
Source File: DocumentIRTransferTest.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
void doTestDocument( ) throws Exception
{
	IReportRunnable report = engine.openReportDesign( REPORT_DESIGN );
	reportHandle = (ReportDesignHandle) report.getDesignHandle( );
	doRenderPages( );
	doRenderAll( );
	doRenderReportletWithInstanceID( );
	doRenderReportletWithBookmark( );
	doDataExtractionWithInstanceID( );
}
 
Example 7
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 8
Source File: ExecutionContext.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private void registerDesign( IReportRunnable runnable )
{
	DesignElementHandle design = (ModuleHandle) runnable.getDesignHandle( );
	element = SimpleElementFactory.getInstance( ).getElement( design );
}
 
Example 9
Source File: DataExtractionTaskTest.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public void testExtractionFromInstanceIdWithFilter( ) throws Exception
{
	// create an RenderTask using the report document
	
	Set<InstanceID> instanceIds = getAllInstanceIds( document );
	for ( InstanceID iid : instanceIds )
	{
		long designId = iid.getComponentID( );
		IReportRunnable runnable = document.getReportRunnable( );
		ReportDesignHandle report = (ReportDesignHandle) runnable
				.getDesignHandle( );
		DesignElementHandle element = report.getElementByID( designId );
		if ( element instanceof TableHandle )
		{
			// it is a sub query
			if ( iid.getComponentID( ) == 280 )
			{
				dataExTask.setInstanceID( iid );
				ArrayList resultSetList = (ArrayList) dataExTask
						.getResultSetList( );

				assertEquals( 1, resultSetList.size( ) );
				// creat filters
				IFilterDefinition[] FilterExpression = new IFilterDefinition[1];
				FilterExpression[0] = new FilterDefinition(
						new ConditionalExpression(
								"row[\"CUSTOMERNUMBER_1\"]", OP_EQ,
								"\"SubQuery_Name: 128\"" ) );
				// add filters to dataExtractionTask
				dataExTask.setFilters( FilterExpression );

				IExtractionResults results = dataExTask.extract( );
				int rowCount = checkExtractionResults( results );
				assertTrue( rowCount == 1 );
			}
		}
		else if ( element instanceof ListHandle )
		{
			// it is the top most query.
			if ( iid.getComponentID( ) == 277 )
			{
				dataExTask.setInstanceID( iid );
				doTestExtractionTaskWithFilters( 1 );
			}
		}
	}
}
 
Example 10
Source File: DocumentIRTransferTest.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
void doDataExtractionWithInstanceID( ) throws Exception
{
	IReportDocument document = engine.openReportDocument( REPORT_DOCUMENT );
	ByteArrayOutputStream out = new ByteArrayOutputStream( );
	IRenderTask renderTask = engine.createRenderTask( document );
	renderTask.getReportRunnable( ).setDesignHandle( reportHandle );
	IRenderOption option = new HTMLRenderOption( );
	option.setOutputFormat( HTMLRenderOption.OUTPUT_FORMAT_HTML );
	option.setOutputStream( out );
	renderTask.setRenderOption( option );
	renderTask.render( );
	renderTask.close( );
	String content = out.toString( "UTF-8" );

	Pattern iidPattern = Pattern.compile( "iid=\"([^\"]*)\"" );
	Matcher matcher = iidPattern.matcher( content );
	while ( matcher.find( ) )
	{
		String strIid = matcher.group( 1 );
		InstanceID iid = InstanceID.parse( strIid );
		long designId = iid.getComponentID( );
		IReportRunnable runnable = renderTask.getReportRunnable( );
		ReportDesignHandle report = (ReportDesignHandle) runnable
				.getDesignHandle( );
		DesignElementHandle element = report.getElementByID( designId );
		if ( element instanceof TableHandle
				|| element instanceof ListHandle )
		{
			IDataExtractionTask task = engine
					.createDataExtractionTask( document );
			task.setInstanceID( iid );
			IExtractionResults results = task.extract( );
			if ( element instanceof TableHandle )
			{
				assertEquals( 27, getFieldCount( results ) );
			}
			else
			{
				assertEquals( 6, getFieldCount( results ) );
			}
			task.close( );

		}
	}
	document.close( );
}
 
Example 11
Source File: ReportDocumentTest.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
void doDataExtractionWithInstanceID( ) throws Exception
{
	IReportDocument document = engine.openReportDocument( REPORT_DOCUMENT );
	ByteArrayOutputStream out = new ByteArrayOutputStream( );
	IRenderTask renderTask = engine.createRenderTask( document );
	IRenderOption option = new HTMLRenderOption( );
	option.setOutputFormat( HTMLRenderOption.OUTPUT_FORMAT_HTML );
	option.setOutputStream( out );
	renderTask.setRenderOption( option );
	renderTask.render( );
	renderTask.close( );
	String content = out.toString( "UTF-8" );

	Pattern iidPattern = Pattern.compile( "iid=\"([^\"]*)\"" );
	Matcher matcher = iidPattern.matcher( content );
	while ( matcher.find( ) )
	{
		String strIid = matcher.group( 1 );
		InstanceID iid = InstanceID.parse( strIid );
		long designId = iid.getComponentID( );
		IReportRunnable runnable = renderTask.getReportRunnable( );
		ReportDesignHandle report = (ReportDesignHandle) runnable
				.getDesignHandle( );
		DesignElementHandle element = report.getElementByID( designId );
		if ( element instanceof TableHandle
				|| element instanceof ListHandle )
		{
			IDataExtractionTask task = engine
					.createDataExtractionTask( document );
			task.setInstanceID( iid );
			IExtractionResults results = task.extract( );
			if ( element instanceof TableHandle )
			{
				assertEquals( 27, getFieldCount( results ) );
			}
			else
			{
				assertEquals( 6, getFieldCount( results ) );
			}
			task.close( );

		}
	}
	document.close( );
}