OfflineODataProvider
open class OfflineODataProvider : DataServiceProvider, @unchecked Sendable
A data service provider for Offline OData.
-
- Offline OData’s DataSyncProvider implementation. See definition in DataSyncProvider. Below sample code intializes an OfflineDataService instance with this property:
let offlineProvider = OfflineODataProvider() let offlineService = OfflineDataService(provider: offlineProvider.syncProvider)See also
OfflineDataService.init(provider:)Declaration
Swift
open var syncProvider: DataSyncProvider { get } -
- This is a reference to the OfflineODataParameters given when the provider is created
- In the next upload/download. All the backend http request will update accordingly.
- Only customHeaders and customCookies can be changed after the provider is open.
- Below sample code can be used to change the custom header/cookie value after the provider is initiated.
provider.providerParameters.customHeaders["runtimeheader"] = "runtimeHeadervalue" provider.providerParameters.customCookies["runtimecookie"] = "runtimecookievalue”Declaration
Swift
public var providerParameters: OfflineODataParameters { get } -
OfflineODataProvider service options.
Declaration
Swift
public var serviceOptions: OfflineODataServiceOptions -
The version of the Offline OData library.
Declaration
Swift
public static var libraryVersion: String { get } -
used for internal testing
Declaration
Swift
open var store: StoreWrapper { get } -
Initializes an OfflineODataProvider.
Throws
OfflineODataError.invalidInputif an invalid input error occurs initializing the OfflineODataProvider.Possible error name could be:OfflineODataErrorName.serviceRootNotAbsolute,OfflineODataErrorName.invalidPageSizeScp,OfflineODataErrorName.invalidStorePathScp,OfflineODataErrorName.failToGenerateDefaultEncryptionKey, etc.Throws
OfflineODataError.communicationErrorif an invalid input error occurs initializing.Possible error name could be:OfflineODataErrorName.serviceRootNotAbsoluteDeclaration
Swift
@available(swift, deprecated: 5.1, message: "OfflineODataDelegate will be replaced by OfflineODataProviderDelegate.") public init(serviceRoot: URL, parameters: OfflineODataParameters, sapURLSession: SAPURLSession, delegate: OfflineODataDelegate) throwsParameters
serviceRootThe service root of the OData backend. This value depends on the “Rewrite Mode” configuration of the application in SAP Mobile Services. If Rewrite Mode is set to “Rewrite URL” then the path of the service root is the Application Connection Name. If Rewrite Mode is set to “Rewrite URL on Back End” then the path or the service root should be the same as the path of the Back-End URL specified in the SAP Mobile Services.
For example, if the SAP Mobile Services being used is at https://sapcpms/, the application is configured with an Application Connection Name of “myconn” to an OData backend with service root “http://myhost:80/odata/endpoint” then serviceRoot should be “https://sapcpms/myconn/” for “Rewrite URL” and “https://sapcpms/odata/endpoint” for “Rewrite URL on Back End”.
parametersThe configuration parameters for the OfflineODataProvider.
sapURLSessionThe SAPURLSession to handle network authentication.
delegateThe methods of this delegate are called at various stages during the execution of open, download, and upload.
Return Value
Instance of OfflineODataProvider.
-
Initializes an OfflineODataProvider.
Throws
OfflineODataError.invalidInputif an invalid input error occurs initializing the OfflineODataProvider. Possible error name could be:OfflineODataErrorName.serviceRootNotAbsolute,OfflineODataErrorName.invalidPageSizeScp,OfflineODataErrorName.invalidStorePathScp,OfflineODataErrorName.failToGenerateDefaultEncryptionKey, etc.Declaration
Swift
public init(serviceRoot: URL, parameters: OfflineODataParameters, sapURLSession: SAPURLSession, delegate: OfflineODataProviderDelegate? = nil) throwsParameters
serviceRootThe service root of the OData backend. This value depends on the “Rewrite Mode” configuration of the application in SAP Mobile Services. If Rewrite Mode is set to “Rewrite URL” then the path of the service root is the Application Connection Name. If Rewrite Mode is set to “Rewrite URL on Back End” then the path or the service root should be the same as the path of the Back-End URL specified in the SAP Mobile Services.
For example, if the SAP Mobile Services being used is at https://sapcpms/, the application is configured with an Application Connection Name of “myconn” to an OData backend with service root “http://myhost:80/odata/endpoint” then serviceRoot should be “https://sapcpms/myconn/” for “Rewrite URL” and “https://sapcpms/odata/endpoint” for “Rewrite URL on Back End”.
parametersThe configuration parameters for the OfflineODataProvider.
sapURLSessionThe SAPURLSession to handle network authentication.
delegateThe methods of this delegate are called at various stages during the execution of open, download, upload, and sendStore.
Return Value
Instance of OfflineODataProvider.
-
The name of the Offline OData store.
Declaration
Swift
open var serviceName: String { get } -
The name of the Offline OData store.
Declaration
Swift
open var serviceName_NS: NSString { get } -
Whether or not the provider has metadata.
Declaration
Swift
open var hasMetadata: Bool { get } -
Metadata of the service. See CSDLDocument.
Declaration
Swift
open var metadata: CSDLDocument { get set } -
Logger of the provider. App developers can configure log level on the logger and control what level of information will be logged.
See SAPCommon.Logger.
Declaration
Swift
public var logger: SAPCommon.Logger { get set } -
Deletes the physical store from the file system. All instances of the OfflineODataProvider must be closed before the physical store can be deleted.
Throws
OfflineODataError.clientInternalErrorif an internal error occurs deleting the store. Possible error name could be:OfflineODataErrorName.dropDbInUse,OfflineODataErrorName.dropDbNotFound,OfflineODataErrorName.couldNotDropDb, etc.Declaration
Swift
public static func clear(at path: URL?, withName name: String?) throwsParameters
pathThe file system path of the local data store.
nameThe name of the store.
-
Deletes the physical store from the file system. This method will close the OfflineODataProvider before attempting to delete the physical store. Note that, this will also clear any information about the defining queries. Therefore, before opening again, any defining queries required for the initial download will need to be respecified.
Throws
OfflineODataError.clientInternalErrorif an internal error occurs closing or deleting the store. Possible error name could be:OfflineODataErrorName.dropDbInUse,OfflineODataErrorName.dropDbNotFound,OfflineODataErrorName.couldNotDropDb, etc.Declaration
Swift
public func clear() throws -
Closes the OfflineODataProvider, freeing any resources. If a download or upload is active, it will be cancelled (it may be resumable after the provider is re-opened).
Throws
OfflineODataError.clientInternalErrorif an error occurs closing the OfflineODataProvider. Possible error name could be:OfflineODataErrorName.fatalInternalError.Declaration
Swift
public func close() throws -
Checks whether or not the there are any pending requests stored in the request queue that have not yet been uploaded.
Throws
OfflineODataError.clientInternalErrorif an internal error occurs determining whether the request queue is empty. Possible error name could be:OfflineODataErrorName.fatalInternalError,OfflineODataErrorName.errorExecutingSqlStmt,OfflineODataErrorName.errorInitializingStore.Declaration
Swift
public func requestQueueIsEmpty() throws -> BoolReturn Value
true if the request queue is empty and false otherwise.
-
Checks whether or not the index of the specified table is valid. The api is only used for debugging when UL DB index is not valid
Throws
OfflineODataError.clientInternalErrorif an internal error occurs determining whether the index is valid. Possible error name could be:OfflineODataErrorName.fatalInternalError,OfflineODataErrorName.storeNotOpenDeclaration
Swift
public func isTableIndexValid(tableName name: String) throws -> BoolReturn Value
true if the index is valid and false otherwise.
-
Checks whether or not there is a pending download.
Throws
OfflineODataError.clientInternalErrorif an internal error occurs determining whether or not there is a pending download. Possible error name could be:OfflineODataErrorName.fatalInternalError,OfflineODataErrorName.errorExecutingSqlStmt,OfflineODataErrorName.errorInitializingStore.Throws
OfflineODataError.preconditionFailedif precondition failure occurs determining whether or not there is a pending download. Possible error name could be:OfflineODataErrorName.storeNotOpen.Declaration
Swift
public func hasPendingDownload() throws -> BoolReturn Value
Whether or not there is a pending download (a download that was cancelled either explicitly or because the provider was closed). It may be possible to continue the download by triggering a new download.
-
Checks whether or not there is a pending upload.
Throws
OfflineODataError.clientInternalErrorif an internal error occurs determining whether or not there is a pending upload. Possible error name could be:OfflineODataErrorName.fatalInternalError,OfflineODataErrorName.errorExecutingSqlStmt,OfflineODataErrorName.errorInitializingStore.Throws
OfflineODataError.preconditionFailedif precondition failure occurs determining whether or not there is a pending upload. Possible error name could be:OfflineODataErrorName.storeNotOpen.Declaration
Swift
public func hasPendingUpload() throws -> BoolReturn Value
Whether or not there is a pending upload (a upload that was cancelled either explicitly or because the provider was closed). It may be possible to continue the upload by triggering a new upload.
-
Open the provider. After this call, the internal metadata data structure will be changed so any values cached in memory will need to be re-retrieved.
OfflineODataError in callback could be:
OfflineODataError.invalidInput,Possible error name could be:OfflineODataErrorName.invalidDefiningQuery,OfflineODataErrorName.mandatoryCookiesNotAvailable,OfflineODataErrorName.definingQueryNameTooLong,OfflineODataErrorName.invalidDefiningQueryName,OfflineODataErrorName.invalidUrlForDefiningQuery,OfflineODataErrorName.requestForMediaStreamExists,OfflineODataErrorName.mediaStreamAlreadyAvailable,OfflineODataErrorName.noMediaStreamsInUrl,OfflineODataErrorName.currentUserWasNotProvided,OfflineODataErrorName.missingStoreName,OfflineODataErrorName.missingStorePath,OfflineODataErrorName.invalidStoreName,OfflineODataErrorName.missingIdentityFile, etc.OfflineODataError.communicationError,Possible error name could be:OfflineODataErrorName.syncFileOperationInterrupted,OfflineODataErrorName.failedToConnectToServer,OfflineODataErrorName.syncFileFailedSocketConnect,OfflineODataErrorName.syncFileCommunicationError,OfflineODataErrorName.authenticationTimeout,OfflineODataErrorName.getAuthStreamParmsFailure, etc.OfflineODataError.serverSideError,Possible error name could be:OfflineODataErrorName.syncFileFailedServerError,OfflineODataErrorName.syncFileFailedDeployFileNotFound,OfflineODataErrorName.serverLostDownload,OfflineODataErrorName.syncFileMaxRetry, etc.OfflineODataError.clientInternalError,Possible error name could be:OfflineODataErrorName.errorConnectingToDb,OfflineODataErrorName.errorInitializingStore,OfflineODataErrorName.fatalInternalError,etcOfflineODataError.preconditionFailed,Possible error name could be:OfflineODataErrorName.hasPendingRequestsWhenUserSwitch,OfflineODataErrorName.hasErrorWhenUploadPreviousUserChanges,OfflineODataErrorName.storeAlreadyOpen,OfflineODataErrorName.serviceRootChanged, etc.Declaration
Swift
public func open(completionHandler: @escaping (_ error: OfflineODataError?) -> Void)Parameters
completionHandlerThe completion handler.
-
open()Asynchronous(Asynchronous) Open the provider. After this call, the internal metadata data structure will be changed so any values cached in memory will need to be re-retrieved.
Possible raised error type is OfflineODataError. It could be:
OfflineODataError.invalidInput,Possible error name could be:OfflineODataErrorName.invalidDefiningQuery,OfflineODataErrorName.mandatoryCookiesNotAvailable,OfflineODataErrorName.definingQueryNameTooLong,OfflineODataErrorName.invalidDefiningQueryName,OfflineODataErrorName.invalidUrlForDefiningQuery,OfflineODataErrorName.requestForMediaStreamExists,OfflineODataErrorName.mediaStreamAlreadyAvailable,OfflineODataErrorName.noMediaStreamsInUrl,OfflineODataErrorName.currentUserWasNotProvided,OfflineODataErrorName.missingStoreName,OfflineODataErrorName.missingStorePath,OfflineODataErrorName.invalidStoreName,OfflineODataErrorName.missingIdentityFile, etc.OfflineODataError.communicationError,Possible error name could be:OfflineODataErrorName.syncFileOperationInterrupted,OfflineODataErrorName.failedToConnectToServer,OfflineODataErrorName.syncFileFailedSocketConnect,OfflineODataErrorName.syncFileCommunicationError,OfflineODataErrorName.authenticationTimeout,OfflineODataErrorName.getAuthStreamParmsFailure, etc.OfflineODataError.serverSideError,Possible error name could be:OfflineODataErrorName.syncFileFailedServerError,OfflineODataErrorName.syncFileFailedDeployFileNotFound,OfflineODataErrorName.serverLostDownload,OfflineODataErrorName.syncFileMaxRetry, etc.OfflineODataError.clientInternalError,Possible error name could be:OfflineODataErrorName.errorConnectingToDb,OfflineODataErrorName.errorInitializingStore,OfflineODataErrorName.fatalInternalError,etcOfflineODataError.preconditionFailed,Possible error name could be:OfflineODataErrorName.hasPendingRequestsWhenUserSwitch,OfflineODataErrorName.hasErrorWhenUploadPreviousUserChanges,OfflineODataErrorName.storeAlreadyOpen,OfflineODataErrorName.serviceRootChanged, etc.Declaration
Swift
public func open() async throws -
Get the previous user if the store is used with forceUploadOnUserSwitch=true. It will be empty string if the local store was not opened with forceUploadOnUserSwitch=true. For more information of forceUploadOnUserSwitch, please refer to OfflineODataParameters.forceUploadOnUserSwitch This function could be called whenever local store was opened or not.
Throws
OfflineODataError.clientInternalErrorif an internal error occurs getting user id. Possible error name could be:OfflineODataErrorName.fatalInternalError,OfflineODataErrorName.errorExecutingSqlStmt,OfflineODataErrorName.errorInitializingStore.Declaration
Swift
public func getPreviousUser() throws -> String?Return Value
userId of user SeeAlso:
open(completionHandler:). SeeAlso:OfflineODataParameters. -
Upload local data to update the OData backend.
OfflineODataError in callback could be:
OfflineODataError.invalidInput,Possible error name could be:OfflineODataErrorName.generateIdNotAllowedWhenUpload,OfflineODataErrorName.invalidCustomCookie,OfflineODataErrorName.invalidCustomHeader,OfflineODataErrorName.mandatoryCookiesNotAvailable,etc.OfflineODataError.preconditionFailed,Possible error name could be:OfflineODataErrorName.storeNotOpen,OfflineODataErrorName.errorUploadAlreadyInProgress,etc.OfflineODataError.serverSideError,Possible error name could be:OfflineODataErrorName.syncFileFailedServerError,OfflineODataErrorName.syncFileMaxRetry, etc.OfflineODataError.communicationError,Possible error name could be:OfflineODataErrorName.syncFileOperationInterrupted,OfflineODataErrorName.syncFileCommunicationError,OfflineODataErrorName.authenticationTimeout,OfflineODataErrorName.getAuthStreamParmsFailure,OfflineODataErrorName.failedToConnectToServer,etcOfflineODataError.clientInternalError,Possible error name could be:OfflineODataErrorName.errorUploadingRequestQueue,OfflineODataErrorName.metadataNotLoaded,OfflineODataErrorName.fatalInternalError,etc.Declaration
Swift
public func upload(completionHandler: @escaping (_ error: OfflineODataError?) -> Void)Parameters
completionHandlerThe completion handler.
-
Upload local data to update the OData backend. Partial upload allows Offline OData applications to upload a subset of the requests in the request queue. Requests from multiple upload categories can be uploaded together by performing a partial upload, which is accomplished by calling the upload function with a list of upload categories to upload. All requests that the selected requests depend on are included in the upload, even if those requests are not in the specified upload categories.
OfflineODataError in callback could be:
OfflineODataError.invalidInput,Possible error name could be:OfflineODataErrorName.generateIdNotAllowedWhenUpload,OfflineODataErrorName.noUploadCategoryAssociated,OfflineODataErrorName.invalidCustomCookie,OfflineODataErrorName.invalidCustomHeader,OfflineODataErrorName.invalidUploadCategory,OfflineODataErrorName.mandatoryCookiesNotAvailable,OfflineODataErrorName.invalidRequestForGenerateUploadCategory,OfflineODataErrorName.uploadCategoryFromNewEntity, etc.OfflineODataError.preconditionFailed,Possible error name could be:OfflineODataErrorName.storeNotOpen,OfflineODataErrorName.errorUploadAlreadyInProgress,etc.OfflineODataError.serverSideError,Possible error name could be:OfflineODataErrorName.syncFileFailedServerError,OfflineODataErrorName.syncFileMaxRetry, etc.OfflineODataError.communicationError,Possible error name could be:OfflineODataErrorName.syncFileOperationInterrupted,OfflineODataErrorName.syncFileCommunicationError,OfflineODataErrorName.authenticationTimeout,OfflineODataErrorName.getAuthStreamParmsFailure,OfflineODataErrorName.failedToConnectToServer,etcOfflineODataError.clientInternalError,Possible error name could be:OfflineODataErrorName.errorUploadingRequestQueue,OfflineODataErrorName.metadataNotLoaded,OfflineODataErrorName.fatalInternalError,etc.- Parameter UploadCategory: An array containing the upload categories to contain in the upload. - Parameter completionHandler: The completion handler.
Declaration
Swift
public func upload( categories: [ UploadCategory ], completionHandler:@escaping ( _ error: OfflineODataError? ) -> Void ) -> Void -
upload()Asynchronous(Asynchronous) Upload local data to update the OData backend.
Possible raised error type is OfflineODataError. It could be:
OfflineODataError.invalidInput,Possible error name could be:OfflineODataErrorName.generateIdNotAllowedWhenUpload,OfflineODataErrorName.invalidCustomCookie,OfflineODataErrorName.invalidCustomHeader,OfflineODataErrorName.mandatoryCookiesNotAvailable,etc.OfflineODataError.preconditionFailed,Possible error name could be:OfflineODataErrorName.storeNotOpen,OfflineODataErrorName.errorUploadAlreadyInProgress,etc.OfflineODataError.serverSideError,Possible error name could be:OfflineODataErrorName.syncFileFailedServerError,OfflineODataErrorName.syncFileMaxRetry, etc.OfflineODataError.communicationError,Possible error name could be:OfflineODataErrorName.syncFileOperationInterrupted,OfflineODataErrorName.syncFileCommunicationError,OfflineODataErrorName.authenticationTimeout,OfflineODataErrorName.getAuthStreamParmsFailure,OfflineODataErrorName.failedToConnectToServer,etcOfflineODataError.clientInternalError,Possible error name could be:OfflineODataErrorName.errorUploadingRequestQueue,OfflineODataErrorName.metadataNotLoaded,OfflineODataErrorName.fatalInternalError,etc.Declaration
Swift
public func upload() async throws -
upload(categories:Asynchronous) (Asynchronous) Upload local data to update the OData backend. Partial upload allows Offline OData applications to upload a subset of the requests in the request queue. Requests from multiple upload categories can be uploaded together by performing a partial upload, which is accomplished by calling the upload function with a list of upload categories to upload. All requests that the selected requests depend on are included in the upload, even if those requests are not in the specified upload categories.
Possible raised error type is OfflineODataError. It could be:
OfflineODataError.invalidInput,Possible error name could be:OfflineODataErrorName.generateIdNotAllowedWhenUpload,OfflineODataErrorName.noUploadCategoryAssociated,OfflineODataErrorName.invalidCustomCookie,OfflineODataErrorName.invalidCustomHeader,OfflineODataErrorName.invalidUploadCategory,OfflineODataErrorName.mandatoryCookiesNotAvailable,OfflineODataErrorName.invalidRequestForGenerateUploadCategory,OfflineODataErrorName.uploadCategoryFromNewEntity, etc.OfflineODataError.preconditionFailed,Possible error name could be:OfflineODataErrorName.storeNotOpen,OfflineODataErrorName.errorUploadAlreadyInProgress,etc.OfflineODataError.serverSideError,Possible error name could be:OfflineODataErrorName.syncFileFailedServerError,OfflineODataErrorName.syncFileMaxRetry, etc.OfflineODataError.communicationError,Possible error name could be:OfflineODataErrorName.syncFileOperationInterrupted,OfflineODataErrorName.syncFileCommunicationError,OfflineODataErrorName.authenticationTimeout,OfflineODataErrorName.getAuthStreamParmsFailure,OfflineODataErrorName.failedToConnectToServer,etcOfflineODataError.clientInternalError,Possible error name could be:OfflineODataErrorName.errorUploadingRequestQueue,OfflineODataErrorName.metadataNotLoaded,OfflineODataErrorName.fatalInternalError,etc.- Parameter UploadCategory: An array containing the upload categories to contain in the upload.
Declaration
Swift
public func upload(categories: [UploadCategory]) async throws -
Download the data for all defining queries from the OData backend to update the local data. If the defining queries are delta enabled, only the changes will be downloaded.
OfflineODataError in callback could be:
OfflineODataError.preconditionFailed,Possible error name could be:OfflineODataErrorName.storeNotOpen,OfflineODataErrorName.subsetDownloadAlreadyInProgress,etc.OfflineODataError.serverSideError,Possible error name could be:OfflineODataErrorName.syncFileFailedServerError,OfflineODataErrorName.serverLostDownload,OfflineODataErrorName.syncFileMaxRetry,OfflineODataErrorName.syncFileFailedDeployFileNotFound, etc.OfflineODataError.communicationError,Possible error name could be:OfflineODataErrorName.syncFileOperationInterrupted,OfflineODataErrorName.authenticationTimeout,OfflineODataErrorName.getAuthStreamParmsFailure,OfflineODataErrorName.failedToConnectToServer,OfflineODataErrorName.syncFileCommunicationError, etc.OfflineODataError.invalidInput,Possible error name could be:OfflineODataErrorName.mandatoryCookiesNotAvailable,OfflineODataErrorName.mandatoryCookiesNotAvailable,OfflineODataErrorName.definingQueryNotFound, etc.OfflineODataError.clientInternalError,Possible error name could be:OfflineODataErrorName.metadataNotLoaded,OfflineODataErrorName.fatalInternalError,etc.Note: The downloading task may not back immediately since which is pending because of other concurrent downloadings or which is in a critical non-cancelled stage.
Declaration
Swift
@discardableResult public func download(completionHandler: @escaping (_ error: OfflineODataError?) -> Void) -> CancelTokenParameters
completionHandlerThe completion handler.
Return Value
A token can be used to cancel the download operation.
-
download(_:Asynchronous) (Asynchronous) Download the data for all defining queries from the OData backend to update the local data. If the defining queries are delta enabled, only the changes will be downloaded.
Possible raised error type is OfflineODataError. It could be:
OfflineODataError.preconditionFailed,Possible error name could be:OfflineODataErrorName.storeNotOpen,OfflineODataErrorName.subsetDownloadAlreadyInProgress,etc.OfflineODataError.serverSideError,Possible error name could be:OfflineODataErrorName.syncFileFailedServerError,OfflineODataErrorName.serverLostDownload,OfflineODataErrorName.syncFileMaxRetry,OfflineODataErrorName.syncFileFailedDeployFileNotFound, etc.OfflineODataError.communicationError,Possible error name could be:OfflineODataErrorName.syncFileOperationInterrupted,OfflineODataErrorName.authenticationTimeout,OfflineODataErrorName.getAuthStreamParmsFailure,OfflineODataErrorName.failedToConnectToServer,OfflineODataErrorName.syncFileCommunicationError, etc.OfflineODataError.invalidInput,Possible error name could be:OfflineODataErrorName.mandatoryCookiesNotAvailable,OfflineODataErrorName.mandatoryCookiesNotAvailable,OfflineODataErrorName.definingQueryNotFound, etc.OfflineODataError.clientInternalError,Possible error name could be:OfflineODataErrorName.metadataNotLoaded,OfflineODataErrorName.fatalInternalError,etc.Declaration
Swift
public func download(_ cancelToken: CancelToken? = nil) async throwsParameters
cancelTokenA token can be used to cancel the download operation.
-
Causes the OfflineODataProvider to remove any stored authentication it may have, causing it to reauthenticate the next time it needs to send a request to the CPms server.
This will call the reset method of the SAPURLSession passed into the init method of this class.
Declaration
Swift
public func forceReauthentication(completionHandler: @escaping () -> Void) -
forceReauthentication()Asynchronous(Asynchronous) Causes the OfflineODataProvider to remove any stored authentication it may have, causing it to reauthenticate the next time it needs to send a request to the CPms server.
This will call the reset method of the SAPURLSession passed into the init method of this class.
Declaration
Swift
public func forceReauthentication() async -
Downloads the data for the specified subset of defining queries from the OData backend to update the local data. If the defining queries are delta enabled, only the changes will be downloaded.
OfflineODataError in callback could be:
OfflineODataError.preconditionFailed,Possible error name could be:OfflineODataErrorName.storeNotOpen,OfflineODataErrorName.subsetDownloadAlreadyInProgress,etc.OfflineODataError.serverSideError,Possible error name could be:OfflineODataErrorName.syncFileFailedServerError,OfflineODataErrorName.serverLostDownload,OfflineODataErrorName.syncFileMaxRetry,OfflineODataErrorName.syncFileFailedDeployFileNotFound, etc.OfflineODataError.communicationError,Possible error name could be:OfflineODataErrorName.syncFileOperationInterrupted,OfflineODataErrorName.syncFileCommunicationError,OfflineODataErrorName.authenticationTimeout,OfflineODataErrorName.getAuthStreamParmsFailure,OfflineODataErrorName.failedToConnectToServer, etc.OfflineODataError.invalidInput,Possible error name could be:OfflineODataErrorName.invalidDownloadSubset,OfflineODataErrorName.mandatoryCookiesNotAvailable,OfflineODataErrorName.definingQueryNotFound,OfflineODataErrorName.mandatoryCookiesNotAvailable, etc.OfflineODataError.clientInternalError,Possible error name could be:OfflineODataErrorName.metadataNotLoaded,OfflineODataErrorName.fatalInternalError,etc.Note: The downloading task may not back immediately since which is pending because of other concurrent downloadings or which is in a critical non-cancelled stage.
Declaration
Swift
@discardableResult public func download(withSubset subset: [OfflineODataDefiningQuery], completionHandler: @escaping (_ error: OfflineODataError?) -> Void) -> CancelTokenParameters
subsetThe subset of the defining queries to download.
completionHandlerThe completion handler.
Return Value
A token can be used to cancel the download operation.
-
download(_:Asynchronous_: ) (Asynchronous) Downloads the data for the specified subset of defining queries from the OData backend to update the local data. If the defining queries are delta enabled, only the changes will be downloaded.
Possible raised error type is OfflineODataError. It could be:
OfflineODataError.preconditionFailed,Possible error name could be:OfflineODataErrorName.storeNotOpen,OfflineODataErrorName.subsetDownloadAlreadyInProgress,etc.OfflineODataError.serverSideError,Possible error name could be:OfflineODataErrorName.syncFileFailedServerError,OfflineODataErrorName.serverLostDownload,OfflineODataErrorName.syncFileMaxRetry,OfflineODataErrorName.syncFileFailedDeployFileNotFound, etc.OfflineODataError.communicationError,Possible error name could be:OfflineODataErrorName.syncFileOperationInterrupted,OfflineODataErrorName.syncFileCommunicationError,OfflineODataErrorName.authenticationTimeout,OfflineODataErrorName.getAuthStreamParmsFailure,OfflineODataErrorName.failedToConnectToServer, etc.OfflineODataError.invalidInput,Possible error name could be:OfflineODataErrorName.invalidDownloadSubset,OfflineODataErrorName.mandatoryCookiesNotAvailable,OfflineODataErrorName.definingQueryNotFound,OfflineODataErrorName.mandatoryCookiesNotAvailable, etc.OfflineODataError.clientInternalError,Possible error name could be:OfflineODataErrorName.metadataNotLoaded,OfflineODataErrorName.fatalInternalError,etc.Note: The downloading task may not back immediately since which is pending because of other concurrent downloadings or which is in a critical non-cancelled stage.
Declaration
Swift
public func download(_ subset: [OfflineODataDefiningQuery], _ cancelToken: CancelToken? = nil) async throwsParameters
subsetThe subset of the defining queries to download.
cancelTokenA token can be used to cancel the download operation.
-
Cancels all downloads and file downloads including those that are queued. This method will also cancel an initial download and file download if it is called while the OfflineODataProvider is opening for the first time.
Throws
OfflineODataError.notFoundif there are no downloads or file downloads to cancel. Possible error name could be:OfflineODataErrorName.errorCancelNoDownload.Throws
OfflineODataError.preconditionFailedif there are no downloads or file downloads to cancel. Possible error name could be:OfflineODataErrorName.errorSystemRefreshInProgress.Declaration
Swift
public func cancelDownload() throws -
Cancels the current upload.
Throws
OfflineODataError.notFoundif there are no uploads to cancel. Possible error name could be:OfflineODataErrorName.errorCancelNoUpload.Declaration
Swift
public func cancelUpload() throws -
Asynchronously sends Offline store to CPms server.
OfflineODataError in callback could be:
OfflineODataError.preconditionFailed,Possible error name could be:OfflineODataErrorName.storeNotOpen.OfflineODataError.communicationError,Possible error name could be:OfflineODataErrorName.sendStoreFailed.OfflineODataError.clientInternalError,Possible error name could be:OfflineODataErrorName.sendStoreCopyStoreFailed,OfflineODataErrorName.sendStoreCopyRequestQueueFailed.Declaration
Swift
public func sendStore(note: String? = nil, completionHandler: @escaping (_ error: OfflineODataError?) -> Void)Parameters
notesend the store relevant information and should not exceed length of 120.
completionHandlerThe completion handler.
-
sendStore(note:Asynchronous) (Asynchronous) Sends Offline store to CPms server.
Possible raised error type is OfflineODataError. It could be:
OfflineODataError.preconditionFailed,Possible error name could be:OfflineODataErrorName.storeNotOpen.OfflineODataError.communicationError,Possible error name could be:OfflineODataErrorName.sendStoreFailed.OfflineODataError.clientInternalError,Possible error name could be:OfflineODataErrorName.sendStoreCopyStoreFailed,OfflineODataErrorName.sendStoreCopyRequestQueueFailed.Declaration
Swift
public func sendStore(note: String? = nil) async throwsParameters
notesend the store relevant information and should not exceed length of 120.
-
Asynchronously sends Offline store to CPms server.
OfflineODataError in callback could be:
OfflineODataError.preconditionFailed,Possible error name could be:OfflineODataErrorName.storeNotOpen.OfflineODataError.communicationError,Possible error name could be:OfflineODataErrorName.sendStoreFailed.OfflineODataError.clientInternalError,Possible error name could be:OfflineODataErrorName.changeSendStoreEncryptionKeyFailed,OfflineODataErrorName.sendStoreCopyRequestQueueFailed,OfflineODataErrorName.sendStoreCopyStoreFailed.OfflineODataError.invalidInput,Possible error name could be:OfflineODataErrorName.sendStoreWithNewEncryptionKeyFailed,OfflineODataErrorName.sendStoreNoteTooLong.Declaration
Swift
public func sendEncryptedStore(newEncryptionKey: String, note: String? = nil, completionHandler: @escaping (_ error: OfflineODataError?) -> Void)Parameters
newEncryptionKeythe new encryption key can not contain special character like space and semicolon.
notesend the store relevant information and should not exceed length of 120.
completionHandlerThe completion handler.
-
sendEncryptedStore(newEncryptionKey:Asynchronousnote: ) (Asynchronous) Sends Offline store to CPms server.
Possible raised error type is OfflineODataError. It could be:
OfflineODataError.preconditionFailed,Possible error name could be:OfflineODataErrorName.storeNotOpen.OfflineODataError.communicationError,Possible error name could be:OfflineODataErrorName.sendStoreFailed.OfflineODataError.clientInternalError,Possible error name could be:OfflineODataErrorName.changeSendStoreEncryptionKeyFailed,OfflineODataErrorName.sendStoreCopyRequestQueueFailed,OfflineODataErrorName.sendStoreCopyStoreFailed.OfflineODataError.invalidInput,Possible error name could be:OfflineODataErrorName.sendStoreWithNewEncryptionKeyFailed,OfflineODataErrorName.sendStoreNoteTooLong.Declaration
Swift
public func sendEncryptedStore(newEncryptionKey: String, note: String? = nil) async throwsParameters
newEncryptionKeythe new encryption key can not contain special character like space and semicolon.
notesend the store relevant information and should not exceed length of 120.
-
Sends only the request queue database to CPms server.
Declaration
Swift
public func sendRequestStore( note: String? = nil, completionHandler: @escaping (_ error: OfflineODataError?) -> Void )Parameters
notesend relevant information, should not exceed length of 120.
completionHandlercalled when the operation completes.
-
sendRequestStore(note:Asynchronous) Sends only the request queue database to CPms server.
Declaration
Swift
public func sendRequestStore(note: String? = nil) async throwsParameters
notesend relevant information, should not exceed length of 120.
-
Sends only the request queue database (encrypted) to CPms server.
Declaration
Swift
public func sendEncryptedRequestStore( newEncryptionKey: String, note: String? = nil, completionHandler: @escaping (_ error: OfflineODataError?) -> Void )Parameters
newEncryptionKeythe new encryption key cannot contain space or semicolon.
notesend relevant information, should not exceed length of 120.
completionHandlercalled when the operation completes.
-
sendEncryptedRequestStore(newEncryptionKey:Asynchronousnote: ) Sends only the request queue database (encrypted) to CPms server.
Declaration
Swift
public func sendEncryptedRequestStore(newEncryptionKey: String, note: String? = nil) async throwsParameters
newEncryptionKeythe new encryption key cannot contain space or semicolon.
notesend relevant information, should not exceed length of 120.
-
Add a defining query to the provider. There are three types of defining queries:
1) A defining query that identifies one or more entities where the automaticallyRetrievesStreams property is set to false. In this case, even if the defining query identifies media entities, the media streams will not be downloaded.
2) A defining query that identifies one or more entities, some of which may be media entities, and where the automaticallyRetrievesStreams property is set to true. In this case, the media streams will be downloaded as well for media entities.
3) A defining query that identifies a single media entity and the automaticallyRetrievesStreams property is set to true. The URL specified in this case MUST be the read link of the media entity, not the read link of the media stream. For example, if the media entity’s read link is Documents(101) and the media stream’s read link is Documents(101)/$value, the expected URL of the defining query is Documents(101).
Defining queries can be added before or after the OfflineODataProvider has been opened.
For performance reasons, it is not recommended (although it is supported) to use $expand in defining queries, unless your OData backend supports deltas with $expand in defining queries.
The Offline OData server component can take advantage of referential constraints to build relationship information instead of relying on $expand. For example, if the relationship (Association) between Customers and Orders has a referential constraint in the metadata document, the defining query https://sapcpms/odata/endpoint/Customers?$expand=Orders is equivalent to the pair of defining queries https://sapcpms/odata/endpoint/Customers and https://sapcpms/odata/endpoint/Orders; in both cases, all Customers, Orders, and relationship information for Customers and Orders are downloaded.
Throws
OfflineODataError.invalidInputif invalid input error occurs adding the defining query. Possible error name could be:OfflineODataErrorName.requestExists,OfflineODataErrorName.invalidDefiningQueryName,OfflineODataErrorName.invalidUrlForDefiningQuery,OfflineODataErrorName.definingQueryNameTooLong,OfflineODataErrorName.mediaStreamAlreadyAvailable,OfflineODataErrorName.requestForMediaStreamExists,OfflineODataErrorName.noMediaStreamsInUrl.Declaration
Swift
public func add(definingQuery: OfflineODataDefiningQuery) throwsParameters
definingQueryThe defining query to add.
-
Set defining query groups at client side.
Multiple defining queries can be grouped into one batch request when SAP Mobile Services downloads the data from the OData back end. In common, it is configured at the cockpit of SAP Mobile Services. Alternatively, it could also be set at client side through this function. Each call will overwrite result of previous call.
Defining query groups can be added before or after the OfflineODataProvider has been opened.
The defining query groups added when OfflineODataProvider is not opened, are not persisted. They will be lost after the device is power off or application is terminated.
Throws
OfflineODataError.clientInternalErrorif an internal error occurs setting the defining query groups. Possible error name could be:OfflineODataErrorName.fatalInternalError,OfflineODataErrorName.errorExecutingSqlStmt,OfflineODataErrorName.errorInitializingStore.Throws
OfflineODataError.preconditionFailedif precondition failure occurs setting the defining query groups,Possible error name could be:OfflineODataErrorName.storeNotOpen.Declaration
Swift
public func setDefiningQueryGroups(groups: Array<Set<String>>) throwsParameters
groupsThe list of defining query group. Each group contains the name of all defining queries that will be grouped into one batch request.
-
Remove a defining query.
See also
Referenceadd(definingQuery:)function for the three types of defining queries. Referenceremove(definingQuery:completionHandler:)function for new interface.Defining queries of type 1 and 2 can only be removed before the OfflineODataProvider is open for the first time.
Defining queries of type 3 can be removed before or after the OfflineODataProvider has been opened.
Note: This method does not support ‘allow_defining_query_removal’, please try
remove(definingQuery:completionHandler:)Throws
OfflineODataError.notFoundif target not found error occurs removing the defining query. Possible error name could be:OfflineODataErrorName.requestNotExists.Throws
OfflineODataError.preconditionFailedif a precondition failure occurs removing the defining query. Possible error name could be:OfflineODataErrorName.requestBeingRemoved,OfflineODataErrorName.removeDefiningQueryNotEnabled,OfflineODataErrorName.removeDefiningQueryWithPartialDownload,OfflineODataErrorName.removeDefiningQueryWithPendingChanges.Declaration
Swift
public func remove(definingQuery: OfflineODataDefiningQuery) throwsParameters
definingQueryThe defining query to remove.
-
Remove a defining query.
See also
Referenceadd(definingQuery:)function for the three types of defining queries. Referenceremove(definingQuery:)function for old interface.Before OfflineODataProvider is open:
- The defining queries of type 1, 2 can only be removed for the first time.
After OfflineODataProvider is open:
- If ‘allow_defining_query_removal’ is not enabled, only the defining queries of type 3 can be removed, and completionHandler will be called with error for others.
- If ‘allow_defining_query_removal’ is enabled, all types can be removed when there is no any pending change. Removing a defining query from the provider will delete all local data of the defining query in OfflineODataProvider like entities downloaded from the backend, relationships associated with the entities and their media streams. The local data is always deleted immediately, but if non-shared delta tracking is enabled, the name of the defining query and its change logs on the server will be deleted during next downloading.
OfflineODataError in callback could be:
OfflineODataError.notFoundPossible error name could be:OfflineODataErrorName.requestNotExists.OfflineODataError.preconditionFailedPossible error name could be:OfflineODataErrorName.requestBeingRemoved,OfflineODataErrorName.removeDefiningQueryNotEnabled,OfflineODataErrorName.removeDefiningQueryWithPartialDownload,OfflineODataErrorName.removeDefiningQueryWithPendingChanges.Declaration
Swift
public func remove(definingQuery: OfflineODataDefiningQuery, completionHandler: @escaping (_ error: OfflineODataError?) -> Void)Parameters
definingQueryThe defining query to remove.
completionHandlerThe completion handler.
-
remove(definingQuery:Asynchronous) (Asynchronous) Remove a defining query.
See also
Referenceadd(definingQuery:)function for the three types of defining queries. Referenceremove(definingQuery:)function for old interface.Before OfflineODataProvider is open:
- The defining queries of type 1, 2 can only be removed for the first time.
After OfflineODataProvider is open:
- If ‘allow_defining_query_removal’ is not enabled, only the defining queries of type 3 can be removed, and completionHandler will be called with error for others.
- If ‘allow_defining_query_removal’ is enabled, all types can be removed when there is no any pending change. Removing a defining query from the provider will delete all local data of the defining query in OfflineODataProvider like entities downloaded from the backend, relationships associated with the entities and their media streams. The local data is always deleted immediately, but if non-shared delta tracking is enabled, the name of the defining query and its change logs on the server will be deleted during next downloading.
Possible raised error type is OfflineODataError. It could be:
OfflineODataError.notFoundPossible error name could be:OfflineODataErrorName.requestNotExists.OfflineODataError.preconditionFailedPossible error name could be:OfflineODataErrorName.requestBeingRemoved,OfflineODataErrorName.removeDefiningQueryNotEnabled,OfflineODataErrorName.removeDefiningQueryWithPartialDownload,OfflineODataErrorName.removeDefiningQueryWithPendingChanges.Declaration
Swift
public func remove(definingQuery: OfflineODataDefiningQuery) async throwsParameters
definingQueryThe defining query to remove.
-
Reserved for internal use. Please do not use. No support will be provided.
-
for internal use. Please do not use. No support will be provided.
-
See definition in DataServiceProvider.
See also
OfflineODataRequestOptions.Declaration
Swift
open func createEntity(_ entity: EntityValue, headers: HTTPHeaders, options: RequestOptions) throws -
See definition in DataServiceProvider.
See also
OfflineODataRequestOptions.Declaration
Swift
open func createLink(from: EntityValue, property: Property, to: EntityValue, headers: HTTPHeaders, options: RequestOptions) throws -
See definition in DataServiceProvider.
Note: key of the entity will be removed if it has been set. No key should be set when creating a media entity.
See also
OfflineODataRequestOptions.Declaration
Swift
open func createMedia(entity: EntityValue, content: StreamBase, headers: HTTPHeaders, options: RequestOptions) throws -
See definition in DataServiceProvider.
See also
OfflineODataRequestOptions.Declaration
Swift
open func deleteByQuery(_ query: DataQuery, headers: HTTPHeaders, options: RequestOptions) throws -
See definition in DataServiceProvider.
See also
OfflineODataRequestOptions.Declaration
Swift
open func deleteEntity(_ entity: EntityValue, headers: HTTPHeaders, options: RequestOptions) throws -
See definition in DataServiceProvider.
See also
OfflineODataRequestOptions.Declaration
Swift
open func deleteStream(entity: EntityValue, link: StreamLink, headers: HTTPHeaders, options: RequestOptions) throws -
See definition in DataServiceProvider.
See also
OfflineODataRequestOptions.Declaration
Swift
open func deleteLink(from: EntityValue, property: Property, to: EntityValue, headers: HTTPHeaders, options: RequestOptions) throws -
See definition in DataServiceProvider.
Declaration
Swift
open func downloadMedia(entity: EntityValue, headers: HTTPHeaders, options: RequestOptions) throws -> ByteStream -
See definition in DataServiceProvider.
See also
OfflineODataRequestOptions.Declaration
Swift
open func downloadStream(entity: EntityValue, link: StreamLink, headers: HTTPHeaders, options: RequestOptions) throws -> ByteStream -
See definition in DataServiceProvider.
Declaration
Swift
open func executeQuery(_ query: DataQuery, headers: HTTPHeaders, options: RequestOptions) throws -> QueryResult -
Query the ErrorArchive, the builtin Offline OData entity set which contains information about requests that failed during the last upload.
Declaration
Swift
open func fetchErrorArchive(query: DataQuery = DataQuery()) throws -> Array<OfflineODataErrorArchiveEntity> -
Query the EventLog, the builtin Offline OData entity set which contains information about Offline OData events such as upload and download.
Declaration
Swift
open func fetchEventLog(query: DataQuery = DataQuery()) throws -> Array<OfflineODataEvent> -
Query the OfflineOData EventLog entity set for the last download time
Throws
OfflineODataError.preconditionFailedif precondition failed occurs getting last download time. Possible error name could be:OfflineODataErrorName.storeNotOpen.Throws
OfflineODataError.clientInternalErrorif an internal error occurs getting last download time. Possible error name could be:OfflineODataErrorName.metadataNotLoaded.See also
Declaration
Swift
open func getLastDownloadTime() throws -> GlobalDateTime? -
Query the OfflineOData EventLog entity set for the last upload time
Throws
OfflineODataError.preconditionFailedif precondition failed occurs getting last upload time. Possible error name could be:OfflineODataErrorName.storeNotOpen.Throws
OfflineODataError.clientInternalErrorif an internal error occurs getting last upload time. Possible error name could be:OfflineODataErrorName.metadataNotLoaded.See also
Declaration
Swift
open func getLastUploadTime() throws -> GlobalDateTime? -
See definition in DataServiceProvider.
Declaration
Swift
open func processBatch(_ batch: RequestBatch, headers: HTTPHeaders, options: RequestOptions) throws -
See definition in DataServiceProvider.
See also
OfflineODataRequestOptions.Declaration
Swift
open func updateEntity(_ entity: EntityValue, headers: HTTPHeaders, options: RequestOptions) throws -
See definition in DataServiceProvider.
See also
OfflineODataRequestOptions.Declaration
Swift
open func updateLink(from: EntityValue, property: Property, to: EntityValue, headers: HTTPHeaders, options: RequestOptions) throws -
See definition in DataServiceProvider.
See also
OfflineODataRequestOptions.Declaration
Swift
open func uploadMedia(entity: EntityValue, content: StreamBase, headers: HTTPHeaders, options: RequestOptions) throws -
See definition in DataServiceProvider.
See also
OfflineODataRequestOptions.Declaration
Swift
open func uploadStream(entity: EntityValue, link: StreamLink, content: StreamBase, headers: HTTPHeaders, options: RequestOptions) throws -
Dump content (as a JSON object) of request queue of the offline store to log.
Throws
OfflineODataError.preconditionFailedif a precondition failure occurs logging request queue. Possible error name could be:OfflineODataErrorName.storeNotOpen.See SAPCommon.LogLevel.
Declaration
Swift
public func logRequestQueue(level: SAPCommon.LogLevel = SAPCommon.LogLevel.debug) throwsParameters
logLevelThe log level to use for logging. Default to debug.
-
Dump defining queries (as a JSON object) that have been added to the offline store to log.
Throws
OfflineODataError.preconditionFailedif a precondition failure occurs logging defining queries. Possible error name could be:OfflineODataErrorName.storeNotOpen.See SAPCommon.LogLevel.
Declaration
Swift
public func logDefiningQueries(level: SAPCommon.LogLevel = SAPCommon.LogLevel.debug) throwsParameters
logLevelThe log level to use for logging. Default to debug.
-
Get all the defining queries.
Declaration
Swift
public func getDefiningQueries() throws -> Array<OfflineODataDefiningQuery> -
Execute Function import. It does not support GET function import requests because GET requests are executed locally and there is no way to predict or simulate what the GET response will be when executed on the backend. The following example describes how to prepare data for executing Function Import: let dataMethod = dataService.dataMethod(withName: “CreateCustomer”) //Function Import name dataMethod.httpMethod = “POST” let paramList = ParameterList() let parameter = Parameter() parameter.name = “customerId” parameter.value = IntValue.of( 10001 ) paramList.append( parameter.value )
dataService.executeMethod( dataMethod, parameters: paramList )
Declaration
Swift
open func executeMethod(_ method: DataMethod, parameters: ParameterList, headers: HTTPHeaders, options: RequestOptions) throws -> DataValue? -
Pings the server to check that both the Offline Server component and the OData backend are reachable. This function will return successfully if both are reachable and will throw an error otherwise.
Throws
DataServiceError If an error occurs pinging the server.Declaration
Swift
open func pingServer(headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws -
Undo pending local changes for a given entity. While you can make changes to existing entities and new entities locally, you can also undo the changes without uploading them. An existing entity will be restored to the original status as if no any changes had been made. A new entity will be removed as if the entity had never been created.
For example, say you have an existing entity customer101. You can either:
Patch customer101 several times. Undoing the changes will restore all property values.
Associate customer101 to some purchase orders. Undoing the changes will remove the relationships.
Delete customer101. Undoing this change will bring customer101 back.
As another example, say you have created a new entity customer102 locally. No matter what subsequent operations you apply to it, undoing the changes will remove customer102 as if this entity had never been created.
There are some more complex cases that Offline OData provides flexible support. For example, say you created a new entity order102 that deep inserted a new related entity customer102 in one request. There can be different sequences of performing undo:
Undo changes for customer102 first. In this case, customer102 will be removed, and order102 will remain (since you are not undoing changes for order102) but is not related to any customer (since customer102 has been removed). The original request for creating order102 and customer102 will be adjusted accordingly to produce the correct result. You can continue to undo changes for order102, which will remove it.
Undo changes for order102 first. In this case, order102 will be removed, and customer102 will remain (since you are not undoing changes for customer102) but is not related to any order (since order102 has been removed). The original request for creating order102 and customer102 will be adjusted accordingly to produce the correct result. You can continue to undo changes for customer102, which will remove it.
Undoing pending changes and undoing local creation (see
OfflineODataParameters.enableUndoLocalCreation) are somewhat related but there are some key differences:Undoing local creation is an optimization for the back end to not send a POST request if a new entity created locally is deleted before it is uploaded. Undoing pending changes is not intended to be an optimization but rather allows correcting mistakes or changing your mind about what you did.
Undoing local creation only applies to new entities created locally. Undoing pending changes also applies to existing entities that have been downloaded from back end.
For a new entity created locally, you can remove it by undoing pending changes for it without performing a deletion. However, you need to perform a deletion on the entity if you want to apply undoing local creation in order to remove it.
Undoing local creation takes effect (removing affected requests from request queue) when you perform an upload. Undoing pending changes takes effect (removing affected requests from request queue) when you call the method.
The undoing local creation algorithm respects cascading deletes while undo pending changes does not.
Because undoing local creation is an optimization, it will not remove requests for deleted entities which would cause entities that were downloaded from the server to be deleted. Undo pending changes on the other hand disregards whether the requests have a side affect on a server entity or not; it simply removes all references to the specified entity in the request queue.
Throws
OfflineODataError.invalidInput if an invalid input error occurs undoing the pending changes. Possible error name could be:
OfflineODataErrorName.invalidNullInKeyPredicate.Throws
OfflineODataError.preconditionFailedif a precondition failure occurs undoing the pending changes. Possible error name could be:OfflineODataErrorName.storeNotOpen.Declaration
Swift
open func undoPendingChanges(for entity: EntityValue) throwsParameters
forThe entity to undo pending changes.
-
Undo pending local changes for an array of entities. In case there are many entities to undo, undo one by one might be time consuming. Undo an array of entities in one call to improve performance
Throws
OfflineODataErrorif an error occurs undoing the pending changes.Declaration
Swift
open func undoPendingChanges(for entities: [EntityValue]) throwsParameters
forThe entities to undo pending changes.
-
Undo pending local changes for a given UploadCategory. Please notes that only UploadCategoryType of stringLiteral is supported for undo operation
Throws
OfflineODataErrorif the UploadCategoryType is not stringLiteralThrows
DataServiceErrorif an error occurs undoing the pending changes.See also
Reference
undoPendingChanges(entity:)for undo local changes for givenEntityValueReferenceundoPendingChanges(transactionId:)for undo local changes for giveTransactionIDReferenceundoPendingChanges(headerName:headerValue)for undo local changes for give HTTP HeaderDeclaration
Swift
open func undoPendingChanges(for uploadCategory: UploadCategory) throwsParameters
forThe uploadCategory to undo pending changes.
-
Undo pending local changes for a given TransactionID. Please notes that only TransactionIDType of stringLiteral is supported for undo operation
Throws
OfflineODataErrorif the TransactionIDType is not stringLiteralThrows
DataServiceErrorif an error occurs undoing the pending changes.See also
Reference
undoPendingChanges(entity:)for undo local changes for givenEntityValueReferenceundoPendingChanges(uploadCategory:)for undo local changes for giveUploadCategoryReferenceundoPendingChanges(headerName:headerValue)for undo local changes for give HTTP HeaderDeclaration
Swift
open func undoPendingChanges(for transactionId: TransactionID) throwsParameters
forThe transactionId to undo pending changes.
-
Undo pending local changes with a given HTTP Header of headerName and headerValue.
Throws
DataServiceErrorif an error occurs undoing the pending changes.See also
Reference
undoPendingChanges(entity:)for undo local changes for givenEntityValueReferenceundoPendingChanges(uploadCategory:)for undo local changes for giveUploadCategoryReferenceundoPendingChanges(transactionId:)for undo local changes for giveTransactionIDDeclaration
Swift
open func undoPendingChanges(headerName: String, headerValue: String) throwsParameters
headerNameThe header name.
headerValueThe header value.
-
See definition in DataServiceProvider.
Declaration
Swift
open func loadMetadata(headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws -
See definition in DataServiceProvider.
Declaration
Swift
open func unloadMetadata() throws -
Declaration
Swift
open func fetchMetadata(headers: HTTPHeaders = HTTPHeaders.empty, options: RequestOptions = RequestOptions.none) throws -> CSDLDocument -
Discard all changes for client-only models including local draft. The purgeClientOnlyData API may be used for the following scenarios:
- The client-only requests may keep growing over time. Query and delete client-only request one by one might be tedious. Use this purge API to quickly drop all client-only data.
The device may be shared between multiple users, and the previous user may need to purge all the client-only data before handover to the next user.
See also
SeeAlso
OfflineODataParameters.forcePurgeClientOnlyDataOnUserSwitchThrows
OfflineODataErrorif unexpected error happened while purging existing client-only dataDeclaration
Swift
public func purgeClientOnlyData() throws