GeodatabaseSyncTask Class

  • GeodatabaseSyncTask
  • class Esri::ArcGISRuntime::GeodatabaseSyncTask

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

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

    This class was introduced in Esri::ArcGISRuntime 100.0.

    Public Functions

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

    Reimplemented Public Functions

    virtual QString apiKey() const override
    virtual void cancelLoad() override
    virtual Esri::ArcGISRuntime::Credential *credential() const override
    virtual void load() override
    virtual Esri::ArcGISRuntime::Error loadError() const override
    virtual Esri::ArcGISRuntime::LoadStatus loadStatus() const override
    virtual Esri::ArcGISRuntime::RequestConfiguration requestConfiguration() const override
    virtual void retryLoad() override
    virtual void setApiKey(const QString &apiKey) override
    virtual void setRequestConfiguration(const Esri::ArcGISRuntime::RequestConfiguration &requestConfiguration) override
    virtual QUrl url() const override

    Signals

    void defaultGenerateGeodatabaseParametersCompleted(QUuid taskId, Esri::ArcGISRuntime::GenerateGeodatabaseParameters defaultGenerateParameters)
    void defaultSyncGeodatabaseParametersCompleted(QUuid taskId, Esri::ArcGISRuntime::SyncGeodatabaseParameters defaultSyncParameters)
    void doneLoading(Esri::ArcGISRuntime::Error loadError)
    void exportDeltaCompleted(QUuid taskId, bool deltaFileCreated)
    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

    Esri::ArcGISRuntime::TaskWatcher exportDelta(Esri::ArcGISRuntime::Geodatabase *geodatabase, const QString &outputPath)
    Esri::ArcGISRuntime::TaskWatcher importGeodatabaseDelta(Esri::ArcGISRuntime::Geodatabase *geodatabase, const QString &pathToDeltaFile)
    Esri::ArcGISRuntime::GeodatabaseSyncTask *instance()

    Detailed Description

    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, Esri::ArcGISRuntime::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(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).

    [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.

    [signal] void GeodatabaseSyncTask::exportDeltaCompleted(QUuid taskId, bool deltaFileCreated)

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

    • taskId - The ID of the completed task.
    • deltaFileCreated - Whether a delta file was successfully exported.

    See also exportDelta().

    [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().

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

    Signal emitted when the load status changes for this object.

    See also Loadable.

    [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.

    [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.

    [override virtual] GeodatabaseSyncTask::~GeodatabaseSyncTask()

    Destructor.

    [override virtual] QString GeodatabaseSyncTask::apiKey() const

    Reimplements: ApiKeyResource::apiKey() const.

    Returns the API key. See ApiKeyResource.

    See also setApiKey().

    [override virtual] void GeodatabaseSyncTask::cancelLoad()

    Reimplements: Loadable::cancelLoad().

    See Loadable.

    Esri::ArcGISRuntime::TaskWatcher GeodatabaseSyncTask::createDefaultGenerateGeodatabaseParameters(const Esri::ArcGISRuntime::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 canceled.

    Esri::ArcGISRuntime::TaskWatcher GeodatabaseSyncTask::createDefaultSyncGeodatabaseParameters(Esri::ArcGISRuntime::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.

    Esri::ArcGISRuntime::TaskWatcher GeodatabaseSyncTask::createDefaultSyncGeodatabaseParameters(Esri::ArcGISRuntime::Geodatabase *geodatabase, Esri::ArcGISRuntime::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.

    [override virtual] Esri::ArcGISRuntime::Credential *GeodatabaseSyncTask::credential() const

    Reimplements: RemoteResource::credential() const.

    Returns the security credential used to access the service.

    Only applicable if using an service that is secured.

    [static] Esri::ArcGISRuntime::TaskWatcher GeodatabaseSyncTask::exportDelta(Esri::ArcGISRuntime::Geodatabase *geodatabase, const QString &outputPath)

    Returns an upload delta geodatabase file containing all the changes since the last sync.

    • geodatabase - The geodatabase to generate a delta from.
    • outputPath - The path and filename to save the generated delta to.

    A delta geodatabase contains the changes that have occurred since a mobile replica Geodatabase was last synchronized with the feature service. See https://developers.arcgis.com/rest/services-reference/enterprise/synchronize-replica.htm for an overview of the delta files used in synchronization. An "upload" delta geodatabase contains the local edits, performed on the user's device, to be sent to the originating feature service.

    When you run this task, any local edits in the Geodatabase will be exported to the specified output path. The output path should include the full path and file name (ending in ".geodatabase") for the export.

    The delta file created by this method is not sent to the server and has no impact on any subsequent sync job. You can call this method repeatedly without affecting the state of the local geodatabase.

    You should not execute more than one sync on a particular geodatabase at the same time. This includes any operations that export or import deltas from the local Geodatabase:

    The task returned by this method has a Boolean result that indicates whether or not a delta geodatabase was created.

    Returns a TaskWatcher for the asynchronous operation.

    This function was introduced in Esri::ArcGISRuntime 100.10.

    See also SyncGeodatabaseParameters::isKeepGeodatabaseDeltas.

    Esri::ArcGISRuntime::ArcGISFeatureServiceInfo GeodatabaseSyncTask::featureServiceInfo() const

    Returns metadata about the service.

    Esri::ArcGISRuntime::GenerateGeodatabaseJob *GeodatabaseSyncTask::generateGeodatabase(const Esri::ArcGISRuntime::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] Esri::ArcGISRuntime::TaskWatcher GeodatabaseSyncTask::importGeodatabaseDelta(Esri::ArcGISRuntime::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.

    A delta geodatabase contains the changes that have occurred since a mobile replica Geodatabase was last-synchronized with the feature service. See https://developers.arcgis.com/rest/services-reference/enterprise/synchronize-replica.htm for an overview of the delta files used in synchronization. A "download" delta geodatabase contains the online edits that will be imported to the local geodatabase.

    You should not execute more than one sync on a particular geodatabase at the same time. This includes any operations that export or import deltas from the local Geodatabase:

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

    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);

    [static] Esri::ArcGISRuntime::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.

    [override virtual] void GeodatabaseSyncTask::load()

    Reimplements: Loadable::load().

    See Loadable.

    [override virtual] Esri::ArcGISRuntime::Error GeodatabaseSyncTask::loadError() const

    Reimplements: Loadable::loadError() const.

    See Loadable.

    [override virtual] Esri::ArcGISRuntime::LoadStatus GeodatabaseSyncTask::loadStatus() const

    Reimplements: Loadable::loadStatus() const.

    See Loadable.

    Esri::ArcGISRuntime::TaskWatcher GeodatabaseSyncTask::registerSyncEnabledGeodatabase(Esri::ArcGISRuntime::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 its 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.

    [override virtual] Esri::ArcGISRuntime::RequestConfiguration GeodatabaseSyncTask::requestConfiguration() const

    Reimplements: RemoteResource::requestConfiguration() const.

    Returns the RequestConfiguration in use by this task.

    This function was introduced in Esri::ArcGISRuntime 100.1.

    See also setRequestConfiguration().

    [override virtual] void GeodatabaseSyncTask::retryLoad()

    Reimplements: Loadable::retryLoad().

    See Loadable.

    [override virtual] void GeodatabaseSyncTask::setApiKey(const QString &apiKey)

    Reimplements: ApiKeyResource::setApiKey(const QString &apiKey).

    Sets the API key to apiKey. See ApiKeyResource.

    See also apiKey().

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

    Reimplements: RemoteResource::setRequestConfiguration(const Esri::ArcGISRuntime::RequestConfiguration &requestConfiguration).

    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().

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

    Returns a job to synchronize a geodatabase back to a service.

    • parameters - Parameters to use to sync the geodatabase.
    • geodatabase - The geodatabase to sync.

    For a successfully completed job the job's result returns an array of SyncLayerResult, typically the array is empty. If individual edits failed then the result array provides these errors grouped by each table using SyncLayerResult instances which in turn contain each edit error.

    You should not execute more than one sync on a particular geodatabase at the same time. This includes any operations that export or import deltas from the local Geodatabase, which are:

    See also Job.

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

    Returns a job to sync a mobile geodatabase with its originating ArcGIS Feature service using the given sync direction and rollback on failure Boolean value.

    • 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 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.

    If the given sync direction is not compatible with the sync task's feature service, the returned job will fail.

    You should not execute more than one sync on a particular geodatabase at the same time. This includes any operations that export or import deltas from the local Geodatabase:

    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.

    Esri::ArcGISRuntime::TaskWatcher GeodatabaseSyncTask::unregisterGeodatabase(Esri::ArcGISRuntime::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 canceled.

    Esri::ArcGISRuntime::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 canceled.

    This function was introduced in Esri::ArcGISRuntime 100.2.

    [override virtual] QUrl GeodatabaseSyncTask::url() const

    Reimplements: RemoteResource::url() const.

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

    Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.