@Override public EdmURIBuilder appendFunctionImportParameters(Map<EdmParameter, Object> functionImportParams) { try { if (functionImportParams != null) { for (Map.Entry<EdmParameter, Object> param : functionImportParams.entrySet()) { EdmParameter edmParam = param.getKey(); EdmSimpleType edmType = (EdmSimpleType) edmParam.getType(); Object value = param.getValue(); if (value instanceof String) { value = value.toString(); } value = edmType.valueToString(value, EdmLiteralKind.URI, edmParam.getFacets()); functionImportParameters.put(edmParam.getName(), value); } } } catch (EdmException e) { throw new RuntimeException("Unexpected EDM Exception: ", e);//NOSONAR } return this; } }
public Object getFunctionImportParameterValue(EdmLiteral literal, EdmSimpleType paramType) throws EdmSimpleTypeException{ return paramType.valueOfString(literal.getLiteral(), EdmLiteralKind.DEFAULT, null, paramType.getDefaultType()); } }
Class<?> edmMappedType) throws ODataJPARuntimeException { if (EdmSimpleTypeKind.String.getEdmSimpleTypeInstance().isCompatible(edmSimpleType) || EdmSimpleTypeKind.Guid.getEdmSimpleTypeInstance().isCompatible(edmSimpleType)) { uriLiteral = uriLiteral.replaceAll("'", "''"); uriLiteral = updateValueIfWildcards(uriLiteral); } else if (EdmSimpleTypeKind.DateTime.getEdmSimpleTypeInstance().isCompatible(edmSimpleType) || EdmSimpleTypeKind.DateTimeOffset.getEdmSimpleTypeInstance().isCompatible(edmSimpleType)) { try { Calendar datetime = (Calendar) edmSimpleType.valueOfString(uriLiteral, EdmLiteralKind.DEFAULT, null, edmSimpleType .getDefaultType()); } else if (EdmSimpleTypeKind.Time.getEdmSimpleTypeInstance().isCompatible(edmSimpleType)) { try { Calendar time = (Calendar) edmSimpleType.valueOfString(uriLiteral, EdmLiteralKind.DEFAULT, null, edmSimpleType .getDefaultType());
private String convertKeyValuesToString(Map<String, Object> keys, EdmEntityType entityType) throws EdmException { String keyPredicateString = ""; for (Entry<String, Object> e : keys.entrySet()) { if (!keyPredicateString.isEmpty()) keyPredicateString += ','; String key = e.getKey(); Object value = e.getValue(); EdmProperty prop = (EdmProperty) entityType.getProperty(key); EdmSimpleType type = (EdmSimpleType) (prop.getType()); String convertedValue = type .toUriLiteral(type.valueToString(value, EdmLiteralKind.DEFAULT, prop.getFacets())); keyPredicateString += key + '=' + convertedValue; } return keyPredicateString; }
private Object formatValue(EdmSimpleType type , LiteralExpression literal) throws EdmException{ EdmSimpleTypeKind typeKind = EdmSimpleTypeKind.valueOf(type.getName()); String value = literal.getUriLiteral().toString(); EdmSimpleType instance = typeKind.getEdmSimpleTypeInstance(); return instance.valueOfString(value , EdmLiteralKind.DEFAULT, null, instance.getDefaultType()); return instance.valueOfString(value , EdmLiteralKind.DEFAULT, null, instance.getDefaultType()); return instance.valueOfString(value , EdmLiteralKind.DEFAULT, null, instance.getDefaultType()); }else if(typeKind.name().equals("Double")){ value = value.replace("d", ""); return instance.valueOfString(value.toString() , EdmLiteralKind.DEFAULT, null, instance.getDefaultType()); }else if(typeKind.name().equals("Int64")){ value = value.replace("L", "").replace("l", "");// Replacing lower case 'l' not required. return instance.valueOfString(value.toString() , EdmLiteralKind.DEFAULT, null, instance.getDefaultType()); }else if(typeKind.name().equals("Guid")){ value = value.replace("guid'", "").replace("'", ""); UUID guidValue = UUID.fromString(value); return instance.valueOfString(guidValue.toString() , EdmLiteralKind.DEFAULT, null, instance.getDefaultType()); return instance.valueOfString(value.toString() , EdmLiteralKind.DEFAULT, null, instance.getDefaultType()); }else{ return instance.valueOfString(literal.getUriLiteral().toString() , EdmLiteralKind.DEFAULT, null, instance.getDefaultType());
final EdmProperty property = (EdmProperty) ((PropertyExpression) expression).getEdmProperty(); final EdmSimpleType propertyType = (EdmSimpleType) property.getType(); return propertyType.valueToString(valueAccess.getPropertyValue(data, property), EdmLiteralKind.DEFAULT, property.getFacets()); : null; return memberType.valueToString(getPropertyValue(data, propertyPath), EdmLiteralKind.DEFAULT, memberProperty .getFacets()); final LiteralExpression literal = (LiteralExpression) expression; final EdmSimpleType literalType = (EdmSimpleType) literal.getEdmType(); return literalType.valueToString(literalType.valueOfString(literal.getUriLiteral(), EdmLiteralKind.URI, null, literalType.getDefaultType()), EdmLiteralKind.DEFAULT, null);
Object value = fetchDefaultValue(type.getDefaultType()); keyValue = Encoder.encode(type.valueToString(value, EdmLiteralKind.URI, keyPropertyInfo.getFacets())); } else { keyValue = Encoder.encode(type.valueToString(data.get(name), EdmLiteralKind.URI, keyPropertyInfo.getFacets()));
try { final EdmSimpleType type = getEdmSimpleType(EdmSimpleTypeKind.String); return new EdmLiteral(type, type.valueOfString(uriLiteral, EdmLiteralKind.URI, facets, String.class)); } catch (EdmSimpleTypeException e) { throw new EdmLiteralException(EdmLiteralException.LITERALFORMAT.addContent(uriLiteral), e); final int i = getEdmSimpleType(EdmSimpleTypeKind.Int32) .valueOfString(uriLiteral, EdmLiteralKind.URI, facets, Integer.class); if (i == 0 || i == 1) { return new EdmLiteral(getInternalEdmSimpleTypeByString("Bit"), uriLiteral); try { final EdmSimpleType type = getEdmSimpleType(EdmSimpleTypeKind.Binary); final byte[] value = type.valueOfString(uriLiteral, EdmLiteralKind.URI, facets, byte[].class); return new EdmLiteral(type, type.valueToString(value, EdmLiteralKind.DEFAULT, facets)); } catch (EdmSimpleTypeException e) { throw new EdmLiteralException(EdmLiteralException.LITERALFORMAT.addContent(uriLiteral), e);
String fqnTypeName = type.getNamespace() + Edm.DELIMITER + type.getName(); writer.writeAttribute(Edm.NAMESPACE_M_2007_08, FormatXml.ATOM_TYPE, fqnTypeName); final String valueAsString = type.valueToString(contentValue, EdmLiteralKind.DEFAULT, prop.getFacets()); if (valueAsString == null) { writer.writeAttribute(Edm.NAMESPACE_M_2007_08, FormatXml.ATOM_NULL, FormatXml.ATOM_VALUE_TRUE);
final EdmSimpleType type = (EdmSimpleType) propertyInfo.getType(); final Object contentValue = value instanceof Map ? ((Map<?, ?>) value).get(propertyInfo.getName()) : value; final String valueAsString = type.valueToString(contentValue, EdmLiteralKind.JSON, propertyInfo.getFacets()); switch (EdmSimpleTypeKind.valueOf(type.getName())) { case String: jsonStreamWriter.stringValue(valueAsString);
private Object convertArgument(final EdmLiteral edmLiteral, final EdmFacets facets, final Class<?> targetType) throws EdmSimpleTypeException { Object value = null; if (edmLiteral != null) { EdmSimpleType edmType = edmLiteral.getType(); value = edmType.valueOfString(edmLiteral.getLiteral(), EdmLiteralKind.DEFAULT, facets, targetType); } return value; }
int index = ODataExpressionParser.index.get(); Class<? extends Object> type = edmMappedType==null? edmSimpleType.getDefaultType(): edmMappedType; int size = positionalParameters.size();
if (!paramType.isCompatible((EdmSimpleType) actType)) { return false;
@Override public Object visitLiteral(LiteralExpression literal, EdmLiteral edmLiteral) { try { EdmSimpleType type = edmLiteral.getType(); Object value = null; if(type.getNamespace().equals("System")){ value = formatSystemTypeValue(literal); }else{ value = formatValue(type,literal ); } tempStack.push(new LiteralNodeImpl(value , new NodeInfoImpl(NODE_KIND.LITERAL))); } catch (EdmException | FilterOptionException e) { log.debug("Error in Filter expression traversal: "+Arrays.toString( e.getStackTrace())); } return null; }
private static EdmLiteral createEdmLiteral(final EdmSimpleTypeKind typeKind, final String literal, final int prefixLength, final int suffixLength) throws EdmLiteralException { final EdmSimpleType type = getEdmSimpleType(typeKind); if (type.validate(literal, EdmLiteralKind.URI, null)) { return new EdmLiteral(type, literal.substring(prefixLength, literal.length() - suffixLength)); } else { throw new EdmLiteralException(EdmLiteralException.LITERALFORMAT.addContent(literal)); } }
if(typeObj instanceof EdmSimpleType){ if(checkNull(typeObj)) edmTypeMap.put(edmName, ((EdmSimpleType)typeObj).getName()); }else if(typeObj instanceof EdmComplexType){ log.debug("Complex type entity name: "+edmName); Object typeCompObj = edmCompType.getProperty(edmCompName).getType(); if( typeCompObj instanceof EdmSimpleType){ edmTypeMap.put(edmName+" - "+edmCompName, ((EdmSimpleType)typeCompObj).getName());
keyPredicate = keyPredicates.get(i); literal = ((EdmSimpleType) keyPredicate.getProperty().getType()).toUriLiteral(keyPredicate.getLiteral()); condition.append(keyPredicate.getProperty().getName()).append(SPACE); condition.append(ODATA_OPERATOR_NE).append(SPACE);
final EdmProperty property = (EdmProperty) ((PropertyExpression) expression).getEdmProperty(); final EdmSimpleType propertyType = (EdmSimpleType) property.getType(); return propertyType.valueToString(valueAccess.getPropertyValue(data, property), EdmLiteralKind.DEFAULT, property.getFacets()); : null; return memberType.valueToString(getPropertyValue(data, propertyPath), EdmLiteralKind.DEFAULT, memberProperty .getFacets()); final LiteralExpression literal = (LiteralExpression) expression; final EdmSimpleType literalType = (EdmSimpleType) literal.getEdmType(); return literalType.valueToString(literalType.valueOfString(literal.getUriLiteral(), EdmLiteralKind.URI, null, literalType.getDefaultType()), EdmLiteralKind.DEFAULT, null);
reader.nextNull(); } else { switch (EdmSimpleTypeKind.valueOf(type.getName())) { case Boolean: if (tokenType == JsonToken.BOOLEAN) { final Class<?> typeMappingClass = typeMapping == null ? type.getDefaultType() : (Class<?>) typeMapping; return type.valueOfString((String) value, EdmLiteralKind.JSON, entityPropertyInfo.getFacets(), typeMappingClass);
@Override public ODataResponse build(final GetFunctionImportUriInfo resultsView, final Object result) throws ODataJPARuntimeException { try { final EdmFunctionImport functionImport = resultsView.getFunctionImport(); final EdmSimpleType type = (EdmSimpleType) functionImport.getReturnType().getType(); if (result != null) { ODataResponse response = null; if (type.getDefaultType().equals(byte[].class)) { response = EntityProvider.writeBinary("application/octet-stream", (byte[]) result); } else { final String value = type.valueToString(result, EdmLiteralKind.DEFAULT, null); response = EntityProvider.writeText(value); } return ODataResponse.fromResponse(response).build(); } else { throw new ODataNotFoundException(ODataHttpException.COMMON); } } catch (EdmException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } catch (EntityProviderException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } catch (ODataException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e); } }