|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface TopologyQueryService
Interface for querying the UCMDB topology.
To create the data structures used by the methods of this interface,
use the factory obtained with the getFactory()
method.
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")); } }
Method Summary | |
---|---|
ExecutableQuery |
createExecutableQuery(java.lang.String queryName)
Creates an ExecutableQuery structure. |
Query |
createQueryStub(java.lang.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(java.lang.String queryName)
Executes the query of the specified name and return its result count. |
TopologyCountByClasses |
evaluateNamedQueryWithClassesBreakdown(java.lang.String queryName,
java.util.Collection<java.lang.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,
java.util.Collection<java.lang.String> elementNamesToCount)
Executes a query stored on the server and returns the result count break-down by classes. |
TopologyCountByClasses |
evaluateQueryWithClassesBreakdown(QueryDefinition queryDefinition,
java.util.Collection<java.lang.String> elementNamesToCount)
Executes a query defined on the client and return its result count break-down by classes. |
Topology |
executeNamedQuery(java.lang.String queryName)
Executes the query of the specified name. |
Topology |
executeNamedQueryInBDMScope(java.lang.String queryName)
Executes the query of the specified name within the BDM scope. |
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(java.lang.String queryName)
Returns a query whose result is always kept updated on server side. |
java.util.Set<java.lang.String> |
hasChanges(java.util.Map<java.lang.String,QueryResultVersion> queries2check)
Same as hasChanges(String, QueryResultVersion) , but is passed a collection of queries and their version
to check for changes |
boolean |
hasChanges(java.lang.String queryName,
QueryResultVersion queryResultVersion)
Checks if the results of the query were changed since the result version was created. |
boolean |
hasChanges(java.lang.String queryName,
java.lang.String queryResultVersionAsString)
Same as hasChanges(String, QueryResultVersion) , but is passed the result of {QueryResultVersion#asString()}. |
java.lang.String |
queryDefinitionToString(QueryDefinition queryDefinition)
Returns the query's string representation. |
java.lang.String |
queryReferenceDefinitionToString(QueryReferenceDefinition queryReferenceDefinition)
Returns the query refernce's string representation. |
void |
registerModelListener(ModelListener listener)
Deprecated. replaced by registerModelListener(ModelListener listener, ModelEventsFilter filter) |
java.lang.String |
registerModelListener(ModelListener listener,
ModelEventsFilter filter)
Registers a listener to be called when the model stored on the UCMDB server changes. |
java.lang.String |
registerModelListener(ModelListener listener,
ModelListenerFilter filter)
Deprecated. replaced by registerModelListener(ModelListener listener, ModelEventsFilter filter) |
void |
registerQueryResultListener(QueryResultListener listener,
java.lang.String queryName)
Registers a listener to be called when the result of the specified server-side query changes. |
CisFromCachedQueryResults |
retrieveCiIdsFromCachedQueryResults(java.util.Collection<UcmdbId> ids,
java.util.Set<java.lang.String> queryNames)
Searches for each of the given CI IDs in the cached results of the queries given. |
CIsChunk |
retrieveCIsSortedChunk(ExecutableQuery executableQuery,
java.lang.String nodeName,
java.util.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,
java.lang.String nodeName,
java.util.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,
java.lang.String nodeName,
java.util.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,
java.lang.String nodeName,
java.util.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,
java.util.Set<IndirectLinkDescriptor> indirectLinkDescriptors)
Retrieves the indirect link internal paths for the given descriptors. |
Query |
stringToInitializedQuery(java.lang.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(java.lang.String str)
Returns a copy of the original query definition used to create the string. |
void |
unregisterModelListener(java.lang.String listenerId)
Unregisters the specified model listener. |
void |
unregisterQueryResultListener(QueryResultListener listener,
java.lang.String queryName)
Unregisters the specified listener. |
void |
updateFilteredModelListener(java.lang.String listenerId,
ModelEventsFilter filter)
Updates model listener filter definition. |
void |
updateFilteredModelListener(java.lang.String listenerId,
ModelListenerFilter filter)
Deprecated. replaced by updateFilteredModelListener(String listenerId, ModelEventsFilter filter) |
boolean |
validateBDMQuery(QueryDefinition queryDefinition)
Checks if the query definition is BDM compliant. |
Method Detail |
---|
Query createQueryStub(java.lang.String queryName)
Query
for details.
ExecutableQuery createExecutableQuery(java.lang.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(java.lang.String queryName) throws UcmdbException
topologyQueryService.executeQuery(topologyQueryFactory.createNamedQuery(queryName).toExecutable());
UcmdbException
boolean validateBDMQuery(QueryDefinition queryDefinition) throws UcmdbException
queryDefinition
- the query definition.
UcmdbException
Topology executeNamedQueryInBDMScope(java.lang.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(java.lang.String queryName) throws UcmdbException
queryName
- The name of a query that is stored on the server
UcmdbException
@NotFinalAPI TopologyCountByClasses evaluateQueryWithClassesBreakdown(ExecutableQuery query, java.util.Collection<java.lang.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, java.util.Collection<java.lang.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(java.lang.String queryName, java.util.Collection<java.lang.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(java.lang.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, java.lang.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, java.lang.String queryName) throws UcmdbException
listener
- client-side implementation of the listener interface
UcmdbException
void registerModelListener(ModelListener listener) throws UcmdbException
registerModelListener(ModelListener listener, ModelEventsFilter filter)
listener
- client-side implementation of the listener interface
UcmdbException
@NotFinalAPI java.lang.String registerModelListener(ModelListener listener, ModelEventsFilter filter) throws UcmdbException
listener
- client-side implementation of the listener interfacefilter
- definition
UcmdbException
@NotFinalAPI java.lang.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(java.lang.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(java.lang.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(java.lang.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, java.lang.String nodeName, java.util.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, java.lang.String nodeName, java.util.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, java.lang.String nodeName, java.util.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, java.lang.String nodeName, java.util.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(java.util.Collection<UcmdbId> ids, java.util.Set<java.lang.String> queryNames)
ids
- CI IDs. Do not pass relation IDs.queryNames
- queries to search in
CisFromCachedQueryResults
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.
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(java.lang.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(java.lang.String queryName, java.lang.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 java.util.Set<java.lang.String> hasChanges(java.util.Map<java.lang.String,QueryResultVersion> queries2check)
hasChanges(String, QueryResultVersion)
, but is passed a collection of queries and their version
to check for changes
queries2check
- a collection of (query name, query result version) pairs
hasChanges(String, QueryResultVersion)
@NotFinalAPI Topology retrieveIndirectLinkPaths(ExecutableQuery executableQuery, java.util.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()
.
java.lang.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 string
UcmdbException
QueryDefinition stringToQueryDefinition(java.lang.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 represntation
UcmdbException
java.lang.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 convert
Query stringToInitializedQuery(java.lang.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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |