org.camunda.bpm.engine.impl
Class AbstractQuery<T extends Query<?,?>,U>

java.lang.Object
  extended by org.camunda.bpm.engine.impl.db.ListQueryParameterObject
      extended by org.camunda.bpm.engine.impl.AbstractQuery<T,U>
All Implemented Interfaces:
Serializable, Command<Object>, Query<T,U>
Direct Known Subclasses:
AbstractVariableQueryImpl, ActivityStatisticsQueryImpl, AuthorizationQueryImpl, BatchQueryImpl, BatchStatisticsQueryImpl, CaseDefinitionQueryImpl, CaseSentryPartQueryImpl, DecisionDefinitionQueryImpl, DecisionRequirementsDefinitionQueryImpl, DeploymentQueryImpl, DeploymentStatisticsQueryImpl, EventSubscriptionQueryImpl, ExternalTaskQueryImpl, FilterQueryImpl, GroupQueryImpl, HistoricActivityInstanceQueryImpl, HistoricActivityStatisticsQueryImpl, HistoricBatchQueryImpl, HistoricCaseActivityInstanceQueryImpl, HistoricDecisionInstanceQueryImpl, HistoricDetailQueryImpl, HistoricJobLogQueryImpl, HistoricTaskInstanceQueryImpl, HistoricVariableInstanceQueryImpl, IncidentQueryImpl, JobDefinitionQueryImpl, JobQueryImpl, ProcessDefinitionQueryImpl, ProcessDefinitionStatisticsQueryImpl, TaskQueryImpl, TenantQueryImpl, UserOperationLogQueryImpl, UserQueryImpl

public abstract class AbstractQuery<T extends Query<?,?>,U>
extends ListQueryParameterObject
implements Command<Object>, Query<T,U>, Serializable

Abstract superclass for all query types.

Author:
Joram Barrez
See Also:
Serialized Form

Nested Class Summary
protected static class AbstractQuery.ResultType
           
 
Field Summary
protected  CommandExecutor commandExecutor
           
protected  Map<String,String> expressions
           
protected  List<QueryOrderingProperty> orderingProperties
           
protected  AbstractQuery.ResultType resultType
           
static String SORTORDER_ASC
           
static String SORTORDER_DESC
           
protected  Set<Validator<AbstractQuery<?,?>>> validators
           
 
Fields inherited from class org.camunda.bpm.engine.impl.db.ListQueryParameterObject
authCheck, databaseType, DEFAULT_ORDER_BY, firstResult, maxResults, orderBy, parameter, tenantCheck
 
Constructor Summary
protected AbstractQuery()
           
protected AbstractQuery(CommandExecutor commandExecutor)
           
 
Method Summary
 void addExpression(String key, String expression)
           
 void addValidator(Validator<AbstractQuery<?,?>> validator)
           
 T asc()
          Order the results ascending on the given property as defined in this class (needs to come after a call to one of the orderByXxxx methods).
protected  void checkQueryOk()
           
 long count()
          Executes the query and returns the number of results
 T desc()
          Order the results descending on the given property as defined in this class (needs to come after a call to one of the orderByXxxx methods).
 T direction(Direction direction)
           
protected  void evaluateExpressions()
           
 long evaluateExpressionsAndExecuteCount(CommandContext commandContext)
           
 List<U> evaluateExpressionsAndExecuteList(CommandContext commandContext, Page page)
           
 Object execute(CommandContext commandContext)
           
abstract  long executeCount(CommandContext commandContext)
           
abstract  List<U> executeList(CommandContext commandContext, Page page)
          Executes the actual query to retrieve the list of results.
 U executeSingleResult(CommandContext commandContext)
           
 T extend(T extendingQuery)
           
 Map<String,String> getExpressions()
           
protected  Method getMethod(String methodName)
           
 String getOrderBy()
          Deprecated. 
 List<QueryOrderingProperty> getOrderingProperties()
           
protected  boolean hasExcludingConditions()
          Whether or not the query has excluding conditions.
 List<U> list()
          Executes the query and get a list of entities as the result.
 List<U> listPage(int firstResult, int maxResults)
          Executes the query and get a list of entities as the result.
protected  void mergeExpressions(AbstractQuery<?,?> extendedQuery, AbstractQuery<?,?> extendingQuery)
           
protected  void mergeOrdering(AbstractQuery<?,?> extendedQuery, AbstractQuery<?,?> extendingQuery)
           
 T orderBy(QueryOrderingProperty orderProperty)
           
 T orderBy(QueryProperty property)
           
 void removeValidator(Validator<AbstractQuery<?,?>> validator)
           
 AbstractQuery<T,U> setCommandExecutor(CommandExecutor commandExecutor)
           
 void setExpressions(Map<String,String> expressions)
           
 void setOrderingProperties(List<QueryOrderingProperty> orderingProperties)
           
 U singleResult()
          Executes the query and returns the resulting entity or null if no entity matches the query criteria.
 void validate()
           
 void validate(Validator<AbstractQuery<?,?>> validator)
           
 
