How can I get tasks of a group which I belong to (jBPM 6.2)

930 views Asked by At

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

There are 1 answers

0
Hai Pham On BEST ANSWER

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