@Override public boolean isCollection() { return property.isCollection(); }
@Override public boolean isCollection() { return property.isCollection(); }
@Override public boolean isCollection() { return property.isCollection(); }
@Override public boolean isCollection() { return property.isCollection(); }
private static AliasQueryOption getKeyAlias(final String name, final EdmProperty edmProperty, final Edm edm, final EdmType referringType, final Map<String, AliasQueryOption> aliases) throws UriParserException, UriValidationException { if (aliases.containsKey(name)) { return parseAliasValue(name, edmProperty.getType(), edmProperty.isNullable(), edmProperty.isCollection(), edm, referringType, aliases); } else { throw new UriValidationException("Alias '" + name + "' for key value not found.", UriValidationException.MessageKeys.MISSING_ALIAS, name); } }
private PropertyResponse buildResponse(ODataResponse response, EdmProperty edmProperty) throws ContentNegotiatorException, SerializerException { PropertyResponse propertyResponse = PropertyResponse.getInstance(DataRequest.this, response, edmProperty.getType(), getContextURL(odata), edmProperty.isCollection()); return propertyResponse; }
private static AliasQueryOption getKeyAlias(final String name, final EdmProperty edmProperty, final Edm edm, final EdmType referringType, final Map<String, AliasQueryOption> aliases) throws UriParserException, UriValidationException { if (aliases.containsKey(name)) { return parseAliasValue(name, edmProperty.getType(), edmProperty.isNullable(), edmProperty.isCollection(), edm, referringType, aliases); } else { throw new UriValidationException("Alias '" + name + "' for key value not found.", UriValidationException.MessageKeys.MISSING_ALIAS, name); } }
private PropertyResponse buildResponse(ODataResponse response, EdmProperty edmProperty) throws ContentNegotiatorException, SerializerException { PropertyResponse propertyResponse = PropertyResponse.getInstance(DataRequest.this, response, edmProperty.getType(), getContextURL(odata), edmProperty.isCollection()); return propertyResponse; }
private void validatePropertyOperations(final UriInfo uriInfo, final HttpMethod method) throws UriValidationException { final List<UriResource> parts = uriInfo.getUriResourceParts(); final UriResource last = !parts.isEmpty() ? parts.get(parts.size() - 1) : null; final UriResource previous = parts.size() > 1 ? parts.get(parts.size() - 2) : null; if (last != null && (last.getKind() == UriResourceKind.primitiveProperty || last.getKind() == UriResourceKind.complexProperty || (last.getKind() == UriResourceKind.value && previous != null && previous.getKind() == UriResourceKind.primitiveProperty))) { final EdmProperty property = ((UriResourceProperty) (last.getKind() == UriResourceKind.value ? previous : last)).getProperty(); if (method == HttpMethod.PATCH && property.isCollection()) { throw new UriValidationException("Attempt to patch collection property.", UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD, method.toString()); } if (method == HttpMethod.DELETE && !property.isNullable()) { throw new UriValidationException("Attempt to delete non-nullable property.", UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD, method.toString()); } } } }
private void consumeEntityProperties(final EdmEntityType edmEntityType, final ObjectNode node, final Entity entity) throws DeserializerException { List<String> propertyNames = edmEntityType.getPropertyNames(); for (String propertyName : propertyNames) { JsonNode jsonNode = node.get(propertyName); if (jsonNode != null) { EdmProperty edmProperty = (EdmProperty) edmEntityType.getProperty(propertyName); if (jsonNode.isNull() && !edmProperty.isNullable()) { throw new DeserializerException("Property: " + propertyName + " must not be null.", DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, propertyName); } Property property = consumePropertyNode(edmProperty.getName(), edmProperty.getType(), edmProperty.isCollection(), edmProperty.isNullable(), edmProperty.getMaxLength(), edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(), edmProperty.getMapping(), jsonNode); entity.addProperty(property); node.remove(propertyName); } } }
edmProperty.isCollection(), edmProperty.isNullable(), edmProperty.getMaxLength(), edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(), edmProperty.getMapping(), subNode);
private void consumeEntityProperties(final EdmEntityType edmEntityType, final ObjectNode node, final Entity entity) throws DeserializerException { List<String> propertyNames = edmEntityType.getPropertyNames(); for (String propertyName : propertyNames) { JsonNode jsonNode = node.get(propertyName); if (jsonNode != null) { EdmProperty edmProperty = (EdmProperty) edmEntityType.getProperty(propertyName); if (jsonNode.isNull() && !edmProperty.isNullable()) { throw new DeserializerException("Property: " + propertyName + " must not be null.", DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, propertyName); } Property property = consumePropertyNode(edmProperty.getName(), edmProperty.getType(), edmProperty.isCollection(), edmProperty.isNullable(), edmProperty.getMaxLength(), edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(), edmProperty.getMapping(), jsonNode); entity.addProperty(property); node.remove(propertyName); } } }
private void consumeEntityProperties(final EdmEntityType edmEntityType, final ObjectNode node, final Entity entity) throws DeserializerException { List<String> propertyNames = edmEntityType.getPropertyNames(); for (String propertyName : propertyNames) { JsonNode jsonNode = node.get(propertyName); if (jsonNode != null) { EdmProperty edmProperty = (EdmProperty) edmEntityType.getProperty(propertyName); if (jsonNode.isNull() && !edmProperty.isNullable()) { throw new DeserializerException("Property: " + propertyName + " must not be null.", DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, propertyName); } Property property = consumePropertyNode(edmProperty.getName(), edmProperty.getType(), edmProperty.isCollection(), edmProperty.isNullable(), edmProperty.getMaxLength(), edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(), edmProperty.getMapping(), jsonNode); entity.addProperty(property); node.remove(propertyName); } } }
@Override public DeserializerResult property(final InputStream stream, final EdmProperty edmProperty) throws DeserializerException { try { final ObjectNode tree = parseJsonTree(stream); final Property property; JsonNode jsonNode = tree.get(Constants.VALUE); if (jsonNode != null) { property = consumePropertyNode(edmProperty.getName(), edmProperty.getType(), edmProperty.isCollection(), edmProperty.isNullable(), edmProperty.getMaxLength(), edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(), edmProperty.getMapping(), jsonNode); tree.remove(Constants.VALUE); } else { property = consumePropertyNode(edmProperty.getName(), edmProperty.getType(), edmProperty.isCollection(), edmProperty.isNullable(), edmProperty.getMaxLength(), edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(), edmProperty.getMapping(), tree); } return DeserializerResultImpl.with().property(property).build(); } catch (final IOException e) { throw wrapParseException(e); } }
@Override public SerializerResult serialize(final ODataRequest request, final EntityCollection result) throws SerializerException { final EdmEntitySet targetEdmEntitySet = Util.determineTargetEntitySet(uriInfo.getUriResourceParts()); final UriResourceProperty uriProperty = (UriResourceProperty) uriInfo.getUriResourceParts().get(uriInfo .getUriResourceParts().size() - 1); final JPAPrimitivePropertyInfo property = determinePrimitiveProperty(result, uriInfo.getUriResourceParts()); final EdmPrimitiveType edmPropertyType = (EdmPrimitiveType) uriProperty.getProperty().getType(); final ContextURL contextUrl = ContextURL.with() .entitySet(targetEdmEntitySet) .navOrPropertyPath(property.getPath()) .build(); final PrimitiveSerializerOptions options = PrimitiveSerializerOptions.with().contextURL(contextUrl).build(); if (uriProperty.getProperty().isCollection()) return serializer.primitiveCollection(serviceMetadata, edmPropertyType, property.getProperty(), options); else return serializer.primitive(serviceMetadata, edmPropertyType, property.getProperty(), options); }
@Override public DeserializerResult property(final InputStream input, final EdmProperty edmProperty) throws DeserializerException { try { final XMLEventReader reader = getReader(input); final StartElement start = skipBeforeFirstStartElement(reader); Property property = property(reader, start, edmProperty.getType(), edmProperty.isNullable(), edmProperty.getMaxLength(), edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(), edmProperty.isCollection()); return DeserializerResultImpl.with().property(property) .build(); } catch (XMLStreamException e) { throw new DeserializerException(e.getMessage(), e, DeserializerException.MessageKeys.IO_EXCEPTION); } catch (final EdmPrimitiveTypeException e) { throw new DeserializerException(e.getMessage(), e, DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY); } }
@Override public DeserializerResult property(final InputStream input, final EdmProperty edmProperty) throws DeserializerException { try { final XMLEventReader reader = getReader(input); final StartElement start = skipBeforeFirstStartElement(reader); Property property = property(reader, start, edmProperty.getType(), edmProperty.isNullable(), edmProperty.getMaxLength(), edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(), edmProperty.isCollection()); return DeserializerResultImpl.with().property(property) .build(); } catch (XMLStreamException e) { throw new DeserializerException(e.getMessage(), e, DeserializerException.MessageKeys.IO_EXCEPTION); } catch (final EdmPrimitiveTypeException e) { throw new DeserializerException(e.getMessage(), e, DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY); } }
@Override public void visit(PropertyResponse response) throws ODataLibraryException, ODataApplicationException { EdmProperty edmProperty = request.getUriResourceProperty().getProperty(); if (edmProperty.isPrimitive()) { if(edmProperty.isCollection()) { selectProcessor(PrimitiveCollectionProcessor.class).readPrimitiveCollection( request.getODataRequest(), response.getODataResponse(), request.getUriInfo(), request.getResponseContentType()); } else { selectProcessor(PrimitiveProcessor.class).readPrimitive( request.getODataRequest(), response.getODataResponse(), request.getUriInfo(), request.getResponseContentType()); } } else { if(edmProperty.isCollection()) { selectProcessor(ComplexCollectionProcessor.class).readComplexCollection( request.getODataRequest(), response.getODataResponse(), request.getUriInfo(), request.getResponseContentType()); } else { selectProcessor(ComplexProcessor.class).readComplex( request.getODataRequest(), response.getODataResponse(), request.getUriInfo(), request.getResponseContentType()); } } }
@Override public void visit(PropertyResponse response) throws ODataLibraryException, ODataApplicationException { EdmProperty edmProperty = request.getUriResourceProperty().getProperty(); if (edmProperty.isPrimitive()) { if(edmProperty.isCollection()) { selectProcessor(PrimitiveCollectionProcessor.class).readPrimitiveCollection( request.getODataRequest(), response.getODataResponse(), request.getUriInfo(), request.getResponseContentType()); } else { selectProcessor(PrimitiveProcessor.class).readPrimitive( request.getODataRequest(), response.getODataResponse(), request.getUriInfo(), request.getResponseContentType()); } } else { if(edmProperty.isCollection()) { selectProcessor(ComplexCollectionProcessor.class).readComplexCollection( request.getODataRequest(), response.getODataResponse(), request.getUriInfo(), request.getResponseContentType()); } else { selectProcessor(ComplexProcessor.class).readComplex( request.getODataRequest(), response.getODataResponse(), request.getUriInfo(), request.getResponseContentType()); } } }
static SQLParameter asParam(EdmProperty edmProp, Object value, boolean rawValue) throws TeiidException { String teiidType = ODataTypeManager.teiidType((SingletonPrimitiveType)edmProp.getType(), edmProp.isCollection()); int sqlType = JDBCSQLTypeInfo.getSQLType(teiidType); if (value == null) { return new SQLParameter(null, sqlType); } if (rawValue) { return new SQLParameter(ODataTypeManager.convertByteArrayToTeiidRuntimeType( DataTypeManager.getDataTypeClass(teiidType), (byte[])value, ((SingletonPrimitiveType)edmProp.getType()).getFullQualifiedName().getFullQualifiedNameAsString(), edmProp.getSrid() != null?edmProp.getSrid().toString():null), sqlType); } return new SQLParameter(ODataTypeManager.convertToTeiidRuntimeType( DataTypeManager.getDataTypeClass(teiidType), value, ((SingletonPrimitiveType)edmProp.getType()).getFullQualifiedName().getFullQualifiedNameAsString(), edmProp.getSrid() != null?edmProp.getSrid().toString():null), sqlType); }