Methods inherited from class org.camunda.bpm.engine.impl.db.ListQueryParameterObject
getAuthCheck, getDatabaseType, getFirstResult, getFirstRow, getLastRow, getMaxResults, getParameter, getTenantCheck, setAuthCheck, setDatabaseType, setFirstResult, setMaxResults, setOrderBy, setParameter, setTenantCheck
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SORTORDER_ASC

public static final String SORTORDER_ASC
See Also:
Constant Field Values

SORTORDER_DESC

public static final String SORTORDER_DESC
See Also:
Constant Field Values

commandExecutor

protected transient CommandExecutor commandExecutor

resultType

protected AbstractQuery.ResultType resultType

orderingProperties

protected List<QueryOrderingProperty> orderingProperties

expressions

protected Map<String,String> expressions

validators

protected Set<Validator<AbstractQuery<?,?>>> validators
Constructor Detail

AbstractQuery

protected AbstractQuery()

AbstractQuery

protected AbstractQuery(CommandExecutor commandExecutor)
Method Detail

setCommandExecutor

public AbstractQuery<T,U> setCommandExecutor(CommandExecutor commandExecutor)

orderBy

public T orderBy(QueryProperty property)

orderBy

public T orderBy(QueryOrderingProperty orderProperty)

asc

public T asc()
Description copied from interface: Query
Order the results ascending on the given property as defined in this class (needs to come after a call to one of the orderByXxxx methods).

Specified by:
asc in interface Query<T extends Query<?,?>,U>

desc

public T desc()
Description copied from interface: Query
Order the results descending on the given property as defined in this class (needs to come after a call to one of the orderByXxxx methods).

Specified by:
desc in interface Query<T extends Query<?,?>,U>

direction

public T direction(Direction direction)

checkQueryOk

protected void checkQueryOk()

singleResult

public U singleResult()
Description copied from interface: Query
Executes the query and returns the resulting entity or null if no entity matches the query criteria.

Specified by:
singleResult in interface Query<T extends Query<?,?>,U>

list

public List<U> list()
Description copied from interface: Query
Executes the query and get a list of entities as the result.

Specified by:
list in interface Query<T extends Query<?,?>,U>

listPage

public List<U> listPage(int firstResult,
                        int maxResults)
Description copied from interface: Query
Executes the query and get a list of entities as the result.

Specified by:
listPage in interface Query<T extends Query<?,?>,U>

count

public long count()
Description copied from interface: Query
Executes the query and returns the number of results

Specified by:
count in interface Query<T extends Query<?,?>,U>

execute

public Object execute(CommandContext commandContext)
Specified by:
execute in interface Command<Object>

evaluateExpressionsAndExecuteCount

public long evaluateExpressionsAndExecuteCount(CommandContext commandContext)

executeCount

public abstract long executeCount(CommandContext commandContext)

evaluateExpressionsAndExecuteList

public List<U> evaluateExpressionsAndExecuteList(CommandContext commandContext,
                                                 Page page)

hasExcludingConditions

protected boolean hasExcludingConditions()
Whether or not the query has excluding conditions. If the query has excluding conditions, (e.g. task due date before and after are excluding), the SQL query is avoided and a default result is returned. The returned result is the same as if the SQL was executed and there were no entries.

Returns:
true if the query does have excluding conditions, false otherwise

executeList

public abstract List<U> executeList(CommandContext commandContext,
                                    Page page)
Executes the actual query to retrieve the list of results.

Parameters:
page - used if the results must be paged. If null, no paging will be applied.

executeSingleResult

public U executeSingleResult(CommandContext commandContext)

getOrderBy

@Deprecated
public String getOrderBy()
Deprecated. 

Overrides:
getOrderBy in class ListQueryParameterObject

getOrderingProperties

public List<QueryOrderingProperty> getOrderingProperties()

setOrderingProperties

public void setOrderingProperties(List<QueryOrderingProperty> orderingProperties)

getExpressions

public Map<String,String> getExpressions()

setExpressions

public void setExpressions(Map<String,String> expressions)

addExpression

public void addExpression(String key,
                          String expression)

evaluateExpressions

protected void evaluateExpressions()

getMethod

protected Method getMethod(String methodName)

extend

public T extend(T extendingQuery)

mergeOrdering

protected void mergeOrdering(AbstractQuery<?,?> extendedQuery,
                             AbstractQuery<?,?> extendingQuery)

mergeExpressions

protected void mergeExpressions(AbstractQuery<?,?> extendedQuery,
                                AbstractQuery<?,?> extendingQuery)

validate

public void validate()

validate

public void validate(Validator<AbstractQuery<?,?>> validator)

addValidator

public void addValidator(Validator<AbstractQuery<?,?>> validator)

removeValidator

public void removeValidator(Validator<AbstractQuery<?,?>> validator)


Copyright © 2016 camunda services GmbH. All rights reserved.