public interface Topology extends Graph
getCIsByName(java.lang.String)
,
its properties and relations are defined by the node with the specified name.
When a CI is retrieved from the collection returned by getAllCIs()
, the CI
has all of the of the queried properties and connected relations of all instances of that CI.
Similarly, when a Relations relation is matched by more than one query link node, the
relation appears in this structure more than once.
When traversing the resulting graph with TopologyCI.getOutgoingRelations()
and TopologyCI.getIncomingRelations()
, the relations are consistent with the connected CIs.
If the CI is taken from a node, the relation will be the one connected to that node.
When the CI is taken from the collection of all CIs, it is associated with all the relations
to which the CI is connected from all nodes.
Examples:
List all hosts in UCMDB:
QueryDefinition queryDefinition = factory.createQueryDefinition("Get all hosts"); queryDefinition.addNode("Hosts").ofType("host").queryProperty("host_dnsname"); Topology topology = topologyQueryService.executeQuery(queryDefinition); for (TopologyCI host : topology.getAllCIs()) { System.out.println("Host key:" + host.getPropertyValue("host_dnsname"); }List all hosts with their contained resources
QueryDefinition queryDefinition = factory.createQueryDefinition("Get hosts' resources"); String hostsNodeName = "Hosts"; QueryNode hostsNode = queryDefinition.addNode(cisNodeName).ofType("host"); QueryNode resourcesNode = queryDefinition.addNode("Resources").ofType("hostresource").queryKeyProperties(); hostsNode.linkedTo(resourcesNode).withLinkOfType("composition"); Topology topology = topologyQueryService.executeQuery(queryDefinition); for (TopologyCI host : topology.getCIsByName(hostsNodeName)) { System.out.println("Host:"); printElement(host); for (Relation relation : host.getOutgoingRelations()) { System.out.println("\tResource:"); printElement(relation.getEnd2CI(), "\t"); } }
Modifier and Type | Method and Description |
---|---|
Collection<TopologyCI> |
getAllCIs()
Returns the collection of all CIs in this result.
|
Map<UcmdbId,TopologyCI> |
getAllCIsAsMap()
Returns the CIs in this result as a map from ID to CI.
|
Collection<TopologyRelation> |
getAllRelations()
Returns the collection of all Relations in this result.
|
TopologyCI |
getCI(UcmdbId id)
Returns the CI from this result having the specified ID.
|
Collection<TopologyCI> |
getCIsByName(String nodeName)
Returns the CIs associated with the specified node.
|
Map<UcmdbId,TopologyCI> |
getCIsByNameAsMap(String nodeName)
Returns the map of the CIs associated with the specified node.
|
Set<String> |
getContainingNodes(UcmdbId id)
Returns the node names associated with the id.
|
Map<UcmdbId,Set<String>> |
getContainingNodesMap()
Returns a map of IDs to their associated node names.
|
Topology |
getNextChunk()
Returns the next partial result of a query result.
|
QueryResultVersion |
getQueryResultVersion()
The version of this topology.
|
TopologyRelation |
getRelation(UcmdbId ucmdbId)
Returns the Relation from this result having the specified ID.
|
Collection<TopologyRelation> |
getRelationsByName(String linkName)
Returns the CIs associated with the specified link.
|
Map<UcmdbId,TopologyRelation> |
getRelationsByNameAsMap(String linkName)
Returns the map of the CIs associated with the specified link.
|
boolean |
hasNextChunk()
Indicates whether more topologies must be retrieved to complete a query result.
|
boolean |
isEmpty()
Returns true if the topology is empty.
|
void |
makeThreadSafe()
Call this method to make the internal topology structure safe to access by multiple threads.
|
boolean |
querySupportsHasChanges()
Returns true if the query that generated this topology supports the "has changes" question.
|
getAllRelationsAsMap
Collection<TopologyCI> getCIsByName(String nodeName)
Map<UcmdbId,TopologyCI> getCIsByNameAsMap(String nodeName)
Collection<TopologyRelation> getRelationsByName(String linkName)
Map<UcmdbId,TopologyRelation> getRelationsByNameAsMap(String linkName)
Collection<TopologyCI> getAllCIs()
Map<UcmdbId,TopologyCI> getAllCIsAsMap()
getAllCIsAsMap
in interface Graph
getAllCIs()
TopologyCI getCI(UcmdbId id)
getAllCIs()
. If no CI with the specified ID if
found in the collection, getCI
returns null.TopologyRelation getRelation(UcmdbId ucmdbId)
getAllRelations()
. If no Relation with the specified ID if
found in the collection, getRelation
returns null.getRelation
in interface Graph
Collection<TopologyRelation> getAllRelations()
getAllRelations
in interface Graph
Set<String> getContainingNodes(UcmdbId id)
Map<UcmdbId,Set<String>> getContainingNodesMap()
boolean hasNextChunk()
Topology getNextChunk()
Topology topology = ... //get initial topology
//process initial topology
while (topology.hasNextChunk()) {
topology = topology.getNextChunk();
//process topology chunk
}
Please note that calling "getNextChunk()" on a Topology object twice might result in an exception.@NotFinalAPI QueryResultVersion getQueryResultVersion()
boolean isEmpty()
getAllCIs().isEmpty() && getAllRelations().isEmpty()
@NotFinalAPI boolean querySupportsHasChanges()
QueryDefinitionRecalcPriority.NOT_ACTIVE
)
TopologyQueryService.hasChanges
method with the query name and the query result version attached to this topology.TopologyQueryService.hasChanges(java.lang.String, com.hp.ucmdb.api.topology.QueryResultVersion)
void makeThreadSafe()
Documentation Feedback
Copyright 2011 - 2018 Micro Focus or one of its affiliates.