MicroStrategy ONE

Drilling to the Child while keeping the Parent

This example demonstrates drilling from an attribute on a report to one of its child attribute. For example, Region to State.  It ensures that the parent or source attribute, Region, exists along with the child, State, in the new report generated after drilling.

Code sample

This code sample assumes that a valid sessionID, messageID and a stateID exist for the report instance that is drilled. Information about the target object (the object that is drilled to), axis (the axis of the template unit from where drilling starts), and position (the position of the template unit from where drilling starts) is available as well.

 try

 {

   //Get the WebObjectsFactory instance

   WebObjectsFactory factory = WebObjectsFactory.getInstance();

 

   //Get the Report Source from the factory

   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 drill instance for the report instance

   WebDrillInstance drillInstance = reportInstance.getDrillInstance();

 

   //Create a collection of Web elements on the drill instance

   WebElements webElements = drillInstance.getDrillElements();

 

   //Set the Web elements selected by the user from the Web interface

   webElements.add(elementID);

 

   //Add the template unit from where drilling should start

   drillInstance.setDrillTemplateUnit(axis,position);

 

   //Fetch the collection of drill actions

   WebDrillActions drillActions = drillInstance.getDrillActions();

 

   //Add a DrillToChild drill action in the collection

   WebNewObjectDrillAction action = (WebNewObjectDrillAction)drillActions.add(EnumDSSXMLDrillType.DssXmlDrillToChild);

 

   //Set the target unit on the drill action

   action.setTarget(targetObject);

 

   //Set the keepOriginal flag to true

   action.setKeepOriginal(true);

 

   //Perform the drilling and gets the new report instance

   WebReportInstance newReportInstance = drillInstance.drill();

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