mx.data

# SQLiteOfflineAdapter - AS3 ADEP Data Services

Package | mx.data
Class | public class SQLiteOfflineAdapter
Inheritance | SQLiteOfflineAdapter DataServiceOfflineAdapter Object

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 3.1

Runtime Versions: | Flash Player 9, AIR 1.1

Provides a SQLite-based persistence format for a DataManager's offline cached items. Essentially each item is persisted as a row in a table named Entity_<destination>, with each column being a field name of the item.

Override the `getQueryCriteria()` method and possibly the `getQueryCriteriaParameters()` to implement custom local queries.

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | constructor : Object A reference to the class object or constructor function for a given object instance. | Object

Protected Properties
Hide Inherited Protected Properties
Show Inherited Protected Properties

| Property | Defined By
--- | --- | ---
|  | destination : String [read-only] Indicates the destination associated with this offline adapter. | DataServiceOfflineAdapter

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | SQLiteOfflineAdapter() Constructor. | SQLiteOfflineAdapter
|  | addOfflineItem(item:Object):void [override] Adds the specified offline item to the localStore. | SQLiteOfflineAdapter
|  | appendItemData(archiveData:IDataOutput, version:String, changedItems:ChangedItems):void Appends to the byte array the specified data items. | SQLiteOfflineAdapter
|  | beginTransaction():void Begins a transaction on the localStore. | DataServiceOfflineAdapter
|  | close():void Closes the localStore associated with this adapter. | DataServiceOfflineAdapter
|  | commit(dispatcher:IEventDispatcher = null, token:mx.rpc:AsyncToken = null, faultsOnly:Boolean = false):void Commits any current changes to the local store. | DataServiceOfflineAdapter
|  | connect(cacheID:String):mx.rpc:AsyncToken Connect to the specified cache. | DataServiceOfflineAdapter
|  | deleteOfflineItem(uid:String):void [override] Deletes the specified offine item with the matching uid from the local store. | SQLiteOfflineAdapter
|  | deleteOfflineItems(uidArray:Array):void Deletes the specified set of offine items with the matching uids from the local store. | DataServiceOfflineAdapter
|  | executeOfflineQuery(propSpecifier:PropertySpecifier, args:Array, startIndex:int, numItems:int):mx.rpc:AsyncToken [override] Used with SQLite adapters to execute dynamic queries locally. | SQLiteOfflineAdapter
|  | exportItemData(version:String, changedItems:ChangedItems):ByteArray Generates a new serialized archive of the specified data items which then can be persisted as appropriate. | SQLiteOfflineAdapter
|  | getFillList():Array Returns the current fills that have been cached in the local store. | DataServiceOfflineAdapter
|  | getItemReferenceIds(uid:String, propName:String):Array [override] Get the ids of the associated items for a given item uid and an association property. | SQLiteOfflineAdapter
|  | getItems(uidArray:Array):Dictionary [override] Restores all the items specified using the uid array specified for a given destination. | SQLiteOfflineAdapter
|  | getMessageCache():Object Restores the message cache from the offline store. | DataServiceOfflineAdapter
|  | hasOwnProperty(name:String):Boolean Indicates whether an object has a specified property defined. | Object
|  | importItemData(expectedVersion:String, archiveData:IDataInput):mx.rpc:AsyncToken Imports archived changed items instance from the byte array, which typically comes from a file. | SQLiteOfflineAdapter
|  | importItems(changedItems:ChangedItems):mx.rpc:AsyncToken Imports archived data items into the local cache. | SQLiteOfflineAdapter
|  | initializeCacheStore():void Initialize the cacheId store. | DataServiceOfflineAdapter
|  | initializeOfflineMetadata(metadata:Metadata):void [override] Initializes the offline cache. | SQLiteOfflineAdapter
|  | isConnected():Boolean Returns true if the local store is "connected"; for example, if the local database is open. | DataServiceOfflineAdapter
|  | isPrototypeOf(theClass:Object):Boolean Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. | Object
|  | isQuerySupported():Boolean [override] Indicates whether the adapter supports query execution. | SQLiteOfflineAdapter
|  | propertyIsEnumerable(name:String):Boolean Indicates whether the specified property exists and is enumerable. | Object
|  | restoreQuery(queryParams:Object):Object Restores queries. | DataServiceOfflineAdapter
|  | retrieveMetaData():Object Look up the metadata for a given destination. | DataServiceOfflineAdapter
|  | rollback():void Rolls back any current changes on the local store. | DataServiceOfflineAdapter
|  | saveItems(items:Array):void [override] Add/Remove all the items specified within the dictionary. | SQLiteOfflineAdapter
|  | saveMessageCache(messageCache:DataMessageCache, unmergedMessages:Array):void Saves the pending uncommitted messages and unmerges messages. | DataServiceOfflineAdapter
|  | saveMetaData(metadata:Object):void Save the meta data configuration for a given destination. | DataServiceOfflineAdapter
|  | saveQuery(queryParams:Object, data:Object):void Saves queries to be replayed offline later. | DataServiceOfflineAdapter
|  | setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void Sets the availability of a dynamic property for loop operations. | Object
|  | toLocaleString():String Returns the string representation of this object, formatted according to locale-specific conventions. | Object
|  | toString():String Returns the string representation of the specified object. | Object
|  | updateOfflineItem(item:Object, propChangeList:Array):void [override] Updates the specified properties of the specified offline item in the local store. | SQLiteOfflineAdapter
|  | updateOfflineItems(itemUpdates:Dictionary):void [override] It is used to update the items that were modified to the local store. | SQLiteOfflineAdapter
|  | valueOf():Object Returns the primitive value of the specified object. | Object

