[Pkg-javascript-commits] [dojo] 10/32: backport fixes from refs #12491, refs #12597, and refs #11537

David Prévot taffit at moszumanska.debian.org
Thu Aug 21 17:39:07 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag 1.6.2
in repository dojo.

commit 77b24788ec6810cd7d559b8c9703026a4fb67229
Author: Kris Zyp <kriszyp at gmail.com>
Date:   Fri Apr 8 16:45:38 2011 +0000

    backport fixes from refs #12491, refs #12597, and refs #11537
    
    git-svn-id: http://svn.dojotoolkit.org/src/branches/1.6/dojo@24239 560b804f-0ae3-0310-86f3-f6aa0a117693
---
 data/ObjectStore.js             |   9 +-
 store/Cache.js                  |   1 +
 store/JsonRest.js               |   8 +-
 store/Memory.js                 |  12 +-
 store/Observable.js             |   1 +
 store/api/Store.js              | 297 ++++++++++++++++++++++++++++++++++++++++
 store/util/SimpleQueryEngine.js |  27 ----
 7 files changed, 317 insertions(+), 38 deletions(-)

diff --git a/data/ObjectStore.js b/data/ObjectStore.js
index be1fda4..f675769 100644
--- a/data/ObjectStore.js
+++ b/data/ObjectStore.js
@@ -176,8 +176,13 @@ dojo.declare("dojo.data.ObjectStore", null,{
 						args.onComplete.call(scope, args.onItem ? null : results, args);
 					}
 					return results;
-				}, args.onError && dojo.hitch(scope, args.onError));
-			}, args.onError && dojo.hitch(scope, args.onError));
+				}, errorHandler);
+			}, errorHandler);
+			function errorHandler(error){
+				if(args.onError){
+					args.onError.call(scope, error, args);
+				}
+			}
 			args.abort = function(){
 				// abort the request
 				if(results.cancel){
diff --git a/store/Cache.js b/store/Cache.js
index dd1d788..4897ecb 100644
--- a/store/Cache.js
+++ b/store/Cache.js
@@ -1,4 +1,5 @@
 define("dojo/store/Cache", ["dojo"], function(dojo) {
+dojo.getObject("store", true, dojo);
 
 /*=====
 dojo.declare("dojo.store.__CacheArgs", null, {
diff --git a/store/JsonRest.js b/store/JsonRest.js
index a41c54e..05723fe 100644
--- a/store/JsonRest.js
+++ b/store/JsonRest.js
@@ -49,7 +49,7 @@ dojo.declare("dojo.store.JsonRest", null, {
 		//		if the object has an id, otherwise it will trigger a POST request.
 		// object: Object
 		//		The object to store.
-		// options: Object?
+		// options: dojo.store.api.Store.PutDirectives?
 		//		Additional metadata for storing the data.  Includes an "id"
 		//		property if a specific id is to be used.
 		//	returns: Number
@@ -73,7 +73,7 @@ dojo.declare("dojo.store.JsonRest", null, {
 		//		if the object has an id, otherwise it will trigger a POST request.
 		// object: Object
 		//		The object to store.
-		// options: Object?
+		// options: dojo.store.api.Store.PutDirectives?
 		//		Additional metadata for storing the data.  Includes an "id"
 		//		property if a specific id is to be used.
 		options = options || {};
@@ -95,9 +95,9 @@ dojo.declare("dojo.store.JsonRest", null, {
 		//		query added as a query string.
 		// query: Object
 		//		The query to use for retrieving objects from the store.
-		//	options: dojo.store.util.SimpleQueryEngine.__queryOptions?
+		// options: dojo.store.api.Store.QueryOptions?
 		//		The optional arguments to apply to the resultset.
-		//	returns: dojo.store.util.QueryResults
+		//	returns: dojo.store.api.Store.QueryResults
 		//		The results of the query, extended with iterative methods.
 		var headers = {Accept: "application/javascript, application/json"};
 		options = options || {};
diff --git a/store/Memory.js b/store/Memory.js
index ebea506..87e57cb 100644
--- a/store/Memory.js
+++ b/store/Memory.js
@@ -1,9 +1,11 @@
 define("dojo/store/Memory", ["dojo", "dojo/store/util/QueryResults", "dojo/store/util/SimpleQueryEngine"], function(dojo) {
 
 dojo.declare("dojo.store.Memory", null, {
+	// summary:
+	//		This is a basic in-memory object store. It implements dojo.store.api.Store.
 	constructor: function(/*dojo.store.Memory*/ options){
 		// summary:
-		//		This is a basic in-memory object store.
+		//		Creates a memory object store.
 		// options:
 		//		This provides any configuration information that will be mixed into the store.
 		// 		This should generally include the data property to provide the starting set of data.
@@ -49,7 +51,7 @@ dojo.declare("dojo.store.Memory", null, {
 		//		Stores an object
 		// 	object: Object
 		//		The object to store.
-		// 	options: Object?
+		// 	options: dojo.store.api.Store.PutDirectives??
 		//		Additional metadata for storing the data.  Includes an "id"
 		//		property if a specific id is to be used.
 		//	returns: Number
@@ -71,7 +73,7 @@ dojo.declare("dojo.store.Memory", null, {
 		//		Creates an object, throws an error if the object already exists
 		// 	object: Object
 		//		The object to store.
-		// 	options: Object?
+		// 	options: dojo.store.api.Store.PutDirectives??
 		//		Additional metadata for storing the data.  Includes an "id"
 		//		property if a specific id is to be used.
 		//	returns: Number
@@ -100,9 +102,9 @@ dojo.declare("dojo.store.Memory", null, {
 		//		Queries the store for objects.
 		// 	query: Object
 		//		The query to use for retrieving objects from the store.
-		//	options: dojo.store.util.SimpleQueryEngine.__queryOptions?
+		//	options: dojo.store.api.Store.QueryOptions?
 		//		The optional arguments to apply to the resultset.
-		//	returns: dojo.store.util.QueryResults
+		//	returns: dojo.store.api.Store.QueryResults
 		//		The results of the query, extended with iterative methods.
 		//
 		// 	example:
diff --git a/store/Observable.js b/store/Observable.js
index c063060..c3d23b0 100644
--- a/store/Observable.js
+++ b/store/Observable.js
@@ -1,4 +1,5 @@
 define("dojo/store/Observable", ["dojo"], function(dojo) {
+dojo.getObject("store", true, dojo);
 
 dojo.store.Observable = function(store){
 	// summary:
diff --git a/store/api/Store.js b/store/api/Store.js
new file mode 100644
index 0000000..f48f821
--- /dev/null
+++ b/store/api/Store.js
@@ -0,0 +1,297 @@
+define([], function() {
+  //  module:
+  //    dojo/store/api/Store
+  //  summary:
+  //    The module defines the Dojo object store interface.
+
+dojo.declare("dojo.store.api.Store", null, {
+	//	summary:
+	//		This is an abstract API that data provider implementations conform to.
+	//		This file defines methods signatures and intentionally leaves all the
+	//		methods unimplemented.  For more information on the dojo.store APIs,
+	//		please visit: http://dojotoolkit.org/reference-guide/dojo/store.html
+	//		Every method and property is optional, and is only needed if the functionality
+	//		it provides is required.
+	//		Every method may return a promise for the specified return value if the 
+	// 		execution of the operation is asynchronous (except
+	//		for query() which already defines an async return value).
+
+	// idProperty: String
+	//		If the store has a single primary key, this tndicates the property to use as the 
+	// 		identity property. The values of this property should be unique.
+	idProperty: "id",
+
+	// queryEngine: Function
+	//		If the store can be queried locally (on the client side in JS), this defines 
+	// 		the query engine to use for querying the data store. 
+	//		This takes a query and query options and returns a function that can execute 
+	// 		the provided query on a JavaScript array. The queryEngine may be replace to 
+	// 		provide more sophisticated querying capabilities. For example:
+	// 		| var query = store.queryEngine({foo:"bar"}, {count:10});
+	//		| query(someArray) -> filtered array
+	// 		The returned query function may have a "matches" property that can be 
+	// 		used to determine if an object matches the query. For example:
+	//		| query.matches({id:"some-object", foo:"bar"}) -> true
+	//		| query.matches({id:"some-object", foo:"something else"}) -> false
+	queryEngine: null,
+
+	get: function(id){
+		//	summary:
+		//		Retrieves an object by its identity
+		//	id: Number
+		//		The identity to use to lookup the object
+		//	returns: Object
+		//		The object in the store that matches the given id.
+	},
+	getIdentity: function(object){
+		// 	summary:
+		//		Returns an object's identity
+		// 	object: Object
+		//		The object to get the identity from
+		//	returns: String|Number
+	},
+	put: function(object, directives){
+		// 	summary:
+		//		Stores an object
+		// 	object: Object
+		//		The object to store.
+		// directives: dojo.store.api.Store.PutDirectives?
+		//		Additional directives for storing objects.
+		//	returns: Number|String
+	},
+	add: function(object, directives){
+		// 	summary:
+		//		Creates an object, throws an error if the object already exists
+		// 	object: Object
+		//		The object to store.
+		// directives: dojo.store.api.Store.PutDirectives?
+		//		Additional directives for creating objects.
+		//	returns: Number|String
+	},
+	remove: function(id){
+		// 	summary:
+		//		Deletes an object by its identity
+		// 	id: Number
+		//		The identity to use to delete the object
+		delete this.index[id];
+		var data = this.data,
+			idProperty = this.idProperty;
+		for(var i = 0, l = data.length; i < l; i++){
+			if(data[i][idProperty] == id){
+				data.splice(i, 1);
+				return;
+			}
+		}
+	},
+	query: function(query, options){
+		// 	summary:
+		//		Queries the store for objects. This does not alter the store, but returns a 
+		//		set of data from the store.
+		// 	query: String|Object|Function
+		//		The query to use for retrieving objects from the store.
+		//	options: dojo.store.api.Store.QueryOptions
+		//		The optional arguments to apply to the resultset.
+		//	returns: dojo.store.api.Store.QueryResults
+		//		The results of the query, extended with iterative methods.
+		//
+		// 	example:
+		// 		Given the following store:
+		//
+		//	...find all items where "prime" is true:
+		//
+		//	|	store.query({ prime: true }).forEach(function(object){
+		//	|		// handle each object
+		//	|	});
+	},
+	transaction: function(){
+		// summary:
+		// 		Starts a new transaction.
+		//		Note that a store user might not call transaction() prior to using put, 
+		// 		delete, etc. in which case these operations effectively could be thought of 
+		// 		as "auto-commit" style actions.
+		//	returns: dojo.store.api.Store.Transaction
+		//		This represents the new current transaction.
+	},
+	getChildren: function(parent, options){
+		//	summary:
+		//		Retrieves the children of an object.
+		// parent: Object
+		// 		The object to find the children of.
+		// options: dojo.store.api.Store.QueryOptions?
+		// 		Additional options to apply to the retrieval of the children.
+		// returns: dojo.store.api.Store.QueryResults
+		// 		A result set of the children of the parent object. 
+	},
+	getMetadata: function(object){
+		// summary:
+		//		Returns any metadata about the object. This may include attribution, 
+		// 		cache directives, history, or version information.
+		//	object: Object
+		//		The object to return metadata for.
+		//	returns: Object
+		//		An object containing metadata.
+	}
+});
+
+dojo.store.api.Store.PutDirectives = function(id, before, parent, overwrite){
+	// summary:
+	//		Directives passed to put() and add() handlers for guiding the update and 
+	// 		creation of stored objects.  
+	// id: String|Number?
+	// 		Indicates the identity of the object if a new object is created
+	// before: Object?
+	//		If the collection of objects in the store has a natural ordering, 
+	// 		this indicates that the created or updated object should be placed before the 
+	//		object specified by the value of this property. A value of null indicates that the 
+	//		object should be last.
+	// parent: Object?,
+	//		If the store is hierarchical (with single parenting) this property indicates the 
+	// 		new parent of the created or updated object.
+	// overwrite: Boolean?
+	//		If this is provided as a boolean it indicates that the object should or should not 
+	// 		overwrite an existing object. A value of true indicates that a new object 
+	// 		should not be created, the operation should update an existing object. A 
+	// 		value of false indicates that an existing object should not be updated, a new 
+	// 		object should be created (which is the same as an add() operation). When 
+	// 		this property is not provided, either an update or creation is acceptable.
+	this.id = id;
+	this.before = before;
+	this.parent = parent;
+	this.overwrite = overwrite;
+};
+
+dojo.store.api.Store.SortInformation = function(attribute, descending){
+	// summary:
+	//		An object describing what attribute to sort on, and the direction of the sort.
+	// attribute: String
+	//		The name of the attribute to sort on.
+	// descending: Boolean
+	//		The direction of the sort.  Default is false.
+	this.attribute = attribute;
+	this.descending = descending;
+};
+
+dojo.store.api.Store.QueryOptions = function(sort, start, count){
+	// summary:
+	//		Optional object with additional parameters for query results.
+	// sort: dojo.store.api.Store.SortInformation[]?
+	//		A list of attributes to sort on, as well as direction
+	//		For example: 
+	// 		| [{attribute:"price, descending: true}]. 
+	// 		If the sort parameter is omitted, then the natural order of the store may be 
+	// 		applied if there is a natural order.	
+	// start: Number?
+	//		The first result to begin iteration on
+	// count: Number?
+	//		The number of how many results should be returned.
+	this.sort = sort;
+	this.start = start;
+	this.count = count;
+};
+
+dojo.declare("dojo.store.api.Store.QueryResults", null, {
+	// summary:
+	//		This is an object returned from query() calls that provides access to the results 
+	// 		of a query. Queries may be executed asynchronously.
+	
+	forEach: function(callback, thisObject){
+		// summary:
+		//		Iterates over the query results, based on 
+		// 		https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/forEach.
+		//		Note that this may executed asynchronously. The callback may be called
+		//		after this function returns.
+		//	callback:
+		//		Function that is called for each object in the query results
+		//	thisObject:
+		//		The object to use as |this| in the callback.
+		
+	},
+	filter: function(callback, thisObject){
+		// summary:
+		//		Filters the query results, based on 
+		// 		https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter.
+		//		Note that this may executed asynchronously. The callback may be called
+		//		after this function returns.
+		//	callback:
+		//		Function that is called for each object in the query results
+		//	thisObject:
+		//		The object to use as |this| in the callback.
+		//	returns: dojo.store.api.Store.QueryResults
+	},
+	map: function(callback, thisObject){
+		// summary:
+		//		Maps the query results, based on 
+		// 		https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map.
+		//		Note that this may executed asynchronously. The callback may be called
+		//		after this function returns.
+		//	callback:
+		//		Function that is called for each object in the query results
+		//	thisObject:
+		//		The object to use as |this| in the callback.
+		//	returns: dojo.store.api.Store.QueryResults
+	},
+	then: function(callback, errorHandler){
+		// summary:
+		//		This registers a callback for when the query is complete, if the query is asynchronous.
+		//		This is an optional method, and may not be present for synchronous queries.
+		//	callback:
+		//		This is called when the query is completed successfully, and is passed a single argument 
+		// 		that is an array representing the query results.
+		//	errorHandler:
+		//		This is called if the query failed, and is passed a single argument that is the error
+		//		for the failure.
+	},
+	observe: function(listener, includeAllUpdates){
+		// summary:
+		//		This registers a callback for notification of when data is modified in the query results.
+		//		This is an optional method, and is usually provided by dojo.store.Observable.
+		//	listener: Function
+		//		The listener function is called when objects in the query results are modified 
+		// 		to affect the query result. The listener function is called with the following 
+		// 		arguments: 
+		// 		| listener(object, removedFrom, insertedInto);
+		//		* The object parameter indicates the object that was create, modified, or deleted.
+		//		* The removedFrom parameter indicates the index in the result array where 
+		// 		the object used to be. If the value is -1, then the object is an addition to 
+		// 		this result set (due to a new object being created, or changed such that it 
+		// 		is a part of the result set).
+		//		* The insertedInto parameter indicates the index in the result array where 
+		// 		the object should be now. If the value is -1, then the object is a removal 
+		// 		from this result set (due to an object being deleted, or changed such that it 
+		// 		is not a part of the result set).
+		//	includeAllUpdates:
+		//		This indicates whether or not to include object updates that do not affect
+		//		the inclusion or order of the object in the query results. By default this is false,
+		//		which means that if any object is updated in such a way that it remains
+		//		in the result set and it's position in result sets is not affected, then the listener 
+		// 		will not be fired. 
+		
+	},
+	// total: Number|Promise?
+	//		This property should be included in if the query options included the "count" 
+	// 		property limiting the result set. This property indicates the total number of objects
+	// 		matching the query (as if "start" and "count" weren't present). This may be
+	//		a promise if the query is asynchronous.
+	total: 0 
+});
+
+dojo.declare("dojo.store.api.Store.Transaction", null, {
+	// summary:
+	//		This is an object returned from transaction() calls that represents the current
+	// 		transaction.
+	
+	commit: function(){
+		// summary:
+		//		Commits the transaction. This may throw an error if it fails. Of if the operation
+		// 		is asynchronous, it may return a promise that represents the eventual success
+		//		or failure of the commit.		
+	},
+	abort: function(callback, thisObject){
+		// summary:
+		//		Aborts the transaction. This may throw an error if it fails. Of if the operation
+		// 		is asynchronous, it may return a promise that represents the eventual success
+		//		or failure of the abort.
+	}
+});
+	
+});
diff --git a/store/util/SimpleQueryEngine.js b/store/util/SimpleQueryEngine.js
index 1355fe4..b747a5f 100644
--- a/store/util/SimpleQueryEngine.js
+++ b/store/util/SimpleQueryEngine.js
@@ -1,33 +1,6 @@
 define("dojo/store/util/SimpleQueryEngine", ["dojo"], function(dojo) {
 dojo.getObject("store.util", true, dojo);
 
-/*=====
-dojo.store.util.SimpleQueryEngine.__sortInformation = function(attribute, descending){
-	// summary:
-	//		An object describing what attribute to sort on, and the direction of the sort.
-	// attribute: String
-	//		The name of the attribute to sort on.
-	// descending: Boolean
-	//		The direction of the sort.  Default is false.
-	this.attribute = attribute;
-	this.descending = descending;
-};
-
-dojo.store.util.SimpleQueryEngine.__queryOptions = function(sort, start, count){
-	// summary:
-	//		Optional object with additional parameters for query results.
-	// sort: dojo.store.util.SimpleQueryEngine.__sortInformation[]?
-	//		A list of attributes to sort on, as well as direction
-	// start: Number?
-	//		The first result to begin iteration on
-	// count: Number?
-	//		The number of how many results should be returned.
-	this.sort = sort;
-	this.start = start;
-	this.count = count;
-};
-=====*/
-
 dojo.store.util.SimpleQueryEngine = function(query, options){
 	// summary:
 	//		Simple query engine that matches using filter functions, named filter

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git



More information about the Pkg-javascript-commits mailing list