Java Code Examples for org.apache.olingo.odata2.api.edm.EdmProperty#getMapping()
The following examples show how to use
org.apache.olingo.odata2.api.edm.EdmProperty#getMapping() .
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: ListsProcessor.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public ODataResponse readEntitySimplePropertyValue(final GetSimplePropertyUriInfo uriInfo, final String contentType) throws ODataException { Object data = retrieveData( uriInfo.getStartEntitySet(), uriInfo.getKeyPredicates(), uriInfo.getFunctionImport(), mapFunctionParameters(uriInfo.getFunctionImportParameters()), uriInfo.getNavigationSegments()); if (data == null) { throw new ODataNotFoundException(ODataNotFoundException.ENTITY); } final List<EdmProperty> propertyPath = uriInfo.getPropertyPath(); final EdmProperty property = propertyPath.get(propertyPath.size() - 1); final Object value = property.getMapping() == null || property.getMapping().getMediaResourceMimeTypeKey() == null ? getPropertyValue(data, propertyPath) : getSimpleTypeValueMap(data, propertyPath); return ODataResponse.fromResponse(EntityProvider.writePropertyValue(property, value)).eTag( constructETag(uriInfo.getTargetEntitySet(), data)).build(); }
Example 2
Source File: ODataExpressionParser.java From olingo-odata2 with Apache License 2.0 | 6 votes |
public static String parseKeyPropertiesToJPAOrderByExpression( final List<EdmProperty> edmPropertylist, final String tableAlias) throws ODataJPARuntimeException { String propertyName = null; String orderExpression = ""; if (edmPropertylist == null) { return orderExpression; } for (EdmProperty edmProperty : edmPropertylist) { try { EdmMapping mapping = edmProperty.getMapping(); if (mapping != null && mapping.getInternalName() != null) { propertyName = mapping.getInternalName();// For embedded/complex keys } else { propertyName = edmProperty.getName(); } } catch (EdmException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } orderExpression += tableAlias + JPQLStatement.DELIMITER.PERIOD + propertyName + " , "; } return normalizeOrderByExpression(orderExpression); }
Example 3
Source File: ODataExpressionParser.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private static String getPropertyName(final CommonExpression whereExpression) throws EdmException, ODataJPARuntimeException { EdmTyped edmProperty = ((PropertyExpression) whereExpression).getEdmProperty(); EdmMapping mapping; if (edmProperty instanceof EdmNavigationProperty) { EdmNavigationProperty edmNavigationProperty = (EdmNavigationProperty) edmProperty; mapping = edmNavigationProperty.getMapping(); } else if(edmProperty instanceof EdmProperty) { EdmProperty property = (EdmProperty) edmProperty; mapping = property.getMapping(); } else { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL, null); } return mapping != null ? mapping.getInternalName() : edmProperty.getName(); }
Example 4
Source File: ListsProcessor.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public ODataResponse readEntitySimplePropertyValue(final GetSimplePropertyUriInfo uriInfo, final String contentType) throws ODataException { Object data = retrieveData( uriInfo.getStartEntitySet(), uriInfo.getKeyPredicates(), uriInfo.getFunctionImport(), mapFunctionParameters(uriInfo.getFunctionImportParameters()), uriInfo.getNavigationSegments()); // if (!appliesFilter(data, uriInfo.getFilter())) if (data == null) { throw new ODataNotFoundException(ODataNotFoundException.ENTITY); } final List<EdmProperty> propertyPath = uriInfo.getPropertyPath(); final EdmProperty property = propertyPath.get(propertyPath.size() - 1); final Object value = property.getMapping() == null || property.getMapping().getMediaResourceMimeTypeKey() == null ? getPropertyValue(data, propertyPath) : getSimpleTypeValueMap(data, propertyPath); return ODataResponse.fromResponse(EntityProvider.writePropertyValue(property, value)).eTag( constructETag(uriInfo.getTargetEntitySet(), data)).build(); }
Example 5
Source File: ListsProcessor.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override public ODataResponse readEntityComplexProperty(final GetComplexPropertyUriInfo uriInfo, final String contentType) throws ODataException { Object data = retrieveData( uriInfo.getStartEntitySet(), uriInfo.getKeyPredicates(), uriInfo.getFunctionImport(), mapFunctionParameters(uriInfo.getFunctionImportParameters()), uriInfo.getNavigationSegments()); if (data == null) { throw new ODataNotFoundException(ODataNotFoundException.ENTITY); } final List<EdmProperty> propertyPath = uriInfo.getPropertyPath(); final EdmProperty property = propertyPath.get(propertyPath.size() - 1); final Object value = property.isSimple() ? property.getMapping() == null || property.getMapping().getMediaResourceMimeTypeKey() == null ? getPropertyValue(data, propertyPath) : getSimpleTypeValueMap(data, propertyPath) : getStructuralTypeValueMap(getPropertyValue(data, propertyPath), (EdmStructuralType) property.getType()); ODataContext context = getContext(); final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "writeProperty"); final ODataResponse response = EntityProvider.writeProperty(contentType, property, value); context.stopRuntimeMeasurement(timingHandle); return ODataResponse.fromResponse(response).eTag(constructETag(uriInfo.getTargetEntitySet(), data)).build(); }
Example 6
Source File: ListsProcessor.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private <T> Map<String, Object> getStructuralTypeValueMap(final T data, final EdmStructuralType type) throws ODataException { ODataContext context = getContext(); final int timingHandle = context.startRuntimeMeasurement(getClass().getSimpleName(), "getStructuralTypeValueMap"); Map<String, Object> valueMap = new HashMap<String, Object>(); EdmMapping mapping = type.getMapping(); if (mapping != null) { handleMimeType(data, mapping, valueMap); } for (final String propertyName : type.getPropertyNames()) { final EdmProperty property = (EdmProperty) type.getProperty(propertyName); final Object value = valueAccess.getPropertyValue(data, property); if (property.isSimple()) { if (property.getMapping() == null || property.getMapping().getMediaResourceMimeTypeKey() == null) { valueMap.put(propertyName, value); } else { // TODO: enable MIME type mapping outside the current subtree valueMap.put(propertyName, getSimpleTypeValueMap(data, Arrays.asList(property))); } } else { valueMap.put(propertyName, getStructuralTypeValueMap(value, (EdmStructuralType) property.getType())); } } context.stopRuntimeMeasurement(timingHandle); return valueMap; }
Example 7
Source File: EntityPropertyInfo.java From olingo-odata2 with Apache License 2.0 | 5 votes |
static EntityPropertyInfo create(final EdmProperty property) throws EdmException { return new EntityPropertyInfo( property.getName(), property.getType(), property.getFacets(), property.getCustomizableFeedMappings(), property.getMimeType(), property.getMapping()); }
Example 8
Source File: ListsProcessor.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override public ODataResponse readEntityComplexProperty(final GetComplexPropertyUriInfo uriInfo, final String contentType) throws ODataException { Object data = retrieveData( uriInfo.getStartEntitySet(), uriInfo.getKeyPredicates(), uriInfo.getFunctionImport(), mapFunctionParameters(uriInfo.getFunctionImportParameters()), uriInfo.getNavigationSegments()); // if (!appliesFilter(data, uriInfo.getFilter())) if (data == null) { throw new ODataNotFoundException(ODataNotFoundException.ENTITY); } final List<EdmProperty> propertyPath = uriInfo.getPropertyPath(); final EdmProperty property = propertyPath.get(propertyPath.size() - 1); final Object value = property.isSimple() ? property.getMapping() == null || property.getMapping().getMediaResourceMimeTypeKey() == null ? getPropertyValue(data, propertyPath) : getSimpleTypeValueMap(data, propertyPath) : getStructuralTypeValueMap(getPropertyValue(data, propertyPath), (EdmStructuralType) property.getType()); ODataContext context = getContext(); final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "writeProperty"); final ODataResponse response = EntityProvider.writeProperty(contentType, property, value); context.stopRuntimeMeasurement(timingHandle); return ODataResponse.fromResponse(response).eTag(constructETag(uriInfo.getTargetEntitySet(), data)).build(); }
Example 9
Source File: ListsProcessor.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private <T> Map<String, Object> getStructuralTypeValueMap(final T data, final EdmStructuralType type) throws ODataException { ODataContext context = getContext(); final int timingHandle = context.startRuntimeMeasurement(getClass().getSimpleName(), "getStructuralTypeValueMap"); Map<String, Object> valueMap = new HashMap<String, Object>(); EdmMapping mapping = type.getMapping(); if (mapping != null) { handleMimeType(data, mapping, valueMap); } for (final String propertyName : type.getPropertyNames()) { final EdmProperty property = (EdmProperty) type.getProperty(propertyName); final Object value = valueAccess.getPropertyValue(data, property); if (property.isSimple()) { if (property.getMapping() == null || property.getMapping().getMediaResourceMimeTypeKey() == null) { valueMap.put(propertyName, value); } else { // TODO: enable MIME type mapping outside the current subtree valueMap.put(propertyName, getSimpleTypeValueMap(data, Arrays.asList(property))); } } else { valueMap.put(propertyName, getStructuralTypeValueMap(value, (EdmStructuralType) property.getType())); } } context.stopRuntimeMeasurement(timingHandle); return valueMap; }
Example 10
Source File: BeanPropertyAccess.java From olingo-odata2 with Apache License 2.0 | 4 votes |
private String getGetterMethodName(final EdmProperty property) throws EdmException { final String prefix = isBooleanProperty(property) ? "is" : "get"; final String defaultMethodName = prefix + property.getName(); return property.getMapping() == null || property.getMapping().getInternalName() == null ? defaultMethodName : property.getMapping().getInternalName(); }
Example 11
Source File: BeanPropertyAccess.java From olingo-odata2 with Apache License 2.0 | 4 votes |
private String getGetterMethodName(final EdmProperty property) throws EdmException { final String prefix = isBooleanProperty(property) ? "is" : "get"; final String defaultMethodName = prefix + property.getName(); return property.getMapping() == null || property.getMapping().getInternalName() == null ? defaultMethodName : property.getMapping().getInternalName(); }