Information Management IBM InfoSphere Master Data Management, Version 11.3

Creating hierarchies

You can create a hierarchy to classify the items under hierarchies. A hierarchy consists of a set of categories. For example, you can create a hierarchy of books for categorizing the books into different categories such as fiction, non-fiction, drama, poetry, technical books, and non-technical books. A category hierarchy is used by catalogs to classify items, while an organization hierarchy is used to manage IBM® InfoSphere® Master Data Management Collaboration Server users.

Before you begin

Ensure that you have created the primary spec to be used for categories in this hierarchy. Also, ensure that you get the type of hierarchy (category hierarchy or organization hierarchy) that you can create from the solution architect.

Procedure

Create the hierarchy with any of the following methods: user interface, Java™ API, or script API. You need to specify hierarchy name, select a primary spec, display attribute, a path attribute, a hierarchy type, and the access control group when you create the hierarchy. Display attribute is the spec node in the primary spec, whose value for each category in the hierarchy will be displayed in the left pane when displaying this hierarchy in the left pane.
Option Description
User interface
  1. Click Product Manager > Hierarchies > New Hierarchy. The Create Hierarchy page opens.
  2. Provide the required details for creating the hierarchy.
  3. Click Save.
Java API The following sample code creates a hierarchy.
Sample 1: Creating a category hierarchy.
Context ctx = PIMContextFactory.getContext(USERNAME, PASSWORD, COMPANY_NAME);

	HierarchyManager manager = ctx.getHierarchyManager();

    	AccessControlGroup acg = ctx.getOrganizationManager().getAccessControlGroup(ACG_NAME);

SpecManager specManager = ctx.getSpecManager();

PrimarySpec primarySpec = (PrimarySpec)specManager.getSpec(PRIMARYSPEC_NAME);

AttributeDefinition displayAttribute = primarySpec.getAttributeDefinition(DISPLAY_ATTRDEF_PATH);

AttributeDefinition pathAttribute = primarySpec.getAttributeDefinition(PATH_ATTRDEF_PATH);

Hierarchy hierarchy = manager.createHierarchy(primarySpec, "newHierarchy", pathAttribute, acg, displayAttribute);

hierarchy.save();
  The following sample code creates an organization hierarchy.
Sample 2: Creating an organization hierarchy.
Context ctx = PIMContextFactory.getContext(USERNAME, PASSWORD, COMPANY_NAME);

OrganizationManager manager = ctx.getOrganizationManager();

AccessControlGroup acg = manager.getAccessControlGroup(ACG_NAME);

SpecManager specManager = ctx.getSpecManager();

PrimarySpec primarySpec = (PrimarySpec)specManager.getSpec(PRIMARYSPEC_NAME);

AttributeDefinition displayAttribute = primarySpec.getAttributeDefinition(DISPLAY_ATTRDEF_PATH);

AttributeDefinition pathAttribute = primarySpec.getAttributeDefinition(PATH_ATTRDEF_PATH);

OrganizationHierarchy hierarchy = manager.createOrganizationHierarchy(primarySpec, "newHierarchy",pathAttribute, acg, displayAttribute);

hierarchy.save();
Script API The following sample script API creates a hierarchy with the name My Hier, My Primary Spec as the primary spec, and str2 as the display and attribute path node.
var HIER_NAME = "My Hier";
var HIER_SPEC_NAME = "My Primary Spec";
var DISPLAY_NODE_NAME = "str2";

var hierSpec = getSpecByName(HIER_SPEC_NAME);
var dispAttrNode = hierSpec.getNodeByPath(HIER_SPEC_NAME + "/" + DISPLAY_NODE_NAME);
var hmOptArgs=[];
hmOptArgs["displayAttribute"] = dispAttrNode;
hmOptArgs["pathAttribute"] = dispAttrNode;

var hier = new CategoryTree(hierSpec, HIER_NAME,hmOptArgs);
var errs = hier.saveCategoryTree();
out.println("Created the hier: " + HIER_NAME + " ---- errs: " + checkString(errs,""));
Users can view the newly created hierarchy in the Hierarchy Console by clicking Product Manager > Hierarchies > Hierarchy Console.


Last updated: 8 Mar 2016