1010from pyodata .exceptions import PyODataParserError , PyODataModelError
1111from pyodata .model .build_functions import build_entity_set
1212from pyodata .model .elements import ComplexType , Schema , NullType , build_element , EntityType , Types , \
13- StructTypeProperty , build_annotation , Typ
13+ StructTypeProperty , build_annotation , Typ , Identifier
1414from pyodata .policies import ParserError
1515from pyodata .v4 .elements import NavigationTypeProperty , NullProperty , ReferentialConstraint , \
16- NavigationPropertyBinding , to_path_info , EntitySet , Unit , EnumMember , EnumType
16+ NavigationPropertyBinding , EntitySet , Unit , EnumMember , EnumType
1717
1818
1919# pylint: disable=protected-access,too-many-locals,too-many-branches,too-many-statements
@@ -115,16 +115,29 @@ def build_schema(config: Config, schema_nodes):
115115 config .err_policy (ParserError .ENTITY_SET ).resolve (ex )
116116
117117 # After all entity sets are parsed resolve the individual bindings among them and entity types
118+ entity_set : EntitySet
118119 for entity_set in schema .entity_sets :
120+ nav_prop_bin : NavigationPropertyBinding
119121 for nav_prop_bin in entity_set .navigation_property_bindings :
120- path_info = nav_prop_bin .path_info
121122 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 )
125138 except PyODataModelError as ex :
126139 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 )
128141 nav_prop_bin .target = NullProperty (nav_prop_bin .target_info )
129142
130143 # TODO: Finally, process Annotation nodes when all Scheme nodes are completely processed.
@@ -148,7 +161,9 @@ def build_navigation_type_property(config: Config, node):
148161
149162
150163def 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' )))
152167
153168
154169def build_unit_annotation (config : Config , target : Typ , annotation_node ):
0 commit comments