Package com.hp.ucmdb.api.topology
Interface QueryLink<QL extends QueryLink<QL>>
- Type Parameters:
QL
- The query link actual interface type, used for method chaining.
- All Superinterfaces:
SupportsInvisibility<QueryLink<QL>>
- All Known Subinterfaces:
DirectLink
,IndirectLink
,OnPropertiesLink
A link in the query definition.
A link in the query definition may add to the result, be used to constraint the result or both.
A link has:
A link has:
- A name, which has a default value (see
name()
). - Two important designated nodes: "
source
" and "target
" ("from" and "to"). These designations may refer to different nodes on the query definition, or may refer to the same node (self link). Invisibility status
- an invisible link acts only as a condition on its connected nodes, while a visible link both acts as a condition and enriches the result with (one or more)Relations
.
It is meaningless to define an invisible link with minimum cardinality of 0 and unbounded maximum cardinality (UNBOUNDED
), since that link will not restrict any adjacent query node.
expression trees
- the source node expression tree and the target node
expression tree.
By default, a link is added with an "and" condition to the top of both expression trees, with cardinality
1..* (unbounded), which is the same as saying:
"A CI is valid as a result of the source node only if there is at least one outgoing link between it and a CI
matching the target node. A CI is valid as a result of the target node only if there is at least one incoming link
between it and a CI matching the source node."
- Using broad range cardinality-setters (from this interface), which effect all the instances of the link in the relevant node expression tree.
- Writing an explicit expression tree using and
setting it
to the node. Using this method allows for complex logical expressions, with multiple instances of each query link and different cardinality settings for each of these instances.
- Since:
- UCMDB 9.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Represents an unbounded cardinality value. -
Method Summary
Modifier and TypeMethodDescriptionReturns this object as a DirectLink.Returns this object as an IndirectLink.Returns this object as an OnPropertiesLink.atLeast
(int minSourceCardinality) Replaces the minimum cardinality of all instances of this query link in the source expression tree with the new values.atMost
(int maxSourceCardinality) Replaces the maximum cardinality of all instances of this query link in the source expression tree with the new value.exactly
(int sourceCardinality) Replaces the minimum cardinality of all instances of this query link in the source expression tree with the new value.Deprecated.Deprecated.usetargetNode()
.name()
The name of this link in the query definition it belongs to.The link type.Sets the self link filter to "restrict to self links" mode.Returns the self link filter.setSelfLinkFilter
(SelfLinkFilter selfLinkMode) Sets the self link filter.int
Returns the maximum of all of the maximum cardinalities set for this query link in the source expression tree.int
Returns the minimum of all of the minimum cardinalities set for this query link in the source expression tree.Returns the node the link of this link comes from.int
Returns the maximum of all of the maximum cardinalities set for this query link in the target expression tree.int
Returns the minimum of all of the minimum cardinalities set for this query link in the target expression tree.Returns the node the link of this link goes to.withElementNumber
(Integer elementNumber) Sets the name of this link.
Setting the name does not change any bind-by-name resource (non-query definition resources) to match the new name.
Changing the name changes the#hashCode
of this object.Sets the self link filter to "restrict to non-self links" mode.withSourceCardinality
(int minimumCardinality, int maximumCardinality) Replaces the cardinality of all instances of this query link in the source expression tree with the new values.withTargetCardinality
(int minimumCardinality, int maximumCardinality) Replaces the cardinality of all the instances of this query link in the target expression tree with the new values.Methods inherited from interface com.hp.ucmdb.api.topology.SupportsInvisibility
invisible, isInvisible
-
Field Details
-
UNBOUNDED
static final int UNBOUNDEDRepresents an unbounded cardinality value.- See Also:
-
-
Method Details
-
name
String name()The name of this link in the query definition it belongs to.- See Also:
-
withName
Sets the name of this link.
Setting the name does not change any bind-by-name resource (non-query definition resources) to match the new name.
Changing the name changes the#hashCode
of this object.- Returns:
- this object. The returned object can be used for method chaining.
- See Also:
-
withElementNumber
-
elementNumber
Integer elementNumber() -
getFromNode
Deprecated.usesourceNode()
.Returns the node the link of this link comes from. -
sourceNode
QueryNode sourceNode()Returns the node the link of this link comes from. -
getToNode
Deprecated.usetargetNode()
.Returns the node the link of this link goes to. -
targetNode
QueryNode targetNode()Returns the node the link of this link goes to. -
withSourceCardinality
Replaces the cardinality of all instances of this query link in the source expression tree with the new values.- Parameters:
minimumCardinality
- the minimum number of links.maximumCardinality
- the maximum number of links.- Returns:
- this object. The returned object can be used for method chaining.
-
withTargetCardinality
Replaces the cardinality of all the instances of this query link in the target expression tree with the new values.- Parameters:
minimumCardinality
- the minimum number of links.maximumCardinality
- the maximum number of links.- Returns:
- this object. The returned object can be used for method chaining.
-
sourceMinCardinality
int sourceMinCardinality()Returns the minimum of all of the minimum cardinalities set for this query link in the source expression tree. -
sourceMaxCardinality
int sourceMaxCardinality()Returns the maximum of all of the maximum cardinalities set for this query link in the source expression tree. -
targetMinCardinality
int targetMinCardinality()Returns the minimum of all of the minimum cardinalities set for this query link in the target expression tree. -
targetMaxCardinality
int targetMaxCardinality()Returns the maximum of all of the maximum cardinalities set for this query link in the target expression tree. -
atLeast
Replaces the minimum cardinality of all instances of this query link in the source expression tree with the new values. Equivalent to withSourceCardinality(minSourceCardinality, sourceMaxCardinality());- Parameters:
minSourceCardinality
- the minimum number of links.- Returns:
- this object. The returned object can be used for method chaining.
-
atMost
Replaces the maximum cardinality of all instances of this query link in the source expression tree with the new value. Equivalent to withSourceCardinality(sourceMinCardinality(), maxSourceCardinality);- Parameters:
maxSourceCardinality
- the maximum number of links.- Returns:
- this object. The returned object can be used for method chaining.
-
exactly
Replaces the minimum cardinality of all instances of this query link in the source expression tree with the new value. Equivalent to withSourceCardinality(sourceMinCardinality(), sourceMaxCardinality());- Parameters:
SourceCardinality
- the minimum number of links.- Returns:
- this object. The returned object can be used for method chaining.
-
queryLinkType
QueryLinkType queryLinkType()The link type.- Returns:
- the type of the link.
-
asDirectLink
Returns this object as a DirectLink.- Returns:
- this object as a DirectLink.
If
queryLinkType()
is notQueryLinkType.DIRECT_LINK
, a class cast exception is thrown. - Throws:
ClassCastException
-
asIndirectLink
Returns this object as an IndirectLink.- Returns:
- this object as an IndirectLink.
If
queryLinkType()
is notQueryLinkType.INDIRECT_LINK
, a class cast exception is thrown. - Throws:
ClassCastException
-
asOnPropertiesLink
Returns this object as an OnPropertiesLink.- Returns:
- this object as an OnPropertiesLink.
If
queryLinkType()
is notQueryLinkType.ON_PROPERTIES_LINK
, a class cast exception is thrown. - Throws:
ClassCastException
-
restrictToSelfLinks
QL restrictToSelfLinks()Sets the self link filter to "restrict to self links" mode. Calling this method restricts links answering this QueryLink to have the same CI as both source and target. The CI can come from different QueryNodes, but its ID must be the same.- Returns:
- this object. The returned object can be used for method chaining.
-
withoutSelfLinks
QL withoutSelfLinks()Sets the self link filter to "restrict to non-self links" mode. Calling this method restricts links answering this QueryLink to links that do not have the same CI as both source and target. Links that start and end with the same CI, even if from different QueryNodes, will be omitted from the result of this QueryLink.- Returns:
- this object. The returned object can be used for method chaining.
-
setSelfLinkFilter
Sets the self link filter. The self link filter may, if set, filter self-links (identical source and target) or filter non-self links (different source and target).- Returns:
- this object. The returned object can be used for method chaining.
-
selfLinkFilter
SelfLinkFilter selfLinkFilter()Returns the self link filter.- Returns:
- the self link filter.
- See Also:
-
sourceNode()
.