org.eclipse.birt.core.exception.BirtException Java Examples

The following examples show how to use org.eclipse.birt.core.exception.BirtException. 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: LineArea.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void initialize( ) throws BirtException
{
	hasStyle = false;
	boxStyle = BoxStyle.DEFAULT;
	localProperties = LocalProperties.DEFAULT;
	maxAvaWidth = parent.getCurrentMaxContentWidth( );
	width = maxAvaWidth;
	// Derive the baseLevel from the parent content direction.
	if ( parent.content != null )
	{
		// IContent#isDirectionRTL already looks at computed style
		if ( parent.content.isDirectionRTL( ) )
			baseLevel = Bidi.DIRECTION_RIGHT_TO_LEFT;
	}
	//parent.add( this );
}
 
Example #2
Source File: BirtStr.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public Object execute( Object[] args,IScriptFunctionContext context ) throws BirtException
{
	if ( args == null )
		throw new IllegalArgumentException( Messages.getString( "error.arguement.cannot.empty" ) );
	if ( args.length > 3 || args.length < 2 )
		throw new IllegalArgumentException( Messages.getFormattedString( "error.argument.number.outofValidRange",
				new Object[]{
						minArgumentNum, maxArgumentNum, args.length
				} ) );

	if ( args.length == 3 )
	{
              return new Integer( search( toJavaString( args[0] ),
                      toJavaString( args[1] ),
                      ( (Number) args[2] ).intValue( ) ) );
	}
	else
	{
              return Integer.valueOf( search( toJavaString( args[0] ),
                      toJavaString( args[1] ) ) );
	}
}
 
Example #3
Source File: DataSetCacheTest.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @throws BirtException
 */
private void useCache3( ) throws BirtException
{
	myDataEngine = newDataEngine( );
	IResultIterator parentRi = getResultIterator1( myDataEngine );
	parentRi.next( );
	IResultIterator ri = parentRi.getSecondaryIterator( "IAMTEST", scope );
	Iterator it = this.expectedValue.iterator( );

	while ( ri.next( ) )
	{
		String str = "";

		Object ob1 = it.next( );
		Object ob2 = ri.getValue( "COL1" );
		assertEquals( ob1, ob2 );
		str += " " + ob2.toString( );
		System.out.println( "row result set: " + str );
	}
	ri.close( );
	parentRi.close( );
	myDataEngine.shutdown( );
}
 
Example #4
Source File: ExpressionUtilTest.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
@Test
   public void testGetColumnBindingName( ) throws BirtException
{
	assertTrue( ExpressionUtil.getColumnBindingName( "100" ) == null );
	assertTrue( ExpressionUtil.getColumnBindingName( "row[\"col1\"]" )
			.equals( "col1" ) );
	assertTrue( ExpressionUtil.getColumnBindingName( "row[\"col1\"+1]" )
			.equals( "col11" ) );
	assertTrue( ExpressionUtil.getColumnBindingName( "row[\"col1\"]+ \"abc\"" ) == null );
	assertTrue( ExpressionUtil.getColumnBindingName( "row[0]" ) == null );
	assertTrue( ExpressionUtil.getColumnBindingName( "row.col1" )
			.equals( "col1" ) );
	assertTrue( ExpressionUtil.getColumnBindingName( "100+row[\"col1\"]" ) == null );
	assertTrue( ExpressionUtil.getColumnBindingName( "Total.sum( row[\"col1\"])" ) == null );
	assertTrue( ExpressionUtil.getColumnBindingName( "row[\"col1\"]+ row[\"col2\"]" ) == null );

}
 
Example #5
Source File: CubeResultSet.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public CubeResultSet( IDataEngine dataEngine, ExecutionContext context,
		ICubeQueryDefinition queryDefn, ICubeQueryResults rsets )
		throws BirtException
{
	this.parent = null;
	this.context = context;
	this.dataEngine = dataEngine;
	this.queryDefn = queryDefn;
	this.cube = rsets.getCubeCursor( );
	if ( rsets.getID( ) != null )
	{
		this.id = new DataSetID( rsets.getID( ) );
	}
	else
	{
		this.id = new DataSetID( "cube" );
	}
	this.queryResults = rsets;
	this.queryResultsID = rsets.getID( );
}
 
