Oracle神谕

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  284 随笔 :: 9 文章 :: 106 评论 :: 0 Trackbacks

9.4. Swimlanes(咏道)
A swimlane is a process role(角色). It is a mechanism to specify that multiple tasks in the process should be done by the same actor.(多个任务被同一个用户执行) So after the first task instance is created for a given swimlane, the actor should be remembered in the process for all subsequent(后来的) tasks that are in the same swimlane. A swimlane therefore has one assignment and all tasks that reference a swimlane should not specify an assignment.

When the first task in a given swimlane is created, the AssignmentHandler of the swimlane is called. The Assignable that is passed to the AssignmentHandler will be the SwimlaneInstance. Important to know is that all assignments that are done on the task instances in a given swimlane will propagate to the swimlane instance. This behaviour is implemented as the default because the person that takes a task to fulfilling(实行) a certain process role will have the knowledge of that perticular process. So all subsequent(并发的) assignements of task instances to that swimlane are done automatically to that user.

Swimlane is a terminology(术语) borrowed from UML activity(活动) diagrams.

------------------------------------------------------------
9.5. Task events (任务事件)
Tasks can have actions associated with them. There are 4 standard event types defined for tasks: task-create, task-assign, task-start and task-end.

(1)task-create
 is fired when a task instance is created.

(2)task-assign
is fired when a task instance is being assigned. Note that in actions that are executed on this event, you can access the previous actor with executionContext.getTaskInstance().getPreviousActorId();
executionContext.getTaskInstance().getPreviousActorId();

(3)task-start
is fired when TaskInstance.start() is called. This can be used to indicate(指示) that the user is actually starting to work on this task instance. Starting a task is optional.

(4)task-end
 is fired when TaskInstance.end(...) is called. This marks the completion of the task. If the task is related to a process execution, this call might trigger the resuming(恢复) of the process execution.

Since tasks can have events and actions associated with them, also exception handlers can be specified on a task. For more information about exception handling, see Section 7.5, “Exception handling”.

---------------------------------------------------------------
9.6. Task timers(任务定时器)
As on nodes, timers can be specified(指定) on tasks. See Section 10.1, “Timers”.

The special(特别的) thing about timers for tasks is that the cancel-event for task timers can be customized(取消事件可以被定制). By default, a timer on a task will be cancelled when the task is ended (=completed). But with the cancel-event attribute on the timer, process developers can customize that to e.g. task-assign or task-start. The cancel-event supports multiple events.|取消事件支持多种事件| The cancel-event types can be combined by specifying them in a comma(逗号) separated list in the attribute.

9.7. Customizing task instances(定制任务实例)
Task instances can be customized. The easiest way to do this is to create a subclass of TaskInstance.|创建一个任务实例的子类| Then update the property jbpm.task.instance.class and specify the class name of your custom class that inherits from TaskInstance. Also create a hibernate mapping file for the subclass (using the hibernate extends="org.jbpm.taskmgmt.exe.TaskInstance"). Then add that mapping file to the list of mapping files in the hibernate.cfg.xml
(1)更新jbpm.task.instance.class 的属性
(2)指定继承TaskInstance的定制类
(3)创建一个子类的影射文件(使用 extends="org.jbpm.taskmgmt.exe.TaskInstance")
(4)将这个影射文件加到 hibernate.cfg.xml

9.8. The identity component(身份组件)
Management of users, groups and permissions is commonly known as identity management. jBPM includes an optional identity component that can be easily replaced by a company's own identity data store.

The jBPM identity management component includes knowledge of the organisational model. Task assignment is typically done with organisational knowledge. So this implies knowledge of an organisational model, describing the users, groups, systems and the relations between them. Optionally, permissions and roles can be included too in an organisational model. Various academic(理论的) research attempts failed, proving that no generic organisational model can be created that fits every organisation.

The way jBPM handles this is by defining an actor as an actual participant(参与者) in a process. An actor is identified by its ID called an actorId. jBPM has only knowledge(知道) about actorId's and they are represented as java.lang.Strings for maximum flexibility. So any knowledge about the organisational model and the structure of that data is outside the scope of the jBPM core engine.

