Other-03-activiti Study Notes-Overview

Source: Internet
Author: User

Workflow development Core Process Analysis 1. Drawing flowchart The first step in the development of Activiti is to draw a flowchart according to the requirements, the flowchart defines how the process is carried out, the conditions of the process jump, and so on. The definition of a flowchart is not a discretionary definition, but a definition based on business requirements.
Draw a flowchart under Eclipse, first install the Activiti plug-in, and then you can create a new Activiti diagram. Drawing Activiti diagram is simple, only a few important: 1) a process must have a start node and an end node, the start node can only have outcomeline, the end node can only be incomeline.        2) A connection can have a name or not, but suggested, and written in the form of consent/refusal, the final can be in the program to get the name, directly splicing on the page.        3) A task node must have a person (personal task) or one of the group (group tasks), this person (group) can be written to die, can also be written as placeholder form (#{assignee}). 4) A Task node if there is only one outcomeline, then this outcomeline can not set the condition, if a task node has more than one outcomeline, each outcomeline must indicate the condition, if the runtime does not meet any of the conditions will be an error , the condition indicates that a Boolean placeholder (#{condition = = true}) is used. 2. Deployment process Activiti After the flowchart is finished, you need to deploy it, and after the Repositoryservice is deployed, you will get aDeploymentdeployment objects, one or more processdefinition process definition objects are hung underneath a deployment object (depending on how many BPMN flowchart files are loaded by this deployment). Repositoryservice is also responsible for managing all the crud associated with the deployment/process definition. if a BPMN file with the same ProcessID is loaded multiple times, the file is parsed into a process definition, and ProcessID is the same, a version upgrade is raised. 3. After the task has been deployed, the entire workflow is ready to start a process through runtimeservice, and the process begins with a ProcessInstance process instance and a task task instance.    After that, you just need to push this task to complete the process.    When you start the process, you can optionally add process variables to help the workflow engine complete the selection of branches. Use...    The Bykey () series begins with a task that always selects the latest version of the process definition. When you start a task, you can optionally add a Businesskey field that represents the key to the business, and this businesskey can be used to find the business instance that corresponds to the process instance. 4. Complete the task 1) Personal Tasks         The completion of a personal task requires only the process variables to be provisioned, two types of process variables need to be provisioned, one is about the selection of the process variables related to the connection, and one is about the next-to-operator-related process variables. Then call Taskservice.completetask (...) to complete the task.
2) Group Tasks         The completion of a group task requires the task to be picked up first, using the current user to pick up the group task, the Taskservice.cliam () function is used to pick up the task, then the group task becomes a personal task, follow the rules of individual tasks. A task that was originally a group task that was picked up will become a personal task, and the task can also be taskservice.setassignee (, null) back to the group task. 3) Task annotations         For a task, each performer can choose to add a comment (and can be added multiple times), before completing the task, call Authentication.setauthenticateduserid () to set the user ID of the current annotation (typically set to the name of the person who wrote the annotation, This name will be displayed at the end of the show), and then call Taskservice.addcomment (...) to annotate the task.
5. Query to do task/query history task 1) query the rules of the to-do task query for the first time according to the taskinstance to do tasks, and then from the to-do task to find the ProcessInstance process instance, and then through the process instance to get Businesskey , you can get the business data, and then you can get the annotation information via ProcessInstance (Taskservice.getprocessinstancecomments (...).    )。 2) Query history task rule with query to-do task, but call is Historicservice.
Workflow development Expansion Process Analysis 1. Exclusive Gateway an exclusive gateway is a diamond-shaped, middle-crossed graph. An exclusive gateway is roughly equivalent to a task with more than one outcomeline, but multiple outcomeline tasks must specify their condition for each oucomeline connection, and the exclusive gateway can N-1 a outcomeline-specified line    , the remaining connection is the default value. When drawing, click the exclusive gateway and select default flow. 2. Parallel Gateway Parallel Gateway is a diamond, a cross in the middle of the graph. Parallel gateways represent a set of tasks that occur in parallel, a parallel gateway must be paired, a parallel spread, a parallel band, and each of the processes between the separation and the band is composed of an execution object (performing Object analysis reference Table Analysis), and these processes are executed in parallel, If one of the processes has reached the band node, it waits for the other process to reach the node. 3. Get the connection by transforming ProcessInstance to processinstanceentity, you can get some additional process information (values in the deployed BPMN file). The Workflow Table Analysis workflow engine automatically creates 25 tables, mainly divided into 5 large groups of 1) Act_ge_ ...  Global Attribute Group 2) Act_hi_ ...  Historical Information Group 3) Act_id_ ...  Authentication Information Group (not used) 4) act_re_ ...  Warehouse Information Group 5) Act_ru_ ... Run-time Information Group
Only important and used tables are analyzed below.




