Prev Next

DMN Module Code Generation & Test

After a Decision Model is created, simulated, the user may generate a DMN Module in language Java/JavaScript/C++/C#. The DMN Module may work together with EA BPSim Execution Engine, Executable Statemachine, or user's own project.

EA also provided a "Test Module" page, which is a preprocess for integrate DMN with BPMN. The idea is by providing one or more BPMN2.0::DataObject elements, then test if a specified target decision can be evaluated correctly or not.

If any error or exception occurs, the user may create a Analyzer Script to debug the code of DMN Module and Test Client.

After this "Test Module" process, EA guaranteed the BPMN2.0::DataObject elements works well with the DMN Module.

The user then configure BPSim by loading DataObjects and assigning DMN Module decisions to BPSim Properties, which will be further used as conditions on the sequence flows outgoing from a gateway.

Modeling & Simulation

We took the example available from Model Patterns: Ribbon | Simulate | DMN | Apply Perspective | DMN Decision | Decision with BKM

Here is a brief overview of the model:

  • Item Definition:

  • Input Data

  • Business Knowledge Model (Decision Table)

  • Decision (Invocation)

  • Simulation

  • Export InputData to a BPMN2.0 DataObject

Activate "Configure" page, click Export DataObject buttons on the toolbar

DMN Module: Code Generation

Activate the 3rd page "Generate Module" of the DMN Simulation window,  select the DMN elements you want to generate to the server, specify the file path and language, then click "Generate".

(Note: For Java language, the path need to match the package structure.)

  • Add elements to module

Click the Add button on the toolbar to open the DMN Element Selection dialog:

Click the decision you want to generate to the server, in this example, we selected decision "Application risk score".

Note: all the dependencies will be selected automatically.

  • Generate DMN Module

Give the Java file a package name, click generate.

Note: in this example, the Module Path ended with "\com\sparxsystems\dmn", which matches the Package "com.sparxsystems.dmn".

  • Click the Test button to enter the Test Server page

DMN Server: Test client

If this page was activated from "Generate Server" page, the "DMN Module" field will be filled automatically with the generated DMN Server's path. Otherwise, click "..." button to browse for a DMN Server file.

Click the "Add DataObject" button to add one or more BPMN2.0 DataObject(s) to the list, choose a decision from the combo box, then click the run button on the toolbar.

In the System Output window, the following message indicates the DMN Server and BPMN2.0 DataObject may work well with each other to evaluate the selected decision.

Running Test Client for DMN Server...

    dmnServer.Application_risk_score: 133.0

Result : 133.0

The Running completed successfully.

If there are errors, create a Analyzer script by clicking the toolbar button and fix the issue.

Important: This "Test Module" step is recommended before integrate DMNServer.java to EA BPSim Execution Engine.