MicroStrategy ONE

Drilling to an Attribute

This example demonstrates drilling on one of the attributes of a report to another attribute. For example, from Manager to Region. The source attribute, Manager, is replaced by the target attribute that is drilled to, which is Region.

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();

   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 WebDrill elements on the drill instance

   WebDrillElements webDrillElements = drillInstance.getDrillElements();

 

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

   //The elementID can be obtained using WebHeader.getDrillElement()

   webDrillElements.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 DrillToUnit drill action in the collection

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

 

   //Set the target unit on the drill action, which is the target attribute to which the user wants to drill to

   action.setTarget(targetObject);

 

   //Perform the drilling and gets the new report instance

   WebReportInstance newReportInstance = drillInstance.drill();

 

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