on 10-01-2015 5:29 PM
Is there any way we can extract the webi prompts information including the values in BI 4.1 as of now i know it is possible from the restful web services but i am looking to get all webi reports parameters to automate my dataprovider change.
If you don't want to use the RESTful web services, you can use the regular Java SDK to do this.
Get the IInfoObject for each webi report.
Cast it as an IWebi.
Use IWebi.getPrompts to get a collection of IWebiPrompt.
Iterate through the list to get the information about the prompts.
-Dell
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Below is the code which i am using to get the prompt information with values
package com.enterprise.batchchange;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.*;
import org.apache.log4j.Logger;
import com.businessobjects.rebean.wi.DocumentInstance;
import com.businessobjects.rebean.wi.Prompt;
import com.businessobjects.rebean.wi.Prompts;
import com.businessobjects.rebean.wi.ReportEngine;
import com.businessobjects.rebean.wi.ValueFromLov;
import com.crystaldecisions.sdk.exception.SDKException;
import com.crystaldecisions.sdk.framework.CrystalEnterprise;
import com.crystaldecisions.sdk.framework.IEnterpriseSession;
import com.crystaldecisions.sdk.framework.ISessionMgr;
import com.crystaldecisions.sdk.occa.infostore.IInfoObject;
import com.crystaldecisions.sdk.occa.infostore.IInfoObjects;
import com.crystaldecisions.sdk.occa.infostore.IInfoStore;
import com.crystaldecisions.sdk.occa.security.ILogonTokenMgr;
public class ReportEngineStuff {
public static Logger log = Logger.getLogger("com.enterprise.batchchange.ReportEngineStuff");
static IEnterpriseSession session, entSession = null;
static ISessionMgr sessionMgr;
static IInfoStore infoStore,iStore;
/* static String boUsername = "administrator";
static String boPassword = "Epco2014Dev";
static String cmsName = "10.96.113.125:7400";
static String boAuthType = "secEnterprise";
*/
static InputStream input = null;
static Properties prop = null;
public static void main(String[] args) throws Exception {
session = getEnterpriseSession();
iStore = (IInfoStore) session.getService("InfoStore");
List<String> list1 = getPromptNames("197408", iStore);
System.out.println("the prompot length is "+list1.size());
for(int i=0;i<list1.size();i++){
System.out.println("the report prompt is : "+list1.get(i));
}
//RESTUtility.changeWEBIUniverse("232266", "30131", "24672", iStore);
}
public static String getDefaultToken() throws SDKException, FileNotFoundException {
sessionMgr = CrystalEnterprise.getSessionMgr();
/*input = new FileInputStream("C:\\config.properties");
String userName = prop.getProperty("name");
String pwd = prop.getProperty("password");
String cms = prop.getProperty("cms");
String boAuthType = prop.getProperty("authType");*/
String userName = "administrator";
String pwd = "Summer11";
String cms = "rdcsndbob01:6400";
String boAuthType = "secEnterprise";
log.info("the username is "+userName+" the password is :"+pwd+" the cms is "+cms);
IEnterpriseSession eSession = sessionMgr.logon(userName, pwd,cms, boAuthType);
ILogonTokenMgr logonTokenMgr = eSession.getLogonTokenMgr();
infoStore = (IInfoStore) eSession.getService("InfoStore");
String defaultToken = logonTokenMgr.getDefaultToken();
return defaultToken;
}
public static IEnterpriseSession getEnterpriseSession() throws SDKException, FileNotFoundException {
sessionMgr = CrystalEnterprise.getSessionMgr();
//Properties prop = new Properties();
/*input = new FileInputStream("C:\\config.properties");
String userName = prop.getProperty("name");
String pwd = prop.getProperty("password");
String cms = prop.getProperty("cms");
String boAuthType = prop.getProperty("authType");*/
String userName = "administrator";
String pwd = "Summer11";
String cms = "rdcsndbob01:6400";
String boAuthType = "secEnterprise";
log.info("the username is "+userName+" the password is :"+pwd+" the cms is "+cms);
session = sessionMgr.logon(userName, pwd, cms, boAuthType);
return session;
}
public static List<String> getPromptNames(String strSIID, IInfoStore iStore)
throws SDKException, FileNotFoundException {
// TODO Auto-generated method stub
List<String> prmptName = new ArrayList<String>();
if (entSession == null) {
entSession = getEnterpriseSession();
}
ReportEngine repEng = (ReportEngine) entSession.getService("",
"WebiReportEngine");// get webi service from BO to open webi
// report
IInfoObjects oInfoObjects = iStore
.query("Select TOP 1 * From CI_INFOOBJECTS Where SI_ID="+ strSIID);
// retrieve
// the
// report
// from
// BO
// with
// id
// 5872
if (oInfoObjects.getResultSize() > 0) // see if report exists in BO
{
IInfoObject oInfoObject = (IInfoObject) oInfoObjects.get(0);// retrieve
// report
// from
// BO
System.out.println("the name is " + oInfoObject.getTitle());
DocumentInstance doc = repEng.openDocument(oInfoObject.getID());// open
// report
// using
// WEBI
// SDK
System.out.println("Report Opened In Memory");
Prompts prompts = doc.getPrompts();// get all repot prompts
System.out.println("number of prompts in report :: "+ prompts.getCount());
//prmptName = new String[prompts.getCount()];
for (int i = 0, m = prompts.getCount(); i < m; i++) {
// doc.refresh();
Prompt prompt = prompts.getItem(i);
String promptType = prompt.getObjectType().toString();
String promptName = prompt.getName();
prmptName.add(promptName);
System.out.println(promptType + " " + promptName);
}
}
return prmptName;
}
public static List<String> getPromptValues(String reportId, IInfoStore iStore)
throws SDKException, FileNotFoundException {
List<String> tempPromptValues = new ArrayList<String>();
SimpleDateFormat originalFormat = new SimpleDateFormat("dd/mm/yyyy hh:mm:ss aa");
SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS-ss:ss");
Date date;
if (entSession == null) {
entSession = getEnterpriseSession();
}
// log.info("trying to get the report engine object !");
ReportEngine repEng = (ReportEngine) entSession.getService("","WebiReportEngine");
// log.info("got the report engine object !");
String query = "Select TOP 1 * From CI_INFOOBJECTS Where SI_ID="+ reportId;
IInfoObjects oInfoObjects = infoStore.query(query);
// log.info("the query is : " + query);
if (oInfoObjects.getResultSize() > 0) // see if report exists in BO
{
IInfoObject oInfoObject = (IInfoObject) oInfoObjects.get(0);// retrieve
// report
// from
// BO
DocumentInstance doc = repEng.openDocument(oInfoObject.getID());// open
// report
// using
// WEBI
// SDK
// log.info("Report Opened In Memory");
Prompts prompts = doc.getPrompts(); // get all repot prompts
int promptCount = prompts.getCount();
log.info("number of prompts in report :: " + promptCount);
//tempPromptValues = new String[promptCount];
if (promptCount > 0) {
ValueFromLov[] val;
ValueFromLov temp;
String[] values = null;
String tempValue = null;
for (int i = 0, m = prompts.getCount(); i < m; i++) {
// doc.refresh();
Prompt prompt = prompts.getItem(i);
// log.info("promopt id is : " + prompt.getID());
String promptType = prompt.getObjectType().toString();
String promptName = prompt.getName();
// /log.info("the prompt type is " + promptType
// + " and the prompt name is: " + promptName);
// DateTime should be 2003-02-26T16:00:00.000-08:00
values = prompt.getCurrentValues();
// log.info("the current values length is : "+values.length);
if (values.length > 0) {
tempValue = values[0];
// log.info("and the value is : "+tempValue);
} else {
// log.info("dont have the current values going for default values ");
values = prompt.getDefaultValues();
// log.info("the default values length is : "+values.length);
if (values.length > 0) {
tempValue = values[0];
// log.info("and the value is : "+tempValue);
} else {
// log.info("dont have the default values going for previous values ");
values = prompt.getPreviousValues();
if (values.length > 0) {
tempValue = values[0];
// log.info("the previous values length is : "+values.length+" and the value is : "+tempValue);
} else {
// log.info("dont have the previous values going for current LOV values ");
val = prompt.getCurrentValuesFromLov();
// log.info("the current LOV values length is : "+val.length);
if (val.length > 0) {
temp = (ValueFromLov) val[0];
tempValue = temp.getValue();
// log.info("and the value is : "+tempValue);
} else {
// log.info("dont have the previous values going for default LOV values ");
val = prompt.getDefaultValuesFromLov();
// log.info("the default LOV values length is : "+val.length);
if (val.length > 0) {
temp = (ValueFromLov) val[0];
tempValue = temp.getValue();
// log.info("and the value is : "+tempValue);
} else {
// log.info("dont have the previous values going for previous LOV values ");
val = prompt.getPreviousValuesFromLov();
// log.info("the previous LOV values length is : "+val.length);
if (val.length > 0) {
temp = (ValueFromLov) val[0];
tempValue = temp.getValue();
// log.info("and the value is : "+tempValue);
} else {
tempValue = " ";
}
}
}
}
}
}
if (promptType == "DATE") {
try {
date = originalFormat.parse(tempValue);
System.out.println("Old Format : "+ originalFormat.format(date));
System.out.println("New Format : "+ targetFormat.format(date));
tempValue = targetFormat.format(date);
} catch (java.text.ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// tempPromptValues.add(tempValue);
tempPromptValues.add(tempValue);
log.info("HI the temp value is " + tempValue);
}
}
}
return tempPromptValues;
}
}
But when i run this it is showing only the prompt names but not the values
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.