Example #6
Source File: DummyPreparedQuery.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public IQueryResults execute( IBaseQueryResults outerResults,
		Scriptable scope ) throws DataException
{
	try
	{
		if ( context == null )
			return new CachedQueryResults( session,
					this.queryDefn.getQueryResultsID( ),
					this,
					this.appContext );

		else
			return new QueryResults( this.tempDir,
					this.context,
					this.queryDefn.getQueryResultsID( ),
					outerResults,
					this.targetGroups );
	}
	catch ( BirtException e )
	{
		throw DataException.wrap( e );
	}
}
 
Example #7
Source File: AbstractNode.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void start( ) throws BirtException
{
	if(isStarted)
	{
		return;
	}
	if ( parent != null && !parent.isStarted( ) )
	{
		parent.start( );
	}
	if( isVisible )
	{
		ContentEmitterUtil.startContent( content, emitter );
	}
	generator.start( content, isFirst );
	isStarted = true;

}
 
Example #8
Source File: DataSetIterator.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 
 * @param session
 * @param query
 * @param appContext
 * @throws AdapterException
 */
private void executeQuery( DataRequestSessionImpl session, IQueryDefinition query, Map appContext )
		throws AdapterException
{
	try
	{
		
		Scriptable scope = session.getScope( );
		TempDateTransformer tt = new TempDateTransformer( session.getDataSessionContext( )
				.getDataEngineContext( )
				.getLocale( ) );
		ScriptableObject.putProperty( scope, tt.getClassName( ), tt );

		queryResult = session.prepare( query, appContext ).execute( scope );
		this.it = queryResult.getResultIterator( );
	}
	catch ( BirtException e )
	{
		throw new AdapterException( e.getLocalizedMessage( ), e );
	}
}
 
Example #9
Source File: ChartExpressionUtil.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This method is to get the measure name that referenced by a measure
 * reference expression.
 * 
 * @param expr
 * @return measure name
 * @since 2.3
 */
private static String getMeasureName( String expr )
{
	if ( isMeasureExpresion( expr ) )
	{
		try
		{
			return ExpressionUtil.getReferencedMeasure( expr );
		}
		catch ( BirtException e )
		{
			logger.log( e );
		}
	}
	return null;
}
 
Example #10
Source File: BlockStackingExecutor.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public IReportItemExecutor nextInline( ) throws BirtException
{
	if(executor.hasNextChild( ))
	{
		IReportItemExecutor nextExecutor = (IReportItemExecutor)executor.getNextChild( );
		IContent nextContent = nextExecutor.execute( );
		
		if(PropertyUtil.isInlineElement(nextContent))
		{
			return new ItemExecutorWrapper(nextExecutor, nextContent);
		}
		else
		{
			this.childContent = nextContent;
			this.childExecutor = nextExecutor;
		}
	}
	return null;
}
 
Example #11
Source File: ContentUtil.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private static List<IConditionalExpression> setupHighlightExprs(
		List<HighlightRuleHandle> rules ) throws BirtException
{
	List<IConditionalExpression> exprs = new ArrayList<IConditionalExpression>( );

	DataRequestSession session = DataRequestSession.newSession( new DataSessionContext( DataSessionContext.MODE_DIRECT_PRESENTATION ) );

	try
	{
		IModelAdapter modelAdapter = session.getModelAdaptor( );

		for ( HighlightRuleHandle rule : rules )
		{
			IConditionalExpression expression = convertHighlightExpression( rule,
					modelAdapter );

			exprs.add( expression );
		}
	}
	finally
	{
		session.shutdown( );
	}

	return exprs;
}
 
Example #12
Source File: BaseCrosstabExecutor.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected void processBookmark( AbstractCrosstabItemHandle handle )
{
	try
	{
		ContentUtil.processBookmark( context,
				content,
				handle,
				getCubeResultSet( ) );
	}
	catch ( BirtException e )
	{
		logger.log( Level.SEVERE,
				Messages.getString( "BaseCrosstabExecutor.error.process.bookmark" ), //$NON-NLS-1$
				e );
	}
}
 
