Packageorg.restfulx.controllers
Classpublic class AuxAIRController
InheritanceAuxAIRController Inheritance flash.events.EventDispatcher

Custom AIR controller that allows performing arbitrary operations (as opposed to CRUD on models) against local SQLite database.



Public Properties
 PropertyDefined by
  initialized : Boolean
indicates if the local database has been set up and is ready to be modified/queried
AuxAIRController
Protected Properties
 PropertyDefined by
  connection : SQLConnection
AuxAIRController
  queue : Array
AuxAIRController
Public Methods
 MethodDefined by
  
AuxAIRController(optsOrOnResult:Object = null, onFault:Function = null, dbFile:File = null)
AuxAIRController
  
executeAnySQL(optsOrClazz:Class, sql:String, includes:Array = null, unmarshall:Boolean = false, cacheBy:String = null):void
This simply executes any SQL that you pass into it optionally allowing you to unmarshall and cache the result
AuxAIRController
  
executeAnySQLInBulk(optsOrClazz:Object, statements:Array):void
This executes any sequence of SQL statements within a trasaction
AuxAIRController
  
findAll(optsOrClazz:Object, conditions:Array = null, includes:Array = null, unmarshall:Boolean = true, cacheBy:String = "index"):void
If you find Rx.models.index in combination with Rx.filter and/or metadata not sufficiently expressive you can perform finds against local SQLite database in a samilar manner to ActiveRecord's find(:all) with conditions.
AuxAIRController
  
findAllBySQL(optsOrClazz:Object, sql:String, includes:Array = null, unmarshall:Boolean = true, cacheBy:String = "index"):void
If you don't want to bother with formatting conditions you can default to writing SQL for SQLite queries yourself.
AuxAIRController
Protected Methods
 MethodDefined by
  
checkConditions(source:Object, conditions:Object):Boolean
AuxAIRController
  
defaultFaultHandler(info:Object, token:Object = null):void
AuxAIRController
  
defaultResultHandler(event:Object, token:Object = null):void
AuxAIRController
  
execute(fqn:String, statement:SQLStatement, includes:Array = null, unmarshall:Boolean = false, cacheBy:String = null):void
AuxAIRController
  
AuxAIRController
  
executeSQLStatement(statement:SQLStatement):void
AuxAIRController
  
getSQLStatement(statement:String):SQLStatement
AuxAIRController
  
initializeConnection(databaseFile:File):void
AuxAIRController
  
invokeResponderResult(responder:IResponder, result:Object):void
AuxAIRController
  
processIncludedRelationships(relationships:Array, fqn:String, data:Array, responder:IResponder = null):void
AuxAIRController
  
queueSQLStatement(statement:SQLStatement):void
AuxAIRController
  
unmarshall(event:ResultEvent):Object
AuxAIRController
  
unmarshallAndCacheResultHandler(event:Object, token:Object = null):void
AuxAIRController
  
unmarshallResultHandler(event:Object, token:Object = null):void
AuxAIRController
Property detail
connectionproperty
protected var connection:SQLConnection
initializedproperty 
public var initialized:Boolean

indicates if the local database has been set up and is ready to be modified/queried

queueproperty 
protected var queue:Array
Constructor detail
AuxAIRController()constructor
public function AuxAIRController(optsOrOnResult:Object = null, onFault:Function = null, dbFile:File = null)

Parameters
optsOrOnResult:Object (default = null) — can be either an anonymous object of options or a result handler function.
 
onFault:Function (default = null) — function to call if there was an error or if unmarshalling fails
 
dbFile:File (default = null) — to use (defaults to Rx.airDatabaseName)
Method detail
checkConditions()method
protected function checkConditions(source:Object, conditions:Object):BooleanParameters
source:Object
 
conditions:Object

Returns
Boolean
defaultFaultHandler()method 
protected function defaultFaultHandler(info:Object, token:Object = null):voidParameters
info:Object
 
token:Object (default = null)
defaultResultHandler()method 
protected function defaultResultHandler(event:Object, token:Object = null):voidParameters
event:Object
 
token:Object (default = null)
execute()method 
protected function execute(fqn:String, statement:SQLStatement, includes:Array = null, unmarshall:Boolean = false, cacheBy:String = null):voidParameters
fqn:String
 
statement:SQLStatement
 
includes:Array (default = null)
 
unmarshall:Boolean (default = false)
 
