public interface TopologyQueryService
getFactory()
method.
Here is an example of executing an ad-hoc query and displaying the results:
TopologyQueryService queryService = ucmdbService.getTopologyQueryService(); TopologyQueryFactory queryFactory = queryService.getFactory(); QueryDefinition queryDefinition = queryFactory.createQueryDefinition("Get hosts with more than one network interface"); String hostNodeName = "Host"; QueryNode hostNode = queryDefinition.addNode(hostNodeName).ofType("host").queryProperty("display_label"); QueryNode ipNode = queryDefinition.addNode("IP").ofType("ip").queryProperty("ip_address"); hostNode.linkedTo(ipNode).withLinkOfType("contained").atLeast(2); Topology topology = queryService.executeQuery(queryDefinition); Collectionhosts = topology.getCIsByName(hostNodeName); for (TopologyCI host : hosts) { System.out.println("Host " + host.getPropertyValue("display_label")); for (TopologyRelation relation : host.getOutgoingRelations()) { System.out.println(" has IP " + relation.getEnd2CI().getPropertyValue("ip_address")); } }
Modifier and Type | Method and Description |
---|---|
ExecutableQuery |
createExecutableQuery(String queryName)
Creates an
ExecutableQuery structure. |
Query |
createQueryStub(String queryName)
Creates a Query stub that holds the query name and allows retrieval of the query definition
(or reference definition, if applicable).
|
TopologyCount |
evaluateNamedQuery(String queryName)
Executes the query of the specified name and return its result count.
|
TopologyCountByClasses |
evaluateNamedQueryWithClassesBreakdown(String queryName,
Collection<String> elementNamesToCount)
Executes the query of the specified name and return its result count break-down by classes.
|
TopologyCount |
evaluateQuery(ExecutableQuery query)
Executes a query stored on the server and returns the result count.
|
TopologyCount |
evaluateQuery(QueryDefinition queryDefinition)
Executes a query defined on the client and returns its result count.
|
TopologyCountByClasses |
evaluateQueryWithClassesBreakdown(ExecutableQuery query,
Collection<String> elementNamesToCount)
Executes a query stored on the server and returns the result count break-down by classes.
|
TopologyCountByClasses |
evaluateQueryWithClassesBreakdown(QueryDefinition queryDefinition,
Collection<String> elementNamesToCount)
Executes a query defined on the client and return its result count break-down by classes.
|
Topology |
executeNamedQuery(String queryName)
Executes the query of the specified name.
|
Topology |
executeNamedQueryInBDMScope(String queryName)
Executes the query of the specified name within the BDM scope.
|
Topology |
executeQueriesTree(QueriesExecutionBulk queriesExecutionBulk)
Executes tree of queries, returning the top-most query result.
|
Topology |
executeQuery(ExecutableQuery query)
Executes a query stored on the server and returns the result.
|
Topology |
executeQuery(QueryDefinition queryDefinition)
Executes a query defined on the client.
|
Topology |
executeQueryInBDMScope(ExecutableQuery query)
Executes a query that is stored on the server, within the BDM scope, and returns the result.
|
TopologyQueryFactory |
getFactory()
Returns the query factory.
|
LiveQuery |
getLiveQuery(String queryName)
Returns a query whose result is always kept updated on server side.
|
Set<String> |
hasChanges(Map<String,QueryResultVersion> queries2check)
Same as
hasChanges(String, QueryResultVersion) , but is passed a collection of queries and their version
to check for changes |
boolean |
hasChanges(String queryName,
QueryResultVersion queryResultVersion)
Checks if the results of the query were changed since the result version was created.
|
boolean |
hasChanges(String queryName,
String queryResultVersionAsString)
Same as
hasChanges(String, QueryResultVersion) , but is passed the result of {QueryResultVersion#asString()}. |
boolean |
isActiveQueryInFailedState(String queryName)
Checks if the given query is defined ACTIVE in UCMDB and is currently in FAILED state.
|
String |
queryDefinitionToString(QueryDefinition queryDefinition)
Returns the query's string representation.
|
String |
queryReferenceDefinitionToString(QueryReferenceDefinition queryReferenceDefinition)
Returns the query refernce's string representation.
|
void |
registerModelListener(ModelListener listener)
Deprecated.
|
String |
registerModelListener(ModelListener listener,
ModelEventsFilter filter)
Registers a listener to be called when the model stored on the UCMDB server changes.
|
String |
registerModelListener(ModelListener listener,
ModelEventsFilter filter,
NotificationListenerFuse fuse)
Registers a listener to be called when the model stored on the UCMDB server changes.
|
String |
registerModelListener(ModelListener listener,
ModelListenerFilter filter)
Deprecated.
|
String |
registerQueryPassivationListener(QueryPassivationListener listener,
String queryName) |
void |
registerQueryResultListener(QueryResultListener listener,
String queryName)
Registers a listener to be called when the result of the specified server-side query changes.
|
CisFromCachedQueryResults |
retrieveCiIdsFromCachedQueryResults(Collection<UcmdbId> ids,
Set<String> queryNames)
Searches for each of the given CI IDs in the cached results of the queries given.
|
CIsChunk |
retrieveCIsSortedChunk(ExecutableQuery executableQuery,
String nodeName,
List<AttributeSortingRule> attributeSortingRules)
Executes the executable query and returns the CIs matching the node name, sorted by the specified sorting rules.
|
CIsChunk |
retrieveCIsSortedChunk(ExecutableQuery executableQuery,
String nodeName,
List<AttributeSortingRule> attributeSortingRules,
int chunkIndex)
Executes the given executable query and returns 'nth chunk of CIs matching the node name,
sorted by the given sorting rules.
|
CIsChunk |
retrieveCIsSortedChunkInBDMScope(ExecutableQuery executableQuery,
String nodeName,
List<AttributeSortingRule> attributeSortingRules)
Executes the executable query within the BDM scope and returns the CIs matching the node name, sorted by the specified sorting rules.
|
CIsChunk |
retrieveCIsSortedChunkInBDMScope(ExecutableQuery executableQuery,
String nodeName,
List<AttributeSortingRule> attributeSortingRules,
int chunkIndex)
Executes the given executable query within the BDM scope and returns 'nth chunk of CIs matching the node name,
sorted by the given sorting rules.
|
ElementIdsForChangedCachedQueries |
retrieveElementIdsForChangedCachedQueries(QueryNamesAndVersions queryNamesAndVersions,
ElementIdsForChangedCachedQueriesOptions options)
Checks the results of each of the given queries in the queryNamesAndVersions and, if they're cached and updated,
returns that result (as ids only).
|
Topology |
retrieveIndirectLinkPaths(ExecutableQuery executableQuery,
Set<IndirectLinkDescriptor> indirectLinkDescriptors)
Retrieves the indirect link internal paths for the given descriptors.
|
Query |
stringToInitializedQuery(String str)
Returns an initialized
Query that holds a copy of the original query or query reference
definition used to create the string. |
QueryDefinition |
stringToQueryDefinition(String str)
Returns a copy of the original query definition used to create the string.
|
void |
unregisterModelListener(String listenerId)
Unregisters the specified model listener.
|
void |
unregisterQueryPassivationListener(String listenerId) |
void |
unregisterQueryResultListener(QueryResultListener listener,
String queryName)
Unregisters the specified listener.
|
void |
updateFilteredModelListener(String listenerId,
ModelEventsFilter filter)
Updates model listener filter definition.
|
void |
updateFilteredModelListener(String listenerId,
ModelListenerFilter filter)
Deprecated.
|
boolean |
validateBDMQuery(QueryDefinition queryDefinition)
Checks if the query definition is BDM compliant.
|
Query createQueryStub(String queryName)
Query
for details.ExecutableQuery createExecutableQuery(String queryName)
ExecutableQuery
structure. The ExecutableQuery can be used to define customizations over a
query execution, such as parameters values, restrictions, seperation to chunks, and so on.
It is possible to create an ExecutableQuery stubs for non-existant queries, but furthur execute operations will fail.
This method does not communicate with the UCMDB server.TopologyQueryFactory getFactory()
Topology executeQuery(QueryDefinition queryDefinition) throws UcmdbException
queryDefinition
- the query to execute.UcmdbException
Topology executeNamedQuery(String queryName) throws UcmdbException
topologyQueryService.executeQuery(topologyQueryFactory.createNamedQuery(queryName).toExecutable());
UcmdbException
boolean validateBDMQuery(QueryDefinition queryDefinition) throws UcmdbException
queryDefinition
- the query definition.UcmdbException
Topology executeNamedQueryInBDMScope(String queryName) throws UcmdbException
UcmdbException
Topology executeQuery(ExecutableQuery query) throws UcmdbException
UcmdbException
Topology executeQueryInBDMScope(ExecutableQuery query) throws UcmdbException
UcmdbException
ExecutableQuery
TopologyCount evaluateQuery(QueryDefinition queryDefinition) throws UcmdbException
UcmdbException
TopologyCount evaluateNamedQuery(String queryName) throws UcmdbException
queryName
- The name of a query that is stored on the serverUcmdbException
@NotFinalAPI TopologyCountByClasses evaluateQueryWithClassesBreakdown(ExecutableQuery query, Collection<String> elementNamesToCount) throws UcmdbException
query
- the query definition.elementNamesToCount
- the element names to count. If empty or null, counts all elements.UcmdbException
@NotFinalAPI TopologyCountByClasses evaluateQueryWithClassesBreakdown(QueryDefinition queryDefinition, Collection<String> elementNamesToCount) throws UcmdbException
queryDefinition
- the query definition.elementNamesToCount
- the element names to count. If empty or null, counts all elements.UcmdbException
@NotFinalAPI TopologyCountByClasses evaluateNamedQueryWithClassesBreakdown(String queryName, Collection<String> elementNamesToCount) throws UcmdbException
queryName
- The name of a query that is stored on the serverelementNamesToCount
- the element names to count. If empty or null, counts all elements.UcmdbException
TopologyCount evaluateQuery(ExecutableQuery query) throws UcmdbException
UcmdbException
LiveQuery getLiveQuery(String queryName)
queryName
- the name of the query. A query with this name must exist in the UCMDB and must be active.LiveQuery
void registerQueryResultListener(QueryResultListener listener, String queryName) throws UcmdbException
listener
- client-side implementation of the listener interface.queryName
- name of an active query stored at the server.UcmdbException
void unregisterQueryResultListener(QueryResultListener listener, String queryName) throws UcmdbException
listener
- client-side implementation of the listener interfaceUcmdbException
String registerQueryPassivationListener(QueryPassivationListener listener, String queryName)
void unregisterQueryPassivationListener(String listenerId)
void registerModelListener(ModelListener listener) throws UcmdbException
registerModelListener(ModelListener listener, ModelEventsFilter filter)
listener
- client-side implementation of the listener interfaceUcmdbException
@NotFinalAPI String registerModelListener(ModelListener listener, ModelEventsFilter filter) throws UcmdbException
listener
- client-side implementation of the listener interfacefilter
- definitionUcmdbException
@NotFinalAPI String registerModelListener(ModelListener listener, ModelEventsFilter filter, NotificationListenerFuse fuse) throws UcmdbException
listener
- client-side implementation of the listener interfacefilter
- definitionfuse
- the notification queue size fuseUcmdbException
@NotFinalAPI String registerModelListener(ModelListener listener, ModelListenerFilter filter) throws UcmdbException
registerModelListener(ModelListener listener, ModelEventsFilter filter)
listener
- client-side implementation of the listener interfacefilter
- filter definition.UcmdbException
@NotFinalAPI void unregisterModelListener(String listenerId) throws UcmdbException
listenerId
- the listener id returned from
registerModelListener(com.hp.ucmdb.api.topology.notification.ModelListener, com.hp.ucmdb.api.topology.notification.ModelEventsFilter)
.UcmdbException
@NotFinalAPI void updateFilteredModelListener(String listenerId, ModelEventsFilter filter) throws UcmdbException
listenerId
- the listener id returned from registerModelListener(com.hp.ucmdb.api.topology.notification.ModelListener, com.hp.ucmdb.api.topology.notification.ModelEventsFilter)
filter
- the filter definition for update.UcmdbException
@NotFinalAPI void updateFilteredModelListener(String listenerId, ModelListenerFilter filter) throws UcmdbException
updateFilteredModelListener(String listenerId, ModelEventsFilter filter)
listenerId
- the listener id returned from registerModelListener(com.hp.ucmdb.api.topology.notification.ModelListener, com.hp.ucmdb.api.topology.notification.ModelEventsFilter)
filter
- the filter definition for update.UcmdbException
@NotFinalAPI CIsChunk retrieveCIsSortedChunk(ExecutableQuery executableQuery, String nodeName, List<AttributeSortingRule> attributeSortingRules)
ExecutableQuery.setMaxChunkSize(int)
, the result is divided
into chunks and only the first chunk is returned. The other chunks can be accessed by index using the
retrieveCIsSortedChunk(ExecutableQuery executableQuery, String nodeName, List attributeSortingRules, int chunkIndex)
method.
You can also use the more verbose method (taking the chunkIndex parameter) to access the first chunk.executableQuery
- the executable query to run.nodeName
- the node name to return the CIs for.
Resulting CIs from all other nodes are ignored.attributeSortingRules
- an ordered collection of the sorting rules.@NotFinalAPI CIsChunk retrieveCIsSortedChunk(ExecutableQuery executableQuery, String nodeName, List<AttributeSortingRule> attributeSortingRules, int chunkIndex)
ExecutableQuery.setMaxChunkSize(int)
.
The first chunk has index of 0 (even if it's empty).
Passing an index out of range results in an empty chunk returned.executableQuery
- the executable query to run. May not be null.nodeName
- the node name to return the CIs for. Resulting CIs from all other nodes are ignored.
May not be null.attributeSortingRules
- an ordered collection of the sorting rules. May not be null, may be empty.
Rules can be created by
getFactory()
.TopologyQueryFactory.createAttributeSortingOrderElement(String, AttributeSortingOrderElementDirection)
chunkIndex
- the index of the chunk to retrieve. Must not be negative.@NotFinalAPI CIsChunk retrieveCIsSortedChunkInBDMScope(ExecutableQuery executableQuery, String nodeName, List<AttributeSortingRule> attributeSortingRules)
ExecutableQuery.setMaxChunkSize(int)
, the result is divided
into chunks and only the first one is returned. The other chunks can be accessed by index using the
retrieveCIsSortedChunk(ExecutableQuery executableQuery, String nodeName, List attributeSortingRules, int chunkIndex)
method.
You can also use the more verbose method (taking the chunkIndex parameter) to access the first chunk.executableQuery
- the executable query to run.nodeName
- the node name to return the CIs for.
Resulting CIs from all other nodes are ignored.attributeSortingRules
- an ordered collection of the sorting rules.@NotFinalAPI CIsChunk retrieveCIsSortedChunkInBDMScope(ExecutableQuery executableQuery, String nodeName, List<AttributeSortingRule> attributeSortingRules, int chunkIndex)
ExecutableQuery.setMaxChunkSize(int)
.
The first chunk has index of 0 (even if it's empty).
Passing an index out of range results in an empty chunk returned.executableQuery
- the executable query to run. May not be null.nodeName
- the node name to return the CIs for. Resulting CIs from all other nodes are ignored.
May not be null.attributeSortingRules
- an ordered collection of the sorting rules. May not be null, may be empty.
Rules can be created by
getFactory()
.TopologyQueryFactory.createAttributeSortingOrderElement(String, AttributeSortingOrderElementDirection)
chunkIndex
- the index of the chunk to retrieve. Must not be negative.CisFromCachedQueryResults retrieveCiIdsFromCachedQueryResults(Collection<UcmdbId> ids, Set<String> queryNames)
ids
- CI IDs. Do not pass relation IDs.queryNames
- queries to search inCisFromCachedQueryResults
with a map of UcmdbId to query names and a set of non-cached query names.@NotFinalAPI ElementIdsForChangedCachedQueries retrieveElementIdsForChangedCachedQueries(QueryNamesAndVersions queryNamesAndVersions, ElementIdsForChangedCachedQueriesOptions options)
QueryDefinitionFirstLoadStrategy.LOAD_ON_SERVER_START
or active and executed before.
Only updated (or forced) query results are returned. Each of these is returned as an id collection only.
In addition, the result version is returned as well - that version should be supplied to a later invocation
of this method to allow only the updated results to be returned.
Note: Like all active queries, an updated result may be during to topological change, definition change or properties
change. In addition, a false update may occur (rare case) as well.
Additional Note: If a query was defined active, but was set not to keep result in repository - the ids collection
will be returned empty, even if the query was updated or enforced to be check.queryNamesAndVersions
- the query names and matching versions to check (or query names to return results for,
regardless of versions).options
- an options object - determines the behavior of the service (e.g. are relation ids returned as well?)@NotFinalAPI boolean hasChanges(String queryName, QueryResultVersion queryResultVersion)
QueryDefinition.recalcPriority()
or
QueryReferenceDefinition.recalcPriority()
), it is also possible to query the resulting Topology
using the Topology.querySupportsHasChanges()
method.
This method does not take into account the properties of CIs and Relations that do not participate in the
query properties conditions.
Implementation notes:
queryName
- the query to check.queryResultVersion
- the version to check changes from.@NotFinalAPI boolean hasChanges(String queryName, String queryResultVersionAsString)
hasChanges(String, QueryResultVersion)
, but is passed the result of {QueryResultVersion#asString()}.queryName
- the query to check.queryResultVersionAsString
- the asString() result of the version to check changes from.hasChanges(String, QueryResultVersion)
@NotFinalAPI Set<String> hasChanges(Map<String,QueryResultVersion> queries2check)
hasChanges(String, QueryResultVersion)
, but is passed a collection of queries and their version
to check for changesqueries2check
- a collection of (query name, query result version) pairshasChanges(String, QueryResultVersion)
@NotFinalAPI Topology retrieveIndirectLinkPaths(ExecutableQuery executableQuery, Set<IndirectLinkDescriptor> indirectLinkDescriptors)
executableQuery
- the executable query that originated the topology from which the indirect link paths are
requried.indirectLinkDescriptors
- the descriptors, created by
TopologyQueryFactory.createIndirectLinkDescriptor()
.String queryDefinitionToString(QueryDefinition queryDefinition) throws UcmdbException
QueryDefinition
to string is done in the
server, requiring a server request.
This string representation may not be version compatible and should not be serialized
for long term storage.queryDefinition
- the query definition to convert to a stringUcmdbException
QueryDefinition stringToQueryDefinition(String str) throws UcmdbException
queryDefinitionToString
.
The conversion from string to QueryDefinition
is done
on the server, requiring a server request.str
- the query's string represntationUcmdbException
String queryReferenceDefinitionToString(QueryReferenceDefinition queryReferenceDefinition)
QueryReferenceDefinition
to string is done on the
server, requiring a server request.
This string representation may not be version compatible and should not be serialized
for long term storage.queryReferenceDefinition
- - the query reference definition to convertQuery stringToInitializedQuery(String str)
Query
that holds a copy of the original query or query reference
definition used to create the string.
The input string is created by a call to
queryReferenceDefinitionToString
or
queryDefinitionToString
The conversion is done on the server, requiring a server request.
Note2: Unlike the general contract for Query, the return value from this method does NOT represent a query stored
on the CMDB server.str
- - query's string representation@NotFinalAPI Topology executeQueriesTree(QueriesExecutionBulk queriesExecutionBulk)
queriesExecutionBulk
- a bulk of query definitions that is resolvable to a tree (dependency-wise) with the aid
of already saved queries.@NotFinalAPI boolean isActiveQueryInFailedState(String queryName) throws UcmdbException
queryName
- the query name.UcmdbException
- If the Query is not defined in UCMDB, or if it not defined ACTIVE Documentation Feedback
Copyright 2011 - 2018 Micro Focus or one of its affiliates.