-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbase_element.go
44 lines (35 loc) · 1.02 KB
/
base_element.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
package main
import (
"fmt"
"reflect"
)
// BaseElement provides common functionality for element handlers
type BaseElement struct {
processor *ElementProcessor
}
// Implement PropertySetter interface at the base level
func (b *BaseElement) SetProperties(element reflect.Value, info FieldInfo) error {
// Common property setting logic
if err := b.setCommonProperties(element, info); err != nil {
return fmt.Errorf("failed to set common properties: %w", err)
}
return nil
}
// setElementProperties sets common properties for BPMN elements.
func (h *BaseElement) setCommonProperties(el reflect.Value, info FieldInfo) error {
if err := callMethod(el, "SetID", []reflect.Value{
reflect.ValueOf(info.typ),
reflect.ValueOf(info.hash),
}); err != nil {
return fmt.Errorf("failed to set ID: %w", err)
}
if err := callMethod(el, "SetName", []reflect.Value{
reflect.ValueOf(info.name),
}); err != nil {
return fmt.Errorf("failed to set name: %w", err)
}
return nil
}
func (h *BaseElement) Cleanup() {
// Cleanup resources
}