osworkflow example 之split&join

osworkflow扩展非常容易,跟我们的应用结合起来使用也很容易。假设一个请假流程:员工请假,需要经过部门经理和人力资源部经理两人共同审批,只有当两人都许可时才通过,任一人驳回就失效,也就是一个and split和and Join流程,并且我们附加一个要求,当发送请假请求、许可和驳回这几个操作时都将发送一条消息给相应的用户。

    流程定义文件如下:
<!----> <? xml version="1.0" encoding="UTF-8"  ?>
<! DOCTYPE workflow PUBLIC "-//OpenSymphony Group//DTD OSWorkflow 2.7//EN" 
"http://www.opensymphony.com/osworkflow/workflow_2_7.dtd"
>
< workflow >
     < initial-actions >
         < action  id ="0"  name ="开始" >
             < pre-functions >
                 < function  type ="class" >
                     < arg  name ="class.name" >
                        com.opensymphony.workflow.util.Caller
                     </ arg >
                 </ function >
             </ pre-functions >
             < results >
                 < unconditional-result  old-status ="Finished"
                    status
="Underway"  step ="1"  owner ="${caller}"   />
             </ results >
         </ action >
     </ initial-actions >

     < steps >
         < step  id ="1"  name ="填假单" >
             < external-permissions >
                 < permission  name ="permA" >
                     < restrict-to >
                         < conditions  type ="AND" >
                             < condition  type ="class" > <!-- 流程处于Underway状态(流程已经启动) -->
                                 < arg  name ="class.name" >
                                    com.opensymphony.workflow.util.StatusCondition
                                 </ arg >
                                 < arg  name ="status" >Underway </ arg >
                             </ condition >
                             < condition  type ="class" >
                                 < arg  name ="class.name" >
                                    com.opensymphony.workflow.util.AllowOwnerOnlyCondition
                                 </ arg >
                             </ condition >
                         </ conditions >
                     </ restrict-to >
                 </ permission >
             </ external-permissions >
             < actions >
                 < action  id ="1"  name ="送出" >
                     < restrict-to >
                         < conditions  type ="AND" >
                             < condition  type ="class" > <!-- 流程处于Underway状态(流程已经启动) -->
                                 < arg  name ="class.name" >
                                    com.opensymphony.workflow.util.StatusCondition
                                 </ arg >
                                 < arg  name ="status" >Underway </ arg >
                             </ condition >
                             < condition  type ="class" >
                                 < arg  name ="class.name" >
                                    com.opensymphony.workflow.util.AllowOwnerOnlyCondition
                                 </ arg >
                             </ condition >
                         </ conditions >
                     </ restrict-to >
                     < pre-functions >
                         < function  type ="class" >
                             < arg  name ="class.name" >
                                com.opensymphony.workflow.util.Caller
                             </ arg >
                         </ function >

                     </ pre-functions >
                     < results >
                         < unconditional-result  old-status ="Finished"
                            split
="1"  status ="Queued" >
                             < post-functions >
                                 < function  type ="class" >
                                     < arg  name ="class.name" >
                                        net.rubyeye.leavesys.service.workflow.SendRemindInfFunction
                                     </ arg >
                                     < arg  name ="groupName" >
                                        AND (GROUPNAME='dept_manager' or
                                        GROUPNAME='comp_manager')
                                     </ arg >
                                     < arg  name ="content" >
                                        you have leavemsg to
                                        check!please check it!
                                     </ arg >
                                 </ function >
                             </ post-functions >
                         </ unconditional-result >
                     </ results >
                 </ action >
             </ actions >
         </ step >
         < step  id ="2"  name ="部门经理批假单" >
             < actions >
                 < action  id ="2"  name ="准许" >
                     < restrict-to >
                         < conditions >
                             < condition  type ="class" >
                                 < arg  name ="class.name" >
                                    com.opensymphony.workflow.util.OSUserGroupCondition
                                 </ arg >
                                 < arg  name ="group" >dept_manager </ arg >
                             </ condition >
                         </ conditions >
                     </ restrict-to >
                     < pre-functions >
                         < function  type ="class" >
                             < arg  name ="class.name" >
                                com.opensymphony.workflow.util.Caller
                             </ arg >
                         </ function >
                         < function  type ="beanshell" >
                             < arg  name ="script" >
                                propertySet.setString("action1",
                                "success");
                             </ arg >
                         </ function >
                     </ pre-functions >
                     < results >
                         < unconditional-result  old-status ="Finished"
                            status