Protected Methods

| Method | Defined By
--- | --- | ---
|  | getFieldColumnName(fieldName:String):String Returns the column name for the specified field, or null if there is no column for the field. | SQLiteOfflineAdapter
|  | getQueryCriteria(args:Array):String OfflineAdapter implementations should override this method with an implementation that returns an appropriate SQL WHERE clause for a given set of fill parameters. | SQLiteOfflineAdapter
|  | getQueryCriteriaParameters(args:Array):Object OfflineAdapter implementation should override this method with an implementation that returns the values used to substitute parameters in the WHERE clause from getQueryCriteria. | SQLiteOfflineAdapter
|  | getQueryOrder(args:Array):String OfflineAdapter implementations should override this method with an implementation that returns an appropriate SQL ORDER BY clause for a given set of fill parameters. | SQLiteOfflineAdapter
|  | getTargetColumnName(referencePath:Array):String Returns the column name for the specified path. | SQLiteOfflineAdapter
|  | getTargetTableName(referencePath:Array):String Walk the specified path to find the table responsible for the property path. | SQLiteOfflineAdapter
|  | getUIDColumnName():String Obtain the column that contains the entity item UID values. | SQLiteOfflineAdapter
|  | internalExecuteOfflineQuery(sqlText:String, parameters:Object, startIndex:int, numItems:int):mx.rpc:AsyncToken Executes a SQL query against the local store and returns a collection of strongly typed items. | SQLiteOfflineAdapter

Constructor Detail

### SQLiteOfflineAdapter

()
Constructor

`public function SQLiteOfflineAdapter()`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 3.1

Runtime Versions: | Flash Player 9, AIR 1.1

Constructor.

Method Detail

### addOfflineItem

()
method

`override public function addOfflineItem(item:Object):void`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 3.1

Runtime Versions: | Flash Player 9, AIR 1.1

Adds the specified offline item to the localStore.

Parameters

| `item:Object` — The item to save to the local store.

### appendItemData

()
method

`public function appendItemData(archiveData:IDataOutput, version:String, changedItems:ChangedItems):void`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 4.5

Runtime Versions: | Flash Player 10.1, AIR 2.0

Appends to the byte array the specified data items. Use this method to aggregate multiple data service (data manager) archives together.

Parameters

| `archiveData:IDataOutput` — - the output stream to append to.
| `version:String` — - the version number to perform format mismatch checking with. The intention is that this should change only when the data format changes.
| `changedItems:ChangedItems` — - describes the created, updated, and deleted items to be imported into the local cache. Note that the timestamp and fillParameters must be specified, to allow subsequent synchronizeFill() calls to work properly to match the imported data.

### deleteOfflineItem

()
method

`override public function deleteOfflineItem(uid:String):void`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 3.1

Runtime Versions: | Flash Player 9, AIR 1.1

Deletes the specified offine item with the matching uid from the local store.

Parameters

| `uid:String` — the uid of the item to delete.

### executeOfflineQuery

()
method

`override public function executeOfflineQuery(propSpecifier:PropertySpecifier, args:Array, startIndex:int, numItems:int):mx.rpc:AsyncToken`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 3.1

Runtime Versions: | Flash Player 9, AIR 1.1

Used with SQLite adapters to execute dynamic queries locally.

The default implementation of this function will build a SQL statement for the query in the following manner:

1. The SELECT clause will be based on the passed-in property specifier.
2. The WHERE clause will be determined by an invocation to `getQueryCriteria()`, which custom implementations should override to return the appropriate WHERE clause for a given set of fill parameters.
3. The LIMIT (range of selected items) clause will be determined by the start index and number of items arguments.

Once the whole SQL statement has been constructed, it is passed to `internalExecuteOfflineQuery` for execution.

Custom implementations should only override this method if they want to perform the full SQL statement creation process on their own.

Parameters

