Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / air / src / sql / Proxy.js
diff --git a/air/src/sql/Proxy.js b/air/src/sql/Proxy.js
deleted file mode 100644 (file)
index c537c6d..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/*\r
- * Ext JS Library 0.30\r
- * Copyright(c) 2006-2009, Ext JS, LLC.\r
- * licensing@extjs.com\r
- * \r
- * http://extjs.com/license\r
- */\r
-\r
-/**\r
- * @class Ext.sql.Proxy\r
- * @extends Ext.data.DataProxy\r
- * An implementation of {@link Ext.data.DataProxy} that reads from a SQLLite\r
- * database.\r
- *\r
- * @constructor\r
- * @param {Object} conn an {@link Ext.sql.Connection} object\r
- * @param {String} table The name of the database table\r
- * @param {String} keyName The primary key of the table\r
- * @param {Ext.data.Store} store The datastore to bind to\r
- * @param {Boolean} readonly By default all changes to the store will be persisted\r
- * to the database. Set this to true to override to make the store readonly.\r
- */\r
-Ext.sql.Proxy = function(conn, table, keyName, store, readonly){\r
-    Ext.sql.Proxy.superclass.constructor.call(this);\r
-    this.conn = conn;\r
-    this.table = this.conn.getTable(table, keyName);\r
-    this.store = store;\r
-\r
-       if (readonly !== true) {\r
-               this.store.on('add', this.onAdd, this);\r
-               this.store.on('update', this.onUpdate, this);\r
-               this.store.on('remove', this.onRemove, this);\r
-       }\r
-};\r
-\r
-Ext.sql.Proxy.DATE_FORMAT = 'Y-m-d H:i:s';\r
-\r
-Ext.extend(Ext.sql.Proxy, Ext.data.DataProxy, {\r
-    load : function(params, reader, callback, scope, arg){\r
-       if(!this.conn.isOpen()){ // assume that the connection is in the process of opening\r
-               this.conn.on('open', function(){\r
-                       this.load(params, reader, callback, scope, arg);\r
-               }, this, {single:true});\r
-               return;\r
-       };\r
-       if(this.fireEvent("beforeload", this, params, reader, callback, scope, arg) !== false){\r
-                       var clause = params.where || '';\r
-                       var args = params.args || [];\r
-                       var group = params.groupBy;\r
-                       var sort = params.sort;\r
-                       var dir = params.dir;\r
-\r
-                       if(group || sort){\r
-                               clause += ' ORDER BY ';\r
-                               if(group && group != sort){\r
-                                       clause += group + ' ASC, ';\r
-                               }\r
-                               clause += sort + ' ' + (dir || 'ASC');\r
-                       }\r
-\r
-                       var rs = this.table.selectBy(clause, args);\r
-                       this.onLoad({callback:callback, scope:scope, arg:arg, reader: reader}, rs);\r
-        }else{\r
-            callback.call(scope||this, null, arg, false);\r
-        }\r
-    },\r
-\r
-    onLoad : function(trans, rs, e, stmt){\r
-        if(rs === false){\r
-               this.fireEvent("loadexception", this, null, trans.arg, e);\r
-            trans.callback.call(trans.scope||window, null, trans.arg, false);\r
-            return;\r
-       }\r
-       var result = trans.reader.readRecords(rs);\r
-        this.fireEvent("load", this, rs, trans.arg);\r
-        trans.callback.call(trans.scope||window, result, trans.arg, true);\r
-    },\r
-\r
-    processData : function(o){\r
-       var fs = this.store.fields;\r
-       var r = {};\r
-       for(var key in o){\r
-               var f = fs.key(key), v = o[key];\r
-                       if(f){\r
-                               if(f.type == 'date'){\r
-                                       r[key] = v ? v.format(Ext.sql.Proxy.DATE_FORMAT,10) : '';\r
-                               }else if(f.type == 'boolean'){\r
-                                       r[key] = v ? 1 : 0;\r
-                               }else{\r
-                                       r[key] = v;\r
-                               }\r
-                       }\r
-               }\r
-               return r;\r
-    },\r
-\r
-    onUpdate : function(ds, record){\r
-       var changes = record.getChanges();\r
-       var kn = this.table.keyName;\r
-       this.table.updateBy(this.processData(changes), kn + ' = ?', [record.data[kn]]);\r
-       record.commit(true);\r
-    },\r
-\r
-    onAdd : function(ds, records, index){\r
-       for(var i = 0, len = records.length; i < len; i++){\r
-               this.table.insert(this.processData(records[i].data));\r
-       }\r
-    },\r
-\r
-    onRemove : function(ds, record, index){\r
-               var kn = this.table.keyName;\r
-       this.table.removeBy(kn + ' = ?', [record.data[kn]]);\r
-    }\r
-});
\ No newline at end of file