public class OfflineODataProvider extends java.lang.Object implements DataServiceProvider
For internal use only.
Constructor and Description |
---|
OfflineODataProvider(OnlineODataProvider onlineProvider)
|
OfflineODataProvider(OnlineODataProvider onlineProvider,
SQLDatabaseProvider offlineStore) |
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.
|
void |
download()
See download(StringList).
|
void |
download(StringList groups)
Download backend data changes into the local offline store.
|
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
OfflineODataProvider.metadata property. |
DataTransaction |
getDataTransaction()
Return the current server transaction.
|
PendingRequestList |
getFailedRequests()
|
PendingRequestList |
getFailedRequests(DataQuery query) |
CsdlDocument |
getMetadata()
Return service metadata.
|
SQLDatabaseProvider |
getOfflineStore() |
OnlineODataProvider |
getOnlineProvider() |
boolean |
getPrettyTracing()
Return should
OfflineODataProvider.traceWithData show pretty-printed JSON/XML content? Defaults to false . |
PendingRequestList |
getQueuedRequests()
|
PendingRequestList |
getQueuedRequests(DataQuery query) |
java.lang.String |
getServiceName()
Return service name.
|
ServiceOptions |
getServiceOptions() |
StorageOptions |
getStorageOptions() |
boolean |
getTraceRequests() |
boolean |
getTraceWithData() |
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 |
open() |
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 |
setPrettyTracing(boolean value)
Set should
OfflineODataProvider.traceWithData show pretty-printed JSON/XML content? Defaults to false . |
void |
setTraceRequests(boolean value) |
void |
setTraceWithData(boolean value) |
void |
synchronize()
Call
OfflineODataProvider.upload followed by OfflineODataProvider.download . |
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 |
upload()
Upload data changes for all uploadable entity sets.
|
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.
|
public OfflineODataProvider(OnlineODataProvider onlineProvider)
onlineProvider
- OnlineProvider parameter.public OfflineODataProvider(OnlineODataProvider onlineProvider, SQLDatabaseProvider offlineStore)
public void beginTransaction()
Begin a server transaction.
beginTransaction
in interface DataServiceProvider
public void commit()
Commit the current server transaction.
commit
in interface DataServiceProvider
public 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 DataServiceProvider
entity
- 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 DataServiceProvider
from
- 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 DataServiceProvider
entity
- 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 DataServiceProvider
query
- 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 DataServiceProvider
entity
- 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 DataServiceProvider
from
- 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 DataServiceProvider
entity
- 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 void download()
public void download(StringList groups)
Download backend data changes into the local offline store.
groups
- If empty, then download from all entity sets. If non-empty, then it specifies groups to be included.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 DataServiceProvider
entity
- 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 DataServiceProvider
entity
- 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 DataServiceProvider
entitySet
- 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 DataServiceProvider
method
- 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 DataServiceProvider
query
- 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 OfflineODataProvider.metadata
property.
fetchMetadata
in interface DataServiceProvider
headers
- Optional request-specific headers.options
- Optional request-specific options.public DataTransaction getDataTransaction()
Return the current server transaction.
getDataTransaction
in interface DataServiceProvider
public PendingRequestList getFailedRequests()
public PendingRequestList getFailedRequests(DataQuery query)
public CsdlDocument getMetadata()
Return service metadata.
getMetadata
in interface DataServiceProvider
public SQLDatabaseProvider getOfflineStore()
public OnlineODataProvider getOnlineProvider()
public boolean getPrettyTracing()
Return should OfflineODataProvider.traceWithData
show pretty-printed JSON/XML content? Defaults to false
.
OfflineODataProvider.traceWithData
show pretty-printed JSON/XML content? Defaults to false
.public PendingRequestList getQueuedRequests()
public PendingRequestList getQueuedRequests(DataQuery query)
public java.lang.String getServiceName()
Return service name.
getServiceName
in interface DataServiceProvider
public ServiceOptions getServiceOptions()
public StorageOptions getStorageOptions()
public boolean getTraceRequests()
public boolean getTraceWithData()
public boolean hasMetadata()
Return has service metadata been loaded.
hasMetadata
in interface DataServiceProvider
public void loadMetadata(HttpHeaders headers, RequestOptions options)
Load service metadata (if not already loaded).
loadMetadata
in interface DataServiceProvider
headers
- 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 DataServiceProvider
format
- Metadata format. Only XML is presently supported.public void open()
public void pingServer(HttpHeaders headers, RequestOptions options)
Ping the server.
pingServer
in interface DataServiceProvider
headers
- 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 DataServiceProvider
batch
- 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 DataServiceProvider
version
- Data version.public void rollback()
Rollback the current server transaction.
rollback
in interface DataServiceProvider
public java.lang.String serviceDocument(int format)
Return the service document, in XML or JSON format.
serviceDocument
in interface DataServiceProvider
format
- Data format (XML or JSON).public void setMetadata(CsdlDocument value)
Set service metadata.
setMetadata
in interface DataServiceProvider
value
- Service metadata.public void setPrettyTracing(boolean value)
Set should OfflineODataProvider.traceWithData
show pretty-printed JSON/XML content? Defaults to false
.
value
- Should OfflineODataProvider.traceWithData
show pretty-printed JSON/XML content? Defaults to false
.public void setTraceRequests(boolean value)
public void setTraceWithData(boolean value)
public void synchronize()
Call OfflineODataProvider.upload
followed by OfflineODataProvider.download
.
public void unloadMetadata()
Unload service metadata (if previously loaded).
unloadMetadata
in interface DataServiceProvider
public void updateEntity(EntityValue entity, HttpHeaders headers, RequestOptions options)
Update an entity in the target system.
updateEntity
in interface DataServiceProvider
entity
- 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 DataServiceProvider
from
- 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 upload()
Upload data changes for all uploadable entity sets.
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 DataServiceProvider
entity
- 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 DataServiceProvider
entity
- 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.