CSDN博客

img tenwang1977

OSWorkflow中的标签元素与概念[原]

发表于2004/9/23 16:20:00  2565人阅读

分类: OSWorkflow

OSWorkflow的核心是一个使用XML定义的描述符文件,下面是对OSWorkflow的描述符文件标签以及OSWorkflow基本概念的说明:

 

一、名词说明:

1.  workflow        工作流

2.  step                步骤

3.  action             动作

4.  result                     执行结果

5.  split                步骤分割

6.  join                 步骤合并

7.  register           寄存器

8.  functions         函数

9.  conditions              条件

10. context            上下文

11. state                状态

 

二、标签及概念:

1.  一个工作流( workflow )可以包含多个step( 步骤 )

2.  一个step可以有多个action( 动作 )action可以被设置为自动执行,也可以是通过用户介入,而通过程序调用执行。

3.  一个action要至少有一个unconditional result和零个或多个conditional result(result是指action的执行结果)

4.  如果你指定了多个conditional results,那么符合执行条件的第一个result将被执行,如果没有指定conditional results或者没有任何一个conditional   results符合执行的条件,那么将执行unconditional result

5.  一个result可以仍然使流程驻留在当前step,可以指向一个新的step,可以指向一个split(步骤分割),还可以指向一个join(步骤合并)。在所述的所有情况下,workflow

    的状态也可以改变(例如:workflow的状态是Underway,QueuedFinished)

6.  如果一个result指向一个split,那么它所指向的split的属性是在splits的标签中描述的。

7.  一个split可以拥有一个或多个unconditional results,但是没有conditional resultsunconditional results指向了从这个split中即将进入的steps

8.  register(寄存器)是一个全局变量,它可以被每个workflow处理,而且也可以用在functions(函数)conditions(条件)中。

9.  propertySet是一个存放持久型数据的map,它可以被当作全局的调用。

10. transientVars是用于存放临时变量的一个map,所有的functionsconditions都可以使用它。它包含所有的registersuser inputs、以及当前workflowcontext(上下文)state(状态)。它仅仅在一个workflow调用的生命期存在。

 

三、OSWorkflow例子程序中的描述符文件:

下面是OSWorkflow例子程序中的描述符文件,可以参考上面的描述与下面的描述符文件对比理解:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE workflow PUBLIC "-//OpenSymphony Group//DTD OSWorkflow 2.6//EN" "http://www.opensymphony.com/osworkflow/workflow_2_6.dtd">

<workflow>

       <initial-actions>

              <action id="1" name="Start Workflow">

                     <restrict-to>

                            <conditions type="AND">

                                   <condition type="beanshell">

                                          <arg name="script">true</arg>

                                   </condition>

                                   <condition type="class">

                                          <arg name="class.name">

com.opensymphony.workflow.util.OSUserGroupCondition

</arg>

                                          <arg name="group">foos</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" status="Underway" step="1" owner="${caller}"/>

                     </results>

              </action>

       </initial-actions>

       <steps>

              <step id="1" name="First Draft">

                     <external-permissions>

                            <permission name="permA">

                                   <restrict-to>

                                          <conditions type="AND">

                                                 <condition type="class">

                                                        <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="Finish First Draft">

                                   <restrict-to>

                                          <conditions type="AND">

                                                 <condition type="beanshell">

                                                        <arg name="script">true</arg>

                                                 </condition>

                                                 <condition type="class">

                                                        <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="beanshell">

                                                 <arg name="script">

                                String caller = context.getCaller();

                                propertySet.setString("caller", caller);

                                boolean test = true;

                                String yuck = null;

                                String blah = "987654321";

                                System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");

                            </arg>

                                          </function>

                                   </pre-functions>

                                   <results>

                                          <result old-status="Finished" split="1">

                                                 <conditions type="AND">

                                                        <condition type="beanshell">

                                                               <arg name="script">

                                                                      propertySet.getString("caller").equals("test")

                                                               </arg>

                                                        </condition>

                                                 </conditions>

                                                 <post-functions>

                                                        <function type="beanshell">

                                                               <arg name="script">

                                        System.out.println("11111111111111");

                                    </arg>

                                                        </function>

                                                 </post-functions>

                                          </result>

                                          <unconditional-result old-status="Finished" split="2"/>

                                   </results>

                                   <post-functions>

                                          <function type="beanshell">

                                                 <arg name="script">

                                System.out.println("22222222222222");

                            </arg>

                                          </function>

                                   </post-functions>

                            </action>

                     </actions>

              </step>

              <step id="2" name="Edit Doc">

                     <external-permissions>

                            <permission name="permB">

                                   <restrict-to>

                                          <conditions type="AND">

                                                 <condition type="class">

                                                        <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="2" name="Sign Up For Editing">

                                   <restrict-to>

                                          <conditions type="AND">

                                                 <condition type="class">

                                                        <arg name="class.name">