As an extension to jBPM we will provide (in the future) a component to manage that simple user-roles model. This many to many relation between users and roles is the same model as is defined in the J2EE and the servlet specs and it could serve as a starting point in new developments. People interested in contributing should check the jboss jbpm jira issue tracker for more details. 用户和角色 (user-roles 模型)


Note that the user-roles model as it is used in the servlet, ejb and portlet specifications, is not sufficiently powerful for handling task assignments. That model is a many-to-many relation between users and roles. This doesn't include information about the teams and the organisational structure of users involved in a process.


The classes in yellow are the relevant(相关的) classes for the expression assignment handler that is discussed next.

A User represents a user or a service.|一个用户表现为一个用户或一个服务。| A Group is any kind of group of users.|一个组是任何种类用户组。| Groups can be nested to model the relation between a team, a business unit and the whole company.|组可以被内嵌到在团队、商业单元和整个公司的关系模型。 | Groups have a type to differentiate between the hierarchical groups and e.g. haircolor groups.|组可以有一个种类来区分分等级的组和haircolor组。| Memberships represent the many-to-many relation between users and groups. A membership can be used to represent a position in a company.|一个membership可以被用来表现在公司中的位置。| The name of the membership can be used to indicate(指出) the role that the user fullfills in the group.

9.8.2. Assignment expressions (分派表达式)
The identity component comes with one implementation that evaluates an expression for the calculation of actors during assignment of tasks. Here's an example of using the assignment expression in a process definition:

<process-definition>
  ...
  <task-node name='a'>
    <task name='laundry'>
      <assignment expression='previous --> group(hierarchy) --> member(boss)' />
    </task>
    <transition to='b' />
  </task-node>
  ...
Syntax of the assignment expression is like this:

first-term --> next-term --> next-term --> ... --> next-term

where

first-term ::= previous |
               swimlane(swimlane-name) |
               variable(variable-name) |
               user(user-name) |
               group(group-name)

and

next-term ::= group(group-type) |
              member(role-name)

9.8.2.1. First terms
An expression is resolved(分解) from left to right.|一个表达式被从左到右进行分解| The first-term specifies a User or Group in the identity model.|第一个项目是在身份模型中指定了一个用户或组| Subsequent terms calculate the next term from the intermediate(中间的) user or group.

previous means the task is assigned to the current authenticated actor. This means the actor that performed the previous step in the process.

swimlane(swimlane-name) means the user or group is taken from the specified swimlane instance.

variable(variable-name) means the user or group is taken from the specified variable instance. The variable instance can contain a java.lang.String, in which case that user or group is fetched from the identity component. Or the variable instance contains a User or Group object.

user(user-name) means the given user is taken from the identity component.

group(group-name) means the given group is taken from the identity component.

9.8.2.2. Next terms
group(group-type) gets the group for a user. Meaning that previous terms must have resulted in a User. It searches for the the group with the given group-type in all the memberships for the user.

member(role-name) gets the user that performs a given role for a group. The previous terms must have resulted in a Group. This term searches for the user with a membership to the group for which the name of the membership matches the given role-name.

9.8.3. Removing the identity component
When you want to use your own datasource for organisational information such as your company's user database or ldap system, you can just rip out the jBPM identity component. The only thing you need to do is make sure that you delete the line ...

<mapping resource="org/jbpm/identity/hibernate/identitymappings.hbm.xml"/>
from the hibernate.cfg.xml

The ExpressionAssignmentHandler is dependent on the identity component so you will not be able to use it as is. In case you want to reuse the ExpressionAssignmentHandler and bind it to your user data store, you can extend from the ExpressionAssignmentHandler and override the method getExpressionSession.

protected ExpressionSession getExpressionSession(AssignmentContext assignmentContext);

posted on 2005-06-15 13:42 java世界畅谈 阅读(941) 评论(0)  编辑  收藏 所属分类: 工作流

只有注册用户登录后才能发表评论。


网站导航: