简体   繁体   中英

drools bpmn java syntax

I created an example drools project and I am using the process type for BPMN flow :

        KieServices ks = KieServices.Factory.get();
        KieContainer kContainer = ks.getKieClasspathContainer();
        KieSession kSession = kContainer.newKieSession("ksession-process");
        kSession.insert(myTicket);
        kSession.startProcess("com.sample.bpmn.hello");
        kSession.fireAllRules();

how can I use the varaible myTicket in the BPMN Gateway diverge constraints if I want to write it in java and not as a rule: (m : Ticket( status == Ticket.CREATE)) .

Facts (objects asserted in a kie-session) are not available in the scope of jbpm (the only exception are probably gateways using DRL syntax). There are some workarounds that you can use to get one of these facts from the session and use it in your gateway, but given that you have the object before you start the process (at least this is what your example is showing) you can pass this object as a process variable.

Map<String, Object> variables = new HashMap<>();
variables.put("ticket", myTicket);
kSession.startProcess("com.sample.bpmn.hello", variables);

Your process definition must have a variable defined with the name myTicket of type Ticket .

In your gateway, you don't need any special syntax to reference this variable:

return ticket.getStatus() == Ticket.CREATE;

Hope it helps,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM