Skip To Content ArcGIS for Developers Sign In Dashboard

GeodatabaseSyncTask Class

(Esri::ArcGISRuntime::GeodatabaseSyncTask)

A task to download or sync a sync-enabled mobile geodatabase. More...

Header: #include <GeodatabaseSyncTask>
Since: Esri::ArcGISRuntime 100.0
Inherits: Object, Loadable, and RemoteResource

Public Functions

GeodatabaseSyncTask(const QUrl &url, QObject *parent = nullptr)
GeodatabaseSyncTask(const QUrl &url, Credential *credential, QObject *parent = nullptr)
~GeodatabaseSyncTask()
TaskWatcher createDefaultGenerateGeodatabaseParameters(const Geometry &extent)
TaskWatcher createDefaultSyncGeodatabaseParameters(Geodatabase *geodatabase)
TaskWatcher createDefaultSyncGeodatabaseParameters(Geodatabase *geodatabase, SyncDirection syncDirection)
ArcGISFeatureServiceInfo featureServiceInfo() const
GenerateGeodatabaseJob *generateGeodatabase(const GenerateGeodatabaseParameters &parameters, const QString &pathToGeodatabaseFile)
TaskWatcher registerSyncEnabledGeodatabase(Geodatabase *geodatabase)
SyncGeodatabaseJob *syncGeodatabase(const SyncGeodatabaseParameters &parameters, Geodatabase *geodatabase)
SyncGeodatabaseJob *syncGeodatabase(SyncDirection syncDirection, bool rollbackOnFailure, Geodatabase *geodatabase)
TaskWatcher unregisterGeodatabase(Geodatabase *geodatabase)
TaskWatcher unregisterGeodatabase(const QUuid &syncId)

Reimplemented Public Functions

virtual void cancelLoad()
virtual Credential *credential() const
virtual void load()
virtual Error loadError() const
virtual LoadStatus loadStatus() const
virtual RequestConfiguration requestConfiguration() const
virtual void retryLoad()
virtual void setRequestConfiguration(const RequestConfiguration &requestConfiguration)
virtual QUrl url() const

Signals

void defaultGenerateGeodatabaseParametersCompleted(QUuid taskId, Esri::ArcGISRuntime::GenerateGeodatabaseParameters defaultGenerateParameters)
void defaultSyncGeodatabaseParametersCompleted(QUuid taskId, Esri::ArcGISRuntime::SyncGeodatabaseParameters defaultSyncParameters)
void doneLoading(Esri::ArcGISRuntime::Error loadError)
void importGeodatabaseDeltaCompleted(QUuid taskId, const QList<Esri::ArcGISRuntime::SyncLayerResult *> &syncLayerResults)
void loadStatusChanged(Esri::ArcGISRuntime::LoadStatus loadStatus)
void registerSyncEnabledGeodatabaseCompleted(QUuid taskId)
void unregisterGeodatabaseCompleted(QUuid taskId)

Static Public Members

TaskWatcher importGeodatabaseDelta(Geodatabase *geodatabase, const QString &pathToDeltaFile)
GeodatabaseSyncTask *instance()
  • 10 static public members inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 public variable inherited from QObject
  • 9 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

A task to download or sync a sync-enabled mobile geodatabase.

Mobile geodatabases are designed for querying and viewing feature data when your app is offline. In addition, while offline your app can edit a geodatabase locally and later sync changes with the service, assuming that the associated service supports sync. While offline, the mobile geodatabase keeps track of local edits. When those edits are synchronized with the service, local edits are sent to the service and changes made on the service in the meantime by other processes are received into the mobile geodatabase.

You can create a mobile geodatabase on your device by downloading it from a sync-enabled ArcGIS feature service. If the geodatabase is sync-enabled, you can sync it with the sync-enabled service from which it was created (its associated service) by registering the mobile geodatabase with the service. The GeodatabaseSyncTask supports creating a geodatabase via downloading from a service, and syncing a sync-enabled geodatabase with its associated service.

Another option is to provision a copy of a sync-enabled mobile geodatabase onto your device by loading it onto your device's file system. Register this geodatabase with the associated service, which gives the geodatabase copy its own replica ID. This identifies the geodatabase copy differently from the original geodatabase, and making the copy sync-able with the service.

