Giter Club home page Giter Club logo

camunda-engine-dmn's Introduction

==================

Lightweight Execution Engine for DMN (Decision Model and Notation) written in Java.

Home | Forum | Issues | License

The Decision Engine can be used seamlessly in combination with BPMN and CMMN or standalone.

Standalone Usage

Add the following Maven Coordinates to your project:

<dependency>
  <groupId>org.camunda.bpm.dmn</groupId>
  <artifactId>camunda-engine-dmn</artifactId>
  <version>${version.camunda}</version>
</dependency>

Now you can use the DMN engine inside your Java Code:

public class DmnApp {

  public static void main(String[] args) {

    // configure and build the DMN engine
    DmnEngine dmnEngine = DmnEngineConfiguration.createDefaultDmnEngineConfiguration().buildEngine();

    // parse a decision
    DmnDecision decision = dmnEngine.parseDecision("orderDecision", "CheckOrder.dmn");

    Map<String, Object> data = new HashMap<String, Object>();
    data.put("status", "gold");
    data.put("sum", 354.12d);

    // evaluate a decision
    DmnDecisionTableResult result = dmnEngine.evaluateDecisionTable(decision, data);

  }

}

Use DMN Engine for implementing a BPMN Business Rule Task

Add the following Maven Coordinates to your project:

<dependency>
  <groupId>org.camunda.bpm</groupId>
  <artifactId>camunda-engine</artifactId>
  <version>${version.camunda}</versions>
</dependency>
<dependency>
  <groupId>com.h2database</groupId>
  <artifactId>h2</artifactId>
  <version>1.3.168</version>
  <scope>test</scope>
</dependency>

Next, reference a DMN decision from a BPMN Business Rule Task:

<bpmn:businessRuleTask id="assignApprover"
  camunda:decisionRef="invoice-assign-approver"
  camunda:resultVariable="approverGroups"
  name="Assign Approver Group(s)">
</bpmn:businessRuleTask>

The camunda:decisionRef attribute references the id of the decision in the DMN file:

<dmn:decision id="invoice-assign-approver" name="Assign Approver">
  ...
</dmn:decision>

Now you can start the BPMN process inside your application:

public class App {

  public static void main(String[] args) {

    ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration()
      .buildProcessEngine();

    try {
      processEngine.getRepositoryService()
        .createDeployment()
        .name("invoice deployment")
        .addClasspathResource("invoice.bpmn")
        .addClasspathResource("assign-approver-groups.dmn")
        .deploy();

      processEngine.getRuntimeService()
        .startProcessInstanceByKey("invoice", createVariables()
            .putValue("invoceNumber", "2323"));
    }
    finally {
      processEngine.close();
    }
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.