cacheBy:String (default = null)
executeAnySQL()method 
public function executeAnySQL(optsOrClazz:Class, sql:String, includes:Array = null, unmarshall:Boolean = false, cacheBy:String = null):void

This simply executes any SQL that you pass into it optionally allowing you to unmarshall and cache the result

Parameters
optsOrClazz:Class — RxModel clazz to execute the query on or the options object
 
sql:String — the SQL query to run
 
includes:Array (default = null) — boolean indiciating if the result should be unmarshalled into RxModel instances
 
unmarshall:Boolean (default = false) — RESTful cache method to simulate
 
cacheBy:String (default = null)
executeAnySQLInBulk()method 
public function executeAnySQLInBulk(optsOrClazz:Object, statements:Array):void

This executes any sequence of SQL statements within a trasaction

Parameters
optsOrClazz:Object — RxModel clazz to execute the query on or the options object
 
statements:Array — the array of SQL queries to run
executePendingSQLStatements()method 
protected function executePendingSQLStatements():void
executeSQLStatement()method 
protected function executeSQLStatement(statement:SQLStatement):voidParameters
statement:SQLStatement
findAll()method 
public function findAll(optsOrClazz:Object, conditions:Array = null, includes:Array = null, unmarshall:Boolean = true, cacheBy:String = "index"):void

If you find Rx.models.index in combination with Rx.filter and/or metadata not sufficiently expressive you can perform finds against local SQLite database in a samilar manner to ActiveRecord's find(:all) with conditions. You can optially unmarshall the result and simulate one of:

The motivation for this is quite similar to Rx.http(AuxHTTPController) with the big difference in that works against local SQLite instead of an arbitrary HTTP service.

You can basically use this to perform non-RESTful finds against local SQLite DB when necessary.

Parameters
optsOrClazz:Object — RxModel clazz to do the find on or the options object
 
conditions:Array (default = null) — list of conditions
 
includes:Array (default = null) — additional relationships to bring into scope
 
unmarshall:Boolean (default = true) — boolean indiciating if the result should be unmarshalled into RxModel instances
 
cacheBy:String (default = "index") — RESTful cache method to simulate

Example
Find projects
      var controller:AuxAIRController = new AuxAIRController(onResult);
      controller.findAll(SimpleProperty, ["name LIKE :name AND available = true", {":name": "%2%"}]);
      

Find projects (Alternative Syntax)
      XRx.air(onresult).findAll(SimpleProperty, ["name LIKE :name AND available = true", {":name": "%2%"}]);
      

findAllBySQL()method 
public function findAllBySQL(optsOrClazz:Object, sql:String, includes:Array = null, unmarshall:Boolean = true, cacheBy:String = "index"):void

If you don't want to bother with formatting conditions you can default to writing SQL for SQLite queries yourself.

Parameters
optsOrClazz:Object — RxModel clazz to do the find on or the options object
 
sql:String — the SQL query to run
 
includes:Array (default = null) — list of conditions
 
unmarshall:Boolean (default = true) — boolean indiciating if the result should be unmarshalled into RxModel instances
 
cacheBy:String (default = "index") — RESTful cache method to simulate

See also

getSQLStatement()method 
protected function getSQLStatement(statement:String):SQLStatementParameters
statement:String

Returns
SQLStatement
initializeConnection()method 
protected function initializeConnection(databaseFile:File):voidParameters
databaseFile:File
invokeResponderResult()method 
protected function invokeResponderResult(responder:IResponder, result:Object):voidParameters
responder:IResponder
 
result:Object
processIncludedRelationships()method 
protected function processIncludedRelationships(relationships:Array, fqn:String, data:Array, responder:IResponder = null):voidParameters
relationships:Array
 
fqn:String
 
data:Array
 
responder:IResponder (default = null)
queueSQLStatement()method 
protected function queueSQLStatement(statement:SQLStatement):voidParameters
statement:SQLStatement
unmarshall()method 
protected function unmarshall(event:ResultEvent):ObjectParameters
event:ResultEvent

Returns
Object
unmarshallAndCacheResultHandler()method 
protected function unmarshallAndCacheResultHandler(event:Object, token:Object = null):voidParameters
event:Object
 
token:Object (default = null)
unmarshallResultHandler()method 
protected function unmarshallResultHandler(event:Object, token:Object = null):voidParameters
event:Object
 
token:Object (default = null)