Class ServiceGeodatabase
- java.lang.Object
-
- com.esri.arcgisruntime.data.ServiceGeodatabase
-
- All Implemented Interfaces:
RemoteResource
,Loadable
public final class ServiceGeodatabase extends java.lang.Object implements Loadable, RemoteResource
A container for a collection ofServiceFeatureTable
connected to a feature service.A ServiceGeodatabase connects to a feature service as a whole, grouping together
ServiceFeatureTable
instances for related records queries, connecting to a version in a branch-versioned service, and managing edits for all tables.- Since:
- 100.9.0
-
-
Constructor Summary
Constructors Constructor Description ServiceGeodatabase(PortalItem portalItem)
Creates a new ServiceGeodatabase from a feature service portal item, and connects to the default version in the feature service.ServiceGeodatabase(PortalItem portalItem, FeatureServiceSessionType sessionType)
Creates a new ServiceGeodatabase from a feature service portal item, and connects to the default version in the feature service.ServiceGeodatabase(PortalItem portalItem, java.lang.String versionName)
Creates a new ServiceGeodatabase from a feature service portal item, and connects to a specific version in the feature service.ServiceGeodatabase(PortalItem portalItem, java.lang.String versionName, FeatureServiceSessionType sessionType)
Creates a new ServiceGeodatabase from a feature service portal item, and connects to a specific version in the feature service.ServiceGeodatabase(java.lang.String serviceUrl)
Constructs a ServiceGeodatabase with the given URL and connected to the default version in the feature service.ServiceGeodatabase(java.lang.String url, FeatureServiceSessionType sessionType)
Creates a newServiceGeodatabase
connected to the default version in a feature service.ServiceGeodatabase(java.lang.String serviceUrl, java.lang.String versionName)
Constructs a ServiceGeodatabase with the given URL and connected to a specific version in the feature service.ServiceGeodatabase(java.lang.String url, java.lang.String versionName, FeatureServiceSessionType sessionType)
Creates a newServiceGeodatabase
connected to a specific version in a feature service.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDoneLoadingListener(java.lang.Runnable listener)
Adds a listener to the loadable resource that is invoked when loading has completed.void
addLoadStatusChangedListener(LoadStatusChangedListener listener)
Adds aLoadStatusChangedListener
to the loadable resource that is invoked whenever the load status changes.ListenableFuture<java.util.List<FeatureTableEditResult>>
applyEditsAsync()
Asynchronously applies all local edits in all tables to the service.void
cancelLoad()
Cancels loading metadata for the object.ListenableFuture<java.lang.Void>
closeAsync()
Closes this service geodatabase.ListenableFuture<ServiceVersionInfo>
createVersionAsync(ServiceVersionParameters newVersion)
Asynchronously creates a new version in the service based on the default version.ListenableFuture<java.util.List<ServiceVersionInfo>>
fetchVersionsAsync()
Asynchronously retrieves a list of all versions on the service.ListenableList<ServiceFeatureTable>
getConnectedTables()
Gets the collection of feature tables managed by the ServiceGeodatabase.Credential
getCredential()
Gets theCredential
that is set on the network-enabled resource.java.lang.String
getDefaultVersionName()
Gets the name of the default version.ArcGISRuntimeException
getLoadError()
Returns the most recent error that was encountered when the loadable resource transitioned to theLoadStatus.FAILED_TO_LOAD
state, either due to calling theLoadable.loadAsync()
orLoadable.retryLoadAsync()
method.LoadStatus
getLoadStatus()
Returns theLoadStatus
of the loadable resource.PortalItem
getPortalItem()
Gets thePortalItem
which the ServiceGeodatabase was created from.RequestConfiguration
getRequestConfiguration()
Gets theRequestConfiguration
used to modify the parameters of network requests made by thisRemoteResource
.ArcGISFeatureServiceInfo
getServiceInfo()
Gets the metadata of the service this object is connected to.FeatureServiceSessionType
getSessionType()
Gets the type of read and edit sessions to use when working with the service.ServiceFeatureTable
getTable(long layerId)
Gets a service feature table object from the ID of a layer or table in the service.java.lang.String
getUri()
Gets the URI of thisRemoteResource
.java.lang.String
getVersionName()
Gets the name of the version the ServiceGeodatabase is currently connected to.boolean
hasLocalEdits()
Gets whether any of the tables in theServiceGeodatabase
have unapplied edits.boolean
isSupportsBranchVersioning()
Gets whether the service supports branch versioning.void
loadAsync()
Loads the metadata of the loadable resource asynchronously.boolean
removeDoneLoadingListener(java.lang.Runnable listener)
Removes a done loading listener from the loadable resource.boolean
removeLoadStatusChangedListener(LoadStatusChangedListener listener)
Removes aLoadStatusChangedListener
from the loadable resource.void
retryLoadAsync()
Loads or retries loading metadata for the object asynchronously.void
setCredential(Credential credential)
Sets aCredential
to be used by the network-enabled resource in the event of an authentication challenge.void
setRequestConfiguration(RequestConfiguration requestConfiguration)
Sets theRequestConfiguration
used to modify the parameters of network requests made by thisRemoteResource
.void
setSessionType(FeatureServiceSessionType sessionType)
Sets the type of read and edit sessions to use when working with the service.ListenableFuture<java.lang.Void>
switchVersionAsync(java.lang.String versionName)
Asynchronously switches all connected feature tables to the new version.ListenableFuture<java.lang.Void>
undoLocalEditsAsync()
Asynchronously undoes all of the local edits in all the tables.
-
-
-
Constructor Detail
-
ServiceGeodatabase
public ServiceGeodatabase(java.lang.String serviceUrl)
Constructs a ServiceGeodatabase with the given URL and connected to the default version in the feature service.If the service is branch versioned, the ServiceGeodatabase will connect to the default version.
- Parameters:
serviceUrl
- the URL of the feature service or the portal item to connect to- Throws:
java.lang.IllegalArgumentException
- if serviceUrl is null or empty- Since:
- 100.9.0
-
ServiceGeodatabase
public ServiceGeodatabase(java.lang.String serviceUrl, java.lang.String versionName)
Constructs a ServiceGeodatabase with the given URL and connected to a specific version in the feature service.If a version with the name does not exist, or the service is not branch versioned, the ServiceGeodatabase will fail to load.
- Parameters:
serviceUrl
- the URL of the feature service or portal item to connect toversionName
- the existing version name to connect to when the ServiceGeodatabase loads; if it is null, this constructor is equivalent toServiceGeodatabase(String)
.- Throws:
java.lang.IllegalArgumentException
- if serviceUrl is null or empty- Since:
- 100.9.0
-
ServiceGeodatabase
public ServiceGeodatabase(PortalItem portalItem)
Creates a new ServiceGeodatabase from a feature service portal item, and connects to the default version in the feature service.If the service is branch versioned, the ServiceGeodatabase will connect to the default version.
- Parameters:
portalItem
- a feature servicePortalItem
- Throws:
java.lang.IllegalArgumentException
- if portalItem is null- Since:
- 100.12.0
- See Also:
getPortalItem()
-
ServiceGeodatabase
public ServiceGeodatabase(PortalItem portalItem, FeatureServiceSessionType sessionType)
Creates a new ServiceGeodatabase from a feature service portal item, and connects to the default version in the feature service.If the service is branch versioned, the ServiceGeodatabase will connect to the default version.
If using
FeatureServiceSessionType.PERSISTENT
, it is important to callcloseAsync()
before destruction.- Parameters:
portalItem
- a feature servicePortalItem
sessionType
- the type of read and edit sessions to use when working with the service- Throws:
java.lang.IllegalArgumentException
- if portalItem is nulljava.lang.IllegalArgumentException
- if sessionType is null- Since:
- 100.12.0
- See Also:
getPortalItem()
-
ServiceGeodatabase
public ServiceGeodatabase(PortalItem portalItem, java.lang.String versionName)
Creates a new ServiceGeodatabase from a feature service portal item, and connects to a specific version in the feature service.If a version with the name does not exist, or the service is not branch versioned, the ServiceGeodatabase will fail to load.
- Parameters:
portalItem
- a feature servicePortalItem
versionName
- the existing version to connect to when the ServiceGeodatabase loads- Throws:
java.lang.IllegalArgumentException
- if portalItem is nulljava.lang.IllegalArgumentException
- if versionName is null- Since:
- 100.12.0
- See Also:
getPortalItem()
-
ServiceGeodatabase
public ServiceGeodatabase(PortalItem portalItem, java.lang.String versionName, FeatureServiceSessionType sessionType)
Creates a new ServiceGeodatabase from a feature service portal item, and connects to a specific version in the feature service.If a version with the name does not exist, or the service is not branch versioned, the ServiceGeodatabase will fail to load.
If using
FeatureServiceSessionType.PERSISTENT
, it is important to callcloseAsync()
before destruction.- Parameters:
portalItem
- a feature servicePortalItem
versionName
- the existing version to connect to when the ServiceGeodatabase loadssessionType
- the type of read and edit sessions to use when working with the service- Throws:
java.lang.IllegalArgumentException
- if portalItem is nulljava.lang.IllegalArgumentException
- if versionName is nulljava.lang.IllegalArgumentException
- if sessionType is null- Since:
- 100.12.0
- See Also:
getPortalItem()
-
ServiceGeodatabase
public ServiceGeodatabase(java.lang.String url, FeatureServiceSessionType sessionType)
Creates a newServiceGeodatabase
connected to the default version in a feature service.If the service is branch versioned, the
ServiceGeodatabase
will connect to the default version.If using
FeatureServiceSessionType.PERSISTENT
, it is important to callcloseAsync()
when you are done with the session.- Parameters:
url
- the URL of the feature service or the portal item to connect tosessionType
- the type of read and edit sessions to use when working with the service- Throws:
java.lang.IllegalArgumentException
- if url is nulljava.lang.IllegalArgumentException
- if sessionType is null- Since:
- 100.10.0
-
ServiceGeodatabase
public ServiceGeodatabase(java.lang.String url, java.lang.String versionName, FeatureServiceSessionType sessionType)
Creates a newServiceGeodatabase
connected to a specific version in a feature service.If a version with the name does not exist, or the service is not branch versioned, the
ServiceGeodatabase
will fail to load.If using
FeatureServiceSessionType.PERSISTENT
, it is important to callcloseAsync()
when you are done with the session.- Parameters:
url
- the URL of the feature service or portal item to connect toversionName
- the existing version to connect to when the ServiceGeodatabase loads; if it is null, this constructor is equivalent toServiceGeodatabase(String, FeatureServiceSessionType)
sessionType
- the type of read and edit sessions to use when working with the service- Throws:
java.lang.IllegalArgumentException
- if url is nulljava.lang.IllegalArgumentException
- if sessionType is null- Since:
- 100.10.0
-
-
Method Detail
-
createVersionAsync
public ListenableFuture<ServiceVersionInfo> createVersionAsync(ServiceVersionParameters newVersion)
Asynchronously creates a new version in the service based on the default version.Branch versioning requires that the default version always be the ancestor of all other versions. If the service isn't branch versioned, an
ArcGISRuntimeException
is thrown.- Parameters:
newVersion
- a ServiceVersionParameters to set the properties of the new version- Returns:
- a ListenableFuture that represents the creation of a new version in the service. When the operation is done the result is a ServiceVersionInfo containing the full metadata for the new version
- Throws:
java.lang.IllegalArgumentException
- if newVersion is nullArcGISRuntimeException
- if the service isn't branch versioned, or if the version parameters do not include a name- Since:
- 100.9.0
-
fetchVersionsAsync
public ListenableFuture<java.util.List<ServiceVersionInfo>> fetchVersionsAsync()
Asynchronously retrieves a list of all versions on the service.- Returns:
- a ListenableFuture that represents the retrieval of all versions on the service. When the operation is
done the result contains a list of
ServiceVersionInfo
objects. - Throws:
ArcGISRuntimeException
- if the service isn't branch versioned- Since:
- 100.9.0
-
getConnectedTables
public ListenableList<ServiceFeatureTable> getConnectedTables()
Gets the collection of feature tables managed by the ServiceGeodatabase.- Returns:
- an unmodifiable listenable list of feature tables managed by the ServiceGeodatabase
- Since:
- 100.9.0
-
getDefaultVersionName
public java.lang.String getDefaultVersionName()
Gets the name of the default version.- Returns:
- the name of the default version
- Since:
- 100.9.0
-
getServiceInfo
public ArcGISFeatureServiceInfo getServiceInfo()
Gets the metadata of the service this object is connected to.- Returns:
- an ArcGISFeatureServiceInfo
- Since:
- 100.9.0
-
isSupportsBranchVersioning
public boolean isSupportsBranchVersioning()
Gets whether the service supports branch versioning.- Returns:
- true if the service supports branch versioning, false otherwise
- Since:
- 100.9.0
-
getTable
public ServiceFeatureTable getTable(long layerId)
Gets a service feature table object from the ID of a layer or table in the service.If a table instance for the layer already exists in
getConnectedTables()
, the existing object will be returned. Otherwise, a newServiceFeatureTable
will be created.- Parameters:
layerId
- the layer id for which to create the table- Returns:
- a table instance for working with the table or layer in the feature service
- Throws:
ArcGISRuntimeException
- if no table or layer exists in the service with the given ID- Since:
- 100.9.0
-
getVersionName
public java.lang.String getVersionName()
Gets the name of the version the ServiceGeodatabase is currently connected to.- Returns:
- the name of the version the ServiceGeodatabase is currently connected to
- Since:
- 100.9.0
-
getSessionType
public FeatureServiceSessionType getSessionType()
Gets the type of read and edit sessions to use when working with the service.The default value is
FeatureServiceSessionType.TRANSIENT
.If the feature service this
ServiceGeodatabase
references is not branch-versioned, onlyFeatureServiceSessionType.TRANSIENT
is supported. If usingFeatureServiceSessionType.PERSISTENT
, it is important to callcloseAsync()
when you are done with the session. Cannot be set after theServiceGeodatabase
is loaded. When theServiceGeodatabase
is created by loading aArcGISMap
, useLoadSettings
to control the session type.- Returns:
- the type of read and edit sessions to use when working with the service
- Since:
- 100.10.0
-
setSessionType
public void setSessionType(FeatureServiceSessionType sessionType)
Sets the type of read and edit sessions to use when working with the service.The default value is
FeatureServiceSessionType.TRANSIENT
.Cannot be set after the
ServiceGeodatabase
is loaded.- Parameters:
sessionType
- the type of read and edit sessions to use when working with the service- Throws:
java.lang.IllegalArgumentException
- if sessionType is null- Since:
- 100.10.0
-
switchVersionAsync
public ListenableFuture<java.lang.Void> switchVersionAsync(java.lang.String versionName)
Asynchronously switches all connected feature tables to the new version.Check the result of
hasLocalEdits()
before attempting to switch versions, to make sure all changes are saved to the service or discarded from the local cache. Use theapplyEditsAsync()
orundoLocalEditsAsync()
methods as appropriate to save or discard changes before switching versions.- Parameters:
versionName
- the name of the version to connect to- Returns:
- a ListenableFuture that represents the success of switching versions. When the operation is done, the version is switched successfully if no runtime error is thrown
- Throws:
java.lang.IllegalArgumentException
- if versionName is nullArcGISRuntimeException
- if the service isn't branch versioned, or no version exists with the supplied name or any ofgetConnectedTables()
have unapplied edits- Since:
- 100.9.0
-
applyEditsAsync
public ListenableFuture<java.util.List<FeatureTableEditResult>> applyEditsAsync()
Asynchronously applies all local edits in all tables to the service.Edits in all tables are applied to the feature service in a call, which is more efficient than doing so one
ServiceFeatureTable.applyEditsAsync()
at a time.- Returns:
- a ListenableFuture that applies the all local edits to the service. When the operation is
done the result contains a list of
FeatureTableEditResult
objects. - Since:
- 100.9.0
-
closeAsync
public ListenableFuture<java.lang.Void> closeAsync()
Closes this service geodatabase.A request to stop any active reading or editing sessions with the feature service is sent and once this asynchronous process is complete,this service geodatabase will be closed.
Before calling this method, there should be no references to all related data. For example, terminate fetch versions, create version, switch, apply or undo edits, remove feature layers, and release tables from map.
After calling this method, accessing this service geodatabase or any of its connected tables will fail with an
ArcGISRuntimeException
Closing this service geodatabase is not necessary if it has not been loaded.
- Returns:
- a ListenableFuture that has no return value
- Since:
- 100.10.0
-
hasLocalEdits
public boolean hasLocalEdits()
Gets whether any of the tables in theServiceGeodatabase
have unapplied edits.- Returns:
- whether any of the tables have unapplied edits
- Since:
- 100.9.0
-
undoLocalEditsAsync
public ListenableFuture<java.lang.Void> undoLocalEditsAsync()
Asynchronously undoes all of the local edits in all the tables.- Returns:
- a ListenableFuture that represents the success of undoing local edits. When the operation is done, the local edits are undone successfully if no exception is thrown.
- Since:
- 100.9.0
-
getPortalItem
public PortalItem getPortalItem()
Gets thePortalItem
which the ServiceGeodatabase was created from.- Returns:
- the
PortalItem
which the ServiceGeodatabase was created from, or null if none - Since:
- 100.12.0
- See Also:
ServiceGeodatabase(PortalItem)
-
getLoadError
public ArcGISRuntimeException getLoadError()
Description copied from interface:Loadable
Returns the most recent error that was encountered when the loadable resource transitioned to theLoadStatus.FAILED_TO_LOAD
state, either due to calling theLoadable.loadAsync()
orLoadable.retryLoadAsync()
method.If the resource subsequently transitions to
LoadStatus.LOADED
(for example, if a call toretryLoadAsync
completes successfully) the error is cleared out.- Specified by:
getLoadError
in interfaceLoadable
- Returns:
- the most recent error that was encountered when the loadable resource transitioned to the
LoadStatus.FAILED_TO_LOAD
state.
-
getLoadStatus
public LoadStatus getLoadStatus()
Description copied from interface:Loadable
Returns theLoadStatus
of the loadable resource.- Specified by:
getLoadStatus
in interfaceLoadable
- 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 fromLoadStatus.LOADING
toLoadStatus.FAILED_TO_LOAD
state. If the load operation was successfully cancelled, a CancellationException will be returned fromLoadable.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 interfaceLoadable
-
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
toLoadStatus.LOADING
. A listener can be added viaLoadable.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 callingLoadable.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) whenloadAsync
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
orLoadStatus.FAILED_TO_LOAD
state) whenloadAsync
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 callingLoadable.cancelLoad()
.
-
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 interfaceLoadable
-
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 interfaceLoadable
- 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 interfaceLoadable
- 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 aLoadStatusChangedListener
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 interfaceLoadable
- Parameters:
listener
- theLoadStatusChangedListener
to be added
-
removeLoadStatusChangedListener
public boolean removeLoadStatusChangedListener(LoadStatusChangedListener listener)
Description copied from interface:Loadable
Removes aLoadStatusChangedListener
from the loadable resource.- Specified by:
removeLoadStatusChangedListener
in interfaceLoadable
- Parameters:
listener
- theLoadStatusChangedListener
to be removed- Returns:
- true if the listener was removed, otherwise false
-
getCredential
public Credential getCredential()
Description copied from interface:RemoteResource
Gets theCredential
that is set on the network-enabled resource.Only applicable if the resource is secured.
- Specified by:
getCredential
in interfaceRemoteResource
- Returns:
- the Credential, or null if there is none
-
setCredential
public void setCredential(Credential credential)
Description copied from interface:RemoteResource
Sets aCredential
to be used by the network-enabled resource in the event of an authentication challenge. The default credential is null.Only applicable if the resource is secured.
- Specified by:
setCredential
in interfaceRemoteResource
- Parameters:
credential
- the Credential to be used for authentication
-
getRequestConfiguration
public RequestConfiguration getRequestConfiguration()
Description copied from interface:RemoteResource
Gets theRequestConfiguration
used to modify the parameters of network requests made by thisRemoteResource
.- Specified by:
getRequestConfiguration
in interfaceRemoteResource
- Returns:
- the
RequestConfiguration
used to modify network requests
-
setRequestConfiguration
public void setRequestConfiguration(RequestConfiguration requestConfiguration)
Description copied from interface:RemoteResource
Sets theRequestConfiguration
used to modify the parameters of network requests made by thisRemoteResource
. If not set, the globalRequestConfiguration
will be used (seeRequestConfiguration.getGlobalRequestConfiguration()
).- Specified by:
setRequestConfiguration
in interfaceRemoteResource
- Parameters:
requestConfiguration
- the RequestConfiguration used to modify network requests
-
getUri
public java.lang.String getUri()
Description copied from interface:RemoteResource
Gets the URI of thisRemoteResource
. Typically this is the URI used to instantiate the object.- Specified by:
getUri
in interfaceRemoteResource
- Returns:
- the URI of this RemoteResource
-
-