private <T> Object getPropertyValue(final T data, final List<EdmProperty> propertyPath) throws ODataException { Object dataObject = data; for (final EdmProperty property : propertyPath) { if (dataObject != null) { dataObject = valueAccess.getPropertyValue(dataObject, property); } } return dataObject; }
private <T> Object getPropertyValue(final T data, final List<EdmProperty> propertyPath) throws ODataException { Object dataObject = data; for (final EdmProperty property : propertyPath) { if (dataObject != null) { dataObject = valueAccess.getPropertyValue(dataObject, property); } } return dataObject; }
private <T> Object getPropertyValue(final T data, final List<EdmProperty> propertyPath) throws ODataException { Object dataObject = data; for (final EdmProperty property : propertyPath) { if (dataObject != null) { dataObject = valueAccess.getPropertyValue(dataObject, property); } } return dataObject; }
private <T> T readEntryData(final List<T> data, final EdmEntityType entityType, final Map<String, Object> key) throws ODataException { for (final T entryData : data) { boolean found = true; for (final EdmProperty keyProperty : entityType.getKeyProperties()) { if (!valueAccess.getPropertyValue(entryData, keyProperty).equals(key.get(keyProperty.getName()))) { found = false; break; } } if (found) { return entryData; } } return null; } }
private <T> T readEntryData(final List<T> data, final EdmEntityType entityType, final Map<String, Object> key) throws ODataException { for (final T entryData : data) { boolean found = true; for (final EdmProperty keyProperty : entityType.getKeyProperties()) { if (!valueAccess.getPropertyValue(entryData, keyProperty).equals(key.get(keyProperty.getName()))) { found = false; break; } } if (found) { return entryData; } } return null; } }
private <T> T readEntryData(final List<T> data, final EdmEntityType entityType, final Map<String, Object> key) throws ODataException { for (final T entryData : data) { boolean found = true; for (final EdmProperty keyProperty : entityType.getKeyProperties()) { if (!valueAccess.getPropertyValue(entryData, keyProperty).equals(key.get(keyProperty.getName()))) { found = false; break; } } if (found) { return entryData; } } return null; } }
private <T> String getSkipToken(final EdmEntitySet entitySet, final T data) throws ODataException { String skipToken = ""; for (final EdmProperty property : entitySet.getEntityType().getKeyProperties()) { final EdmSimpleType type = (EdmSimpleType) property.getType(); skipToken = skipToken.concat(type.valueToString(valueAccess.getPropertyValue(data, property), EdmLiteralKind.DEFAULT, property.getFacets())); } return skipToken; }
private <T> String getSkipToken(final EdmEntitySet entitySet, final T data) throws ODataException { String skipToken = ""; for (final EdmProperty property : entitySet.getEntityType().getKeyProperties()) { final EdmSimpleType type = (EdmSimpleType) property.getType(); skipToken = skipToken.concat(type.valueToString(valueAccess.getPropertyValue(data, property), EdmLiteralKind.DEFAULT, property.getFacets())); } return skipToken; }
private <T> String getSkipToken(final EdmEntitySet entitySet, final T data) throws ODataException { String skipToken = ""; for (final EdmProperty property : entitySet.getEntityType().getKeyProperties()) { final EdmSimpleType type = (EdmSimpleType) property.getType(); skipToken = skipToken.concat(type.valueToString(valueAccess.getPropertyValue(data, property), EdmLiteralKind.DEFAULT, property.getFacets())); } return skipToken; }
private <T> Map<String, Object> getStructuralTypeTypeMap(final T data, final EdmStructuralType type) throws ODataException { ODataContext context = getContext(); final int timingHandle = context.startRuntimeMeasurement(getClass().getSimpleName(), "getStructuralTypeTypeMap"); Map<String, Object> typeMap = new HashMap<String, Object>(); for (final String propertyName : type.getPropertyNames()) { final EdmProperty property = (EdmProperty) type.getProperty(propertyName); if (property.isSimple()) { typeMap.put(propertyName, valueAccess.getPropertyType(data, property)); } else { typeMap.put(propertyName, getStructuralTypeTypeMap(valueAccess.getPropertyValue(data, property), (EdmStructuralType) property.getType())); } } context.stopRuntimeMeasurement(timingHandle); return typeMap; }
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); }
private <T> Map<String, Object> getStructuralTypeTypeMap(final T data, final EdmStructuralType type) throws ODataException { ODataContext context = getContext(); final int timingHandle = context.startRuntimeMeasurement(getClass().getSimpleName(), "getStructuralTypeTypeMap"); Map<String, Object> typeMap = new HashMap<String, Object>(); for (final String propertyName : type.getPropertyNames()) { final EdmProperty property = (EdmProperty) type.getProperty(propertyName); if (property.isSimple()) { Object value = valueAccess.getPropertyType(data, property); if (value != null) { typeMap.put(propertyName, value); } } else { Object value = valueAccess.getPropertyValue(data, property); if (value == null) { Class<?> complexClass = valueAccess.getPropertyType(data, property); value = createInstance(complexClass); } typeMap.put(propertyName, getStructuralTypeTypeMap(value, (EdmStructuralType) property.getType())); } } context.stopRuntimeMeasurement(timingHandle); return typeMap; }
private <T> Map<String, Object> getStructuralTypeTypeMap(final T data, final EdmStructuralType type) throws ODataException { ODataContext context = getContext(); final int timingHandle = context.startRuntimeMeasurement(getClass().getSimpleName(), "getStructuralTypeTypeMap"); Map<String, Object> typeMap = new HashMap<String, Object>(); for (final String propertyName : type.getPropertyNames()) { final EdmProperty property = (EdmProperty) type.getProperty(propertyName); if (property.isSimple()) { Object value = valueAccess.getPropertyType(data, property); if (value != null) { typeMap.put(propertyName, value); } } else { Object value = valueAccess.getPropertyValue(data, property); if (value == null) { Class<?> complexClass = valueAccess.getPropertyType(data, property); value = createInstance(complexClass); } typeMap.put(propertyName, getStructuralTypeTypeMap(value, (EdmStructuralType) property.getType())); } } context.stopRuntimeMeasurement(timingHandle); return typeMap; }
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; }
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().getMimeType() == 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; }
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; }
private <T> String constructETag(final EdmEntitySet entitySet, final T data) throws ODataException { final EdmEntityType entityType = entitySet.getEntityType(); String eTag = null; for (final String propertyName : entityType.getPropertyNames()) { final EdmProperty property = (EdmProperty) entityType.getProperty(propertyName); if (property.getFacets() != null && property.getFacets().getConcurrencyMode() == EdmConcurrencyMode.Fixed) { final EdmSimpleType type = (EdmSimpleType) property.getType(); final String component = type.valueToString(valueAccess.getPropertyValue(data, property), EdmLiteralKind.DEFAULT, property.getFacets()); eTag = eTag == null ? component : eTag + Edm.DELIMITER + component; } } return eTag == null ? null : "W/\"" + eTag + "\""; }
private <T> String constructETag(final EdmEntitySet entitySet, final T data) throws ODataException { final EdmEntityType entityType = entitySet.getEntityType(); String eTag = null; for (final String propertyName : entityType.getPropertyNames()) { final EdmProperty property = (EdmProperty) entityType.getProperty(propertyName); if (property.getFacets() != null && property.getFacets().getConcurrencyMode() == EdmConcurrencyMode.Fixed) { final EdmSimpleType type = (EdmSimpleType) property.getType(); final String component = type.valueToString(valueAccess.getPropertyValue(data, property), EdmLiteralKind.DEFAULT, property.getFacets()); eTag = eTag == null ? component : eTag + Edm.DELIMITER + component; } } return eTag == null ? null : "W/\"" + eTag + "\""; }
private <T> String constructETag(final EdmEntitySet entitySet, final T data) throws ODataException { final EdmEntityType entityType = entitySet.getEntityType(); String eTag = null; for (final String propertyName : entityType.getPropertyNames()) { final EdmProperty property = (EdmProperty) entityType.getProperty(propertyName); if (property.getFacets() != null && property.getFacets().getConcurrencyMode() == EdmConcurrencyMode.Fixed) { final EdmSimpleType type = (EdmSimpleType) property.getType(); final String component = type.valueToString(valueAccess.getPropertyValue(data, property), EdmLiteralKind.DEFAULT, property.getFacets()); eTag = eTag == null ? component : eTag + Edm.DELIMITER + component; } } return eTag == null ? null : "W/\"" + eTag + "\""; }
@Override public ODataResponse readEntityLink(final GetEntityLinkUriInfo uriInfo, final String contentType) throws ODataException { final Object data = retrieveData( uriInfo.getStartEntitySet(), uriInfo.getKeyPredicates(), uriInfo.getFunctionImport(), mapFunctionParameters(uriInfo.getFunctionImportParameters()), uriInfo.getNavigationSegments()); if (data == null) { throw new ODataNotFoundException(ODataNotFoundException.ENTITY); } final EdmEntitySet entitySet = uriInfo.getTargetEntitySet(); Map<String, Object> values = new HashMap<String, Object>(); for (final EdmProperty property : entitySet.getEntityType().getKeyProperties()) { values.put(property.getName(), valueAccess.getPropertyValue(data, property)); } ODataContext context = getContext(); final EntityProviderWriteProperties entryProperties = EntityProviderWriteProperties .serviceRoot(context.getPathInfo().getServiceRoot()) .build(); final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "writeLink"); final ODataResponse response = EntityProvider.writeLink(contentType, entitySet, values, entryProperties); context.stopRuntimeMeasurement(timingHandle); return ODataResponse.fromResponse(response).build(); }