Prev Next

DMN Module Code Generation and Test Module

After a Decision model is created and simulated, you can generate a DMN module in Java, JavaScript, C++ or C#. That DMN module can be used with the Enterprise Architect BPSim Execution Engine, Executable StateMachine, or your own project.

Enterprise Architect also provides a 'Test Module' page, which is a preprocess for integrating DMN with BPMN. The concept is to provide 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, you can create an Analyzer Script to debug the code of the DMN module and Test Client.

After this 'Test Module' process, Enterprise Architect guarantees that the BPMN2.0::DataObject elements will work well with the DMN Module.

You 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.

Access

Ribbon

Simulate > Decision Analysis > DMN > Open DMN Simulation > Generate Module

DMN Module: Code Generation

On the DMN Simulation window, select the DMN structure you want to generate the module from, in the data entry field of the Toolbar.

Click on the 'Generate Module' tab, and then Ctrl+click on the names of the DMN elements you want to generate to the server.

In the data entry field in the tab toolbar, select the language to generate in, and in the 'Module Path' field click on the Browse. icon and browse to the path location to generate the module into (note, for Java the path has to match the Package structure).

Click on the Generate button ().

When the generation is complete, click on the button to open the 'Test Module' tab for the generated module.

DMN Server: Test Module

When you use the button to select the 'Test Module' tab, the 'DMN Module' field will be filled automatically with the generated DMN Server path of the module you most recently generated on the 'Generate Module' tab. If necessary, on the 'Decision' field click on the drop-down arrow and select the required Decision.

Click on the Add BPMN DataObject button () in the Toolbar and select one or more (Ctrl+Click) BPMN2.0 DataObject(s) to add to the list in the main panel.

Now click the Run button on the toolbar. In the System Output window, this message indicates the DMN Server and BPMN2.0 DataObject can 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 an Analyzer script by clicking the toolbar button and use the script to fix the issue.

Important: This 'Test Module' step is recommended before integrating DMNServer.java with the Enterprise Architect BPSim Execution Engine.

Code Generation & Connect to BPMN

  • Generate the DMN Server in Java, JavaScript, C++, or C#
  • Run/Debug tests of the Java version of the DMN Server
  • Connect the DMN Server to the Enterprise Architect BPSim Execution Engine

Common Errors & Solutions

  • Variable Types: as DMN models use the FEEL language (Simulate with JavaScript), typing variables is not compulsory; however, when generating code to languages that are compiled, you do have to type a variable - there are context menu options and tag values for setting the type of a variable
  • Since a DMN expression allows for spaces, in order to clarify the composite Input Data there must be a space before and after the '.' in the expression; for example, 'Applicant data . Age' is valid, whereas 'Applicant data.Age' is not valid
    Note that when using the Auto Completion feature this issue will not arise
  • Running validation will help you locate most of the modeling issues; do this before simulation and code generation

Notes

  • Compiling with Java requires full read-write access to the target directory; compilation will fail if the module path is set to just 'C:' or 'C:\Program Files (x86)'