| `propSpecifier:PropertySpecifier` — property specifier determines the SELECT clause for the query
| `args:Array` — fill arguments used by custom implementations to determine the WHERE clause for the query
| `startIndex:int` — start index for a paged query
| `numItems:int` — number of items to retrieve for a paged query or -1 to retrieve all.

Returns

| `mx.rpc:AsyncToken` — AsyncToken with the result being an array of strongly typed items

### exportItemData

()
method

`public function exportItemData(version:String, changedItems:ChangedItems):ByteArray`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 4.5

Runtime Versions: | Flash Player 10.1, AIR 2.0

Generates a new serialized archive of the specified data items which then can be persisted as appropriate.

Parameters

| `version:String` — - the version number to perform format mismatch checking with. The intention is that this should change only when the data format changes.
| `changedItems:ChangedItems` — - describes the created, updated, and deleted items to be imported into the local cache. Note that the timestamp and fillParameters must be specified, to allow subsequent synchronizeFill() calls to work properly to match the imported data.

Returns

| `ByteArray` — a ByteArray of the serialized data.

### getFieldColumnName

()
method

`protected function getFieldColumnName(fieldName:String):String`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 3.1

Runtime Versions: | Flash Player 9, AIR 1.1

Returns the column name for the specified field, or null if there is no column for the field.

By default the column name is the same as the field name, unless it conflicts with an SQLite keyword, in which case it is prefixed with an _.

Parameters

| `fieldName:String` — name of the field.

Returns

| `String` — column name for the given field.

### getItemReferenceIds

()
method

`override public function getItemReferenceIds(uid:String, propName:String):Array`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 3.1

Runtime Versions: | Flash Player 9, AIR 1.1

Get the ids of the associated items for a given item uid and an association property. Supported only for SQLLite implementations.

Parameters

| `uid:String` — the uid of the item owning the association.
| `propName:String` — the association property name.

Returns

| `Array` — an array of ids for referenced items of the association.

### getItems

()
method

`override public function getItems(uidArray:Array):Dictionary`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 3.1

Runtime Versions: | Flash Player 9, AIR 1.1

Restores all the items specified using the uid array specified for a given destination.

Parameters

| `uidArray:Array` — an array of uids to fetch

Returns

| `Dictionary` — a map of uid to items

### getQueryCriteria

()
method

`protected function getQueryCriteria(args:Array):String`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 3.1

Runtime Versions: | Flash Player 9, AIR 1.1

OfflineAdapter implementations should override this method with an implementation that returns an appropriate SQL WHERE clause for a given set of fill parameters. The WHERE clause should conform to the schema generated for the offline store for the destination in context. The convention for this schema is that item-class property names are mapped one-to-one to the column names of their storage tables.

Note that the WHERE clause may refer only to columns of the table backing items for the destination in context.

This method is called by `executeOfflineQuery` in order to determine the WHERE clause to use for the query being executed.

Parameters

| `args:Array` — fill parameters.

Returns

| `String` — SQL WHERE clause for the corresponding fill parameters. Returns null if no WHERE clause need be used for the corresponding fill paramters. Default implementation returns null for all fill parameters.

### getQueryCriteriaParameters

()
method

`protected function getQueryCriteriaParameters(args:Array):Object`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 3.1

Runtime Versions: | Flash Player 9, AIR 1.1

OfflineAdapter implementation should override this method with an implementation that returns the values used to substitute parameters in the WHERE clause from `getQueryCriteria`.

This method is called by the `executeOfflineQuery()` method to determine the substitutions that are required for the query being executed.

Parameters

| `args:Array` — fill parameters.

Returns

| `Object` — Object with key-value pairs. The keys represent the names of the parameters to replace and the values correspond to the substitution values. Positional parameters can be substituted using integer keys. Default implementation returns null.

### getQueryOrder

()
method

`protected function getQueryOrder(args:Array):String`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 3.1

Runtime Versions: | Flash Player 9, AIR 1.1

OfflineAdapter implementations should override this method with an implementation that returns an appropriate SQL ORDER BY clause for a given set of fill parameters. The ORDER BY clause should conform to the schema generated for the offline store for the destination in context. The convention for this schema is that item-class property names are mapped one-to-one to the column names of their storage tables. Note that the ORDER BY clause can refer only to columns of the table backing items for the destination in context.

This method is called by the `executeOfflineQuery()` method to determine the ORDER BY clause to use for the query being executed.

Parameters

| `args:Array` — fill parameters.

Returns

| `String` — SQL ORDER BY clause for the corresponding fill parameters. Default implementation returns the column name for the UID.

### getTargetColumnName

()
method

`protected function getTargetColumnName(referencePath:Array):String`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 3.1

Runtime Versions: | Flash Player 9, AIR 1.1

Returns the column name for the specified path. Note that the column name might be stored in a different table. This routine is mainly used to assist model-generated code.

Parameters

| `referencePath:Array` — path

Returns

| `String` — the column name that corresponds to the path, or null if there is none

### getTargetTableName

()
method

`protected function getTargetTableName(referencePath:Array):String`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 3.1

Runtime Versions: | Flash Player 9, AIR 1.1

Walk the specified path to find the table responsible for the property path. This routine is mainly used to assist model-generated code.

Parameters

| `referencePath:Array` — path

Returns

| `String` — the table name

### getUIDColumnName

()
method

`protected function getUIDColumnName():String`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 3.1

Runtime Versions: | Flash Player 9, AIR 1.1

Obtain the column that contains the entity item UID values.

Returns

| `String` — the column that contains the entity item UID values.

### importItemData

()
method

`public function importItemData(expectedVersion:String, archiveData:IDataInput):mx.rpc:AsyncToken`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 4.5

Runtime Versions: | Flash Player 10.1, AIR 2.0

Imports archived changed items instance from the byte array, which typically comes from a file.

Parameters

| `expectedVersion:String` — - the expected version of the archive. An error is thrown if the archive version does not match.
| `archiveData:IDataInput` — - the AMF serialized changedItem instance, as described in the {

Returns

| `mx.rpc:AsyncToken` — AsyncToken that indicates when the items have been applied to the local cache.

### importItems

()
method

`public function importItems(changedItems:ChangedItems):mx.rpc:AsyncToken`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 4.5

Runtime Versions: | Flash Player 10.1, AIR 2.0

Imports archived data items into the local cache.

Parameters

| `changedItems:ChangedItems` — - describes the created, updated, and deleted items to be imported into the local cache. Note that the resultTimestamp and fillParameters must be specified, to allow subsequent synchronizeFill() calls to work properly to match the imported data.

Returns

| `mx.rpc:AsyncToken` — AsyncToken that indicates when the items have been applied to the local cache.

### initializeOfflineMetadata

()
method

`override public function initializeOfflineMetadata(metadata:Metadata):void`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 3.1

Runtime Versions: | Flash Player 9, AIR 1.1

Initializes the offline cache. Supported only for SQLLite implementations.

Parameters

| `metadata:Metadata` — the metadata describing the destination.

### internalExecuteOfflineQuery

()
method

`protected function internalExecuteOfflineQuery(sqlText:String, parameters:Object, startIndex:int, numItems:int):mx.rpc:AsyncToken`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 3.1

Runtime Versions: | Flash Player 9, AIR 1.1

Executes a SQL query against the local store and returns a collection of strongly typed items.

Parameters

| `sqlText:String` — SQL clause to use during query exectuion, as determined by the `executeOfflineQuery()` method with the help of the `getQueryCriteria()` method
| `parameters:Object` — map of key-value pairs used for parameter replacements
| `startIndex:int` — the starting index for paging
| `numItems:int` — number of items to get or -1 if everything should be returned

Returns

| `mx.rpc:AsyncToken` — AsyncToken with the result being an array of strongly typed items

### isQuerySupported

()
method

`override public function isQuerySupported():Boolean`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 3.1

Runtime Versions: | Flash Player 9, AIR 1.1

Indicates whether the adapter supports query execution. To support query execution, implementations of this adapter must implement the `getQueryCriteria()` method or override the `executeOfflineQuery()` method By default, the value is set to false.

Returns

| `Boolean` — true if the adapter supports query execution.

### saveItems

()
method

`override public function saveItems(items:Array):void`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 3.1

Runtime Versions: | Flash Player 9, AIR 1.1

Add/Remove all the items specified within the dictionary. If the dictionary contains the managed object, then it is persisted to the local store. If it contains the UID as the key, then the item is removed from the store.

Parameters

| `items:Array` — an array of items to save

### updateOfflineItem

()
method

`override public function updateOfflineItem(item:Object, propChangeList:Array):void`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 3.1

Runtime Versions: | Flash Player 9, AIR 1.1

Updates the specified properties of the specified offline item in the local store. The property change list is not used with default local shared object implementation as it is not needed.

Parameters

| `item:Object` — the item to update, containing new values.
| `propChangeList:Array` — a list of properties that are being updated.

### updateOfflineItems

()
method

`override public function updateOfflineItems(itemUpdates:Dictionary):void`

Language Version: | ActionScript 3.0

Product Version: | Adobe Digital Enterprise Platform Data Services for Java EE 3.1

Runtime Versions: | Flash Player 9, AIR 1.1

It is used to update the items that were modified to the local store. It takes in a dictionary where the key passed in is the updated item self and the value would be a array of the properties changes. The property change list is not used with default local shared object implementation as it is not needed.

Parameters

| `itemUpdates:Dictionary` — the map of items to the array of changed properties

© 2015 Adobe Systems Incorporated. All rights reserved.
Mon Apr 10 2017, 12:28 PM -07:00