Hopefully a straightforward question - though I've not yet found the answer in the BIRT integration book, nor here on the forums...<br />
<br />
I'm attempting to open a report design from a simple script so I can add lots of data sources to it programmatically. I've the following method:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
private ReportDesignHandle getReportDesignHandle( String reportDefLoc ) throws BirtException
{
DesignConfig config = new DesignConfig();
config.setResourceLocator( new CustomResourceLocator() );
System.out.print(" Starting design engine...");
Platform.startup( config );
IDesignEngineFactory factory = ( IDesignEngineFactory ) Platform
.createFactoryObject( IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY );
IDesignEngine designEngine = factory.createDesignEngine( config );
System.out.println("...done");
System.out.println( " Starting session..." );
sesh = designEngine.newSessionHandle( null );
sesh.setResourceLocator( new CustomResourceLocator() ); // Doesn't seem to help.
sesh.setResourceFolder( CustomResourceLocator.RESOURCE_FOLDER_STRING ); // Ditto!
ReportDesignHandle rdh = null;
rdh = sesh.openDesign( reportDefLoc );
return rdh;
}
</pre>
<br />
Where CustomResourceLocator looks like this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
public class CustomResourceLocator implements IResourceLocator
{
public static final String RESOURCE_FOLDER_STRING = "PATH TO SHARED RESOURCES";
@Override
public URL findResource( ModuleHandle modHandle, String path, int i )
{
return findResource( modHandle, path, i, null );
}
@Override
public URL findResource( ModuleHandle modHandle, String path, int i, Map map )
{
try
{
URL url;
url = new URL( "file://" + RESOURCE_FOLDER_STRING + path );
System.out.println(" Custom Resource Locator suggests " + url );
return url;
}
catch ( MalformedURLException e )
{
e.printStackTrace();
return null;
}
}
}
</pre>
<br />
The CustomResourceLocator is returning a valid URL - pasting it into Windows Explorer results in the file opening - and yet I still get a cannot find the shared resource (in this case the Library file) when I run the code...<br />
<br />
Do I need to manipulate the ModuleHandle too? (It isn't returned so that seems unlikely...)<br />
<br />
Your ideas would be greatly appreciated!