Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.
Prev | Next |
Boxed Context
A Boxed Context is a collection of context entries. Each context entry consists of a variable and an expression. The Context also has a result value.
Access
Ribbon |
Simulate > Decision Analysis > DMN > DMN Expression : select or create a Decision or BusinessKnowledgeModel |
Other |
Double-click on a DMN Decision or BusinessKnowledgeModel |
Toolbar Options
Options |
Description |
See also |
---|---|---|
Click on this button to save the configuration to the current Decision or BusinessKnowledgeModel. |
||
Click on this button to edit parameters for the Business Knowledge Model. |
||
Click on this button to add a 'Context Entry' to the boxed context. Each 'Context Entry' consists of a variable and an expression. |
||
This button is enabled when a ContextEntry's variable is selected. Click on this button to delete the selected Context Entry. |
||
This button is enabled when a 'Context Entry' variable is selected. Click on this button to move the selected 'Context Entry' up one position. |
||
This button is enabled when a 'Context Entry' variable is selected. Click on this button to move the selected 'Context Entry' down one position. |
||
Click on this button to validate the Boxed Context. Enterprise Architect will perform a series of validations to help you locate errors in the Expression. |
DMN Expression Validation | |
This button is enabled when the Boxed Context is defined for a Business Knowledge Model. |
BusinessKnowledgeModel & Test Harness |
Example — Installment calculation
The Business Knowledge Model (BKM) Installment calculation is implemented as Boxed Context.
- The BKM defines four parameters: Product Type, Rate, Term and Amount
- The Boxed Context defines two variable-expression pair entries, these variables serve as 'local variables' that can be used in later expressions
- Return value: The expression can use the value of 'local variables'
- Any expressions in a Boxed Context can use built-in functions, which are defined in the customizable Template — DMN Library; for example, functions PMT(...) and decimal(...) are used in this example
Expression Editor and Intelli-sense Support
The parameter and Context Entry's variable name can contain spaces, according to the FEEL language specification. This feature makes the expression easy to read. In order to help you edit the expressions with less typing and making fewer mistakes, Enterprise Architect provides Intelli-sense support for editing expressions:
Right-click on the Expression | Edit Expressions... the 'Expression' dialog displays
Press
to show the Intelli-sense menu:- All the Context Entry Variables earlier than the current one will be included (the context entries later than the current one are excluded)
- For BKM, all the parameters will be included
- For Decision, all the required Decisions will be included
The DMN model can be generated as source code for JavaScript, Java, C# and C++. Since some languages might have different syntax for some expressions, Enterprise Architect provides language override pages for each language. If no override code is specified for a language, the expression defined for the FEEL language will be used.
In the generated code, the space inside a variable name will be replaced by an underscore.
Test Harness for Business Knowledge Model
Select the 'Input Parameter Values for Simulation' tab and complete the fields.
Click on the
on the toolbar; the test result will be presented in the Boxed Context.
- The runtime parameter value will be displayed; for example, 'Rate = 0.00375'
- The 'Context Entry' variable's runtime value will be displayed; for example, 'Monthly Repayment = 1520.05'
- The BKM's result will be evaluated by the last entry and the values displayed on the declaration line; for example, 'return = 1540.06'
You can use this functionality to unit test a BusinessKnowledgeModel without knowing the context and later on invoked by a Decision or other BusinessKnowledgeModel.
Menu options are available for this tool bar button. For more information, see the Business Knowledge Model and Test Harness Help topic.