Example #13
Source File: MultiSheetsReportTest.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testThreeTablesRenderPaginationBug() throws BirtException, IOException {

	InputStream inputStream = runAndRenderReportDefaultTask("MultiSheets1.rptdesign", "xlsx");
	assertNotNull(inputStream);
	try {			
		XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
		assertNotNull(workbook);
		
		assertEquals( 1, workbook.getNumberOfSheets() );
		assertEquals( "Number Formats Test Report", workbook.getSheetAt(0).getSheetName());
		
		assertEquals( "3", workbook.getSheetAt(0).getHeader().getRight() );
		
		assertEquals(11, firstNullRow(workbook.getSheetAt(0)));
	} finally {
		inputStream.close();
	}
}
 
Example #14
Source File: Issue26.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testMultiRowEmptinessXls() throws BirtException, IOException {

	debug = false;
	InputStream inputStream = runAndRenderReport("Issue26.rptdesign", "xls");
	assertNotNull(inputStream);
	try {
		HSSFWorkbook workbook = new HSSFWorkbook(inputStream);
		assertNotNull(workbook);
		
		assertEquals( 1, workbook.getNumberOfSheets() );

		Sheet sheet = workbook.getSheetAt(0);
		assertEquals( 3, this.firstNullRow(sheet));
		
		assertEquals( "Hello\n\nMatey", sheet.getRow(1).getCell(0).getStringCellValue() );
		assertEquals( 41.3, sheet.getRow(1).getHeightInPoints(), 0.01 );
		assertEquals( 55.1, sheet.getRow(2).getHeightInPoints(), 0.01 );
	
	} finally {
		inputStream.close();
	}
}
 
Example #15
Source File: ExcelLayoutEngine.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void startPage( IPageContent pageContent ) throws BirtException
{
	if ( page == null || context.isEnableMultipleSheet( ) )
	{
		// intializePage method recalculate page style and page size. So it
		// only invoked when a new page is started, and not invoked in
		// outputDataIfBufferIsFull().
		initializePage( pageContent );
		newPage( );
	}
	page.startPage( pageContent );
	XlsContainer topContainer = containers.peek( );
	topContainer.setStyle( StyleBuilder.createStyleEntry( pageContent
			.getComputedStyle( ) ) );
	if ( !page.isOutputInMasterPage( )
	        && pageContent.getPageHeader( ) != null )
	{
		contentVisitor.visitChildren( pageContent.getPageHeader( ), null );
	}
}
 
Example #16
Source File: BirtDateTime.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected Object getValue( Object[] args, IScriptFunctionContext context ) throws BirtException
{
	if ( existNullValue( args ) )
	{
		return null;
	}
	Calendar current = getCalendar( DataTypeUtil.toDate( args[0] ) );
	int currentWeek = current.get( Calendar.WEEK_OF_YEAR );
	Calendar start = getFiscalYearStateDate( context, args );
	start.set( Calendar.YEAR, current.get( Calendar.YEAR ) );
	int startWeek = start.get( Calendar.WEEK_OF_YEAR );
	if ( currentWeek >= startWeek )
	{
		return currentWeek - startWeek + 1;
	}
	
	// Go to last year to add weeks together
	start.set( Calendar.YEAR, current.get( Calendar.YEAR ) - 1 );
	Calendar lastYearLastWeek = getCalendar( new Date( start.get( Calendar.YEAR ) - 1,
			11,
			31 ) );
	// Last week may return 1 as week of year
	while ( lastYearLastWeek.get( Calendar.WEEK_OF_YEAR ) == 1 )
	{
		lastYearLastWeek.add( Calendar.DAY_OF_MONTH, -1 );
	}
	return lastYearLastWeek.get( Calendar.WEEK_OF_YEAR )
			- start.get( Calendar.WEEK_OF_YEAR ) + 1 + currentWeek;
}
 