="Queued"  join ="1"  owner ="${caller}"   />
                     </ results >
                 </ action >

                 < action  id ="3"  name ="驳回" >
                     < restrict-to >
                         < conditions >
                             < condition  type ="class" >
                                 < arg  name ="class.name" >
                                    com.opensymphony.workflow.util.OSUserGroupCondition
                                 </ arg >
                                 < arg  name ="group" >dept_manager </ arg >
                             </ condition >
                         </ conditions >
                     </ restrict-to >
                     < pre-functions >
                         < function  type ="class" >
                             < arg  name ="class.name" >
                                com.opensymphony.workflow.util.Caller
                             </ arg >
                         </ function >
                         < function  type ="beanshell" >
                             < arg  name ="script" >
                                propertySet.setString("action1",
                                "fail");
                             </ arg >
                         </ function >
                     </ pre-functions >
                     < results >
                         < unconditional-result  old-status ="Finished"
                            status
="Queued"  join ="2"  owner ="${caller}"   />
                     </ results >
                 </ action >
             </ actions >
         </ step >

         < step  id ="3"  name ="公司经理批假单" >
             < actions >
                 < action  id ="4"  name ="准许" >
                     < restrict-to >
                         < conditions >
                             < condition  type ="class" >
                                 < arg  name ="class.name" >
                                    com.opensymphony.workflow.util.OSUserGroupCondition
                                 </ arg >
                                 < arg  name ="group" >comp_manager </ arg >
                             </ condition >
                         </ conditions >
                     </ restrict-to >
                     < pre-functions >
                         < function  type ="class" >
                             < arg  name ="class.name" >
                                com.opensymphony.workflow.util.Caller
                             </ arg >
                         </ function >
                         < function  type ="beanshell" >
                             < arg  name ="script" >
                                propertySet.setString("action2",
                                "success");
                             </ arg >
                         </ function >
                     </ pre-functions >
                     < results >
                         < unconditional-result  old-status ="Finished"
                            status
="Queued"  join ="1"  owner ="${caller}"   />
                     </ results >
                 </ action >

                 < action  id ="5"  name ="驳回" >
                     < restrict-to >
                         < conditions >
                             < condition  type ="class" >
                                 < arg  name ="class.name" >
                                    com.opensymphony.workflow.util.OSUserGroupCondition
                                 </ arg >
                                 < arg  name ="group" >dept_manager </ arg >
                             </ condition >
                         </ conditions >
                     </ restrict-to >
                     < pre-functions >
                         < function  type ="class" >
                             < arg  name ="class.name" >
                                com.opensymphony.workflow.util.Caller
                             </ arg >
                         </ function >
                         < function  type ="beanshell" >
                             < arg  name ="script" >
                                propertySet.setString("action2",
                                "fail");
                             </ arg >
                         </ function >
                     </ pre-functions >
                     < results >
                         < unconditional-result  old-status ="Finished"
                            status
="Queued"  join ="2"  owner ="${caller}"   />
                     </ results >
                 </ action >
             </ actions >
         </ step >

         < step  id ="4"  name ="停止"   />
     </ steps >
     < splits >
         < split  id ="1" >
             < unconditional-result  old-status ="Finished"  status ="Queued"
                step
="2"   />
             < unconditional-result  old-status ="Finished"  status ="Queued"
                step
="3"   />
         </ split >
     </ splits >
     < joins >
         < join  id ="1" >
             < conditions  type ="AND" >
                 < condition  type ="beanshell" >
                     < arg  name ="script" >
                         <![CDATA[
     "Finished".equals(jn.getStep(2).getStatus()) &&
        "Finished".equals(jn.getStep(3).getStatus())&&"success".equals(propertySet.getString("action1"))&&
        "success".equals(propertySet.getString("action2"))
      
]]>
                     </ arg >
                 </ condition >
             </ conditions >
             < unconditional-result  old-status ="Finished"  status ="Queued"
                step
="4" />
         </ join >

         < join  id ="2" >
             < conditions  type ="OR" >
                 < condition  type ="beanshell" >
转:http://dennis-zane.iteye.com/blog/57497
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值