GeodatabaseSyncTask also allows you to unregister a geodatabase, which permanently prevents sync of that mobile geodatabase with its associated service. Unregistered geodatabases cannot be re-registered.

The associated service may be hosted in the cloud on ArcGIS Online or on-premises with ArcGIS Server. Your app must have network access to the service in order to download or sync with the service.

Member Function Documentation

GeodatabaseSyncTask::GeodatabaseSyncTask(const QUrl &url, QObject *parent = nullptr)

Constructs a GeodatabaseSyncTask with a URL.

  • url - The URL of the sync-enabled ArcGIS feature service.
  • parent - The parent object for this GeodatabaseSyncTask (optional).

GeodatabaseSyncTask::GeodatabaseSyncTask(const QUrl &url, Credential *credential, QObject *parent = nullptr)

Constructs a GeodatabaseSyncTask with a URL and a credential.

  • url - The URL of the sync-enabled ArcGIS feature service.
  • credential - The credential.
  • parent - The parent object for this GeodatabaseSyncTask (optional).

GeodatabaseSyncTask::~GeodatabaseSyncTask()

Destructor.

[virtual] void GeodatabaseSyncTask::cancelLoad()

Reimplemented from Loadable::cancelLoad().

See Loadable.

TaskWatcher GeodatabaseSyncTask::createDefaultGenerateGeodatabaseParameters(const Geometry &extent)

Starts a task to get properly initialized parameters for generating a geodatabase based on the specified extent.

This convenience method populates a GenerateGeodatabaseParameters object with values based on defaults and on what the service supports. The GenerateGeodatabaseParameters is returned to the app through the signal defaultGenerateGeodatabaseParametersCompleted.

  • If the service does not support SyncModel::Layer then SyncModel::Geodatabase will be used.
    • All layers from the service will be included.
    • The extent will be the service's full extent.
  • Features inside the provided extent are included in the generated geodatabase.
  • Output features are in the spatial reference of the given extent.
  • Attachments are included.
  • Related tables and layers are not included.

Returns a TaskWatcher for the operation. The operation can be cancelled.

TaskWatcher GeodatabaseSyncTask::createDefaultSyncGeodatabaseParameters(Geodatabase *geodatabase)

Starts a task to get properly initialized parameters for syncing a geodatabase with its service.

  • geodatabase - The geodatabase that will be synced.

This convenience method will populate the parameters with values matching what the service and the geodatabase support.

  • For a geodatabase using SyncModel::Layer, all layers will be included.
  • For a read-only service, the sync direction will be SyncDirection::Download. Otherwise, the sync direction will be SyncDirection::Bidirectional.

TaskWatcher GeodatabaseSyncTask::createDefaultSyncGeodatabaseParameters(Geodatabase *geodatabase, SyncDirection syncDirection)

Starts a task to get properly initialized parameters for syncing a geodatabase with its service using the specified sync direction.

  • geodatabase - The geodatabase that will be synced.
  • syncDirection - The preferred sync direction.

This convenience method will populate the parameters with values matching what the service and the geodatabase support.

  • For a geodatabase using SyncModel::Layer, all layers will be included.
  • For a read-only service, the sync direction will be SyncDirection::Download. Otherwise, the sync direction will be set based on the syncDirection parameter.

This function was introduced in Esri::ArcGISRuntime 100.3.

[virtual] Credential *GeodatabaseSyncTask::credential() const

Reimplemented from RemoteResource::credential().

Returns the security credential used to access the service.

Only applicable if using an service that is secured.

[signal] void GeodatabaseSyncTask::defaultGenerateGeodatabaseParametersCompleted(QUuid taskId, Esri::ArcGISRuntime::GenerateGeodatabaseParameters defaultGenerateParameters)

Signal emitted when the task completes that generates the default GenerateGeodatabaseParameters.

  • taskId - The ID of the completed task.
  • defaultGenerateParameters - The generated parameters.

See also createDefaultGenerateGeodatabaseParameters().

[signal] void GeodatabaseSyncTask::defaultSyncGeodatabaseParametersCompleted(QUuid taskId, Esri::ArcGISRuntime::SyncGeodatabaseParameters defaultSyncParameters)

Signal emitted when the task completes that generates the default SyncGeodatabaseParameters.

  • taskId - The ID of the completed task.
  • defaultSyncParameters - The generated parameters.

See also createDefaultSyncGeodatabaseParameters().

