.addAsset(
KieServices.Factory.get().getResources().newClassPathResource(
"Evaluation.bpmn",getClass().getClassLoader()), ResourceType.BPMN2)
.userGroupCallback(new JBossUserGroupCallbackImpl(props))
.get();
RuntimeManager runtimeManager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
RuntimeEngine runtimeEngine = runtimeManager.getRuntimeEngine(EmptyContext.get());
KieSession ksession = runtimeEngine.getKieSession();
TaskService taskService = runtimeEngine.getTaskService();
// start a new process instance
Map<String, Object> params = new HashMap<String, Object>();
params.put("employee", "krisv");
params.put("reason", "Yearly performance evaluation");
ProcessInstance processInstance =
ksession.startProcess("com.sample.evaluation", params);
System.out.println("Process instance " + processInstance.getId() + " started ...");
ProcessInstance pi = ksession.getProcessInstance(processInstance.getId());
System.out.println(pi);
// complete Self Evaluation
List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("krisv", "en-UK");
TaskSummary task = tasks.get(0);
System.out.println("'krisv' completing task " + task.getName() + ": " + task.getDescription());
taskService.start(task.getId(), "krisv");
Map<String, Object> vars = taskService.getTaskContent(task.getId());
Map<String, Object> results = new HashMap<String, Object>();
results.put("performance", "exceeding");
taskService.complete(task.getId(), "krisv", results);
// john from HR
tasks = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");
task = tasks.get(0);
System.out.println("'john' completing task " + task.getName() + ": " + task.getDescription());
taskService.claim(task.getId(), "john");
taskService.start(task.getId(), "john");
results = new HashMap<String, Object>();
results.put("performance", "acceptable");
taskService.complete(task.getId(), "john", results);
// mary from PM
tasks = taskService.getTasksAssignedAsPotentialOwner("mary", "en-UK");
task = tasks.get(0);
System.out.println("'mary' completing task " + task.getName() + ": " + task.getDescription());
taskService.claim(task.getId(), "mary");
taskService.start(task.getId(), "mary");
results = new HashMap<String, Object>();
results.put("performance", "outstanding");
taskService.complete(task.getId(), "mary", results);
System.out.println("Process instance completed");
runtimeManager.disposeRuntimeEngine(runtimeEngine);
runtimeManager.close();
server.shutdown();
}