Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dojo.provide("karma.kernel.factory.storemodel.Store");
- dojo.require("karma.kernel.factory.storemodel.Transports");
- dojo.require("dojo.store.Observable");
- dojo.require("dojo.data.ObjectStore");
- dojo.require("dojo.store.Cache");
- dojo.require("dojo.store.Memory");
- dojo.require("karma.kernel.factory.store.Cache");
- dojo.require("karma.kernel.factory.store.Memory");
- //>>excludeStart("excludeRql", kwArgs.excludeRql)
- dojo.require("rql.query");
- dojo.require("rql.parser");
- //>>excludeEnd("excludeRql")
- dojo.declare("karma.kernel.factory.storemodel.Store", null, {
- tableName: null,
- _dictLegacyWrappers: null, // Collection of legacy wrappers for this store
- constructor: function(args){
- // summary:
- // args: have the following defined
- // tableName:
- // The name of the database table that this store will represent
- // idProperty:
- // The name of the ID column in the table
- this._dictLegacyWrappers = new dojox.collections.Dictionary();
- this.tableName = args.tableName;
- console.log("creating store for table: " + args.tableName);
- // Create a JSON transport object
- var transports = new karma.kernel.factory.storemodel.Transports();
- args = dojo.mixin(args, {
- target: kernel.config.restServerUrl + args.tableName + "/"
- });
- var transport = transports.get(args);
- // Create an in-memory store
- var memory = new dojo.store.Memory(args);
- memory.queryEngine = rql['js-array'].query;
- //wrap the in-memory store with our "observable fix" in-memory store
- var observableMemory = new karma.kernel.factory.store.Memory(memory);
- // Wrap the transport and in-memory (observable fixed) objects in a queryable cache object
- var cache = new dojo.store.Cache(transport, observableMemory);
- var queryableCache = new karma.kernel.factory.store.Cache(cache,observableMemory);
- // Make our store observable
- var store = new dojo.store.Observable(queryableCache);
- dojo.mixin(this, store);
- },
- getLegacyStore: function(labelProperty){
- // summary:
- // Wraps the store in a legacyStore wrapper (based on the labelProperty), if the legacyStore does not yet exist, and then
- // returns the legacyStore that corresponds to the labelProperty.
- // If this store has already been wrapped in a LegacyStore with this labelProperty, the existing LegacyStore is returned.
- //
- // labelProperty:
- // The name of the column in the table that will be used as the label in legacy widgets
- // If this is a new labelProperty for this store, create a new wrapper, and save it to the dictLegacyStores dictionary.
- if (!this._dictLegacyWrappers.containsKey(labelProperty)) {
- var legacyStore = new dojo.data.ObjectStore({
- objectStore: this,
- labelProperty: labelProperty
- });
- this._dictLegacyWrappers.add(labelProperty, legacyStore);
- }
- return this._dictLegacyWrappers.item(labelProperty);
- }
- });
Add Comment
Please, Sign In to add comment