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

Prev Next

Integrate DMN Module Into BPSim for Simulation

The strength of DMN is its ability to describe business requirement through decision requirement diagram and encapsulate the complicated logics into versatile expressions like decision table, boxed context.

On the other end, the strength of BPMN is its ability to describe business process  with a sequence flow of tasks and events, or to describe collaborations of processes with message flows.

The Decision Requirements Diagram forms a bridge between business process models and decision logic models:

  • Business process models will define tasks within business processes where decision-making is required to occur
  • Decision Requirements Diagrams will define the decisions to be made in those tasks, their interrelationships, and their requirements for decision logic
  • Decision logic will define the required decisions in sufficient detail to allow validation and/or automation.

DMN provides a complete decision model which complements a business process model by specifying in detail the decision-making carried out in process tasks.

The two examples demonstrated in this page can be accessed from:

  • EA Example Model | Model Simulation | BPSim Models
  • Perspectives | Business Modeling | BPSim | BPSim Case Studies

There are two ways to let BPSim expressions use DMN model:

  • DMN's Decision Service: Demonstrated by Loan Application Process
  • DMN's BusinessKnowledgeModel: Demonstrated by Delivery Cost Calculation

The Process of integrating DMN Model into BPSim Model includes:

  • DMN Model Validation, Simulation, Code Generation and Test the generated Module
  • Setup usage dependency from BPSim Artifact to DMN Artifact
  • Generate/Update BPMN DataObject from DMN DataSet
  • Create Property Parameters in BPSim to be used on tasks and sequence flows out going from gateways
  • Bind DMN interface to BPSim Property parameters

DMN Model Validation for Compiled language like Java

When you create a DMN model and simulate it in Enterprise Architect, the code driving the simulation is JavaScript, meaning that the variables do not need to be explicitly typed (the variable type is inferred from the value assigned to it).

However, for languages like C++/C#/Java, the compiler will report an error that a variable does not have a type.

For generation to these languages you need to run the Validation on the model and use this to find variables that need their type set. For example:

  • Business Knowledge Model's parameter: Select the BKM element to view in the DMN Expression window | click the 2nd button to open Parameter dialog | specify a type to the Parameter
  • Decision's type: Select the Decision element | in Properties window | select in the value combobox for property "variableType"
  • Decision Table's Input/Output clauses: On the Decision Table's Input/Output clause, context menu | choose the type

DMN Code Generation In Java

Post using the validation to fix any variable type issues, we can proceed on to the Generate Module page in the DMN Simulation window.

  • Select DecisionService1 in the top combo box, then all the elements involved in DecisionService1 will be included in the list.
  • Item Definition, Business Knowledge Model are global elements;
  • Input Data, Decisions are encapsulated in the Decision Service element.
  • The supported languages are C++/C#/Java/JavaScript. Note. For JavaScript, the generated .js file is the same as the simulation script (Simulation page | Run button's drop dow menu | Generate New Script) except that the simulation related codes are taken away.
  • For Java language, the Module Path must match the Package structure. In this example, the DMNModule.java must be generate to a directory to form a file path ends with: "\com\sparxsystems\dmn\DMNModule.java", you have to manually create the directory structures for now.

Click on the Generate Code button on the toolbar (next to the language combo box). This example will use Java, however C++ and C# are the same. These actions are performed:

  • The .java file is generated to the path specified
  • An Analyzer Script (Build script) for this Artifact is created
  • The Build Script for this Analyzer Script is executed
  • The message is reported in the System Output window

If the model is valid, this will return the message:

If there are compiling errors, you can open the generated java file by clicking the button next to the Generate button on the toolbar, manually fix the issue, and compile with the generated script until you are successful.

One common reason for a compile failure is that languages can have different grammars for an expression. You might need to provide value for a language to overwrite the default: (Context menu on an DMN Literal Expression | Edit Expression ...)

Testing DMN Modules before external Use

Having generated the model to java code and successfully compiled it we now want to:

- Test this module's correctness

- Provide it with inputs

- Get the output decision values

  • Generate BPMN DataObject

The data carried by the selected data set will be generated to the BPMN DataObject's Notes field.

  • Click the Test Run button (2nd to the right on the toolbar of the 'Generate Module' page) to open the 'Test Module' page

  • Click the first button on the toolbar to select the inputs: BPMN DataObject elements
  • Select the available outputs from the 'Decision' combo box, such as Get_Routing(), and click on the Run button on the toolbar

The execution result will be displayed in the Debug window. You can also open the test module file and set a breakpoint on the line and debug into the DMN Module to do line-level-debugging.

We highly recommend you test your DMN Module with this window to guarantee that the DMN Module is functional with the given inputs (from BPMN DataObject) and that it will successfully compute the result of the output.

Note: The DMN Module path is saved in the DMNSimConfiguration Artifact's Filepath property.

Now, it is time to integrate the DMN module into the BPSim model.

The first step is to set up the usage dependency between the BPSim Artifact and the DMN Artifact.

Note: A BPSim Artifact can use multiple DMN modules if necessary. This is supported by simply putting all DMN Artifacts on this diagram and drawing a Dependency connector from the BPSim Artifact to each DMN Artifact.

These Help topics provide two examples of using the above methods. See:

  • Example: Integrate DMN Decision Service into BPSim Data Object and Property Parameter
  • Example: Integrate DMN Business Knowledge Model into BPSim Property Parameter

Learn More