Accessing BIRT report design and BIRT resource path in custom ODA plug‑ins
ODA providers often need to obtain information about a resource path defined in ODA consumer applications. For example, if you develop an ODA flat file data source, you can implement an option to look up the data files in a path relative to a resource folder managed by its consumer. Such resource identifiers are needed in both design-time and run-time drivers.
ODA consumer applications are able to specify:
*The run-time resource identifiers and pass them to the ODA run-time driver in an application context map
*The design-time resource identifiers in a DataSourceDesign, as defined in an ODA design session model
Accessing resource identifiers in the run-time ODA driver
For run time, the BIRT ODA run-time consumer passes its resource location information in the org.eclipse.datatools.connectivity.oda.util.ResourceIdentifiers instance in the appContext map. ODA run-time drivers can get the instance in any one of the setAppContext methods, such as IDriver.setAppContext:
*To get the instance from the appContext map, pass the map key ResourceIdentifiers.ODA_APP_CONTEXT_KEY_CONSUMER_RESOURCE_IDS, defined by the class as a method argument.
*To get the BIRT resource folder URI, call the getApplResourceBaseURI( ) method.
*To get the URI of the associated report design file folder, call the getDesignResourceBaseURI( ) method. The URI is application‑dependent and it can be absolute or relative. If your application maintains relative URLs, call the getDesignResourceURILocator.resolve( ) method to get the absolute URI.
The code snippet on Listing 48‑3 shows how to access the resource identifiers through the application context.
Listing 48‑3 Accessing resource identifiers at run time
URI resourcePath = null;
URI absolutePath = null;
 
Object obj = this.appContext.get
( ResourceIdentifiers.ODA_APP_CONTEXT_KEY_CONSUMER_RESOURCE
_IDS );
if ( obj != null )
{
ResourceIdentifiers identifier = (ResourceIdentifiers)obj;
if ( identifier.getDesignResourceBaseURI( ) != null )
{ resourcePath = identifier.getDesignResourceBaseURI();
 
if ( ! resourcePath.isAbsolute() )
absolutePath =
identifier.getDesignResourceURILocator().resolve(
resourcePath );
else
absolutePath = resourcePath;
}
}
Accessing resource identifiers in the design ODA driver
The resource identifiers are available to the custom ODA designer UI driver. The designer driver provides the user interface for the custom data source and data set. Typically, to implement a custom behavior, the data source UI driver extends the following class:
org.eclipse.datatools.connectivity.oda.design.ui.wizards.DataSourceWizardPage
The DataSourceWizardPage class has an inherited method, getHostResourceIdentifiers( ), which provides access to the resource and report paths. The extended DataSourceWizardPage just needs to call the base method to get the ResourceIdentifiers for its path’s information. Similarly, if the custom driver implements a custom data source editor page, it extends:
org.eclipse.datatools.connectivity.oda.design.ui.wizards.DataSourceEditorPage
The DataSourceEditorPage class has an inherited method, getHostResourceIdentifiers( ). The extended class just needs to call the base class method to get the ResourceIdentifiers object for the two resource and report path base URIs. Related primary methods in the org.eclipse.datatools.connectivity.oda.design.ResourceIdentifiers class are:
*getDesignResourceBaseURI( );
*getApplResourceBaseURI( );