com.opensymphony.workflow.util.StatusCondition

</arg>

                                                        <arg name="status">Queued</arg>

                                                 </condition>

                                                 <condition type="class">

                                                        <arg name="class.name">

com.opensymphony.workflow.util.OSUserGroupCondition

</arg>

                                                        <arg name="group">bars</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" status="Underway" step="2" owner="${caller}"/>

                                   </results>

                            </action>

                            <action id="3" name="Finish Editing">

                                   <restrict-to>

                                          <conditions type="AND">

                                                 <condition type="class">

                                                        <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.MostRecentOwner

</arg>

                                                 <arg name="stepId">1</arg>

                                          </function>

                                   </pre-functions>

                                   <results>

                                          <unconditional-result

old-status="Finished" status="Underway" step="3" owner="${mostRecentOwner}"/>

                                   </results>

                            </action>

                            <action id="4" name="Requeue Editing">

                                   <restrict-to>

                                          <conditions type="AND">

                                                 <condition type="class">

                                                        <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>

                                   <results>

                                          <unconditional-result old-status="Finished" status="Queued" step="2"/>

                                   </results>

                            </action>

                     </actions>

              </step>

              <step id="3" name="Review Doc">

                     <external-permissions>

                            <permission name="permA">

                                   <restrict-to>

                                          <conditions type="AND">

                                                 <condition type="class">

                                                        <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="5" name="More Edits">

                                   <restrict-to>

                                          <conditions type="AND">

                                                 <condition type="class">

                                                        <arg name="class.name">

com.opensymphony.workflow.util.StatusConditio

</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.MostRecentOwner

</arg>

                                                 <arg name="stepId">2</arg>

                                          </function>

                                   </pre-functions>

                                   <results>

                                          <unconditional-result

old-status="Finished" status="Underway" step="2" owner="${mostRecentOwner}"/>

                                   </results>

                            </action>

                            <action id="6" name="Peer Review">

                                   <restrict-to>

                                          <conditions type="AND">

                                                 <condition type="class">

                                                        <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>

                                   <results>

                                          <unconditional-result old-status="Finished" status="Queued" step="4"/>

                                   </results>

                            </action>

                            <action id="7" name="Publish Doc">

                                   <restrict-to>

                                          <conditions type="AND">

                                                 <condition type="class">

                                                        <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.MostRecentOwner

</arg>

                                                 <arg name="stepId">2</arg>

                                          </function>

                                   </pre-functions>

                                   <results>

                                          <unconditional-result

                                                old-status="Finished" status="Underway" step="5" owner="${mostRecentOwner}"/>

                                   </results>

                            </action>

                     </actions>

              </step>

              <step id="4" name="Second Review">

                     <external-permissions>

                            <permission name="permC">

                                   <restrict-to>

                                          <conditions type="AND">

                                                 <condition type="class">

                                                        <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="8" name="Finish Second Review">

                                   <restrict-to>

                                          <conditions type="AND">

                                                 <condition type="class">

                                                        <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.MostRecentOwner

</arg>

                                                 <arg name="stepId">3</arg>

                                          </function>

                                   </pre-functions>

                                   <results>

                                          <unconditional-result

old-status="Finished" status="Underway" step="3" owner="${mostRecentOwner}"/>

                                   </results>

                            </action>

                            <action id="9" name="Sign Up For Second Review">

                                   <restrict-to>

                                          <conditions type="AND">

                                                 <condition type="class">

                                                        <arg name="class.name">

com.opensymphony.workflow.util.StatusCondition

</arg>

                                                        <arg name="status">Queued</arg>

                                                 </condition>

                                                 <condition type="class">

                                                        <arg name="class.name">

