Class Geodatabase

  • All Implemented Interfaces:
    Loadable

    public final class Geodatabase
    extends java.lang.Object
    implements Loadable
    A mobile geodatabase containing offline feature data.

    The Geodatabase class is used for opening and accessing the contents of a mobile geodatabase. A geodatabase is either an offline copy of data from an ArcGIS service (created as a result of a GeodatabaseSyncTask), or can be created using ArcMap or ArcGIS Pro. The geodatabase contains one or more GeodatabaseFeatureTables. Each GeodatabaseFeatureTable contains attribute data. For spatial features, it also stores the geometry and rendering information.

    A GeodatabaseFeatureTable containing point, polyline or polygon features can be used to create a FeatureLayer. A GeodatabaseFeatureTable containing annotation features can be used to create an AnnotationLayer. Both of these layer types can be added to a map and viewed with a map view.

    Geodatabase implements the loadable interface; the geodatabase feature tables can be accessed after the geodatabase has been loaded.

    Since:
    100.0.0
    • Constructor Detail

      • Geodatabase

        public Geodatabase​(java.lang.String geodatabasePath)
        Creates a new Geodatabase instance from a geodatabase at the given path.
        Parameters:
        geodatabasePath - path to geodatabase to be opened
        Throws:
        java.lang.IllegalArgumentException - if geodatabasePath is null
        Since:
        100.0.0
    • Method Detail

      • getGeodatabaseFeatureTables

        public java.util.List<GeodatabaseFeatureTable> getGeodatabaseFeatureTables()
        Gets an unmodifiable list of the geodatabase feature tables that contain geometries such as points, lines or polygons.

        The results will not include feature tables containing annotation or dimension features. The list will be empty if the Geodatabase itself is not loaded.

        Returns:
        the geodatabase feature tables that contain geometries
        Since:
        100.0.0
        See Also:
        getGeodatabaseAnnotationTables()
      • getGeodatabaseFeatureTable

        public GeodatabaseFeatureTable getGeodatabaseFeatureTable​(java.lang.String name)
        Gets a feature table containing point, line or polygon features from the geodatabase, as specified by the given name.
        Parameters:
        name - the name of the geodatabase feature table
        Returns:
        the specified geodatabase feature table, or null if the specified table does not exist or contains annotation or dimension feature data
        Since:
        100.0.0
        See Also:
        getGeodatabaseAnnotationTable(String)
      • getGeodatabaseFeatureTableByServiceLayerId

        public GeodatabaseFeatureTable getGeodatabaseFeatureTableByServiceLayerId​(int layerId)
        Gets a feature table from the geodatabase containing point, line or polygon features, as specified by the given service layer ID. The ID must match ArcGISFeatureLayerInfo.getServiceLayerId().
        Parameters:
        layerId - the service layer ID of the geodatabase feature table
        Returns:
        the specified geodatabase feature table, or null if the specified table does not exist or contains annotation or dimension feature data
        Since:
        100.0.0
        See Also:
        getGeodatabaseAnnotationTableByServiceLayerId(int)
      • getGeodatabaseAnnotationTables

        public java.util.List<GeodatabaseFeatureTable> getGeodatabaseAnnotationTables()
        Gets an unmodifiable list of the geodatabase feature tables that contain annotation features.

        The results will not include feature tables that contain geometries such as points, lines or polygons. The list will be empty if the Geodatabase itself is not loaded.

        Returns:
        the geodatabase feature tables that contain annotation features
        Since:
        100.6.0
        See Also:
        getGeodatabaseFeatureTables()
      • getGeodatabaseAnnotationTable

        public GeodatabaseFeatureTable getGeodatabaseAnnotationTable​(java.lang.String name)
        Gets a feature table containing annotation features from the geodatabase, as specified by the given name.
        Parameters:
        name - the name of the geodatabase feature table
        Returns:
        the specified geodatabase feature table, or null if the specified table does not exist or does not contain annotation feature data
        Since:
        100.6.0
        See Also:
        getGeodatabaseFeatureTable(String)
      • getGeodatabaseAnnotationTableByServiceLayerId

        public GeodatabaseFeatureTable getGeodatabaseAnnotationTableByServiceLayerId​(int layerId)
        Gets a feature table containing annotation features from the geodatabase, as specified by the given service layer ID. The ID must match ArcGISFeatureLayerInfo.getServiceLayerId().
        Parameters:
        layerId - the service layer ID of the geodatabase feature table
        Returns:
        the specified geodatabase feature table, or null if the specified table does not exist or does not contain annotation feature data
        Since:
        100.6.0
        See Also:
        getGeodatabaseFeatureTableByServiceLayerId(int)
      • hasLocalEdits

        public boolean hasLocalEdits()
        Indicates if the geodatabase has local edits.

        For mobile geodatabases created by ArcGIS Pro, this method returns false because there is no concept of uploading or applying edits. For tables from mobile geodatabases, use GeodatabaseFeatureTable.hasLocalEditsSince(Calendar).

        Returns:
        true if there are local edits, false otherwise
        Since:
        100.0.0
      • getServiceUrl

        public java.lang.String getServiceUrl()
        Gets the URL of the service the geodatabase was created from.
        Returns:
        URL of the service the geodatabase was created from
        Since:
        100.0.0
      • getSyncId

        public java.util.UUID getSyncId()
        Gets the sync ID of the geodatabase. The geodatabase's sync ID is the same as the replica ID described in the REST documentation. This is used by the service that created the geodatabase to uniquely identify it when carrying out sync operations. It can also be used when unregistering the geodatabase if it has already been deleted locally.
        Returns:
        Sync ID of the given geodatabase or null if there is an error. Will also return null if this is not a sync enabled geodatabase or if the geodatabase is not loaded.
        Since:
        100.6.0
        See Also:
        GeodatabaseSyncTask.unregisterGeodatabaseAsync(UUID)
      • getSyncModel

        public SyncModel getSyncModel()
        Gets the sync model of the geodatabase. This was set when the geodatabase was created and determines how updates can be synced with the service. If the sync model is PER_GEODATABASE, layers cannot be synced independently: the whole geodatabase must be synced in one operation.

        If the sync model is PER_LAYER, layers can be synced independently of one another.

        Returns:
        the geodatabase's sync model
        Since:
        100.0.0
      • isSyncEnabled

        public boolean isSyncEnabled()
        Indicates if sync is enabled for the geodatabase. If this is true, the geodatabase can be synced with the service it was created from.
        Returns:
        true if sync is enabled, false otherwise
        Since:
        100.0.0
      • getDomains

        public ListenableList<Domain> getDomains()
        Returns a list of the domains that exist in the geodatabase.

        The returned list will be empty if the geodatabase itself is not loaded.

        Returns:
        returns a list of the domains that exist in the geodatabase
        Since:
        100.14.0
      • getGenerateGeodatabaseExtent

        @Deprecated
        public Envelope getGenerateGeodatabaseExtent()
        Deprecated.
        As of 100.7.0, replaced by getGenerateGeodatabaseGeometry(). A geodatabase can be generated using geometry including an Envelope or a Polygon - this property will always return the bounding envelope. The getGenerateGeodatabaseGeometry() property will return the underlying geometry.
        Gets the extent used to generate the sync enabled geodatabase.

        Use this to restrict editing of layers to within this extent.

        Returns:
        the extent used to generate the sync enabled geodatabase, or null if the geodatabase is not sync enabled
        Since:
        100.0.0
      • getGenerateGeodatabaseGeometry

        public Geometry getGenerateGeodatabaseGeometry()
        The geometry (for example, an Envelope or Polygon used to generate a sync enabled geodatabase.

        Edits made to a sync enabled Geodatabase must intersect the geometry used to generate the geodatabase. If an edit is made outside this extent, or area of interest, it will be rejected.

        This method will return the geometry which was used to create this geodatabase. For example, if the geodatabase was created using a GenerateGeodatabaseJob, this method reflects GenerateGeodatabaseParameters.getExtent(). If the geometry was created using an GenerateOfflineMapJob, this method reflects GenerateOfflineMapParameters.getAreaOfInterest(). If the geodatabase was downloaded as part of a PreplannedMapArea, this method will match the geometry used by the web map author when the map area was created.

        If no geometry was used to create the geodatabase (for example if it was authored using ArcGIS Pro), this method may return null. It will also be null until the geodatabase is loaded and getLoadStatus() returns LoadStatus.LOADED.

        Returns:
        the geometry used to generate a sync enabled geodatabase, or null if the geodatabase is not sync enabled
        Since:
        100.7.0
      • getPath

        public java.lang.String getPath()
        Returns the geodatabase path.
        Returns:
        the geodatabase path
        Since:
        100.2.0
      • getUtilityNetworks

        public java.util.List<UtilityNetwork> getUtilityNetworks()
        Gets an unmodifiable list of UtilityNetwork objects that are packaged within the Geodatabase.

        The returned array will be empty if the geodatabase itself is not loaded or if no utility networks exist in the geodatabase.

        Returns:
        the UtilityNetwork objects that are packaged within the Geodatabase
        Since:
        100.11.0
      • getUtilityNetwork

        public UtilityNetwork getUtilityNetwork​(java.lang.String utilityNetworkName)
        Returns an UtilityNetwork from the geodatabase with the specified utility network name.
        Parameters:
        utilityNetworkName - the name of the utility network
        Returns:
        if the specified utility network is not found, then null is returned
        Throws:
        java.lang.IllegalArgumentException - if utilityNetworkName is null
        Since:
        100.11.0
      • close

        public void close()
        Closes this geodatabase.

        After closing, the geodatabase file can be safely deleted or moved.

        Any operation on a closed geodatabase will result in undefined behavior - it may succeed or throw exceptions. So make sure that a closed geodatabase is no longer in use from, for example, feature layers, feature tables, geodatabase sync tasks, etc.

        Since:
        100.1.0
      • isInTransaction

        public boolean isInTransaction()
        Gets whether a transaction is active on the geodatabase.
        Returns:
        true if a transaction is active on the geodatabase, otherwise false
        Since:
        100.2.0
      • createAsync

        public static ListenableFuture<Geodatabase> createAsync​(java.lang.String path)
        Creates an empty mobile geodatabase at the specified path.

        The path must be non-empty, available, allow read/write access, and end in ".geodatabase". If any of these restrictions are violated, the task will not succeed and a task error will be set.

        Parameters:
        path - the path at which the mobile geodatabase should be created
        Returns:
        a ListenableFuture that returns a Geodatabase in a loaded state, if one was able to be created at the specified path
        Throws:
        java.lang.IllegalArgumentException - if path is null
        Since:
        100.14.0
      • createDomainAsync

        public ListenableFuture<Domain> createDomainAsync​(DomainDescription domainDescription)
        Creates a new domain in the geodatabase.

        Creating domains is only supported in mobile geodatabases (either created in Pro or via createAsync(String)). The Field.Type of the domain cannot be unknown. The domain name must not already exist in the geodatabase. For additional domain name constraints, see DomainDescription.getName().

        Parameters:
        domainDescription - the description of the domain to create
        Returns:
        a ListenableFuture that returns a Domain if one was able to be created
        Throws:
        java.lang.IllegalArgumentException - if domainDescription is null
        Since:
        100.14.0
      • deleteDomainAsync

        public ListenableFuture<java.lang.Void> deleteDomainAsync​(java.lang.String domainName)
        Deletes the domain with the specified name from the geodatabase.

        Deleting domains is only supported in mobile geodatabases (either created in Pro or via createAsync(String)). The domain with the specified name must exist in the geodatabase. The domain must not be in use by any fields in existing tables.

        Parameters:
        domainName - the name of the domain to delete
        Returns:
        a ListenableFuture with no return value. If there is no error, the domain was deleted successfully.
        Throws:
        java.lang.IllegalArgumentException - if domainName is null
        Since:
        100.14.0
      • deleteTableAsync

        public ListenableFuture<java.lang.Void> deleteTableAsync​(java.lang.String tableName)
        Deletes an existing table from the geodatabase.

        Deleting tables is only supported in mobile geodatabases (either created in Pro or via createAsync(String)). A table with the specified name must exist in the geodatabase. Attempting further use of a deleted table, such as rendering it in a feature layer or querying it, may result in errors. Only spatial and non-spatial tables can be deleted.

        Parameters:
        tableName - the name of the table to delete
        Returns:
        a ListenableFuture with no return value. If there is no error, the table was deleted successfully.
        Throws:
        java.lang.IllegalArgumentException - if tableName is null
        Since:
        100.14.0
      • beginTransaction

        public void beginTransaction()
        Starts a new transaction on the geodatabase.

        An exception will be thrown if another transaction is already active on the geodatabase. A geodatabase cannot be synchronized while a transaction is active.

        Since:
        100.2.0
      • commitTransaction

        public void commitTransaction()
        Commits the current transaction on the geodatabase.

        Commit changes in the current transaction to the geodatabase. This will also end the transaction. An exception will be thrown if a transaction has not been started on the geodatabase.

        Since:
        100.2.0
      • rollbackTransaction

        public void rollbackTransaction()
        Rollback the current transaction on the geodatabase.

        Discard changes in the current transaction from the geodatabase. This will also end the transaction. An exception will be thrown if a transaction has not been started on the geodatabase.

        Since:
        100.2.0
      • getMinServerGeneration

        public long getMinServerGeneration()
        Returns the minimum server generation number for the geodatabase.

        Server generation numbers indicate the state of a geodatabase (or individual layers) with respect to changes which have been synced with the online service. The number increases as new changes from the online feature service are synced to the local geodatabase. If getSyncModel() is SyncModel.PER_GEODATABASE, the value will indicate the server generation number for the entire geodatabase. If the getSyncModel() is SyncModel.PER_LAYER, the value will be the lowest server generation number for all of the layers in the geodatabase. This property will be -1 if the geodatabase does not support sync (SyncModel.NONE).

        This property will be -1 until the geodatabase is LoadStatus.LOADED.

        Note that this property is only required when using advanced workflows to manually apply pre-generated changes and not when performing a sync directly against the online service.

        Returns:
        the minimum server generation number for the geodatabase
        Since:
        100.6.0
      • getGeodatabaseDimensionTables

        public java.util.List<GeodatabaseFeatureTable> getGeodatabaseDimensionTables()
        Gets the geodatabase feature tables that contain dimension features. A List of GeodatabaseFeatureTable objects.

        The results will not include feature tables that contain geometries such as points, lines or polygons, or annotation features. The returned list will be empty if the geodatabase itself is not loaded.

        Returns:
        a list of GeodatabaseFeatureTable objects that contain dimension features
        Since:
        100.13.0
      • getGeodatabaseDimensionTable

        public GeodatabaseFeatureTable getGeodatabaseDimensionTable​(long serviceLayerId)
        Returns a feature table containing dimension features from the geodatabase, as specified by the given feature service layer ID.
        Parameters:
        serviceLayerId - the service layer ID of the geodatabase feature table containing dimension features
        Returns:
        a GeodatabaseFeatureTable object or null if the specified table does not contain dimension feature data
        Since:
        100.13.0
      • getGeodatabaseDimensionTable

        public GeodatabaseFeatureTable getGeodatabaseDimensionTable​(java.lang.String tableName)
        Returns a feature table containing dimension features from the geodatabase, as specified by the given tableName.
        Parameters:
        tableName - the name of the geodatabase feature table containing dimension
        Returns:
        a GeodatabaseFeatureTable object or null if the specified table does not contain dimension feature data
        Throws:
        java.lang.IllegalArgumentException - if tableName is null or empty
        Since:
        100.13.0
      • getLoadStatus

        public LoadStatus getLoadStatus()
        Description copied from interface: Loadable
        Returns the LoadStatus of the loadable resource.
        Specified by:
        getLoadStatus in interface Loadable
        Returns:
        the LoadStatus of the loadable resource
      • cancelLoad

        public void cancelLoad()
        Description copied from interface: Loadable
        Cancels loading metadata for the object.

        Cancels loading the metadata if the object is loading, and always invokes the done loading listener.

        A load operation that is in progress (LoadStatus.LOADING state) can be cancelled by calling this method and the resource will transition from LoadStatus.LOADING to LoadStatus.FAILED_TO_LOAD state. If the load operation was successfully cancelled, a CancellationException will be returned from Loadable.getLoadError().

        Cancellation should be used carefully because all enqueued done loading listeners for that resource instance will get invoked with an error stating that the operation was cancelled. Thus, one component in the application can cancel the load operation initiated by other components.

        This method does nothing if the resource is not in LoadStatus.LOADING state.

        Specified by:
        cancelLoad in interface Loadable
      • loadAsync

        public void loadAsync()
        Description copied from interface: Loadable
        Loads the metadata of the loadable resource asynchronously.

        The load status changes from LoadStatus.NOT_LOADED to LoadStatus.LOADING. A listener can be added via Loadable.addDoneLoadingListener(java.lang.Runnable) that is invoked upon completion of the asynchronous load operation.

        If the load operation completes successfully, the load status will be LoadStatus.LOADED, which means the resource has loaded its metadata.

        If the load operation failed, the load status will be LoadStatus.FAILED_TO_LOAD and the error can be retrieved by calling Loadable.getLoadError().

        This method can be called concurrently and repeatedly, but only one attempt is ever made to perform the load operation. If a load operation is already in progress (LoadStatus.LOADING state) when loadAsync is called, it simply piggy-backs on the outstanding operation and the done loading listener added to the loadable resource is enqueued to be invoked when that operation completes. If the operation has already completed (LoadStatus.LOADED or LoadStatus.FAILED_TO_LOAD state) when loadAsync is called, the done loading listener is immediately invoked when added to the loadable resource.

        If a loadable resource has failed to load, calling loadAsync on it subsequently will not change its state. The done loading listener will be invoked immediately when added to the loadable resource. In order to retry loading the resource, Loadable.retryLoadAsync() needs to be used.

        A load operation that is in progress (LoadStatus.LOADING state) can be cancelled by calling Loadable.cancelLoad().

        Specified by:
        loadAsync in interface Loadable
      • retryLoadAsync

        public void retryLoadAsync()
        Description copied from interface: Loadable
        Loads or retries loading metadata for the object asynchronously.

        Will retry loading the metadata if the object's load status is LoadStatus.FAILED_TO_LOAD. Will load the object if it is not loaded. Will not retry to load the object if the object is loaded.

        For more details on the load process see Loadable.loadAsync().

        Specified by:
        retryLoadAsync in interface Loadable
      • addDoneLoadingListener

        public void addDoneLoadingListener​(java.lang.Runnable listener)
        Description copied from interface: Loadable
        Adds a listener to the loadable resource that is invoked when loading has completed.

        The listener may be added at any point, whether the loadable resource has already completed loading or not.

        • For resources that are not loaded when the listener is added (LoadStatus is NOT_LOADED or LOADING): When the resource completes loading, the listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
        • For resources that are already loaded when the listener is added (LoadStatus is LOADED or FAILED_TO_LOAD): The listener will be called immediately, on the current thread.

        Alternatively, to be notified when there is any change in the load status, use the Loadable.addLoadStatusChangedListener(LoadStatusChangedListener) method instead.

        Specified by:
        addDoneLoadingListener in interface Loadable
        Parameters:
        listener - a Runnable that is invoked upon completion of the load operation
      • removeDoneLoadingListener

        public boolean removeDoneLoadingListener​(java.lang.Runnable listener)
        Description copied from interface: Loadable
        Removes a done loading listener from the loadable resource.
        Specified by:
        removeDoneLoadingListener in interface Loadable
        Parameters:
        listener - the listener to be removed
        Returns:
        true if the listener was removed, otherwise false
      • addLoadStatusChangedListener

        public void addLoadStatusChangedListener​(LoadStatusChangedListener listener)
        Description copied from interface: Loadable
        Adds a LoadStatusChangedListener to the loadable resource that is invoked whenever the load status changes.

        Adding this listener on the UI thread will cause it to be invoked on the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.

        The listener will not be called if added to a loadable resource that has already completed loading. To be notified when a loadable resource has completed loading, including if the resource is already loaded when the listener is added, use the Loadable.addDoneLoadingListener(Runnable) method.

        Specified by:
        addLoadStatusChangedListener in interface Loadable
        Parameters:
        listener - the LoadStatusChangedListener to be added
      • removeLoadStatusChangedListener

        public boolean removeLoadStatusChangedListener​(LoadStatusChangedListener listener)
        Description copied from interface: Loadable
        Removes a LoadStatusChangedListener from the loadable resource.
        Specified by:
        removeLoadStatusChangedListener in interface Loadable
        Parameters:
        listener - the LoadStatusChangedListener to be removed
        Returns:
        true if the listener was removed, otherwise false