Building a data provider

You can build a data provider by:

Integrating the Web Intelligence Java Report Panel into your application

The Web Intelligence Java Report Panel is the standard method for users to create data providers and edit queries.

 

The Web Intelligence Java Report Panel

Note:    This applet is different from previous releases of Web Intelligence.

Launching the Web Intelligence Java Report Panel

You launch the Web Intelligence Java Report Panel using JSP. You use the <applet> or <object> tag to declare the applet, and the <param> tag to specify the applet's parameters. All parameters are of the type java.lang.String.

ParametersValue(s)Description

Applet parameters

code

"com.businessobjects.wp.tc.TCMain"

The path to the applet.

useslibrary

"Web Intelligence Report Panel"

The name of the applet.

useslibrarycodebase

"/webiApplet/ThinCadenza.jar"

The path to the archive containing the applet

HelpRoot

-

The path to the online help.

Lang

"en"; "jp"

The language of the user interface.

Server parameters

Server

-

The name of the server from which the applet is downloaded.

Isapi

"/servlet/com.businessobjects.cdzlet.
CadenzaServlet"

The path to the servlet through which the server and the browser communicate.

Port

default is "8080"

The port used for the application server

CdzSession

use the string returned by ReportEngine.
getServerInstance

The session identifier for the open document.

Document parameters

Token

use the string returned by DocumentInstance.
getStorageToken when editing an open document

The storage token for the document.

RepoType

"corporate"; "inbox"; "personal".

The type of the repository in which the document is stored.

DocumentID

-

The id of the document.

DocumentName

-

The name of the document.

OpenFirstClassOfUniverse

-

If present, the applet automatically opens the first class of the universe.

Data source parameters

UniverseID

-

The id of the universe on which the query will be run.

You can use the implicit JSP request object (javax.servlet.http.HttpServletRequest) to get the values for some of these parameters. For example, you can use request.getServerName and request.getServerPort to populate the Server and Port parameters.

Note:    Some parameters are optional depending on what you are doing with the applet. For example, if you are creating a new document, you do not need to provide a storage token.

Example:    Launching the Web Intelligence Java Report Panel

The following example shows JSP functions that use BusinessObjects Enterprise SDK to recover a universe object from a valid ID. This Universe can be used to supply information necessary to start the Java Report Panel

<%!

IInfoObject getUniverse(IInfoStore iStore, String ID){

    IInfoObjects universes = null;

    IInfoObject universe = null;

    try{

        String sQuery = "SELECT SI_CUID, SI_NAME FROM"

                + " CI_APPOBJECTS WHERE SI_ID = " + ID

                + " AND SI_KIND = '"+ CeKind.UNIVERSE +"'";

        universes = (IInfoObjects) iStore.query(sQuery);

        if(universes.size() > 0)

            universe = (IInfoObject)universes.get(0);

    }catch(Exception e){

        universe = null;

    }

    return universe;

}

%>

// The following JSP script retrieves all necessary

// parameters and then launches the Web Intelligence Java

// Report Panel.

<%

IInfoStore iStore = (IInfoStore) session.getAttribute("InfoStore");

ReportEngine wiRepEngine = (ReportEngine) session.getAttribute("ReportEngine");

String ID = request.getParameter("uID");

universe = getUniverse(iStore, ID);

