Interface ExecutableQuery

All Superinterfaces:
ContactNodeRestrictions<ExecutableQuery>, DataStoresConditionable<ExecutableQuery>, PropertiesCarrier<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 Details

    • getQueryDefinition

      QueryDefinition getQueryDefinition()
    • onTopOfQuery

      ExecutableQuery onTopOfQuery(String parentQueryName)
      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.

      Unlike QueryDefinition.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

      QueryNodeRestrictions nodeRestrictions(String nodeName)
      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 PropertiesToQuery nodePropertiesToQuery(String nodeName)
      Deprecated.
    • propertiesToQueryPerNode

      PropertiesCarrierWrapper propertiesToQueryPerNode(String nodeName)
      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 of propertiesToQueryPerNode(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 with Topology.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

      @NotFinalAPI QueryParameters 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

      @NotFinalAPI ExecutableQuery withDataIntegrityRulesBundle(String dataIntegrityRulesBundle)
    • getDataIntegrityRulesBundle

      @NotFinalAPI String getDataIntegrityRulesBundle()
    • setParameter

      @Deprecated void setParameter(String parameterName, Object parameterValue)
      Deprecated.
      use queryParameters.
    • setBooleanParameter

      @Deprecated void setBooleanParameter(String parameterName, boolean parameterValue)
      Deprecated.
      use queryParameters.
    • setBytesParameter

      @Deprecated void setBytesParameter(String parameterName, byte[] parameterValue)
      Deprecated.
    • setDateParameter

      @Deprecated void setDateParameter(String parameterName, Date parameterValue)
      Deprecated.
    • setDoubleParameter

      @Deprecated void setDoubleParameter(String parameterName, double parameterValue)
      Deprecated.
    • setFloatParameter

      @Deprecated void setFloatParameter(String parameterName, float parameterValue)
      Deprecated.
      use queryParameters.
    • setIntListParameter

      @Deprecated void setIntListParameter(String parameterName, int[] parameterValue)
      Deprecated.
    • setIntListParameter

      @Deprecated void setIntListParameter(String parameterName, Iterable<Integer> parameterValue)
      Deprecated.
    • setIntParameter

      @Deprecated void setIntParameter(String parameterName, int parameterValue)
      Deprecated.
    • setLongParameter

      @Deprecated void setLongParameter(String parameterName, long parameterValue)
      Deprecated.
    • setStringListParameter

      @Deprecated void setStringListParameter(String parameterName, String[] parameterValue)
      Deprecated.
    • setStringListParameter

      @Deprecated void setStringListParameter(String parameterName, Iterable<String> parameterValue)
      Deprecated.
    • setStringParameter

      @Deprecated void setStringParameter(String parameterName, String parameterValue)
      Deprecated.