OSWorkflow 2.6 introduces a new ExpressionQuery
API.
Note that not all workflow stores support queries. Currently the Hibernate, JDBC, and Memory workflow stores do support queries. The hibernate store however does not support mixed-type queries (for example, a query that uses both the history and current step contexts). To execute a query, a WorkflowExpressionQuery object is constructed, and the query
method is invoked on the Workflow object.
Below are some query example:
new WorkflowExpressionQuery(
new FieldExpression(FieldExpression.OWNER, FieldExpression.CURRENT_STEPS, FieldExpression.EQUALS, "testuser"));
new WorkflowExpressionQuery(
new FieldExpression(FieldExpression.NAME, FieldExpression.ENTRY, FieldExpression.EQUALS, 'myworkflow'))
Below is an example of a nested query:
Expression queryLeft = new FieldExpression(
FieldExpression.OWNER,
FieldExpression.CURRENT_STEPS,
FieldExpression.EQUALS, 'testuser');
Expression queryRight = new FieldExpression(
FieldExpression.STATUS,
FieldExpression.CURRENT_STEPS,
FieldExpression.EQUALS,
"Finished",
true);
WorkflowExpressionQuery query = new WorkflowExpressionQuery(
new NestedExpression(new Expression[] {queryLeft, queryRight},
NestedExpression.AND));
Finally, here is an example of a mixed-context query. Note that this query is not supported by the Hibernate workflow store.
Expression queryLeft = new FieldExpression(
FieldExpression.FINISH_DATE,
FieldExpression.HISTORY_STEPS,
FieldExpression.LT, new Date());
Expression queryRight = new FieldExpression(
FieldExpression.STATUS,
FieldExpression.CURRENT_STEPS,
FieldExpression.EQUALS, "Finished");
WorkflowExpressionQuery query = new WorkflowExpressionQuery(
new NestedExpression(new Expression[] {queryLeft, queryRight},
NestedExpression.OR));