The example provided in this document is provided “as-is” to the user and assumes that the user:
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:
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());
}
}