Activiti Task Node Handler settings

Source: Internet
Author: User

1.1.1. Preface

Share the original ( respecting the original reprint right when the first line please specify, reproduced from the share of the source of cattle http://blog.csdn.net/qq_30739519)

When we use the Activiti workflow engine, the most common is definitely the task node, because in the OA System, approval system, office automation system, the core processing is the operation of the process, The operation of the process depends on how people are set up, and the staffing is a very important part, so if you can make the activiti workflow engine work at the core, it is necessary to support a strong staff organization architecture design. Let's start by talking about the activiti workflow engine itself that can be used directly. Let's take a look at how people are set up.

1.1.2. How to deal with human distribution

There are six ways to set up the handling of human beings, which makes it easy to set up handlers for task nodes in conjunction with the business, as shown in:

The task handler's settings are as follows:


Let's take a look at the specifics of each approach:

1.1.3. act_ru_identitylink

Because the handler in addition to directly set the way the designated person processing, theact_ru_identitylink table has no data, the other way is recorded in this table, so it is necessary to say this table structure, table structure as shown:

Act_ru_identitylink Table Structure Description:

task_id corresponds to the primary key in the act_ru_task id_

Type_: The corresponding category has starter Process instance initiator,candidate: node candidate

GROUP_ID: The ID primary key for the candidate group ,

USER_ID: id_ primary key for the corresponding person

REV_: Version number

where group_id,user_id is not necessarily the activiti workflow engine in the personnel relationship, it is possible to enable us to customize the personnel structure of the relationship, This is an important point to note, because later in the article, we will explain how to extend the Workflow staff architecture

1.1.4. The first way of assignee

In this way, the specific handler is specified, and theXML configuration information corresponds to the following:

1.1.4.1. XML

<usertask id= "Usertask1" name= "Business Purchase" activiti:assignee= "Share cow original" >      <extensionElements>  </ Usertask>

When we run we can see that the assignee_ field in the act_ru_task table lets us set the value


1.1.5. The second way of assignee variable

In this way, the specific handler is specified, and theXML configuration information corresponds to the following:

1.1.5.1. XML

<usertask id= "Usertask1" name= "Business Purchase" activiti:assignee= "${share Cow original}" >      <extensionElements>  </ Usertask>

run when the ${share the cow original} "to share the original variables of the cow to pass in, that is, the ${} inside the variable passed in, we can see when we run the act_ru_task table the assignee_ field allows us to set the value, note that this variable pass must be passed when the process has not reached the task node, otherwise when the process arrives at this node, the transfer variable will not be. Because the current node is setting the variable value information for the next node.

1.1.6. the way after the candidate group in the third Way

This way is to specify that more than one person to process, theXML configuration information corresponds to the following:

1.1.6.1. XML

<usertask id= "Usertask1" name= "Business Purchase"  activiti:candidateusers= "Share cow original" ></userTask>

When a candidate group is used, multiple is, split. For example, we need to set the current task handler is a,b,C Three people processing, then how do we set it? When set, we are set to a,b,c .

When the process runs to the current node, a,b,C Three people can query to the agent information, and then the corresponding operation.

Database changes are placed in the Act_ru_identitylink more than three records corresponding to the same task ID. Refer to the act_ru_identitylink described above.

1.1.7. The Third Way after the candidate group's way candidate Group is a collection

This way is to specify that more than one person to process, theXML configuration information corresponds to the following:

1.1.7.1. XML

<usertask id= "Usertask1" name= "Business Purchase"  activiti:candidateusers= "${share cow original}" ></userTask>

When set, we can specify a set, this set of variables, we run the program, but also, the form of segmentation, to pass the value, but it should be noted that this method must be a collection object, not a string type.

Look at the following two ways of assigning values:

The first way:

String candidateusers="A,b,c";

task. SetVariable ("Share cow original", candidateusers);

This way is wrong, the program runs when the error, error message is not to share the cow original this collection.

The correct way is as follows:

String [] candidateusers={"A","B","C"};

task. SetVariable ("Share cow original", Arrays. Aslist(candidateusers));

Database changes are placed in the Act_ru_identitylink more than three records corresponding to the same task ID. Refer to the act_ru_identitylink described above.

1.1.8. Fourth Way role

The way to do this is to specify multiple roles to process, and theXML configuration information corresponds to the following:

1.1.8.1. XML

<usertask id= "Usertask1" name= "Business Purchase" activiti:candidategroups= "Share cow original" ></userTask>

When a character is used, multiple is, split. For example, we need to set the current task processing role is a,b,C Three role processing, then how do we set it? When set, we are set to a,b,c .

When the process runs to the current node, a,b,c Three roles can be queried to the agent information, and then the corresponding operation.

Database changes are placed in the Act_ru_identitylink more than three records corresponding to the same task ID. Refer to the act_ru_identitylink described above.

1.1.9. Fifth way role of the way variable way

The way to do this is to specify multiple roles to process, and theXML configuration information corresponds to the following:

1.1.9.1. XML

<usertask id= "Usertask1" name= "Business Purchase" activiti:candidategroups= "Share cow original" ></userTask>

When set, we can specify a set, this set of variables, we run the program, but also, the form of segmentation, to pass the value, but it should be noted that this method must be a collection object, not a string type.

Look at the following two ways of assigning values:

The first way:

String candidateusers="A,b,c";

task. SetVariable ("Share cow original", candidateusers);

This way is wrong, the program runs when the error, error message is not to share the cow original this collection.

The correct way is as follows:

String [] candidateusers={"A","B","C"};

task. SetVariable ("Share cow original", Arrays. Aslist(candidateusers));

1.1.10. Sixth mode of listener

Listener mode, we can dynamically control, in this listener, we can query from the database corresponding to the person or role of the person, the way the variables are set in, to achieve a flexible multi-use.

The specific listener configuration is as follows:

The specific XML is as follows:

<usertask id= "Usertask1" name= "Business Sourcing" >      <extensionElements>        <activiti:tasklistener event= " Assignment "class=" Com.daling.bpmn.extend.MyTaskListener "></activiti:taskListener>      </ Extensionelements>    </userTask>

The specific listener implementation classes are as follows:

public class Mytasklistener implements Tasklistener {@Overridepublic void notify (Delegatetask Task) {String [] candidateu Sers={"A", "B", "C"};task.setvariable ("Share cow original", Arrays.aslist (Candidateusers));} }

1.1.11. Summary

the settings for the Activiti task node handler are summarized as follows:

1. Specify a specific handler, you can set the person using the variable method. You can also define it directly in the template.

2. Candidate groups, can be defined in the template, not flexible. Flexible approach, you can specify a variable assignment value.

3. Roles, can be defined in the template, not flexible. Flexible approach, you can specify a variable assignment value.

4. You can use task listeners to perform assignment operations.

5. Variables are flexible in the way they are defined and are not flexible because the person or role that handles the node can change.

1.1.12. Legacy points

The above several ways we summed up, the first is to designate people, groups, roles, this is typically a one-dimensional data structure, but the actual project, our personnel relations, generally, people, roles, departments, this is a two-dimensional structure, it is obvious that this way is not possible, because the program is no way, At the same time the area is a role or department, and we may have to the role, division, convergence, and more complex operations, so we still need to extend the workflow of people set this piece. Detailed explanations of the subsequent chapters.

Share cows, share, we are happy.

Activiti Task Node Handler settings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.