Interface SubjectHierarchySession
- All Superinterfaces:
AutoCloseable, Closeable, OsidSession, OsidSession
This session defines methods for traversing a hierarchy of
Subject objects. Each node in the hierarchy is a unique Subject .
The hierarchy may be traversed recursively to establish the tree structure
through getSubjectNodes() . To relate these Ids to another
OSID, getAncestorSubjects() and getDescendantSubjects()
can be used for retrievals that can be used for bulk lookups in other
OSIDs. Any Subject available in the Ontology OSID is known to this
hierarchy but does not appear in the hierarchy traversal until added as a
root node or a child of another node.
A user may not be authorized to traverse the entire hierarchy. Parts
of the hierarchy may be made invisible through omission from the returns
of getParentSubjects() or getChildSubjects() in lieu of a
PERMISSION_DENIED error that may disrupt the traversal through
authorized pathways.
This session defines views that offer differing behaviors when retrieving multiple objects.
- comparative view: subject elements may be silently omitted or re-ordered
- plenary view: provides a complete set or is an error condition
-
Method Summary
Modifier and TypeMethodDescriptionbooleanTests if this user can perform hierarchy queries.getChildSubjectIds(Id subjectId) Gets the childIdsof the given subject.getChildSubjects(Id subjectId) Gets the children of the given subject.getParentSubjectIds(Id subjectId) Gets the parent Ids of the given subject.getParentSubjects(Id subjectId) Gets the parents of the given subject.Gets the root subjectIdsin this hierarchy.Gets the root subjects in this subject hierarchy.Gets the hierarchy associated with this session.Gets the hierarchyIdassociated with this session.getSubjectNodeIds(Id subjectId, long ancestorLevels, long descendantLevels, boolean includeSiblings) Gets a portion of the hierarchy for the given subject.getSubjectNodes(Id subjectId, long ancestorLevels, long descendantLevels, boolean includeSiblings) Gets a portion of the hierarchy for the given subject.booleanhasChildSubjects(Id subjectId) Tests if a subject has any children.booleanhasParentSubjects(Id subjectId) Tests if theSubjecthas any parents.booleanisAncestorOfSubject(Id id, Id subjectId) Tests if anIdis an ancestor of a subject.booleanisChildOfSubject(Id id, Id subjectId) Tests if a subject is a direct child of another.booleanisDescendantOfSubject(Id id, Id subjectId) Tests if anIdis a descendant of a subject.booleanisParentOfSubject(Id id, Id subjectId) Tests if anIdis a direct parent of a subject.voidThe returns from the subject methods may omit or translate elements based on this session, such as authorization, and not result in an error.voidA complete view of theHierarchyreturns is desired.Methods inherited from interface OsidSession
closeMethods inherited from interface OsidSession
getAuthenticatedAgent, getAuthenticatedAgentId, getClockRate, getDate, getEffectiveAgent, getEffectiveAgentId, getFormatType, getLocale, isAuthenticated, startTransaction, supportsTransactionsModifier and TypeMethodDescriptionGets the agent authenticated to this session.Gets theIdof the agent authenticated to this session.Gets the rate of the service clock.getDate()Gets the service date which may be the current date or the effective date in which this session exists.Gets the effective agent in use by this session.Gets theIdof the effective agent in use by this session.Gets theDisplayTextformatTypepreference in effect for this session.Gets the locale indicating the localization preferences in effect for this session.booleanTests if an agent is authenticated to this session.Starts a new transaction for this sesson.booleanTests for the availability of transactions.
-
Method Details
-
getSubjectHierarchyId
Id getSubjectHierarchyId()Gets the hierarchyIdassociated with this session.- Returns:
- the hierarchy
Idassociated with this session - Compliance:
mandatory- This method must be implemented.
-
getSubjectHierarchy
Gets the hierarchy associated with this session.- Returns:
- the hierarchy associated with this session
- Throws:
OperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
canAccessSubjectHierarchy
boolean canAccessSubjectHierarchy()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 aPERMISSION_DENIED. This is intended as a hint to an application that may opt not to offer traversal operations.- Returns:
falseif hierarchy traversal methods are not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
useComparativeSubjectView
void useComparativeSubjectView()The returns from the subject 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.
-
usePlenarySubjectView
void usePlenarySubjectView()A complete view of theHierarchyreturns 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.
-
getRootSubjectIds
Gets the root subjectIdsin this hierarchy.- Returns:
- the root subject
Ids - Throws:
OperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
getRootSubjects
Gets the root subjects in this subject hierarchy.- Returns:
- the root subjects
- Throws:
OperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method is must be implemented.
-
hasParentSubjects
boolean hasParentSubjects(Id subjectId) throws NotFoundException, OperationFailedException, PermissionDeniedException Tests if theSubjecthas any parents.- Parameters:
subjectId- theIdof a subject- Returns:
trueif the subject has parents,falseotherwise- Throws:
NotFoundException-subjectIdis not foundNullArgumentException-subjectIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
isParentOfSubject
boolean isParentOfSubject(Id id, Id subjectId) throws NotFoundException, OperationFailedException, PermissionDeniedException Tests if anIdis a direct parent of a subject.- Parameters:
id- anIdsubjectId- theIdof a subject- Returns:
trueif thisidis a parent ofsubjectId,falseotherwise- Throws:
NotFoundException-subjectIdis not foundNullArgumentException-idorsubjectIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.- Notes:
If- {@code id} not found return {@code false} .
-
getParentSubjectIds
IdList getParentSubjectIds(Id subjectId) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets the parent Ids of the given subject.- Parameters:
subjectId- theIdof a subject- Returns:
- the parent
Idsof the subject - Throws:
NotFoundException-subjectIdis not foundNullArgumentException-subjectIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
getParentSubjects
SubjectList getParentSubjects(Id subjectId) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets the parents of the given subject.- Parameters:
subjectId- theIdof a subject- Returns:
- the parents of the subject
- Throws:
NotFoundException-subjectIdis not foundNullArgumentException-subjectIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
isAncestorOfSubject
boolean isAncestorOfSubject(Id id, Id subjectId) throws NotFoundException, OperationFailedException, PermissionDeniedException Tests if anIdis an ancestor of a subject.- Parameters:
id- anIdsubjectId- theIdof a subject- Returns:
trueif thisidis an ancestor ofsubjectId,falseotherwise- Throws:
NotFoundException-subjectIdis not foundNullArgumentException-idorsubjectIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.- Notes:
If- {@code id} not found return {@code false} .
-
hasChildSubjects
boolean hasChildSubjects(Id subjectId) throws NotFoundException, OperationFailedException, PermissionDeniedException Tests if a subject has any children.- Parameters:
subjectId- theIdof a subject- Returns:
trueif thesubjectIdhas children,falseotherwise- Throws:
NotFoundException-subjectIdis not foundNullArgumentException-subjectIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
isChildOfSubject
boolean isChildOfSubject(Id id, Id subjectId) throws NotFoundException, OperationFailedException, PermissionDeniedException Tests if a subject is a direct child of another.- Parameters:
id- anIdsubjectId- theIdof a subject- Returns:
trueif theidis a child ofsubjectId,falseotherwise- Throws:
NotFoundException-subjectIdis not foundNullArgumentException-idorsubjectIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.- Notes:
If- {@code id} not found return {@code false} .
-
getChildSubjectIds
IdList getChildSubjectIds(Id subjectId) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets the childIdsof the given subject.- Parameters:
subjectId- theIdto query- Returns:
- the children of the subject
- Throws:
NotFoundException-subjectIdis not foundNullArgumentException-subjectIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
getChildSubjects
SubjectList getChildSubjects(Id subjectId) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets the children of the given subject.- Parameters:
subjectId- theIdto query- Returns:
- the children of the subject
- Throws:
NotFoundException-subjectIdis not foundNullArgumentException-subjectIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
isDescendantOfSubject
boolean isDescendantOfSubject(Id id, Id subjectId) throws NotFoundException, OperationFailedException, PermissionDeniedException Tests if anIdis a descendant of a subject.- Parameters:
id- anIdsubjectId- theIdof a subject- Returns:
trueif theidis a descendant of thesubjectId,falseotherwise- Throws:
NotFoundException-subjectIdis not foundNullArgumentException-idorsubjectIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.- Notes:
If- {@code id} is not found return {@code false} .
-
getSubjectNodeIds
Node getSubjectNodeIds(Id subjectId, long ancestorLevels, long descendantLevels, boolean includeSiblings) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets a portion of the hierarchy for the given subject.- Parameters:
subjectId- theIdto queryancestorLevels- the maximum number of ancestor levels to include. A value of 0 returns no parents in the node.descendantLevels- the maximum number of descendant levels to include. A value of 0 returns no children in the node.includeSiblings-trueto include the siblings of the given node,falseto omit the siblings- Returns:
- a subject node
- Throws:
NotFoundException-subjectIdis not foundNullArgumentException-subjectIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
getSubjectNodes
SubjectNode getSubjectNodes(Id subjectId, long ancestorLevels, long descendantLevels, boolean includeSiblings) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets a portion of the hierarchy for the given subject.- Parameters:
subjectId- theIdto queryancestorLevels- the maximum number of ancestor levels to include. A value of 0 returns no parents in the node.descendantLevels- the maximum number of descendant levels to include. A value of 0 returns no children in the node.includeSiblings-trueto include the siblings of the given node,falseto omit the siblings- Returns:
- a subject node
- Throws:
NotFoundException-subjectIdis not foundNullArgumentException-subjectIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-