Package com.hp.ucmdb.api.topology
Interface ExecutableQuery
- All Superinterfaces:
ContactNodeRestrictions<ExecutableQuery>
,DataStoresConditionable<ExecutableQuery>
,PropertiesCarrier<ExecutableQuery>
public interface ExecutableQuery
extends PropertiesCarrier<ExecutableQuery>, DataStoresConditionable<ExecutableQuery>, ContactNodeRestrictions<ExecutableQuery>
Represents a server-side query suitable for execution. Enables modifying the execution
environment.
For example, enables changing the set of objects the query runs on, specifying
parameters, additional restrictions and so on.
Changes made on this interface are never saved to the UCMDB and exist only in the execution context.
Methods from the
PropertiesCarrier
interface: Using any of the PropertiesCarrier
methods on this object cancels all PropertiesCarrier definitions made on the original
query definition.
Methods from the DataStoresConditionable
interface: Using any of the
DataStoresConditionable methods on this object cancels all DataStoresConditionable
definitions made on the original query definition.
Methods from the ContactNodeRestrictions
interface: Using any of the C
ontactNodeRestrictions methods on this object cancels all ContactNodeRestrictions
definitions made on the original query reference definition.
1. Examples of running a parameterized query:
Example 1.1: Running a parameterized query (single value parameter).
This example will set the value of condition matching the parameter name "MyParamName" to the string "MyValue".
The condition is assumed to be capable of handling strings, otherwise an error would occur.
Prerequisites: A query named "MyQuery" with a parameterized property condition named "MyParamName".
How to create a parameterized property condition can be seen in CompletePropertyCondition
.
Example code
ExecutableQuery executableQuery = toplogyQueryService.createExecutableQuery("MyQuery");
executableQuery.queryParameters().addValue("MyParamName", "MyValue");
Topology topology = toplogyQueryService.executeQuery(executableQuery);
//continue using the topology
Example 1.2: Running a parameterized query (range parameter).
This example will set the value of condition matching the parameter name "MyParamName" to the a range of values from 1 to 10.
The condition is assumed to be capable of handling integers, otherwise an error would occur.
Prerequisites: A query named "MyQuery" with a parameterized property condition named "MyParamName".
How to create a parameterized property condition can be seen in CompletePropertyCondition
.
Example code
ExecutableQuery executableQuery = toplogyQueryService.createExecutableQuery("MyQuery");
executableQuery.queryParameters().addValuesInRange("MyParamName", 1, 10);
Topology topology = toplogyQueryService.executeQuery(executableQuery);
//continue using the topology
Example 1.3: Running a parameterized query (Condition replacement).
This example will completely replace the original condition identified by parameter name "MyParamName".
The new condition is assumed to be valid for the query element it's grafted on, otherwise an error would occur.
Prerequisites: A query named "MyQuery" with a parameterized property condition named "MyParamName".
How to create a parameterized property condition can be seen in CompletePropertyCondition
.
Example code
ExecutableQuery executableQuery = toplogyQueryService.createExecutableQuery("MyQuery");
PropertyConditionBuilder builder = executableQuery.queryParameters().createConditionBuilder();
ConditionExpressionBuilder<CompletePropertyCondition, PropertiesConditionOperand> condition =
builder.use(builder.property("Prop1").isEqualTo("Value1"));
executableQuery.queryParameters().addConditionReplacement("MyParamName", condition);
Topology topology = topologyQueryService.executeQuery(executableQuery);
//continue using the topology
- Since:
- 8.0
-
Method Summary
Modifier and TypeMethodDescriptionnodePropertiesToQuery
(String nodeName) Deprecated.nodeRestrictions
(String nodeName) Returns the existing restrictions the specifed node so they can be added to and modified.onTopOfQuery
(String parentQueryName) Sets this query to run over the result of another query.Returns the map of node name to properties.propertiesToQueryPerNode
(String nodeName) Returns new or existing properties on a node so they can be added to and modified.Returns the QueryParameters interface.void
setBooleanParameter
(String parameterName, boolean parameterValue) Deprecated.use queryParameters.void
setBytesParameter
(String parameterName, byte[] parameterValue) Deprecated.void
setDateParameter
(String parameterName, Date parameterValue) Deprecated.void
setDoubleParameter
(String parameterName, double parameterValue) Deprecated.void
setFloatParameter
(String parameterName, float parameterValue) Deprecated.use queryParameters.Sets this executable query to be calculated without using the query results cache.void
setIntListParameter
(String parameterName, int[] parameterValue) Deprecated.void
setIntListParameter
(String parameterName, Iterable<Integer> parameterValue) Deprecated.void
setIntParameter
(String parameterName, int parameterValue) Deprecated.void
setLongParameter
(String parameterName, long parameterValue) Deprecated.void
setMaxChunkSize
(int maxChunkSize) Sets the limit for maximum elements returned per chunk in the query's result.void
setParameter
(String parameterName, Object parameterValue) Deprecated.use queryParameters.void
setStringListParameter
(String parameterName, Iterable<String> parameterValue) Deprecated.void
setStringListParameter
(String parameterName, String[] parameterValue) Deprecated.void
setStringParameter
(String parameterName, String parameterValue) Deprecated.withDataIntegrityRulesBundle
(String dataIntegrityRulesBundle) Methods inherited from interface com.hp.ucmdb.api.topology.ContactNodeRestrictions
queriesRestrictingContactNodes, restrictAllContactNodesByQueries, restrictAllContactNodesByQueries
Methods inherited from interface com.hp.ucmdb.api.topology.DataStoresConditionable
dataStores, isAllDataStores, isInternalDataStoreOnly, withAllDataStores, withDataStores, withDataStores, withInternalDataStoreOnly
Methods inherited from interface com.hp.ucmdb.api.topology.PropertiesCarrier
excludedProperties, excludeProperties, excludeProperty, getDefaultPropertiesToQuery, getPropertiesToQueryPerType, isPropertiesCarrierEmpty, propertiesCarrierBehavior, propertiesToQuery, queryKeyProperties, queryProperties, queryPropertiesWithQualifier, queryProperty, withPropertiesCarrierBehavior
-
Method Details
-
getQueryDefinition
QueryDefinition getQueryDefinition() -
onTopOfQuery
Sets this query to run over the result of another query. The scope of the query is not the whole universe but over the subset defined by the result of another query. UnlikeQueryDefinition.withBaseQueryName(java.lang.String)
, the parent query result does not have to be calculated before this can be executed.- Parameters:
parentQueryName
- the name of the query that specifies the "universe" for this query to run on- Returns:
- this object
- See Also:
-
nodeRestrictions
Returns the existing restrictions the specifed node so they can be added to and modified. If no restrictions object exists, a new one is created.- Parameters:
nodeName
- The node of which to return restrictions.- Returns:
- the restrictions of the specified node
-
nodePropertiesToQuery
Deprecated. -
propertiesToQueryPerNode
Returns new or existing properties on a node so they can be added to and modified.- Returns:
- the properties of the node query
-
propertiesToQueryPerNode
Map<String,PropertiesCarrierWrapper> propertiesToQueryPerNode()Returns the map of node name to properties. Will not return null, but may return empty map if no there was no previous invocation ofpropertiesToQueryPerNode(String)
. -
setMaxChunkSize
void setMaxChunkSize(int maxChunkSize) Sets the limit for maximum elements returned per chunk in the query's result. If the query's result is larger than this limit, the Topology returned must be asked quried to see if there are more chunks. If so, retrieve these chunks withTopology.getNextChunk()
. -
setForceAdhocCalculationFlag
ExecutableQuery setForceAdhocCalculationFlag()Sets this executable query to be calculated without using the query results cache. This trades processing time (for all of the uCMDB clients) for up-to-date results in saved queries. Non-active queries and non-saved queries are executed ad-hoc anyway. Note: some configurations mandates this anyway. -
queryParameters
Returns the QueryParameters interface. The QueryParameters allows setting values to named conditions or even replacing the named conditions altogether.- Returns:
- the QueryParameters associated with this ExecutableQuery.
-
withDataIntegrityRulesBundle
-
getDataIntegrityRulesBundle
-
setParameter
Deprecated.use queryParameters. -
setBooleanParameter
Deprecated.use queryParameters. -
setBytesParameter
Deprecated. -
setDateParameter
Deprecated. -
setDoubleParameter
Deprecated. -
setFloatParameter
Deprecated.use queryParameters. -
setIntListParameter
Deprecated. -
setIntListParameter
Deprecated. -
setIntParameter
Deprecated. -
setLongParameter
Deprecated. -
setStringListParameter
Deprecated. -
setStringListParameter
Deprecated. -
setStringParameter
Deprecated.
-
propertiesToQueryPerNode