def action_of_complex_value(): print r"==action_of_complex_value==" client.send_data_to_server(r"ResetDataSource").get() home_address = r"People(1)/HomeAddress" home_address_value = odata_client_python.to_complex_value(client.get_data_from_server(home_address).get()[0]) property_value = odata_client_python.odata_value() home_address_value.get_property_value(r"City", property_value) print odata_client_python.to_primitive_value(property_value).to_string() == r"Tokyo" model = client.get_model().get() address_type = model.find_complex_type(r"Address") new_address1 = odata_client_python.odata_complex_value(address_type) new_address1.set_value(r"City", r"Shanghai") new_address1.set_value(r"PostalCode", r"200000") new_address1.set_value(r"Street", r"Zixing Road") addresses = odata_client_python.odata_collection_value(odata_client_python.edm_collection_type(r"AddressCollection", address_type)) addresses.add_collection_value(new_address1) parameters = odata_client_python.vector_odata_parameter() parameters.push_back(odata_client_python.odata_parameter(r"addresses", addresses)) parameters.push_back(odata_client_python.odata_parameter(r"index", odata_client_python.odata_primitive_value.make_primitive_value(0))) returned_values = odata_client_python.vector_odata_value() client.send_data_to_server(r"People(1)/Microsoft.Test.OData.Services.ODataWCFService.ResetAddress", parameters, returned_values).get() print len(returned_values) == 1 returned_value = returned_values[0] home_address_value = odata_client_python.to_complex_value(client.get_data_from_server(home_address).get()[0]) home_address_value.get_property_value(r"City", property_value) print odata_client_python.to_primitive_value(property_value).to_string() == r"Shanghai" returned_entity_value = odata_client_python.to_entity_value(returned_value) returned_entity_value.get_property_value(r"HomeAddress", property_value) odata_client_python.to_complex_value(property_value).get_property_value(r"City", property_value) print odata_client_python.to_primitive_value(property_value).to_string() == r"Shanghai"
def action_of_complex_value(): print r"==action_of_complex_value==" client.send_data_to_server(r"ResetDataSource").get() home_address = r"People(1)/HomeAddress" home_address_value = odata_client_python.to_complex_value( client.get_data_from_server(home_address).get()[0]) property_value = odata_client_python.odata_value() home_address_value.get_property_value(r"City", property_value) print odata_client_python.to_primitive_value( property_value).to_string() == r"Tokyo" model = client.get_model().get() address_type = model.find_complex_type(r"Address") new_address1 = odata_client_python.odata_complex_value(address_type) new_address1.set_value(r"City", r"Shanghai") new_address1.set_value(r"PostalCode", r"200000") new_address1.set_value(r"Street", r"Zixing Road") addresses = odata_client_python.odata_collection_value( odata_client_python.edm_collection_type(r"AddressCollection", address_type)) addresses.add_collection_value(new_address1) parameters = odata_client_python.vector_odata_parameter() parameters.push_back( odata_client_python.odata_parameter(r"addresses", addresses)) parameters.push_back( odata_client_python.odata_parameter( r"index", odata_client_python.odata_primitive_value.make_primitive_value(0))) returned_values = odata_client_python.vector_odata_value() client.send_data_to_server( r"People(1)/Microsoft.Test.OData.Services.ODataWCFService.ResetAddress", parameters, returned_values).get() print len(returned_values) == 1 returned_value = returned_values[0] home_address_value = odata_client_python.to_complex_value( client.get_data_from_server(home_address).get()[0]) home_address_value.get_property_value(r"City", property_value) print odata_client_python.to_primitive_value( property_value).to_string() == r"Shanghai" returned_entity_value = odata_client_python.to_entity_value(returned_value) returned_entity_value.get_property_value(r"HomeAddress", property_value) odata_client_python.to_complex_value(property_value).get_property_value( r"City", property_value) print odata_client_python.to_primitive_value( property_value).to_string() == r"Shanghai"
def query_complex(self, query_ex, ret_type): if self._client is None: return [] values = self._client.get_data_from_server(query_ex).get() ret = [] for value in values: if value is None: continue complex_value = odata_client_python.to_complex_value(value) if complex_value is None: continue ret.append(ret_type.create_instance_from_complex(complex_value, self)) return ret
def query_complex_property(): print r"==query_complex_property==" client.send_data_to_server(r"ResetDataSource").get() query_result = client.get_data_from_server(r"People(1)/HomeAddress").get() print len(query_result) == 1 print query_result[0].get_value_type().get_type_kind() == odata_client_python.Complex property_value = odata_client_python.to_complex_value(query_result[0]) street_field = odata_client_python.odata_value() print property_value.get_property_value(r"Street", street_field) print street_field.get_value_type().get_type_kind() == odata_client_python.Primitive primitive_value = odata_client_python.to_primitive_value(street_field) street = primitive_value.to_string() print street == r"1 Microsoft Way"
def operation_query_complex(self, query_ex, parameters, is_function, ret_type): if self._client is None: return None ret_values = odata_client_python.vector_odata_value() self._client.send_data_to_server(query_ex, parameters, ret_values, odata_client_python.HTTP_GET if is_function else odata_client_python.HTTP_POST).get() ret = [] for value in ret_values: if value is None: continue complex_value = odata_client_python.to_complex_value(value) if complex_value is None: continue ret.append(ret_type.create_instance_from_complex(complex_value, self)) return ret
def query_complex_property(): print r"==query_complex_property==" client.send_data_to_server(r"ResetDataSource").get() query_result = client.get_data_from_server(r"People(1)/HomeAddress").get() print len(query_result) == 1 print query_result[0].get_value_type().get_type_kind( ) == odata_client_python.Complex property_value = odata_client_python.to_complex_value(query_result[0]) street_field = odata_client_python.odata_value() print property_value.get_property_value(r"Street", street_field) print street_field.get_value_type().get_type_kind( ) == odata_client_python.Primitive primitive_value = odata_client_python.to_primitive_value(street_field) street = primitive_value.to_string() print street == r"1 Microsoft Way"