Skip to content

Commit 95b0854

Browse files
committed
refactor XML structs towards BPMN standard
1 parent df05e1f commit 95b0854

File tree

2 files changed

+100
-66
lines changed

2 files changed

+100
-66
lines changed

pkg/spec/BPMN20/bpmn_structs.go

Lines changed: 97 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ type TDefinitions struct {
1414
Messages []TMessage `xml:"message"`
1515
}
1616

17+
type TCallableElement struct {
18+
TRootElement
19+
Name string `xml:"name,attr"`
20+
}
21+
1722
type TProcess struct {
18-
Id string `xml:"id,attr"`
19-
Name string `xml:"name,attr"`
23+
TCallableElement
2024
ProcessType string `xml:"processType,attr"`
2125
IsClosed bool `xml:"isClosed,attr"`
2226
IsExecutable bool `xml:"isExecutable,attr"`
@@ -36,8 +40,8 @@ type TProcess struct {
3640
}
3741

3842
type TSubProcess struct {
39-
Id string `xml:"id,attr"`
40-
Name string `xml:"name,attr"`
43+
TActivity
44+
TriggeredByEvent bool `xml:"triggeredByEvent,attr"`
4145
StartEvents []TStartEvent `xml:"startEvent"`
4246
EndEvents []TEndEvent `xml:"endEvent"`
4347
SequenceFlows []TSequenceFlow `xml:"sequenceFlow"`
@@ -50,13 +54,52 @@ type TSubProcess struct {
5054
IntermediateTrowEvent []TIntermediateThrowEvent `xml:"intermediateThrowEvent"`
5155
EventBasedGateway []TEventBasedGateway `xml:"eventBasedGateway"`
5256
InclusiveGateway []TInclusiveGateway `xml:"inclusiveGateway"`
53-
IncomingAssociation []string `xml:"incoming"`
54-
OutgoingAssociation []string `xml:"outgoing"`
57+
}
58+
59+
// TBaseElement is an "abstract" struct
60+
type TBaseElement struct {
61+
Id string `xml:"id,attr"`
62+
Documentation string `xml:"documentation"`
63+
}
64+
65+
// TRootElement is an "abstract" struct
66+
type TRootElement struct {
67+
TBaseElement
68+
}
69+
70+
// TEventDefinition is an "abstract" struct
71+
type TEventDefinition struct {
72+
TRootElement
73+
}
74+
75+
type TFlowElement struct {
76+
TBaseElement
77+
Name string `xml:"name,attr"`
78+
}
79+
80+
type TGateway struct {
81+
TFlowNode
82+
GatewayDirection GatewayDirection `xml:"gatewayDirection,attr"`
83+
}
84+
85+
type TFlowNode struct {
86+
TFlowElement
87+
IncomingAssociation []string `xml:"incoming"`
88+
OutgoingAssociation []string `xml:"outgoing"`
89+
}
90+
91+
// TEvent is an "abstract" struct
92+
type TEvent struct {
93+
TFlowNode
94+
}
95+
96+
// TCatchEvent is an "abstract" struct
97+
type TCatchEvent struct {
98+
TEvent
5599
}
56100

57101
type TSequenceFlow struct {
58-
Id string `xml:"id,attr"`
59-
Name string `xml:"name,attr"`
102+
TFlowElement
60103
SourceRef string `xml:"sourceRef,attr"`
61104
TargetRef string `xml:"targetRef,attr"`
62105
ConditionExpression []TExpression `xml:"conditionExpression"`
@@ -67,114 +110,102 @@ type TExpression struct {
67110
}
68111

69112
type TStartEvent struct {
70-
Id string `xml:"id,attr"`
71-
Name string `xml:"name,attr"`
72-
IsInterrupting bool `xml:"isInterrupting,attr"`
73-
ParallelMultiple bool `xml:"parallelMultiple,attr"`
74-
IncomingAssociation []string `xml:"incoming"`
75-
OutgoingAssociation []string `xml:"outgoing"`
113+
TCatchEvent
114+
IsInterrupting bool `xml:"isInterrupting,attr"`
115+
ParallelMultiple bool `xml:"parallelMultiple,attr"`
76116
}
77117

78118
type TEndEvent struct {
79-
Id string `xml:"id,attr"`
80-
Name string `xml:"name,attr"`
81-
IncomingAssociation []string `xml:"incoming"`
82-
OutgoingAssociation []string `xml:"outgoing"`
119+
TThrowEvent
83120
}
84121

85122
type TServiceTask struct {
86-
Id string `xml:"id,attr"`
87-
Name string `xml:"name,attr"`
88-
Default string `xml:"default,attr"`
89-
CompletionQuantity int `xml:"completionQuantity,attr"`
90-
IsForCompensation bool `xml:"isForCompensation,attr"`
91-
OperationRef string `xml:"operationRef,attr"`
92-
Implementation string `xml:"implementation,attr"`
93-
IncomingAssociation []string `xml:"incoming"`
94-
OutgoingAssociation []string `xml:"outgoing"`
95-
Input []extensions.TIoMapping `xml:"extensionElements>ioMapping>input"`
96-
Output []extensions.TIoMapping `xml:"extensionElements>ioMapping>output"`
97-
TaskDefinition extensions.TTaskDefinition `xml:"extensionElements>taskDefinition"`
123+
TTask
124+
Default string `xml:"default,attr"`
125+
CompletionQuantity int `xml:"completionQuantity,attr"`
126+
IsForCompensation bool `xml:"isForCompensation,attr"`
127+
OperationRef string `xml:"operationRef,attr"`
128+
Implementation string `xml:"implementation,attr"`
129+
Input []extensions.TIoMapping `xml:"extensionElements>ioMapping>input"`
130+
Output []extensions.TIoMapping `xml:"extensionElements>ioMapping>output"`
131+
TaskDefinition extensions.TTaskDefinition `xml:"extensionElements>taskDefinition"`
132+
}
133+
134+
// TActivity is an "abstract" struct
135+
type TActivity struct {
136+
TFlowNode
137+
IsForCompensation bool `xml:"isForCompensation,attr"`
138+
StartQuantity int `xml:"startQuantity,attr" default:"1"`
139+
CompletionQuantity int `xml:"completionQuantity,attr"`
140+
}
141+
142+
type TTask struct {
143+
TActivity
98144
}
99145

100146
type TUserTask struct {
101-
Id string `xml:"id,attr"`
102-
Name string `xml:"name,attr"`
103-
IncomingAssociation []string `xml:"incoming"`
104-
OutgoingAssociation []string `xml:"outgoing"`
147+
TTask
105148
Input []extensions.TIoMapping `xml:"extensionElements>ioMapping>input"`
106149
Output []extensions.TIoMapping `xml:"extensionElements>ioMapping>output"`
107150
AssignmentDefinition extensions.TAssignmentDefinition `xml:"extensionElements>assignmentDefinition"`
108151
}
109152

110153
type TParallelGateway struct {
111-
Id string `xml:"id,attr"`
112-
Name string `xml:"name,attr"`
113-
IncomingAssociation []string `xml:"incoming"`
114-
OutgoingAssociation []string `xml:"outgoing"`
154+
TGateway
115155
}
116156

117157
type TExclusiveGateway struct {
118-
Id string `xml:"id,attr"`
119-
Name string `xml:"name,attr"`
120-
IncomingAssociation []string `xml:"incoming"`
121-
OutgoingAssociation []string `xml:"outgoing"`
158+
TGateway
122159
}
123160

124161
type TIntermediateCatchEvent struct {
125-
Id string `xml:"id,attr"`
126-
Name string `xml:"name,attr"`
127-
IncomingAssociation []string `xml:"incoming"`
128-
OutgoingAssociation []string `xml:"outgoing"`
162+
TCatchEvent
129163
MessageEventDefinition TMessageEventDefinition `xml:"messageEventDefinition"`
130164
TimerEventDefinition TTimerEventDefinition `xml:"timerEventDefinition"`
131165
LinkEventDefinition TLinkEventDefinition `xml:"linkEventDefinition"`
132166
ParallelMultiple bool `xml:"parallelMultiple"`
133167
Output []extensions.TIoMapping `xml:"extensionElements>ioMapping>output"`
134168
}
135169

170+
type TThrowEvent struct {
171+
TEvent
172+
}
173+
136174
type TIntermediateThrowEvent struct {
137-
Id string `xml:"id,attr"`
138-
Name string `xml:"name,attr"`
139-
IncomingAssociation []string `xml:"incoming"`
175+
TThrowEvent
140176
LinkEventDefinition TLinkEventDefinition `xml:"linkEventDefinition"`
141177
Output []extensions.TIoMapping `xml:"extensionElements>ioMapping>output"`
142178
}
143179

144180
type TEventBasedGateway struct {
145-
Id string `xml:"id,attr"`
146-
Name string `xml:"name,attr"`
147-
IncomingAssociation []string `xml:"incoming"`
148-
OutgoingAssociation []string `xml:"outgoing"`
181+
TGateway
149182
}
150183

151184
type TMessageEventDefinition struct {
152-
Id string `xml:"id,attr"`
185+
TEventDefinition
153186
MessageRef string `xml:"messageRef,attr"`
154187
}
155188

156189
type TTimerEventDefinition struct {
157-
Id string `xml:"id,attr"`
190+
TEventDefinition
158191
TimeDuration TTimeDuration `xml:"timeDuration"`
159192
}
160193

161-
type TLinkEventDefinition struct {
162-
Id string `xml:"id,attr"`
163-
Name string `xml:"name,attr"`
194+
type TTimeDuration struct {
195+
XMLText string `xml:",innerxml"`
164196
}
165197

166-
type TMessage struct {
167-
Id string `xml:"id,attr"`
198+
type TLinkEventDefinition struct {
199+
TEventDefinition
168200
Name string `xml:"name,attr"`
169201
}
170202

171-
type TTimeDuration struct {
172-
XMLText string `xml:",innerxml"`
203+
type TMessage struct {
204+
TRootElement
205+
Name string `xml:"name,attr"`
206+
ItemRef string `xml:"itemRef,attr"`
173207
}
174208

175209
type TInclusiveGateway struct {
176-
Id string `xml:"id,attr"`
177-
Name string `xml:"name,attr"`
178-
IncomingAssociation []string `xml:"incoming"`
179-
OutgoingAssociation []string `xml:"outgoing"`
210+
TGateway
180211
}

pkg/spec/BPMN20/doc.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Package BPMN20 contains structs and interfaces to parse BPMN (XML) files,
2+
// based on specification BPMN v2.0.2, see https://www.omg.org/spec/BPMN/
3+
package BPMN20

0 commit comments

Comments
 (0)