EducationSoftwareStrategy.com
StrategyCommunity

Knowledge Base

Product

Community

Knowledge Base

TopicsBrowse ArticlesDeveloper Zone

Product

Download SoftwareProduct DocumentationSecurity Hub

Education

Tutorial VideosSolution GalleryEducation courses

Community

GuidelinesGrandmastersEvents
x_social-icon_white.svglinkedin_social-icon_white.svg
Strategy logoCommunity

© Strategy Inc. All Rights Reserved.

LegalTerms of UsePrivacy Policy
  1. Home
  2. Topics

KB19622: How to run a prompted datamart report using the MicroStrategy Web SDK


Community Admin

• Strategy


How to run a prompted datamart report using the MicroStrategy Web SDK

The example provided in this document is provided “as-is” to the user and assumes that the user:

  • Can program, compile (e.g. javac, jikes, etc.), and execute Java programs
  • Can configure environment variables (e.g. JAR files, property files, etc.)
  • Have all the necessary tools to create Java applications (JDK, IDE, etc.)
  • Has access to the Strategy SDK documentation.
  • Has read the customization warning at the bottom of this document

 
PREREQUISITES:
 
For the sample to work, the Strategy Web JAR files must be accessible by the Java Runtime
Environment. The Strategy Web JAR files can be found under:

  • Strategy Web Universal (JSP): {web_root}/WEB-INF/lib directory.
  • Strategy Web (.NET): Program Files\Common Files\Strategy directory.

Note:
 
More elaborate programs will require additional library files and are out of the scope of this document.
 
 
The following piece of code will execute a datamart report answering an object prompt using the saved default answer in Strategy Web SDK.
 
 


package com.Strategy.standalone;

import com.Strategy.web.beans.ReportBean;
import com.Strategy.web.beans.WebBeanFactory;
import com.Strategy.web.objects.EnumWebPromptType;
import com.Strategy.web.objects.WebIServerSession;
import com.Strategy.web.objects.WebObjectsException;
import com.Strategy.web.objects.WebObjectsFactory;
import com.Strategy.web.objects.WebObjectsPrompt;
import com.Strategy.web.objects.WebPrompt;
import com.Strategy.web.objects.WebPrompts;
import com.Strategy.web.objects.WebReportInstance;
import com.Strategy.webapi.EnumDSSXMLApplicationType;
import com.Strategy.webapi.EnumDSSXMLExecutionFlags;

public class PromptedDataMart {

 
 public static void main(String[] args) throws WebObjectsException {
  try { 

   WebObjectsFactory factory=WebObjectsFactory.getInstance();
   WebIServerSession serverSession=factory.getIServerSession(); 
     
   serverSession.setServerName("SERVERNAME");
   serverSession.setServerPort(0);
   serverSession.setProjectName("PROJECT NAME");
   serverSession.setLogin("administrator");
   serverSession.setPassword("");
   serverSession.setApplicationType(EnumDSSXMLApplicationType.DssXmlApplicationCustomApp);
   
   //Create report bean using the ID of an existing Datamart report
   ReportBean rb = getReportBean("AC76536442D4238AA7053EA614FD2192",serverSession);
   WebReportInstance reportInstance = rb.getReportInstance();
   
   WebPrompts prompts = reportInstance.getPrompts();
       int promptSize = prompts.size();
       System.out.println("Number of Prompts in report :->"+promptSize);
       
      for (int i = 0; i < prompts.size(); i++){
           WebPrompt prompt = prompts.get(i);
           
           int promptType = prompt.getPromptType();
           
           System.out.println("Prompt  Type:->"+promptType);
           
           switch (promptType) {
        //For testing purposes I'll just use Object prompt type
           //passing default answer
        case EnumWebPromptType.WebPromptTypeObjects:
         System.out.println("Setting prompt valye for Object Type prompt");
         WebObjectsPrompt objPrompt = (WebObjectsPrompt) prompt;
         if(objPrompt.hasDefaultAnswer()) { // Check if the prompt has a default answer...
          objPrompt.setAnswer(objPrompt.getDefaultAnswer()); // Use default as answer...
     }
     else if(objPrompt.hasPreviousAnswer()) { // Check if the prompt has a previous answer...
      objPrompt.setAnswer(objPrompt.getPreviousAnswer()); // Use previous as answer...
     }
          break;
        
        default:
         System.out.println("Prompt type :->" + promptType + " is not support by ReportExecutor Utility.");
        }
      }
   
   //sets the execution flag to indicate that datamart should be executed
   rb.setExecutionFlags(EnumDSSXMLExecutionFlags.DssXmlExecutionGenerateDatamart); 
   rb.collectData();
  
   serverSession.closeSession();
   System.out.println("Done");
  }
  catch(Exception e){
   e.printStackTrace();
  }  
 }
 
 public static ReportBean getReportBean(String id,WebIServerSession session) {
    ReportBean rb = (ReportBean) WebBeanFactory.getInstance().newBean("ReportBean");
    
    //initialize session appropriately
    rb.setSessionInfo(session);
    rb.setObjectID(id);
    return rb;
   }


}

 
Customization Code Warning:
This customization is provided as a convenience to Strategy users and is only directly applicable to the version stated. While this code may apply to other releases directly, Strategy Technical Support makes no guarantees that the code provided will apply to any future or previous builds. In the event of a code change in future builds, Strategy may not be able to provide additional code on this matter even though this customization is provided at this time for this specific build.
 


Comment

0 comments

Details

Knowledge Article

Published:

June 24, 2017

Last Updated:

June 24, 2017