Shark工作流的实现和WMFC&OMG规范的对比

                                        -----第五部分:工作流的实例化

 

关键字:Shark 工作流 WMFC OMG 规范

学习了这么多的开源框架,准备自己也实现一个。万事开头难,先说说如何用XPDL来描述流程中需要包含的信息和如何实例化一个流程。

shark中有一个Package-Business_Example 的例子。其中Customer Service - Request for Partial Shipment (客户服务对分装运输的要求)流程信息的xdpl描述如下:

<WorkflowProcess>

    <WorkflowProcess AccessLevel="PUBLIC" Id="Business_Example_Wor2" Name="Customer Service - Request for Partial Shipment">

        <ProcessHeader DurationUnit="D">

            <Created>13-03-2003</Created>

        </ProcessHeader>

        <RedefinableHeader PublicationStatus="UNDER_TEST"/>

        <FormalParameters>

            <FormalParameter Id="Customer_Name" Index="1" Mode="IN">

                <DataType>

                    <BasicType Type="STRING"/>

                </DataType>

                <Description>The customer (or customer organization) name</Description>

            </FormalParameter>

            <FormalParameter Id="Product_Name" Index="2" Mode="IN">

                <DataType>

                    <BasicType Type="STRING"/>

                </DataType>

                <Description>The product name</Description>

            </FormalParameter>

            <FormalParameter Id="Ordered_Quantity" Index="3" Mode="IN">

                <DataType>

                    <BasicType Type="INTEGER"/>

                </DataType>

                <Description>The number of ordered items</Description>

            </FormalParameter>

            <FormalParameter Id="No_Of_Stocked_Items" Index="4" Mode="IN">

                <DataType>

                    <BasicType Type="INTEGER"/>

                </DataType>

                <Description>The number of ordered items on stock</Description>

            </FormalParameter>

            <FormalParameter Id="Partial_Ship_Status" Index="5" Mode="OUT">

                <DataType>

                    <DeclaredType Id="Business_Example_Typ2"/>

                </DataType>

                <Description>If customer aggreed on partial shipment, set the value of this variable to "OK", otherwise to anything else ("NOT_OK" for e.g.)</Description>

            </FormalParameter>

        </FormalParameters>

        <Activities>

            <Activity Id="Business_Example_Wor2_Act4" Name="notify sales">

                <Description>Enter the customer response ("OK" if customer accepts partial shipment)</Description>

                <Implementation>

                    <No/>

                </Implementation>

                <Performer>Participant_Repository_Par10</Performer>

                <StartMode>

                    <Automatic/>

                </StartMode>

                <FinishMode>

                    <Automatic/>

                </FinishMode>

                <ExtendedAttributes>

                    <ExtendedAttribute Name="ParticipantID" Value="Participant_Repository_Par10"/>

                    <ExtendedAttribute Name="XOffset" Value="381"/>

                    <ExtendedAttribute Name="YOffset" Value="70"/>

                    <ExtendedAttribute Name="VariableToProcess_UPDATE" Value="Partial_Ship_Status"/>

                </ExtendedAttributes>

            </Activity>

            <Activity Id="Business_Example_Wor2_Act2" Name="ask customer for partial shipment">

                <Description>Asks customer if it is OK to partialy ship the existing number of wanted items</Description>

                <Implementation>

                    <No/>

                </Implementation>

                <Performer>Participant_Repository_Par10</Performer>

                <StartMode>

                    <Automatic/>

                </StartMode>

                <FinishMode>

                    <Automatic/>

                </FinishMode>

                <ExtendedAttributes>

                    <ExtendedAttribute Name="ParticipantID" Value="Participant_Repository_Par10"/>

                    <ExtendedAttribute Name="XOffset" Value="226"/>

                    <ExtendedAttribute Name="YOffset" Value="70"/>

                    <ExtendedAttribute Name="VariableToProcess_VIEW" Value="Customer_Name"/>

                    <ExtendedAttribute Name="VariableToProcess_VIEW" Value="Product_Name"/>

                    <ExtendedAttribute Name="VariableToProcess_VIEW" Value="Order_Quantity"/>

                    <ExtendedAttribute Name="VariableToProcess_VIEW" Value="No_Of_Stocked_Items"/>

                </ExtendedAttributes>

            </Activity>

        </Activities>

        <Transitions>

            <Transition From="Business_Example_Wor2_Act2" Id="Business_Example_Wor2_Tra23" Name="Transition" To="Business_Example_Wor2_Act4">

                <ExtendedAttributes>

                    <ExtendedAttribute Name="RoutingType" Value="NOROUTING"/>

                </ExtendedAttributes>

            </Transition>

        </Transitions>

        <ExtendedAttributes>

            <ExtendedAttribute Name="StartOfWorkflow" Value="Participant_Repository_Par10;Business_Example_Wor2_Act2;128;70;NOROUTING"/>

            <ExtendedAttribute Name="EndOfWorkflow" Value="Participant_Repository_Par10;Business_Example_Wor2_Act4;527;70;NOROUTING"/>

            <ExtendedAttribute Name="ParticipantVisualOrder" Value="Participant_Repository_Par10;"/>

        </ExtendedAttributes>

    </WorkflowProcess>

</WorkflowProcess>

解释如下:

这个流程只有两个活动:

1<Activity Id="Business_Example_Wor2_Act2" Name="ask customer for partial shipment">

    询问用户时候需要分装运输

2<Activity Id="Business_Example_Wor2_Act4" Name="notify sales">

        告诉客户销售

 

两个活动的转移:

     <Transition From="Business_Example_Wor2_Act2" Id="Business_Example_Wor2_Tra23" Name="Transition" To="Business_Example_Wor2_Act4">

上面的描述只是一个基本的XPDL的实现,在现实世界里所需要的信息是不充分的。

比如:

1、          当用户A登陆后,需要知道和用户A相关的那些活动已经启动,并提示用户A,操作这个活动。这样在实例化的流程中需要包含参与者的信息。

2、          上面的描述中只是包含了工作流本身的信息,很显然,工作流任务执行的具体最后要落实在业务过程上,那么在实例化后的工作流中应该包含业务的数据,最少应该包含能够找到这个业务的连接数据。

3、          工作流具体的状态业务状态在实例化的流程中应该保存起来。

 

   从上面的对比中可以看出,工作流引擎对如何实例化工作信息和业务信息应该是不同的,因为这并不是WMFC规范中的内容。

 

待续

田春峰

accesine@163.com

 

 

 

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