• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CsdlNavigationProperty类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty的典型用法代码示例。如果您正苦于以下问题:Java CsdlNavigationProperty类的具体用法?Java CsdlNavigationProperty怎么用?Java CsdlNavigationProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CsdlNavigationProperty类属于org.apache.olingo.commons.api.edm.provider包,在下文中一共展示了CsdlNavigationProperty类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getESNavigationProperties

import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入依赖的package包/类
/**
 * Gets Elasticsearch navigation properties map.
 * 
 * @return properties map, with key - property name and value -
 *         {@link ElasticEdmNavigationProperty} instance
 */
public Map<String, ElasticEdmNavigationProperty> getESNavigationProperties() {
    if (navigationPropertiesCash == null) {
        Map<String, ElasticEdmNavigationProperty> localNavigationProperties = new LinkedHashMap<>();
        List<CsdlNavigationProperty> structuredTypeNavigationProperties = csdlEntityType
                .getNavigationProperties();
        for (CsdlNavigationProperty property : structuredTypeNavigationProperties) {
            if (property instanceof ElasticCsdlNavigationProperty) {
                localNavigationProperties.put(property.getName(),
                        new ElasticEdmNavigationProperty(edm,
                                (ElasticCsdlNavigationProperty) property));
            }
        }
        navigationPropertiesCash = Collections.unmodifiableMap(localNavigationProperties);
    }
    return navigationPropertiesCash;
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:23,代码来源:ElasticEdmEntityType.java


示例2: getNavigationProperties

import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入依赖的package包/类
public Map<String, EdmNavigationProperty> getNavigationProperties() {
  if (navigationProperties == null) {
    final Map<String, EdmNavigationProperty> localNavigationProperties =
        new LinkedHashMap<String, EdmNavigationProperty>();
    final List<CsdlNavigationProperty> structuredTypeNavigationProperties =
        providerStructuredType.getNavigationProperties();

    if (structuredTypeNavigationProperties != null) {
      for (CsdlNavigationProperty navigationProperty : structuredTypeNavigationProperties) {
        localNavigationProperties.put(navigationProperty.getName(),
            new EdmNavigationPropertyImpl(edm, navigationProperty));
      }
    }

    navigationProperties = Collections.unmodifiableMap(localNavigationProperties);
  }
  return navigationProperties;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:AbstractEdmStructuredType.java


示例3: navigationProperty

import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入依赖的package包/类
@Test
public void navigationProperty() throws Exception {
  CsdlEdmProvider provider = mock(CsdlEdmProvider.class);
  EdmProviderImpl edm = new EdmProviderImpl(provider);
  final FullQualifiedName entityTypeName = new FullQualifiedName("ns", "entity");
  CsdlEntityType entityTypeProvider = new CsdlEntityType();
  entityTypeProvider.setKey(Collections.<CsdlPropertyRef> emptyList());
  when(provider.getEntityType(entityTypeName)).thenReturn(entityTypeProvider);
  CsdlNavigationProperty propertyProvider = new CsdlNavigationProperty();
  propertyProvider.setType(entityTypeName);
  propertyProvider.setNullable(false);
  EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider);
  assertFalse(property.isCollection());
  assertFalse(property.isNullable());
  EdmType type = property.getType();
  assertEquals(EdmTypeKind.ENTITY, type.getKind());
  assertEquals("ns", type.getNamespace());
  assertEquals("entity", type.getName());
  assertNull(property.getReferencingPropertyName("referencedPropertyName"));
  assertNull(property.getPartner());
  assertFalse(property.containsTarget());

  // Test caching
  EdmType cachedType = property.getType();
  assertTrue(type == cachedType);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:27,代码来源:EdmNavigationPropertyImplTest.java


示例4: navigationPropertyWithPartner

import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入依赖的package包/类
@Test
public void navigationPropertyWithPartner() throws Exception {
  CsdlEdmProvider provider = mock(CsdlEdmProvider.class);
  EdmProviderImpl edm = new EdmProviderImpl(provider);
  final FullQualifiedName entityTypeName = new FullQualifiedName("ns", "entity");
  CsdlEntityType entityTypeProvider = new CsdlEntityType();
  entityTypeProvider.setKey(Collections.<CsdlPropertyRef> emptyList());

  List<CsdlNavigationProperty> navigationProperties = new ArrayList<CsdlNavigationProperty>();
  navigationProperties.add(new CsdlNavigationProperty().setName("partnerName").setType(entityTypeName));
  entityTypeProvider.setNavigationProperties(navigationProperties);
  when(provider.getEntityType(entityTypeName)).thenReturn(entityTypeProvider);
  CsdlNavigationProperty propertyProvider = new CsdlNavigationProperty();
  propertyProvider.setType(entityTypeName);
  propertyProvider.setNullable(false);
  propertyProvider.setPartner("partnerName");
  EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider);
  EdmNavigationProperty partner = property.getPartner();
  assertNotNull(partner);

  // Caching
  assertTrue(partner == property.getPartner());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:24,代码来源:EdmNavigationPropertyImplTest.java


示例5: navigationPropertyWithNonexistentPartner

import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入依赖的package包/类
@Test(expected = EdmException.class)
public void navigationPropertyWithNonexistentPartner() throws Exception {
  CsdlEdmProvider provider = mock(CsdlEdmProvider.class);
  EdmProviderImpl edm = new EdmProviderImpl(provider);
  final FullQualifiedName entityTypeName = new FullQualifiedName("ns", "entity");
  CsdlEntityType entityTypeProvider = new CsdlEntityType();
  entityTypeProvider.setKey(Collections.<CsdlPropertyRef> emptyList());

  List<CsdlNavigationProperty> navigationProperties = new ArrayList<CsdlNavigationProperty>();
  navigationProperties.add(new CsdlNavigationProperty().setName("partnerName").setType(entityTypeName));
  entityTypeProvider.setNavigationProperties(navigationProperties);
  when(provider.getEntityType(entityTypeName)).thenReturn(entityTypeProvider);
  CsdlNavigationProperty propertyProvider = new CsdlNavigationProperty();
  propertyProvider.setType(entityTypeName);
  propertyProvider.setNullable(false);
  propertyProvider.setPartner("wrong");
  EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider);
  property.getPartner();
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:EdmNavigationPropertyImplTest.java


示例6: readEntityType

import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入依赖的package包/类
private void readEntityType(XMLEventReader reader, StartElement element, CsdlSchema schema)
    throws XMLStreamException {
  CsdlEntityType entityType = new CsdlEntityType();
  entityType.setProperties(new ArrayList<CsdlProperty>());
  entityType.setNavigationProperties(new ArrayList<CsdlNavigationProperty>());
  entityType.setKey(new ArrayList<CsdlPropertyRef>());
  entityType.setName(attr(element, "Name"));
  if (attr(element, "BaseType") != null) {
    entityType.setBaseType(new FullQualifiedName(attr(element, "BaseType")));
  }
  entityType.setAbstract(Boolean.parseBoolean(attr(element, "Abstract")));
  entityType.setOpenType(Boolean.parseBoolean(attr(element, "OpenType")));
  entityType.setHasStream(Boolean.parseBoolean(attr(element, "HasStream")));
  readEntityProperties(reader, entityType);
  schema.getEntityTypes().add(entityType);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:17,代码来源:MetadataParser.java


示例7: fetchLastBaseEntityHavingNavigationProperty

import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入依赖的package包/类
/**
 * This fetches the last Base Type entity from a hierarchy of base type derived types
 * @param baseTypeFQName
 * @return CsdlNavigationProperty
 */
private CsdlNavigationProperty fetchLastBaseEntityHavingNavigationProperty(
    FullQualifiedName baseTypeFQName, String navBindingProperty) {
  CsdlEntityType baseEntityType = null;
  while (baseTypeFQName != null) {
    if (!(csdlEntityTypesMap.containsKey(baseTypeFQName))) {
      baseTypeFQName = validateCsdlEntityTypeWithAlias(baseTypeFQName);
    }
    baseEntityType = csdlEntityTypesMap.get(baseTypeFQName);
    if (baseEntityType != null) {
      if (baseEntityType.getNavigationProperty(navBindingProperty) != null) {
        break;
      } else if (baseEntityType.getBaseType() != null) {
        baseTypeFQName = baseEntityType.getBaseTypeFQN();
      } else if (baseEntityType.getBaseType() == null) {
        break;
      }
    }
  }
  if (baseEntityType == null) {
    throw new RuntimeException("Entity Type is null with fully qualified name:" + baseTypeFQName);
  }
  return baseEntityType.getNavigationProperty(navBindingProperty);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:29,代码来源:CsdlTypeValidator.java


示例8: fetchNavigationProperty

import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入依赖的package包/类
/**
 * fetch the actual navigation property from the remaning path
 * @param remainingPath
 * @param strNavProperty
 * @param sourceTypeHavingNavProp
 * @return CsdlNavigationProperty
 */
private CsdlNavigationProperty fetchNavigationProperty(String remainingPath,
    String strNavProperty, CsdlStructuralType sourceTypeHavingNavProp) {
  String[] paths = remainingPath.split("/");
  for (String path : paths) {
    FullQualifiedName fqName = null;
    if (sourceTypeHavingNavProp instanceof CsdlComplexType) {
      fqName = ((CsdlComplexType)sourceTypeHavingNavProp).getProperty(path).getTypeAsFQNObject();
    } else if (sourceTypeHavingNavProp instanceof CsdlEntityType) {
      fqName = ((CsdlEntityType)sourceTypeHavingNavProp).getProperty(path).getTypeAsFQNObject();
    }
    if (fqName != null) {
      String namespace = aliasNamespaceMap.get(fqName.getNamespace());
      fqName = namespace != null ? new FullQualifiedName(namespace, fqName.getName()) : fqName;
    }
    
    sourceTypeHavingNavProp = csdlEntityTypesMap.get(fqName) != null ? 
        csdlEntityTypesMap.get(fqName) : 
          csdlComplexTypesMap.get(fqName);
  }
  return sourceTypeHavingNavProp.getNavigationProperty(strNavProperty);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:29,代码来源:CsdlTypeValidator.java


示例9: CsdlNav

import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入依赖的package包/类
CsdlNav(Class<?> typeOfTarget, String sourceProp, boolean isCollection) throws CsdlExtractException {
    ODataEntity targetEntity = typeOfTarget.getAnnotation(ODataEntity.class);
    if (targetEntity == null) {
        throw new CsdlExtractException("Type " + typeOfTarget.getName() + " must be annotated as ODataEntity");
    }

    navigationBinding = new CsdlNavigationPropertyBinding().setTarget(targetEntity.entitySetName())
                                                           .setPath(sourceProp);
    navigationProp = new CsdlNavigationProperty().setName(sourceProp).setType(
            FullQualifiedNamesUtil.createFullQualifiedEntityName(targetEntity.name()))
                                                 .setCollection(isCollection);
}
 
开发者ID:mat3e,项目名称:olingo-jpa,代码行数:13,代码来源:JpaEntityCsdlProvider.java


示例10: getNavigationProperties_EntityTypeNameAndMappings_OneChildPropertyRetrieved

import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入依赖的package包/类
@Test
public void getNavigationProperties_EntityTypeNameAndMappings_OneChildPropertyRetrieved() {
    doReturn(getParentChildMappings()).when(metaDataProvider).getMappingsForField(AUTHORS_INDEX,
            ElasticConstants.PARENT_PROPERTY);
    MultyElasticIndexCsdlEdmProvider edmProvider = new MultyElasticIndexCsdlEdmProvider(
            metaDataProvider, indices);
    List<ElasticCsdlNavigationProperty> navigationProperties = edmProvider
            .getNavigationProperties(AUTHORS_INDEX, AUTHOR_TYPE);
    assertEquals(1, navigationProperties.size());
    CsdlNavigationProperty navigationProperty = navigationProperties.get(0);
    assertEquals(BOOK_TYPE, navigationProperty.getName());
    assertTrue(navigationProperty.isCollection());
    assertEquals(AUTHOR_TYPE, navigationProperty.getPartner());
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:15,代码来源:MultyElasticIndexCsdlEdmProviderTest.java


示例11: getNavigationProperties_EntityTypeNameAndMappings_OneParentPropertyRetrieved

import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入依赖的package包/类
@Test
public void getNavigationProperties_EntityTypeNameAndMappings_OneParentPropertyRetrieved() {
    doReturn(getParentChildMappings()).when(metaDataProvider).getMappingsForField(AUTHORS_INDEX,
            ElasticConstants.PARENT_PROPERTY);
    MultyElasticIndexCsdlEdmProvider edmProvider = new MultyElasticIndexCsdlEdmProvider(
            metaDataProvider, indices);
    List<ElasticCsdlNavigationProperty> navigationProperties = edmProvider
            .getNavigationProperties(AUTHORS_INDEX, BOOK_TYPE);
    assertEquals(1, navigationProperties.size());
    CsdlNavigationProperty navigationProperty = navigationProperties.get(0);
    assertEquals(AUTHOR_TYPE, navigationProperty.getName());
    assertFalse(navigationProperty.isCollection());
    assertEquals(BOOK_TYPE, navigationProperty.getPartner());
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:15,代码来源:MultyElasticIndexCsdlEdmProviderTest.java


示例12: createEntityType_IndexAndType_EntityTypeRetrived

import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入依赖的package包/类
@Test
public void createEntityType_IndexAndType_EntityTypeRetrived()
        throws ODataException, IOException {
    MultyElasticIndexCsdlEdmProvider edmProvider = new MultyElasticIndexCsdlEdmProvider(
            metaDataProvider, indices);
    doReturn(getStubProperties()).when(metaDataProvider).getMappingForType(AUTHORS_INDEX,
            AUTHOR_TYPE);
    doReturn(getParentChildMappings()).when(metaDataProvider).getMappingsForField(AUTHORS_INDEX,
            ElasticConstants.PARENT_PROPERTY);
    ElasticCsdlEntityType entityType = edmProvider.createEntityType(AUTHORS_INDEX, AUTHOR_TYPE);
    assertTrue(entityType instanceof ElasticCsdlEntityType);
    assertEquals(AUTHORS_INDEX, ((ElasticCsdlEntityType) entityType).getESIndex());
    assertEquals(AUTHOR_TYPE, ((ElasticCsdlEntityType) entityType).getESType());
    List<CsdlProperty> properties = entityType.getProperties();
    assertEquals(3, properties.size());
    CsdlProperty idProperty = properties.get(2);
    assertEquals(ElasticConstants.ID_FIELD_NAME, idProperty.getName());
    List<CsdlPropertyRef> keys = entityType.getKey();
    assertEquals(1, keys.size());
    CsdlPropertyRef idRef = keys.get(0);
    assertEquals(ElasticConstants.ID_FIELD_NAME, idRef.getName());
    List<CsdlNavigationProperty> navigationProperties = entityType.getNavigationProperties();
    assertEquals(1, navigationProperties.size());
    ElasticCsdlNavigationProperty bookProperty = (ElasticCsdlNavigationProperty) navigationProperties
            .get(0);
    assertEquals(BOOK_TYPE, bookProperty.getName());
    assertEquals(BOOK_TYPE, bookProperty.getESType());
    assertEquals(AUTHORS_INDEX, bookProperty.getESIndex());
    assertEquals(BOOK_FQN, bookProperty.getTypeFQN());
    assertEquals(AUTHOR_TYPE, bookProperty.getPartner());
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:32,代码来源:MultyElasticIndexCsdlEdmProviderTest.java


示例13: CsdlProvider

import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入依赖的package包/类
private CsdlProvider(final String name) {
   this.name = name;
namespace = NAMESPACE_PREFIX + name;
   other = name.equals("One") ? "Two" : "One";
   entitySet = new CsdlEntitySet().setName(ENTITY_SET_PREFIX + name)
       .setType(new FullQualifiedName(namespace, ENTITY_TYPE_PREFIX + name));
   entityType = new CsdlEntityType().setName(ENTITY_TYPE_PREFIX + name)
       .setKey(Collections.singletonList(new CsdlPropertyRef().setName("ID" + name)))
       .setProperties(Collections.singletonList(
           new CsdlProperty().setName("ID" + name).setNullable(false).setType("Edm.Guid")))
       .setNavigationProperties(Collections.singletonList(
           new CsdlNavigationProperty().setName("Navigation" + other)
               .setType(new FullQualifiedName(ALIAS_PREFIX + other, ENTITY_TYPE_PREFIX + other))));
 }
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:15,代码来源:CrossServiceTest.java


示例14: navigationPropertyWithReferntialConstraint

import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入依赖的package包/类
@Test
public void navigationPropertyWithReferntialConstraint() throws Exception {
  CsdlEdmProvider provider = mock(CsdlEdmProvider.class);
  EdmProviderImpl edm = new EdmProviderImpl(provider);
  final FullQualifiedName entityTypeName = new FullQualifiedName("ns", "entity");
  CsdlEntityType entityTypeProvider = new CsdlEntityType();
  entityTypeProvider.setKey(Collections.<CsdlPropertyRef> emptyList());
  when(provider.getEntityType(entityTypeName)).thenReturn(entityTypeProvider);
  CsdlNavigationProperty propertyProvider = new CsdlNavigationProperty();
  propertyProvider.setType(entityTypeName);
  propertyProvider.setNullable(false);
  propertyProvider.setContainsTarget(true);
  List<CsdlReferentialConstraint> referentialConstraints = new ArrayList<CsdlReferentialConstraint>();
  referentialConstraints.add(new CsdlReferentialConstraint().setProperty("property").setReferencedProperty(
      "referencedProperty"));
  propertyProvider.setReferentialConstraints(referentialConstraints);

  EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider);
  assertEquals("property", property.getReferencingPropertyName("referencedProperty"));
  assertNull(property.getReferencingPropertyName("wrong"));
  assertTrue(property.containsTarget());
  
  assertNotNull(property.getReferentialConstraints());
  List<EdmReferentialConstraint> edmReferentialConstraints = property.getReferentialConstraints();
  assertEquals(1, edmReferentialConstraints.size());
  assertTrue(edmReferentialConstraints == property.getReferentialConstraints());
  
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:29,代码来源:EdmNavigationPropertyImplTest.java


示例15: navigationPropertyWithNonExistentType

import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入依赖的package包/类
@Test(expected = EdmException.class)
public void navigationPropertyWithNonExistentType() throws Exception {
  EdmProviderImpl edm = mock(EdmProviderImpl.class);
  CsdlNavigationProperty propertyProvider = new CsdlNavigationProperty();
  EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider);
  property.getType();
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:8,代码来源:EdmNavigationPropertyImplTest.java


示例16: setupTypes

import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入依赖的package包/类
@Before
public void setupTypes() throws Exception {
  CsdlEdmProvider provider = mock(CsdlEdmProvider.class);
  EdmProviderImpl edm = new EdmProviderImpl(provider);

  FullQualifiedName baseName = new FullQualifiedName("namespace", "BaseTypeName");
  CsdlComplexType baseComplexType = new CsdlComplexType();
  List<CsdlProperty> baseProperties = new ArrayList<CsdlProperty>();
  baseProperties.add(new CsdlProperty().setName("prop1").setType(
      EdmPrimitiveTypeKind.String.getFullQualifiedName()));
  List<CsdlNavigationProperty> baseNavigationProperties = new ArrayList<CsdlNavigationProperty>();
  baseNavigationProperties.add(new CsdlNavigationProperty().setName("nav1"));
  baseComplexType.setName("BaseTypeName").setAbstract(false).setOpenType(false).setProperties(baseProperties)
      .setNavigationProperties(baseNavigationProperties);
  when(provider.getComplexType(baseName)).thenReturn(baseComplexType);

  baseType = new EdmComplexTypeImpl(edm, baseName, baseComplexType);

  FullQualifiedName name = new FullQualifiedName("namespace", "typeName");
  CsdlComplexType complexType = new CsdlComplexType().setBaseType(baseName);
  List<CsdlProperty> properties = new ArrayList<CsdlProperty>();
  properties.add(new CsdlProperty().setName("prop2").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()));
  List<CsdlNavigationProperty> navigationProperties = new ArrayList<CsdlNavigationProperty>();
  navigationProperties.add(new CsdlNavigationProperty().setName("nav2"));
  complexType.setName("BaseTypeName").setAbstract(false).setOpenType(false).setProperties(properties)
      .setNavigationProperties(navigationProperties);
  when(provider.getComplexType(name)).thenReturn(complexType);

  type = new EdmComplexTypeImpl(edm, name, complexType);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:31,代码来源:EdmComplexTypeImplTest.java


示例17: readComplexType

import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入依赖的package包/类
private void readComplexType(XMLEventReader reader, StartElement element, CsdlSchema schema)
    throws XMLStreamException {
  CsdlComplexType complexType = new CsdlComplexType();
  complexType.setProperties(new ArrayList<CsdlProperty>());
  complexType.setNavigationProperties(new ArrayList<CsdlNavigationProperty>());
  complexType.setName(attr(element, "Name"));
  if (attr(element, "BaseType") != null) {
    complexType.setBaseType(new FullQualifiedName(attr(element, "BaseType")));
  }
  complexType.setAbstract(Boolean.parseBoolean(attr(element, "Abstract")));
  complexType.setOpenType(Boolean.parseBoolean(attr(element, "OpenType")));
  readProperties(reader, complexType);

  schema.getComplexTypes().add(complexType);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:16,代码来源:MetadataParser.java


示例18: validateReferentialConstraint

import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入依赖的package包/类
/**
 * @param sourceEntityType
 * @param targetEntityType
 * @param navProperty
 */
private void validateReferentialConstraint(CsdlEntityType sourceEntityType, CsdlEntityType targetEntityType,
    CsdlNavigationProperty navProperty) {
  if (!navProperty.getReferentialConstraints().isEmpty()) {
    String propertyName = navProperty.getReferentialConstraints().get(0).getProperty();
    if (sourceEntityType.getProperty(propertyName) == null) {
      throw new RuntimeException("Property name " + propertyName + " not part of the source entity.");
    }
    String referencedPropertyName = navProperty.getReferentialConstraints().get(0).getReferencedProperty();
    if (targetEntityType.getProperty(referencedPropertyName) == null) {
      throw new RuntimeException("Property name " + referencedPropertyName + " not part of the target entity.");
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:CsdlTypeValidator.java


示例19: findLastQualifiedNameHavingNavigationProperty

import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入依赖的package包/类
/**
 * This looks for the last fully qualified identifier to fetch the navigation property
 * e.g if navigation property path is Microsoft.Exchange.Services.OData.Model.ItemAttachment/Item 
 * then it fetches the entity ItemAttachment and fetches the navigation property Item
 * if navigation property path is EntityType/ComplexType/OData.Model.DerivedComplexType/Item
 * then it fetches the complex type DerivedComplexType and fetches the navigation property Item
 * @param navBindingPath
 * @return CsdlNavigationProperty
 */
private CsdlNavigationProperty findLastQualifiedNameHavingNavigationProperty(String navBindingPath,
    CsdlEntityType sourceEntityType) {
  String[] paths = navBindingPath.split("/");
  String lastFullQualifiedName = "";
  for (String path : paths) {
    if (path.contains(".")) {
      lastFullQualifiedName = path;
    }
  }
  String strNavProperty = paths[paths.length - 1];
  String remainingPath = navBindingPath.substring(navBindingPath.indexOf(lastFullQualifiedName) 
      + lastFullQualifiedName.length() + (lastFullQualifiedName.length() == 0 ? 0 : 1), 
      navBindingPath.lastIndexOf(strNavProperty));
  if (remainingPath.length() > 0) {
    remainingPath = remainingPath.substring(0, remainingPath.length() - 1);
  }
  CsdlNavigationProperty navProperty = null;
  CsdlEntityType sourceEntityTypeHavingNavProp = lastFullQualifiedName.length() == 0 ? sourceEntityType : 
    (csdlEntityTypesMap.containsKey(new FullQualifiedName(lastFullQualifiedName)) ? 
        csdlEntityTypesMap.get(new FullQualifiedName(lastFullQualifiedName)) : 
          csdlEntityTypesMap.get(fetchCorrectNamespaceFromAlias(new FullQualifiedName(lastFullQualifiedName))));
  if (sourceEntityTypeHavingNavProp == null) {
    CsdlComplexType sourceComplexTypeHavingNavProp = 
        csdlComplexTypesMap.containsKey(new FullQualifiedName(lastFullQualifiedName)) ?
        csdlComplexTypesMap.get(new FullQualifiedName(lastFullQualifiedName)) : 
          csdlComplexTypesMap.get(fetchCorrectNamespaceFromAlias(new FullQualifiedName(lastFullQualifiedName)));
    if (sourceComplexTypeHavingNavProp == null) {
      throw new RuntimeException("The fully Qualified type " + lastFullQualifiedName + 
          " mentioned in navigation binding path not found ");
    }
    navProperty = remainingPath.length() > 0 ? fetchNavigationProperty(remainingPath, strNavProperty, 
        sourceComplexTypeHavingNavProp) : sourceComplexTypeHavingNavProp.getNavigationProperty(strNavProperty);
  } else {
    navProperty = remainingPath.length() > 0 ? fetchNavigationProperty(remainingPath, strNavProperty, 
        sourceEntityTypeHavingNavProp) : sourceEntityTypeHavingNavProp.getNavigationProperty(strNavProperty);
  }
  return navProperty;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:48,代码来源:CsdlTypeValidator.java


示例20: getEntityType

import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入依赖的package包/类
@Override
public CsdlEntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException {
  if (ET_CAR.equals(entityTypeName)) {
    return new CsdlEntityType()
        .setName(ET_CAR.getName())
        .setKey(Arrays.asList(
            new CsdlPropertyRef().setName("Id")))
        .setProperties(
            Arrays.asList(
                new CsdlProperty().setName("Id").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()),
                new CsdlProperty().setName("Model").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()),
                new CsdlProperty().setName("ModelYear").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName())
                    .setMaxLength(4),
                new CsdlProperty().setName("Price").setType(EdmPrimitiveTypeKind.Decimal.getFullQualifiedName())
                    .setScale(2),
                new CsdlProperty().setName("Currency").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName())
                    .setMaxLength(3)
                )
        ).setNavigationProperties(Arrays.asList(
            new CsdlNavigationProperty().setName("Manufacturer").setType(ET_MANUFACTURER)
            )
        );

  } else if (ET_MANUFACTURER.equals(entityTypeName)) {
    return new CsdlEntityType()
        .setName(ET_MANUFACTURER.getName())
        .setKey(Arrays.asList(
            new CsdlPropertyRef().setName("Id")))
        .setProperties(Arrays.asList(
            new CsdlProperty().setName("Id").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()),
            new CsdlProperty().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()),
            new CsdlProperty().setName("Address").setType(CT_ADDRESS))
        ).setNavigationProperties(Arrays.asList(
            new CsdlNavigationProperty().setName("Cars").setType(ET_CAR).setCollection(true)
            )
        );
  }

  return null;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:41,代码来源:CarsEdmProvider.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MultipleDocumentHandling类代码示例发布时间:2022-05-22
下一篇:
Java ConvertBufferedImage类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap