Use the Java Method report type to define a drill-through report to drill through to a custom Java method that you create.
You may create a Java method that generates a report that satisfies your specific requirements. For example, you may create a Java method that extracts data from a specific application.
For the Spreadsheet Add-in or Smart View user in the client application that runs the drill-through report, there is no difference between executing a drill-through report to a relational source and executing a drill-through report with user-defined Java methods.
To define a Java method report type and specify the Java method to execute during drill-through:
In Java Class Name, enter the full package name of the Java class; for example:
test.com.hyperion.cp.scripts.acceptance.test_cases.TestDTRJavaMethod
In Java Method Name , enter the name of the Java method; for example:
runTest
User-defined Java methods that can be invoked by Essbase Studio Server must have the following signature:
public static void <method-name>(ArrayList<String>[]> args, ResultSet result)
The ArrayList<String>[]> args parameter of the user-defined Java method is an array list of drill-through report arguments. Each item of the array list describes a member from the intersection and includes the dimension name, class name, and member name. For example
“ProductH” “SKU” “100-10” “TimeH” “Time Year” “2006”
If the member is a top member of an Essbase dimension, the value of class name is null. For example:
“ProductH” null “ProductH”
The ResultSet parameter is an interface from the Java package, com.hyperion.cp.interfaces.
Note: | Before setting any values in the records of the result set, all tags of the result set must be defined. |
The following methods of the interface can be used in user-defined Java methods:
/** * Adds a new tag to result set signature * @param tag Tag name * @param clazz Java class that corresponds to the tag * (Boolean, Integer, Long, Double, String) */ public void addTag(String tag, Class clazz); /** * Sets value in result set record * @param tag Tag name * @param value Value */ public void setValue(String tag, boolean value); public void setValue(String tag, int value); public void setValue(String tag, long value); public void setValue(String tag, double value); public void setValue(String tag, String value); /** * Adds record to the result set * */ public void addRecord();
The following is an example of the user-defined Java method, runTest. This method converts the parameters of the drill-through report to a result set with the tags Hierarchy, Class, Value. The values of all tags are strings.
package test.com.hyperion.cp.scripts.acceptance.test_cases; import com.hyperion.cp.interfaces.ResultSet; import java.util.ArrayList; import java.util.Iterator; public class TestDTRJavaMethod { /** * User defined java method for DTR * @param result Result of DTR * @param args Actual arguments of the DTR */ public static void runTest(ArrayList<String[]> args, ResultSet result) { // make signature of the result result.addTag("Hierarchy", String.class); result.addTag("Class", String.class); result.addTag("Value", String.class); Iterator<String[]> iterator = args.iterator(); while (iterator.hasNext()) { // add records to the result String[] tuple = iterator.next(); result.setValue("Hierarchy", tuple[0]); result.setValue("Class", tuple[1]); result.setValue("Value", tuple[2]); result.addRecord(); } } }
When the spreadsheet user runs the drill-through report, the Java method is executed and results in the following drill-through report:
====================================== Hierarchy Class Value ====================================== ProductH SKU 100-10 TimeH Time Year 2006 MarketH REGION East MyMeasuresH Msr_Gen4 Sales ======================================
Click Save, and then Close to close the drill-through report editor; or select the Associations tab and perform the tasks in Associating Drill-through Reports with Essbase Models.