1
votes

I'm trying to create a BPM using jBPM 6.2. The process looks like:

User creates a request. His manager will evaluate to accept or reject. In the case his manager accepts, the IT dept's guys will implement that request

But I cannot get task from the group which I belong to. In my BPM, The human task was assigned to IT group. I tried to use account: salaboy, jack (in IT dept) but I don't see any tasks associated with those account

Below is the screenshot of my process and you can see the group ID is IT

Process

I didn't change any configuration of the server. The roles look like:

admin=admin,analyst,kiemgmt
krisv=admin,analyst
john=analyst,Accounting,PM
mary=analyst,HR
sales-rep=analyst,sales
jack=analyst,IT
katy=analyst,HR
salaboy=admin,analyst,IT,HR,Accounting

The code to test is that:

public static void main(String[] args) {
    KieServices ks = KieServices.Factory.get();
    KieContainer kContainer = ks.getKieClasspathContainer();
    KieBase kbase = kContainer.getKieBase("kbase");

    RuntimeManager manager = createRuntimeManager(kbase);
    RuntimeEngine engine = manager.getRuntimeEngine(null);
    KieSession ksession = engine.getKieSession();
    TaskService taskService = engine.getTaskService();

    ksession.startProcess("com.sample.bpmn.hello");

    // let john execute Task 1
    List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");
    TaskSummary task = list.get(0);
    System.out.println("John is executing task " + task.getName());

    taskService.start(task.getId(), "john");
    taskService.complete(task.getId(), "john", null);

    // let mary execute Task 2
    list = taskService.getTasksAssignedAsPotentialOwner("mary", "en-UK");
    task = list.get(0);
    System.out.println("Mary is executing task " + task.getName());
    taskService.start(task.getId(), "mary");
    Map<String, Object> params = new HashMap<>();
    params.put("output", true);
    taskService.complete(task.getId(), "mary", params);

    // let salaboy execute Task 3


    list = taskService.getTasksAssignedAsPotentialOwner("salaboy", "en-UK");
    task = list.get(0);

    System.out.println("salaboy is executing task " + task.getName());
    taskService.start(task.getId(), "salaboy");
    taskService.complete(task.getId(), "salaboy", null);

    manager.disposeRuntimeEngine(engine);
    System.exit(0);
}

private static RuntimeManager createRuntimeManager(KieBase kbase) {
    JBPMHelper.startH2Server();
    JBPMHelper.setupDataSource();
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa");
    RuntimeEnvironmentBuilder builder = RuntimeEnvironmentBuilder.Factory.get()
        .newDefaultBuilder().entityManagerFactory(emf)
        .knowledgeBase(kbase);
    return RuntimeManagerFactory.Factory.get()
        .newSingletonRuntimeManager(builder.get(), "com.sample:example:1.0");
}

If I assign the Implement task to salaboy, it works like a charm

Please let me know if you have any suggestions

Thanks

1
It would probably help if you showed us some code examples. In theory is you use the RuntimeDataService.getTasksAssignedAsPotentialOwner method it should return the a Collection of tasks that the user could claim/start. Did you verify that the users are actually in the role? Is the UserGroupCallback properly setup? Is the GroupID specified for step?Mike
Thank you so much Mike, I just updated my post with more information. Can you please take a look and advise. As you can see in my post, I use TaskService to get tasks. What is the different between RunTimeDataService and TaskService?Hai Pham
I noticed that Salaboy is an admin, and you aren't. My thoughts would be that you're not set up with the appropriate role in the user roles table in the database.Canadian Coder
Well, as far as i know, default configurarion of users and roles is in properties file. And i didn't change anything, just added a new project to play around so i don't think this is a reason. Anyway, i will take a look on it to double check. Is there a GUI to check roles of userHai Pham
I think you might be confusing John and Jack.Ampie Barnard

1 Answers

0
votes

We should use Workbench (Web version) instead of Eclipse.