While working for Business Object Java SDK 4.0 , we went through couple of business scenario where we did customization on BI Launchpad and perform schedule webi reporting. There is well known API which helps to set up desired prompts and their value to schedule the same. We have upgraded the BI from BI 4.0 to BI 4.1 and the customization we performed for setting prompt broke. BI 4.1 doesn’t support set prompt API anymore.
There is recommendation to use RESTFul API from Business Objects support team but using RESTFul API is good with others functionality except to deal with setting prompts.
We found a different approach to set prompt value back to report engine to run report on new prompt field values.
The following method helps to set prompts:
We have single value prompt, Multi value prompt and optional prompt to deal with.
public StringBuilder populateWebiPrompts(Workspace workspace, WorkspaceService workSpaceService, List<Parameter> srcParameters,
IWebiProcessingInfo dstWebi, Locale pvl, SharedPromptsBean.DocumentWrapper docWrap,
Report rptDtls, DriverManagerDataSource datasourceAudit) throws SDKException {
// System.out.println("populateWebiPrompts");
if (srcParameters == null)
thrownew SDKException.InvalidArg();
StringBuilder promptsQuery = new StringBuilder();
// report prompts from excel sheet to feed back to report to schedule
PromptExcell[] reportExcellPrompt = rptDtls.getPromptsExcell();
promptsQuery.append(String.format("%nReport %d: '%s' / '%s'%n", rptDtls.getRow(), rptDtls.getReportName(), rptDtls.getInstanceTitle()));
// we are going to populate the prompts from rebean
// clear out SI_PROMPTS in webiinfoobject
ListdstPrompts = null;
dstPrompts = ((IInternalWebIntelligenceProcessingInfo) dstWebi).getPrompts(true);
intdstPromptsCount = dstPrompts.size();
// System.out.println("dstPromptsCount" + dstPromptsCount);
if (dstPrompts != null) {
for (inti = 0; i< dstPromptsCount; i++) {
dstPrompts.remove(0);
}
}
List<Parameter> srcPrompts = new Vector();
// read parameter to handle each promptParameter
for (Parameter parameter : srcParameters) {
srcPrompts.add(parameter);
}
intsrcPromptsCount = srcPrompts.size();
// System.out.println("srcPromptsCount" + srcPromptsCount);
ListpromptInfos = docWrap.getPrompts();
for (inti = 0; i< srcPromptsCount; i++) {
Parameter srcPrompt = srcPrompts.get(i);
intj = 0;
booleanbFound = false;
String promptText = srcPrompt.getPromptText();
for (intk = 0; k< reportExcellPrompt.length&& !bFound; k++) {
if (reportExcellPrompt[k].getName().indexOf(promptText) != -1) {
j = k;
bFound = true;
}
}
// add current value
Answer answer = srcPrompt.getAnswerInformation().getPreviousAnswer();
DataType dataType = srcPrompt.getAnswerInformation().getDataType();
if (answer == null) {
ReportsSchedulerLogger.logInfoMessage("answer is null, need to play with it");
// setign up answer for which prompt there is no answer from parameterList.
if (srcPrompt.isOptional()) {
if(( reportExcellPrompt[j].getValue() != null && !"".equals(reportExcellPrompt[j].getValue()) ) ){
// optional prompt can be of single Answer value or multiAnswerValue
// creating Multi or Single ValueAnswer promt if we need feed back data to prompt to run report, mean if the excel file have values for these
// optional prompt
// dealign multiAnswerValue with help of prompt text
// if the prompt text doesn't look for multiAnswerValue prompt, create singleAnswerValue prompt
AnswerInformation answerInfo = srcPrompt.getAnswerInformation();
Answer answer1 = ParameterAnswerFactory.createSingleAnswer(srcPrompt, "", "");
srcPrompt.getAnswerInformation().setPreviousAnswer(answer1);
answer = srcPrompt.getAnswerInformation().getPreviousAnswer();
} else {
// if there is no value available into excel sheet to feed back, then create simple SkippedAnswer prompt to avoid null value to set it
// create skipped parameter if the answer is null to avoid unwanted value pass to report engine
Answer answer1 = ParameterAnswerFactory.createSkippedAnswer(srcPrompt);
srcPrompt.getAnswerInformation().setPreviousAnswer(answer1);
answer = srcPrompt.getAnswerInformation().getPreviousAnswer();
}
}
else {
// no idea, what else we need to deal with , for time being, creating single value answer
AnswerInformation answerInfo = srcPrompt.getAnswerInformation();
Answer answer1 = ParameterAnswerFactory.createSingleAnswer(srcPrompt, "", "");
srcPrompt.getAnswerInformation().setPreviousAnswer(answer1);
answer = srcPrompt.getAnswerInformation().getPreviousAnswer();
}
}
if (answer != null) {
String promptInfName = "";
booleanbIsReset = false;
SharedPromptsBean.PromptInfo promptInf = (SharedPromptsBean.PromptInfo) promptInfos.get(i);
promptInfName = promptInf.getPromptName();
bIsReset = false;
// System.out.println("answer not null");
String name = srcPrompt.getIdentifier();
if (promptInfName.equals(promptText) && bIsReset) {
continue;
} else {
IWebiPrompt dstPrompt = ((IWebiPrompts) dstPrompts).add(name);
ListdstValues = dstPrompt.getValues();
ListdstDisplayedValues = dstPrompt.getValuesToDisplay();
ListdstIdxs = dstPrompt.getValueIndexes();
dstValues.clear();
dstIdxs.clear();
promptsQuery.append(String.format("%s = '%s'%n", promptText, reportExcellPrompt[j].getValue()));
if (promptInf.getIsDynamic()) {
// if check box state = true for UseFormula
dstPrompt.setDynamic(true);
// TODO: perhaps we need to localize the string
String dynamicLabel = "#Dynamic value";
dstValues.add(dynamicLabel);
dstDisplayedValues.add(dynamicLabel);
dstIdxs.add("");
} else {
dstPrompt.setDynamic(false);
if (answerinstanceof SingleValueAnswer) {
//System.out.println("SingleValueAnswer");
AnswerValue answerValue = ((SingleValueAnswer) answer).getAnswerValue();
// setting up prompt value for single value prompt
// check up for optional prompt
if(srcPrompt.isOptional() ){
if( reportExcellPrompt[j].getValue() == null ||
" ".equalsIgnoreCase(reportExcellPrompt[j].getValue()) || "".equalsIgnoreCase(reportExcellPrompt[j].getValue()) ){
// leave those as usual, taken care by own
} else {
Field lfg = answerValue.getCaptionField();
lfg.setString(reportExcellPrompt[j].getValue());
answerValue.setCaptionField(lfg);
}
dstValues.add(formatAnswerInfoWithoutHierarchicalConsideration(answerValue, pvl, dataType));
dstDisplayedValues.add(formatAnswerInfo(answerValue, pvl, dataType));
// System.out.println("formatAnswerInfo(answerValue) " + formatAnswerInfo(answerValue, pvl, dataType));
dstIdxs.add(formatField(answerValue.getKeyField(), pvl, dataType));
}
else {
Field lfg = answerValue.getCaptionField();
lfg.setString(reportExcellPrompt[j].getValue());
answerValue.setCaptionField(lfg);
dstValues.add(formatAnswerInfoWithoutHierarchicalConsideration(answerValue, pvl, dataType));
dstDisplayedValues.add(formatAnswerInfo(answerValue, pvl, dataType));
// System.out.println("formatAnswerInfo(answerValue) " + formatAnswerInfo(answerValue, pvl, dataType));
dstIdxs.add(formatField(answerValue.getKeyField(), pvl, dataType));
}
} elseif (answerinstanceof MultiValueAnswer) {
//System.out.println("MultiValueAnswer");
EList<AnswerValue> answerList = ((MultiValueAnswer) answer).getAnswerValues();
// check up for optional prompt
if(srcPrompt.isOptional() ){
// retrieving the prompt from multi value and split those into comma separetd String array []
if( reportExcellPrompt[j].getValue() == null ||
" ".equalsIgnoreCase(reportExcellPrompt[j].getValue()) ||
"".equalsIgnoreCase(reportExcellPrompt[j].getValue())){
// skipping the values as there is null values to set back to prompt
dstPrompt.setSkipped(true);
} else {
// optional prompt but values to set back to prompt from excel sheet
String multiPromptVl = new String(reportExcellPrompt[j].getValue());
String[] prmptMultiFiledVl = new String [multiPromptVl.split(";").length];
int h= 0;
for(String prompt : multiPromptVl.split(";")){
prmptMultiFiledVl[h] = prompt;
h++;
// building multi answer values and set it back to the list
String caption = prmptMultiFiledVl[0];
Member memberValue = createMember(caption, null, dataType, pvl);
if (memberValue != null){
((MultiValueAnswer)answer).getAnswerValues().add(createAnswerValue(srcPrompt, caption, null, dataType, pvl));
}
}
answerList = ((MultiValueAnswer) answer).getAnswerValues(); // retrieve the multi value answer from list to set
// iterate through individual prompt and set the prompt value back
for(intp =0; p< answerList.size(); p++){
AnswerValue answerValue = answerList.get(p);
// setting up prompt value for single value prompt
Field lfg = answerValue.getCaptionField();
lfg.setString(prmptMultiFiledVl[p]);
answerValue.setCaptionField(lfg);
dstValues.add(formatAnswerInfoWithoutHierarchicalConsideration(answerValue, pvl, dataType));
dstDisplayedValues.add(formatAnswerInfo(answerValue, pvl, dataType));
//System.out.println("formatAnswerInfo(answerValue) " + formatAnswerInfo(answerValue, pvl, dataType));
dstIdxs.add(formatField(answerValue.getKeyField(), pvl, dataType));
}
}
} else {
// prompt is not optional and has to set value from excel file to populate webi
if( reportExcellPrompt[j].getValue() != null
&& !"".equalsIgnoreCase(reportExcellPrompt[j].getValue())){
String multiPromptVl = new String(reportExcellPrompt[j].getValue());
String[] prmptMultiFiledVl = new String [multiPromptVl.split(";").length];
int h= 0;
for(String prompt : multiPromptVl.split(";")){
prmptMultiFiledVl[h] = prompt;
h++;
// building multi answer values and set it back to the list
String caption = prmptMultiFiledVl[0];
Member memberValue = createMember(caption, null, dataType, pvl);
if (memberValue != null){
((MultiValueAnswer)answer).getAnswerValues().add(createAnswerValue(srcPrompt, caption, null, dataType, pvl));
}
}
answerList = ((MultiValueAnswer) answer).getAnswerValues();// retrieve the multi value answer from list to set
// iterate through individual prompt and set the prompt value back
for(intp =0; p< answerList.size(); p++){
AnswerValue answerValue = answerList.get(p);
// setting up prompt value for single value prompt
Field lfg = answerValue.getCaptionField();
lfg.setString(prmptMultiFiledVl[p]);
answerValue.setCaptionField(lfg);
dstValues.add(formatAnswerInfoWithoutHierarchicalConsideration(answerValue, pvl, dataType));
dstDisplayedValues.add(formatAnswerInfo(answerValue, pvl, dataType));
//System.out.println("formatAnswerInfo(answerValue) " + formatAnswerInfo(answerValue, pvl, dataType));
dstIdxs.add(formatField(answerValue.getKeyField(), pvl, dataType));
}
}
}
} elseif (answerinstanceof IntervalAnswer) {
// TODO manage the intervalldoublon
//System.out.println("IntervalAnswer");
Interval interval = ((IntervalAnswer) answer).getInterval();
AnswerValue answerValue = interval.getLowValue();
dstValues.add(formatAnswerInfoWithoutHierarchicalConsideration(answerValue, pvl, dataType));
dstDisplayedValues.add(formatAnswerInfo(answerValue, pvl, dataType));
dstIdxs.add(formatField(answerValue.getKeyField(), pvl, dataType));
answerValue = interval.getHighValue();
dstValues.add(formatAnswerInfoWithoutHierarchicalConsideration(answerValue, pvl, dataType));
dstDisplayedValues.add(formatAnswerInfo(answerValue, pvl, dataType));
dstIdxs.add(formatField(answerValue.getKeyField(),pvl, dataType));
} elseif (answerinstanceof ComplexAnswer) {
//System.out.println("ComplexAnswer");
EList<Range> rangeList = ((ComplexAnswer) answer).getRanges();
intindex = 0;
for (Range range : rangeList) {
// TODO manage the intervalldoublon
AnswerValue answerValue = range.getLowValue();
String strAnswer = answerValue.getCaptionField().toString();
answerValue = range.getHighValue();
strAnswer += answerValue.getCaption().toString();
dstValues.add(formatAnswerInfoWithoutHierarchicalConsideration(answerValue, pvl, dataType));
dstDisplayedValues.add(formatAnswerInfo(answerValue, pvl, dataType));
dstIdxs.add(index);
index++;
}
} elseif (answerinstanceof SkippedAnswer) {
//System.out.println("SkippedAnswer");
dstPrompt.setSkipped(true);
}
}
// Add DataProvider
ListdstDataProviders = dstPrompt.getDataProviders();
dstDataProviders.clear();
List<com.sap.sl.dataprovider.DataProvider> dps = workSpaceService.getDataProviders(workspace);
List<com.sap.sl.dataprovider.DataProvider> promptDPs = getDataProviders(srcPrompt, dps);
//System.out.println("promptDPs");
if (promptDPs.size() > 0) {
for (com.sap.sl.dataprovider.DataProvider promptDP : promptDPs) {
String dpID = promptDP.getID();
//System.out.println("dpID: " + dpID);
String dpName = promptDP.getName();
//System.out.println("dpName: " + dpName);
((IDataProviders) dstDataProviders).add(dpID, dpName);
}
}
java.util.ListIteratorli = dstValues.listIterator();
while (li.hasNext()) {
System.out.println("li.next(): " + li.next());
}
} // else of if (promptInfName.equals(promptText) && bIsReset)
} // if (answer != null){
} // for (int i=0; i<srcPromptsCount; i++){
returnpromptsQuery;
}