HERE Android SDK Developer's Guide

CLE2DataManager

The class CLE2DataManager is a member of com.here.android.mpa.customlocation2 .

Class Summary

public class CLE2DataManager

extends java.lang.Object

This class is responsible for managing layer data for CLE2 offline use.

[For complete information, see the section Class Details]

Nested Class Summary

Table 1. Nested Classes in CLE2DataManager
Nested Classes

public static abstract interface CLE2DataManager.CLE2DownloadListener

Represents a listener that reports information about the completion of layer download.

public static final enumeration CLE2DataManager.OperationType

Indicated type of operation performed on CLE2 data.

public static final enumeration CLE2DataManager.StorageType

Indicates which class of storage was affected by the data operation.

Method Summary

Table 2. Methods in CLE2DataManager
Methods

public boolean cancelAllLayerDowloads ()

Deprecated: Deprecated as of release 3.4.

Attempts to cancel execution of all ongoing downloads.

public boolean cancelDownload (String layerId)

Deprecated: Deprecated as of release 3.4.

Attempts to cancel execution of a specific layer download.

public boolean deleteAll ()

Deprecated: Deprecated as of release 3.4.

Removes all data from the local storage.

public boolean deleteLayer (String layerId)

Deprecated: Deprecated as release of 3.4.

Delete one specific layer from the local storage.

public void downloadLayer (String layerId, CLE2DownloadListener listener)

Deprecated: Deprecated as of release 3.4.

Request the full download of a specific layer if layer doesn't exist locally and layer is not updated with server data.

public boolean equals (Object other)

For documentation, see java.lang.Object

public static CLE2DataManager getInstance ()

Returns the CLE2DataManager singleton instance.

public int getNumberOfStoredGeometries (String layerId)

Get the number of geometries stored of a given layer.

public int hashCode ()

For documentation, see java.lang.Object

public CLE2Task<CLE2OperationResult> newDeleteLayersTask (List layerIds, StorageType storageType)

Creates a task for deleting specified layers from the service or local storage.

public CLE2Task<CLE2OperationResult> newDownloadLayerTask (String layerId)

Creates a task for downloading a layer from CLE2 service and storing it in local storage.

public CLE2Task<CLE2Geometry> newFetchLocalLayersTask (List layerIds)

Creates a task for retrieving all geometries from specified locally stored layers.

public CLE2Task<CLE2OperationResult> newGeometryTask (OperationType operationType, String layerId, java.util.List <CLE2Geometry> geometryData, StorageType storageType)

Creates a task for modifying CLE data.

public CLE2Task<String, CLE2LayerMetadata> newListLayersTask (StorageType storageType)

Creates a CLE2 task for getting a list of available layers.

public CLE2Task<CLE2OperationResult> newPurgeLocalStorageTask ()

Creates a task for removing all data from local storage.

public CLE2Task<CLE2OperationResult> newUploadLayerTask (String layerId, java.util.List <CLE2Geometry> geometryData)

Creates a task for uploading a new layer into CLE service, creating a new layer with specified ID.

Class Details

This class is responsible for managing layer data for CLE2 offline use. To download a full layer, call downloadLayer(String, CLE2DataManager.CLE2DownloadListener). To store a subset of geometries, create a CLE2Request and setCachingEnabled(boolean) to true.

Method Details

public boolean cancelAllLayerDowloads ()

Deprecated: Deprecated as of release 3.4.

Keep track of your download tasks and use cancel() instead

Attempts to cancel execution of all ongoing downloads. This attempt will fail if the task has already completed, already been cancelled, or could not be cancelled for some other reason. This call does not guarantee that any download task will be cancelled. For the end result, inspect CLE2ErrorCode value obtained from CLE2Error object passed to the listener.

Returns:

true if there was at least one outstanding download task for which cancellation will be attempted; false otherwise

public boolean cancelDownload (String layerId)

Deprecated: Deprecated as of release 3.4.

Use cancel() on a download task obtained from newDownloadLayerTask(String)

Attempts to cancel execution of a specific layer download. This attempt will fail if the task has already completed, already been cancelled, or could not be cancelled for some other reason. This call does not guarantee that the download job will be cancelled. For the end result, inspect CLE2ErrorCode value obtained from CLE2Error object passed to the listener.

Parameters:

  • layerId

    Name of the layer specifying which download should stop.

Returns:

true if there was a download task for specified layer for which cancellation will be attempted; false otherwise

public boolean deleteAll ()

Deprecated: Deprecated as of release 3.4.

Use newPurgeLocalStorageTask()

Removes all data from the local storage. This method is synchronous and blocks until database operation is finished, which in some circumstances can take some time.

public boolean deleteLayer (String layerId)

Deprecated: Deprecated as release of 3.4.

Use newDeleteLayersTask(List, CLE2DataManager.StorageType) with LOCAL instead

Delete one specific layer from the local storage. This method is synchronous and blocks until database operation is finished, which in some circumstances can take some time.

