@@ -14,8 +14,8 @@ class TDInputBuilder(object):
14
14
# Rules for 'free-text' fields
15
15
__value_rules = []
16
16
17
- # Rules for fields with 'option ' constraints
18
- __option_rules = []
17
+ # Rules for fields with 'oneof ' constraints
18
+ __oneof_rules = []
19
19
20
20
def add_value_rule (self , domain , type , value ):
21
21
"""
@@ -48,19 +48,19 @@ def add_value_rule(self, domain, type, value):
48
48
"""
49
49
self .__value_rules .append ((domain , type , value ))
50
50
51
- def add_option_rule (self , domain , type ):
51
+ def add_oneof_rule (self , domain , type ):
52
52
"""
53
- Adds an rule how to process fields with 'options ' constraints.
53
+ Adds an rule how to process fields with 'oneOf ' constraints.
54
54
55
55
Example:
56
56
ib = TDInputBuilder()
57
- ib.add_option_rule ('http://someont.de/#Color', 'http://someont.de/#Red')
57
+ ib.add_oneof_rule ('http://someont.de/#Color', 'http://someont.de/#Red')
58
58
input_params = ib.build(some_action)
59
59
60
60
This sets the value of the field with the following type description to "#ff0000"
61
61
{
62
62
"type": "string",
63
- "options ": [
63
+ "oneOf ": [
64
64
{
65
65
"value": "#0000ff",
66
66
"dbo:Colour": "dbr:Blue"
@@ -78,7 +78,7 @@ def add_option_rule(self, domain, type):
78
78
@type type str
79
79
@param type Full IRI of the fields value type.
80
80
"""
81
- self .__option_rules .append ((domain , type ))
81
+ self .__oneof_rules .append ((domain , type ))
82
82
83
83
def __dispatch_value_field (self , ns_repo , key , value , datatype ):
84
84
"""
@@ -97,19 +97,19 @@ def __dispatch_value_field(self, ns_repo, key, value, datatype):
97
97
return rule_value
98
98
return None
99
99
100
- def __dispatch_options_field (self , ns_repo , options ):
100
+ def __dispatch_oneof_field (self , ns_repo , options ):
101
101
"""
102
- Determines the value of a 'options ' constrained field using the rules given.
102
+ Determines the value of a 'oneOf ' constrained field using the rules given.
103
103
@return Returns the value imposed by an applicable rule or None if no rule was applicable.
104
104
"""
105
105
for option in options :
106
106
for key , value in option .items ():
107
- if key != 'value ' :
108
- for rule_domain , rule_type in self .__option_rules :
107
+ if key != 'constant ' :
108
+ for rule_domain , rule_type in self .__oneof_rules :
109
109
domain = ns_repo .resolve (key )
110
110
type = ns_repo .resolve (value )
111
111
if sparql .classes_equivalent (domain , rule_domain ) and sparql .classes_equivalent (type , rule_type ):
112
- return option ['value ' ]
112
+ return option ['constant ' ]
113
113
return None
114
114
115
115
def __dispatch_type_description (self , ns_repo , it ):
@@ -121,12 +121,12 @@ def __dispatch_type_description(self, ns_repo, it):
121
121
"""
122
122
if it ['type' ] != 'object' :
123
123
for key , value in it .items ():
124
- if key == 'options ' :
125
- v = self .__dispatch_options_field (ns_repo , it ['options ' ])
124
+ if key == 'oneOf ' :
125
+ v = self .__dispatch_oneof_field (ns_repo , it ['oneOf ' ])
126
126
if v :
127
127
return v
128
128
else :
129
- raise UnknownSemanticsException ('The semantics of none of the options could be determined.' )
129
+ raise UnknownSemanticsException ('The semantics of none of the oneOf options could be determined.' )
130
130
131
131
elif isinstance (key , str ) and isinstance (value , str ):
132
132
v = self .__dispatch_value_field (ns_repo , key , value , it ['type' ])
0 commit comments