-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom_schema_types.config
65 lines (60 loc) · 2.07 KB
/
custom_schema_types.config
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
custom_schema_types {
allowed_input_types = [
'BAM'
]
allowed_bam_types = [
'normal',
'tumor'
]
allowed_resource_types = [
'memory',
'cpus'
]
/**
* Check namespace for resource updates
*/
check_resource_update_namespace = { Map options, String name, Map properties ->
custom_schema_types.check_if_namespace(options[name], name)
def given_keys = options[name].keySet() as ArrayList
if (given_keys.size() <= 0) {
return
}
custom_schema_types.check_input_type_keys(given_keys, name, custom_schema_types.allowed_resource_types)
options[name].each { entry ->
def entry_as_map = [:]
entry_as_map[entry.key] = entry.value
schema.validate_parameter(entry_as_map, entry.key, properties.elements[entry.key])
}
}
/**
* Check list of resource updates
*/
check_resource_update_list = { Map options, String name, Map properties ->
custom_schema_types.check_if_list(options[name], name)
for (item in options[name]) {
custom_schema_types.check_if_process_list(item[0], name)
custom_schema_types.check_if_number(item[1], name)
}
}
/**
* Check if given input is valid process list
*/
check_if_process_list = { val, String name ->
if (custom_schema_types.is_string(val)) {
if (val.isEmpty()) {
throw new Exception("Empty string specified for ${name}. Please provide valid input.")
}
} else {
try {
custom_schema_types.check_if_list(val, name)
} catch(Exception e) {
throw new Exception("${name} should be either a string or a list. Please provide valid input.")
}
}
}
types = [
'MapList': custom_schema_types.check_list_of_namespace,
'ResourceUpdateNamespace': custom_schema_types.check_resource_update_namespace,
'ResourceUpdateList': custom_schema_types.check_resource_update_list
]
}