SAP iOS SDK has few classes and protocols related oData operation mentioned in the below links
Class OfflineOdataProvider : DataServiceProvider
A class similar to OnlineODataProvider, but has methods that upload, download and clear the
offline database.
When mobile application handles oData content, it does not directly call the methods of OnlineODataProvider or OfflineODataProvider, instead the application calls the method of DataService (or derived classes). The DataService class has generic parameter of DataServiceProvider type, which is used to handle the actual oData requests.
Class DataService<Provider: DataServiceProvider>
Then in the application, a derived class of DataService will call various methods (executeQuery etc) implemented by ODataProvider to manage proxy class objects (derived from EntityValue class), like Customers, Products. The DataService class manages the proxy class object through DataQuery class, which represents a standard SQL statement. To create DataService object, the constructor needs parameters to provide serviceRoot url, a urlSession to authenticate with backend, and a service name. The service name does not matter for online cases.
If offlineDataServiceProvider is used as generic parameter to create DataService, when first time calling open method, it will download the database from HCP MobileService, and once the offline database is created, calling the same method again will just open the existing database without sending any requests to server, so the open and following DataQuery methods will work even if the device is offline.
Class DataQuery
DataQuery class is used to specified a SQL query, such as what columns to be selected, what is the order or where conditions.
Note, although the client can choose either using online or offline OData provider, the SAP cloud platform mobile service does not have any difference in application configuration regardless which one is selected on client side. As long as the server provides a valid oData service, then the client can work with it.
Understanding the relationship between those classes and protocols will help to use them.
Protocol DataServiceProvider
This protocol defines the basic operations (create, delete, update entity) along with pingServer, loadMetadata method.
Class OnlineODataProvider : DataServiceProvider
A class implements the DataServiceProvider, OnlineODataProvider requires ServiceRoot URL and SAPURLSession as init parameters, so it can send request to server to perform the data operation.
Class OfflineOdataProvider : DataServiceProvider
A class similar to OnlineODataProvider, but has methods that upload, download and clear the
offline database.
When mobile application handles oData content, it does not directly call the methods of OnlineODataProvider or OfflineODataProvider, instead the application calls the method of DataService (or derived classes). The DataService class has generic parameter of DataServiceProvider type, which is used to handle the actual oData requests.
Class DataService<Provider: DataServiceProvider>
Then in the application, a derived class of DataService will call various methods (executeQuery etc) implemented by ODataProvider to manage proxy class objects (derived from EntityValue class), like Customers, Products. The DataService class manages the proxy class object through DataQuery class, which represents a standard SQL statement. To create DataService object, the constructor needs parameters to provide serviceRoot url, a urlSession to authenticate with backend, and a service name. The service name does not matter for online cases.
If offlineDataServiceProvider is used as generic parameter to create DataService, when first time calling open method, it will download the database from HCP MobileService, and once the offline database is created, calling the same method again will just open the existing database without sending any requests to server, so the open and following DataQuery methods will work even if the device is offline.
Class DataQuery
DataQuery class is used to specified a SQL query, such as what columns to be selected, what is the order or where conditions.
Note, although the client can choose either using online or offline OData provider, the SAP cloud platform mobile service does not have any difference in application configuration regardless which one is selected on client side. As long as the server provides a valid oData service, then the client can work with it.
No comments:
Post a Comment