]> git.wh0rd.org - tt-rss.git/blame - lib/dojo/data/api/Read.js.uncompressed.js
upgrade dojo to 1.8.3 (refs #570)
[tt-rss.git] / lib / dojo / data / api / Read.js.uncompressed.js
CommitLineData
f0cfe83e
AD
1define("dojo/data/api/Read", ["../../_base/declare"], function(declare){
2
3// module:
4// dojo/data/api/Read
5
6return declare("dojo.data.api.Read", null, {
7 // summary:
8 // This is an abstract API that data provider implementations conform to.
9 // This file defines methods signatures and intentionally leaves all the
10 // methods unimplemented. For more information on the dojo.data APIs,
11 // please visit: http://www.dojotoolkit.org/node/98
12
13 getValue: function( /* dojo/data/api/Item */ item,
14 /* attribute-name-string */ attribute,
15 /* value? */ defaultValue){
16 // summary:
17 // Returns a single attribute value.
18 // Returns defaultValue if and only if *item* does not have a value for *attribute*.
19 // Returns null if and only if null was explicitly set as the attribute value.
20 // Returns undefined if and only if the item does not have a value for the
21 // given attribute (which is the same as saying the item does not have the attribute).
22 // description:
23 // Saying that an "item x does not have a value for an attribute y"
24 // is identical to saying that an "item x does not have attribute y".
25 // It is an oxymoron to say "that attribute is present but has no values"
26 // or "the item has that attribute but does not have any attribute values".
27 // If store.hasAttribute(item, attribute) returns false, then
28 // store.getValue(item, attribute) will return undefined.
29 // item:
30 // The item to access values on.
31 // attribute:
32 // The attribute to access represented as a string.
33 // defaultValue:
34 // Optional. A default value to use for the getValue return in the attribute does not exist or has no value.
35 // returns:
36 // a literal, an item, null, or undefined (never an array)
37 // exceptions:
38 // Throws an exception if *item* is not an item, or *attribute* is not a string
39 // example:
40 // | var darthVader = store.getValue(lukeSkywalker, "father");
41 throw new Error('Unimplemented API: dojo.data.api.Read.getValue');
42 },
43
44 getValues: function(/* dojo/data/api/Item */ item,
45 /* attribute-name-string */ attribute){
46 // summary:
47 // This getValues() method works just like the getValue() method, but getValues()
48 // always returns an array rather than a single attribute value. The array
49 // may be empty, may contain a single attribute value, or may contain
50 // many attribute values.
51 // If the item does not have a value for the given attribute, then getValues()
52 // will return an empty array: []. (So, if store.hasAttribute(item, attribute)
53 // has a return of false, then store.getValues(item, attribute) will return [].)
54 // item:
55 // The item to access values on.
56 // attribute:
57 // The attribute to access represented as a string.
58 // returns:
59 // an array that may contain literals and items
60 // exceptions:
61 // Throws an exception if *item* is not an item, or *attribute* is not a string
62 // example:
63 // | var friendsOfLuke = store.getValues(lukeSkywalker, "friends");
64 throw new Error('Unimplemented API: dojo.data.api.Read.getValues');
65 },
66
67 getAttributes: function(/* dojo/data/api/Item */ item){
68 // summary:
69 // Returns an array with all the attributes that this item has. This
70 // method will always return an array; if the item has no attributes
71 // at all, getAttributes() will return an empty array: [].
72 // item:
73 // The item to access attributes on.
74 // exceptions:
75 // Throws an exception if *item* is not an item, or *attribute* is not a string
76 // example:
77 // | var array = store.getAttributes(kermit);
78 throw new Error('Unimplemented API: dojo.data.api.Read.getAttributes');
79 },
80
81 hasAttribute: function( /* dojo/data/api/Item */ item,
82 /* attribute-name-string */ attribute){
83 // summary:
84 // Returns true if the given *item* has a value for the given *attribute*.
85 // item:
86 // The item to access attributes on.
87 // attribute:
88 // The attribute to access represented as a string.
89 // exceptions:
90 // Throws an exception if *item* is not an item, or *attribute* is not a string
91 // example:
92 // | var trueOrFalse = store.hasAttribute(kermit, "color");
93 throw new Error('Unimplemented API: dojo.data.api.Read.hasAttribute');
94 },
95
96 containsValue: function(/* dojo/data/api/Item */ item,
97 /* attribute-name-string */ attribute,
98 /* anything */ value){
99 // summary:
100 // Returns true if the given *value* is one of the values that getValues()
101 // would return.
102 // item:
103 // The item to access values on.
104 // attribute:
105 // The attribute to access represented as a string.
106 // value:
107 // The value to match as a value for the attribute.
108 // exceptions:
109 // Throws an exception if *item* is not an item, or *attribute* is not a string
110 // example:
111 // | var trueOrFalse = store.containsValue(kermit, "color", "green");
112 throw new Error('Unimplemented API: dojo.data.api.Read.containsValue');
113 },
114
115 isItem: function(/* anything */ something){
116 // summary:
117 // Returns true if *something* is an item and came from the store instance.
118 // Returns false if *something* is a literal, an item from another store instance,
119 // or is any object other than an item.
120 // something:
121 // Can be anything.
122 // example:
123 // | var yes = store.isItem(store.newItem());
124 // | var no = store.isItem("green");
125 throw new Error('Unimplemented API: dojo.data.api.Read.isItem');
126 },
127
128 isItemLoaded: function(/* anything */ something){
129 // summary:
130 // Returns false if isItem(something) is false. Returns false if
131 // if isItem(something) is true but the the item is not yet loaded
132 // in local memory (for example, if the item has not yet been read
133 // from the server).
134 // something:
135 // Can be anything.
136 // example:
137 // | var yes = store.isItemLoaded(store.newItem());
138 // | var no = store.isItemLoaded("green");
139 throw new Error('Unimplemented API: dojo.data.api.Read.isItemLoaded');
140 },
141
142 loadItem: function(/* Object */ keywordArgs){
143 // summary:
144 // Given an item, this method loads the item so that a subsequent call
145 // to store.isItemLoaded(item) will return true. If a call to
146 // isItemLoaded() returns true before loadItem() is even called,
147 // then loadItem() need not do any work at all and will not even invoke
148 // the callback handlers. So, before invoking this method, check that
149 // the item has not already been loaded.
150 // keywordArgs:
151 // An anonymous object that defines the item to load and callbacks to invoke when the
152 // load has completed. The format of the object is as follows:
153 // | {
154 // | item: object,
155 // | onItem: Function,
156 // | onError: Function,
157 // | scope: object
158 // | }
159 //
160 // ####The *item* parameter
161 //
162 // The item parameter is an object that represents the item in question that should be
163 // contained by the store. This attribute is required.
164 //
165 // ####The *onItem* parameter
166 //
167 // Function(item)
168 // The onItem parameter is the callback to invoke when the item has been loaded. It takes only one
169 // parameter, the fully loaded item.
170 //
171 // ####The *onError* parameter
172 //
173 // Function(error)
174 // The onError parameter is the callback to invoke when the item load encountered an error. It takes only one
175 // parameter, the error object
176 //
177 // ####The *scope* parameter
178 //
179 // If a scope object is provided, all of the callback functions (onItem,
180 // onError, etc) will be invoked in the context of the scope object.
181 // In the body of the callback function, the value of the "this"
182 // keyword will be the scope object. If no scope object is provided,
183 // the callback functions will be called in the context of dojo.global().
184 // For example, onItem.call(scope, item, request) vs.
185 // onItem.call(dojo.global(), item, request)
186 if(!this.isItemLoaded(keywordArgs.item)){
187 throw new Error('Unimplemented API: dojo.data.api.Read.loadItem');
188 }
189 },
190
191 fetch: function(/* Object */ keywordArgs){
192 // summary:
193 // Given a query and set of defined options, such as a start and count of items to return,
194 // this method executes the query and makes the results available as data items.
195 // The format and expectations of stores is that they operate in a generally asynchronous
196 // manner, therefore callbacks are always used to return items located by the fetch parameters.
197 // description:
198 // A Request object will always be returned and is returned immediately.
199 // The basic request is nothing more than the keyword args passed to fetch and
200 // an additional function attached, abort(). The returned request object may then be used
201 // to cancel a fetch. All data items returns are passed through the callbacks defined in the
202 // fetch parameters and are not present on the 'request' object.
203 //
204 // This does not mean that custom stores can not add methods and properties to the request object
205 // returned, only that the API does not require it. For more info about the Request API,
206 // see dojo/data/api/Request
207 // keywordArgs:
208 // The keywordArgs parameter may either be an instance of
209 // conforming to dojo/data/api/Request or may be a simple anonymous object
210 // that may contain any of the following:
211 // | {
212 // | query: query-object or query-string,
213 // | queryOptions: object,
214 // | onBegin: Function,
215 // | onItem: Function,
216 // | onComplete: Function,
217 // | onError: Function,
218 // | scope: object,
219 // | start: int
220 // | count: int
221 // | sort: array
222 // | }
223 // All implementations should accept keywordArgs objects with any of
224 // the 9 standard properties: query, onBegin, onItem, onComplete, onError
225 // scope, sort, start, and count. Some implementations may accept additional
226 // properties in the keywordArgs object as valid parameters, such as
227 // {includeOutliers:true}.
228 //
229 // ####The *query* parameter
230 //
231 // The query may be optional in some data store implementations.
232 // The dojo/data/api/Read API does not specify the syntax or semantics
233 // of the query itself -- each different data store implementation
234 // may have its own notion of what a query should look like.
235 // However, as of dojo 0.9, 1.0, and 1.1, all the provided datastores in dojo.data
236 // and dojox.data support an object structure query, where the object is a set of
237 // name/value parameters such as { attrFoo: valueBar, attrFoo1: valueBar1}. Most of the
238 // dijit widgets, such as ComboBox assume this to be the case when working with a datastore
239 // when they dynamically update the query. Therefore, for maximum compatibility with dijit
240 // widgets the recommended query parameter is a key/value object. That does not mean that the
241 // the datastore may not take alternative query forms, such as a simple string, a Date, a number,
242 // or a mix of such. Ultimately, The dojo/data/api/Read API is agnostic about what the query
243 // format.
244 //
245 // Further note: In general for query objects that accept strings as attribute
246 // value matches, the store should also support basic filtering capability, such as *
247 // (match any character) and ? (match single character). An example query that is a query object
248 // would be like: { attrFoo: "value*"}. Which generally means match all items where they have
249 // an attribute named attrFoo, with a value that starts with 'value'.
250 //
251 // ####The *queryOptions* parameter
252 //
253 // The queryOptions parameter is an optional parameter used to specify options that may modify
254 // the query in some fashion, such as doing a case insensitive search, or doing a deep search
255 // where all items in a hierarchical representation of data are scanned instead of just the root
256 // items. It currently defines two options that all datastores should attempt to honor if possible:
257 // | {
258 // | ignoreCase: boolean, // Whether or not the query should match case sensitively or not. Default behaviour is false.
259 // | deep: boolean // Whether or not a fetch should do a deep search of items and all child
260 // | // items instead of just root-level items in a datastore. Default is false.
261 // | }
262 //
263 // ####The *onBegin* parameter.
264 //
265 // function(size, request);
266 // If an onBegin callback function is provided, the callback function
267 // will be called just once, before the first onItem callback is called.
268 // The onBegin callback function will be passed two arguments, the
269 // the total number of items identified and the Request object. If the total number is
270 // unknown, then size will be -1. Note that size is not necessarily the size of the
271 // collection of items returned from the query, as the request may have specified to return only a
272 // subset of the total set of items through the use of the start and count parameters.
273 //
274 // ####The *onItem* parameter.
275 //
276 // function(item, request);
277 //
278 // If an onItem callback function is provided, the callback function
279 // will be called as each item in the result is received. The callback
280 // function will be passed two arguments: the item itself, and the
281 // Request object.
282 //
283 // ####The *onComplete* parameter.
284 //
285 // function(items, request);
286 //
287 // If an onComplete callback function is provided, the callback function
288 // will be called just once, after the last onItem callback is called.
289 // Note that if the onItem callback is not present, then onComplete will be passed
290 // an array containing all items which matched the query and the request object.
291 // If the onItem callback is present, then onComplete is called as:
292 // onComplete(null, request).
293 //
294 // ####The *onError* parameter.
295 //
296 // function(errorData, request);
297 //
298 // If an onError callback function is provided, the callback function
299 // will be called if there is any sort of error while attempting to
300 // execute the query.
301 // The onError callback function will be passed two arguments:
302 // an Error object and the Request object.
303 //
304 // ####The *scope* parameter.
305 //
306 // If a scope object is provided, all of the callback functions (onItem,
307 // onComplete, onError, etc) will be invoked in the context of the scope
308 // object. In the body of the callback function, the value of the "this"
309 // keyword will be the scope object. If no scope object is provided,
310 // the callback functions will be called in the context of dojo.global().
311 // For example, onItem.call(scope, item, request) vs.
312 // onItem.call(dojo.global(), item, request)
313 //
314 // ####The *start* parameter.
315 //
316 // If a start parameter is specified, this is a indication to the datastore to
317 // only start returning items once the start number of items have been located and
318 // skipped. When this parameter is paired with 'count', the store should be able
319 // to page across queries with millions of hits by only returning subsets of the
320 // hits for each query
321 //
322 // ####The *count* parameter.
323 //
324 // If a count parameter is specified, this is a indication to the datastore to
325 // only return up to that many items. This allows a fetch call that may have
326 // millions of item matches to be paired down to something reasonable.
327 //
328 // ####The *sort* parameter.
329 //
330 // If a sort parameter is specified, this is a indication to the datastore to
331 // sort the items in some manner before returning the items. The array is an array of
332 // javascript objects that must conform to the following format to be applied to the
333 // fetching of items:
334 // | {
335 // | attribute: attribute || attribute-name-string,
336 // | descending: true|false; // Optional. Default is false.
337 // | }
338 // Note that when comparing attributes, if an item contains no value for the attribute
339 // (undefined), then it the default ascending sort logic should push it to the bottom
340 // of the list. In the descending order case, it such items should appear at the top of the list.
341 // returns:
342 // The fetch() method will return a javascript object conforming to the API
343 // defined in dojo/data/api/Request. In general, it will be the keywordArgs
344 // object returned with the required functions in Request.js attached.
345 // Its general purpose is to provide a convenient way for a caller to abort an
346 // ongoing fetch.
347 //
348 // The Request object may also have additional properties when it is returned
349 // such as request.store property, which is a pointer to the datastore object that
350 // fetch() is a method of.
351 // exceptions:
352 // Throws an exception if the query is not valid, or if the query
353 // is required but was not supplied.
354 // example:
355 // Fetch all books identified by the query and call 'showBooks' when complete
356 // | var request = store.fetch({query:"all books", onComplete: showBooks});
357 // example:
358 // Fetch all items in the story and call 'showEverything' when complete.
359 // | var request = store.fetch(onComplete: showEverything);
360 // example:
361 // Fetch only 10 books that match the query 'all books', starting at the fifth book found during the search.
362 // This demonstrates how paging can be done for specific queries.
363 // | var request = store.fetch({query:"all books", start: 4, count: 10, onComplete: showBooks});
364 // example:
365 // Fetch all items that match the query, calling 'callback' each time an item is located.
366 // | var request = store.fetch({query:"foo/bar", onItem:callback});
367 // example:
368 // Fetch the first 100 books by author King, call showKing when up to 100 items have been located.
369 // | var request = store.fetch({query:{author:"King"}, start: 0, count:100, onComplete: showKing});
370 // example:
371 // Locate the books written by Author King, sort it on title and publisher, then return the first 100 items from the sorted items.
372 // | var request = store.fetch({query:{author:"King"}, sort: [{ attribute: "title", descending: true}, {attribute: "publisher"}], ,start: 0, count:100, onComplete: 'showKing'});
373 // example:
374 // Fetch the first 100 books by authors starting with the name King, then call showKing when up to 100 items have been located.
375 // | var request = store.fetch({query:{author:"King*"}, start: 0, count:100, onComplete: showKing});
376 // example:
377 // Fetch the first 100 books by authors ending with 'ing', but only have one character before it (King, Bing, Ling, Sing, etc.), then call showBooks when up to 100 items have been located.
378 // | var request = store.fetch({query:{author:"?ing"}, start: 0, count:100, onComplete: showBooks});
379 // example:
380 // Fetch the first 100 books by author King, where the name may appear as King, king, KING, kInG, and so on, then call showKing when up to 100 items have been located.
381 // | var request = store.fetch({query:{author:"King"}, queryOptions:(ignoreCase: true}, start: 0, count:100, onComplete: showKing});
382 // example:
383 // Paging
384 // | var store = new LargeRdbmsStore({url:"jdbc:odbc:foobar"});
385 // | var fetchArgs = {
386 // | query: {type:"employees", name:"Hillary *"}, // string matching
387 // | sort: [{attribute:"department", descending:true}],
388 // | start: 0,
389 // | count: 20,
390 // | scope: displayer,
391 // | onBegin: showThrobber,
392 // | onItem: displayItem,
393 // | onComplete: stopThrobber,
394 // | onError: handleFetchError,
395 // | };
396 // | store.fetch(fetchArgs);
397 // | ...
398 // and then when the user presses the "Next Page" button...
399 // | fetchArgs.start += 20;
400 // | store.fetch(fetchArgs); // get the next 20 items
401 throw new Error('Unimplemented API: dojo.data.api.Read.fetch');
402 },
403
404 getFeatures: function(){
405 // summary:
406 // The getFeatures() method returns an simple keyword values object
407 // that specifies what interface features the datastore implements.
408 // A simple CsvStore may be read-only, and the only feature it
409 // implements will be the 'dojo/data/api/Read' interface, so the
410 // getFeatures() method will return an object like this one:
411 // {'dojo.data.api.Read': true}.
412 // A more sophisticated datastore might implement a variety of
413 // interface features, like 'dojo.data.api.Read', 'dojo/data/api/Write',
414 // 'dojo.data.api.Identity', and 'dojo/data/api/Attribution'.
415 return {
416 'dojo.data.api.Read': true
417 };
418 },
419
420 close: function(/*dojo/data/api/Request|Object?*/ request){
421 // summary:
422 // The close() method is intended for instructing the store to 'close' out
423 // any information associated with a particular request.
424 // description:
425 // The close() method is intended for instructing the store to 'close' out
426 // any information associated with a particular request. In general, this API
427 // expects to receive as a parameter a request object returned from a fetch.
428 // It will then close out anything associated with that request, such as
429 // clearing any internal datastore caches and closing any 'open' connections.
430 // For some store implementations, this call may be a no-op.
431 // request:
432 // An instance of a request for the store to use to identify what to close out.
433 // If no request is passed, then the store should clear all internal caches (if any)
434 // and close out all 'open' connections. It does not render the store unusable from
435 // there on, it merely cleans out any current data and resets the store to initial
436 // state.
437 // example:
438 // | var request = store.fetch({onComplete: doSomething});
439 // | ...
440 // | store.close(request);
441 throw new Error('Unimplemented API: dojo.data.api.Read.close');
442 },
443
444 getLabel: function(/* dojo/data/api/Item */ item){
445 // summary:
446 // Method to inspect the item and return a user-readable 'label' for the item
447 // that provides a general/adequate description of what the item is.
448 // description:
449 // Method to inspect the item and return a user-readable 'label' for the item
450 // that provides a general/adequate description of what the item is. In general
451 // most labels will be a specific attribute value or collection of the attribute
452 // values that combine to label the item in some manner. For example for an item
453 // that represents a person it may return the label as: "firstname lastlame" where
454 // the firstname and lastname are attributes on the item. If the store is unable
455 // to determine an adequate human readable label, it should return undefined. Users that wish
456 // to customize how a store instance labels items should replace the getLabel() function on
457 // their instance of the store, or extend the store and replace the function in
458 // the extension class.
459 // item:
460 // The item to return the label for.
461 // returns:
462 // A user-readable string representing the item or undefined if no user-readable label can
463 // be generated.
464 throw new Error('Unimplemented API: dojo.data.api.Read.getLabel');
465 },
466
467 getLabelAttributes: function(/* dojo/data/api/Item */ item){
468 // summary:
469 // Method to inspect the item and return an array of what attributes of the item were used
470 // to generate its label, if any.
471 // description:
472 // Method to inspect the item and return an array of what attributes of the item were used
473 // to generate its label, if any. This function is to assist UI developers in knowing what
474 // attributes can be ignored out of the attributes an item has when displaying it, in cases
475 // where the UI is using the label as an overall identifer should they wish to hide
476 // redundant information.
477 // item:
478 // The item to return the list of label attributes for.
479 // returns:
480 // An array of attribute names that were used to generate the label, or null if public attributes
481 // were not used to generate the label.
482 throw new Error('Unimplemented API: dojo.data.api.Read.getLabelAttributes');
483 }
484});
485
486});