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


Java EdmKeyPropertyRef.getProperty方法代码示例

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


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

示例1: keyBehaviour

import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef; //导入方法依赖的package包/类
@Test
public void keyBehaviour() {
  List<String> keyPredicateNames = baseType.getKeyPredicateNames();
  assertEquals(1, keyPredicateNames.size());
  assertEquals("Id", keyPredicateNames.get(0));

  EdmKeyPropertyRef keyPropertyRef = baseType.getKeyPropertyRef("Id");
  assertNotNull(keyPropertyRef);
  assertEquals("Id", keyPropertyRef.getName());
  assertNull(keyPropertyRef.getAlias());

  EdmProperty keyProperty = keyPropertyRef.getProperty();
  assertNotNull(keyProperty);
  assertEquals(baseType.getProperty("Id"), keyProperty);

  List<EdmKeyPropertyRef> keyPropertyRefs = baseType.getKeyPropertyRefs();
  assertNotNull(keyPropertyRefs);
  assertEquals(1, keyPropertyRefs.size());
  assertEquals("Id", keyPropertyRefs.get(0).getName());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:EdmEntityTypeImplTest.java

示例2: aliasForPropertyInComplexPropertyOneLevel

import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef; //导入方法依赖的package包/类
@Test
public void aliasForPropertyInComplexPropertyOneLevel() {
  CsdlPropertyRef providerRef = new CsdlPropertyRef().setName("comp/Id").setAlias("alias");
  EdmEntityType etMock = mock(EdmEntityType.class);
  EdmProperty keyPropertyMock = mock(EdmProperty.class);
  EdmProperty compMock = mock(EdmProperty.class);
  EdmComplexType compTypeMock = mock(EdmComplexType.class);
  when(compTypeMock.getStructuralProperty("Id")).thenReturn(keyPropertyMock);
  when(compMock.getType()).thenReturn(compTypeMock);
  when(etMock.getStructuralProperty("comp")).thenReturn(compMock);
  EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(etMock, providerRef);
  assertEquals("alias", ref.getAlias());

  EdmProperty property = ref.getProperty();
  assertNotNull(property);
  assertTrue(property == keyPropertyMock);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:EdmKeyPropertyRefImplTest.java

示例3: aliasForPropertyInComplexPropertyTwoLevels

import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef; //导入方法依赖的package包/类
@Test
public void aliasForPropertyInComplexPropertyTwoLevels() {
  CsdlPropertyRef providerRef = new CsdlPropertyRef().setName("comp/comp2/Id").setAlias("alias");
  EdmEntityType etMock = mock(EdmEntityType.class);
  EdmProperty keyPropertyMock = mock(EdmProperty.class);
  EdmProperty compMock = mock(EdmProperty.class);
  EdmComplexType compTypeMock = mock(EdmComplexType.class);
  EdmProperty comp2Mock = mock(EdmProperty.class);
  EdmComplexType comp2TypeMock = mock(EdmComplexType.class);
  when(comp2TypeMock.getStructuralProperty("Id")).thenReturn(keyPropertyMock);
  when(comp2Mock.getType()).thenReturn(comp2TypeMock);
  when(compTypeMock.getStructuralProperty("comp2")).thenReturn(comp2Mock);
  when(compMock.getType()).thenReturn(compTypeMock);
  when(etMock.getStructuralProperty("comp")).thenReturn(compMock);
  EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(etMock, providerRef);

  EdmProperty property = ref.getProperty();
  assertNotNull(property);
  assertTrue(property == keyPropertyMock);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:EdmKeyPropertyRefImplTest.java

示例4: keyValuePair

import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef; //导入方法依赖的package包/类
private static UriParameter keyValuePair(UriTokenizer tokenizer,
    final String keyPredicateName, final EdmEntityType edmEntityType,
    final Edm edm, final EdmType referringType, final Map<String, AliasQueryOption> aliases)
    throws UriParserException, UriValidationException {
  final EdmKeyPropertyRef keyPropertyRef = edmEntityType.getKeyPropertyRef(keyPredicateName);
  final EdmProperty edmProperty = keyPropertyRef == null ? null : keyPropertyRef.getProperty();
  if (edmProperty == null) {
    throw new UriValidationException(keyPredicateName + " is not a valid key property name.",
        UriValidationException.MessageKeys.INVALID_KEY_PROPERTY, keyPredicateName);
  }
  ParserHelper.requireNext(tokenizer, TokenKind.EQ);
  if (tokenizer.next(TokenKind.COMMA) || tokenizer.next(TokenKind.CLOSE) || tokenizer.next(TokenKind.EOF)) {
    throw new UriParserSyntaxException("Key value expected.", UriParserSyntaxException.MessageKeys.SYNTAX);
  }
  if (nextPrimitiveTypeValue(tokenizer, (EdmPrimitiveType) edmProperty.getType(), edmProperty.isNullable())) {
    return createUriParameter(edmProperty, keyPredicateName, tokenizer.getText(), edm, referringType, aliases);
  } else {
    throw new UriParserSemanticException(keyPredicateName + " has not a valid  key value.",
        UriParserSemanticException.MessageKeys.INVALID_KEY_VALUE, keyPredicateName);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:22,代码来源:ParserHelper.java

示例5: read

import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef; //导入方法依赖的package包/类
public Entity read(final EdmEntityType edmEntityType, final EntityCollection entitySet,
    final List<UriParameter> keys) throws DataProviderException {
  try {
    for (final Entity entity : entitySet.getEntities()) {
      boolean found = true;
      for (final UriParameter key : keys) {
        EdmKeyPropertyRef refType = edmEntityType.getKeyPropertyRef(key.getName());
        Object value =  findPropertyRefValue(entity, refType);
        
        final EdmProperty property = refType.getProperty();
        final EdmPrimitiveType type = (EdmPrimitiveType) property.getType();
        
        if (key.getExpression() != null && !(key.getExpression() instanceof Literal)) {
          throw new DataProviderException("Expression in key value is not supported yet!",
              HttpStatusCode.NOT_IMPLEMENTED);
        }
        final String text = key.getAlias() == null ? key.getText() : ((Literal) key.getExpression()).getText();
        final Object keyValue = type.valueOfString(type.fromUriLiteral(text),
            property.isNullable(), property.getMaxLength(), property.getPrecision(), property.getScale(),
            property.isUnicode(),
            Calendar.class.isAssignableFrom(value.getClass()) ? Calendar.class : value.getClass());
        if (!value.equals(keyValue)) {
          found = false;
          break;
        }
      }
      if (found) {
        return entity;
      }
    }
    return null;
  } catch (final EdmPrimitiveTypeException e) {
    throw new DataProviderException("Wrong key!", HttpStatusCode.BAD_REQUEST, e);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:36,代码来源:DataProvider.java

示例6: readDataFromEntity

import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef; //导入方法依赖的package包/类
public Entity readDataFromEntity(final EdmEntityType edmEntityType,
    final List<UriParameter> keys) throws DataProviderException {
  EntityCollection coll = data.get(edmEntityType.getName());
  List<Entity> entities = coll.getEntities();
  try {
    for (final Entity entity : entities) {
      boolean found = true;
      for (final UriParameter key : keys) {
        EdmKeyPropertyRef refType = edmEntityType.getKeyPropertyRef(key.getName());
        Object value =  findPropertyRefValue(entity, refType);
        
        final EdmProperty property = refType.getProperty();
        final EdmPrimitiveType type = (EdmPrimitiveType) property.getType();
        
        if (key.getExpression() != null && !(key.getExpression() instanceof Literal)) {
          throw new DataProviderException("Expression in key value is not supported yet!",
              HttpStatusCode.NOT_IMPLEMENTED);
        }
        final String text = key.getAlias() == null ? key.getText() : ((Literal) key.getExpression()).getText();
        final Object keyValue = type.valueOfString(type.fromUriLiteral(text),
            property.isNullable(), property.getMaxLength(), property.getPrecision(), property.getScale(),
            property.isUnicode(),
            Calendar.class.isAssignableFrom(value.getClass()) ? Calendar.class : value.getClass());
        if (!value.equals(keyValue)) {
          found = false;
          break;
        }
      }
      if (found) {
        return entity;
      }
    }
    return null;
  } catch (final EdmPrimitiveTypeException e) {
    throw new DataProviderException("Wrong key!", HttpStatusCode.BAD_REQUEST, e);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:38,代码来源:DataProvider.java

示例7: setBindingPropertyKeyNameAndValue

import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef; //导入方法依赖的package包/类
/**
 * @param keyList
 * @param edmEntitySet
 * @param values
 * @param propertyNames
 * @throws DataProviderException
 */
private static void setBindingPropertyKeyNameAndValue(List<UriParameter> keyList, EdmEntitySet edmEntitySet,
    List<Object> values, List<String> propertyNames) throws DataProviderException {
  for (final UriParameter key : keyList) {
    EdmKeyPropertyRef refType = edmEntitySet.getEntityType().getKeyPropertyRef(key.getName());
    final EdmProperty property = refType.getProperty();
    final EdmPrimitiveType type = (EdmPrimitiveType) property.getType();
    try {
      values.add(type.fromUriLiteral(key.getText()));
    } catch (EdmPrimitiveTypeException e) {
      throw new DataProviderException("Wrong key!", HttpStatusCode.BAD_REQUEST, e);
    }
    propertyNames.add(key.getName());
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:22,代码来源:ActionData.java

示例8: complexKeyWithAlias

import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef; //导入方法依赖的package包/类
@Test
public void complexKeyWithAlias() {
  List<String> keyPredicateNames = typeWithComplexKey.getKeyPredicateNames();
  assertEquals(2, keyPredicateNames.size());
  assertEquals("Id", keyPredicateNames.get(0));
  assertEquals("alias", keyPredicateNames.get(1));

  EdmKeyPropertyRef keyPropertyRef = typeWithComplexKey.getKeyPropertyRef("Id");
  assertNotNull(keyPropertyRef);
  assertEquals("Id", keyPropertyRef.getName());
  assertNull(keyPropertyRef.getAlias());
  EdmProperty keyProperty = keyPropertyRef.getProperty();
  assertNotNull(keyProperty);
  assertEquals(typeWithComplexKey.getProperty("Id"), keyProperty);

  keyPropertyRef = typeWithComplexKey.getKeyPropertyRef("alias");
  assertNotNull(keyPropertyRef);
  assertEquals("Comp/ComplexPropName", keyPropertyRef.getName());
  assertEquals("alias", keyPropertyRef.getAlias());

  keyProperty = keyPropertyRef.getProperty();
  assertNotNull(keyProperty);
  EdmElement complexProperty = typeWithComplexKey.getProperty("Comp");
  EdmComplexType complexType = (EdmComplexType) complexProperty.getType();
  assertNotNull(complexType);
  assertEquals(complexType.getProperty("ComplexPropName"), keyProperty);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:28,代码来源:EdmEntityTypeImplTest.java

示例9: noAlias

import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef; //导入方法依赖的package包/类
@Test
public void noAlias() {
  CsdlPropertyRef providerRef = new CsdlPropertyRef().setName("Id");
  EdmEntityType etMock = mock(EdmEntityType.class);
  EdmProperty keyPropertyMock = mock(EdmProperty.class);
  when(etMock.getStructuralProperty("Id")).thenReturn(keyPropertyMock);
  EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(etMock, providerRef);
  assertEquals("Id", ref.getName());
  assertNull(ref.getAlias());

  EdmProperty property = ref.getProperty();
  assertNotNull(property);
  assertTrue(property == keyPropertyMock);
  assertTrue(property == ref.getProperty());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:16,代码来源:EdmKeyPropertyRefImplTest.java

示例10: simpleKey

import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef; //导入方法依赖的package包/类
private static UriParameter simpleKey(UriTokenizer tokenizer, final EdmKeyPropertyRef edmKeyPropertyRef,
    final Edm edm, final EdmType referringType, final Map<String, AliasQueryOption> aliases)
    throws UriParserException, UriValidationException {
  final EdmProperty edmProperty = edmKeyPropertyRef == null ? null : edmKeyPropertyRef.getProperty();
  if (nextPrimitiveTypeValue(tokenizer,
      edmProperty == null ? null : (EdmPrimitiveType) edmProperty.getType(),
      edmProperty == null ? false : edmProperty.isNullable())) {
    final String literalValue = tokenizer.getText();
    ParserHelper.requireNext(tokenizer, TokenKind.CLOSE);
    return createUriParameter(edmProperty, edmKeyPropertyRef.getName(), literalValue, edm, referringType, aliases);
  } else {
    return null;
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:15,代码来源:ParserHelper.java

示例11: buildKeyPredicate

import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef; //导入方法依赖的package包/类
@Override
public String buildKeyPredicate(final EdmEntityType edmEntityType, final Entity entity) throws SerializerException {
  StringBuilder result = new StringBuilder();
  final List<String> keyNames = edmEntityType.getKeyPredicateNames();
  boolean first = true;
  for (final String keyName : keyNames) {
    EdmKeyPropertyRef refType = edmEntityType.getKeyPropertyRef(keyName);
    if (first) {
      first = false;
    } else {
      result.append(',');
    }
    if (keyNames.size() > 1) {
      result.append(Encoder.encode(keyName)).append('=');
    }
    final EdmProperty edmProperty =  refType.getProperty();
    if (edmProperty == null) {
      throw new SerializerException("Property not found (possibly an alias): " + keyName,
          SerializerException.MessageKeys.MISSING_PROPERTY, keyName);
    }
    final EdmPrimitiveType type = (EdmPrimitiveType) edmProperty.getType();
    final Object propertyValue = findPropertyRefValue(entity, refType);
    try {
      final String value = type.toUriLiteral(
          type.valueToString(propertyValue,
              edmProperty.isNullable(), edmProperty.getMaxLength(),
              edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode()));
      result.append(Encoder.encode(value));
    } catch (final EdmPrimitiveTypeException e) {
      throw new SerializerException("Wrong key value!", e,
          SerializerException.MessageKeys.WRONG_PROPERTY_VALUE, edmProperty.getName(), 
          propertyValue != null ? propertyValue.toString(): null);
    }
  }
  return result.toString();
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:37,代码来源:UriHelperImpl.java

示例12: oneKeyNoAliasButInvalidProperty

import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef; //导入方法依赖的package包/类
@Test(expected = EdmException.class)
public void oneKeyNoAliasButInvalidProperty() {
  CsdlPropertyRef providerRef = new CsdlPropertyRef().setName("Id");
  EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(mock(EdmEntityType.class), providerRef);
  ref.getProperty();
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:7,代码来源:EdmKeyPropertyRefImplTest.java

示例13: aliasButNoPath

import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef; //导入方法依赖的package包/类
@Test(expected = EdmException.class)
public void aliasButNoPath() {
  CsdlPropertyRef providerRef = new CsdlPropertyRef().setName("Id").setAlias("alias");
  EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(mock(EdmEntityType.class), providerRef);
  ref.getProperty();
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:7,代码来源:EdmKeyPropertyRefImplTest.java

示例14: aliasButEmptyPath

import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef; //导入方法依赖的package包/类
@Test(expected = EdmException.class)
public void aliasButEmptyPath() {
  CsdlPropertyRef providerRef = new CsdlPropertyRef().setName("").setAlias("alias");
  EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(mock(EdmEntityType.class), providerRef);
  ref.getProperty();
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:7,代码来源:EdmKeyPropertyRefImplTest.java


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