workflow学习笔记

最近心血来潮,准备学习workflow,学习笔记慢慢更新:

WorkFlow developer Guide
若要update workflow中的object的internal name,需要调用一个特别的SQL script. wfchitt.sql.
See: Wfchitt.sql, Oracle Workflow Administrator’s Guide.

第三章
Message:
 在workflow的process中,notification发送给用户的就是Message.通过Message可以让User更快与workflow之间进行互动,
可以敦促User尽早地对workflow进行回覆。接收Message的Object叫做performer。
 Message不能直接使用与Attribute上的子attribute,而需要在Message下再建立自己的Attribute,但是可以与Attribute节点下的Attribute重名,
这样的话,Message下面的Attribute就会引用Attribute节点下面的attribute的值。
 在Message中若要引用attribute,则需要这样的格式:&MessAttr
 Document Message Attribute不能被Message的subject引用,而只能被Message的Body引用。
 Message的Priority属性只是给user一个信息紧急性的提示,对Process并没有多大的影响。
 Message body必须小于4000bytes,如果body中有使用引用变量的话,最终的结果也不能大于32000bytes
 如果Message需要User作出反馈,则在Result tab中定义对应的lookup type。若定义了result的话,Message的图标上会标上红色的问号
 
Activites:
 一个活动是一个完整的Process中的一环,可以包含如下:
     Notification:负责发送message给workflow user
     Function:可以call PL/SQL或 其他外部的程式来自动执行
     Event:接受、发起或发送一个bussiness event
     Process:可以一层套一层
Notification Activity:
  当workflow engine到达一个notification activity时,会调用Send()API来通知Notification System将信息发送给指定的performer。
当performer对notification activity作出回应之后,Notification System会处理这些回应并通知workflow engine,notification activity
已经执行完成,可以继续执行下一个activity。        
  当将一个notification activity做为一个节点纳入到process中的时候,需要指定notification activtiy的performer。对应的performer可
以是一个特定的role,也可以是一个Item type attribute。如果是Item Type attribute的话,performer就可以通过程式来动态的决定。
  若Expand Roles不打勾,workflow会将通知发给role中的所有user,并在通知队列中提示有新的通知。当其中的一个User close或对该通知进行
  了回复,会将其他user的通知队列中的通知信息删除。
  若将Expand Roles打勾,workflow会将通知发给role中的所有的User,但当其中的一个user打开或对该通知做出回应,Workflow会将其他
User的通知都删除。

Function Activity:
  可以是PL/SQL的程式或外部的其他程式,其可以被调用。其可以接受参数。若是有参数的话,可以使用Item Type的Attribute,动态修改attribute的
  值然后再传给function。
 
Event Activity:

Activity  Cost:
 Function activity和Even activity  都有一个Cost属性。用来表示workflow会花多少秒的时间来执行这个activity。范围为0.00~1,000,000.00不过DB
中是以百秒为单位。大部分时间workflow会执行完一个activity再执行接下来的activity。有时若想将一个activity通过background的方式来执行,可以通
过设定workflow来实现。若运行的时间大于给定的值时,将会启用通过background的方式并行执行当前这个activity和接下来的activity。默认的是5000秒

To create a Notification Activity:
Result type上挑选的result type中的lookup_code是该Notification有可能返回的结果。若该Notification没有返回值,则选择None。
Message中选择该Notification要发送的Message.
Expand Roles若打勾,相对独立的Message会被发送出去。
Function中可以指定Post-notification function。有四种执行的模式respond、forward、transfer、timeout。当Notification System以respond模式执行完function之后,
workflow engine会再以run model的模式执行该post-function

To create a Function Activity:
Function Name中输入该Function Activity需要执行的function的名字,格式为:.
Function Type输入function的类型:PL/SQL Function\External Function\External Java Function
定义对应的function的时候必须根据standard API来定义。
Result type中同样选择与function返回结果相同的result type,即对应的lookup_type.可以选择None->没有返回值或workflow preocess不care function的返回结果。
若function中有参数,可以在function activity下建立属于该function的attribute。该attribute只对其对应的function有效,并不是对于整个process有效的。
可以将Item type上的attribute拉到function activity下,就会在function activity下出现一个与Item type上的attribute相同的attribute,function下的会自动引用
item type上的值。

To create an Event Activity
Event action中选择对应的action:
raise:raise an event to the bussiness Event system;
receive:receive an event from bussiness event system
send:Send an event directly from one event agent to another agent without re-raising the event to the Bussiness event system.

To create a Process activity
在开始画process diagram,得先建立一个process。Process是可以一层嵌套一层的。在嵌套的时候,外面一层的process可以根据嵌套在里面一层的process的结果来决定
下一步的动作。所以process会有个result type的属性。
Runnable若打勾,该process处于top-level,可以单独执行。若不打勾,不能单独的执行,只能有其他的process呼叫它才可以执行。


