public class

GeodatabaseSyncTask

extends Object
java.lang.Object
   ↳ com.esri.core.tasks.geodatabase.GeodatabaseSyncTask

Class Overview

The GeodatabaseSyncTask class is for managing the offline usage of ArcGIS services.

The class contains methods for requesting geodatabases from an ArcGIS service which can be used when the application is used in an offline environment. The geodatabases can be used for querying and viewing feature data. Geodatabases can also be edited in the offline environment. Geodatabases for editing can only be requested if the ArcGIS service supports synchronisation.

Geodatabases can be synchronized with the ArcGIS service when the application is able to connect to a network again. Synchronisation performs 2 tasks:

  • uploads changes made on the application whilst offline to the ArcGIS service.
  • downloads changes made on the ArcGIS service to the geodatabase.

Summary

Constants
String GENERATE_GDB_REQUEST_RECOVERY_INFO_DIR
String SYNC_GDB_REQUEST_RECOVERY_INFO_DIR
Public Constructors
GeodatabaseSyncTask(String serviceUrl, UserCredentials credentials)
Instantiates a GeodatabaseTask to a given ArcGIS service.
Public Methods
Future<FeatureServiceInfo> fetchFeatureServiceInfo(CallbackListener<FeatureServiceInfo> callback)
Fetches the FeatureServiceInfo asynchronously from the service.
FeatureServiceInfo fetchFeatureServiceInfo()
Fetches the FeatureServiceInfo synchronously from the service.
Future<String> generateGeodatabase(GenerateGeodatabaseParameters params, String fileName, boolean useCachedJob, GeodatabaseStatusCallback statusCallback, CallbackListener<String> geodatabaseResponseCallback)
This method requests the geodatabase, polls the server to get the current status and then downloads the file when it is ready for you.
Future<GeodatabaseStatusInfo> registerGeodatabase(Geodatabase geodatabase, GeodatabaseStatusCallback statusCallback, CallbackListener<GeodatabaseStatusInfo> responseCallback)
This method registers an existing sync enabled geodatabase with a feature service as a new instance so that edits can be synced.
Future<Map<Integer, GeodatabaseFeatureTableEditErrors>> syncGeodatabase(SyncGeodatabaseParameters params, Geodatabase geodatabase, GeodatabaseStatusCallback statusCallback, CallbackListener<Map<Integer, GeodatabaseFeatureTableEditErrors>> syncResponseCallback)
This method runs the entire sync process.
Future<GeodatabaseTaskResult> unregisterGeodatabase(Geodatabase geodatabase, CallbackListener<GeodatabaseTaskResult> completedCallback)
This unregisters the given geodatabase from the server.
Future<GeodatabaseTaskResult> unregisterGeodatabase(String geodatabaseId, CallbackListener<GeodatabaseTaskResult> completedCallback)
This unregisters the current geodatabase from the server and therefore any local edits will be lost and no further syncs can be made until the geodatabase has been registered (by calling registerGeodatabase(Geodatabase, GeodatabaseStatusCallback, CallbackListener) It also allows the geodatabase to be shared with others, and in fact it MUST be called on a geodatabase before it is shared with others (and they register the geodatabase before using it).
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String GENERATE_GDB_REQUEST_RECOVERY_INFO_DIR

Constant Value: "GenerateGdbRequest"

public static final String SYNC_GDB_REQUEST_RECOVERY_INFO_DIR

Constant Value: "SyncGdbRequest"

Public Constructors

public GeodatabaseSyncTask (String serviceUrl, UserCredentials credentials)

Instantiates a GeodatabaseTask to a given ArcGIS service.

Parameters
serviceUrl String: for the ArcGIS service
credentials UserCredentials: for accessing the service. If no credentials are needed then supply null.

Public Methods

public Future<FeatureServiceInfo> fetchFeatureServiceInfo (CallbackListener<FeatureServiceInfo> callback)

Fetches the FeatureServiceInfo asynchronously from the service. The FeatureServiceInfo allows access to the synchronization capabilities of the service.

Parameters
callback CallbackListener: The callback that fires when the FeatureServiceInfo has been fetched or an error occurred.
Returns
Future<FeatureServiceInfo> A Future that allows cancellation of the async request as well as retrieving the FeatureServiceInfo result.

public FeatureServiceInfo fetchFeatureServiceInfo ()

Fetches the FeatureServiceInfo synchronously from the service. Performs a network request on the current thread, so do not call this from the UI thread.

Returns
FeatureServiceInfo The FeatureServiceInfo.
Throws
Exception If unable to complete the request.

public Future<String> generateGeodatabase (GenerateGeodatabaseParameters params, String fileName, boolean useCachedJob, GeodatabaseStatusCallback statusCallback, CallbackListener<String> geodatabaseResponseCallback)

This method requests the geodatabase, polls the server to get the current status and then downloads the file when it is ready for you. If the process that is running this method quits, the download will be resumed the next time this method is called. Note that for this to work we need to make sure that the parameters in params are exactly the same as when this method was last run.

The geodatabaseResponseCallback (and the future returned by this method) will return a string. If the geodatabase is successfully downloaded and renamed, this string will match fileName. If this method fails to rename the geodatabase file (file already exists and is read only for some reason) then the string will be the name of the downloaded file.

Parameters
params GenerateGeodatabaseParameters: the parameters for generation of geodatabase.
fileName String: the file name to save the downloaded geodatabase to. If this file already exists it will be over written if possible.
useCachedJob boolean: if true attempt to resume the request if the params match a previous request
statusCallback GeodatabaseStatusCallback: a callback which fires when the status of the task changes
geodatabaseResponseCallback CallbackListener: a callback which fires when the task has completed or failed.
Returns
Future<String> A Future which allows you want to cancel the task at any time by using future.cancel

public Future<GeodatabaseStatusInfo> registerGeodatabase (Geodatabase geodatabase, GeodatabaseStatusCallback statusCallback, CallbackListener<GeodatabaseStatusInfo> responseCallback)

This method registers an existing sync enabled geodatabase with a feature service as a new instance so that edits can be synced. This allows sharing of sync enabled geodatabases. The geodatabase passed to this method must return true from isSyncEnabled().

Parameters
geodatabase Geodatabase: the geodatabase which is to be registered
statusCallback GeodatabaseStatusCallback: fires whenever the current status is updated
responseCallback CallbackListener: fires when the operations completes of fails
Returns
Future<GeodatabaseStatusInfo> Future status
Throws
Exception
IOException
IOException
Exception

public Future<Map<Integer, GeodatabaseFeatureTableEditErrors>> syncGeodatabase (SyncGeodatabaseParameters params, Geodatabase geodatabase, GeodatabaseStatusCallback statusCallback, CallbackListener<Map<Integer, GeodatabaseFeatureTableEditErrors>> syncResponseCallback)

This method runs the entire sync process. It sends changes to the server, polls the server at a predefined interval to determine the status, then downloads the sync results and applies them to your geodatabase. If the application which calls this method is quit while this process is running, it should recall this method with the same params and the job will be restarted (as long as the geodatabase is still available on the server (clean out time) and will continue where it left off.

The Map returned by this method contains an entry for each layer with sync. errors. The sync. errors, if any, are contained in a GeodatabaseFeatureTableEditErrors instance which has properties for returning the details of any feature or attachment edit errors. On network interruption, an exception is thrown in syncResponseCallback. ServerError is returned in geodatabaseStatusCallback if failure is from ArcGIS Server.

Parameters
params SyncGeodatabaseParameters: for the synchronisation job. These can be obtained from the geodatabase class.
geodatabase Geodatabase: the geodatabase to be synchronised
statusCallback GeodatabaseStatusCallback: callback which fires every time the status of the job changes.
syncResponseCallback CallbackListener: callback fires when the job completes or fails.
Returns
Future<Map<Integer, GeodatabaseFeatureTableEditErrors>> Future> future that can be used to get the result or cancel execution

public Future<GeodatabaseTaskResult> unregisterGeodatabase (Geodatabase geodatabase, CallbackListener<GeodatabaseTaskResult> completedCallback)

This unregisters the given geodatabase from the server. Once this operation has been carried out, it will not be possible to use the geodatabase and it should be deleted.

Parameters
geodatabase Geodatabase: the geodatabase to unregister
completedCallback CallbackListener: the completed callback that will be called when the geodatabase is unregistered. The GeodatabaseTaskResult returned will indicate success or failure. If the geodatabase fails to unregister, an error message is provided.
Returns
Future<GeodatabaseTaskResult> the future providing an alternative means of getting the result. Can also be used to cancel the task.
Throws
Exception the exception

public Future<GeodatabaseTaskResult> unregisterGeodatabase (String geodatabaseId, CallbackListener<GeodatabaseTaskResult> completedCallback)

This unregisters the current geodatabase from the server and therefore any local edits will be lost and no further syncs can be made until the geodatabase has been registered (by calling registerGeodatabase(Geodatabase, GeodatabaseStatusCallback, CallbackListener) It also allows the geodatabase to be shared with others, and in fact it MUST be called on a geodatabase before it is shared with others (and they register the geodatabase before using it).

Parameters
geodatabaseId String: the geodatabase id of the geodatabase to unregister
completedCallback CallbackListener: the completed callback that will be called when the geodatabase is unregistered. The GeodatabaseTaskResult returned will indicate success or failure. If the geodatabase fails to unregister, an error message is provided.
Returns
Future<GeodatabaseTaskResult> the future providing an alternative means of getting the result. Can also be used to cancel the task.