private <T> void setStructuralTypeValuesFromMap(final T data, final EdmStructuralType type, final Map<String, Object> valueMap, final boolean merge) throws ODataException { ODataContext context = getContext(); final int timingHandle = context.startRuntimeMeasurement(getClass().getSimpleName(), "setStructuralTypeValuesFromMap"); for (final String propertyName : type.getPropertyNames()) { final EdmProperty property = (EdmProperty) type.getProperty(propertyName); if (type instanceof EdmEntityType && ((EdmEntityType) type).getKeyProperties().contains(property)) { Object v = valueAccess.getPropertyValue(data, property); if (v != null) { continue; } } if (!merge || valueMap != null && valueMap.containsKey(propertyName)) { final Object value = valueMap == null ? null : valueMap.get(propertyName); if (property.isSimple()) { valueAccess.setPropertyValue(data, property, value); } else { @SuppressWarnings("unchecked") final Map<String, Object> values = (Map<String, Object>) value; setStructuralTypeValuesFromMap(valueAccess.getPropertyValue(data, property), (EdmStructuralType) property.getType(), values, merge); } } } context.stopRuntimeMeasurement(timingHandle); }
final Object value = valueMap == null ? null : valueMap.get(propertyName); if (property.isSimple()) { valueAccess.setPropertyValue(data, property, value); } else { @SuppressWarnings("unchecked") Class<?> complexClass = valueAccess.getPropertyType(data, property); complexData = createInstance(complexClass); valueAccess.setPropertyValue(data, property, complexData);
final Object value = valueMap == null ? null : valueMap.get(propertyName); if (property.isSimple()) { valueAccess.setPropertyValue(data, property, value); } else { @SuppressWarnings("unchecked") Class<?> complexClass = valueAccess.getPropertyType(data, property); complexData = createInstance(complexClass); valueAccess.setPropertyValue(data, property, complexData);
@Override public ODataResponse deleteEntitySimplePropertyValue(final DeleteUriInfo 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); data = getPropertyValue(data, propertyPath.subList(0, propertyPath.size() - 1)); valueAccess.setPropertyValue(data, property, null); valueAccess.setMappingValue(data, property.getMapping(), null); return ODataResponse.newBuilder().build(); }
@Override public ODataResponse deleteEntitySimplePropertyValue(final DeleteUriInfo 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); data = getPropertyValue(data, propertyPath.subList(0, propertyPath.size() - 1)); valueAccess.setPropertyValue(data, property, null); valueAccess.setMappingValue(data, property.getMapping(), null); return ODataResponse.newBuilder().build(); }
@Override public ODataResponse deleteEntitySimplePropertyValue(final DeleteUriInfo 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); data = getPropertyValue(data, propertyPath.subList(0, propertyPath.size() - 1)); valueAccess.setPropertyValue(data, property, null); valueAccess.setMappingValue(data, property.getMapping(), null); return ODataResponse.newBuilder().build(); }
@Override public ODataResponse updateEntitySimplePropertyValue(final PutMergePatchUriInfo uriInfo, final InputStream content, final String requestContentType, final String contentType) throws ODataException { Object data = retrieveData( uriInfo.getStartEntitySet(), uriInfo.getKeyPredicates(), uriInfo.getFunctionImport(), mapFunctionParameters(uriInfo.getFunctionImportParameters()), uriInfo.getNavigationSegments()); if (!appliesFilter(data, uriInfo.getFilter())) { throw new ODataNotFoundException(ODataNotFoundException.ENTITY); } final List<EdmProperty> propertyPath = uriInfo.getPropertyPath(); final EdmProperty property = propertyPath.get(propertyPath.size() - 1); data = getPropertyValue(data, propertyPath.subList(0, propertyPath.size() - 1)); ODataContext context = getContext(); int timingHandle = context.startRuntimeMeasurement("EntityConsumer", "readPropertyValue"); Object value; try { value = EntityProvider.readPropertyValue(property, content); } catch (final EntityProviderException e) { throw new ODataBadRequestException(ODataBadRequestException.BODY, e); } context.stopRuntimeMeasurement(timingHandle); valueAccess.setPropertyValue(data, property, value); valueAccess.setMappingValue(data, property.getMapping(), requestContentType); return ODataResponse.newBuilder().eTag(constructETag(uriInfo.getTargetEntitySet(), data)).build(); }
@Override public ODataResponse updateEntitySimplePropertyValue(final PutMergePatchUriInfo uriInfo, final InputStream content, final String requestContentType, final String contentType) throws ODataException { Object data = retrieveData( uriInfo.getStartEntitySet(), uriInfo.getKeyPredicates(), uriInfo.getFunctionImport(), mapFunctionParameters(uriInfo.getFunctionImportParameters()), uriInfo.getNavigationSegments()); if (!appliesFilter(data, uriInfo.getFilter())) { throw new ODataNotFoundException(ODataNotFoundException.ENTITY); } final List<EdmProperty> propertyPath = uriInfo.getPropertyPath(); final EdmProperty property = propertyPath.get(propertyPath.size() - 1); data = getPropertyValue(data, propertyPath.subList(0, propertyPath.size() - 1)); ODataContext context = getContext(); int timingHandle = context.startRuntimeMeasurement("EntityConsumer", "readPropertyValue"); Object value; try { value = EntityProvider.readPropertyValue(property, content); } catch (final EntityProviderException e) { throw new ODataBadRequestException(ODataBadRequestException.BODY, e); } context.stopRuntimeMeasurement(timingHandle); valueAccess.setPropertyValue(data, property, value); valueAccess.setMappingValue(data, property.getMapping(), requestContentType); return ODataResponse.newBuilder().eTag(constructETag(uriInfo.getTargetEntitySet(), data)).build(); }
@Override public ODataResponse updateEntitySimplePropertyValue(final PutMergePatchUriInfo uriInfo, final InputStream content, final String requestContentType, final String contentType) throws ODataException { Object data = retrieveData( uriInfo.getStartEntitySet(), uriInfo.getKeyPredicates(), uriInfo.getFunctionImport(), mapFunctionParameters(uriInfo.getFunctionImportParameters()), uriInfo.getNavigationSegments()); if (!appliesFilter(data, uriInfo.getFilter())) { throw new ODataNotFoundException(ODataNotFoundException.ENTITY); } final List<EdmProperty> propertyPath = uriInfo.getPropertyPath(); final EdmProperty property = propertyPath.get(propertyPath.size() - 1); data = getPropertyValue(data, propertyPath.subList(0, propertyPath.size() - 1)); ODataContext context = getContext(); int timingHandle = context.startRuntimeMeasurement("EntityConsumer", "readPropertyValue"); Object value; try { value = EntityProvider.readPropertyValue(property, content); } catch (final EntityProviderException e) { throw new ODataBadRequestException(ODataBadRequestException.BODY, e); } context.stopRuntimeMeasurement(timingHandle); valueAccess.setPropertyValue(data, property, value); valueAccess.setMappingValue(data, property.getMapping(), requestContentType); return ODataResponse.newBuilder().eTag(constructETag(uriInfo.getTargetEntitySet(), data)).build(); }
valueAccess.setPropertyValue(data, property, value); } else { @SuppressWarnings("unchecked")
valueAccess.setPropertyValue(data, property, value); } else { @SuppressWarnings("unchecked")
valueAccess.setPropertyValue(data, property, value); } else { @SuppressWarnings("unchecked")