-
Notifications
You must be signed in to change notification settings - Fork 9
/
action.go
95 lines (72 loc) · 2.21 KB
/
action.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package legacybridge
import (
"context"
legacyAction "github.com/TIBCOSoftware/flogo-lib/core/action"
"github.com/project-flogo/core/action"
"github.com/project-flogo/core/data/metadata"
"github.com/project-flogo/core/support/log"
)
func RegisterLegacyAction(ref string, legacyFactory legacyAction.Factory) {
err := action.LegacyRegister(ref, &legacyFactoryWrapper{legacyFactory: legacyFactory})
if err != nil {
log.RootLogger().Warnf("Error registering legacy action '%s': %v", ref, err)
}
}
type legacyFactoryWrapper struct {
legacyFactory legacyAction.Factory
}
func (legacyFactoryWrapper) Initialize(ctx action.InitContext) error {
//ignore
return nil
}
func (w *legacyFactoryWrapper) New(config *action.Config) (action.Action, error) {
lConfig := &legacyAction.Config{}
lConfig.Ref = config.Ref
lConfig.Settings = config.Settings
lConfig.Id = config.Id
legacyAct, err := w.legacyFactory.New(lConfig)
if err != nil {
return nil, err
}
var wa action.Action
if act, ok := legacyAct.(legacyAction.AsyncAction); ok {
wa = wrapAsyncAction(act)
} else if act, ok := legacyAct.(legacyAction.SyncAction); ok {
wa = wrapSyncAction(act)
}
return wa, nil
}
func wrapAsyncAction(legacyAct legacyAction.AsyncAction) action.AsyncAction {
aw := &asyncActWrapper{legacyAct: legacyAct}
//todo wrap metadata
return aw
}
func wrapSyncAction(legacyAct legacyAction.SyncAction) action.SyncAction {
aw := &syncActWrapper{legacyAct: legacyAct}
//todo wrap metadata
return aw
}
type asyncActWrapper struct {
legacyAct legacyAction.AsyncAction
}
func (asyncActWrapper) Metadata() *action.Metadata {
panic("implement me")
}
func (asyncActWrapper) IOMetadata() *metadata.IOMetadata {
panic("implement me")
}
func (asyncActWrapper) Run(context context.Context, inputs map[string]interface{}, handler action.ResultHandler) error {
panic("implement me")
}
type syncActWrapper struct {
legacyAct legacyAction.SyncAction
}
func (syncActWrapper) Metadata() *action.Metadata {
panic("implement me")
}
func (syncActWrapper) IOMetadata() *metadata.IOMetadata {
panic("implement me")
}
func (syncActWrapper) Run(context context.Context, inputs map[string]interface{}) (map[string]interface{}, error) {
panic("implement me")
}