Book a Demo

Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Prev Next

DMN Module Code Generation & Test

After a Decision Model is created and simulated, you can generate a DMN Module in Java, JavaScript, C++ or C#. The 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 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.

Modeling & Simulation

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

An example of Binding Data input to a DMN BKM using Sparx Systems Enterprise Architect.

Here is a brief overview of the model:

  • Item Definition

An example of an ItemDefinition for a DMN model using Sparx Systems Enterprise Architect.

  • Input Data

An example of setting the DMN Expression for an InputData DMN element using Sparx Systems Enterprise Architect.

  • Business Knowledge Model (Decision Table)

An example of setting a Decision table in the DMN Expression for a Business Knowledege Model using Sparx Systems Enterprise Architect.

  • Decision (Invocation)

An example of setting a DMN Expression for an Invocation using Sparx Systems Enterprise Architect.

  • Simulation

An example simulation of a DMN model showing the values on the diagram and in the DMN Expression using Sparx Systems Enterprise Architect.

  • Export InputData to a BPMN2.0 DataObject

Activate the 'Configure' page, and click on the Export DataObject button on the toolbar.

DMN Module: Code Generation

Activate the 'Generate Module' tab of the DMN Simulation window, select the DMN elements you want to generate to the server, specify the file path and language, then click on the Generate button.

(Note: For Java, the path has to match the Package structure.)

  • Add the elements to the module, then click on the Add button on the toolbar to open the 'DMN Element Selection' dialog

A view of the dialog for selecting the Elements to be included in code generation of a DMN module Sparx Systems Enterprise Architect.

  • Click on the decision you want to generate to the server; in this example we select the decision 'Application risk score'

Note: All the dependencies will be selected automatically.

A view of the dialog for selecting the Elements to be included in code generation of a DMN module Sparx Systems Enterprise Architect.

  • Generate the DMN Module; give the Java file a Package name, then click on the Generate button

Setting the module path ready for the Java code generation of a DMN model using Sparx Systems Enterprise Architect.

Note: In this example, the Module Path ends with '\com\sparxsystems\dmn', which matches the Package 'com.sparxsystems.dmn'.

  • Click on the Test button to access the 'Test Server' page

DMN Server: Test client

If this page was activated from the 'Generate Server' page, the 'DMN Module' field will be filled automatically with the generated DMN Server's path. Otherwise, click the Browse. 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.

Adding BPMN DataObjects to a DMN simulation's Test Module using Sparx Systems Enterprise Architect.

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 fix the issue.

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