1) Deployment1. When the deployment starts, the ID of the next database key is queried from the Act_ge_property table, which also has some meta information from the current workflow engine to detect whether the current workflow engine matches the database version, so Act_ge_property        A table is a database meta-information table. 2. The deployment information is then inserted into the Act_re_deployment table, including the ID of the deployment, the name of the deployment, the deployment time, and so on, so the records in the Act_ge_deployment table are the records of the deployment, so act_ge_deployment        The table is the Deployment information table. 3. In the future, you will insert the deployed BPMN file and resource file into the Act_ge_bytearray table, so deployment_id_ in this table is the foreign key for the Deployment information table Id_.so Act_ge_bytearray is the serialized Resource table. 4. All BPMN files are then parsed to generate the process definition information, which is inserted into the Act_procdef_info table, and the information in this table is parsed by the BPMN serialization file stored in the Act_ge_bytearray table, so act_ The info_json_id in the Procdef_info table is id_ in the Act_ge_bytearray table. So act_procdef_info represents the process definition parsing result information table. 5. The workflow engine then loads a process definition into the Act_re_procdef table, which is the real process definition object table.
Conclusion:One deployment corresponds to multiple resources, the resource is a BPMN serialized object, and a BPMN serialization object corresponds to a process definition parsing result, so one deployment corresponds to multiple resources, and the BPMN file in the resource corresponds to the process definition object one by one. So a deployment can also correspond to multiple process definition objects. All act_re_ ... The table for the series is a table of persisted objects.
2) The process1. When calling Runtimeservice.startprocessby ... (...) , the process information is extracted from the Process definition object Table Act_re_procdef, and a process instance is created (the process definition is a class, the process instance is the feeling of the object), and is inserted into the Act_ru_execution table. The process instance represents the entire process from start to finish, no matter what path, and also an object, called the execution object, in the Act_ru_execution table, Id_ represents the Execution object id,proc_inst_id_ represents the process instance ID, if it is a single-line process, Then the execution object ID and the process instance ID are the same, and there is only one data in the table, which represents both the execution object and the process instance, and if it is a multi-line process (parallel gateway), there will be two sets of data, the first set is the process instance object, the object id_ and proc_inst_id_ are equal, And this object only corresponds to one piece of data, the second group is the execution object, there are a few parallel lines there are several execution objects, this group of records id_ represents the Execution object id,proc_inst_id_ represents the process instance ID, they are not equal.        So act_ru_execution is the Execution object table.        2. When there is an execution object in the Act_ru_execution table, the executing object is bound to have a task, the task is each node in the process, the task is inserted in the Act_ru_task table, so act_ru_task represents the task log table. 3. Each task must have a person, for the personal task of the person is the Act_ru_task table in the Assignee_ field, for group tasks, the processing group in the Act_ru_identitylink table, a one-to-many relationship. SoAct_ru_identitylinkrepresents the Group task Person table. 4. Each process instance has its own process variables, the process variables can be set at the start of the task, or can be set when the task is completed, or can be set directly, the process variables will exist in the Act_ru_variables table, the general set of process variables are the owner of the process instance, but if set is the Local process variable, then the Task_id_ field in the Act_ru_variables table also has a value, which means that the process variable is bound to the task. So act_ru_variables represents the process variable table. Conclusion: Act_ru_ ... The table for the series is the runtime's record table, and all the run-time state flows are recorded in these tables.
3) Finish/End Task/comment1. When a task is completed, the task record is deleted from the Act_ru_task table, then flows to the next task, inserts the record of the next task, and if there is no next task, the entire process executes, there is no new task record, and the life cycle of the execution object/process instance ends , the record is removed.        When the task/process instance is removed, the process variables/annotations for the outside key are also removed. 2. When all process instances/tasks/process variables/annotation/group tasks are created, the records are inserted into their corresponding history tables, respectively, corresponding to the Act_hi_proc_inst/act_hi_taskinst/act_hi_varinst/act_hi_ Comment/act_hi_identitylink, annotations do not have a run-time table and are inserted directly into the history table when created. And when each activity is executed (including the start task/End Task/etc.), the record is inserted into the Act_hi_actinst table. Conclusion: Act_hi_ ... Series tables are history tables, and all historical data is recorded in these tables.

From for notes (Wiz)

Other-03-activiti Study Notes-Overview

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.