-
1. Re: from a sub process script task how can I get the root process ID?
swiderski.maciej Feb 3, 2015 1:54 AM (in response to danutc)best would be to do something like this:
kcontext.getKieRuntime().getEnvironment().get("RuntimeManager").getRuntimeEngine(Context).getAuditService()
where context depends on strategy you use but in general you can always use ProcessInstanceIdContext.get(pid)
HTH
-
2. Re: Re: from a sub process script task how can I get the root process ID?
melissa.ferenal Feb 3, 2015 9:19 PM (in response to swiderski.maciej)Hi Maciej
I tried the code snippet you provided on a script task but it returned an error "Process Instances failed to start: [test.process_q2:226 - :2] -- This persistence strategy only deals with UserTransaction instances!"
Code:
org.kie.api.runtime.manager.audit.AuditService as = ((RuntimeManager)kcontext.getKieRuntime().getEnvironment().get("RuntimeManager")).getRuntimeEngine(org.kie.internal.runtime.manager.context.ProcessInstanceIdContext.get(kcontext.getProcessInstance().getId())).getAuditLogService();
java.util.List li = as.findProcessInstances() ;
System.out.println(li.toString());
Thanks
-
3. Re: from a sub process script task how can I get the root process ID?
swiderski.maciej Feb 4, 2015 2:13 AM (in response to melissa.ferenal)are you running within jbpm console aka kie-wb or in custom application?
HTH
-
4. Re: from a sub process script task how can I get the root process ID?
melissa.ferenal Feb 4, 2015 4:41 AM (in response to swiderski.maciej)I'm using jbpm-console and embedded the code in a script task.
-
5. Re: from a sub process script task how can I get the root process ID?
melissa.ferenal Feb 9, 2015 11:35 PM (in response to melissa.ferenal)any idea on this?
-
6. Re: Re: from a sub process script task how can I get the root process ID?
swiderski.maciej Feb 11, 2015 1:58 AM (in response to melissa.ferenal)in that case you can use following:
org.kie.api.runtime.Environment env = kcontext.getKieRuntime().getEnvironment(); org.kie.api.runtime.manager.audit.AuditService as = org.jbpm.process.audit.JPAAuditLogService(env, new org.jbpm.process.audit.strategy.KieSessionCommandScopedStrategy (env));
HTH
-
7. Re: Re: Re: from a sub process script task how can I get the root process ID?
melissa.ferenal Feb 11, 2015 9:54 PM (in response to swiderski.maciej)Thanks for the code snippet Maciej. It really helped a lot.
Here's my final code for getting the Audit service in a Script task.
org.kie.api.runtime.Environment env = kcontext.getKieRuntime().getEnvironment(); org.kie.api.runtime.manager.audit.AuditService as = new org.jbpm.process.audit.JPAAuditLogService(env, org.jbpm.process.audit.strategy.PersistenceStrategyType.KIE_SESSION);