Java Code Examples for org.eclipse.birt.core.exception.BirtException#getErrorCode()

The following examples show how to use org.eclipse.birt.core.exception.BirtException#getErrorCode() . 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: DataAdapterUtil.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 
 * @param context
 * @throws AdapterException
 */
public static void unRegisterDataObject( ScriptContext context ) throws AdapterException
{
	Scriptable targetScope;
	try
	{
		if( context!= null )
		{
			targetScope = ( (IDataScriptEngine) context.getScriptEngine( IDataScriptEngine.ENGINE_NAME ) ).getJSScope( context );
			targetScope.delete( "row" );
			targetScope.delete( "dimension" );
			targetScope.delete( "measure" );
			targetScope.delete( "data" );				
		}
	}
	catch ( BirtException e )
	{
		throw new AdapterException( e.getErrorCode( ), e );
	}
}
 
Example 2
Source File: ExecutionContext.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void addException( BirtException e )
{
	for ( int i = 0; i < exList.size( ); i++ )
	{
		BirtException err = (BirtException) exList.get( i );
		if ( e.getErrorCode( ) != null
				&& e.getErrorCode( ).equals( err.getErrorCode( ) )
				&& e.getLocalizedMessage( ) != null
				&& e.getLocalizedMessage( ).equals(
						err.getLocalizedMessage( ) ) )
		{
			countList.set( i,
					Integer.valueOf( ( (Integer) countList.get( i ) ).intValue( ) + 1 ) );
			return;
		}
	}
	exList.add( e );
	countList.add( Integer.valueOf( 1 ) );

}
 
Example 3
Source File: DataAdapterUtil.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This method is used to register the Java Script Objects which are defined in the scope of
 * source ResultSet ( might be IResultSet or CubeCursor ) to target scope. One possible client
 * of this method is Report Engine. A classic use case is that instead of register its own "row" object 
 * the Report Engine can simply call this method with proper argument so that the "row" object
 * registered in IResultIterator's scope, that is, JSResultSetRow, can be accessed by engine using
 * engine scope. 
 *   
 * @param targetScope
 * @param source
 * @throws AdapterException 
 */
public static void registerDataObject( ScriptContext context,
		ILinkedResult source ) throws AdapterException
{
	try
	{
		Scriptable targetScope = ( (IDataScriptEngine) context.getScriptEngine( IDataScriptEngine.ENGINE_NAME ) ).getJSScope( context );
		int type = ( (ILinkedResult) source ).getCurrentResultType( );
		if ( type == ILinkedResult.TYPE_TABLE )
		{
			targetScope.put( "row",
					targetScope,
					new JSResultIteratorObject( (ILinkedResult) source,
							targetScope ) );
			targetScope.put( "data",
					targetScope,
					new JSResultIteratorObject( (ILinkedResult) source,
							targetScope ) );
		}
		else if ( type == ILinkedResult.TYPE_CUBE && source.getCurrentResult( )!= null )
		{
			Scriptable scope = ( (ICubeCursor) source.getCurrentResult( ) ).getScope( );
			targetScope.put( "data", targetScope, scope.get( "data", scope ) );
			if( scope.get( "data", scope ) != null && scope.get( "data", scope ) instanceof Scriptable )
				targetScope.put( "row", targetScope, scope.get( "row", scope ) );
			targetScope.put( "dimension",
					targetScope,
					scope.get( "dimension", scope ) );
			targetScope.put( "measure", targetScope, scope.get( "measure",
					scope ) );
		}
	}
	catch ( BirtException e )
	{
		throw new AdapterException( e.getErrorCode( ), e );
	}
}
 
Example 4
Source File: DataSessionContext.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a DataEngine context in the provided mode, using the provided top level scope.
 * Also sets the handle of the report design being executed. 
 *
 * @param mode Data Session mode. Can be MODE_GENERATION, MODE_PRESENTATION 
 *    or MODE_DIRECT_PRESENTATION
 * @param moduleHandle If not null, this report module is used to look up data set
 *    and data source definition when executing queries.
 * @param scriptContext
 * @param classLoader
 * @throws AdapterException
 */
public DataSessionContext( int mode, ModuleHandle moduleHandle, ScriptContext scriptContext, ClassLoader classLoader ) throws AdapterException
{
	try
	{
		if ( !( mode == MODE_GENERATION
				|| mode == MODE_PRESENTATION
				|| mode == MODE_DIRECT_PRESENTATION || mode == MODE_UPDATE ) )
			throw new AdapterException( ResourceConstants.ADAPTER_INVALID_MODE,
					Integer.valueOf( mode ) );

		this.mode = mode;
		this.moduleHandle = moduleHandle;
		this.appClassLoader = classLoader;
		this.hasExternalScope = scriptContext != null;
		ScriptContext internalScriptContext = null;
		if ( scriptContext == null )
		{
			internalScriptContext = new ScriptContext( );
			scriptContext = internalScriptContext.newContext( this.getTopScope( ) );
			DataEngineThreadLocal.getInstance( ).getCloseListener( )
					.add( new ScriptContextCloser( internalScriptContext ) );
		}
		this.sContext = scriptContext;
		this.topScope = ( (IDataScriptEngine) scriptContext.getScriptEngine( IDataScriptEngine.ENGINE_NAME ) ).getJSScope( scriptContext );
	}
	catch ( BirtException e )
	{
		throw new AdapterException( e.getErrorCode( ), e );
	}
}
 
Example 5
Source File: EngineException.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public EngineException( BirtException ex)
{
	super( pluginId, ex.getErrorCode( ), (ResourceBundle) null, ex );
	birtException = ex;
}