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


Java CsdlNavigationProperty类代码示例

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


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


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