简体   繁体   English

Drools bpmn Java语法

[英]drools bpmn java syntax

I created an example drools project and I am using the process type for BPMN flow : 我创建了一个drools项目示例,并且正在使用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)) . 如果要以Java而不是通常的方式编写它,如何在BPMN网关发散约束中使用可变的myTicket:(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). 事实(在kie会话中声明的对象)在jbpm范围内不可用(唯一的例外可能是使用DRL语法的网关)。 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 . 您的流程定义必须有一个变量,其名称myTicketTicket类型的myTicket

In your gateway, you don't need any special syntax to reference this variable: 在网关中,不需要任何特殊的语法来引用此变量:

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

Hope it helps, 希望能帮助到你,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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