-
Notifications
You must be signed in to change notification settings - Fork 21
/
commandInputRecordSchema.go
75 lines (59 loc) · 1.86 KB
/
commandInputRecordSchema.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
package cwl
import (
"fmt"
//"github.com/davecgh/go-spew/spew"
//"reflect"
)
// http://www.commonwl.org/v1.0/CommandLineTool.html#CommandInputRecordSchema
type CommandInputRecordSchema struct {
RecordSchema `yaml:",inline" json:",inline" bson:",inline" mapstructure:",squash"` // provides Type, Label, Name
Fields []CommandInputRecordField `yaml:"fields,omitempty" json:"fields,omitempty" bson:"fields,omitempty"`
}
func NewCommandInputRecordSchema(native_map map[string]interface{}) (cirs *CommandInputRecordSchema, err error) {
cirs = &CommandInputRecordSchema{}
var rs *RecordSchema
rs, err = NewRecordSchema(native_map)
if err != nil {
return
}
cirs.RecordSchema = *rs
return
}
func NewCommandInputRecordSchemaFromInterface(native interface{}, schemata []CWLType_Type) (cirs *CommandInputRecordSchema, err error) {
native, err = MakeStringMap(native)
if err != nil {
return
}
switch native.(type) {
case map[string]interface{}:
native_map, ok := native.(map[string]interface{})
if !ok {
err = fmt.Errorf("(NewInputRecordSchemaFromInterface) type switch error")
return
}
cirs, err = NewCommandInputRecordSchema(native_map)
if err != nil {
return
}
fields, has_fields := native_map["fields"]
if !has_fields {
err = fmt.Errorf("(NewInputRecordSchemaFromInterface) no fields")
return
}
var fields_array []interface{}
fields_array, ok = fields.([]interface{})
if !ok {
err = fmt.Errorf("(NewInputRecordSchemaFromInterface) fields is not array")
return
}
cirs.Fields, err = CreateCommandInputRecordFieldArray(fields_array, schemata)
if err != nil {
err = fmt.Errorf("(NewInputRecordSchemaFromInterface) CreateInputRecordFieldArray returns: %s", err.Error())
return
}
return
default:
err = fmt.Errorf("(NewInputRecordSchemaFromInterface) error")
}
return
}