- 浏览: 170351 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (173)
- Cocos2d-X (11)
- ubuntu (17)
- ofbiz (7)
- freemarker (1)
- nginx (9)
- redHat (7)
- SpringBoot (13)
- C# (0)
- PHP (2)
- Android (0)
- 咖啡豆 (7)
- Python (21)
- IONIC (8)
- AngularJS (1)
- 大鲸鱼 (10)
- 好玩的东西 (11)
- mysql 占用 (5)
- kelude (1)
- jS (0)
- Wx (1)
- H5-M500 (3)
- 开发即运维 (4)
- ReactNative (11)
- C++ (0)
- 其他杂项 (2)
- Truffle (1)
- WebLogic (0)
- Unity3D (0)
- WeChatMiniProgram (0)
- 小程序 (3)
- OLAP (1)
- ceb (1)
- 微信小程序 (2)
- 小程序undefined (1)
- 小程序机型问题 (1)
- Olingo (1)
- Cocos Creator (2)
- kylin (1)
- docker network (1)
最新评论
-
沈寅麟:
如果:[MySQL] specified key was to ...
OFBiz使用utf8mb4保存emoji -
沈寅麟:
从主机复制文件到容器里主机–>容器1,获取容器ID使用s ...
退出不关闭容器 -
沈寅麟:
conf.d/default.config---------- ...
Nginx配置AJP -
沈寅麟:
配置完nginx,在启动的时候遇到如下问题:nginx: [e ...
Nginx配置AJP -
沈寅麟:
docker commit [OPTIONS] CONTAIN ...
退出不关闭容器
Deep Inserts
OData already supports 'deep inserts'. A 'deep insert' creates an entity and builds a link to an existing entity. So posting here:
~/People(6)/Friends
Inserts a new person and creates a 'friends' link with Person 6.
The same type specification rules apply for deep inserts too, so posting here:
~/People(6)/Friends/HR.Employee
Will succeed only if the type is unambiguous and allowed (i.e. it is an Employee or derived from Employee).
如果你想寻找灵感,可以参考以下代码片段
OData already supports 'deep inserts'. A 'deep insert' creates an entity and builds a link to an existing entity. So posting here:
~/People(6)/Friends
Inserts a new person and creates a 'friends' link with Person 6.
The same type specification rules apply for deep inserts too, so posting here:
~/People(6)/Friends/HR.Employee
Will succeed only if the type is unambiguous and allowed (i.e. it is an Employee or derived from Employee).
如果你想寻找灵感,可以参考以下代码片段
public void simpleDeepInsert() throws Exception { final ODataClient client = getEdmEnabledClient(); final URI createURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build(); final ClientObjectFactory factory = getFactory(); final ClientEntity entity = factory.newEntity(ET_KEY_NAV); // Prepare entity(EntitySet: ESKeyNav, Type: ETKeyNav) entity.getProperties() .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 42))); entity.getProperties() .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("42"))); entity.getProperties() .add(factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_NAV_FIVE_PROP) .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 42))))); entity.getProperties() .add(factory.newComplexProperty(PROPERTY_COMP_ALL_PRIM, factory.newComplexValue(CT_ALL_PRIM) .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("42"))))); entity.getProperties() .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM, factory.newComplexValue(CT_TWO_PRIM) .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 42))) .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("42"))))); entity.getProperties() .add(factory.newComplexProperty(PROPERTY_COMP_COMP_NAV, factory.newComplexValue(CT_PRIM_COMP) .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("42"))) .add(factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_NAV_FIVE_PROP) .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 42))))))); // Non collection navigation property // Create related entity(EntitySet: ESTwoKeyNav, Type: ETTwoKeyNav, Nav. Property: NavPropertyETTwoKeyNavOne) final ClientEntity inlineEntitySingle = factory.newEntity(ET_TWO_KEY_NAV); inlineEntitySingle.getProperties() .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 43))); inlineEntitySingle.getProperties() .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("43"))); inlineEntitySingle.getProperties() .add(factory.newComplexProperty(PROPERTY_COMP, factory.newComplexValue(CT_PRIM_COMP) .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 430))))); inlineEntitySingle.getProperties() .add(factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_PRIM_COMP) .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 431))))); inlineEntitySingle.getProperties() .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM, factory.newComplexValue(CT_TWO_PRIM) .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 432))) .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("432"))))); // Collection navigation property // The navigation property has a partner navigation property named "NavPropertyETKeyNavOne" // Create related entity(EntitySet: ESTwoKeyNav, Type: NavPropertyETTwoKeyNavMany final ClientEntity inlineEntityCol1 = factory.newEntity(ET_TWO_KEY_NAV); inlineEntityCol1.getProperties() .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 44))); inlineEntityCol1.getProperties() .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("44"))); inlineEntityCol1.getProperties() .add(factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_PRIM_COMP) .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 441))))); inlineEntityCol1.getProperties() .add(factory.newComplexProperty(PROPERTY_COMP, factory.newComplexValue(CT_PRIM_COMP) .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 440))))); inlineEntityCol1.getProperties() .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM, factory.newComplexValue(CT_TWO_PRIM) .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 442))) .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("442"))))); final ClientEntity inlineEntityCol2 = factory.newEntity(ET_TWO_KEY_NAV); inlineEntityCol2.getProperties() .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 45))); inlineEntityCol2.getProperties() .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("45"))); inlineEntityCol2.getProperties() .add(factory.newComplexProperty(PROPERTY_COMP_NAV, factory.newComplexValue(CT_PRIM_COMP) .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 451))))); inlineEntityCol2.getProperties() .add(factory.newComplexProperty(PROPERTY_COMP, factory.newComplexValue(CT_PRIM_COMP) .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 450))))); inlineEntityCol2.getProperties() .add(factory.newComplexProperty(PROPERTY_COMP_TWO_PRIM, factory.newComplexValue(CT_TWO_PRIM) .add(factory.newPrimitiveProperty(PROPERTY_INT16, factory.newPrimitiveValueBuilder().buildInt16((short) 452))) .add(factory.newPrimitiveProperty(PROPERTY_STRING, factory.newPrimitiveValueBuilder().buildString("452"))))); final ClientInlineEntity newDeepInsertEntityLink = factory.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, inlineEntitySingle); final ClientEntitySet newDeepInsertEntitySet = factory.newEntitySet(); newDeepInsertEntitySet.getEntities().add(inlineEntityCol1); newDeepInsertEntitySet.getEntities().add(inlineEntityCol2); final ClientInlineEntitySet newDeepInsertEntitySetLink = factory.newDeepInsertEntitySet(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, newDeepInsertEntitySet); entity.addLink(newDeepInsertEntityLink); entity.addLink(newDeepInsertEntitySetLink); // Perform create request final ODataEntityCreateResponse<ClientEntity> responseCreate = client.getCUDRequestFactory() .getEntityCreateRequest(createURI, entity) .execute(); assertEquals(HttpStatusCode.CREATED.getStatusCode(), responseCreate.getStatusCode()); final String cookie = responseCreate.getHeader(HttpHeader.SET_COOKIE).toString(); // Fetch ESKeyNav entity with expand of NavPropertyETTwoKeyNavOne nav. property ClientProperty propertyInt16 = responseCreate.getBody().getProperty(PROPERTY_INT16); final URI esKeyNavURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment( propertyInt16.getPrimitiveValue().toValue()).expand(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).build(); final ODataEntityRequest<ClientEntity> esKeyNavRequest = client.getRetrieveRequestFactory() .getEntityRequest(esKeyNavURI); esKeyNavRequest.addCustomHeader(HttpHeader.COOKIE, cookie); final ODataRetrieveResponse<ClientEntity> esKeyNavResponse = esKeyNavRequest.execute(); final ClientEntity clientEntity = esKeyNavResponse.getBody(); // Check nav. property NavPropertyETTwoKeyNavOne assertNotNull(clientEntity.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE)); ClientInlineEntity navOne = ((ClientInlineEntity) clientEntity.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE)); assertShortOrInt(431, navOne.getEntity().getProperty(PROPERTY_COMP_NAV).getComplexValue() .get(PROPERTY_INT16).getPrimitiveValue().toValue()); // Check nav. property NavPropertyETTwoKeyNavMany assertNotNull(clientEntity.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)); ClientInlineEntitySet navMany = (ClientInlineEntitySet) clientEntity.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY); assertEquals(2, navMany.getEntitySet().getEntities().size()); assertShortOrInt(441, navMany.getEntitySet().getEntities().get(0).getProperty(PROPERTY_COMP_NAV) .getValue().asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue()); assertShortOrInt(451, navMany.getEntitySet().getEntities().get(1).getProperty(PROPERTY_COMP_NAV) .getValue().asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue()); // Fetch ESTwoKeyNav entities and check if available and the partner relation have been set up // Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavOne) Map<String, Object> composedKey = new HashMap<String, Object>(); composedKey.put(PROPERTY_INT16, navOne.getEntity().getProperty(PROPERTY_INT16).getPrimitiveValue().toValue()); composedKey.put(PROPERTY_STRING, navOne.getEntity().getProperty(PROPERTY_STRING).getPrimitiveValue().toValue()); final URI esTwoKeyNavEntitySingleURI = client.newURIBuilder(SERVICE_URI) .appendEntitySetSegment(ES_TWO_KEY_NAV) .appendKeySegment(composedKey) .build(); final ODataEntityRequest<ClientEntity> esTwoKeyNavSingleRequest = client.getRetrieveRequestFactory() .getEntityRequest(esTwoKeyNavEntitySingleURI); esTwoKeyNavSingleRequest.addCustomHeader(HttpHeader.COOKIE, cookie); final ODataRetrieveResponse<ClientEntity> esTwoKeyNavSingleResponse = esTwoKeyNavSingleRequest.execute(); assertShortOrInt(431, esTwoKeyNavSingleResponse.getBody().getProperty(PROPERTY_COMP_NAV).getComplexValue() .get(PROPERTY_INT16).getPrimitiveValue().toValue()); // Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavMany(0)) composedKey.clear(); composedKey.put(PROPERTY_INT16, navMany.getEntitySet().getEntities().get(0).getProperty(PROPERTY_INT16) .getPrimitiveValue().toValue()); composedKey.put(PROPERTY_STRING, navMany.getEntitySet().getEntities().get(0).getProperty(PROPERTY_STRING) .getPrimitiveValue().toValue()); URI esTwoKeyNavEntityManyOneURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey) .expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build(); final ODataEntityRequest<ClientEntity> esTwoKeyNavManyOneRequest = client.getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyOneURI); esTwoKeyNavManyOneRequest.addCustomHeader(HttpHeader.COOKIE, cookie); final ODataRetrieveResponse<ClientEntity> esTwoKeyNavManyOneResponse = esTwoKeyNavManyOneRequest.execute(); assertShortOrInt(441, esTwoKeyNavManyOneResponse.getBody().getProperty(PROPERTY_COMP_NAV) .getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue()); assertNotNull(esTwoKeyNavManyOneResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE)); ClientInlineEntity nvLink = (ClientInlineEntity)esTwoKeyNavManyOneResponse.getBody() .getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE); assertEquals(propertyInt16.getPrimitiveValue().toValue(), nvLink.getEntity().getProperty(PROPERTY_INT16) .getPrimitiveValue().toValue()); // Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavMany(1)) composedKey.clear(); composedKey.put(PROPERTY_INT16, navMany.getEntitySet().getEntities().get(1).getProperty(PROPERTY_INT16) .getPrimitiveValue().toValue()); composedKey.put(PROPERTY_STRING, navMany.getEntitySet().getEntities().get(1).getProperty(PROPERTY_STRING) .getPrimitiveValue().toValue()); URI esTwoKeyNavEntityManyTwoURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey) .expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build(); final ODataEntityRequest<ClientEntity> esTwoKeyNavManyTwoRequest = client.getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyTwoURI); esTwoKeyNavManyTwoRequest.addCustomHeader(HttpHeader.COOKIE, cookie); final ODataRetrieveResponse<ClientEntity> esTwoKeyNavManyTwoResponse = esTwoKeyNavManyTwoRequest.execute(); assertShortOrInt(451, esTwoKeyNavManyTwoResponse.getBody().getProperty(PROPERTY_COMP_NAV) .getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue()); assertNotNull(esTwoKeyNavManyTwoResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE)); nvLink = (ClientInlineEntity)esTwoKeyNavManyTwoResponse.getBody() .getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE); assertEquals(propertyInt16.getPrimitiveValue().toValue(), nvLink.getEntity().getProperty(PROPERTY_INT16) .getPrimitiveValue().toValue()); }
相关推荐
该项目是一款基于freeRTOS操作系统和STM32F103x微控制器的手机远程控制浴室温度系统设计源码,共包含1087个文件,包括580个C语言源文件、269个头文件、45个汇编源文件、36个数据文件、36个目标文件、35个编译规则文件、28个包含文件、27个文本文件、6个源文件、3个归档文件。此系统通过手机远程实现对浴室温度的有效控制,适用于智能浴室环境管理。
labview程序代码参考学习使用,希望对你有所帮助。
labview程序代码参考学习使用,希望对你有所帮助。
labview程序代码参考学习使用,希望对你有所帮助。
labview程序代码参考学习使用,希望对你有所帮助。