Parameters:

  • layerId

    ID of a layer to remove from cache

Returns:

true if operation successful, false otherwise

public void downloadLayer (String layerId, CLE2DownloadListener listener)

Deprecated: Deprecated as of release 3.4.

Use newDownloadLayerTask(String) instead

Request the full download of a specific layer if layer doesn't exist locally and layer is not updated with server data.

Please note that this method will make two request. One for checking updates and another for downloading. If local stored data is up to date with server data, no downloading will happen.

Parameters:

  • layerId

    Name of a layer to download

  • listener

    listener to notify result of operation.

Throws:

  • IllegalArgumentException

    if layerId is null or empty

public boolean equals (Object other)

For documentation, see java.lang.Object

Parameters:

  • other

public static CLE2DataManager getInstance ()

Returns the CLE2DataManager singleton instance.

Returns:

CLE2LayerDownloader instance.

public int getNumberOfStoredGeometries (String layerId)

Get the number of geometries stored of a given layer.

Parameters:

  • layerId

Returns:

number of geometries stored for a given layer.

public int hashCode ()

For documentation, see java.lang.Object

public CLE2Task<CLE2OperationResult> newDeleteLayersTask (List layerIds, StorageType storageType)

Creates a task for deleting specified layers from the service or local storage.

When operating on local storage, this operation will delete all data for specified layers, regardless of how they got there (ie. search result caching or downloading of whole layer).

Parameters:

  • layerIds

    the list of IDs of layers to remove

  • storageType

    the location of data to be deleted

Returns:

a CLE2 task for removing a layer from the service

Throws:

  • IllegalArgumentException

    if layerIds is null, empty or contains null or empty strings

public CLE2Task<CLE2OperationResult> newDownloadLayerTask (String layerId)

Creates a task for downloading a layer from CLE2 service and storing it in local storage.

When started, this operation will check if locally stored layer exists and if it's out of date before downloading data from the service. As such, no unnecessary download will take place if local data is up to date with the service.

Upon success, all data stored locally for the specified layer are the same as on the server at the time of download.

Parameters:

  • layerId

    id of layer to download

Returns:

a CLE2 task for downloading the layer

Throws:

  • IllegalArgumentException

    if @{code layerId} is null or empty

public CLE2Task<CLE2Geometry> newFetchLocalLayersTask (List layerIds)

Creates a task for retrieving all geometries from specified locally stored layers.

Parameters:

  • layerIds

    the list of ids of layers to retrieve data for

Returns:

a CLE2 task for retrieving the geometry data

Throws:

  • IllegalArgumentException

    if layerIds is null, empty or contains null or empty strings

public CLE2Task<CLE2OperationResult> newGeometryTask (OperationType operationType, String layerId, java.util.List <CLE2Geometry> geometryData, StorageType storageType)

Creates a task for modifying CLE data. The nature of the modification is determined by the operationType and can be creation of new data items, updating of existing ones or deleting.

For local storage, running CREATE on a layer that does not exist will create it. For remote storage it will fail if the layer does not already exist in the service. To create a new remote layer, use newUploadLayerTask(String, List).

Parameters:

  • operationType

    type of operation to perform

  • layerId

    id of layer to perform the operation on

  • geometryData

    the data to be used for the operation

  • storageType

    determines whether to modify locally stored data or remote ones

Returns:

a CLE2 task for modifying data

Throws:

  • IllegalArgumentException

    if @{code layerId} is null or empty or @{code geometryData} is null or empty or contains @{code null} elements

public CLE2Task<String, CLE2LayerMetadata> newListLayersTask (StorageType storageType)

Creates a CLE2 task for getting a list of available layers. You can specify whether to retrieve it from the CLE2 service or from local storage. In case of local storage, only layers downloaded using downloadLayer(String, CLE2DataManager.CLE2DownloadListener) will be listed.

The result of this task is a map where the key is a layer ID and the value is a metadata object for this layer.

Parameters:

  • storageType

    LOCAL to list layers only from local storage, REMOTE to list layers only from remote CLE2 service

Returns:

a CLE2 task for getting a list of available layers.

public CLE2Task<CLE2OperationResult> newPurgeLocalStorageTask ()

Creates a task for removing all data from local storage.

Returns:

a CLE2 task for purging all data from local storage

public CLE2Task<CLE2OperationResult> newUploadLayerTask (String layerId, java.util.List <CLE2Geometry> geometryData)

Creates a task for uploading a new layer into CLE service, creating a new layer with specified ID. Provided layer ID will be converted to all upper-case by CLE service. If a layer with the same ID already exist, it will be replaced by this one. This operation does not impact locally stored data. Note that layer data needs to be uniform, meaning all geometries be of the same type and have the same set of attributes.

Parameters:

  • layerId

    the id of layer to upload

  • geometryData

    geometry data to upload

Returns:

a CLE2 task for uploading the layer

Throws:

  • IllegalArgumentException

    if @{code layerId} is null or empty or @{code geometryData} is null or empty or contains @{code null} elements