To define optional Activity details
当activity执行的过程中出错时,可以指定要运行哪个error process。在details的property中先指定error Item type(internal name),在指定其下的error process(internal name)。
指定的时候不需要在当前的workflow builder 的session中打开对应的error item type。
Error item type default为WFERROR,也可以自己定义。
自己定义error item type时必须包含两个attribute:
 WF_ADMINISTRATOR:定义将error notification发送给谁。
 error_itemout:判断error notification是否timeout。
 version:目前使用的版本。workflow总是使用最新的版本。
 
支持版本的activity:
1、Notifications
2、Functions
3、Events
4、Processes and subprocesses
5、Process activities (nodes)
6、Activity attributes
7、Activity attribute values
8、Activity transitions
 当你对以上的activity做了修改并重新保存到db里,workflow的loader会产生一个新的version,而不是把原来的盖掉。所以不用担心目前已经在跑的process里的activity。新的version只
 对新的version保存完之后才start的process有影响。
 
不支持Version的Object:
1、Item attributes
2、Messages
3、Lookups
4、PL/SQL code referenced by function activities
所以修改了以上的object的话,会立即影响正在运行的process。

Item attribute:
在work item 初始化时,会为每一个该item type的item attribute create一个runtime 的copy。所以在往work item中添加item attribute不会影响到已经initiate的work item。
除非调用API addItemAttr()或AddItemAttributeArray()来为已经initiate完毕的work item create相应的attribute。
由于Item attribute的关系,若修改PL/SQL的内容,当设计到刚新建的Item attribute,而又没使用API为已经initiate的work item create对应的attribute时会出错。

Message:
当需要发送Message时,Notification system为每个message attribute在notification table建一个notification attribute。而Message的其他不被替换的内容并不会做相应的copy。
所以在发送前若该了Message的static Text,会影响到准备发送的message。修改message时注意在添加新的token时,可能不会被替换掉。

第四章
Difining a workflow process Diagram
Transition:在diagram中以一个arrow展现,表示一个活动的结束及另一个活动开始。
如果一个activity有事先定一个result type,则必须将transition与其中的一个result相关联。
可以为有事先定义好result type的activity建立、、等transition。
:若没有其他的transition复合completion result,则会执行transition
:会忽略activity的result及其他的transition,而只执行transition
:当于设定的时间内activity还没有complete的话,就会cancel掉所有的与该activity有关的notification,并执行transition

按住Ctrl+alt,然后对一个object进行拖拉,即可实现复制功能。

Node页签:
label栏位:指定一个名词。若该Activity在Process里应用了多次,默认的会在Label(与Internal name一样)后加-N,可修改,只要不重复即可
Start/End:若是start或end,需要选择对应的属性,否则选Normal
Result:若process需要返回值,则需要为该process的每个End设定返回值,Result栏位
TimeOut:
 No Timeout:该activity不需要在规定的时间内完成
 Relative Time:可设定day,hour,minutes,限定时间
 Item Attribute:可在程式运行的过程中动态给定时间
Notification activity node就需要设定performer,performer为该notification需要sent的对象。


Rule:
Oracle workflow roles存储于Oracle workflow directory service database里面。目前在workflow builder里不能建立role,可以显示及引用
Notification activity必须指定一个performer,可以是一个designated role(特定角色) 或动态给值得item attribute。
assign performer给一个role时,必须从oracle workflow db中将role load到workflow builder session中。

如何load rule:
connect to db and open item type
File->load roles


第五章
如何使用workflow事先定义好的activity
 若要将一个activity拉入另一个处于不同data store的process时,需要先将activity复制到目标data store,再拉入到process。
 
And/Or activity
 若需要多个条件满足后才继续往下,则使用and;
 若只要某个条件满足即可往下,则使用or
 
Comparison activity:
 提供一个标准的方式来comparison两个number,date,text。
 Compare Date:Use to compare the value of an item type attribute of type Date with a constant date.
 Compare Number:Use to compare the value of an item type attribute of type Number with a constant number.
 Compare Text:Use to compare the value of two item type attributes of type Text.
All the Comparison activities call a PL/SQL procedure named WF_STANDARD.COMPARE.
 以上三个activity都有两个变量:
  Test Value:一个固定的number,date或text string。
  reference value:an item type attribute of type Number, Date,or Text.
 返回的值为:”Greater Than” ”Less Than” ”Equal” or ”Null” 

wait Activity:根据设定的时间将process暂挂

Launch Process Activity:可以在当前的process中启动另一个process。该process通过调用WF_STANDARD.LAUNCHPROCESS来启动process。
 该activity有6个activity attribute:
  Item Type:要启动的process的item type的internal name,必须给值
  Item key
  process name
  User key
  owner key
  Defer immediate

