Decision Service
A Decision Service packages a part of the decision requirements graph behind an interface. A caller passes its parameters and gets back the values of its output decisions.
Semantics
A decision service has four lists:
- Output Decisions: The decisions whose values the service returns.
- Encapsulated Decisions: The decisions the outputs need that stay inside the service. A caller never sees their values.
- Input Data: The input data the members read. Each one is a parameter.
- Input Decisions: Decisions outside the service that the members read. Each one is a parameter. The caller passes its value, and the service does not evaluate it.
The service is a function. Its parameters are the input data first, then the input decisions, each group in the order the service lists it. A service with one output decision returns that decision's value. A service with several returns a context keyed by the output decision names. The service's variable carries the service's name and the type of that result.
A file may leave out the encapsulated decisions and the inputs, since they follow from the requirements. The modeler fills them in on import and saves the complete lists.
Usage
- Business rule task: A BPMN task calls the service by its ID, see Calling a decision service.
- Evaluate API: Name the service in
decisionServices, see Evaluation. - Invocation: A decision with a knowledge requirement on the service calls it with an invocation.
In the Modeler
The service is a rounded rectangle with its name and parameters in the header. Encapsulated decisions sit in the upper section and output decisions below the divider line. A service without encapsulated decisions has no divider, and all its members are outputs.
- Membership: Drag a decision into the service to add it. Above the divider it becomes encapsulated, below it an output. Dragging it across the divider changes its role, and dragging it out of the service removes it. The move button next to each member in the properties panel does the same, and gives a service with only outputs its first encapsulated decision. Only decisions go inside a service. Input data dropped on one returns to where it was.
- Shared decisions: A decision can belong to several services. Dropping a decision that sits in one service onto another adds it there as a shadow, and the decision stays where it was. Dragging a shadow onto another service moves that membership there. Dragging it out of its service or deleting it removes the decision from that service only. A requirement between two members of a service is drawn inside that service, on the shadow where it has one.
- Parameters: The properties panel shows the signature, for example
Pricing(Applicant, Score) → Offer. The parameters follow from the requirements the members have on nodes outside the service. The up and down buttons reorder them within the input data and within the input decisions. A new parameter goes at the end of its group. - Output type: With one output decision the service has that decision's type. With several it returns a context, and you can pick an item definition for it.
- Collapse: The button in the header collapses the service to a box that shows its signature. Requirements that cross the border then end on the box.
- Test: The Test button in the properties panel evaluates the service with the values you enter for its parameters. The results list each decision the service evaluated, with its value and the rules it matched.
The modeler reports an error for a member that is not a decision, and a warning for an encapsulated decision no output decision needs and for an input no member reads.
File Format
The saved file holds the four lists, a <variable> named like the service, isCollapsed on the service's shape and, when the service has encapsulated decisions, a DMNDecisionServiceDividerLine. On import, membership comes from the lists, never from where the shapes sit. A service drawn with its output decisions on top is flipped, so its encapsulated decisions sit on top.
A decision in several services has one shape. Each other service records where its shadow sits as a quantum:shadow element in the di:extension of the service's shape, which other tools ignore. On import, a decision listed by several services goes into the first service whose border holds its shape, or else into the first service that lists it, and the other services get shadows.