Documentation
¶
Index ¶
- Constants
- func ApplyParameters(p *Process, parameters map[string]model.ElementParameters) (issues []model.Issue)
- func BlockedScripts(p *Process, blocklist *script.Blocklist) (issues []model.Issue)
- func CheckTimerMinimum(e *Element, minimum time.Duration) []model.Issue
- func FillEmptyTimers(xml string, value func(elementId string) (timer.Kind, string)) (string, []string, error)
- func GeneratedSvgVersion(svg string) int
- func RenderSvg(xml string) (svg string, ok bool)
- func StartParameters(e *Element) []model.StartParameter
- func Validate(p *Process, rules Rules) (issues []model.Issue)
- func WithDiagram(xml string) (result string, added bool, err error)
- type Element
- type ElementScript
- type ElementType
- type EventKind
- type Flow
- type FormField
- type MapEntry
- type Mapping
- type MessageRef
- type Process
- type Rules
- type TimerDefinition
- type Value
- type ValueKind
Constants ¶
const ( NsBpmnDi = "http://www.omg.org/spec/BPMN/20100524/DI" NsDc = "http://www.omg.org/spec/DD/20100524/DC" NsDi = "http://www.omg.org/spec/DD/20100524/DI" )
const ( NsBpmn = "http://www.omg.org/spec/BPMN/20100524/MODEL" NsCamunda = "http://camunda.org/schema/1.0/bpmn" NsSenergy = "https://senergy.infai.org" NsXsi = "http://www.w3.org/2001/XMLSchema-instance" )
const ( NsBioColor = "http://bpmn.io/schema/bpmn/biocolor/1.0" NsColor = "http://www.omg.org/spec/BPMN/non-normative/color/1.0" )
const SvgGeneratorVersion = 1
SvgGeneratorVersion names the drawing rules of RenderSvg in every SVG it creates. Raise it with every change to what a generated SVG shows, so that SVGs of an older generator can be found with GeneratedSvgVersion and drawn anew.
Variables ¶
This section is empty.
Functions ¶
func ApplyParameters ¶
func ApplyParameters(p *Process, parameters map[string]model.ElementParameters) (issues []model.Issue)
ApplyParameters sets the values a deployment overrides per element: input mappings by name as text, senergy:variables of device events, timer definitions and defaults of start form fields (DEP-01). Overrides of elements, inputs or fields the process does not have are issues.
func BlockedScripts ¶ added in v0.31.0
BlockedScripts returns an issue for each element with a copy of a script that ended the engine, also with other comments and whitespace (EXPR-03). A deploy checks it again after its parameters replaced inputs.
func CheckTimerMinimum ¶
CheckTimerMinimum reports a literal timer duration shorter than minimum; deploy parameters can set a timer after validation, so the deploy checks it again (DEP-01).
func FillEmptyTimers ¶ added in v0.50.0
func FillEmptyTimers(xml string, value func(elementId string) (timer.Kind, string)) (string, []string, error)
FillEmptyTimers gives every timer without definition, as the old designer leaves them, the kind and value that value returns for the id of its element; a timer without value stays empty. The ids of the timers found empty are returned. The deploy dialog of process-deployment wrote its time into such a timer (SNRGY-5063), an update to a new model version carries that time over (SNRGY-5180).
func GeneratedSvgVersion ¶ added in v0.51.0
GeneratedSvgVersion returns the generator version that created svg, or 0 for an SVG the engine did not create, e.g. one of the designer.
func RenderSvg ¶ added in v0.51.0
RenderSvg draws the main diagram of a BPMN model as SVG, for a model a client stored without one. It reads the positions of bpmndi:BPMNDiagram, sent by the client or added by WithDiagram, and follows the look of the designer (bpmn-js): shapes, markers and labels in Arial, every element in a group with data-element-id. The symbols are drawn by the engine, so the result is similar to an export of the designer, not equal. The diagrams of collapsed subprocesses are left out, as in an export of the designer. A model without diagram, e.g. one stored before the engine added them, is drawn in the layout of WithDiagram. ok is false for a model that is no BPMN or has nothing to draw; the output of a model is always the same.
func StartParameters ¶
func StartParameters(e *Element) []model.StartParameter
StartParameters lists the form fields of a start event without those marked ignore_on_start (RUN-02).
func WithDiagram ¶ added in v0.9.0
WithDiagram adds a bpmndi:BPMNDiagram to a model that has none, so that a designer can show a model a client sent without one. The layout puts the flow nodes in layers along the sequence flows, lanes as bands and the participants of a collaboration as pools; a subprocess with content is shown collapsed with a diagram of its own. Annotations, data objects and message flows get no position. A model with a diagram, or one that is no BPMN, comes back unchanged with added false.
Types ¶
type Element ¶
type Element struct {
Id string
Name string
Type ElementType
Kind EventKind
Incoming []*Flow
Outgoing []*Flow
DefaultFlow *Flow
Message *MessageRef
Timer *TimerDefinition
Inputs []Mapping
Outputs []Mapping
// script task
Script string
ResultVariable string
// service task (TASK-00, TASK-07)
TaskType string
Retries *int
Timeout string
// start event form fields (BPMN-02)
FormFields []FormField
// senergy:* attributes by local name, e.g. device event descriptions
Attributes map[string]string
// camunda:properties of the element
Properties map[string]string
// id of the lane the element is in; the deploy dialog groups by lane (BPMN-01)
Lane string
// boundary event: the task it is attached to, and camunda:errorMessageVariable, the instance
// variable that receives the error message (BPMN-19)
AttachedTo *Element
ErrorMessageVariable string
// task: the error boundary events attached to it; validation allows at most one
Boundaries []*Element
// contains filtered or unexported fields
}
func (*Element) ErrorBoundary ¶ added in v0.38.0
ErrorBoundary returns the error boundary event that catches the errors of the task, or nil.
func (*Element) HasMappings ¶
func (*Element) IsDeviceCommand ¶
IsDeviceCommand reports a service task that sends device commands (TASK-01).
func (*Element) IsDeviceConnection ¶ added in v0.45.0
IsDeviceConnection reports a service task that reads the connection state of a device (SNRGY-5151).
func (*Element) IsDeviceEvent ¶
IsDeviceEvent reports a message event that waits for device or import data (EVT-03).
func (*Element) Key ¶
Key identifies the element for namespace rules, e.g. "startEvent:timer" (NS-06).
func (*Element) Successors ¶ added in v0.38.0
Successors returns the elements a token can move to from this element: the targets of its flows and its boundary events.
type ElementScript ¶ added in v0.31.0
ElementScript is a script of a process with the element it runs at.
type ElementType ¶
type ElementType string
ElementType is the local name of a supported BPMN flow node (BPMN-01 to BPMN-16).
const ( StartEvent ElementType = "startEvent" EndEvent ElementType = "endEvent" IntermediateCatchEvent ElementType = "intermediateCatchEvent" IntermediateThrowEvent ElementType = "intermediateThrowEvent" Task ElementType = "task" ScriptTask ElementType = "scriptTask" ServiceTask ElementType = "serviceTask" ExclusiveGateway ElementType = "exclusiveGateway" ParallelGateway ElementType = "parallelGateway" InclusiveGateway ElementType = "inclusiveGateway" EventBasedGateway ElementType = "eventBasedGateway" // only with an error definition, attached to a task (BPMN-19) BoundaryEvent ElementType = "boundaryEvent" )
func (ElementType) CanCatchErrors ¶ added in v0.38.0
func (this ElementType) CanCatchErrors() bool
CanCatchErrors reports the tasks an error boundary event may be attached to (BPMN-19).
func (ElementType) IsEvent ¶
func (this ElementType) IsEvent() bool
func (ElementType) IsGateway ¶
func (this ElementType) IsGateway() bool
type Flow ¶
type Flow struct {
Id string
Name string
Source *Element
Target *Element
// JavaScript condition, empty if the flow is unconditional
Condition string
// contains filtered or unexported fields
}
type MessageRef ¶
type MessageRef struct {
// id of the bpmn:message the event refers to, if any
Id string
// literal message name; empty for device events, whose name the engine assigns per deployment
Name string
DeviceEvent bool
// senergy:messageName, a JavaScript expression for the name, evaluated when the event waits;
// e.g. the done event of a deployment a module created (SMS-04)
Expression string
}
type Process ¶
type Process struct {
Id string
Name string
// senergy:description of the process, which the designer of smart services writes
Description string
Elements map[string]*Element
Flows map[string]*Flow
// element ids in document order, for deterministic iteration
Order []string
}
func Parse ¶
Parse reads BPMN XML into a process graph. It returns an error only if no process can be read at all. Everything outside the supported subset is reported as an issue that names the element (BPMN-18); Validate adds the semantic checks.
func ParseAndValidate ¶
ParseAndValidate combines Parse and Validate; issues block a deploy and are hints on a model save.
func (*Process) NoneStartEvent ¶
NoneStartEvent returns the start event used for starts through the API, or nil.
func (*Process) Scripts ¶ added in v0.31.0
func (this *Process) Scripts() (result []ElementScript)
Scripts lists the JavaScript of the process as the engine runs it: script tasks, script values of input and output mappings, message names, timer expressions, the conditions of sequence flows at their source element, the conditions of device and import events and the joined pre- and postscripts of module tasks (EXPR-03, blocklist).
func (*Process) StartEvents ¶
type Rules ¶
type Rules struct {
// element keys like "startEvent" or "startEvent:timer"; a rule on the type covers all kinds
Elements model.ListRule
TaskTypes model.ListRule
// reports whether the engine implements a task type; nil accepts every type
TaskTypeAvailable func(taskType string) bool
// reject cycles in the sequence flow, so that every run ends (SMS-03)
ForbidCycles bool
// shortest timer duration; 0 allows every duration. process-deployment rejected durations
// below 5 s, which keeps loops with a timer from flooding instances and history.
MinTimerDuration time.Duration
// scripts that ended the engine (EXPR-03); nil blocks nothing
Blocklist *script.Blocklist
}
Rules restrict the supported subset per namespace (NS-03, NS-06).