Time for action – working with users

IdentityService is used to manage users and groups in Activiti. Now, let's see a demo for working with users. To implement IdentityService, we have to follow the ensuing steps:

  1. We will create a class file where we will use IdentityService. Write the following code in it:
    ProcessEngine processEngine = ProcessEngineConfiguration
          .createStandaloneProcessEngineConfiguration()
          .setJdbcDriver("com.mysql.jdbc.Driver")
          .setJdbcUrl("jdbc:mysql://localhost:3306/activiti_book")
          .setJdbcPassword("root").setJdbcUsername("root")
          .buildProcessEngine();
      
      IdentityService identityService=processEngine.getIdentityService();
      
      List<Group> partofuser =identityService.createGroupQuery().groupMember("gonzo").list();
      
    System.out.println("Gonzo is a part of following group");
      
    for(Group partofuse:partofuser)
    {
      System.out.println("Group name:"+partofuse.getName());
    }
  2. Once you are done implementing the code, we will have to execute it to view the results.
  3. The result of the preceding code will list all the groups to which the specified user belongs, as follows:
    Gonzo is a part of following group
    Group name:Management
    Group name:Marketing
    Group name:Sales
    Group name:User

What just happened?

We learned about IdentityService. Now, we are able to manage users and groups using IdentityService. We saw how to find a user's group using the group query, which is a part of IdentityService.

HistoryService

HistoryService is used to get historical data from the Activiti Engine, such as the following:

  • When a particular process was started
  • Which task has been completed by whom
  • What the execution time was for a process or task

So, with the help of HistoryService, we can generate reports for the business process and identify the efficiency of the business process execution.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset