Prev Next

Boxed Context

A boxed context is a collection of context entry. Each context entry is consisted of a variable and an expression. The Context also has an result value.

Access

Ribbon

Simulate > Decision Analysis > DMN > DMN Expression, then select / create a Decision or BusinessKnowledgeModel

Other

Double-click on an 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 Context Entry to the boxed context. Each Context Entry is consisted 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 ContextEntry's variable is selected.

Click on this button to move the selected Context Entry up.

This button is Enabled when a ContextEntry's variable is selected.

Click on this button to move the selected Context Entry down.

Click on this button to validate the Boxed Context. EA will perform a series of validations to help the modeler to pickup errors in the Expression.

DMN Expression Validation

This button is Enabled when the boxed context is defined for a BusinessKnowledgeModel.

BusinessKnowledgeModel & Test Harness

Example - Installment calculation

This Business Knowledge Model (BKM) Installment calculation is implemented as Boxed Context.

  • The BKM defines 4 parameters: Product Type, Rate, Term, Amount
  • The Boxed Context defines 2 variable-expression pairs entries, these variables serves as "local variables", which 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 is defined in the customizable Template - DMN Library. For example, functions PMT(...) and decimal(...) are used in this example.

Expression Editor and IntelliSense Support

The parameter and Context Entry's Variable name may contain space according to FEEL language specification. This feature makes the expression easy to read. In order to help the user to edit the expressions with fewer typing and make less mistake, EA provided IntelliSense support for editing expressions:

Context menu on the Expression | Click the menu item "Edit Expressions..." to bring up the Expression Dialog.

Press "Ctrl + Space" to show the IntelliSense menu:

  • All the Context Entry Variables (the context entries later than the current one are excluded) will be included.
  • For BKM, all the parameters will be included.
  • For Decision, all the required Decisions will be included.

The DMN Model may be generated as source code for language JavaScript/Java/C#/C++, since some languages may have different syntax for some expressions, EA provided language override pages for each language. If no override code is specified for a language, the expression defined for 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

Activate tab "Input Parameter Values for Simulation", fill the values.

Click the Test Harness button on the toolbar, the test result will be presented on the boxed context.

  • The runtime parameter value will be displayed. E.g. Rate = 0.00375
  • The Context Entry variable's runtime value will be displayed. E.g. Monthly Repayment = 1520.05
  • The BKM's result will be evaluated by the last entry and the values is displayed on the declaration line. E.g. return = 1540.06

The user 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 the this toolbar button. For more information, click the See also link.

Learn more