Example #17
Source File: NativeRowObject.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public Object get( String name, Scriptable start )
{
	IQueryResultSet rset = getResultSet( );
	if ( rset == null )
	{
		return null;
	}

	if ( "_outer".equals( name ) )
	{
		IBaseResultSet parent = rset.getParent( );
		if ( parent != null
				&& parent.getType( ) == IBaseResultSet.QUERY_RESULTSET )
		{
			return new NativeRowObject( start, (IQueryResultSet) parent );
		}
		else
		{
			// TODO: return cuber object used in script
			// return new NativeCubeObject(start, parent);
		}
		return null;
	}
	try
	{
		if ( "__rownum".equals( name ) )
		{
			return Long.valueOf( rset.getRowIndex( ) );
		}
		return rset.getValue( name );
	}
	catch ( BirtException ex )
	{
		throw new EvaluatorException( ex.toString( ) );
	}
}
 
Example #18
Source File: RowDataTest.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public Object evaluate( String expr )
{
	// TODO Auto-generated method stub
	try
	{
		return rs.getValue( expr );
	}
	catch ( BirtException e )
	{				
	}
	return null;
}
 
Example #19
Source File: ReportContextImpl.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public Object evaluate( String script ) throws BirtException
{
	if ( null != script && script.length( ) > 0 )
	{
		return context.evaluate( script );
	}
	return null;
}
 
Example #20
Source File: ExcelLayoutEngine.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void processForeign( IForeignContent foreign, HyperlinkDef link )
        throws BirtException
{
	addForeignContainer( foreign.getComputedStyle( ), link );
	contentVisitor.visitChildren( foreign, null );
	endContainer( );
}
 
Example #21
Source File: LocalizedContentVisitor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public IContent localize( IContent content ) throws BirtException
{
	IStyle style = content.getInlineStyle( );
	processBackgroundImage( style );
	switch ( content.getContentType( ) )
	{
		case IContent.CELL_CONTENT :
			return localizeCell( (ICellContent) content );
		case IContent.DATA_CONTENT :
			return localizeData( (IDataContent) content );
		case IContent.FOREIGN_CONTENT :
			return localizeForeign( (IForeignContent) content );
		case IContent.IMAGE_CONTENT :
			return localizeImage( (IImageContent) content );
		case IContent.LABEL_CONTENT :
			return localizeLabel( (ILabelContent) content );
		case IContent.PAGE_CONTENT :
			return localizePage( (IPageContent) content );
		case IContent.ROW_CONTENT :
			return localizeRow( (IRowContent) content );
		case IContent.TABLE_CONTENT :
			return localizeTable( (ITableContent) content );
		case IContent.TEXT_CONTENT :
			return localizeText( (ITextContent) content );
		case IContent.AUTOTEXT_CONTENT :
			return localizeAutoText( (IAutoTextContent) content );
		case IContent.LIST_CONTENT :
			return localizeList( (IListContent) content );
		case IContent.GROUP_CONTENT :
		case IContent.LIST_GROUP_CONTENT :
		case IContent.TABLE_GROUP_CONTENT :
			return localizeGroup( (IGroupContent) content );
		default :
			return content;
	}
}
 
Example #22
Source File: ViewingTest2.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @throws BirtException
 */
private void preBasicIV( ) throws BirtException
{
	IQueryResults qr = null;

	if ( this.PRE_execute_query )
	{
		// here queryResultID needs to set as the data set
		QueryDefinition qd = newPreIVReportQuery( this.PRE_add_filter,
				this.PRE_add_sort,
				this.PRE_add_group,
				PRESENTATION );
		if (!this.usesDetails)
		{
			qd.setUsesDetails( false );
		}
		qd.setQueryResultsID( this.UPDATE_queryResultID );

		qr = myPreDataEngine.prepare( qd ).execute( null );
		this.UPDATE_queryResultID = qr.getID( );
	}
	else
	{
		qr = myPreDataEngine.getQueryResults( this.UPDATE_queryResultID );
	}

	displayPreResult( qr, this.PRE_print_groupinfo, this.PRE_use_skipto );
}
 
Example #23
Source File: CompositeContentEmitter.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void startTableBand( ITableBandContent band ) throws BirtException
{
	for (int i = 0; i < emitters.size(); i++)
	{
		((IContentEmitter)emitters.get(i)).startTableBand(band);
	}
}
 
