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

KB34189: How to Programmatically Retrieve an Attribute from a Hierarchy using MicroStrategy Java Web SDK 9.3.1


Community Admin

• Strategy


This article discusses how to Programmatically Retrieve an Attribute from a Hierarchy using MicroStrategy Java Web SDK 9.3.1

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 sample code demonstrates how to retrieve an attribute from a hierarchy or dimension object using the Strategy Java Web SDK 9.3.1:
 


/**
* Strategy SDK Sample
*
* Copyright © 2005 Strategy Incorporated. All Rights Reserved.
*
* Strategy MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
* SUITABILITY OF THIS SAMPLE CODE, EITHER EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. Strategy SHALL NOT
* BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
* MODIFYING OR DISTRIBUTING THIS SAMPLE CODE OR ITS DERIVATIVES.
*
*
*/

package customclasses.misc;

import com.Strategy.web.objects.WebAttribute;
import com.Strategy.web.objects.WebClusterAdmin;
import com.Strategy.web.objects.WebDimension;
import com.Strategy.web.objects.WebDimensionAttribute;
import com.Strategy.web.objects.WebIServerSession;
import com.Strategy.web.objects.WebObjectSource;
import com.Strategy.web.objects.WebObjectsException;
import com.Strategy.web.objects.WebObjectsFactory;
import com.Strategy.webapi.EnumDSSXMLFolderNames;
import com.Strategy.webapi.EnumDSSXMLObjectTypes;

public class GetAttributeDim {
    /**

     * @param args

     * @throws WebObjectsException

     */
    
    public static void main(String[] args) throws WebObjectsException { // TODO Auto-generated method stub
        
        WebObjectsFactory mMSTRProjectFactory = WebObjectsFactory.getInstance();
        WebClusterAdmin lAdmin = mMSTRProjectFactory.getClusterAdmin();
		
        lAdmin.setRequestTimeOutMillis(400000);
        lAdmin.setServerBusyTimeOutMillis(400000);
		
        WebIServerSession mMSTRProjectSession = mMSTRProjectFactory.getIServerSession();
        mMSTRProjectSession.setServerName("machinename");
        mMSTRProjectSession.setLogin("Administrator");
        mMSTRProjectSession.setPassword("");
        mMSTRProjectSession.setServerPort(0);
        mMSTRProjectSession.setProjectName("Strategy Tutorial");
        mMSTRProjectSession.getSessionID();
		
        WebObjectSource lOS = mMSTRProjectFactory.getObjectSource();
        String customerHierID = "B793B55611D3E4E51000E887EC6DE8A4";
		
        WebDimension dim = (WebDimension) lOS.getObject(customerHierID, EnumDSSXMLObjectTypes.DssXmlTypeDimension, true);
        System.out.println("Dim name: " + dim.getName());
        System.out.println("type: " + dim.getType()); //The following attribute object GUID is 'Customer State' in Strategy Tutorial
        
        String customerStateAttributeID = "54BABC8311D59D57C000B28A4CC5F24F";
        WebDimensionAttribute dimState = dim.itemByID(customerStateAttributeID);
		
        WebAttribute lAttrib = dimState.getAttribute();
        System.out.println("Attribute Name: " + lAttrib.getName());
		
        WebDimensionAttribute lWebDimAttr = lAttrib.getDimensionAttribute();
        System.out.println("Dimension Attribute Display Name: " + lWebDimAttr.getDisplayName());
		
        WebAttribute att2 = lWebDimAttr.getAttribute();
        System.out.println("Attribute GUID: " + att2.getID());
        System.out.println(" Attribute Name: " + att2.getName());
    }
}

  
 
CUSTOMIZATION 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 Technical Support makes no guarantee that an updated version of this particular customization will be provided. 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. For enhancements to this customization or to incorporate similar functionality into other versions, contact your Account Executive to inquire about Strategy Consulting assistance.


Comment

0 comments

Details

Knowledge Article

Published:

June 13, 2017

Last Updated:

June 13, 2017