MicroStrategy ONE

Displaying a List of Drill Paths for the Template Units on a Report

While a report can have its default drill paths that use the entire template of the report as the source of drilling, each template unit on a report can have its own set of default drill paths as well.

This example lists the default drill paths for each of the template units of a report. This example is similar to Display a List of Drill Paths for the Report, except in this case, use the getDrillPaths() method from each WebTemplateUnit on the WebTemplate belonging to the report.

Code sample

This code sample assumes that a valid sessionID, messageID and a stateID exist for the report instance that is drilled.

 try

 {

 

   //Get the WebObjectsFactory instance

   WebObjectsFactory factory = WebObjectsFactory.getInstance();

   factory.getIServerSession().setSessionID(sessionID);

 

   //Get the Report Source from the factory

   WebReportSource reportSource = factory.getReportSource();

 

   //Use the Report Source to retrieve the Web Report instance corresponding to the given messageID and stateID

   WebReportInstance reportInstance = reportSource.getInstance(messageID, stateID);

 

   //Get the report template

   WebTemplate template = reportInstance.getTemplate();

 

   //Get the list of template units for the template

   SimpleList templateUnitsList = template.getUnits();

 

   //Get the template units as an enumeration

   Enumeration templateUnits = templateUnitsList.elements();

 

   Log.logger.log(Level.INFO, " The drill paths for the templateUnits are as follows ");

 

   //Traverse each template unit

   while(templateUnits.hasMoreElements())

   {

 

     //Fetch the next template unit

     WebTemplateUnit templateUnit = (WebTemplateUnit)templateUnits.nextElement();

     Log.logger.log(Level.INFO, " Template Name : " + templateUnit.getName());

 

     //Get the drill map for the entire report

     WebDrillMap drillMap = templateUnit.getDrillMap();

 

     //Get the collection of drill paths as an enumeration

     Enumeration drillPaths = drillMap.elements();

 

     //Traverse the drill paths and prints their information

     Log.logger.log(Level.INFO, " The drill paths for the whole report are as follows ");

 

     while(drillPaths.hasMoreElements())

     {

 

       //Get the element at the current index

       WebDrillPath drillPath = (WebDrillPath)drillPaths.nextElement();

 

       //Print the ID, name, and description for the drill path

       Log.logger.log(Level.INFO, "ID : " + drillPath.getID());

       Log.logger.log(Level.INFO, "Name : " + drillPath.getName());

       Log.logger.log(Level.INFO, "Description : " + drillPath.getDescription());

 

       //Determine the importance index for the drill path and print it

       switch(drillPath.getImportance())

       {

         // high importance

         case com.microstrategy.webapi.EnumDSSXMLDrillImportance.DssXmlDrillImportanceHigh :

         Log.logger.log(Level.INFO, "Importance : High");

         break;

 

         // low importance

         case com.microstrategy.webapi.EnumDSSXMLDrillImportance.DssXmlDrillImportanceLow :

         Log.logger.log(Level.INFO, "Importance : Low");

         break;

 

         // medium importance

         case com.microstrategy.webapi.EnumDSSXMLDrillImportance.DssXmlDrillImportanceMedium :

         Log.logger.log(Level.INFO, "Importance : Medium");

         break;

       }

       Log.logger.log(Level.INFO, "Set Name : " + drillPath.getSetName());

     }

   }

 } catch(WebObjectsException e) { Log.logger.log(Level.ERROR, e.getMessage);}