Example #24
Source File: BirtDateTime.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected Object getValue( Object[] args ) throws BirtException
{
	if( existNullValue( args ) )
	{
		return null;
	}
	if( args.length == 1 )
		return weekDay(DataTypeUtil.toDate(args[0]));
	else
		return weekDay(DataTypeUtil.toDate(args[0]), ((Number)args[1]).intValue( ));
}
 
Example #25
Source File: DataEngineImpl.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void clearCache( IBaseDataSourceDesign dataSource,
		IBaseDataSetDesign dataSet ) throws BirtException
{
	if ( dataSource == null || dataSet == null )
		return;

	DataSetCacheManager dscManager = this.getSession( ).getDataSetCacheManager( );
	if( dscManager == null )
		return;
	else
		dscManager.clearCache( dataSource, dataSet );
}
 
Example #26
Source File: ReportQueryBuilder.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void handleColumn( ColumnDesign column,
		IDataQueryDefinition query )
{
	try
	{
		transformColumnExpressions( column, query );
	}
	catch ( BirtException ex )
	{
		context.addException( column, ex );
	}
}
 
Example #27
Source File: ReportQueryBuilder.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * visit content of a row
 */
public Object visitRow( RowDesign row, Object value )
{
	IDataQueryDefinition query;
	if ( row.useCachedResult( ) )
	{
		query = getRefenceQuery( row );
		if ( query == null )
		{
			registerUnresolvedQueryReference( row );
			return null;
		}
	}
	else
	{
		query = createQuery( row, (IDataQueryDefinition) value );
	}
	for ( int i = 0; i < row.getCellCount( ); i++ )
	{
		CellDesign cell = row.getCell( i );
		build( query, cell );
	}
	try
	{
		transformExpressions( row, query );
	}
	catch ( BirtException ex )
	{
		context.addException( row.getHandle( ), ex );
	}
	return getResultQuery( query, value );
}
 
Example #28
Source File: OutputColumnsPage.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public boolean performOk( )
{
	if ( isValid( ) )
	{
		saveOutputColumns( );
		( (DataSetHandle) getContainer( ).getModel( ) ).removeListener( this );
		if( this.modelChanged )
		{
			( (DataSetEditor) this.getContainer( ) ).updateDataSetDesign( this );
			this.modelChanged = false;
		}
		try
		{
			if ( !pageActivated )
			{
				setAnalysisTypeForColumn( );
			}
		}
		catch ( BirtException e )
		{
			ExceptionHandler.handle( e, true );
		}

		( (DataSetHandle) getContainer( ).getModel( ) ).removeListener( this );

		return super.performOk( );
	}
	else
	{
		( (DataSetHandle) getContainer( ).getModel( ) ).removeListener( this );
		return false;
	}
}
 
Example #29
Source File: PDFLayoutEngineContext.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public Object visitList( IListContent list, Object value )
		throws BirtException
{
	( (IContentEmitter) value ).startList( list );
	return null;

}
 
Example #30
Source File: HTMLPageBuffer.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void endPage( IContent content, boolean finished,
		IContentEmitter emitter ) throws BirtException
{
	( (AbstractNode) currentNode ).setFinished( finished );
	if ( currentNode.isStarted( ) )
	{
		context.getPageHintManager( ).generatePageRowHints( getTableKeys() );
		currentNode.end( );
		pageBreakEvent( );
		if ( !finished )
		{
			context.setPageNumber( context.getPageNumber( ) + 1 );
			context.setPageCount( context.getPageCount( ) + 1 );
		}
	}
	else
	{
		context.setEmptyPage( true );
		if ( finished )
		{
			if ( context.getPageNumber( ) == 1 )
			{
				currentNode.flush( );
				pageBreakEvent( );
			}
			else
			{
				context.setPageNumber( context.getPageNumber( ) - 1 );
				context.setPageCount( context.getPageCount( ) - 1 );
			}
		}
	}
	this.finished = true;
	generator.reset( );
	//context.removeLayoutHint( );
	context.getPageHintManager( ).clearPageHint( );
	currentNode = null;
}