[signal] void GeodatabaseSyncTask::doneLoading(Esri::ArcGISRuntime::Error loadError)

Signal emitted when this object is done loading.

  • loadError - Details about any error that may have occurred.

Note: If there is a load error it will also be emitted on the errorOccurred signal.

See also Loadable and Object.

ArcGISFeatureServiceInfo GeodatabaseSyncTask::featureServiceInfo() const

Returns metadata about the service.

GenerateGeodatabaseJob *GeodatabaseSyncTask::generateGeodatabase(const GenerateGeodatabaseParameters &parameters, const QString &pathToGeodatabaseFile)

Returns a job to generate a mobile geodatabase from an ArcGIS Feature service.

  • parameters - Parameters specifying what information to include in the geodatabase.
  • pathToGeodatabaseFile - Where to save the geodatabase on the local file system.

The result of the job will be of type Geodatabase.

The pathToGeodatabaseFile can specify a path for the downloaded geodatabase, including the desired name and the .geodatabase file extension. Or, pathToGeodatabaseFile can be a filename only, in which case the file extension is added and the geodatabase is stored in the user's Documents folder.

A GenerateGeodatabaseJob representing the progress on the server is returned.

The returned job is in the JobStatus::NotStarted state. Start it by calling Job::start().

The job should be deleted after completion.

See also Job.

[static] TaskWatcher GeodatabaseSyncTask::importGeodatabaseDelta(Geodatabase *geodatabase, const QString &pathToDeltaFile)

Imports a geodatabase delta and applies it to the given geodatabase.

  • geodatabase - The mobile geodatabase to apply the import to.
  • pathToDeltaFile - The path to delta file on the local file system to import the delta from.

Returns a TaskWatcher for the operation. The operation can be cancelled.

Note: Before 100.3, this function was not static and must be called from object. Since 100.3, this function should be used as static function, with instance() to connect to signals.

connect(GeodatabaseSyncTask::instance(), &GeodatabaseSyncTask::importGeodatabaseDeltaCompleted, [](QUuid, QList<SyncLayerResult*> results)
{
  // use results
    qDeleteAll(results);
});

GeodatabaseSyncTask::importGeodatabaseDelta(&geodatabase, deltaPath);

[signal] void GeodatabaseSyncTask::importGeodatabaseDeltaCompleted(QUuid taskId, const QList<Esri::ArcGISRuntime::SyncLayerResult *> &syncLayerResults)

Signal emitted when the task completes that imports a geodatabase delta.

  • taskId - The ID of the completed task.
  • syncLayerResults - The list of SyncLayerResult objects per layer that indicate the results of importing this delta.

The returned SyncLayerResult objects have the GeodatabaseSyncTask as their parent.

See also Returned QObjects Parenting and importGeodatabaseDelta().

[static] GeodatabaseSyncTask *GeodatabaseSyncTask::instance()

Returns an instance of the GeodatabaseSyncTask singleton.

The instance is used to connect to the Object::errorOccurred, and importGeodatabaseDeltaCompleted signals. You do not need to obtain the instance to call the static methods on the GeodatabaseSyncTask.

This function was introduced in Esri::ArcGISRuntime 100.3.

[virtual] void GeodatabaseSyncTask::load()

Reimplemented from Loadable::load().

See Loadable.

[virtual] Error GeodatabaseSyncTask::loadError() const

Reimplemented from Loadable::loadError().

See Loadable.

[virtual] LoadStatus GeodatabaseSyncTask::loadStatus() const

Reimplemented from Loadable::loadStatus().

See Loadable.

[signal] void GeodatabaseSyncTask::loadStatusChanged(Esri::ArcGISRuntime::LoadStatus loadStatus)

Signal emitted when the load status changes for this object.

See also Loadable.

TaskWatcher GeodatabaseSyncTask::registerSyncEnabledGeodatabase(Geodatabase *geodatabase)

Starts a task to register a copy of a sync enabled geodatabase with a service so the copy can sync to the service.

The local geodatabase file is typically a copy of another original geodatabase file. The original geodatabase must already be known to the service and have a replica ID. A successful register will give the local geodatabase it's own replica ID and separate it from the original. It can then be synchronized with the service to receive updates. After taking copies of the original database, do not sync changes to the original until all copies have been registered. This operation is not related to GeodatabaseSyncTask::unregisterGeodatabase which removes the geodatabase from the service.