com.opensymphony.workflow.util.OSUserGroupCondition

</arg>

                                                        <arg name="group">bazs</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" status="Underway" step="4" owner="${caller}"/>

                                   </results>

                            </action>

                            <action id="10" name="Queue Second Review">

                                   <restrict-to>

                                          <conditions type="AND">

                                                 <condition type="class">

                                                        <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>

                                   <results>

                                          <unconditional-result old-status="Finished" status="Queued" step="4"/>

                                   </results>

                            </action>

                     </actions>

              </step>

              <step id="5" name="Publish Doc">

                     <actions>

                            <action id="11" name="Publish Document">

                                   <restrict-to>

                                          <conditions type="AND">

                                                 <condition type="class">

                                                        <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" status="Finished" step="5" owner="${caller}"/>

                                   </results>

                            </action>

                     </actions>

              </step>

              <step id="6" name="Foo">

                     <actions>

                            <action name="Finish Foo" id="12">

                                   <restrict-to>

                                          <conditions type="AND">

                                                 <condition type="class">

                                                        <arg name="class.name">

com.opensymphony.workflow.util.StatusCondition

</arg>

                                                        <arg name="status">Underway</arg>

                                                        <arg name="stepId">6</arg>

                                                 </condition>

                                                 <condition type="class">

                                                        <arg name="class.name">

com.opensymphony.workflow.util.AllowOwnerOnlyCondition

</arg>

                                                        <arg name="stepId">6</arg>

                                                 </condition>

                                          </conditions>

                                   </restrict-to>

                                   <results>

                                          <unconditional-result old-status="Finished" join="1"/>

                                   </results>

                            </action>

                     </actions>

              </step>

              <step id="7" name="Bar">

                     <actions>

                            <action name="Finish Bar" id="13">

                                   <restrict-to>

                                          <conditions type="AND">

                                                 <condition type="class">

                                                        <arg name="class.name">

com.opensymphony.workflow.util.StatusCondition

</arg>

                                                        <arg name="status">Underway</arg>

                                                        <arg name="stepId">7</arg>

                                                 </condition>

                                                 <condition type="class">

                                                        <arg name="class.name">

com.opensymphony.workflow.util.AllowOwnerOnlyCondition

</arg>

                                                        <arg name="stepId">7</arg>

                                                 </condition>

                                          </conditions>

                                   </restrict-to>

                                   <results>

                                          <unconditional-result

 old-status="Finished" owner="test" status="Underway" step="8"/>

                                   </results>

                            </action>

                     </actions>

              </step>

              <step id="8" name="Baz">

                     <actions>

                            <action name="Finish Baz" id="14">

                                   <restrict-to>

                                          <conditions type="AND">

                                                 <condition type="class">

                                                        <arg name="class.name">

com.opensymphony.workflow.util.StatusCondition

</arg>

                                                        <arg name="status">Underway</arg>

                                                        <arg name="stepId">8</arg>

                                                 </condition>

                                                 <condition type="class">

                                                        <arg name="class.name">

com.opensymphony.workflow.util.AllowOwnerOnlyCondition

</arg>

                                                        <arg name="stepId">8</arg>

                                                 </condition>

                                          </conditions>

                                   </restrict-to>

                                   <results>

                                          <unconditional-result old-status="Finished" join="1"/>

                                   </results>

                            </action>

                     </actions>

              </step>

       </steps>

       <splits>

              <split id="1">

                     <unconditional-result old-status="Finished" status="Underway" owner="test" step="6"/>

                     <unconditional-result old-status="Finished" status="Underway" owner="test" step="7"/>

              </split>

              <split id="2">

                     <unconditional-result old-status="Finished" status="Queued" step="2"/>

              </split>

       </splits>

       <joins>

              <join id="1">

                     <conditions type="AND">

                            <condition type="beanshell">

                                   <arg name="script">

<![CDATA["Finished".equals(jn.getStep(6).getStatus())

  && "Finished".equals(jn.getStep(8).getStatus())]]>

</arg>

                            </condition>

                     </conditions>

                     <unconditional-result old-status="Finished" status="Underway" owner="test" step="2"/>

              </join>

       </joins>

</workflow>

0 0

相关博文

我的热门文章

img
取 消
img