if (universe != null){

    String currPath = request.getServletPath();

    String contextPath = request.getContextPath();

    String serverName = request.getServerName();

    int serverPort = request.getServerPort();

    

    currPath = currPath.substring(

                0, currPath.lastIndexOf( '/' ) + 1 );

    currPath = contextPath + currPath;

    String instanceID = wiRepEngine.createServerInstance();

    String strWISession =

        instanceID.substring(0,instanceID.indexOf(","));

%>

<APPLET CODE="com.businessobjects.wp.tc.TCMain"

    CODEBASE="<%= contextPath %>/webiApplet/"

    ARCHIVE="ThinCadenza.jar" style="

            width: 100%; height: 100%;">

<PARAM NAME=CODE VALUE="com.businessobjects.wp.tc.TCMain" >

<PARAM NAME=CODEBASE VALUE="<%= contextPath %>/webiApplet/">

<PARAM NAME=ARCHIVE VALUE="ThinCadenza.jar" >

<PARAM NAME="type"

        VALUE="application/x-java-applet;version=1.4">

<PARAM NAME="Isapi"

        VALUE="<%= contextPath %>/CadenzaServlet"></PARAM>

<PARAM NAME="Server" VALUE="<%= serverName %>"></PARAM>

<PARAM NAME="Protocol" VALUE="http"></PARAM>

<PARAM NAME="Port" VALUE="<%= serverPort %>"></PARAM>

<PARAM NAME="Type" VALUE="signed"></PARAM>

<PARAM NAME="WebiSession"

        VALUE="<%= strWISession %>"></PARAM>

<PARAM NAME="CdzSession" VALUE="<%= instanceID %>"></PARAM>

<PARAM NAME="DocumentID" VALUE=""></PARAM>

<PARAM NAME="UniverseID"

        VALUE="UnivCUID=<%=universe.getCUID()%>"></PARAM>

<PARAM NAME="bRobot" VALUE="false"></PARAM>

<PARAM NAME="bTraceInLogFile" VALUE="false"></PARAM>

<PARAM NAME="HelpRoot"

        VALUE="<%= contextPath.substring(1) %>"></PARAM>

<PARAM NAME="SaveAs"

        VALUE="<%= contextPath %>save.jsp"></PARAM>

<PARAM NAME="Lang"

        VALUE="<%= request.getLocale().getLanguage() %>"

                ></param>

</APPLET>


Building a data provider manually

When you create a new document instance, Web Intelligence automatically creates an empty data provider for the document. The data provider has a data source and an empty query object. Building a data provider consists in populating the query object with the data source objects in which you are interested.

To build a data provider:

  1. Get the collection of data providers for the document.
  2. Get the universe elements in which you are interested.
  3. Get the query for the data provider.
  4. Add result objects.
  5. Add condition objects (optional).
  6. Execute the query.

Example:    Building a data provider

The following JSP code fragment illustrates how to populate the query object of a data provider.

//select a universe ==> sID

...

//create a new document instance

DocumentInstance doc = reportEngine.newDocument(sID);

DataProviders dps = doc.getDataProviders();

// Retrieve the 1st data provider

DataProvider dp = dps.getItem(0);

// Retrieve the universe objects

DataSource ds = dp.getDataSource ();

DataSourceObject city =

                                ds.getClasses().getChildByName("city");

DataSourceObject year =

                                ds.getClasses().getChildByName ("year");

DataSourceObject sales =

                                ds.getClasses().getChildByName ("sales");

Query q = dp.getQuery();

// Add result objects to the query

q.addResultObject (city);

q.addResultObject (year);

q.addResultObject (sales);

// Run the query: execute the query and fetch the data

dp.runQuery();


Editing queries

A query is represented by the Query object and has the following parts:

To get the query for a data provider, use DataProvider.getQuery.

Result objects

A result object is a class or an object in a universe. Including a result object in the query is the same as dragging and dropping an object into the Results area of the Query Panel of the Web Intelligence Java Report Panel. When you execute the query, the result object is added to the report dictionary (as a report expression, see Block structure: axes and report expressions) and is available for editing reports.

To add a result object to the query, use Query.addResultObject.

To remove a result object from the query, use Query.removeResultObject.

Scope of analysis

The scope of analysis is a feature that enables you to include more information in a cube than the query requires. This is very helpful in drilling as it is avoids modifying the query for every drill operation. See Drilling in Web Intelligence Reports.

The scope of analysis is defined in terms of the scope level and is represented by the Scope interface. The scope level specifies how many objects of a class hierarchy are retrieved when you run the query. The scope level can be LEVEL_1, LEVEL_2, LEVEL_3, or CUSTOM.

A scope level of LEVEL_1 indicates that just the result object specified in the query is retrieved. A scope level of LEVEL_3 indicates that the first three objects in the class hierarchy, starting with the result objects specified in the query, will be included in the retrieved results.

If you modify the elements in the scope of analysis, Web Intelligence changes the scope level accordingly. If you create a scope of analysis that does not match an existing hierarchy, for example, if you remove the Quarter object from the scope of analysis so that a drill on the Year goes to the Month object, the scope level is set to CUSTOM, however, if you remove the third level from a LEVEL_3 scope of analysis, Web Intelligence sets the scope level to LEVEL_2.

To get the scope of analysis for a query, use Query.getScope.

To modify a scope of analysis add and remove the objects you want in the scope of analysis with Scope.addScopeObject and Scope.removeScopeObject.

Conditions

A condition is a constraint on the data retrieved when you run a query, and is sometimes called a query filter.

For example, if you add the result objects Year, Revenue, Store, and Company Average, then define the condition ((Year between 1995 and 1999) AND (Revenue < Company Average)), the query would return only data about the stores that, between 1995 and 1999, achieved revenues below the company average. For more information on conditions see Web Intelligence User's Guide.

Simple conditions

The simplest condition consists of a container, a data source object, and unary operator. For example, in the condition (Revenue is not NULL), "Revenue" is the object, and "is not NULL" is the operator.

In REBean, this condition is represented as follows.

 

The FilterCondition class holds information about operators and operands. For some operators, such as BETWEEN, the FilterCondition contains more than one operand.

Example:    Creating a simple condition

The following JSP code fragment creates the condition (Revenue < 10000).

Query q; //query to which the condition is applied

//create a container for the condition

ConditionContainer c1 = q.createCondtion();

//create an object for the condition

ConditionObject co = c1.createConditionObject(revenue);

//create a FilterCondition object to contain information

//about the operator and the operand

FilterCondition fc = co.createFilterCondition(Operator.LESS);

fc.createFilterConditionConstant("10000");


Complex conditions

By combining containers with operators and adding extra condition objects you can build very complex conditions.

Example:    Structure of a complex condition

The following is a representation in REBean of the condition:

(Revenue < 1000000) OR ((Year = 2002) AND (Holiday)).

 


Including a prompt in a condition

To include a prompt in a condition use FilterCondition.createConditionPrompt.

This method returns a ConditionPrompt object that you can use to define a prompt that is activated when the query is executed.

As with normal prompts when you create a condition prompt you need to define the name of the prompt (that is, the question that is asked). You can also define properties such as its default value, and whether or not it is constrained to a list of values.

You handle these prompts with the same workflows that are described in Handling prompts.

Example:    Including a prompt in a condition

The following JSP code fragment creates the condition prompt "Year?"

//get the query (q) to which the condition is applied

//...

//create a container for the condition

ConditionContainer cc = q.createCondition();

//create an object for the condition

ConditionObject co = cc.createConditionObject(country);

//create a FilterCondition object to contain the prompt

FilterCondition fc = co.createFilterCondition(Operator.EQUAL);

//define the prompt

ConditionPrompt cp = fc.createConditionPrompt("Country?");

cp.setConstrained(false);

cp.setMonoValue(true);

cp.addDefault("Australia");




Business Objects
http://www.businessobjects.com/
Support services
http://www.businessobjects.com/services/support/