当前位置: 首页>>代码示例>>Java>>正文


Java Entity.getNavigationLink方法代码示例

本文整理汇总了Java中org.apache.olingo.commons.api.data.Entity.getNavigationLink方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.getNavigationLink方法的具体用法?Java Entity.getNavigationLink怎么用?Java Entity.getNavigationLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.olingo.commons.api.data.Entity的用法示例。


在下文中一共展示了Entity.getNavigationLink方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleDeleteSingleNavigationProperties

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
private void handleDeleteSingleNavigationProperties(final EdmEntitySet edmEntitySet,
    final Entity entity, final Entity changedEntity) throws DataProviderException {
  final EdmEntityType entityType = edmEntitySet.getEntityType();
  final List<String> navigationPropertyNames = entityType.getNavigationPropertyNames();

  for (final String navPropertyName : navigationPropertyNames) {
    final Link navigationLink = changedEntity.getNavigationLink(navPropertyName);
    final EdmNavigationProperty navigationProperty =
        entityType.getNavigationProperty(navPropertyName);
    if (!navigationProperty.isCollection() && navigationLink != null
        && navigationLink.getInlineEntity() == null) {

      // Check if partner is available
      if (navigationProperty.getPartner() != null
          && entity.getNavigationLink(navPropertyName) != null) {
        Entity partnerEntity = entity.getNavigationLink(navPropertyName).getInlineEntity();
        removeLink(navigationProperty.getPartner(), partnerEntity);
      }

      // Remove link
      removeLink(navigationProperty, entity);
    }
  }
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:25,代码来源:DataProvider.java

示例2: handleDeleteSingleNavigationProperties

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
private void handleDeleteSingleNavigationProperties(final EdmEntitySet edmEntitySet, final Entity entity,
    final Entity changedEntity) throws DataProviderException {
  final EdmEntityType entityType = edmEntitySet.getEntityType();
  final List<String> navigationPropertyNames = entityType.getNavigationPropertyNames();

  for (final String navPropertyName : navigationPropertyNames) {
    final Link navigationLink = changedEntity.getNavigationLink(navPropertyName);
    final EdmNavigationProperty navigationProperty = entityType.getNavigationProperty(navPropertyName);
    if (!navigationProperty.isCollection() && navigationLink != null && navigationLink.getInlineEntity() == null) {

      // Check if partner is available
      if (navigationProperty.getPartner() != null && entity.getNavigationLink(navPropertyName) != null) {
        Entity partnerEntity = entity.getNavigationLink(navPropertyName).getInlineEntity();
        removeLink(navigationProperty.getPartner(), partnerEntity);
      }

      // Remove link
      removeLink(navigationProperty, entity);
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:22,代码来源:DataProvider.java

示例3: deleteReference

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
public void deleteReference(final Entity entity, final EdmNavigationProperty navigationProperty,
    final String entityId, final String rawServiceRoot) throws DataProviderException {

  if (navigationProperty.isCollection()) {
    final Entity targetEntity = getEntityByReference(entityId, rawServiceRoot);
    final Link navigationLink = entity.getNavigationLink(navigationProperty.getName());

    if (navigationLink != null && navigationLink.getInlineEntitySet() != null
        && navigationLink.getInlineEntitySet().getEntities().contains(targetEntity)) {

      // Remove partner single-valued navigation property
      if (navigationProperty.getPartner() != null) {
        final EdmNavigationProperty edmPartnerNavigationProperty = navigationProperty.getPartner();
        if (!edmPartnerNavigationProperty.isCollection() && !edmPartnerNavigationProperty.isNullable()) {
          throw new DataProviderException("Navigation property must not be null", HttpStatusCode.BAD_REQUEST);
        } else if (!edmPartnerNavigationProperty.isCollection()) {
          removeLink(edmPartnerNavigationProperty, targetEntity);
        } else if (edmPartnerNavigationProperty.isCollection()
            && edmPartnerNavigationProperty.getPartner() != null) {
          // Bidirectional referential constraint
          final Link partnerNavigationLink = targetEntity.getNavigationLink(edmPartnerNavigationProperty.getName());
          if (partnerNavigationLink != null && partnerNavigationLink.getInlineEntitySet() != null) {
            partnerNavigationLink.getInlineEntitySet().getEntities().remove(entity);
          }
        }
      }

      // Remove target entity from collection-valued navigation property
      navigationLink.getInlineEntitySet().getEntities().remove(targetEntity);
    } else {
      throw new DataProviderException("Entity not found", HttpStatusCode.NOT_FOUND);
    }
  } else {
    if (navigationProperty.isNullable()) {
      removeLink(navigationProperty, entity);
    } else {
      throw new DataProviderException("Navigation property must not be null", HttpStatusCode.BAD_REQUEST);
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:41,代码来源:DataProvider.java

示例4: entityBoundActionWithNavigation

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
protected static EntityActionResult entityBoundActionWithNavigation(final String name, 
    final Map<String, Parameter> parameters,
    final Map<String, EntityCollection> data, List<UriParameter> keyList, 
    EdmEntitySet edmEntitySet, EdmNavigationProperty navProperty) 
        throws DataProviderException {
  List<Object> keyPropertyValues = new ArrayList<Object>();
  List<String> keyPropertyNames = new ArrayList<String>();
  if ("BAETTwoKeyNavRTETTwoKeyNavParam".equals(name)) {
    if (!keyList.isEmpty()) {
      setBindingPropertyKeyNameAndValue(keyList, edmEntitySet, keyPropertyValues, keyPropertyNames);
      EntityCollection entityCollection = data.get(edmEntitySet.getName());
      Entity entity = getSpecificEntity(entityCollection, keyPropertyValues, keyPropertyNames);
      
      Link link = entity.getNavigationLink(navProperty.getName());
      Entity inlineEntity = link.getInlineEntity();
      ComplexValue complexValue = inlineEntity.getProperty("PropertyComp").asComplex();
      List<Property> complexProperties = complexValue.getValue();
      Iterator<Property> itr = complexProperties.iterator();
      Parameter actionParam = parameters.get("PropertyComp");
      Property actionProp = actionParam.asComplex().getValue().get(0);
      while (itr.hasNext()) {
        Property property = itr.next();
        if (property.getName().equals(actionProp.getName())) {
          property.setValue(actionProp.getValueType(), actionProp.getValue());
          break;
        }
      }
      return new EntityActionResult().setEntity(inlineEntity);
      }
  }
  throw new DataProviderException("Action " + name + " is not yet implemented.",
      HttpStatusCode.NOT_IMPLEMENTED);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:34,代码来源:ActionData.java

示例5: esAllPrimExpandedToOne

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
@Test
public void esAllPrimExpandedToOne() throws Exception {
  final Entity entity = deserialize("EntityESAllPrimExpandedNavPropertyETTwoPrimOne.json");

  Link navigationLink = entity.getNavigationLink("NavPropertyETTwoPrimOne");
  assertNotNull(navigationLink);

  assertEquals("NavPropertyETTwoPrimOne", navigationLink.getTitle());
  assertEquals(Constants.ENTITY_NAVIGATION_LINK_TYPE, navigationLink.getType());
  assertNotNull(navigationLink.getInlineEntity());
  assertNull(navigationLink.getInlineEntitySet());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:13,代码来源:ODataDeserializerDeepInsertTest.java

示例6: esAllPrimExpandedToMany

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
@Test
public void esAllPrimExpandedToMany() throws Exception {
  final Entity entity = deserialize("EntityESAllPrimExpandedNavPropertyETTwoPrimMany.json");

  Link navigationLink = entity.getNavigationLink("NavPropertyETTwoPrimMany");
  assertNotNull(navigationLink);

  assertEquals("NavPropertyETTwoPrimMany", navigationLink.getTitle());
  assertEquals(Constants.ENTITY_SET_NAVIGATION_LINK_TYPE, navigationLink.getType());
  assertNull(navigationLink.getInlineEntity());
  assertNotNull(navigationLink.getInlineEntitySet());
  assertEquals(1, navigationLink.getInlineEntitySet().getEntities().size());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:14,代码来源:ODataDeserializerDeepInsertTest.java

示例7: extendedEntityProperty

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
@Test
public void extendedEntityProperty() throws Exception {
  final String payload = "{\n" + 
      "   \"@odata.context\":\"$metadata#ETKeyPrimNav/$entity\",\n" + 
      "   \"@odata.metadataEtag\":\"W/metadataETag\",\n" + 
      "   \"@odata.etag\":\"W/32767\",\n" + 
      "   \"PropertyInt16\":32767,\n" + 
      "   \"PropertyString\":\"string\",\n" + 
      "   \"NavPropertyETKeyPrimNavOne\":\n" + 
      "      {\n" + 
      "         \"@odata.type\":\"#olingo.odata.test1.ETKeyPrimNavDerived\",\n" + 
      "         \"PropertyInt16\":32767,\n" + 
      "         \"PropertyString\":\"First Resource - first\",\n" + 
      "         \"PropertyBoolean\":true\n" + 
      "      }\n" + 
      "   \n" + 
      "}";
  final Entity result = deserialize(payload, "ETKeyPrimNav");
  Assert.assertNotNull(result);
  Link navProperty = result.getNavigationLink("NavPropertyETKeyPrimNavOne");
  Assert.assertNotNull(navProperty);
  Entity e = navProperty.getInlineEntity();
  Assert.assertNotNull(e);
  Assert.assertEquals("olingo.odata.test1.ETKeyPrimNavDerived", e.getType());
  Assert.assertEquals(new Short((short)32767), e.getProperty("PropertyInt16").getValue());
  Assert.assertEquals("First Resource - first", e.getProperty("PropertyString").getValue());
  Assert.assertEquals(true, e.getProperty("PropertyBoolean").getValue());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:29,代码来源:ODataJsonDeserializerEntityTest.java

示例8: getRelatedEntity

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
public Entity getRelatedEntity(Entity entity, UriResourceNavigation navigationResource) 
    throws ODataApplicationException {
  
  final EdmNavigationProperty edmNavigationProperty = navigationResource.getProperty();
  
  if(edmNavigationProperty.isCollection()) {
    return Util.findEntity(edmNavigationProperty.getType(), getRelatedEntityCollection(entity, navigationResource), 
       navigationResource.getKeyPredicates());
  } else {
    final Link link = entity.getNavigationLink(edmNavigationProperty.getName());
    return link == null ? null : link.getInlineEntity();
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:14,代码来源:Storage.java

示例9: removeLink

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
private void removeLink(final EdmNavigationProperty navigationProperty, final Entity entity) {
  final Link link = entity.getNavigationLink(navigationProperty.getName());
  if (link != null) {
    entity.getNavigationLinks().remove(link);
  }
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:7,代码来源:DataProvider.java

示例10: deleteReference

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
public void deleteReference(final Entity entity, final EdmNavigationProperty navigationProperty,
    final String entityId, final String rawServiceRoot) throws DataProviderException {

  if (navigationProperty.isCollection()) {
    final Entity targetEntity = getEntityByReference(entityId, rawServiceRoot);
    final Link navigationLink = entity.getNavigationLink(navigationProperty.getName());

    if (navigationLink != null && navigationLink.getInlineEntitySet() != null
        && navigationLink.getInlineEntitySet().getEntities().contains(targetEntity)) {

      // Remove partner single-valued navigation property
      if (navigationProperty.getPartner() != null) {
        final EdmNavigationProperty edmPartnerNavigationProperty =
            navigationProperty.getPartner();
        if (!edmPartnerNavigationProperty.isCollection()
            && !edmPartnerNavigationProperty.isNullable()) {
          throw new DataProviderException("Navigation property must not be null",
              HttpStatusCode.BAD_REQUEST);
        } else if (!edmPartnerNavigationProperty.isCollection()) {
          removeLink(edmPartnerNavigationProperty, targetEntity);
        } else if (edmPartnerNavigationProperty.isCollection()
            && edmPartnerNavigationProperty.getPartner() != null) {
          // Bidirectional referential constraint
          final Link partnerNavigationLink =
              targetEntity.getNavigationLink(edmPartnerNavigationProperty.getName());
          if (partnerNavigationLink != null
              && partnerNavigationLink.getInlineEntitySet() != null) {
            partnerNavigationLink.getInlineEntitySet().getEntities().remove(entity);
          }
        }
      }

      // Remove target entity from collection-valued navigation property
      navigationLink.getInlineEntitySet().getEntities().remove(targetEntity);
    } else {
      throw new DataProviderException("Entity not found", HttpStatusCode.NOT_FOUND);
    }
  } else if (navigationProperty.isNullable()) {
    removeLink(navigationProperty, entity);
  } else {
    throw new DataProviderException("Navigation property must not be null",
        HttpStatusCode.BAD_REQUEST);
  }
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:45,代码来源:DataProvider.java

示例11: applyExpandOptionToEntity

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
private void applyExpandOptionToEntity(final Entity entity, final EdmBindingTarget edmBindingTarget,
    final ExpandOption expandOption, final UriInfoResource uriInfo, final Edm edm) throws ODataApplicationException {

  final EdmEntityType entityType = edmBindingTarget.getEntityType();

  for (ExpandItem item : expandOption.getExpandItems()) {
    if(item.getLevelsOption() != null) {
      throw new ODataApplicationException("$levels is not implemented", 
          HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
    }
    
    List<EdmNavigationProperty> navigationProperties = new ArrayList<EdmNavigationProperty>();
    if(item.isStar()) {
      List<EdmNavigationPropertyBinding> bindings = edmBindingTarget.getNavigationPropertyBindings();
      for (EdmNavigationPropertyBinding binding : bindings) {
        EdmElement property = entityType.getProperty(binding.getPath());
        if(property instanceof EdmNavigationProperty) {
          navigationProperties.add((EdmNavigationProperty) property);
        }
      }
    } else {
      final List<UriResource> uriResourceParts = item.getResourcePath().getUriResourceParts();
      if (uriResourceParts.get(0) instanceof UriResourceNavigation) {
        navigationProperties.add(((UriResourceNavigation) uriResourceParts.get(0)).getProperty());
      }
    }

    for (EdmNavigationProperty navigationProperty: navigationProperties) {
      final String navPropertyName = navigationProperty.getName();
      final EdmBindingTarget targetEdmEntitySet = edmBindingTarget.getRelatedBindingTarget(navPropertyName);

      final Link link = entity.getNavigationLink(navPropertyName);
      if (link != null && entityType.getNavigationProperty(navPropertyName).isCollection()) {
        applyOptionsToEntityCollection(link.getInlineEntitySet(),
            targetEdmEntitySet,
            item.getFilterOption(),
            item.getOrderByOption(),
            item.getCountOption(),
            item.getSkipOption(),
            item.getTopOption(),
            item.getExpandOption(),
            uriInfo, edm);
      }
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:47,代码来源:ExpandSystemQueryOptionHandler.java

示例12: entityESKeyNavContFullMetadataWithContNav

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
@Test
public void entityESKeyNavContFullMetadataWithContNav() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESKeyNavCont");
  final Entity entity = data.readAll(edmEntitySet).getEntities().get(1);
  Link link = entity.getNavigationLink("NavPropertyETContMany");
  InputStream result = serializerFullMetadata.entityCollection(metadata, 
      edmEntitySet.getEntityType().getNavigationProperty("NavPropertyETContMany").getType(), 
      link.getInlineEntitySet(),
      EntityCollectionSerializerOptions.with()
          .contextURL(ContextURL.with().
              type(edmEntitySet.getEntityType().getNavigationProperty("NavPropertyETContMany").getType())
              .entitySetOrSingletonOrType("ESKeyNavCont(-365)/NavPropertyETContMany").build())
          .build()).getContent();
  final String resultString = IOUtils.toString(result);
  final String expected = "{\"@odata.context\":\"$metadata#ESKeyNavCont%28-365%29%2FNavPropertyETContMany\","
      + "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\",\"value\":[{"
      + "\"@odata.type\":\"#olingo.odata.test1.ETCont\",\"@odata.id\":"
      + "\"ESKeyNavCont(-365)/NavPropertyETContMany(-32768)\","
      + "\"[email protected]\":\"#Int16\",\"PropertyInt16\":-32768,"
      + "\"PropertyString\":\"Second Resource - negative values\",\"[email protected]\":"
      + "\"#Int32\",\"PropertyInt32\":-2147483648,\"[email protected]\":\"#Int64\","
      + "\"PropertyInt64\":-9223372036854775808,\"[email protected]\":\"#Single\","
      + "\"PropertySingle\":-1.79E8,\"PropertyDouble\":-179000.0,"
      + "\"[email protected]\":\"#Decimal\",\"PropertyDecimal\":-34,"
      + "\"[email protected]\":\"#Binary\",\"PropertyBinary\":\"ASNFZ4mrze8=\","
      + "\"[email protected]\":\"#Date\",\"PropertyDate\":\"2015-11-05\","
      + "\"[email protected]\":\"#DateTimeOffset\","
      + "\"PropertyDateTimeOffset\":\"2005-12-03T07:17:08Z\","
      + "\"[email protected]\":\"#Duration\","
      + "\"PropertyDuration\":\"PT9S\",\"[email protected]\":"
      + "\"#Guid\",\"PropertyGuid\":\"76543201-23ab-cdef-0123-456789dddfff\","
      + "\"[email protected]\":\"#TimeOfDay\","
      + "\"PropertyTimeOfDay\":\"23:49:14\",\"PropertyBoolean\":false,"
      + "\"[email protected]\":\"#Byte\",\"PropertyByte\":0,"
      + "\"[email protected]\":\"#SByte\",\"PropertySByte\":-128},"
      + "{\"@odata.type\":\"#olingo.odata.test1.ETCont\","
      + "\"@odata.id\":\"ESKeyNavCont(-365)/NavPropertyETContMany(0)\","
      + "\"[email protected]\":\"#Int16\",\"PropertyInt16\":0,"
      + "\"PropertyString\":\"\",\"[email protected]\":\"#Int32\","
      + "\"PropertyInt32\":0,\"[email protected]\":\"#Int64\","
      + "\"PropertyInt64\":0,\"[email protected]\":\"#Single\","
      + "\"PropertySingle\":0.0,\"PropertyDouble\":0.0,"
      + "\"[email protected]\":\"#Decimal\",\"PropertyDecimal\":0,"
      + "\"[email protected]\":\"#Binary\",\"PropertyBinary\":\"\","
      + "\"[email protected]\":\"#Date\",\"PropertyDate\":\"1970-01-01\","
      + "\"[email protected]\":\"#DateTimeOffset\","
      + "\"PropertyDateTimeOffset\":\"2005-12-03T00:00:00Z\","
      + "\"[email protected]\":\"#Duration\",\"PropertyDuration\":\"PT0S\","
      + "\"[email protected]\":\"#Guid\","
      + "\"PropertyGuid\":\"76543201-23ab-cdef-0123-456789cccddd\","
      + "\"[email protected]\":\"#TimeOfDay\","
      + "\"PropertyTimeOfDay\":\"00:01:01\",\"PropertyBoolean\":false,"
      + "\"[email protected]\":\"#Byte\",\"PropertyByte\":0,"
      + "\"[email protected]\":\"#SByte\",\"PropertySByte\":0}]}";        

  Assert.assertEquals(expected, resultString);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:58,代码来源:ODataJsonSerializerTest.java

示例13: getRelatedEntityCollection

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
public EntityCollection getRelatedEntityCollection(Entity entity, UriResourceNavigation navigationResource) {
  final Link link = entity.getNavigationLink(navigationResource.getProperty().getName());
  return link == null ? new EntityCollection() : link.getInlineEntitySet();
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:5,代码来源:Storage.java

示例14: getRelatedEntityCollection

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
public EntityCollection getRelatedEntityCollection(Entity entity, String navigationPropertyName) {
  final Link link = entity.getNavigationLink(navigationPropertyName);
  return link == null ? new EntityCollection() : link.getInlineEntitySet();
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:5,代码来源:Storage.java


注:本文中的org.apache.olingo.commons.api.data.Entity.getNavigationLink方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。