Using the Strategy Java Web SDK in 9.4.1, it is possible to programmatically retrieve information about parent/child relationships between attributes. In the following example, the customer hierarchy and customer state attribute objects from the Strategy Tutorial project are being used.
The code snippet will implement the following steps:
1. Retrieve the user-defined hierarchy object
2. From the hierarchy object, retrieve the attribute dimension object by passing in the ID of the attribute
3. Use the methods to return the parents and children information from the attribute.
package customclasses.misc;
import com.Strategy.web.objects.SimpleList;
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 {
public static void main(String[] args) throws WebObjectsException {
WebObjectsFactory mMSTRProjectFactory = WebObjectsFactory.getInstance();
WebClusterAdmin lAdmin = mMSTRProjectFactory.getClusterAdmin();
lAdmin.setRequestTimeOutMillis(400000);
lAdmin.setServerBusyTimeOutMillis(400000);
WebIServerSession mMSTRProjectSession = mMSTRProjectFactory.getIServerSession();
mMSTRProjectSession.setServerName("SERVER-NAME");
mMSTRProjectSession.setLogin("USERID");
mMSTRProjectSession.setPassword("");
mMSTRProjectSession.setServerPort(0);
mMSTRProjectSession.setProjectName("PROJECT");
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());
SimpleList children = lWebDimAttr.getChildren(); //returns customer city
SimpleList parents = lWebDimAttr.getParents(); //returns customer region
}
}