[signal] void GeodatabaseSyncTask::registerSyncEnabledGeodatabaseCompleted(QUuid taskId)

Signal emitted when the task completes that registers the mobile geodatabase.

  • taskId - The ID of the completed task.

See also registerSyncEnabledGeodatabase.

[virtual] RequestConfiguration GeodatabaseSyncTask::requestConfiguration() const

Reimplemented from RemoteResource::requestConfiguration().

Returns the RequestConfiguration in use by this task.

This function was introduced in Esri::ArcGISRuntime 100.1.

See also setRequestConfiguration().

[virtual] void GeodatabaseSyncTask::retryLoad()

Reimplemented from Loadable::retryLoad().

See Loadable.

[virtual] void GeodatabaseSyncTask::setRequestConfiguration(const RequestConfiguration &requestConfiguration)

Reimplemented from RemoteResource::setRequestConfiguration().

Sets configuration parameters used for network requests sent by this task to requestConfiguration.

This function was introduced in Esri::ArcGISRuntime 100.1.

See also requestConfiguration().

SyncGeodatabaseJob *GeodatabaseSyncTask::syncGeodatabase(const SyncGeodatabaseParameters &parameters, Geodatabase *geodatabase)

Returns a job to sync a mobile geodatabase with its originating ArcGIS Feature service.

  • parameters - Parameters specifying how to sync the geodatabase.
  • geodatabase - The geodatabase to sync with the service.

The result of the job will be a list of SyncLayerResult objects. This list will be empty for a successfully completed job. If individual edits failed then the result array provides these errors grouped by each table using SyncLayerResult instances. These contain information for each edit error as a FeatureEditResult.

A SyncGeodatabaseJob representing the progress on the server is returned.

The returned job is in the JobStatus::NotStarted state. Start it by calling Job::start().

The job should be deleted after completion.

See also Job.

SyncGeodatabaseJob *GeodatabaseSyncTask::syncGeodatabase(SyncDirection syncDirection, bool rollbackOnFailure, Geodatabase *geodatabase)

Returns a job to sync a mobile geodatabase with its originating ArcGIS Feature service using provided sync direction.

  • syncDirection - The preferred sync direction.
  • rollbackOnFailure - Whether to roll back edits when a failure occurs.
  • geodatabase - The geodatabase to sync with the service.

The result of the job will be a list of SyncLayerResult objects. This list will be empty for a successfully completed job. If individual edits failed then the result array provides these errors grouped by each table using SyncLayerResult instances. These contain information for each edit error as a FeatureEditResult.

If rollbackOnFailure is false, then failed edits are skipped. Other edits are still applied. This property only applies to edits uploaded by the client to the server. It does not apply to edits imported by client from the server.

A SyncGeodatabaseJob representing the progress on the server is returned. The returned job is in the JobStatus::NotStarted state. Start it by calling Job::start().

The job should be deleted after completion.

This function was introduced in Esri::ArcGISRuntime 100.3.

See also Job.

TaskWatcher GeodatabaseSyncTask::unregisterGeodatabase(Geodatabase *geodatabase)

Starts a task to unregister an existing sync-enabled mobile geodatabase from the service.

  • geodatabase - The mobile geodatabase to unregister.

This removes the geodatabase's replica ID from the service, which means the geodatabase can no longer be synchronized with the service. The local geodatabase is not deleted and remains on the local file system.

Returns a TaskWatcher for the operation. The operation can be cancelled.

TaskWatcher GeodatabaseSyncTask::unregisterGeodatabase(const QUuid &syncId)

Starts a task to unregister an existing sync-enabled mobile geodatabase from the service.

This removes the geodatabase's replica ID from the service, which means the geodatabase can no longer be synchronized with the service. The local geodatabase remains on the local file system.

Returns a TaskWatcher for the operation. The operation can be cancelled.

This function was introduced in Esri::ArcGISRuntime 100.2.

[signal] void GeodatabaseSyncTask::unregisterGeodatabaseCompleted(QUuid taskId)

Signal emitted when the task completes that unregisters the mobile geodatabase.

  • taskId - The ID of the completed task.

See also unregisterGeodatabase.

[virtual] QUrl GeodatabaseSyncTask::url() const

Reimplemented from RemoteResource::url().

Returns the URL to a sync-enabled ArcGIS Feature service.


Feedback on this topic?