Constructor
new OfflineStore()
Members
(static, readonly) Notification :number
Offline OData store notifications.
Notifications are hints to the application about the current state of the Offline Store.
They indicate that either a refresh or flush operation was previously interrupted and
may be recovered if performed again.
Type:
- number
Properties:
Name | Type | Description |
---|---|---|
PENDING_REFRESH |
number | The store was closed while performing a refresh. It may be possible to continue the pending refresh by triggering a new refresh. |
PENDING_FLUSH |
number | The store was closed while flushing the request queue. It may be possible to continue the pending flush by triggering a new flush. |
(static, readonly) ProgressState :number
Offline OData store progress states.
Type:
- number
Properties:
Name | Type | Description |
---|---|---|
STORE_DOWNLOADING |
number | Downloading offline store. |
REFRESH |
number | Refreshing offline store. |
FLUSH_REQUEST_QUEUE |
number | Flushing request queue. |
DONE |
number | Opening, Refreshing, FlusingRequestQueue progress is completed. |
(static, readonly) State :number
Offline OData store opening states.
These states represent the major activities during initialization and opening of the Offline Store.
Type:
- number
Properties:
Name | Type | Description |
---|---|---|
OPENING |
number | The store has started to open |
INITIALIZING |
number | Initializing the resources for a new store. Not applicable on Windows |
POPULATING |
number | Populating the store. |
DOWNLOADING |
number | Downloading the store. |
OPEN |
number | The store has opened successfully |
CLOSED |
number | The store has been closed by the user while opening |
(readonly) customCookies :Object
Object that contains the cookies to send as name value pairs.
Type:
- Object
(readonly) customHeaders :Object
Object that contains the headers to send as name value pairs.
Type:
- Object
(readonly) definingRequests :Object
Object that contains the coverage of data as name value pairs. The names are arbitrary and used when performing
refreshes with subsets. The values are OData URLs represent the coverage of data to be managed by the store.
Type:
- Object
(readonly) enableRepeatableRequests :Boolean
If the OData Producer is able to support repeatable requests then enable use of this.
Type:
- Boolean
(readonly) host :String
The host of the server.
Type:
- String
(readonly) https :Boolean
Whether to use HTTP or HTTPS. Default is HTTP.
Type:
- Boolean
(readonly) name :String
The unique name of the store.
Type:
- String
offlineServiceRoot
Offline service root that can be used for media entry create requests.
This property will be set after the store has been opened.
Example
// !! Assumes media_file exists as a file input element in the DOM.
var file = document.getElementById("media_file").files[0];
var xhr = new XMLHttpRequest();
// Third paramenter (async) must always be true.
xhr.open("POST", store.offlineServiceRoot + "Drivers", true);
xhr.setRequestHeader("Accept", "application/json");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 201) {
console.log("Media Created");
} else {
console.log("Failed to create media");
}
}
}
xhr.send(file);
onnotification
Called once for each notification that is available while opening the store.
onrequesterror :OfflineStore~requesterror
Called when a modification request fails against the OData producer.
This can be called multiple times during a single flush if there is a bunch of pending modifications.
Type:
- OfflineStore~requesterror
Example
store.onrequesterror = function(error) {
console.log("Error occurred while sending modification to server. " + error);
};
onstatechanged
Called whenever the store state changes during the initialization and opening of the Offline Store.
(readonly) pageSize :Number
Specifies the maximum number of entities that can be returned in a single read request.
Type:
- Number
(readonly) port :Number
The port of the server.
Type:
- Number
(readonly) serviceRoot :String
Identifies the root of an OData service. This can be relative to the host and should be set to a backend connection name from the server.
Type:
- String
storePath
The file system path to store the local data store.
If omitted a default location will be chosen.
To place the store on the SDCard for Android, add the Cordova file plugin and set the value for this property to `cordova.file.externalRootDirectory`.
The output from the toURL method on the DirectoryEntry object from the Cordova file plugin is a valid value.
(readonly) streamParams :String
Any additional stream parameters.
Type:
- String
(readonly) urlSuffix :String
The URL suffix path to the server
Type:
- String
Methods
clear(success, error)
Removes the physical store from the filesystem. The store must be closed before clearing.
Parameters:
Name | Type | Description |
---|---|---|
success |
sap.OfflineStore~success | Called when store is successfully cleared. |
error |
sap.OfflineStore~error | Called if store cannot be cleared. |
close(success, error)
Closes the store and releases its resources.
Closing the store will attempt to interrupt any operation already occurring against
this store, and will block until the other operations have finished.
Parameters:
Name | Type | Description |
---|---|---|
success |
sap.OfflineStore~success | Called when store successfully closes. |
error |
sap.OfflineStore~error | Called when store fails to close. |
flush(success, error, progressopt)
Starts sending pending modification requests to the server.
The application must have network connectivity to perform this operation.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
success |
sap.OfflineStore~success | Called when flush has finished. | |
error |
sap.OfflineStore~error | Called if error calling flush. | |
progress |
sap.OfflineStore~progress |
<optional> |
Called every time when there is an update while the store is being flushed. |
getRequestQueueStatus(success, error)
Returns whether or not the there are any pending requests stored in the request queue that have
not yet been flushed.
Parameters:
Name | Type | Description |
---|---|---|
success |
sap.OfflineStore~successQueueStatus | Called with the status of the request queue. |
error |
sap.OfflineStore~error | Called if there was an issue determining queue state. |
open(success, error, optionsopt, progressopt)
Opens the store.
The store will be available for offline access only after it is open successfully.
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
success |
sap.OfflineStore~success | Called when store successfully opens. | |||||||||
error |
sap.OfflineStore~error | Called when store fails to open. | |||||||||
options |
Object |
<optional> |
Options used when opening the store object
Properties
|
||||||||
progress |
sap.OfflineStore~progress |
<optional> |
Called every time when there is an update while the store is being opened. |
refresh(success, error, subsetopt, progressopt)
Refreshes the store with the OData service.
The application must have network connectivity to perform this operation.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
success |
sap.OfflineStore~success | Called when store is successfully refreshed. | |
error |
sap.OfflineStore~error | Called if store fails to refresh itself. | |
subset |
Array |
<optional> |
List of the names of the defining requests to refresh. |
progress |
sap.OfflineStore~progress |
<optional> |
Called every time when there is an update while the store is being refreshed. |
registerStreamRequest(name, resourcePath, success, error)
Registers a request to download an individual media stream.
The registered request must be the read link of the media entity (not the media stream).
You must refresh the store for the stream to be downloaded. To download just the stream
call refresh with the subset parameter set to the name you registered the stream with.
Parameters:
Name | Type | Description |
---|---|---|
name |
an arbitrary and unique name associated with the defining request. | |
resourcePath |
the path to the media entity | |
success |
sap.OfflineStore~success | Called when registration is successful. |
error |
sap.OfflineStore~error | Called if registraion fails. |
unregisterStreamRequest(name, success, error)
Unregisters a previously registered stream request
Parameters:
Name | Type | Description |
---|---|---|
name |
The name of the request to unregister | |
success |
sap.OfflineStore~success | Called when unregistration is successful. |
error |
sap.OfflineStore~error | Called if unregistraion fails. |
Type Definitions
error(error)
Offline store error callback.
Parameters:
Name | Type | Description |
---|---|---|
error |
String | The error message. |
progress(progressStatus)
Offline store progress callback.
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
progressStatus |
Object | This progress status contains updates from Offline Store during opening, refresh and flush request queue.
Properties
|
requesterror(error)
Offline store flush error callback.
Parameters:
Name | Type | Description |
---|---|---|
error |
String | The error message. |
success()
Offline store success callback.
successQueueStatus(statusopt)
Offline store queue status success callback.
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
status |
Object |
<optional> |
Status for the request queue.
Properties
|