Java Code Examples for org.apache.olingo.server.api.uri.UriParameter#getName()
The following examples show how to use
org.apache.olingo.server.api.uri.UriParameter#getName() .
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: ParserHelper.java From olingo-odata4 with Apache License 2.0 | 5 votes |
protected static void validateFunctionParameters(final EdmFunction function, final List<UriParameter> parameters, final Edm edm, final EdmType referringType, final Map<String, AliasQueryOption> aliases) throws UriParserException, UriValidationException { for (final UriParameter parameter : parameters) { final String parameterName = parameter.getName(); final EdmParameter edmParameter = function.getParameter(parameterName); final boolean isNullable = edmParameter.isNullable(); if (parameter.getText() == null && parameter.getExpression() == null && !isNullable) { if (parameter.getAlias() == null) { // No alias, value is explicitly null. throw new UriValidationException("Missing non-nullable parameter " + parameterName, UriValidationException.MessageKeys.MISSING_PARAMETER, parameterName); } else { final String valueForAlias = aliases.containsKey(parameter.getAlias()) ? parseAliasValue(parameter.getAlias(), edmParameter.getType(), edmParameter.isNullable(), edmParameter.isCollection(), edm, referringType, aliases).getText() : null; // Alias value is missing or explicitly null. if (valueForAlias == null) { throw new UriValidationException("Missing alias for " + parameterName, UriValidationException.MessageKeys.MISSING_ALIAS, parameter.getAlias()); } } } } }
Example 2
Source File: ParserHelper.java From olingo-odata4 with Apache License 2.0 | 5 votes |
protected static void validateFunctionParameterFacets(final EdmFunction function, final List<UriParameter> parameters, Edm edm, Map<String, AliasQueryOption> aliases) throws UriParserException, UriValidationException { for (UriParameter parameter : parameters) { EdmParameter edmParameter = function.getParameter(parameter.getName()); final EdmType type = edmParameter.getType(); final EdmTypeKind kind = type.getKind(); if ((kind == EdmTypeKind.PRIMITIVE || kind == EdmTypeKind.DEFINITION || kind == EdmTypeKind.ENUM) && !edmParameter.isCollection()) { final EdmPrimitiveType primitiveType = (EdmPrimitiveType) type; String text = null; try { text = parameter.getAlias() == null ? parameter.getText() : aliases.containsKey(parameter.getAlias()) ? parseAliasValue(parameter.getAlias(), edmParameter.getType(), edmParameter.isNullable(), edmParameter.isCollection(), edm, type, aliases).getText() : null; if (edmParameter.getMapping() == null) { primitiveType.valueOfString(primitiveType.fromUriLiteral(text), edmParameter.isNullable(), edmParameter.getMaxLength(), edmParameter.getPrecision(), edmParameter.getScale(), true, primitiveType.getDefaultType()); } else { primitiveType.valueOfString(primitiveType.fromUriLiteral(text), edmParameter.isNullable(), edmParameter.getMaxLength(), edmParameter.getPrecision(), edmParameter.getScale(), true, edmParameter.getMapping().getMappedJavaClass()); } } catch (final EdmPrimitiveTypeException e) { throw new UriValidationException( "Invalid value '" + text + "' for parameter " + parameter.getName(), e, UriValidationException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, parameter.getName()); } } } }
Example 3
Source File: Util.java From olingo-odata4 with Apache License 2.0 | 4 votes |
public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams) throws ODataApplicationException { // loop over all keys for (final UriParameter key : keyParams) { // key String keyName = key.getName(); String keyText = key.getText(); // Edm: we need this info for the comparison below EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName); Boolean isNullable = edmKeyProperty.isNullable(); Integer maxLength = edmKeyProperty.getMaxLength(); Integer precision = edmKeyProperty.getPrecision(); Boolean isUnicode = edmKeyProperty.isUnicode(); Integer scale = edmKeyProperty.getScale(); // get the EdmType in order to compare EdmType edmType = edmKeyProperty.getType(); EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType; // Runtime data: the value of the current entity // don't need to check for null, this is done in olingo library Object valueObject = entity.getProperty(keyName).getValue(); // now need to compare the valueObject with the keyText String // this is done using the type.valueToString // String valueAsString = null; try { valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode); } catch (EdmPrimitiveTypeException e) { throw new ODataApplicationException("Failed to retrieve String value", HttpStatusCode.INTERNAL_SERVER_ERROR .getStatusCode(), Locale.ENGLISH, e); } if (valueAsString == null) { return false; } boolean matches = valueAsString.equals(keyText); if (!matches) { // if any of the key properties is not found in the entity, we don't need to search further return false; } } return true; }
Example 4
Source File: Util.java From syndesis with Apache License 2.0 | 4 votes |
public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams) throws ODataApplicationException { // loop over all keys for (final UriParameter key : keyParams) { // key String keyName = key.getName(); String keyText = key.getText(); // Edm: we need this info for the comparison below EdmProperty edmKeyProperty = (EdmProperty)edmEntityType.getProperty(keyName); Boolean isNullable = edmKeyProperty.isNullable(); Integer maxLength = edmKeyProperty.getMaxLength(); Integer precision = edmKeyProperty.getPrecision(); Boolean isUnicode = edmKeyProperty.isUnicode(); Integer scale = edmKeyProperty.getScale(); // get the EdmType in order to compare EdmType edmType = edmKeyProperty.getType(); EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType)edmType; // Runtime data: the value of the current entity // don't need to check for null, this is done in olingo library Object valueObject = entity.getProperty(keyName).getValue(); // now need to compare the valueObject with the keyText String // this is done using the type.valueToString String valueAsString; try { valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode); } catch (EdmPrimitiveTypeException e) { throw new ODataApplicationException("Failed to retrieve String value", HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ENGLISH, e); } if (valueAsString == null) { return false; } boolean matches = valueAsString.equals(keyText); if (!matches) { // if any of the key properties is not found in the entity, we don't need to search further return false; } } return true; }
Example 5
Source File: Util.java From olingo-odata4 with Apache License 2.0 | 4 votes |
public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams) throws ODataApplicationException { // loop over all keys for (final UriParameter key : keyParams) { // key String keyName = key.getName(); String keyText = key.getText(); // Edm: we need this info for the comparison below EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName); Boolean isNullable = edmKeyProperty.isNullable(); Integer maxLength = edmKeyProperty.getMaxLength(); Integer precision = edmKeyProperty.getPrecision(); Boolean isUnicode = edmKeyProperty.isUnicode(); Integer scale = edmKeyProperty.getScale(); // get the EdmType in order to compare EdmType edmType = edmKeyProperty.getType(); EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType; // Runtime data: the value of the current entity // don't need to check for null, this is done in olingo library Object valueObject = entity.getProperty(keyName).getValue(); // now need to compare the valueObject with the keyText String // this is done using the type.valueToString String valueAsString; try { valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode); } catch (EdmPrimitiveTypeException e) { throw new ODataApplicationException("Failed to retrieve String value", HttpStatusCode.INTERNAL_SERVER_ERROR .getStatusCode(), Locale.ENGLISH, e); } if (valueAsString == null) { return false; } boolean matches = valueAsString.equals(keyText); if (!matches) { // if any of the key properties is not found in the entity, we don't need to search further return false; } } return true; }
Example 6
Source File: Util.java From olingo-odata4 with Apache License 2.0 | 4 votes |
public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams) throws ODataApplicationException { // loop over all keys for (final UriParameter key : keyParams) { // key String keyName = key.getName(); String keyText = key.getText(); // Edm: we need this info for the comparison below EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName); Boolean isNullable = edmKeyProperty.isNullable(); Integer maxLength = edmKeyProperty.getMaxLength(); Integer precision = edmKeyProperty.getPrecision(); Boolean isUnicode = edmKeyProperty.isUnicode(); Integer scale = edmKeyProperty.getScale(); // get the EdmType in order to compare EdmType edmType = edmKeyProperty.getType(); EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType; // Runtime data: the value of the current entity // don't need to check for null, this is done in olingo library Object valueObject = entity.getProperty(keyName).getValue(); // now need to compare the valueObject with the keyText String // this is done using the type.valueToString // String valueAsString = null; try { valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode); } catch (EdmPrimitiveTypeException e) { throw new ODataApplicationException("Failed to retrieve String value", HttpStatusCode.INTERNAL_SERVER_ERROR .getStatusCode(), Locale.ENGLISH, e); } if (valueAsString == null) { return false; } boolean matches = valueAsString.equals(keyText); if (!matches) { // if any of the key properties is not found in the entity, we don't need to search further return false; } } return true; }
Example 7
Source File: Util.java From olingo-odata4 with Apache License 2.0 | 4 votes |
public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity rt_entity, List<UriParameter> keyParams) { // loop over all keys for (final UriParameter key : keyParams) { // key String keyName = key.getName(); String keyText = key.getText(); // note: below line doesn't consider: keyProp can be part of a complexType in V4 // in such case, it would be required to access it via getKeyPropertyRef() // but since this isn't the case in our model, we ignore it in our implementation EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName); // Edm: we need this info for the comparison below Boolean isNullable = edmKeyProperty.isNullable(); Integer maxLength = edmKeyProperty.getMaxLength(); Integer precision = edmKeyProperty.getPrecision(); Boolean isUnicode = edmKeyProperty.isUnicode(); Integer scale = edmKeyProperty.getScale(); // get the EdmType in order to compare EdmType edmType = edmKeyProperty.getType(); // if(EdmType instanceof EdmPrimitiveType) // do we need this? EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType; // Runtime data: the value of the current entity // don't need to check for null, this is done in FWK Object valueObject = rt_entity.getProperty(keyName).getValue(); // TODO if the property is a complex type // now need to compare the valueObject with the keyText String // this is done using the type.valueToString String valueAsString = null; try { valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode); } catch (EdmPrimitiveTypeException e) { return false; // TODO proper Exception handling } if (valueAsString == null) { return false; } boolean matches = valueAsString.equals(keyText); if (matches) { // if the given key value is found in the current entity, continue with the next key continue; } else { // if any of the key properties is not found in the entity, we don't need to search further return false; } } return true; }
Example 8
Source File: Util.java From olingo-odata4 with Apache License 2.0 | 4 votes |
public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams) throws ODataApplicationException { // loop over all keys for (final UriParameter key : keyParams) { // key String keyName = key.getName(); String keyText = key.getText(); // Edm: we need this info for the comparison below EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName); Boolean isNullable = edmKeyProperty.isNullable(); Integer maxLength = edmKeyProperty.getMaxLength(); Integer precision = edmKeyProperty.getPrecision(); Boolean isUnicode = edmKeyProperty.isUnicode(); Integer scale = edmKeyProperty.getScale(); // get the EdmType in order to compare EdmType edmType = edmKeyProperty.getType(); EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType; // Runtime data: the value of the current entity // don't need to check for null, this is done in olingo library Object valueObject = entity.getProperty(keyName).getValue(); // now need to compare the valueObject with the keyText String // this is done using the type.valueToString // String valueAsString = null; try { valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode); } catch (EdmPrimitiveTypeException e) { throw new ODataApplicationException("Failed to retrieve String value", HttpStatusCode.INTERNAL_SERVER_ERROR .getStatusCode(), Locale.ENGLISH, e); } if (valueAsString == null) { return false; } boolean matches = valueAsString.equals(keyText); if (!matches) { // if any of the key properties is not found in the entity, we don't need to search further return false; } } return true; }
Example 9
Source File: Util.java From olingo-odata4 with Apache License 2.0 | 4 votes |
public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams) throws ODataApplicationException { // loop over all keys for (final UriParameter key : keyParams) { // key String keyName = key.getName(); String keyText = key.getText(); // Edm: we need this info for the comparison below EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName); Boolean isNullable = edmKeyProperty.isNullable(); Integer maxLength = edmKeyProperty.getMaxLength(); Integer precision = edmKeyProperty.getPrecision(); Boolean isUnicode = edmKeyProperty.isUnicode(); Integer scale = edmKeyProperty.getScale(); // get the EdmType in order to compare EdmType edmType = edmKeyProperty.getType(); EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType; // Runtime data: the value of the current entity // don't need to check for null, this is done in olingo library Object valueObject = entity.getProperty(keyName).getValue(); // now need to compare the valueObject with the keyText String // this is done using the type.valueToString // String valueAsString = null; try { valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode); } catch (EdmPrimitiveTypeException e) { throw new ODataApplicationException("Failed to retrieve String value", HttpStatusCode.INTERNAL_SERVER_ERROR .getStatusCode(), Locale.ENGLISH, e); } if (valueAsString == null) { return false; } boolean matches = valueAsString.equals(keyText); if (!matches) { // if any of the key properties is not found in the entity, we don't need to search further return false; } } return true; }
Example 10
Source File: Util.java From olingo-odata4 with Apache License 2.0 | 4 votes |
public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams) throws ODataApplicationException { // loop over all keys for (final UriParameter key : keyParams) { // key String keyName = key.getName(); String keyText = key.getText(); // Edm: we need this info for the comparison below EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName); Boolean isNullable = edmKeyProperty.isNullable(); Integer maxLength = edmKeyProperty.getMaxLength(); Integer precision = edmKeyProperty.getPrecision(); Boolean isUnicode = edmKeyProperty.isUnicode(); Integer scale = edmKeyProperty.getScale(); // get the EdmType in order to compare EdmType edmType = edmKeyProperty.getType(); EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType; // Runtime data: the value of the current entity // don't need to check for null, this is done in olingo library Object valueObject = entity.getProperty(keyName).getValue(); // now need to compare the valueObject with the keyText String // this is done using the type.valueToString String valueAsString; try { valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode); } catch (EdmPrimitiveTypeException e) { throw new ODataApplicationException("Failed to retrieve String value", HttpStatusCode.INTERNAL_SERVER_ERROR .getStatusCode(), Locale.ENGLISH, e); } if (valueAsString == null) { return false; } boolean matches = valueAsString.equals(keyText); if (!matches) { // if any of the key properties is not found in the entity, we don't need to search further return false; } } return true; }
Example 11
Source File: Util.java From olingo-odata4 with Apache License 2.0 | 4 votes |
public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity rt_entity, List<UriParameter> keyParams) { // loop over all keys for (final UriParameter key : keyParams) { // key String keyName = key.getName(); String keyText = key.getText(); // note: below line doesn't consider: keyProp can be part of a complexType in V4 // in such case, it would be required to access it via getKeyPropertyRef() // but since this isn't the case in our model, we ignore it in our implementation EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName); // Edm: we need this info for the comparison below Boolean isNullable = edmKeyProperty.isNullable(); Integer maxLength = edmKeyProperty.getMaxLength(); Integer precision = edmKeyProperty.getPrecision(); Boolean isUnicode = edmKeyProperty.isUnicode(); Integer scale = edmKeyProperty.getScale(); // get the EdmType in order to compare EdmType edmType = edmKeyProperty.getType(); // if(EdmType instanceof EdmPrimitiveType) // do we need this? EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType; // Runtime data: the value of the current entity // don't need to check for null, this is done in FWK Object valueObject = rt_entity.getProperty(keyName).getValue(); // TODO if the property is a complex type // now need to compare the valueObject with the keyText String // this is done using the type.valueToString String valueAsString = null; try { valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode); } catch (EdmPrimitiveTypeException e) { return false; // TODO proper Exception handling } if (valueAsString == null) { return false; } boolean matches = valueAsString.equals(keyText); // if any of the key properties is not found in the entity, we don't need to search further if (!matches) { return false; } // if the given key value is found in the current entity, continue with the next key } return true; }
Example 12
Source File: Util.java From olingo-odata4 with Apache License 2.0 | 4 votes |
public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams) throws ODataApplicationException { // loop over all keys for (final UriParameter key : keyParams) { // key String keyName = key.getName(); String keyText = key.getText(); // Edm: we need this info for the comparison below EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName); Boolean isNullable = edmKeyProperty.isNullable(); Integer maxLength = edmKeyProperty.getMaxLength(); Integer precision = edmKeyProperty.getPrecision(); Boolean isUnicode = edmKeyProperty.isUnicode(); Integer scale = edmKeyProperty.getScale(); // get the EdmType in order to compare EdmType edmType = edmKeyProperty.getType(); EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType; // Runtime data: the value of the current entity // don't need to check for null, this is done in olingo library Object valueObject = entity.getProperty(keyName).getValue(); // now need to compare the valueObject with the keyText String // this is done using the type.valueToString // String valueAsString = null; try { valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode); } catch (EdmPrimitiveTypeException e) { throw new ODataApplicationException("Failed to retrieve String value", HttpStatusCode.INTERNAL_SERVER_ERROR .getStatusCode(), Locale.ENGLISH, e); } if (valueAsString == null) { return false; } boolean matches = valueAsString.equals(keyText); if (!matches) { // if any of the key properties is not found in the entity, we don't need to search further return false; } } return true; }
Example 13
Source File: Util.java From olingo-odata4 with Apache License 2.0 | 4 votes |
public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity rt_entity, List<UriParameter> keyParams) { // loop over all keys for (final UriParameter key : keyParams) { // key String keyName = key.getName(); String keyText = key.getText(); // note: below line doesn't consider: keyProp can be part of a complexType in V4 // in such case, it would be required to access it via getKeyPropertyRef() // but since this isn't the case in our model, we ignore it in our implementation EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName); // Edm: we need this info for the comparison below Boolean isNullable = edmKeyProperty.isNullable(); Integer maxLength = edmKeyProperty.getMaxLength(); Integer precision = edmKeyProperty.getPrecision(); Boolean isUnicode = edmKeyProperty.isUnicode(); Integer scale = edmKeyProperty.getScale(); // get the EdmType in order to compare EdmType edmType = edmKeyProperty.getType(); // if(EdmType instanceof EdmPrimitiveType) // do we need this? EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType; // Runtime data: the value of the current entity // don't need to check for null, this is done in FWK Object valueObject = rt_entity.getProperty(keyName).getValue(); // TODO if the property is a complex type // now need to compare the valueObject with the keyText String // this is done using the type.valueToString String valueAsString = null; try { valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode); } catch (EdmPrimitiveTypeException e) { return false; // TODO proper Exception handling } if (valueAsString == null) { return false; } boolean matches = valueAsString.equals(keyText); // if any of the key properties is not found in the entity, we don't need to search further if (!matches) { return false; } // if the given key value is found in the current entity, continue with the next key } return true; }
Example 14
Source File: Util.java From olingo-odata4 with Apache License 2.0 | 4 votes |
public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams) throws ODataApplicationException { // loop over all keys for (final UriParameter key : keyParams) { // key String keyName = key.getName(); String keyText = key.getText(); // Edm: we need this info for the comparison below EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName); Boolean isNullable = edmKeyProperty.isNullable(); Integer maxLength = edmKeyProperty.getMaxLength(); Integer precision = edmKeyProperty.getPrecision(); Boolean isUnicode = edmKeyProperty.isUnicode(); Integer scale = edmKeyProperty.getScale(); // get the EdmType in order to compare EdmType edmType = edmKeyProperty.getType(); EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType; // Runtime data: the value of the current entity // don't need to check for null, this is done in olingo library Object valueObject = entity.getProperty(keyName).getValue(); // now need to compare the valueObject with the keyText String // this is done using the type.valueToString // String valueAsString = null; try { valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode); } catch (EdmPrimitiveTypeException e) { throw new ODataApplicationException("Failed to retrieve String value", HttpStatusCode.INTERNAL_SERVER_ERROR .getStatusCode(), Locale.ENGLISH, e); } if (valueAsString == null) { return false; } boolean matches = valueAsString.equals(keyText); if (!matches) { // if any of the key properties is not found in the entity, we don't need to search further return false; } } return true; }
Example 15
Source File: Util.java From olingo-odata4 with Apache License 2.0 | 4 votes |
public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams) throws ODataApplicationException { // loop over all keys for (final UriParameter key : keyParams) { // key String keyName = key.getName(); String keyText = key.getText(); // Edm: we need this info for the comparison below EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName); Boolean isNullable = edmKeyProperty.isNullable(); Integer maxLength = edmKeyProperty.getMaxLength(); Integer precision = edmKeyProperty.getPrecision(); Boolean isUnicode = edmKeyProperty.isUnicode(); Integer scale = edmKeyProperty.getScale(); // get the EdmType in order to compare EdmType edmType = edmKeyProperty.getType(); EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType; // Runtime data: the value of the current entity // don't need to check for null, this is done in olingo library Object valueObject = entity.getProperty(keyName).getValue(); // now need to compare the valueObject with the keyText String // this is done using the type.valueToString String valueAsString; try { valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode); } catch (EdmPrimitiveTypeException e) { throw new ODataApplicationException("Failed to retrieve String value", HttpStatusCode.INTERNAL_SERVER_ERROR .getStatusCode(), Locale.ENGLISH, e); } if (valueAsString == null) { return false; } boolean matches = valueAsString.equals(keyText); if (!matches) { // if any of the key properties is not found in the entity, we don't need to search further return false; } } return true; }
Example 16
Source File: Util.java From olingo-odata4 with Apache License 2.0 | 4 votes |
public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams) throws ODataApplicationException { // loop over all keys for (final UriParameter key : keyParams) { // key String keyName = key.getName(); String keyText = key.getText(); // Edm: we need this info for the comparison below EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName); Boolean isNullable = edmKeyProperty.isNullable(); Integer maxLength = edmKeyProperty.getMaxLength(); Integer precision = edmKeyProperty.getPrecision(); Boolean isUnicode = edmKeyProperty.isUnicode(); Integer scale = edmKeyProperty.getScale(); // get the EdmType in order to compare EdmType edmType = edmKeyProperty.getType(); EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType; // Runtime data: the value of the current entity // don't need to check for null, this is done in olingo library Object valueObject = entity.getProperty(keyName).getValue(); // now need to compare the valueObject with the keyText String // this is done using the type.valueToString // String valueAsString = null; try { valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode); } catch (EdmPrimitiveTypeException e) { throw new ODataApplicationException("Failed to retrieve String value", HttpStatusCode.INTERNAL_SERVER_ERROR .getStatusCode(), Locale.ENGLISH, e); } if (valueAsString == null) { return false; } boolean matches = valueAsString.equals(keyText); if (!matches) { // if any of the key properties is not found in the entity, we don't need to search further return false; } } return true; }
Example 17
Source File: Util.java From olingo-odata4 with Apache License 2.0 | 4 votes |
public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams) throws ODataApplicationException { // loop over all keys for (final UriParameter key : keyParams) { // key String keyName = key.getName(); String keyText = key.getText(); // Edm: we need this info for the comparison below EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName); Boolean isNullable = edmKeyProperty.isNullable(); Integer maxLength = edmKeyProperty.getMaxLength(); Integer precision = edmKeyProperty.getPrecision(); Boolean isUnicode = edmKeyProperty.isUnicode(); Integer scale = edmKeyProperty.getScale(); // get the EdmType in order to compare EdmType edmType = edmKeyProperty.getType(); EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType; // Runtime data: the value of the current entity // don't need to check for null, this is done in olingo library Object valueObject = entity.getProperty(keyName).getValue(); // now need to compare the valueObject with the keyText String // this is done using the type.valueToString String valueAsString; try { valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode); } catch (EdmPrimitiveTypeException e) { throw new ODataApplicationException("Failed to retrieve String value", HttpStatusCode.INTERNAL_SERVER_ERROR .getStatusCode(), Locale.ENGLISH, e); } if (valueAsString == null) { return false; } boolean matches = valueAsString.equals(keyText); if (!matches) { // if any of the key properties is not found in the entity, we don't need to search further return false; } } return true; }
Example 18
Source File: Util.java From olingo-odata4 with Apache License 2.0 | 4 votes |
public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity rt_entity, List<UriParameter> keyParams) throws ODataApplicationException { // loop over all keys for (final UriParameter key : keyParams) { // key String keyName = key.getName(); String keyText = key.getText(); // Edm: we need this info for the comparison below EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName); Boolean isNullable = edmKeyProperty.isNullable(); Integer maxLength = edmKeyProperty.getMaxLength(); Integer precision = edmKeyProperty.getPrecision(); Boolean isUnicode = edmKeyProperty.isUnicode(); Integer scale = edmKeyProperty.getScale(); // get the EdmType in order to compare EdmType edmType = edmKeyProperty.getType(); // if(EdmType instanceof EdmPrimitiveType) // do we need this? EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType; // Runtime data: the value of the current entity // don't need to check for null, this is done in olingo library Object valueObject = rt_entity.getProperty(keyName).getValue(); // now need to compare the valueObject with the keyText String // this is done using type.valueToString String valueAsString = null; try { valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode); } catch (EdmPrimitiveTypeException e) { throw new ODataApplicationException("Failed to retrieve String value", HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ENGLISH, e); } if (valueAsString == null) { return false; } boolean matches = valueAsString.equals(keyText); if (!matches) { // if any of the key properties is not found in the entity, we don't need to search further return false; } } return true; }