Refresh Status¶
You can fetch the server-side refresh statuses of your shared defining requests. The refresh status indicates both the timestamp of the last server-side refresh and the configured refresh interval, providing users with insights into data freshness.
Fetching Refresh Status¶
To fetch refresh statuses, invoke fetchDefiningRequestRefreshStatuses on your OfflineODataProvider instance. The operation runs asynchronously, delivering results through the OfflineODataProviderDelegate. For more information about OfflineODataProviderDelegate, see Progress API.
// fetchDefiningRequestRefreshStatuses can only be called asynchronously.
// The first parameter is the success handler and the second
// parameter is the failure handler with the exception encountered
// as the parameter.
offlineODataProvider.fetchDefiningRequestRefreshStatuses(
() -> {
// Handle the result in the delegate callback updateDefiningRequestRefreshStatuses
...
},
(error) -> {
// Handle the error, for example logging the error
...
}
);
// fetchDefiningRequestRefreshStatuses is a suspend function.
// Call it from a coroutine context.
offlineODataProvider.fetchDefiningRequestRefreshStatuses()
// Handle the result in the delegate callback updateDefiningRequestRefreshStatuses
/// fetchDefiningRequestRefreshStatuses is an async throwing function.
/// Call it from an async context.
try await offlineODataProvider.fetchDefiningRequestRefreshStatuses()
/// Handle the result in the delegate callback offlineODataProvider(_:didFetchDefiningRequestRefreshStatuses:error:)
Handling the Result¶
Implement the appropriate method in your OfflineODataProviderDelegate to receive the result:
@Override
public void updateDefiningRequestRefreshStatuses(@NonNull OfflineODataProvider provider, @NonNull List<OfflineODataEndpointRefreshStatus> statuses, @Nullable OfflineODataException error) {
if (error != null) {
// Handle the error, for example logging the error
...
return;
}
for (OfflineODataEndpointRefreshStatus endpoint : statuses) {
for (OfflineODataDefiningRequestRefreshStatus query : endpoint.getQueries()) {
String name = query.getDefiningQueryName();
GlobalDateTime lastUpdated = query.getLastUpdatedTime();
Integer interval = query.getRefreshInterval();
...
}
}
}
override fun updateDefiningRequestRefreshStatuses(provider: OfflineODataProvider, statuses: List<OfflineODataEndpointRefreshStatus>, error: OfflineODataException?) {
if (error != null) {
// Handle the error, for example logging the error
...
return
}
for (endpoint in statuses) {
for (query in endpoint.queries) {
val name = query.definingQueryName
val lastUpdated = query.lastUpdatedTime
val interval = query.refreshInterval
...
}
}
}
public func offlineODataProvider(_ provider: OfflineODataProvider, didFetchDefiningRequestRefreshStatuses statuses: [OfflineODataEndpointRefreshStatus], error: OfflineODataError?) {
if let error = error {
/// Handle the error, for example logging the error
...
return
}
for endpoint in statuses {
for query in endpoint.queries {
let name = query.definingQueryName
let lastUpdated = query.lastUpdatedTime
let interval = query.refreshInterval
...
}
}
}
The error parameter is set if the operation fails, in which case the statuses list is empty.
The refresh status information is represented by two objects.
-
OfflineODataEndpointRefreshStatusRepresents a single endpoint. TheendpointNameproperty specifies the name of the endpoint, while thequeriesproperty holds anOfflineODataDefiningRequestRefreshStatusobject for each defining request configured for that endpoint. -
OfflineODataDefiningRequestRefreshStatusRepresents the refresh status of a single defining request. Available properties include:
| Property | Description |
|---|---|
definingQueryName |
The name of the defining query |
lastUpdatedTime |
The timestamp of the last server-side refresh. Null if the defining request has never been refreshed. |
refreshInterval |
The configured refresh interval in minutes. Null if no refresh interval is configured. |