Substituting Users
- User1 can define a substitute user for the time period that he/she will be unavailable.
- Once this substitution period starts, all the existing tasks of user1 are transferred to the substitute to user2 as a bulk reassignment.
- From this point onwards, any new tasks that are going to be assigned to user1 will be assigned to user2 instead.
- The substitute user (i.e., user2) will also be added as a candidate user to all the existing tasks, for which the original assignee (i.e., user1) is a candidate user.
The below sections demonstrate how to use the sample, which is shipped with WSO2 EI, to simulate this BPMN user substitution feature via the BPMN Explorer.
Alternatively, you can use the BPMN substitution APIs to add, update and look up for substitution information. For more information, see /wiki/spaces/EI6xx/pages/49614200.
Creating the users
Follow the steps below to create the two users.
- Log in to the Management Console of the Business Process profile.
- Click Configure → Users and Roles → Add → Add New User.
- Enter the below details to create a user called user1 and click Next.
In the next screen, assign the user to the
admin
role and click Finish.- Repeat the above steps to create user2 as shown below.
You vire the users created as shown below.
Deploying the sample
Follow the steps below to deploy the sample.
- Login to the Management Console as the admin, using admin/admin credentials.
- Navigate to Processes → Add → BPMN and upload the
<EI_HOME>/samples/business-process/bpmn/UserTaskCreatorProcess.bar
file.
You view the process deployed as shown below.
Enabling user substitution
Follow the steps below to enable user substitution.
Point your DBMS to the database, which stores data related to the BPMN Engine, and execute the
<EI_HOME>/wso2/business-process/dbscripts/bps/bpmn/create/
activiti.<DB_Name>.create.substitute.sql
database script, based on your Database type.This creates the table, which stores data related to user substitution. Skip this step if you are using the standalone WSO2 EI distribution to run this sample.
Open the file in the
<EI_HOME>/wso2/business-process/conf/
and uncomment the following configuration.activiti.xml
<bean id="userSubstitutionConfiguration"> <property name="enabled" value="true"></property> <property name="enableTransitivity" value="false"></property> <property name="activationInterval" value="60"></property> </bean>
Trying out the sample
Follow the steps below to try out how to substitute user1 with user2.
Log in to the BPMN explorer as the admin using admin/admin credentials.
- Click PROCESSES in the top menu, and click the Start option of the User task Creator Process.
- Start a few process instances of the User task Creator Process by giving ‘user1’ as the assignee.
Log out as admin and log in as "user1" on the BPMN explorer using the relevant credentials.
- Select the My Tasks tab. You will see a few tasks listed that are assigned to user1.
Select the Substitutions tab and click Add Substitute. Enter "user2" as the substitute user and enter start and end times.
You view the substitution record you just added listed under the My Substitutions Information section.- Click the TASKS → My Tasks tab. You will see that there are no tasks for user1 anymore. All the existing tasks that were assigned to "user1" have been substituted to "user2" due to your substitution request.
- Log out as "user1" and log in as "user2" and select the My Tasks tab. Now, you view the tasks with the name "User task for user1" assigned to "user2".
- Log in as admin and start a few task instances for user1 again and log out.
- Log in as "user2" and click TASKS → My Tasks. You view that the tasks you just assigned to "user1" are assigned to "user2" instead. This is because future tasks are also being reassigned according to the substitution record.
- Log in again as "user1" and select the Substitutions tab. Click on the Deactivate button. This will disable the existing substitution record. Now the substitution view will look as follows.
- Log in as admin and start a few task instances giving "user1" as the assignee again and log out.
- Log in as "user1" again and click TASKS → My Tasks. You view that these tasks are now available for user1 since the substitution was disabled in the above step.