OBIEE 12c Archive Report Setup

Download as pdf or txt
Download as pdf or txt
You are on page 1of 29
At a glance
Powered by AI
The document discusses how to create an EAR file that can be deployed on WebLogic to make a Java EJB method available in OBIEE. This allows reports to be exported programmatically to a file server. Step-by-step instructions and a sample EAR file are provided.

The EAR file contains the Java EJB classes that provide the logic to export reports. It is deployed on the WebLogic server so the EJB method is accessible to invoke from within OBIEE.

The EAR file needs to be deployed on the WebLogic server. Some configuration changes may be required. Then the EJB method can be invoked from an OBIEE action or scheduler agent. A sample invocation is described.

OBIEE 12.

2C Archive / Bursting Report Setup


Configuration Only

CHANGE HISTORY

Vers. No. Date Author, Unit Code Comment


1.0 15/12/2015 Shahed Munir and Creation of the document
Krishna Mohan
1.1 18/12/2015 Krishna Mohan Added Bursting Functionality with Dynamic File Name
1.2 22/12/2015 Krishna Mohan Changed from PDFBox to Apache Tika

Contents
Description ............................................................................................................................................ 2
Create EJB WAR / EAR file ................................................................................................................ 3
Create an EJB Application Using the following steps ..................................................... 3
Start with ArchiveReportsBean.java ............................................................................................... 9
ArchiveReports.java ...................................................................................................................... 10
ArchiveReportsLocal.java .............................................................................................................. 11
Let’s compile the project and Debug the Project ............................................................................. 12
Let’s create the WAR file and then the EAR file................................................................................ 13
Deploy the Application: Generate physical WAR and EAR files ........................................................ 19
Enable the Action Frame Work ......................................................................................................... 21
Credential Store Entry ....................................................................................................................... 22
Invocation of EJB Java Method within OBIEE ................................................................................... 23
DELIVERBI Working Ear File .............................................................................................................. 23
DELIVERBI Dynamic Archive Ear File ................................................................................................. 24
--1 ArchiveReportsBean.java......................................................................................................... 24
--2 ArchiveReports.java ................................................................................................................. 27
--3 ArchiveReportsLocal.java ........................................................................................................ 27
Description

An Ear file is deployed to the weblogic server so that a JAVA EJB or Method is available within OBIEE
so that reports can be delivered to the file server. This solution was tested on OBIEE 12c on a Linux
Operating system.

The Solution is very simple to use when implemented. You can invoke a Java Method from within an
Agent or just execute as a Action. 2 Parameters,

1 for file name = /tmp/myreportoutput.pdf , xls etc.

2. If Action = Select Output Format and pick a REPORT, If Scheduler Agent just select Delivery
Content and output format.

We have included a working ear file in our Deliverbi Box location

https://app.box.com/s/vqdyqfcfr2yoyhle432o7ofm48y1e7i0

Brief Overview of setup if using our EAR File

1. Deploy EAR File to BIServer1 - WebLogic server as a deployment and start servicing all
requests – Page 19
2. Amend the ActionFrameworkConfig.xml file page 21
3. Create a credential key within Enterprise Manager /em : page 22
4. Reboot all services: sh stop.sh within the bitools folder.

Alternatively create your own ear file and deploy with instructions in the document. With more
functionality such as dynamic file names etc.
Create EJB WAR / EAR file
Download JDeveloper 11.1.1.7 and install

Pick up the following two JAR files from DELIVERBIBOX or an existing OBIEE 11.1.1.9.0 installation

https://app.box.com/s/vqdyqfcfr2yoyhle432o7ofm48y1e7i0

actionframework-common.jar

schedulerrpccalls.jar

Open JDeveloper

Create an EJB Application Using the following steps

1. Create an application -> File -> New... -> General -> Generic Application and click
OK:
2. Provide an application name: DeliverBIApplication

3. Click on Next. Provide a project name: ArchiveReports. Then, click on Finish:


4. Next, create the session Bean. Right click on ArchiveReports -> New... -> Business
Tier -> EJB and select Session Bean on the right pane and click OK:

