Interface EntityProvider.EntityProviderInterface

  • Enclosing class:
    EntityProvider

    public static interface EntityProvider.EntityProviderInterface
    (Internal) interface for all EntityProvider necessary read and write methods for accessing entities defined in an Entity Data Model.

    This interface is declared as inner interface (class) because the EntityProvider provides a convenience access (and basic implementation for XML and JSON format) to all interface methods.
    Hence, it is not recommended to implement this interface (it is possible to implement it and to provide an own EntityProvider for support of additional formats but it is recommended to handle additional formats directly within an ODataProcessor).

    • Method Detail

      • writeMetadata

        ODataResponse writeMetadata​(List<Schema> schemas,
                                    Map<String,​String> predefinedNamespaces)
                             throws EntityProviderException
        Write metadata document in XML format for the given schemas and the provided predefined namespaces at the EDMX element. PredefinedNamespaces is of type Map<prefix,namespace> and may be null or an empty Map.
        Parameters:
        schemas - all XML schemas which will be written
        predefinedNamespaces - type of Map<prefix,namespace> and may be null or an empty Map
        Returns:
        resulting ODataResponse with written metadata content.
        Throws:
        EntityProviderException - if writing of data (serialization) fails
      • writeMetadata

        ODataResponse writeMetadata​(DataServices serviceMetadata,
                                    Map<String,​String> predefinedNamespaces)
                             throws EntityProviderException
        Write metadata document in XML format for the given schemas and the provided predefined namespaces at the EDMX element. PredefinedNamespaces is of type Map<prefix,namespace> and may be null or an empty Map. Important This method takes edmx references into account This method will not calculate the DataServiceVersion but will instead take the version provided via the signature if no version is set the default version 2.0 is used.
        Parameters:
        serviceMetadata - Metadata
        predefinedNamespaces - type of Map<prefix,namespace> and may be null or an empty Map
        Returns:
        resulting ODataResponse with written metadata content.
        Throws:
        EntityProviderException - if writing of data (serialization) fails
      • writeServiceDocument

        ODataResponse writeServiceDocument​(String contentType,
                                           Edm edm,
                                           String serviceRoot)
                                    throws EntityProviderException
        Write service document based on given Edm and service root as given content type.
        Parameters:
        contentType - format in which service document should be written
        edm - entity data model to be written
        serviceRoot - service root for the written service document
        Returns:
        resulting ODataResponse with written service document content.
        Throws:
        EntityProviderException - if writing of data (serialization) fails
      • writePropertyValue

        ODataResponse writePropertyValue​(EdmProperty edmProperty,
                                         Object value)
                                  throws EntityProviderException
        Write property as content type application/octet-stream or text/plain.
        Parameters:
        edmProperty - entity data model for to be written property
        value - property which will be written
        Returns:
        resulting ODataResponse with written property value content.
        Throws:
        EntityProviderException - if writing of data (serialization) fails
      • writeBinary

        ODataResponse writeBinary​(String mimeType,
                                  byte[] data)
                           throws EntityProviderException
        Write binary content with content type header set to given mime type parameter.
        Parameters:
        mimeType - mime type which is written and used as content type header information.
        data - which is written to ODataResponse.
        Returns:
        response object resulting ODataResponse with written binary content.
        Throws:
        EntityProviderException - if writing of data (serialization) fails
      • writeFeed

        ODataResponse writeFeed​(String contentType,
                                EdmEntitySet entitySet,
                                List<Map<String,​Object>> data,
                                EntityProviderWriteProperties properties)
                         throws EntityProviderException
        Write given data (which is given in form of a List with a Map for each entity. Such a Map contains all properties [as property name to property value mapping] for the entry) in the specified format (given as contentType) based on given entity data model for an entity set (given as EdmEntitySet) and properties for this entity provider (given as EntityProviderWriteProperties).
        Parameters:
        contentType - format in which the feed should be written
        entitySet - entity data model for given entity data set
        data - set of entries in form of a List with a Map for each entity (such a Map contains all properties [as property name to property value mapping).
        properties - additional properties necessary for writing of data
        Returns:
        resulting ODataResponse with written feed content.
        Throws:
        EntityProviderException - if writing of data (serialization) fails
      • writeEntry

        ODataResponse writeEntry​(String contentType,
                                 EdmEntitySet entitySet,
                                 Map<String,​Object> data,
                                 EntityProviderWriteProperties properties)
                          throws EntityProviderException
        Write given data (which is given in form of a Map for which contains all properties as property name to property value mapping) for the entry in the specified format (given as contentType) based on entity data model for an entity set (given as EdmEntitySet) and properties for this entity provider (given as EntityProviderWriteProperties).
        Parameters:
        contentType - format in which the entry should be written
        entitySet - entity data model for given entity data set
        data - which contains all properties as property name to property value mapping for the entry
        properties - additional properties necessary for writing of data
        Returns:
        resulting ODataResponse with written entry content
        Throws:
        EntityProviderException - if writing of data (serialization) fails
      • writeProperty

        ODataResponse writeProperty​(String contentType,
                                    EdmProperty edmProperty,
                                    Object value)
                             throws EntityProviderException
        Write given value (which is given in form of an Object) for the property in the specified format (given as contentType) based on given entity data model for an entity property (given as EdmProperty).
        Parameters:
        contentType - format in which the property should be written
        edmProperty - entity data model for given property
        value - data which is written
        Returns:
        resulting ODataResponse with written property content.
        Throws:
        EntityProviderException - if writing of data (serialization) fails
      • writeLink

        ODataResponse writeLink​(String contentType,
                                EdmEntitySet entitySet,
                                Map<String,​Object> data,
                                EntityProviderWriteProperties properties)
                         throws EntityProviderException
        Write link for key property based on entity data model for an entity set (given as EdmEntitySet) in the specified format (given as contentType). The necessary key property values must be provided within the data (in the form of property name to property value mapping) and properties for this entity provider must be set (given as EntityProviderWriteProperties).
        Parameters:
        contentType - format in which the entry should be written
        entitySet - entity data model for given entity data set
        data - which contains all key properties as property name to property value mapping for the entry
        properties - additional properties necessary for writing of data
        Returns:
        resulting ODataResponse with written link content.
        Throws:
        EntityProviderException - if writing of data (serialization) fails
      • writeLinks

        ODataResponse writeLinks​(String contentType,
                                 EdmEntitySet entitySet,
                                 List<Map<String,​Object>> data,
                                 EntityProviderWriteProperties properties)
                          throws EntityProviderException
        Write all links for key property based on entity data model for an entity set (given as EdmEntitySet) in the specified format (given as contentType) for a set of entries. The necessary key property values must be provided within the data (in form of a List with a Map for each entry. Such a Map contains all key properties [as property name to property value mapping] for the entry) and properties for this entity provider must be set (given as EntityProviderWriteProperties).
        Parameters:
        contentType - format in which the entry should be written
        entitySet - entity data model for given entity data set
        data - set of entries in form of a List with a Map for each entry (such a Map contains all key properties [as property name to property value mapping).
        properties - additional properties necessary for writing of data
        Returns:
        resulting ODataResponse with written links content.
        Throws:
        EntityProviderException - if writing of data (serialization) fails
      • readProperty

        Map<String,​Object> readProperty​(String contentType,
                                              EdmProperty edmProperty,
                                              InputStream content,
                                              EntityProviderReadProperties properties)
                                       throws EntityProviderException
        Read (de-serialize) properties from content (as InputStream) in specified format (given as contentType) based on entity data model (given as EdmProperty) and provide this data as Map which contains the read data in form of property name to property value mapping.
        Parameters:
        contentType - format of content in the given input stream.
        edmProperty - entity data model for entity property to be read
        content - data in form of an InputStream which contains the data in specified format
        properties - additional properties necessary for reading content from InputStream into Map.
        Returns:
        property as name and value in a map
        Throws:
        EntityProviderException - if reading of data (de-serialization) fails
      • readPropertyValue

        Object readPropertyValue​(EdmProperty edmProperty,
                                 InputStream content,
                                 Class<?> typeMapping)
                          throws EntityProviderException
        Read (de-serialize) a property value from content (as InputStream) in format text/plain based on entity data model (given as EdmProperty) and provide this data as Object.
        Parameters:
        edmProperty - entity data model for entity property to be read
        content - data in form of an InputStream which contains the data in format text/plain
        typeMapping - defines the mapping for this edm property to a java class which should be used during read of the content. If according edm property can not be read into given java class an EntityProviderException is thrown. Supported mappings are documented in EdmSimpleType.
        Returns:
        property value as object
        Throws:
        EntityProviderException - if reading of data (de-serialization) fails
      • readLink

        String readLink​(String contentType,
                        EdmEntitySet entitySet,
                        InputStream content)
                 throws EntityProviderException
        Read (de-serialize) a link from content (as InputStream) in specified format (given as contentType) based on entity data model (given as EdmEntitySet) and provide the link as String.
        Parameters:
        contentType - format of content in the given input stream.
        entitySet - entity data model for entity property to be read
        content - data in form of an InputStream which contains the data in specified format
        Returns:
        link as string
        Throws:
        EntityProviderException - if reading of data (de-serialization) fails
      • readLinks

        List<String> readLinks​(String contentType,
                               EdmEntitySet entitySet,
                               InputStream content)
                        throws EntityProviderException
        Read (de-serialize) all links from content (as InputStream) in specified format (given as contentType) based on entity data model (given as EdmEntitySet) and provide the link as List of Strings.
        Parameters:
        contentType - format of content in the given input stream.
        entitySet - entity data model for entity property to be read
        content - data in form of an InputStream which contains the data in specified format
        Returns:
        links as List of Strings
        Throws:
        EntityProviderException - if reading of data (de-serialization) fails
      • readMetadata

        Edm readMetadata​(InputStream inputStream,
                         boolean validate)
                  throws EntityProviderException
        Read (de-serialize) data from metadata inputStream (as InputStream) and provide Edm as Edm
        Parameters:
        inputStream - the given input stream
        validate - has to be true if metadata should be validated
        Returns:
        Edm as Edm
        Throws:
        EntityProviderException - if reading of data (de-serialization) fails
      • writeBatchRequest

        InputStream writeBatchRequest​(List<BatchPart> batchParts,
                                      String boundary)
        Create Batch Request body as InputStream.
        Parameters:
        batchParts - a list of BatchPartRequests BatchPart
        boundary - Boundary
        Returns:
        Batch Request as InputStream