forked from nitram509/lib-bpmn-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
engine_process_instance.go
68 lines (55 loc) · 1.65 KB
/
engine_process_instance.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package bpmn_engine
import (
"github.com/ipsitasbgit/lib-bpmn-engine/pkg/bpmn_engine/var_holder"
"time"
"github.com/ipsitasbgit/lib-bpmn-engine/pkg/spec/BPMN20/process_instance"
)
type ProcessInstanceInfo struct {
processInfo *ProcessInfo
instanceKey int64
variableHolder var_holder.VariableHolder
createdAt time.Time
state process_instance.State
caughtEvents []catchEvent
}
type ProcessInstance interface {
GetProcessInfo() *ProcessInfo
GetInstanceKey() int64
// GetVariable from the process instance's variable context
GetVariable(key string) interface{}
// SetVariable to the process instance's variable context
SetVariable(key string, value interface{})
GetCreatedAt() time.Time
GetState() process_instance.State
}
func (pii *ProcessInstanceInfo) GetProcessInfo() *ProcessInfo {
return pii.processInfo
}
func (pii *ProcessInstanceInfo) GetInstanceKey() int64 {
return pii.instanceKey
}
func (pii *ProcessInstanceInfo) GetVariable(key string) interface{} {
return pii.variableHolder.GetVariable(key)
}
func (pii *ProcessInstanceInfo) SetVariable(key string, value interface{}) {
pii.variableHolder.SetVariable(key, value)
}
func (pii *ProcessInstanceInfo) GetCreatedAt() time.Time {
return pii.createdAt
}
// GetState returns one of [READY, ACTIVE, COMPLETED, FAILED]
// State diagram:
// ┌─────┐
// │Ready│
// └──┬──┘
// |
// ┌───▽──┐
// │Active│
// └───┬──┘
// |
// ┌────▽────┐
// │Completed│
// └─────────┘
func (pii *ProcessInstanceInfo) GetState() process_instance.State {
return pii.state
}