5. Accept the default and click on Next:


6. Provide the following and click on Next:

- EJB Name: ArchiveReports


- Session Type: Stateless
- Transaction Type: Bean

7. Accept the defaults and click on Next:


8. Accept the defaults and click on Next:

9. Click on Finish:
10. Get from the server the needed libraries to execute this code. Transfer the file to the
machine where JDeveloper is running. The libraries are under:

-
<FMW_HOME>/user_projects/domains/bifoundation_domain/servers/bi_server1/tmp
/_WL_user/bimiddleware_11.1.1/udy1lp/lib/actionframework-common.jar

Import the needed libraries to execute this code. Right click on ArchiveReports -> Project
Properties... Libraries and Classpath -> click on Add JAR Directory... -> Navigate to the
directory where you put the actionframework-common.jar and scheduler/schedulerrpccalls.jar
files, click on the files and click on Select. To add them. Then click
Click OK.

Now fill in the code

Start with ArchiveReportsBean.java

Save after amending the code in each of the .java


package archivereports;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.activation.DataHandler;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;

@Stateless(name="archivereports", mappedName="ejb/Application1-archivereports-archivereports")
@TransactionManagement(TransactionManagementType.BEAN)
@Remote
public class ArchiveReportsBean
implements ArchiveReports, ArchiveReportsLocal
{
public String ArchiveReport(String filename, DataHandler report)
throws FileNotFoundException, IOException
{
File f = new File(filename);
FileOutputStream outputStream = new FileOutputStream(f);
report.writeTo(outputStream);
outputStream.close();
return "Report Archived";
}
}

ArchiveReports.java

package archivereports;

import java.io.FileNotFoundException;
import java.io.IOException;
import javax.activation.DataHandler;
import javax.ejb.Remote;
import oracle.bi.action.annotation.OBIActionParameter;

@Remote
public abstract interface ArchiveReports
{
public abstract String ArchiveReport(@OBIActionParameter(name="Filename", prompt="Enter filename and location:")
String paramString
, @OBIActionParameter(name="Analysis", prompt="Choose Delivery Content:") DataHandler
paramDataHandler)
throws FileNotFoundException, IOException;
}

ArchiveReportsLocal.java

package archivereports;

import javax.ejb.Local;

@Local
public abstract interface ArchiveReportsLocal {}
Let’s compile the project and Debug the Project

Save the Project

Cancel the pop up window – Choose Default Run Target

Review Messages window to ensure there are no errors. There will be 1 warning which you can
ignore.
Let’s create the WAR file and then the EAR file

1. Create a deployment profile for your project. Right click on the project name ->
Project Properties... -> Deployment -> New... button and provide

- Archive Type: WAR File


- Name: ArchiveReports

Then click OK.


2. Accept the defaults and click OK:

3. Click OK:

4. Next we need to create an EAR file deployment profile. Click on Application in the
main tool bar and select Application Properties
Untick Auto Generate and Synch and Users and Groups Checkboxes as shown above

5. Click on New and select EAR File as Archive Type and Name as ArchiveReports

Click OK
Click on Application Assembly and click on ArchiveReports as shown below
Click on EAR Options tick Include Manifest File

Click OK
Click OK again

Click on Project and Save the project


Deploy the Application: Generate physical WAR and EAR files

Right click on the Project name and choose Deploy

Click on Archive Reports and Choose Deploy to WAR

Click Next and Finish

Next choose Application from the main menu and click Deploy
Click on ArchiveReports and Choose Deploy to EAR

Click Next and Finish


Find the ArchiveReports.ear file on your computer (location can be something like
C:\JDeveloper\mywork\DeliverBIApplication\deploy)

and move the file to Oracle Home on Linux server or any location Web Logic can access.

Deploy this application to Weblogic Console as a standard Application Deployment to BI


Server1

Once Deployed start servicing all requests

Enable the Action Frame Work

Navigate to the following directory on Linux Server

