Hierarchy Open Service Interface Definitions hierarchy version 3.0.0
The Hierarchy OSID is an auxiliary service providing a means for
accessing and managing hierarchical relationships among OSID Ids.
An OSID Id may have onr or more parents or children and the
hierarchy itself represents a directed acyclic graph. The hierarchy
service defines a set of interfaces used among other OSIDs that utilize
hierarchies and can also be used to abstract hierarchical data into a
standalone service.
Hierarchical queries may be performed using the
HierarchyTraversalSession. A set of methods exist to query parents,
children, ancestors, and decendants. A Node structure may be retrieved
to access a portion of a hierarchy in bulk. The Node provides
methods to get parents and children of the node directly.
Hierarchies are federateable by combining nodes. There is no hierarchy service for the hierarchy catalog.
Service Managers¶
Hierarchy Profile¶
-
class
dlkit.services.hierarchy.HierarchyProfile¶ Bases:
dlkit.osid.managers.OsidProfileThe hierarchy profile describes the interoperability among hierarchy services.
-
supports_hierarchy_traversal()¶ Tests if hierarchy traversal is supported.
Returns: trueif hierarchy traversal is supported,falseotherwiseReturn type: booleancompliance: mandatory – This method must be implemented.
-
supports_hierarchy_design()¶ Tests if hierarchy design is supported.
Returns: trueif hierarchy design is supported,falseotherwiseReturn type: booleancompliance: mandatory – This method must be implemented.
-
supports_hierarchy_lookup()¶ Tests if a hierarchy lookup is supported.
Returns: trueif hierarchy lookup is supported,falseotherwiseReturn type: booleancompliance: mandatory – This method must be implemented.
-
supports_hierarchy_admin()¶ Tests if a hierarchy administration is supported.
Returns: trueif hierarchy administration is supported,falseotherwiseReturn type: booleancompliance: mandatory – This method must be implemented.
-
hierarchy_record_types¶ Gets the supported
Hierarchytypes.Returns: a list containing the supported Hierarchyrecord typesReturn type: osid.type.TypeListcompliance: mandatory – This method must be implemented.
-
hierarchy_search_record_types¶ Gets the supported
Hierarchysearch record types.Returns: a list containing the supported Hierarchysearch record typesReturn type: osid.type.TypeListcompliance: mandatory – This method must be implemented.
-
Hierarchy Manager¶
-
class
dlkit.services.hierarchy.HierarchyManager(proxy=None)¶ Bases:
dlkit.osid.managers.OsidManager,dlkit.osid.sessions.OsidSession,dlkit.services.hierarchy.HierarchyProfileThe hierarchy manager provides access sessions to traverse and manage hierrachies of
Ids.The sessions included in this manager are:
HierarchyTraversalSession:a basic session traversing a hierarchyHierarchyDesignSession:a session to design a hierarchyHierarchySequencingSession:a session to sequence nodes in a hierarchyHierarchyStructureNotificationSession:a session for notififcations within a hierarchy structureHierarchyLookupSession:a session looking up hiererachiesHierarchyQuerySession:a session querying hiererachiesHierarchySearchSession:a session for searching for hierarchiesHierarchyAdminSession:a session for creating and deleting hierarchiesHierarchyNotificationSession:a session for subscribing to changes in hierarchies
Hierarchy Traversal Methods¶
HierarchyManager.hierarchy_id¶Gets the hierarchy
Idassociated with this session.
Returns: the hierarchy Idassociated with this sessionReturn type: osid.id.Idcompliance: mandatory – This method must be implemented.
HierarchyManager.hierarchy¶Gets the hierarchy associated with this session.
Returns: the hierarchy associated with this session Return type: osid.hierarchy.HierarchyRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
HierarchyManager.can_access_hierarchy()¶Tests if this user can perform hierarchy queries.
A return of true does not guarantee successful authorization. A return of false indicates that it is known all methods in this session will result in a
PermissionDenied. This is intended as a hint to an application that may opt not to offer lookup operations.
Returns: falseif lookup methods are not authorized,trueotherwiseReturn type: booleancompliance: mandatory – This method must be implemented.
HierarchyManager.roots¶Gets the root nodes of this hierarchy.
Returns: the root nodes Return type: osid.id.IdListRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
HierarchyManager.has_parents(id_)¶Tests if this
Idcontains any parents.
Parameters: id ( osid.id.Id) – theIdto queryReturns: trueif thisIdcontains parents,falseotherwiseReturn type: booleanRaise: NotFound–idis not foundRaise: NullArgument–idisnullRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
HierarchyManager.is_parent(id_, parent_id)¶Tests if an
Idis a direct parent of another.
Parameters:
- id (
osid.id.Id) – theIdto query- parent_id (
osid.id.Id) – theIdof a parentReturns:
trueif thisparent_idis a parent ofid,falseotherwiseReturn type:
booleanRaise:
NotFound–idis not foundRaise:
NullArgument–idorparent_idisnullRaise:
OperationFailed– unable to complete requestRaise:
PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented. implementation notes: If
parent_idnot found returnfalse.
HierarchyManager.get_parents(id_)¶Gets the parents of the given
id.
Parameters: id ( osid.id.Id) – theIdto queryReturns: the parents of the idReturn type: osid.id.IdListRaise: NotFound–idis not foundRaise: NullArgument–idisnullRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
HierarchyManager.is_ancestor(id_, ancestor_id)¶Tests if an
Idis an ancestor of another.
Parameters:
- id (
osid.id.Id) – theIdto query- ancestor_id (
osid.id.Id) – theIdof an ancestorReturns:
trueif thisancestor_idis a parent ofid,falseotherwiseReturn type:
booleanRaise:
NotFound–idis not foundRaise:
NullArgument–idorancestor_idisnullRaise:
OperationFailed– unable to complete requestRaise:
PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented. implementation notes: If
ancestor_idnot found returnfalse.
HierarchyManager.has_children(id_)¶Tests if this
Idhas any children.
Parameters: id ( osid.id.Id) – theIdto queryReturns: trueif thisIdhas children,falseotherwiseReturn type: booleanRaise: NotFound–idis not foundRaise: NullArgument–idisnullRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
HierarchyManager.is_child(id_, child_id)¶Tests if a node is a direct child of another.
Parameters:
- id (
osid.id.Id) – theIdto query- child_id (
osid.id.Id) – theIdof a childReturns:
trueif thischild_idis a child of theId,falseotherwiseReturn type:
booleanRaise:
NotFound–idis not foundRaise:
NullArgument–idorchild_idisnullRaise:
OperationFailed– unable to complete requestRaise:
PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented. implementation notes: If
child_idnot found returnfalse.
HierarchyManager.get_children(id_)¶Gets the children of the given
Id.
Parameters: id ( osid.id.Id) – theIdto queryReturns: the children of the idReturn type: osid.id.IdListRaise: NotFound–idis not foundRaise: NullArgument–idisnullRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
HierarchyManager.is_descendant(id_, descendant_id)¶Tests if a node is a descendant of another.
Parameters:
- id (
osid.id.Id) – theIdto query- descendant_id (
osid.id.Id) – theIdof a descendantReturns:
trueif thisdescendant_idis a child of theId,falseotherwiseReturn type:
booleanRaise:
NotFound–idis not foundRaise:
NullArgument–idordescendantisnullRaise:
OperationFailed– unable to complete requestRaise:
PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented. implementation notes: If not found return
false.
HierarchyManager.get_nodes(id_, ancestor_levels, descendant_levels, include_siblings)¶Gets a portion of the hierarchy for the given
Id.
Parameters:
- id (
osid.id.Id) – theIdto query- ancestor_levels (
cardinal) – the maximum number of ancestor levels to include. A value of 0 returns no parents in the node.- descendant_levels (
cardinal) – the maximum number of descendant levels to include. A value of 0 returns no children in the node.- include_siblings (
boolean) –trueto include the siblings of the given node,falseto omit the siblingsReturns: a node
Return type:
osid.hierarchy.NodeRaise:
NotFound–idis not foundRaise:
NullArgument–idisnullRaise:
OperationFailed– unable to complete requestRaise:
PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
Hierarchy Design Methods¶
HierarchyManager.hierarchy_idGets the hierarchy
Idassociated with this session.
Returns: the hierarchy Idassociated with this sessionReturn type: osid.id.Idcompliance: mandatory – This method must be implemented.
HierarchyManager.hierarchyGets the hierarchy associated with this session.
Returns: the hierarchy associated with this session Return type: osid.hierarchy.HierarchyRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
HierarchyManager.can_modify_hierarchy()¶Tests if this user can change the hierarchy.
A return of true does not guarantee successful authorization. A return of false indicates that it is known performing any update will result in a
PermissionDenied. This is intended as a hint to an application that may opt not to offer these operations to an unauthorized user.
Returns: falseif changing this hierarchy is not authorized,trueotherwiseReturn type: booleancompliance: mandatory – This method must be implemented.
HierarchyManager.add_root(id_)¶Adds a root node.
Parameters: id ( osid.id.Id) – theIdof the nodeRaise: AlreadyExists–idis already in hierarchyRaise: NotFound–idnot foundRaise: NullArgument–idisnullRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
HierarchyManager.add_child(id_, child_id)¶Adds a child to a
Id.
Parameters:
- id (
osid.id.Id) – theIdof the node- child_id (
osid.id.Id) – theIdof the new childRaise:
AlreadyExists–child_idis already a child ofidRaise:
NotFound–idorchild_idnot foundRaise:
NullArgument–idorchild_idisnullRaise:
OperationFailed– unable to complete requestRaise:
PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
HierarchyManager.remove_root(id_)¶Removes a root node.
Parameters: id ( osid.id.Id) – theIdof the nodeRaise: NotFound–idwas not found or not in hierarchyRaise: NullArgument–idisnullRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
HierarchyManager.remove_child(id_, child_id)¶Removes a childfrom an
Id.
Parameters:
- id (
osid.id.Id) – theIdof the node- child_id (
osid.id.Id) – theIdof the child to removeRaise:
NotFound–idorchild_idwas not found orchild_idis not a child ofidRaise:
NullArgument–idorchild_idisnullRaise:
OperationFailed– unable to complete requestRaise:
PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
HierarchyManager.remove_children(id_)¶Removes all childrenfrom an
Id.
Parameters: id ( osid.id.Id) – theIdof the nodeRaise: NotFound– an node identified by the givenIdwas not foundRaise: NullArgument–idisnullRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
Hierarchy Lookup Methods¶
HierarchyManager.can_lookup_hierarchies()¶Tests if this user can perform
Hierarchylookups.A return of true does not guarantee successful authorization. A return of false indicates that it is known all methods in this session will result in a
PermissionDenied. This is intended as a hint to an application that may opt not to offer lookup operations to unauthorized users.
Returns: falseif lookup methods are not authorized,trueotherwiseReturn type: booleancompliance: mandatory – This method must be implemented.
HierarchyManager.use_comparative_hierarchy_view()¶The returns from the lookup methods may omit or translate elements based on this session, such as authorization, and not result in an error.
This view is used when greater interoperability is desired at the expense of precision.
compliance: mandatory – This method is must be implemented.
HierarchyManager.use_plenary_hierarchy_view()¶A complete view of the
Hierarchyreturns is desired.Methods will return what is requested or result in an error. This view is used when greater precision is desired at the expense of interoperability.
compliance: mandatory – This method is must be implemented.
HierarchyManager.get_hierarchy(hierarchy_id)¶Gets the
Hierarchyspecified by itsId.In plenary mode, the exact
Idis found or aNotFoundresults. Otherwise, the returnedHierarchymay have a differentIdthan requested, such as the case where a duplicateIdwas assigned to aHierarchyand retained for compati
Parameters: hierarchy_id ( osid.id.Id) – theIdof theHierarchyto retrieveReturns: the returned HierarchyReturn type: osid.hierarchy.HierarchyRaise: NotFound– noHierarchyfound with the givenIdRaise: NullArgument–hierarchy_idisnullRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
HierarchyManager.get_hierarchies_by_ids(hierarchy_ids)¶Gets a
Hierarchycorresponding to the givenIdList.In plenary mode, the returned list contains all of the hierarchies specified in the
Idlist, in the order of the list, including duplicates, or an error results if anIdin the supplied list is not found or inaccessible. Otherwise, inaccessibleHierarchyobjects may be omitted from the list and may present the elements in any order including returning a unique set.
Parameters: hierarchy_ids ( osid.id.IdList) – the list ofIdsto retrieveReturns: the returned HierarchylistReturn type: osid.hierarchy.HierarchyListRaise: NotFound– anId wasnot foundRaise: NullArgument–hierarchy_idsisnullRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
HierarchyManager.get_hierarchies_by_genus_type(hierarchy_genus_type)¶Gets a
HierarchyListcorresponding to the given genusTypewhich does not include hierarchies of types derived from the specifiedType.In plenary mode, the returned list contains all known hierarchies or an error results. Otherwise, the returned list may contain only those hierarchies that are accessible through this session.
Parameters: hierarchy_genus_type ( osid.type.Type) – a hierarchy genus typeReturns: the returned HierarchylistReturn type: osid.hierarchy.HierarchyListRaise: NullArgument–hierarchy_genus_typeisnullRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
HierarchyManager.get_hierarchies_by_parent_genus_type(hierarchy_genus_type)¶Gets a
HierarchyListcorresponding to the given hierarchy genusTypeand include any additional hierarchies with types derived from the specifiedType.In plenary mode, the returned list contains all known hierarchies or an error results. Otherwise, the returned list may contain only those hierarchies that are accessible through this session.
Parameters: hierarchy_genus_type ( osid.type.Type) – a hierarchy genus typeReturns: the returned HierarchylistReturn type: osid.hierarchy.HierarchyListRaise: NullArgument–hierarchy_genus_typeisnullRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
HierarchyManager.get_hierarchies_by_record_type(hierarchy_record_type)¶Gets a
HierarchyListcorresponding to the given hierarchy recordType.The set of hierarchies implementing the given record type are returned.In plenary mode, the returned list contains all known hierarchies or an error results. Otherwise, the returned list may contain only those hierarchies that are accessible through this session.
Parameters: hierarchy_record_type ( osid.type.Type) – a hierarchy record typeReturns: the returned HierarchylistReturn type: osid.hierarchy.HierarchyListRaise: NullArgument–hierarchy_record_typeisnullRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
HierarchyManager.get_hierarchies_by_provider(resource_id)¶Gets a
HierarchyListfor the given provider ````.The set of hierarchies implementing the given record type are returned.In plenary mode, the returned list contains all known hierarchies or an error results. Otherwise, the returned list may contain only those hierarchies that are accessible through this session.
Parameters: resource_id ( osid.id.Id) – a resourceIdReturns: the returned HierarchylistReturn type: osid.hierarchy.HierarchyListRaise: NullArgument–resource_idisnullRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
HierarchyManager.hierarchies¶Gets all hierarchies.
In plenary mode, the returned list contains all known hierarchies or an error results. Otherwise, the returned list may contain only those hierarchies that are accessible through this session.
Returns: a list of HierarchiesReturn type: osid.hierarchy.HierarchyListRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
Hierarchy Admin Methods¶
HierarchyManager.can_create_hierarchies()¶Tests if this user can create
Hierarchyobjects.A return of true does not guarantee successful authorization. A return of false indicates that it is known creating a
Hierarchywill result in aPermissionDenied. This is intended as a hint to an application that may not wish to offer create operations to unauthorized users.
Returns: falseifHierarchycreation is not authorized,trueotherwiseReturn type: booleancompliance: mandatory – This method must be implemented.
HierarchyManager.can_create_hierarchy_with_record_types(hierarchy_record_types)¶Tests if this user can create a single
Hierarchyusing the desired record types.While
HierarchyManager.getHierarchyRecordTypes()can be used to examine which records are supported, this method tests which record(s) are required for creating a specificHierarchy. Providing an empty array tests if aHierarchycan be created with no records.
Parameters: hierarchy_record_types ( osid.type.Type[]) – array of hierarchy record typesReturns: trueifHierarchycreation using the specifiedTypesis supported,falseotherwiseReturn type: booleanRaise: NullArgument–hierarchy_record_typesisnullcompliance: mandatory – This method must be implemented.
HierarchyManager.get_hierarchy_form_for_create(hierarchy_record_types)¶Gets the hierarchy form for creating new hierarchies.
A new form should be requested for each create transaction. This method is used for creating new hierarchies, where only the
HierarchyTypeis known.
Parameters: hierarchy_record_types ( osid.type.Type[]) – array of hierarchy record typesReturns: the hierarchy form Return type: osid.hierarchy.HierarchyFormRaise: NullArgument–hierarchy_record_typesisnullRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failureRaise: Unsupported– unable to get form for requested record typescompliance: mandatory – This method must be implemented.
HierarchyManager.create_hierarchy(hierarchy_form)¶Creates a new
Hierarchy.
Parameters: hierarchy_form ( osid.hierarchy.HierarchyForm) – the form for thisHierarchyReturns: the new HierarchyReturn type: osid.hierarchy.HierarchyRaise: IllegalState–hierarchy_formalready used in a create transactionRaise: InvalidArgument– one or more of the form elements is invalidRaise: NullArgument–hierarchy_formisnullRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failureRaise: Unsupported–hierarchy_formdid not originate fromget_hierarchy_form_for_create()compliance: mandatory – This method must be implemented.
HierarchyManager.can_update_hierarchies()¶Tests if this user can update
Hierarchyobjects.A return of true does not guarantee successful authorization. A return of false indicates that it is known updating a
Hierarchywill result in aPermissionDenied. This is intended as a hint to an application that may not wish to offer update operations to unauthorized users.
Returns: falseifHierarchymodification is not authorized,trueotherwiseReturn type: booleancompliance: mandatory – This method must be implemented.
HierarchyManager.get_hierarchy_form_for_update(hierarchy_id)¶Gets the hierarchy form for updating an existing hierarchy.
A new hierarchy form should be requested for each update transaction.
Parameters: hierarchy_id ( osid.id.Id) – theIdof theHierarchyReturns: the hierarchy form Return type: osid.hierarchy.HierarchyFormRaise: NotFound–hierarchy_idis not foundRaise: NullArgument–hierarchy_idisnullRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
HierarchyManager.update_hierarchy(hierarchy_form)¶Updates an existing hierarchy.
Parameters: hierarchy_form ( osid.hierarchy.HierarchyForm) – the form containing the elements to be updatedRaise: IllegalState–hierarchy_formalready used in an update transactionRaise: InvalidArgument– the form contains an invalid valueRaise: NullArgument–hierarchy_idorhierarchy_formisnullRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failureRaise: Unsupported–hierarchy_formdid not originate fromget_hierarchy_form_for_update()compliance: mandatory – This method must be implemented.
HierarchyManager.can_delete_hierarchies()¶Tests if this user can delete
Hierarchyobjects.A return of true does not guarantee successful authorization. A return of false indicates that it is known deleting a
Hierarchywill result in aPermissionDenied. This is intended as a hint to an application that may not wish to offer delete operations to unauthorized users.
Returns: falseifHierarchydeletion is not authorized,trueotherwiseReturn type: booleancompliance: mandatory – This method must be implemented.
HierarchyManager.delete_hierarchy(hierarchy_id)¶Deletes a
Hierarchy.
Parameters: hierarchy_id ( osid.id.Id) – theIdof theHierarchyto removeRaise: NotFound–hierarchy_idnot foundRaise: NullArgument–hierarchy_idisnullRaise: OperationFailed– unable to complete requestRaise: PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.
HierarchyManager.can_manage_hierarchy_aliases()¶Tests if this user can manage
Idaliases forHierarchyobjects.A return of true does not guarantee successful authorization. A return of false indicates that it is known changing an alias will result in a
PermissionDenied. This is intended as a hint to an application that may opt not to offer alias operations to an unauthorized user.
Returns: falseifHierarchyaliasing is not authorized,trueotherwiseReturn type: booleancompliance: mandatory – This method must be implemented.
HierarchyManager.alias_hierarchy(hierarchy_id, alias_id)¶Adds an
Idto aHierarchyfor the purpose of creating compatibility.The primary
Idof theHierarchyis determined by the provider. The newIdperforms as an alias to the primaryId. If the alias is a pointer to another vault it is reassigned to the given vaultId.
Parameters:
- hierarchy_id (
osid.id.Id) – theIdof anHierarchy- alias_id (
osid.id.Id) – the aliasIdRaise:
AlreadyExists–alias_idis already assignedRaise:
NotFound–hierarchy_idnot foundRaise:
NullArgument–hierarchy_idoralias_idisnullRaise:
OperationFailed– unable to complete requestRaise:
PermissionDenied– authorization failurecompliance: mandatory – This method must be implemented.