osworkflow Query语法解析

摘自: 银狐的专栏
查询
在OSWorkflow 2.6中,引入了新的ExpressionQuery API。
注意:不是所有的workflow 的存储都支持查询。目前,Hibernate,JDBC和内存存储都支持查询。然而,hibernate存储不支持混合类型的查询(例如:一个历史和当前 步骤的查询信息的查询)。要执行查询,就要建立一个WorkflowExpressionQuery对象,然后在 WorkflowExpressionQuery对象中调用查询方法。
下面是一个查询的例子:
//Get all workflow entry ID's for which the owner is 'testuser'
 new WorkflowExpressionQuery(
   new FieldExpression(FieldExpression.OWNER,             //Check the OWNER field
   FieldExpression.CURRENT_STEPS,                             //Look in the current steps context
   FieldExpression.EQUALS,                                           //check equality
   "testuser"));                                                             //the equality value is 'testuser'
//Get all workflow entry ID's that have the name 'myworkflow'
 new WorkflowExpressionQuery(
   new FieldExpression(FieldExpression.NAME,                //Check the NAME field
   FieldExpression.ENTRY,                                              //Look in the entries context
   FieldExpression.EQUALS,                                           //Check equality
   'myworkflow'))                                                          //equality value is 'myworkflow'

下面是一个嵌套查询的例子:
// Get all finished workflow entries where the current owner is 'testuser'
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.

//Get all workflow entries that were finished in the past
//or are currently marked finished
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));

 

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值