/Middlewarehomebi12/user_projects/domains/bi12/config/fmwconfig/biconfig/actions
And amend the ActionFrameworkConfig.xml file which is available here. This one is for
OBIEE 12 . Remember to update the hostname to your server hostname and port if necessary
https://app.box.com/s/vqdyqfcfr2yoyhle432o7ofm48y1e7i0

The Action Framework Config file enables the use of an EJB Java Method within OBIEE
after the ear file has been deployed to the weblogic server as a deployment and has been
started to service all requests.
Credential Store Entry

Login in Enterprise Manager / EM

Create the Credential Map oracle.bi.actions

Then create a key JNDIUser


You can use Admin credentials such as weblogic user

Press OK and save.

Restart all services including Web Logic.

Invocation of EJB Java Method within OBIEE

This EJB application can be now be invoked as a Java Method using

New -> Action -> Invoke a Java Method within OBIEE Or within a OBIEE Scheduled agent.

1. Filename = Location and name of file to be exported


2. Analysis = If an OBIEE Action - Select Output format and pick a Analysis
Analysis = If used in a scheduled Agent – Select output format and select Delivery Content.

DELIVERBI Working Ear File

A Working OBIEE 12c Ear File that we have created is also available to download from our box.net
location below. Just upload to Linux Server and Deploy to Weblogic as an application /console . Start
servicing all requests.

Amend the ActionFrameworkConfig.xml which is included.

Create the credential Store key JNDIUser

Restart all services.

Download Link : https://app.box.com/s/vqdyqfcfr2yoyhle432o7ofm48y1e7i0


DELIVERBI Dynamic Archive Ear File

I worked with our original solution and improved it to burst / archive reports to Linux file system that
is generic.

The new functionality within EAR file enables dynamic file names to be produced for exporting /
using the content of the report / dashboard.

I have achieved this by adding few more parameters to the Java Bean when exposed in OBIEE EJB.

The new JAR file looks for Tags embedded in the Dashboard / Report and uses them to derive the file
name of the file being exported to the file system.

Had to go through few hoops to achieve this functionality.

I used a public JAR from Apache Tika that allow file conversions.

Then I started amending the Java Bean code to extract the Delivery content as a String to work out
the target file name. I have added few more parameters to the Java Bean to make it as generic as
possible.

As this solution is an improvisation based on the original solution, I am only providing the high level
approach and components and not step by step instructions

The revised Java Code looks like

--1 ArchiveReportsBean.java
package archivereports;

/* DeliverBI */

import com.siebel.analytics.scheduler.javahostrpccalls.SchedulerJavaExtension;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.activation.DataHandler;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
import java.io.*;
import java.lang.Thread;
import org.apache.pdfbox.pdmodel.PDDocument;

import sun.management.FileSystemImpl;

import org.apache.tika.detect.DefaultDetector;
import org.apache.tika.detect.Detector;
import org.apache.tika.exception.TikaException;
import org.apache.tika.io.TikaInputStream;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.parser.AutoDetectParser;
import org.apache.tika.parser.ParseContext;
import org.apache.tika.parser.Parser;
import org.apache.tika.sax.BodyContentHandler;
import org.apache.tika.exception.TikaException;

import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;

