Java Code Examples for org.apache.olingo.commons.api.edm.EdmElement#getType()
The following examples show how to use
org.apache.olingo.commons.api.edm.EdmElement#getType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CoreUtils.java From olingo-odata4 with Apache License 2.0 | 6 votes |
private static ClientProperty getODataProperty( final EdmEnabledODataClient client, final EdmElement edmProperty, final String property, final Object obj) { final EdmTypeInfo type; if (edmProperty == null) { // maybe opentype ... type = null; } else { final EdmType edmType = edmProperty.getType(); type = new EdmTypeInfo.Builder().setEdm(client.getCachedEdm()).setTypeExpression( edmProperty.isCollection() ? "Collection(" + edmType.getFullQualifiedName().toString() + ")" : edmType.getFullQualifiedName().toString()).build(); } return getODataProperty(client, property, type, obj); }
Example 2
Source File: EdmEntityTypeImplTest.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@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); }
Example 3
Source File: ExpressionParser.java From olingo-odata4 with Apache License 2.0 | 4 votes |
private void parsePropertyPathExpr(UriInfoImpl uriInfo, final UriResourcePartTyped lastResource) throws UriParserException, UriValidationException { final String oDataIdentifier = tokenizer.getText(); final EdmType lastType = lastResource == null ? referringType : ParserHelper.getTypeInformation(lastResource); if (!(lastType instanceof EdmStructuredType)) { throw new UriParserSemanticException("Property paths must follow a structured type.", UriParserSemanticException.MessageKeys.ONLY_FOR_STRUCTURAL_TYPES, oDataIdentifier); } final EdmStructuredType structuredType = (EdmStructuredType) lastType; final EdmElement property = structuredType.getProperty(oDataIdentifier); if (property == null) { throw new UriParserSemanticException("Unknown property.", UriParserSemanticException.MessageKeys.EXPRESSION_PROPERTY_NOT_IN_TYPE, lastType.getFullQualifiedName().getFullQualifiedNameAsString(), oDataIdentifier); } if (property.getType() instanceof EdmComplexType) { final UriResourceComplexPropertyImpl complexResource = new UriResourceComplexPropertyImpl((EdmProperty) property); uriInfo.addResourcePart(complexResource); if (property.isCollection()) { if (tokenizer.next(TokenKind.SLASH)) { parseCollectionPathExpr(uriInfo, complexResource); } } else { parseComplexPathExpr(uriInfo, complexResource); } } else if (property instanceof EdmNavigationProperty) { // Nav. property; maybe a collection final UriResourceNavigationPropertyImpl navigationResource = new UriResourceNavigationPropertyImpl((EdmNavigationProperty) property); navigationResource.setKeyPredicates( ParserHelper.parseNavigationKeyPredicate(tokenizer, (EdmNavigationProperty) property, edm, referringType, aliases)); uriInfo.addResourcePart(navigationResource); if (navigationResource.isCollection()) { parseCollectionNavigationExpr(uriInfo, navigationResource); } else { parseSingleNavigationExpr(uriInfo, navigationResource); } } else { // Primitive type or Enum type final UriResourcePrimitivePropertyImpl primitiveResource = new UriResourcePrimitivePropertyImpl((EdmProperty) property); uriInfo.addResourcePart(primitiveResource); if (property.isCollection()) { if (tokenizer.next(TokenKind.SLASH)) { parseCollectionPathExpr(uriInfo, primitiveResource); } } else { parseSinglePathExpr(uriInfo, primitiveResource); } } }