Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| devel:documentation:workflows:dev:workflow [2020/06/25 14:52] – [Sending notifications] svandav | devel:documentation:workflows:dev:workflow [2026/04/09 08:39] (current) – kolombom | ||
|---|---|---|---|
| Line 6: | Line 6: | ||
| Its advantage lies in integration with Spring framework and it is easy to use in ours devstack. Activiti Platform sets up Rest Api and like that it will be using most of it's functionalities. By running Rest and Activiti Platform on a stand-alone application server, we can communicate even with a non-Java environment. Disadvantage of this solution is lossage of direct Java integration. It is possible to call Spring beans directly from workflow process (by [[http:// | Its advantage lies in integration with Spring framework and it is easy to use in ours devstack. Activiti Platform sets up Rest Api and like that it will be using most of it's functionalities. By running Rest and Activiti Platform on a stand-alone application server, we can communicate even with a non-Java environment. Disadvantage of this solution is lossage of direct Java integration. It is possible to call Spring beans directly from workflow process (by [[http:// | ||
| - | |||
| <note tip> | <note tip> | ||
| - | | + | |
| - | * **/ | + | |
| - | * **/ | + | * **/ |
| + | * **/ | ||
| </ | </ | ||
| - | =====Design of process===== | + | ===== Design of process ===== |
| - | Design of workflow process is realized with XML in format BPM 2.0. It is very helpful to use Activiti Designer. It is [[http:// | + | |
| + | Design of workflow process is realized with XML in format BPM 2.0. It is very helpful to use Activiti Designer. It is [[http:// | ||
| **Sample of Activiti process in IDE Eclipse plugin:** | **Sample of Activiti process in IDE Eclipse plugin:** | ||
| - | {{ : | + | {{ : |
| - | =====Example of usage Expression Language===== | + | ===== Example of usage Expression Language ===== |
| - | In our example of EL (lower), there is an option to assembly description of user's task. There is element " | + | In our example of EL (lower), there is an option to assembly description of user's task. There is element " |
| Because of this procedure, we need in process attributes identifiers. With identifiers and EL expressions, | Because of this procedure, we need in process attributes identifiers. With identifiers and EL expressions, | ||
| - | |||
| < | < | ||
| + | |||
| < | < | ||
| - | activiti: | + | |
| < | < | ||
| ${defaultIdmRoleService.get(roleIdentifier).name} vedoucím pro uživatele | ${defaultIdmRoleService.get(roleIdentifier).name} vedoucím pro uživatele | ||
| Line 35: | Line 36: | ||
| </ | </ | ||
| </ | </ | ||
| + | |||
| </ | </ | ||
| - | =====User task===== | + | ===== User task ===== |
| - | Workflow activity **UserTask** can assign a task to a specific user by attribute **assignee**. The task can have just one assignee. If we want to assign more users, who can solve the task, we use attribute **candidateUsers**. | + | |
| + | Workflow activity **UserTask** | ||
| In this step there are no differences between assignee and candidateUsers. If a user is assignee or is in a list of **candidateUsers**, | In this step there are no differences between assignee and candidateUsers. If a user is assignee or is in a list of **candidateUsers**, | ||
| - | =====Service task===== | + | ===== Service task ===== |
| Service task is activity run automatically by the system. Code, which will be executed, can be defined: | Service task is activity run automatically by the system. Code, which will be executed, can be defined: | ||
| + | |||
| * In Java class, which path is defined in attribute **class**. | * In Java class, which path is defined in attribute **class**. | ||
| * In Java class implementing JavaDelegate. | * In Java class implementing JavaDelegate. | ||
| * **By Experssion Language**. | * **By Experssion Language**. | ||
| + | In our example of EL (lower) is definition of service activity, which run expression **# | ||
| - | In our example of EL (lower) is definition of service activity, which run expression **# | + | This expression calls method **addRole** |
| - | + | ||
| - | This expression calls method **addRole** for adding a new role. The new role will be passed to **newIdmIdentityRole** process, which contains new link DTO between role and user. | + | |
| - | Of service **defaultIdmIdentityService** method **addRole** is called from Spring context. | + | |
| - | + | ||
| < | < | ||
| Line 60: | Line 62: | ||
| | | ||
| </ | </ | ||
| + | |||
| </ | </ | ||
| - | =====Script task===== | + | ===== Script task ===== |
| Script task activity allows run scripts defined in the workflow. Workflow supports JavaScript and Groovy. We will be using Groovy for it's performance and specific implementation version (in pom.xml). JavaScript engine is part of Java and implementation version will depend on the version on which version whole application will run. | Script task activity allows run scripts defined in the workflow. Workflow supports JavaScript and Groovy. We will be using Groovy for it's performance and specific implementation version (in pom.xml). JavaScript engine is part of Java and implementation version will depend on the version on which version whole application will run. | ||
| - | The script is used, when EL cannot make expression we want. For example of iteration or creation new instance of Object and setting attributes. In our example (lower) we are creating new instance of link object between role and user and object is filled by identificators. This instance is then put in process variables with key **newIdmIdentityRole** execution.setVariable(" | + | The script is used, when EL cannot make expression we want. For example of iteration or creation new instance of Object and setting attributes. In our example (lower) we are creating new instance of link object between role and user and object is filled by identificators. This instance is then put in process variables with key **newIdmIdentityRole** |
| < | < | ||
| - | < | + | < |
| | | ||
| - | | + | |
| - | | + | |
| | | ||
| < | < | ||
| | | ||
| - | | + | |
| - | | + | ir.setRole(roleIdentifier); |
| - | | + | ir.setValidFrom(validFrom); |
| - | | + | ir.setValidTill(validTill); |
| | | ||
| </ | </ | ||
| </ | </ | ||
| + | |||
| </ | </ | ||
| - | =====Email Task===== | + | |
| + | ===== Email Task ===== | ||
| Email task activity sends emails. Our emailer (EmailService) is injected into workflow engine, so it is possible disable sending notification (e.g. for debuging). Email can be send to specific identity by putting in username instead of email address. | Email task activity sends emails. Our emailer (EmailService) is injected into workflow engine, so it is possible disable sending notification (e.g. for debuging). Email can be send to specific identity by putting in username instead of email address. | ||
| Line 106: | Line 113: | ||
| </ | </ | ||
| </ | </ | ||
| + | |||
| </ | </ | ||
| - | =====Workflow localization===== | + | ===== Workflow localization ===== |
| {{tag> localization}} | {{tag> localization}} | ||
| Line 118: | Line 127: | ||
| * **Task name** | * **Task name** | ||
| * **Task description** | * **Task description** | ||
| - | |||
| ==== How translate the name of a workflow process ==== | ==== How translate the name of a workflow process ==== | ||
| - | For example, we will be using basic process for change the user permission ' | + | For example, we will be using basic process for change the user permission ' |
| - | This process contains activity with name ' | + | |
| Without translation looks code this: | Without translation looks code this: | ||
| Line 128: | Line 135: | ||
| <code java> | <code java> | ||
| | | ||
| + | |||
| </ | </ | ||
| Line 136: | Line 144: | ||
| <code java> | <code java> | ||
| | | ||
| + | |||
| </ | </ | ||
| Line 148: | Line 157: | ||
| } | } | ||
| } | } | ||
| + | |||
| </ | </ | ||
| - | Where ' | + | Where ' |
| ==== Translation with the context ==== | ==== Translation with the context ==== | ||
| Line 158: | Line 168: | ||
| <code java> | <code java> | ||
| | | ||
| + | |||
| </ | </ | ||
| Line 167: | Line 178: | ||
| } | } | ||
| } | } | ||
| + | |||
| </ | </ | ||
| + | |||
| ==== How translate the name and description of a workflow task ==== | ==== How translate the name and description of a workflow task ==== | ||
| - | For example, we will be using again basic process for change the user permission ' | + | For example, we will be using again basic process for change the user permission ' |
| - | This process contains activity with the name ' | + | |
| We creates translation in the frontend for this task. In the localization file (usually in the / | We creates translation in the frontend for this task. In the localization file (usually in the / | ||
| Line 186: | Line 198: | ||
| } | } | ||
| } | } | ||
| + | |||
| </ | </ | ||
| - | Where ' | + | Where ' |
| Usually we want translate documentation for process task. In our example contains documentation of the ' | Usually we want translate documentation for process task. In our example contains documentation of the ' | ||
| Line 194: | Line 207: | ||
| <code javascript> | <code javascript> | ||
| | | ||
| + | |||
| </ | </ | ||
| - | It means, documentation contains the name of a process with wrapped variable contains the name of the applicant. | + | It means, documentation contains the name of a process with wrapped variable contains the name of the applicant. We will uses this variable in translation on the frontend. In the localization file (usually in the / |
| - | We will uses this variable in translation on the frontend. In the localization file (usually in the / | + | |
| <code javascript> | <code javascript> | ||
| Line 211: | Line 224: | ||
| } | } | ||
| } | } | ||
| + | |||
| </ | </ | ||
| Translation of description contains variable with the name of applicant again. | Translation of description contains variable with the name of applicant again. | ||
| - | <note tip>If none transaltion for task in the specific workflow is found, then we try find translation without workflow ID (for example ' | + | <note tip>If none transaltion for task in the specific workflow is found, then we try find translation without workflow ID (for example ' |
| - | + | ||
| - | =====Passage of workflow - solver decision===== | + | |
| - | The main principle of the workflow process is a creation of user task. An assigned user must decide how this task will be solved. The development of process is dependent on assign user's decision. We can explain further in an example of process assign role. A user will make a request to assign himself a specific role. A task is created and will be assigned to superior of the requester. Superior will decide if he agrees to assign a role to the requester or not. This **decision** will be **assessed**. In case of rejection, task will be terminated, otherwise, process will continue with next round of decisions. | + | |
| - | It is important to properly define process, so solver will clearly know, of which possibilities he has to choose. And this has to be determined in each user's task. After termination of user's task, evaluation of decision have to be implemented. | + | ===== Passage of workflow - solver decision ===== |
| + | |||
| + | The main principle of the workflow process is a creation of user task. An assigned user must decide how this task will be solved. The development of process is dependent on assign user's decision. We can explain further in an example of process assign role. A user will make a request to assign himself a specific role. A task is created and will be assigned to superior of the requester. Superior will decide if he agrees to assign a role to the requester or not. This **decision** | ||
| + | |||
| + | It is important to properly define process, so solver will clearly know, of which possibilities he has to choose. And this has to be determined in each user's task. After termination of user's task, evaluation of decision have to be implemented. | ||
| + | |||
| + | ==== Definition of decisions ==== | ||
| - | ====Definition of decisions==== | ||
| Definition of decisions in user tasks have to be more complex than text represented of code enumeration " | Definition of decisions in user tasks have to be more complex than text represented of code enumeration " | ||
| Line 228: | Line 244: | ||
| Decision attributes: | Decision attributes: | ||
| - | * **id** - Decision' | ||
| - | * **label** - Description of decision for user (" | ||
| - | * **level** - It sets design of button (" | ||
| - | * **tooltip** - Description in detail ("By approving you will agree with terms and conditions" | ||
| - | * **showWarning** - Defines if warning message will be shown on end of terminating task (true/ | ||
| - | * **warningMessage** - Defines contend of showWarning message ("Do you really want to approve request?" | ||
| - | * **permissions** - Defines required permissions, | ||
| - | * **skipValidation** - If you not used this attribute the behavioral will same as if you set it to false. When you set it to true then the validation of form(userTask) will be ignored. | ||
| - | ===From properties=== | + | * **id** |
| + | * **label** | ||
| + | * **level** | ||
| + | * **tooltip** | ||
| + | * **showWarning** | ||
| + | * **warningMessage** | ||
| + | * **permissions** | ||
| + | * **skipValidation** | ||
| + | * **reasonRequired ** - This property set to true enforces decision reason to be provided. | ||
| + | === From properties === | ||
| We created our decision system, because Aktiviti does not have decision system. On the other hand, Aktiviti allows define **form properties**. This system allows set for each user's activity, which process attributes will be shown. | We created our decision system, because Aktiviti does not have decision system. On the other hand, Aktiviti allows define **form properties**. This system allows set for each user's activity, which process attributes will be shown. | ||
| - | In our example (lower) there are two **properties** defined in user task. The first property has id " | + | In our example (lower) there are two **properties** |
| < | < | ||
| < | < | ||
| - | < | + | < |
| ${defaultIdmIdentityService.get(identityIdentifier).getUsername()}. | ${defaultIdmIdentityService.get(identityIdentifier).getUsername()}. | ||
| </ | </ | ||
| < | < | ||
| - | < | + | < |
| id=" | id=" | ||
| name=" | name=" | ||
| Line 255: | Line 273: | ||
| required=" | required=" | ||
| </ | </ | ||
| - | < | + | < |
| - | id=" | + | id=" |
| - | name=" | + | name=" |
| - | type=" | + | type=" |
| - | readable=" | + | readable=" |
| - | writable=" | + | writable=" |
| required=" | required=" | ||
| </ | </ | ||
| </ | </ | ||
| + | |||
| </ | </ | ||
| - | ===Decision=== | + | === Decision === |
| - | In previous article we described how **form properties** works. We do not want return complex definition of decison as string, so we need new data typ. Our data type is registered by Spring configuration in Aktiviti engine as **DecisionFormType** with key **decision**. | + | |
| + | In previous article we described how **form properties** | ||
| Decision values are defined by workflow definition as JSON objects and these values are written at creation of task (**approve**, | Decision values are defined by workflow definition as JSON objects and these values are written at creation of task (**approve**, | ||
| Line 274: | Line 294: | ||
| < | < | ||
| < | < | ||
| - | < | + | < |
| " | " | ||
| </ | </ | ||
| Line 281: | Line 301: | ||
| < | < | ||
| < | < | ||
| - | < | + | < |
| " | " | ||
| </ | </ | ||
| Line 288: | Line 308: | ||
| < | < | ||
| < | < | ||
| - | < | + | < |
| vedoucímu?", | vedoucímu?", | ||
| </ | </ | ||
| </ | </ | ||
| </ | </ | ||
| - | </ | ||
| + | </ | ||
| - | Access to these attributes is realized by form properties (type = decision). In our example (lower) there is user's task, which has form properties **approve** and **disapprove**. In this activity user will have two decision options (buttons). | + | Access to these attributes is realized by form properties (type = decision). In our example (lower) there is user's task, which has form properties **approve** |
| < | < | ||
| Line 305: | Line 325: | ||
| </ | </ | ||
| </ | </ | ||
| - | </ | ||
| + | </ | ||
| - | ====Evaluation of decision==== | + | ==== Evaluation of decision ==== |
| We already described how to define decision for user's activity, Now we will evaluate decisions in process. | We already described how to define decision for user's activity, Now we will evaluate decisions in process. | ||
| - | Before closing user's task, Aktiviti engine is called with form properties values and decision' | + | Before closing user's task, Aktiviti engine is called with form properties values and decision' |
| - | In next step component **exclusiveGateway** (XOR) is used. This component evaluate conditions on each outgoing path, if evaluation of path is **true**, process will continue on this path. If all outgoing paths are evaluated as **false**, exception is thrown. | + | In next step component **exclusiveGateway** |
| - | + | ||
| - | In our example (lower) is defined two outgoing paths - **sequenceFlow**. The first path has condition **${decision.equals(" | + | |
| + | In our example (lower) is defined two outgoing paths - **sequenceFlow**. The first path has condition **${decision.equals(" | ||
| < | < | ||
| Line 327: | Line 346: | ||
| < | < | ||
| </ | </ | ||
| + | |||
| </ | </ | ||
| - | =====Dynamic detail of task===== | + | ===== Dynamic detail of task ===== |
| - | We described **Form properties** as process attributes, which will be shown in user's task and we defined **decisions** as buttons for controlling the flow (paths) in process. Form properties can be used for dynamic design for each task. | + | |
| + | We described **Form properties** | ||
| Principle is similiar to **decision**. In process is definition, which components will be used, and on the frontend side is by that definition generated detail by using default frontend components. Aktiviti engine by default provide a few components (**string**, | Principle is similiar to **decision**. In process is definition, which components will be used, and on the frontend side is by that definition generated detail by using default frontend components. Aktiviti engine by default provide a few components (**string**, | ||
| Line 336: | Line 357: | ||
| But these components are insufficient, | But these components are insufficient, | ||
| - | * **textArea** - It will be shown as one-line field (as additional options, key " | + | * **textArea** |
| - | * **textField** - It will be shown as multiline editor (as additional options, key " | + | * **textField** |
| * **date** | * **date** | ||
| - | * **checkbox** - Shows as checkbox. | + | * **checkbox** |
| - | * **selectBox** - Show as selectbox. It is using EnumSelectBox component. | + | * **selectBox** |
| - | * **taskHistory** - It can show previous tasks from WF in table. | + | * **taskHistory** |
| Each component has additional settings **From property**: | Each component has additional settings **From property**: | ||
| - | * **id** - Unique component identifier in single process. If attribute **variables** is not filled, then id even define process attribute. | ||
| - | * **name** - Name, which will be used as description of component (label). It is possible to use final text or localization key. | ||
| - | * **type** - Type of component. See above (textArea, textField, etc.). | ||
| - | * **variable** - Defines process attribute, which can be used in component (value can be read, but also result can be written). | ||
| - | * **expression** - Expression (EL) can be defined here. Expression will be executed at start of the task and result will be used as value of component. | ||
| - | * **readable** - Defines, if component will be shown (default value is **true**). | ||
| - | * **writable** - Defines, if component could be edited (default value is **true**). | ||
| - | * **required** - Defines, if value will be mandatory (default value is **false**). | ||
| - | <note tip> | + | * **id** |
| + | * **name** | ||
| + | * **type** | ||
| + | * **variable** | ||
| + | * **expression** | ||
| + | * **readable** | ||
| + | * **writable** | ||
| + | * **required** | ||
| + | <note tip> | ||
| - | ===Example of user's task selectBox: | + | === Example of user's task selectBox: === |
| - | {{: | + | |
| - | Data which are displayed in selectBox can be set via Map< | + | {{.:selectbox.png}} |
| - | You can set options directly in WF without service on BE. Just use field Default in Form property configuration | + | |
| - | ===Example of user's task taskHistory: | + | Data which are displayed in selectBox can be set via Map< |
| - | {{:devel:documentation: | + | |
| - | Data which are displayed in table can be set via List< | + | === Example of user's task taskHistory: |
| + | {{.: | ||
| + | Data which are displayed in table can be set via List< | ||
| In our user's task example (lower) there are generated frontend result and definition in XML. | In our user's task example (lower) there are generated frontend result and definition in XML. | ||
| - | ===Example of user's task with dynamic detail: | + | === Example of user's task with dynamic detail: === |
| - | {{ : | + | |
| - | ===Example of user's task definition with dynamic detail:=== | + | {{ : |
| + | |||
| + | === Example of user's task definition with dynamic detail: === | ||
| < | < | ||
| - | < | + | < |
| < | < | ||
| < | < | ||
| Line 388: | Line 409: | ||
| < | < | ||
| </ | </ | ||
| - | < | + | < |
| < | < | ||
| </ | </ | ||
| </ | </ | ||
| + | |||
| </ | </ | ||
| - | =====Custom task detail===== | + | |
| + | === Setting solver note message - decision reason === | ||
| + | |||
| + | The task solver is able to set a reason of the decision or any other note to the solved task. The text area serving to this purpose is part of the confirmation modal window which appears, when user clicks the decision button. Display of this modal window (see in the picture below) has to be enabled by '' | ||
| + | |||
| + | {{ .: | ||
| + | |||
| + | When the task is solved the solver' | ||
| + | |||
| + | {{.: | ||
| + | |||
| + | **Configuration** | ||
| + | |||
| + | There exist several ways how to configure solver notes. The general approach is the setting from workflow. Workflow bpmn20 file contains the following section which is used for configuration of decision buttons in userTask. The section looks like this: | ||
| + | < | ||
| + | |||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | </ | ||
| + | |||
| + | <note tip> To avoid the need of workflow modification and an easy configuration of the most common decisions i.e. '' | ||
| + | |||
| + | '' | ||
| + | |||
| + | If decision button '' | ||
| + | |||
| + | ===== Custom task detail ===== | ||
| Dynamic definition of components provide us with quick and easy way to add another item to task. But even this system has a few disadvantages: | Dynamic definition of components provide us with quick and easy way to add another item to task. But even this system has a few disadvantages: | ||
| - | * Components cannot interact with each other. | + | * Components cannot interact with each other. * Cannot modified placement of each component on task detail (except for order). * Cannot show complex components like tables with specific properties (show detail, specific filtr, etc.). |
| - | * Cannot modified placement of each component on task detail (except for order). | + | |
| - | * Cannot show complex components like tables with specific properties (show detail, specific filtr, etc.). | + | |
| But if some of these feature is necessary on task detail, yet it can be made by specially created detail, which can be modified as you wish. it means, in frontend will be created new component (page), which will be used in specific task. | But if some of these feature is necessary on task detail, yet it can be made by specially created detail, which can be modified as you wish. it means, in frontend will be created new component (page), which will be used in specific task. | ||
| - | Usage of this specially created detail is setted in user's task detail with parameter **Form key**. If this parameter is filled, **DynamicTaskDetail** will not be used, but component with same name as value of Form key parameter will be used. | + | Usage of this specially created detail is setted in user's task detail with parameter **Form key**. If this parameter is filled, **DynamicTaskDetail** |
| < | < | ||
| < | < | ||
| + | |||
| </ | </ | ||
| - | |||
| <note tip> | <note tip> | ||
| Line 424: | Line 474: | ||
| ] | ] | ||
| }; | }; | ||
| + | |||
| </ | </ | ||
| - | + | ===== Localization ===== | |
| - | =====Localization===== | + | |
| There are three ways to name buttons in decision: | There are three ways to name buttons in decision: | ||
| - | * **Custom text** - If we do not want to create localization we can put in custom text. We could put " | ||
| - | * **Localization key** - If we want use specific localization translation, | ||
| - | * **Automatic assembly of localization key** - If we do not fill value **label**, this value will be filled automatically in form **decision.approve.label**, | ||
| + | * **Custom text** | ||
| + | * **Localization key** - If we want use specific localization translation, | ||
| + | * **Automatic assembly of localization key** - If we do not fill value **label**, this value will be filled automatically in form **decision.approve.label**, | ||
| < | < | ||
| - | <note tip>In similar way works localization for items in dynamic generated detail task. Automatic key uses prefix **formData**. Supported items are **name**, **tooltip**, | + | <note tip>In similar way works localization for items in dynamic generated detail task. Automatic key uses prefix **formData**. Supported items are **name**, **tooltip**, |
| **Localization example** | **Localization example** | ||
| + | |||
| < | < | ||
| " | " | ||
| Line 484: | Line 535: | ||
| } | } | ||
| } | } | ||
| + | |||
| </ | </ | ||
| - | =====Sending notifications===== | + | ===== Sending notifications ===== |
| There is global configuration in application properties, which can turned on or off sending notifications from UserTask. | There is global configuration in application properties, which can turned on or off sending notifications from UserTask. | ||
| + | |||
| < | < | ||
| # Global property that allow disable or enable sending notification from WF | # Global property that allow disable or enable sending notification from WF | ||
| idm.sec.core.wf.notification.send=false | idm.sec.core.wf.notification.send=false | ||
| + | |||
| </ | </ | ||
| Sending notification can be turnd off in each UserTask by setting Form property **sendNotification**. Example of this setting: | Sending notification can be turnd off in each UserTask by setting Form property **sendNotification**. Example of this setting: | ||
| + | |||
| <code xml> | <code xml> | ||
| < | < | ||
| Line 501: | Line 557: | ||
| writable=" | writable=" | ||
| </ | </ | ||
| + | |||
| </ | </ | ||
| - | Type of variable have to be **configuration**. It is FormType, which is not propagated to frontend. ID or name have to be **sendNotification**. It does not matter even in case of **idm.sec.core.wf.notification.send** is setted to false, because form property **sendNotification** has **higher priority**. | + | Type of variable have to be **configuration**. It is FormType, which is not propagated to frontend. ID or name have to be **sendNotification**. It does not matter even in case of **idm.sec.core.wf.notification.send** |
| - | If Form property **sendNotification** is not explicitly filled, notification will be sent. | + | If Form property **sendNotification** |
| - | New listener **TaskSendNotificationEventListener** was created for purposes of sending notifications. This listener reacts on these events: TASK\_ASSIGNED, | + | New listener **TaskSendNotificationEventListener** |