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

How to remove an object from a report object and keep the object in the Working Set


Manuel Enrique Pastrana Rodriguez

Senior Product Specialist • Strategy


This document illustrates how to remove objects (attribute, metric, etc.) from a report instance object and keep them in the working set in MicroStrategy Java Web SDK. This operation allows users to change the display layout of the report without altering the working set definition.

This document illustrates how to remove objects (attribute, metric, etc.) from a report instance object and keep them in the working set in Strategy Java Web SDK. This operation allows users to change the display layout of the report without altering the working set definition.
The following sample code shows how to accomplish it:
 


// Create our I-Server Session
WebIServerSession session = SessionManager.getSessionWithDetails(intelligenceServerName, projectName, StrategyUsername, StrategyPassword);

// The GUID of the data mart report to use
String reportID = "F67BD85348FEE604EFDF6EBF265002A2";

//Create a report source with the server session
WebReportSource rSource = session.getFactory().getReportSource();

//Execute a report and obtain a new report instance object
try {
  WebReportInstance wrpInstance = rSource.getNewInstance(reportID);

  //Get the report's template object
  WebTemplate template = wrpInstance.getTemplate();
  WebTemplateUnit templUnit;

  //Get the object to be removed. In this case the first object in the first axis
  templUnit = template.getTemplateUnit(1,1);
  int unitType = templUnit.getUnitType();

  //Get the WebObjectInfo object associated to the object that will be removed

  WebObjectInfo oi = null;
  switch (unitType) {
    case EnumDSSXMLTemplateUnitType.DssXmlTemplateAttribute:
      WebTemplateAttribute templAttr = (WebTemplateAttribute)templUnit.getTarget();
      oi = (WebObjectInfo) templAttr.getAttributeInfo();
      break;

    case EnumDSSXMLTemplateUnitType.DssXmlTemplateConsolidation:
      WebTemplateConsolidation templCons = (WebTemplateConsolidation)templUnit.getTarget();
      oi = (WebObjectInfo) templCons.getConsolidationInfo();
      break;

    case EnumDSSXMLTemplateUnitType.DssXmlTemplateCustomGroup:
      WebTemplateCustomGroup templCG = (WebTemplateCustomGroup)templUnit.getTarget();
      oi = (WebObjectInfo) templCG.getCustomGroupInfo();
      break;

    case EnumDSSXMLTemplateUnitType.DssXmlTemplateMetrics:
      WebTemplateMetric templMetric = (WebTemplateMetric)templUnit.getTarget();
      oi = (WebObjectInfo) templMetric.getMetric();
      break;
  }

  //Remove the object from the template
  template.remove(oi);

  //Apply the changes and get a new report instance object
  WebReportManipulation wrpManip = wrpInstance.getReportManipulator();
  wrpInstance = wrpManip.applyChanges();

  //Get and display the new report layout
  String remObjXMLResult = wrpInstance.getResultsAsXML();
  System.out.println(remObjXMLResult);
} catch (WebObjectsException | UnsupportedOperationException | IllegalArgumentException
| WebReportValidationException e) {
  e.printStackTrace();
}

 


Comment

0 comments

Details

Knowledge Article

Published:

June 22, 2017

Last Updated:

June 22, 2017