-
Notifications
You must be signed in to change notification settings - Fork 1
/
metadata.go
42 lines (35 loc) · 1.02 KB
/
metadata.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 filewatcher
import (
"github.com/project-flogo/core/data/coerce"
)
type HandlerSettings struct {
DirName string `md:"dirName"` // directory name for watching
AssetName string `md:"assetName"`
SensorName string `md:"sensorName"`
SensorType string `md:"sensorType"`
}
type Output struct {
FileName string `md:"fileName"` // file name to be changed.
AssetName string `md:"assetName"`
SensorName string `md:"sensorName"`
SensorType string `md:"sensorType"`
}
func (o *Output) ToMap() map[string]interface{} {
return map[string]interface{}{
"fileName": o.FileName,
"assetName": o.AssetName,
"sensorName": o.SensorName,
"sensorType": o.SensorType,
}
}
func (o *Output) FromMap(values map[string]interface{}) error {
var err error
o.FileName, err = coerce.ToString(values["fileName"])
o.AssetName, err = coerce.ToString(values["assetName"])
o.SensorName, err = coerce.ToString(values["sensorName"])
o.SensorType, err = coerce.ToString(values["sensorType"])
if err != nil {
return err
}
return nil
}