10
10
from pyodata .exceptions import PyODataParserError , PyODataModelError
11
11
from pyodata .model .build_functions import build_entity_set
12
12
from pyodata .model .elements import ComplexType , Schema , NullType , build_element , EntityType , Types , \
13
- StructTypeProperty , build_annotation , Typ
13
+ StructTypeProperty , build_annotation , Typ , Identifier
14
14
from pyodata .policies import ParserError
15
15
from pyodata .v4 .elements import NavigationTypeProperty , NullProperty , ReferentialConstraint , \
16
- NavigationPropertyBinding , to_path_info , EntitySet , Unit , EnumMember , EnumType
16
+ NavigationPropertyBinding , EntitySet , Unit , EnumMember , EnumType
17
17
18
18
19
19
# pylint: disable=protected-access,too-many-locals,too-many-branches,too-many-statements
@@ -115,16 +115,29 @@ def build_schema(config: Config, schema_nodes):
115
115
config .err_policy (ParserError .ENTITY_SET ).resolve (ex )
116
116
117
117
# After all entity sets are parsed resolve the individual bindings among them and entity types
118
+ entity_set : EntitySet
118
119
for entity_set in schema .entity_sets :
120
+ nav_prop_bin : NavigationPropertyBinding
119
121
for nav_prop_bin in entity_set .navigation_property_bindings :
120
- path_info = nav_prop_bin .path_info
121
122
try :
122
- nav_prop_bin .path = schema .entity_type (path_info .type ,
123
- namespace = path_info .namespace ).nav_proprty (path_info .proprty )
124
- nav_prop_bin .target = schema .entity_set (nav_prop_bin .target_info )
123
+ identifiers = nav_prop_bin .path_info
124
+ entity_identifier = identifiers [0 ] if isinstance (identifiers , list ) else entity_set .entity_type_info
125
+ entity = schema .entity_type (entity_identifier .name , namespace = entity_identifier .namespace )
126
+ name = identifiers [- 1 ].name if isinstance (identifiers , list ) else identifiers .name
127
+ nav_prop_bin .path = entity .nav_proprty (name )
128
+
129
+ identifiers = nav_prop_bin .target_info
130
+ if isinstance (identifiers , list ):
131
+ name = identifiers [- 1 ].name
132
+ namespace = identifiers [- 1 ].namespace
133
+ else :
134
+ name = identifiers .name
135
+ namespace = identifiers .namespace
136
+
137
+ nav_prop_bin .target = schema .entity_set (name , namespace )
125
138
except PyODataModelError as ex :
126
139
config .err_policy (ParserError .NAVIGATION_PROPERTY_BIDING ).resolve (ex )
127
- nav_prop_bin .path = NullType (path_info . type )
140
+ nav_prop_bin .path = NullType (nav_prop_bin . path_info [ - 1 ]. name )
128
141
nav_prop_bin .target = NullProperty (nav_prop_bin .target_info )
129
142
130
143
# TODO: Finally, process Annotation nodes when all Scheme nodes are completely processed.
@@ -148,7 +161,9 @@ def build_navigation_type_property(config: Config, node):
148
161
149
162
150
163
def build_navigation_property_binding (config : Config , node , et_info ):
151
- return NavigationPropertyBinding (to_path_info (node .get ('Path' ), et_info ), node .get ('Target' ))
164
+ # return NavigationPropertyBinding(to_path_info(node.get('Path'), et_info), node.get('Target'))
165
+
166
+ return NavigationPropertyBinding (Identifier .parse (node .get ('Path' )), Identifier .parse (node .get ('Target' )))
152
167
153
168
154
169
def build_unit_annotation (config : Config , target : Typ , annotation_node ):
0 commit comments