Decision Literal Expression - 图1

A decision literal expression represents decision logic which can be depicted as an expression in DMN 1.1.It consists of a literal expression and a variable.

A decision literal expression is represented by a literalExpression element inside a decision XML element.

  1. <definitions xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd" id="definitions" name="definitions" namespace="http://camunda.org/schema/1.0/dmn">
  2. <decision id="season" name="Season">
  3. <variable name="season" typeRef="string" />
  4. <literalExpression>
  5. <text>calendar.getSeason(date)</text>
  6. </literalExpression>
  7. </decision>
  8. </definitions>

Decision Name

Decision Literal Expression - 图2

The name describes the decision for which the literal expression provides thedecision logic. It is set as the name attribute on the decision element.

  1. <decision id="season" name="Season">
  2. <!-- ... -->
  3. </decision>

Decision Id

Decision Literal Expression - 图3

The id is the technical identifier of the decision. It is set in the idattribute on the decision element.

Each decision should have an unique id when it is deployed to the Camunda BPMplatform. The engine uses the id as the decision key of the deployedDecisionDefinition.

  1. <decision id="season" name="Season">
  2. <!-- ... -->
  3. </decision>

Literal Expression

The literal expression specifies how the value of the decision is generated. It is an expression which will be evaluated by the DMN engine.It can be used to do a complex calculation, to invoke a bean which provides decision logic, or to combine the output values of required decisions.

The expression is set inside a text element that is a child of the literalExpression XML element.

  1. <literalExpression>
  2. <text>calendar.getSeason(date)</text>
  3. </literalExpression>

Literal Expression Language

The expression language of the literal expression can be specified by theexpressionLanguage attribute on the literalExpression XML element. Thesupported expression languages are listed in the User Guide.

  1. <literalExpression expressionLanguage="groovy">
  2. <text>calendar.getSeason(date)</text>
  3. </literalExpression>

If no expression language is set then the global expression language is usedwhich is set on the definitions XML element.

  1. <definitions id="definitions"
  2. name="definitions"
  3. xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd"
  4. expressionLanguage="groovy"
  5. namespace="http://camunda.org/schema/1.0/dmn">
  6. <!-- ... -->
  7. </definitions>

In case no global expression language is set, the default expression languageis used instead. The default expression language for literal expressions is JUEL.Please refer to the User Guide to read more about expressionlanguages.

Variable

A decision literal expression must have a variable which specifies the name and the type of the decision result.A variable is represented by a variable element inside a decision XML element.

  1. <decision id="season" name="Season">
  2. <variable name="season" />
  3. </decision>

Variable Name

The name of the variable is used to reference the value of the literal expression in the decision result. It is specified by the name attribute on the variable XML element.

  1. <variable name="season" />

Variable Type Definition

The type of the decision result can be specified by the typeRef attribute on thevariable XML element. After the expression is evaluated by theDMN engine it converts the result to the specified type. The supported typesare listed in the User Guide.

  1. <variable name="season" typeRef="string" />

Note that the type is not required but recommended since it provides a typesafety of the expression result.

原文: https://docs.camunda.org/manual/7.9/reference/dmn11/decision-literal-expression/