private void putType(ObjectNode node, final String name, final EdmType type) { if (type != null) { node.put(name, type.getFullQualifiedName().getFullQualifiedNameAsString()); } }
@Override public boolean isPrimitive() { return propertyType != null && propertyType.getKind() == EdmTypeKind.PRIMITIVE; }
@Override public BuilderImpl setType(final EdmType type) { EdmPrimitiveTypeKind primitiveTypeKind = null; if (type != null) { if (type.getKind() != EdmTypeKind.PRIMITIVE) { throw new IllegalArgumentException(String.format("Provided type %s is not primitive", type)); } primitiveTypeKind = EdmPrimitiveTypeKind.valueOf(type.getName()); } return setType(primitiveTypeKind); }
@Override public JPAEntityType getEntity(final EdmType edmType) throws ODataJPAModelException { final IntermediateSchema schema = schemaListInternalKey.get(edmType.getNamespace()); if (schema != null) return schema.getEntityType(edmType.getName()); return null; }
private void consumePropertySingleNode(final String name, final EdmType type, final boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale, final boolean isUnicode, final EdmMapping mapping, final JsonNode jsonNode, final Property property) throws DeserializerException { switch (type.getKind()) { case PRIMITIVE: case DEFINITION: case ENUM: Object value = readPrimitiveValue(name, (EdmPrimitiveType) type, isNullable, maxLength, precision, scale, isUnicode, mapping, jsonNode); property.setValue(type.getKind() == EdmTypeKind.ENUM ? ValueType.ENUM : ValueType.PRIMITIVE, value); break; case COMPLEX: EdmType derivedType = getDerivedType((EdmComplexType) type, jsonNode); property.setType(derivedType.getFullQualifiedName().getFullQualifiedNameAsString()); value = readComplexNode(name, derivedType, isNullable, jsonNode); property.setValue(ValueType.COMPLEX, value); break; default: throw new DeserializerException("Invalid Type Kind for a property found: " + type.getKind(), DeserializerException.MessageKeys.INVALID_JSON_TYPE_FOR_PROPERTY, name); } }
private static List<Column> resolveKeyPredicatesToColumnsUpdate(EdmEntityType entityType, List<UriParameter> keyPredicates){ List<Column> columns = new ArrayList<Column>(); for(UriParameter uriPred:keyPredicates){ Column col=formNewColumnObject(uriPred.getName().replace("_", "."),null,getValueOfProperty(uriPred),true); col.setColumnDataType(entityType.getProperty(uriPred.getName()).getType().getName()); columns.add(col); } return columns; }
private void consumePropertySingleNode(final String name, final EdmType type, final boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale, final boolean isUnicode, final EdmMapping mapping, final JsonNode jsonNode, final Property property) throws DeserializerException { switch (type.getKind()) { case PRIMITIVE: case DEFINITION: case ENUM: Object value = readPrimitiveValue(name, (EdmPrimitiveType) type, isNullable, maxLength, precision, scale, isUnicode, mapping, jsonNode); property.setValue(type.getKind() == EdmTypeKind.ENUM ? ValueType.ENUM : ValueType.PRIMITIVE, value); break; case COMPLEX: EdmType derivedType = getDerivedType((EdmComplexType) type, jsonNode); property.setType(derivedType.getFullQualifiedName() .getFullQualifiedNameAsString()); value = readComplexNode(name, derivedType, isNullable, jsonNode); property.setValue(ValueType.COMPLEX, value); break; default: throw new DeserializerException("Invalid Type Kind for a property found: " + type.getKind(), DeserializerException.MessageKeys.INVALID_JSON_TYPE_FOR_PROPERTY, name); } }
@Override public boolean compatibleTo(final EdmType targetType) { EdmStructuredType sourceType = this; if (targetType == null) { throw new EdmException("Target type must not be null"); } while (!sourceType.getName().equals(targetType.getName()) || !sourceType.getNamespace().equals(targetType.getNamespace())) { sourceType = sourceType.getBaseType(); if (sourceType == null) { return false; } } return true; }
@Override public Object visitLiteral(Literal literal) throws ExpressionVisitException, ODataApplicationException { validateDate(literal.getText(), literal.getType()); if(literal.getType()!=null&&literal.getType().getName().equals("Guid")) { /* * We want to convert uuids in a case insensitive manner, to do that we convert to lower case * 1) the actual value to which comparison has to be done * 2) The value persisted in DB. (By calling LCASE function of HANA.This is done in the visitMember method) */ return ("'"+literal.getText()+"'").toLowerCase(); } return literal.getText(); }
private void appendType(JsonGenerator json, final String name, final EdmType type) throws IOException { if (type != null) { json.writeStringField(name, type.getFullQualifiedName().getFullQualifiedNameAsString()); } }
private void checkEqualityTypes(final Expression left, final Expression right) throws UriParserException { checkNoCollection(left); checkNoCollection(right); final EdmType leftType = getType(left); final EdmType rightType = getType(right); if (leftType == null || rightType == null || leftType.equals(rightType)) { return; } // Numeric promotion for Edm.Byte and Edm.SByte if (isType(leftType, EdmPrimitiveTypeKind.Byte, EdmPrimitiveTypeKind.SByte) && isType(rightType, EdmPrimitiveTypeKind.Byte, EdmPrimitiveTypeKind.SByte)) { return; } if (leftType.getKind() != EdmTypeKind.PRIMITIVE || rightType.getKind() != EdmTypeKind.PRIMITIVE || !(((EdmPrimitiveType) leftType).isCompatible((EdmPrimitiveType) rightType) || ((EdmPrimitiveType) rightType).isCompatible((EdmPrimitiveType) leftType))) { throw new UriParserSemanticException("Incompatible types.", UriParserSemanticException.MessageKeys.TYPES_NOT_COMPATIBLE, leftType.getFullQualifiedName().getFullQualifiedNameAsString(), rightType.getFullQualifiedName().getFullQualifiedNameAsString()); } }
@Override public boolean isPrimitive() { return propertyType != null && propertyType.getKind() == EdmTypeKind.PRIMITIVE; }
@Override public BuilderImpl setType(final EdmType type) { EdmPrimitiveTypeKind primitiveTypeKind = null; if (type != null) { if (type.getKind() != EdmTypeKind.PRIMITIVE) { throw new IllegalArgumentException(String.format("Provided type %s is not primitive", type)); } primitiveTypeKind = EdmPrimitiveTypeKind.valueOf(type.getName()); } return setType(primitiveTypeKind); }
@Override public boolean compatibleTo(final EdmType targetType) { EdmStructuredType sourceType = this; if (targetType == null) { throw new EdmException("Target type must not be null"); } while (!sourceType.getName().equals(targetType.getName()) || !sourceType.getNamespace().equals(targetType.getNamespace())) { sourceType = sourceType.getBaseType(); if (sourceType == null) { return false; } } return true; }
@Override public String toString() { return type == null ? "NULL" : type.getFullQualifiedName().getFullQualifiedNameAsString(); } }
private void checkEqualityTypes(final Expression left, final Expression right) throws UriParserException { checkNoCollection(left); checkNoCollection(right); final EdmType leftType = getType(left); final EdmType rightType = getType(right); if (leftType == null || rightType == null || leftType.equals(rightType)) { return; } // Numeric promotion for Edm.Byte and Edm.SByte if (isType(leftType, EdmPrimitiveTypeKind.Byte, EdmPrimitiveTypeKind.SByte) && isType(rightType, EdmPrimitiveTypeKind.Byte, EdmPrimitiveTypeKind.SByte)) { return; } if (leftType.getKind() != EdmTypeKind.PRIMITIVE || rightType.getKind() != EdmTypeKind.PRIMITIVE || !(((EdmPrimitiveType) leftType).isCompatible((EdmPrimitiveType) rightType) || ((EdmPrimitiveType) rightType).isCompatible((EdmPrimitiveType) leftType))) { throw new UriParserSemanticException("Incompatible types.", UriParserSemanticException.MessageKeys.TYPES_NOT_COMPATIBLE, leftType.getFullQualifiedName().getFullQualifiedNameAsString(), rightType.getFullQualifiedName().getFullQualifiedNameAsString()); } }
private boolean isEnumType(final Expression expression) throws UriParserException { final EdmType expressionType = getType(expression); return expressionType == null || expressionType.getKind() == EdmTypeKind.ENUM || isType(expressionType, EdmPrimitiveTypeKind.Int16, EdmPrimitiveTypeKind.Int32, EdmPrimitiveTypeKind.Int64, EdmPrimitiveTypeKind.Byte, EdmPrimitiveTypeKind.SByte); }
/** * Set the edm entity type. * @param type the edm entity type * @return Builder */ public Builder type(final EdmType type) { contextURL.entitySetOrSingletonOrType = type.getFullQualifiedName().toString(); return this; }
@Override public Parameter parameter(final String content, final EdmParameter parameter) throws DeserializerException { final EdmType type = parameter.getType(); final EdmTypeKind kind = type.getKind(); if ((kind == EdmTypeKind.PRIMITIVE || kind == EdmTypeKind.DEFINITION || kind == EdmTypeKind.ENUM) && !parameter.isCollection()) { // The content is a primitive URI literal. Parameter result = new Parameter(); result.setName(parameter.getName()); result.setType(type.getFullQualifiedName().getFullQualifiedNameAsString()); final EdmPrimitiveType primitiveType = (EdmPrimitiveType) type; try { result.setValue(type.getKind() == EdmTypeKind.ENUM ? ValueType.ENUM : ValueType.PRIMITIVE, primitiveType.valueOfString(primitiveType.fromUriLiteral(content), parameter.isNullable(), parameter.getMaxLength(), parameter.getPrecision(), parameter.getScale(), true, parameter.getMapping() == null ? primitiveType.getDefaultType() : parameter.getMapping().getMappedJavaClass())); } catch (final EdmPrimitiveTypeException e) { throw new DeserializerException( "Invalid value '" + content + "' for parameter " + parameter.getName(), e, DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, parameter.getName()); } return result; } else { // The content is a JSON array or object. return new ODataJsonDeserializer(ContentType.JSON).parameter(content, parameter); } }
private boolean isEnumType(final Expression expression) throws UriParserException { final EdmType expressionType = getType(expression); return expressionType == null || expressionType.getKind() == EdmTypeKind.ENUM || isType(expressionType, EdmPrimitiveTypeKind.Int16, EdmPrimitiveTypeKind.Int32, EdmPrimitiveTypeKind.Int64, EdmPrimitiveTypeKind.Byte, EdmPrimitiveTypeKind.SByte); }