@Stateless(name="archivereports", mappedName="ejb/Application1-archivereports-
archivereports")
@TransactionManagement(TransactionManagementType.BEAN)
@Remote
public class ArchiveReportsBean
implements ArchiveReports, ArchiveReportsLocal
{
public String ArchiveReport(String filelocation, String filename, String StringStart, String StringEnd,
DataHandler report)
throws FileNotFoundException, IOException
{
File f = new File(filelocation + filename);
FileOutputStream outputStream = new FileOutputStream(f);
report.writeTo(outputStream);
outputStream.close();

String newfile = filelocation + filename;

try {
InputStream input = new FileInputStream(new File(newfile));
ContentHandler textHandler = new BodyContentHandler();
Metadata metadata = new Metadata();
AutoDetectParser parser = new AutoDetectParser();
ParseContext context = new ParseContext();
parser.parse(input, textHandler, metadata, context);
String st = metadata.get(metadata.TITLE);
st = st + textHandler.toString();

String startmatch = StringStart;


String endmatch = StringEnd;

int startposition = st.indexOf(startmatch) + startmatch.length();


int endposition = st.indexOf(endmatch);

newfile = filelocation + st.substring(startposition,endposition) + filename;

/*-- KM Enable below for debugging


File debugFile = new File("/tmp/DeliverBI_Bursting.debug");
FileWriter out = new FileWriter(debugFile);
out.write(newfile);
out.write(startmatch);
out.write(endmatch);
out.close(); */

} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (TikaException e) {
e.printStackTrace();
}

try{

File oldfile = new File(filelocation + filename);


oldfile.renameTo(new File (newfile));

}
catch(Exception e){
File outputFile = new File("/tmp/DeliverBI_Bursting_debug.txt");
FileWriter out = new FileWriter(outputFile);
out.write("Landed in Exception. Unable to rename file" + "\r\n");
out.close(); }
return "Report Archived";

}
}

--2 ArchiveReports.java

package archivereports;

/* DeliverBI */

import java.io.FileNotFoundException;
import java.io.IOException;
import javax.activation.DataHandler;
import javax.ejb.Remote;
import oracle.bi.action.annotation.OBIActionParameter;
import com.siebel.analytics.scheduler.javahostrpccalls.SchedulerJavaExtension;
import com.siebel.analytics.scheduler.javahostrpccalls.SchedulerJobException;
import com.siebel.analytics.scheduler.javahostrpccalls.SchedulerJobInfo;

@Remote
public abstract interface ArchiveReports
{
public abstract String ArchiveReport
(@OBIActionParameter(name="Filelocation", prompt="Enter file location:") String param1String
, @OBIActionParameter(name="Filename", prompt="Enter filename:") String paramString
, @OBIActionParameter(name="StringStart", prompt="Enter the Starting String pattern:") String
param3String
, @OBIActionParameter(name="StringEnd", prompt="Enter the Ending String pattern:") String
param4String
, @OBIActionParameter(name="Analysis", prompt="Choose Delivery Content:") DataHandler
paramDataHandler
)
throws FileNotFoundException, IOException;
}

--3 ArchiveReportsLocal.java

package archivereports;
/* DeliverBI */

import javax.ejb.Local;

@Local
public abstract interface ArchiveReportsLocal {}

I already created an EAR file even though I included the source code in this post. Just deploy
this EAR file like you would do for the original solution. You can access this EAR file along
with the Java Source code and the pdfbox jar from the following link

https://app.box.com/s/s0wx29gf9ptyv1sdnmcwk0kescxh5m7y

You only need to deploy the EAR file as I have done the hard work for you.

When used in OBIEE there will be now 5 parameters instead of the original 2.

1. The first parameter is just the Linux directory location for the output to be saved.
Ensure the ‘/’ is given at the end
2. The default name of the output file
3. The start Tag that will be looked up in the delivery content to identify the start of the
target file name. See below figure below
4. The end Tag that will be looked up in the delivery content to identify the end of the
target file name. See the below figure
I created a narrative view in the report I am going to export with the start and end tags. In the
narrative view I have included the User session variable and datetime to uniquely identify the
export file.

These tags are dynamic. The reason I have included the Start Tag and End Tag as parameters
is to enable usage of any tags. So any content that is included in between these tags will be
used to produce the export file name.

5. Choose the delivery content and its type

Note:

When the Start and End Tags specified is not found in the report / dashboard content then the
default file name provided in Parameter 2 will be used to produce the output file

When the Tags are located in the report / dashboard then the content between these two tags
is prefixed to the default file (parameter 2) name to produce the output file

After running the Action, the output file will be


Krishna.Udathu_18-12-2015_1515_35km2.xlsx

If any of the parameter values specified pushes the EJB into error, the application produces a
debug file in the /tmp directory on the Linux server with the name
DeliverBI_Bursting_debug.txt

You might also like