Noop Activity:
  什么都不做的activity。可以将其加入到process 中,并修改其名字为有意义的activity,以便提醒将来需要做什么。

Loop Counter Activity:
  可以限制procee通过某一个特定路径的次数。通过调用WF_STANDARD.LOOPCOUNTER 来实现。
  当loop的次数小于 Loop limit,就执行"Loop" transition 对应的Activity;当loop的次数大于Loop limit,执行"Exit" transition对应的activity

Start Activity:作为一个process 开始的标识,不执行任何的动作。该activity会call procedure:WF_STANDARD.NOOP.
End Activity:作为一个process 结束的标识。可以为该activity设定一个返回值,作为一个process结束后的返回值。该activity会call procedure:WF_STANDARD.NOOP.

Role Resolution Activity:
  你可以在执行一个notification前,通过该Activity,从包含多个user的role中挑选一个user做为notification的performer。
  调用WF_STANDARD.ROLERESOLUTION,
  有一个参数:METHOD,VALUE=Load Balance,选择open的notification少的user做为performer;
                    value= Sequential,按距离上次接收到该acitivity的notification时间的长度来决定,时间长的优先

Notify Activity:
 通过一个prior的function决定要通过Notify Activity function将message(不需要返回值)发送到哪里。                 
 参数:
 Message name:需要发送的message的名字。
 Performer
 Expand Roles:Yes or No
 

Vote Yes/No Activity:
  发送notification给某个role中的所有user,然后统计user返回的结果是Yes还是No,然后决定下一个动作是什么。
  有三个参数:
  Present Yes:到达百分几以上才返回yes
  Present No:到达百分几以上才返回No
  Voting Option:
     wait for All votes:Workflow Engine会等待所有的vote都cast完才去计算。若会设置timeout,则会在timeout前先计算已经cast的vote并返回结果
     Tally on every vote:随时做统计
     require all votes:等待所有的vote都已经cast后才去计算投票的结果,若timeout,则会走标准的timeout流程,若没有timeout流程,则报错。

Master/Detail Coordination Activities
 Wait for Flow Activity
   将Master/Detail中的某个acitivity暂停,直到另一个Detail/Master执行完某个特定的activity。
   参数:
   Continuation Flow:指定该Activity得等到相应的Master/Detail的process结束后才继续进行下来。
   Continuation Activity:指定该Activity等到相应的process执行到特定的activity后才继续往下走。
Continue Flow Activity:

第六章Defining Procedures and functions for workflow
Function或Notification activity所呼叫的procedure都应该以以下的模板来建立:

1=> procedure (itemtype in varchar2,
                                itemkey in varchar2,
                                actid in number,
                                funcmode in varchar2,
                                resultout out varchar2) is
2=>   
3=> begin
      if ( funcmode = ’RUN’ ) then
         
          resultout := ’COMPLETE:’;
          return;
      end if;
4=>   if ( funcmode = ’CANCEL’ ) then
         
          resultout := ’COMPLETE’;
          return;
      end if;
5=>   if ( funcmode = ’RESPOND’ ) then
         
          resultout := ’COMPLETE’;
          6 – 4 Oracle Workflow Developer’s Guide
          return;
      end if;
6=>   if ( funcmode = ’FORWARD’ ) then
         
          resultout := ’COMPLETE’;
          return;
      end if;
7=>   if ( funcmode = ’TRANSFER’ ) then
        
         resultout := ’COMPLETE’;
         return;
      end if;
8=>   if ( funcmode = ’TIMEOUT’ ) then
        
         if () then
            resultout := ’COMPLETE’;
         else
            resultout := wf_engine.eng_timedout;
         end if;
         return;
      end if;
9=>   if ( funcmode = ’’ ) then
         resultout := ’ ’;
         return;
      end if;
10=>exception
      when others then
      WF_CORE.CONTEXT (’’, ’’, ,
      , to_char(), );
      raise;
11=> end ;

1=>当workflow Engine call procedure时,需要传4个参数:
   itemtype:item type的internal name。
   itemkye : workflow-enabled application为该itemtype所产生的一个primary key
   actid  : procedure中的activity对应的ID number
  funcmode:Activity的execution mode.
       若call该procedure的activity是一个function activity的话,funcmode为RUN 或CANCEL
       RUN:当activity第一次执行时为RUN
       CANCEL: 当一个activity的On Revisit设定为Reset时,当循环执行到该activity时,mode为CANCEL
           当process的部分流程调用wf_engine.abortProcess()而cancel掉后,activity的mode为CANCEL
         (若该procedure由function activity调用,则5至9可以不用,因为只可能出现两种mode)
          

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/385592/viewspace-566523/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/385592/viewspace-566523/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值