Strategy ONE
Creating a Custom Group Using "In List" Attribute Qualification
/**
* Main method to execute all sample scenarios
* @param args String[]
*/
public static void main(String args[]) {
try {
//Create a session using the SessionManagementSample class
_serverSession = SessionManagementSample.getSession();
//Create a Custom Group using a shortcut to a filter
_customGroup = getNewCustomGroup();
createShortcutToFilter(_customGroup, "FB7D02F44E9B0B7BB41B01A9BD79ED74", "Year Equal or Greater Than 2000");
// Create a Custom Group using In List Attribute Qualification
_customGroup = getNewCustomGroup();
createInListAttributeQualification(_customGroup, "Northern Regions");
// Create a Custom Group using "'Begins With" in the Attribute Qualification
_customGroup = getNewCustomGroup();
createBeginsWithAttributeQualification(_customGroup, "Employee's last name begins with A");
// Create a Custom Group using a Metric Qualification
_customGroup = getNewCustomGroup();
createMetricQualification(_customGroup, "Revenue greater than 1000 at the region level");
// Create a Custom Group Banding Qualification
_customGroup = getNewCustomGroup();
createCustomGroupBandingQualification(_customGroup, "Banding on Revenue at the Country Level");
//Close session
_serverSession.closeSession();
} catch (WebObjectsException webObjEx) {
System.out.println("Error in main: " + webObjEx.getMessage());
}
}
...
/**
* Creates an In List Attribute Qualification Custom Group
* @param cg WebCustomGroup - A new custom group instance
* @param expressionName String - The name used when saving the Custom Group. Also used as the name of the expression.
* @return WebCustomGroup - The new Custom Group
*/
public static WebCustomGroup createInListAttributeQualification(WebCustomGroup cg, String expressionName) {
try {
// Set the filter type to make it truly a custom group
cg.setFilterType(EnumDSSXMLFilterType.DssXmlCustomGroup);
//Display name for CG
//myCG.setName("Test for CG Name");
cg.setDisplayName("Test for CG display Name");
// Get the expression from the custom group
WebExpression expression = cg.getExpression();
/**
* ATTRIBUTE QUALIFICATION - IN LIST
*/
// Set the root node function to IN and expression type to FilterListQual
WebOperatorNode root = (WebOperatorNode) expression.getRootNode();
root.setDisplayName("Northern Regions - Expression (Attribute Qualification)");
root.setFunction(EnumDSSXMLFunction.DssXmlFunctionIn);
root.setExpressionType(EnumDSSXMLExpressionType.DssXmlFilterListQual);
//8D679D4B11D3E4981000E787EC6DE8A4 - Region
WebObjectInfo regionAtt = _objSource.getObject("8D679D4B11D3E4981000E787EC6DE8A4", EnumDSSXMLObjectTypes.DssXmlTypeAttribute);
// Add a shortcut node to the "Region" attribute
expression.createShortcutNode(regionAtt);
// Add an element list node createElementsObjectNode
WebAttribute att = (WebAttribute) regionAtt;
WebElementsObjectNode elemsNode = expression.createElementsObjectNode(att);
//Get attribute elements from Intelligence Server
att.populate();
//Add Northern regions to the attribute qualification
WebElements elements = att.getElementSource().getElements();
WebElement element = null;
for (int i = 0; i < elements.size(); i++) {
element = elements.get(i);
if (element.getDisplayName().startsWith("North")) {
elemsNode.getElements().add(element.getElementID(), element.getDisplayName());
}
}
/**
* Save Misc Custom Group Properties
*/
//Allow aggregation on the CG
//Enabled - EnumDSSXMLAEAggregation.DssXmlAggregationEnable
//Disabled - EnumDSSXMLAEAggregation.DssXmlAggregationDisable
cg.setAggregation(EnumDSSXMLAEAggregation.DssXmlAggregationEnable);
//Enable Hierarchical Display
cg.setFlatten(true);
//Custom Group Element Header Display Option
//Above Child Elements - true
//Below Child Elements - false
cg.setParentFirst(true);
saveCustomGroup(cg, expressionName);
} catch (WebObjectsException woEx) {
SessionManagementSample.handleError(_serverSession, "Error: " + woEx.getMessage());
} finally {
return cg;
}
}
