If you had gone through my previous blog entry here i would have talked about the means of storing BI EE reports on a periodic basis using Java Scripts. But one of the main problems with this is that it would not work in an Unix environment. So, now lets look at an approach to store the BI EE report outputs using Java APIs of BI Publisher and Delivers. But as a pre-requisite you need to go through the above mentioned blog entry to understand how Java Classes are called from BI Delivers. Now in this example, we shall be using BI Publisher Delivery Manager Java APIs and will be calling these APIs from iBots. Lets look at the steps one by one.
1. The first step to achieve this is to create the Java Class containing the relevant code. I have used JDeveloper 10.1.3.2. In order for the below code to work you need to have 3 jar files included. They are xdocore.jar, versioninfo.jar and schedulerrpccalls.jar. You can find xdocore.jar and versioninfo.jar in {OracleBI}\oc4j_bi\j2ee\home\applications\xmlpserver\xmlpserver\WEB-INF\lib. And you can find schedulerrpccalls.jar in {OracleBI}\web\javahost\lib\scheduler. Now compile the below given code and bundle it as a jar file. To know how to bundle it as a jar check the blog entry mentioned above. Remember, while deploying it as a jar you need to include the above mentioned 3 dependency jars too.
package bieesoap;import java.io.FileInputStream;
import java.io.FileNotFoundException;
import oracle.apps.xdo.delivery.DeliveryException;
import oracle.apps.xdo.delivery.DeliveryManager;
import oracle.apps.xdo.delivery.DeliveryPropertyDefinitions;
import oracle.apps.xdo.delivery.DeliveryRequest;
import com.siebel.analytics.scheduler.javahostrpccalls.SchedulerJavaExtension;
import com.siebel.analytics.scheduler.javahostrpccalls.SchedulerJobException;
import com.siebel.analytics.scheduler.javahostrpccalls.SchedulerJobInfo;import java.io.File;import oracle.apps.xdo.delivery.local.LocalPropertyDefinitions;public class LocalCopy implements SchedulerJavaExtension{
public LocalCopy() {
}public void run(SchedulerJobInfo jobInfo) throws SchedulerJobException {
try
{
FileInputStream fileInputStr = new FileInputStream(jobInfo.getResultSetFile());
DeliveryManager delMan = new DeliveryManager();
DeliveryRequest delReq = delMan.createRequest(DeliveryManager.TYPE_LOCAL);
delReq.addProperty(LocalPropertyDefinitions.LOCAL_DESTINATION, “D:\\BIPAPI\\Output.pdf”);
delReq.setDocument(fileInputStr);
delReq.submit();
delReq.close();
}
catch(Exception ex)
{
throw new SchedulerJobException(1, 1, ex.getMessage());
}}public void cancel() {
}}
This is how the above code works. When we include a Java Class from an ibot, the ibot uses the Java Host service to make a remote procedure call to the Run method of the class specified. jobInfo object would get the output of the ibot (say a PDF file) and will pass it on to the Delivery manager API of BI Publisher. The delivery manager API then makes a call to the file system to store the PDF file to a local directory.
2. Copy the deployed jar file to your java host lib path(check the above blog entry to know where to specify this path).
3. Now create an ibot and include any report content. Ensure that you are making the output type to be of PDF since we are making the above output file name to be output.pdf. Go to the Advanced properties and add a Java Class as shown below.
This can be very useful for advanced integration scenarios. You can even call the BI Publisher FOProcessor API to actually create the BIP reports and can use Delivers to deliver them. There are lots of different functionalities where this can be very helpful.