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 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" )
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 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) 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).