public class JsonEntityProvider extends java.lang.Object implements DataServiceProvider
For internal use only.
| Modifier and Type | Method and Description |
|---|---|
void |
beginTransaction()
Begin a server transaction.
|
void |
commit()
Commit the current server transaction.
|
void |
createEntity(EntityValue entity,
HttpHeaders headers,
RequestOptions options)
Create an entity in the target system.
|
void |
createLink(EntityValue from,
Property property,
EntityValue to,
HttpHeaders headers,
RequestOptions options)
Create a link from a source entity to a target entity.
|
void |
createMedia(EntityValue entity,
StreamBase content,
HttpHeaders headers,
RequestOptions options)
Create a media entity with the specified content in the target system.
|
void |
deleteByQuery(DataQuery query,
HttpHeaders headers,
RequestOptions options)
Execute query to delete data from the target system.
|
void |
deleteEntity(EntityValue entity,
HttpHeaders headers,
RequestOptions options)
Delete an entity from the target system.
|
void |
deleteLink(EntityValue from,
Property property,
EntityValue to,
HttpHeaders headers,
RequestOptions options)
Delete a link from a source entity to a target entity.
|
void |
deleteStream(EntityValue entity,
StreamLink link,
HttpHeaders headers,
RequestOptions options)
Delete the content of a stream property from the target system.
|
ByteStream |
downloadMedia(EntityValue entity,
HttpHeaders headers,
RequestOptions options)
Obtain a stream for downloading the content of a media entity from the target system.
|
ByteStream |
downloadStream(EntityValue entity,
StreamLink link,
HttpHeaders headers,
RequestOptions options)
Obtain a stream for downloading the content of a stream property from the target system.
|
DataContext |
entityContext(EntitySet entitySet,
StructureType derivedType,
int format,
int version)
Return a data context for a specified entity set, data format and data version.
|
DataValue |
executeMethod(DataMethod method,
ParameterList parameters,
HttpHeaders headers,
RequestOptions options)
Execute a data method (action or function) in the target system.
|
QueryResult |
executeQuery(DataQuery query,
HttpHeaders headers,
RequestOptions options)
Execute a data query to get data from the target system.
|
CsdlDocument |
fetchMetadata(HttpHeaders headers,
RequestOptions options)
Fetch latest service metadata and return it, but don't change the
JsonEntityProvider.metadata property. |
DataTransaction |
getDataTransaction()
Return the current server transaction.
|
CsdlDocument |
getMetadata()
Return service metadata.
|
java.lang.String |
getServiceName()
Return service name.
|
boolean |
hasMetadata()
Return has service metadata been loaded.
|
void |
loadMetadata(HttpHeaders headers,
RequestOptions options)
Load service metadata (if not already loaded).
|
java.lang.String |
metadataText(int format)
Return metadata document text of the service.
|
void |
pingServer(HttpHeaders headers,
RequestOptions options)
Ping the server.
|
void |
processBatch(RequestBatch batch,
HttpHeaders headers,
RequestOptions options)
Execute a request batch in the target system.
|
DataContext |
queryContext(int version)
Return a data context for parsing a data query.
|
void |
rollback()
Rollback the current server transaction.
|
java.lang.String |
serviceDocument(int format)
Return the service document, in XML or JSON format.
|
void |
setMetadata(CsdlDocument value)
Set service metadata.
|
void |
unloadMetadata()
Unload service metadata (if previously loaded).
|
void |
updateEntity(EntityValue entity,
HttpHeaders headers,
RequestOptions options)
Update an entity in the target system.
|
void |
updateLink(EntityValue from,
Property property,
EntityValue to,
HttpHeaders headers,
RequestOptions options)
Update a link from a source entity to a target entity.
|
void |
uploadMedia(EntityValue entity,
StreamBase content,
HttpHeaders headers,
RequestOptions options)
Upload content for a media entity to the target system
Caution: Having too many threads simultaneously uploading streams
may result in out-of-memory conditions on memory-constrained devices.
|
void |
uploadStream(EntityValue entity,
StreamLink link,
StreamBase content,
HttpHeaders headers,
RequestOptions options)
Upload content for a stream property to the target system.
|
static JsonEntityProvider |
withMetadata(CsdlDocument metadata)
Return a new provider that wraps
metadata. |
static JsonEntityProvider |
withProvider(DataServiceProvider provider)
Return a new provider that wraps
provider. |
public void beginTransaction()
Begin a server transaction.
beginTransaction in interface DataServiceProviderpublic void commit()
Commit the current server transaction.
commit in interface DataServiceProviderpublic void createEntity(EntityValue entity, HttpHeaders headers, RequestOptions options)
Create an entity in the target system.
Automatically calls CsdlDocument.resolveEntity to ensure that EntityValue.entitySet is available.
DataServiceException if the entity set hasn't been explicitly provided before calling createEntity and there isn't a unique entity set for the entity type.
createEntity in interface DataServiceProviderentity - Entity to be created.headers - Request-specific headers.options - Request-specific options.public void createLink(EntityValue from, Property property, EntityValue to, HttpHeaders headers, RequestOptions options)
Create a link from a source entity to a target entity.
createLink in interface DataServiceProviderfrom - Source entity for the link to be created.property - Source navigation property for the link to be created.to - Target entity for the link to be created.headers - Request-specific headers.options - Request-specific options.public void createMedia(EntityValue entity, StreamBase content, HttpHeaders headers, RequestOptions options)
Create a media entity with the specified content in the target system.
If the entity has non-stream structural properties in addition to the key properties and media content, such as label in the examples below,
then this function will send two requests to the server: a first request to upload (POST) the media stream,
and a second request (PATCH/PUT) to update the non-stream properties. It is not currently supported to make these two calls atomic.
Caution: Having too many threads simultaneously creating streams
may result in out-of-memory conditions on memory-constrained devices.
createMedia in interface DataServiceProviderentity - Entity to be created.content - Initial content. Must be a ByteStream or CharStream. Will be closed before this function returns.headers - Request-specific headers.options - Request-specific options.public void deleteByQuery(DataQuery query, HttpHeaders headers, RequestOptions options)
Execute query to delete data from the target system.
deleteByQuery in interface DataServiceProviderquery - Data query specifying the information to be deleted.headers - Request-specific headers.options - Request-specific options.public void deleteEntity(EntityValue entity, HttpHeaders headers, RequestOptions options)
Delete an entity from the target system.
deleteEntity in interface DataServiceProviderentity - Entity to be deleted.headers - Request-specific headers.options - Request-specific options.public void deleteLink(EntityValue from, Property property, EntityValue to, HttpHeaders headers, RequestOptions options)
Delete a link from a source entity to a target entity.
deleteLink in interface DataServiceProviderfrom - Source entity for the link to be deleted.property - Source navigation property for the link to be deleted.to - Target entity for the link to be deleted.headers - Request-specific headers.options - Request-specific options.public void deleteStream(EntityValue entity, StreamLink link, HttpHeaders headers, RequestOptions options)
Delete the content of a stream property from the target system.
deleteStream in interface DataServiceProviderentity - Entity containing the stream property whose content is to be deleted.headers - Request-specific headers.options - Request-specific options.link - Stream link for the stream to be deleted.public ByteStream downloadMedia(EntityValue entity, HttpHeaders headers, RequestOptions options)
Obtain a stream for downloading the content of a media entity from the target system.
Caution: streams are often used for large content that may not fit (all at once) in available application memory.
Having too many threads simultaneously downloading streams, or using ByteStream.readAndClose,
may result in out-of-memory conditions on memory-constrained devices.
downloadMedia in interface DataServiceProviderentity - Entity whose content is to be downloaded.headers - Request-specific headers.options - Request-specific options.public ByteStream downloadStream(EntityValue entity, StreamLink link, HttpHeaders headers, RequestOptions options)
Obtain a stream for downloading the content of a stream property from the target system.
Caution: streams are often used for large content that may not fit (all at once) in available application memory.
Having too many threads simultaneously downloading streams, or using ByteStream.readAndClose,
may result in out-of-memory conditions on memory-constrained devices.
downloadStream in interface DataServiceProviderentity - Entity containing the stream property whose content is to be downloaded.link - Stream link for the stream to be downloaded.headers - Request-specific headers.options - Request-specific options.public DataContext entityContext(EntitySet entitySet, StructureType derivedType, int format, int version)
Return a data context for a specified entity set, data format and data version.
entityContext in interface DataServiceProviderentitySet - Entity set for entity value to be parsed or formatted.derivedType - (nullable) Derived type for query results.format - Data format.version - Data version.public DataValue executeMethod(DataMethod method, ParameterList parameters, HttpHeaders headers, RequestOptions options)
Execute a data method (action or function) in the target system. Actions may have backend side-effects. Functions should not have backend side-effects.
DataServiceException or DataNetworkException if an error occurs during action invocation.
executeMethod in interface DataServiceProvidermethod - Data method.parameters - Method parameters.headers - Request-specific headers.options - Request-specific options.public QueryResult executeQuery(DataQuery query, HttpHeaders headers, RequestOptions options)
Execute a data query to get data from the target system.
executeQuery in interface DataServiceProviderquery - Data query specifying the information to be returned.headers - Request-specific headers.options - Request-specific options.public CsdlDocument fetchMetadata(HttpHeaders headers, RequestOptions options)
Fetch latest service metadata and return it, but don't change the JsonEntityProvider.metadata property.
fetchMetadata in interface DataServiceProviderheaders - Optional request-specific headers.options - Optional request-specific options.public DataTransaction getDataTransaction()
Return the current server transaction.
getDataTransaction in interface DataServiceProviderpublic CsdlDocument getMetadata()
Return service metadata.
getMetadata in interface DataServiceProviderpublic java.lang.String getServiceName()
Return service name.
getServiceName in interface DataServiceProviderpublic boolean hasMetadata()
Return has service metadata been loaded.
hasMetadata in interface DataServiceProviderpublic void loadMetadata(HttpHeaders headers, RequestOptions options)
Load service metadata (if not already loaded).
loadMetadata in interface DataServiceProviderheaders - Optional request-specific headers.options - Optional request-specific options.public java.lang.String metadataText(int format)
Return metadata document text of the service.
metadataText in interface DataServiceProviderformat - Metadata format. Only XML is presently supported.public void pingServer(HttpHeaders headers, RequestOptions options)
Ping the server.
pingServer in interface DataServiceProviderheaders - Optional request-specific headers.options - Optional request-specific options.public void processBatch(RequestBatch batch, HttpHeaders headers, RequestOptions options)
Execute a request batch in the target system.
processBatch in interface DataServiceProviderbatch - The request batch.headers - Request-specific headers.options - Request-specific options.public DataContext queryContext(int version)
Return a data context for parsing a data query.
queryContext in interface DataServiceProviderversion - Data version.public void rollback()
Rollback the current server transaction.
rollback in interface DataServiceProviderpublic java.lang.String serviceDocument(int format)
Return the service document, in XML or JSON format.
serviceDocument in interface DataServiceProviderformat - Data format (XML or JSON).public void setMetadata(CsdlDocument value)
Set service metadata.
setMetadata in interface DataServiceProvidervalue - Service metadata.public void unloadMetadata()
Unload service metadata (if previously loaded).
unloadMetadata in interface DataServiceProviderpublic void updateEntity(EntityValue entity, HttpHeaders headers, RequestOptions options)
Update an entity in the target system.
updateEntity in interface DataServiceProviderentity - Entity to be updated.headers - Request-specific headers.options - Request-specific options.public void updateLink(EntityValue from, Property property, EntityValue to, HttpHeaders headers, RequestOptions options)
Update a link from a source entity to a target entity.
updateLink in interface DataServiceProviderfrom - Source entity for the link to be updated.property - Source navigation property for the link to be updated. This must be a one-to-one navigation property.to - Target entity for the link to be updated.headers - Request-specific headers.options - Request-specific options.public void uploadMedia(EntityValue entity, StreamBase content, HttpHeaders headers, RequestOptions options)
Upload content for a media entity to the target system
Caution: Having too many threads simultaneously uploading streams
may result in out-of-memory conditions on memory-constrained devices.
Note: this function cannot be used to create a media entity. See DataService.createMedia.
uploadMedia in interface DataServiceProviderentity - Entity whose content is to be uploaded.content - Upload stream content. Will be closed before this function returns.headers - Request-specific headers.options - Request-specific options.public void uploadStream(EntityValue entity, StreamLink link, StreamBase content, HttpHeaders headers, RequestOptions options)
Upload content for a stream property to the target system. Caution: Having too many threads simultaneously uploading streams may result in out-of-memory conditions on memory-constrained devices.
uploadStream in interface DataServiceProviderentity - Entity containing the stream property whose content is to be uploaded.link - Stream link for the stream to be uploaded.content - Upload stream content. Will be closed before this function returns.headers - Request-specific headers.options - Request-specific options.public static JsonEntityProvider withMetadata(CsdlDocument metadata)
Return a new provider that wraps metadata.
metadata - Service metadata.metadata.public static JsonEntityProvider withProvider(DataServiceProvider provider)
Return a new provider that wraps provider.
provider - Service provider.provider.