Deploying a Decision

To deploy a DMN decision you can either use the Repository Service or add it toa process application. The platform will recognize all files with a or.dmn11.xml file extension as DMN resources.

Use the Repository Service to create a new deployment and addDMN resources to it. The following code, for example, will create a newdeployment for a DMN file in the classpath.

Deploying a decision with a Process Application

If you deploy a Process Application, you can add the DMN file to yourarchive as other resources, like BPMN processes. The DMN files must havea .dmn or .dmn11.xml file extension to be recognized as DMN resource.

If your is set up to scan for process definitions, it willautomatically deploy the DMN definitions too. This is the default.

  1. <process-archive name="loan-approval">
  2. <properties>
  3. <property name="isScanForProcessDefinitions">true</property>
  4. </properties>
  5. </process-archive>

Otherwise, you have to specify the DMN resources explicitly in the ProcessArchive

  1. <process-archive name="loan-approval">
  2. <resource>bpmn/invoice.bpmn</resource>
  3. <resource>dmn/assign-approver.dmn</resource>
  4. <properties>
  5. <property name="isScanForProcessDefinitions">false</property>
  6. </process-archive>

Versioning of Decisions

When a DMN resource is deployed to the platform, every supported DMN Decisionis transformed into a Decision Definition. A decision definition representsa single DMN decision in the platform. It has, among others, these attributes:

  • id: The unique identifier of the Decision Definition generated by theplatform.
  • key: The DMN decision id attribute from the XML file.
  • name: The DMN decision name attribute from the XML file.
  • version: The version of the Decision Definition generated by the platform.

    The Decision Definition Key

The decision definition key is equivalent to the id attribute of the DMNdecision in the DMN XML.

When deploying the above DMN XML file, a decision definition having the following properties is created:

  • id: GENERATED
  • key: my-decision
  • name: My Decision
  • version: 1

When a decision is deployed, it is checked whether a definition with the same key is already deployed.If not, the decision definition is assigned version 1 for this key. If a decision definition with the samekey already exists, the newly deployed decision definition will become a new version ofthe existing one, increasing its version by one.

The Decision Definition Id

The id of a decision definition is not equivalent to the id attribute ofthe DMN XML decision. It is generated by the platform as unique identifier.This means a decision definition id directly corresponds to a decisiondefinition key and version combination.

Reference a Decision Definition

To reference a deployed decision definition in the context of the platform,either the decision definition id or the decision definition key and version isused. If a decision definition key is used but no version is specified, thedefault is to use the latest version of the decision definition.

Versioning of Decision Requirements Graph

In addition to the decision definitions, the (i.e., the definitions element in the XML) of a deployed DMN resource is transformed into a Decision Requirements Definition. It has, among others, these attributes:

  • id: The unique identifier of the Decision Requirements Definition generated by theplatform.
  • key: The definitions id attribute from the XML file.
  • name: The definitions name attribute from the XML file.
  • version: The version of the Decision Requirements Definition generated by the platform.
    Note that the decision requirements definition is only created if the DMN resource contains more than one decision.

The decision requirements definition key is equivalent to the attribute of the definitions element in the DMN XML.

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <definitions xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd"
  3. id="my-drg"
  4. name="My DRG"
  5. namespace="http://camunda.org/schema/1.0/dmn">
  6. <!-- ... -->
  7. </definitions>

When deploying the above DMN XML file, a decision requirements definition having the following properties is created:

  • id: GENERATED
  • key: my-drg
  • name: My DRG
  • version: 1

    The Decision Requirements Definition Version

When a decision requirements graph is deployed, it is checked whether a definition with the same key is already deployed.If not, the decision requirements definition is assigned version 1 for this key. If a decision requirements definition with the samekey already exists, the newly deployed definition will become a new version ofthe existing one, increasing its version by one.

Note that the versions of the contained decision definitions can be different from the decision requirements definition if they are also deployed inside other DMN resources, as a single decision inside a DMN resource, or added later.

Querying the Decision Repository

All deployed decision definitions and decision requirements definitions can be queried by the repository service API.

Querying Decision Definitions

Get a decision definition with the id “decisionDefinitionId”:

  1. DecisionDefinition decisionDefinition = processEngine
  2. .getDecisionDefinition("decisionDefinitionId");

Query for the latest version of decision definition with the key “decisionDefinitionKey”:

  1. DecisionDefinition decisionDefinition = processEngine
  2. .getRepositoryService()
  3. .createDecisionDefinitionQuery()
  4. .decisionDefinitionKey("decisionDefinitionKey")
  5. .latestVersion()
  6. .singleResult();

Query for all versions of decision definitions with the key“decisionDefinitionKey”:

  1. List<DecisionDefinition> decisionDefinitions = processEngine
  2. .createDecisionDefinitionQuery()
  3. .decisionDefinitionKey("decisionDefinitionKey")
  4. .list();

Additionally, the repository service can be used to get the DMN XML file,a DMN model instance or deployed diagram images.

The decision requirements definitions can be queried in a similar way to the decision definitions.

  1. // query for the latest version of a decision requirements definition by key
  2. DecisionRequirementsDefinition decisionRequirementsDefinition = processEngine
  3. .getRepositoryService()
  4. .createDecisionRequirementsDefinitionQuery()
  5. .decisionRequirementsDefinitionKey(key)
  6. .latestVersion()
  7. .singleResult();
  8. // query for all versions of decision requirements definitions by name
  9. List<DecisionRequirementsDefinition> decisionRequirementsDefinitions = processEngine
  10. .getRepositoryService()
  11. .createDecisionRequirementsDefinitionQuery()
  12. .decisionRequirementsDefinitionName(name)

Authorizations for Querying the Decision Repository

The user needs the READ permission on the resource DECISION_DEFINITION toquery decision definitions. This permission is also required to retrieve decisiondefinitions, decision models and decision diagrams from the repository. Theresource id of the authorization is the decision definition key.

To query decision requirements definitions, the user needs the permission on the resource DECISION_REQUIREMENTS_DEFINITION. Theresource id of the authorization is the key of the decision requirements definitions.

For more information about authorizations, please refer to the AuthorizationService section.

Cockpit

Deployed decision definitions can be viewed in the webapp.