Hierarchy Developer's Guide for Oracle Billing Insight > Basic Hierarchy Manager Use Cases > Taking the User's Role into Consideration >

Creating Hierarchies


The following code shows an example of creating hierarchies:

IHierarchyContext hierarchyContext = new HierarchyContext();
//hierarchyContext can be set through web appflow layer
hierarchyContext.setUser(user);
hierarchyContext.setSubject(subject);
...
LookupService lookup = LookupServiceFactory.getInstance();
IHierarchyService hierarchyServices = (IHierarchyService)lookup.getModule("hierarchy");
IHierarchyAccessManager haMgr = hierarchyServices.createHierarchyAccessManager(hierarchyContext);
IHierarchy hierarchy =
haMgr.createHierarchy (hierarchyname, hierarchy_type, hierarchyDesc);
.....

Use IHierarchyAccessManager to create a hierarchy, based on the current user or subject information stored in the HierarchyContext. Note that the method acts differently depending on the user role:

  • User is a Subscriber. HierarchyAccessException is thrown, because the subscriber is not allowed to create a hierarchy.
  • User is a Manager. A new hierarchy is created with a domain ID of the user's company ID, and the user is assigned to the root node of the tree.
  • User is a System Administrator. A new hierarchy is created with a domain ID of the user's company ID.
Hierarchy Developer's Guide for Oracle Billing Insight Copyright © 2016, Oracle and/or its affiliates. All rights reserved. Legal Notices.