-
Notifications
You must be signed in to change notification settings - Fork 1
/
activity.go
42 lines (31 loc) · 1.09 KB
/
activity.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
package flogojsontransformer
import (
"github.com/TIBCOSoftware/flogo-lib/core/activity"
"github.com/TIBCOSoftware/flogo-lib/logger"
"github.com/kabukky/kazaam"
)
// activityLog is the default logger for the exec Activity
var log = logger.GetLogger("activity-tibco-flogojsontransformer")
type JsontransformerActivity struct {
metadata *activity.Metadata
}
// NewActivity creates a new AppActivity
func NewActivity(metadata *activity.Metadata) activity.Activity {
return &JsontransformerActivity{metadata: metadata}
}
// Metadata returns the activity's metadata
func (a *JsontransformerActivity) Metadata() *activity.Metadata {
return a.metadata
}
func (a *JsontransformerActivity) Eval(context activity.Context) (done bool, err error) {
log.Info("JSON Transformer starting...")
jsonin, _ := context.GetInput("Input").(string)
spec, _ := context.GetInput("Transformation").(string)
kazaamTransform, _ := kazaam.NewKazaam(spec)
kazaamOut, err := kazaamTransform.TransformJSONStringToString(jsonin)
if err != nil {
log.Info(err)
}
context.SetOutput("result", kazaamOut)
return true, nil
}