diff options
author | 2008-11-13 09:49:11 +0000 | |
---|---|---|
committer | 2008-11-13 09:49:11 +0000 | |
commit | e44a7e37b6c7b5961adaffc62b9042b8d442938e (patch) | |
tree | 95b67c356e93163467db2451f2b8cce84ed5d582 /includes/js/dojo/data/api/Identity.js | |
parent | a62b9742ee5e28bcec6872d88f50f25b820914f6 (diff) | |
download | scuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.gz scuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.zip |
New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dojo/data/api/Identity.js')
-rw-r--r-- | includes/js/dojo/data/api/Identity.js | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/includes/js/dojo/data/api/Identity.js b/includes/js/dojo/data/api/Identity.js new file mode 100644 index 0000000..d6d47f7 --- /dev/null +++ b/includes/js/dojo/data/api/Identity.js @@ -0,0 +1,107 @@ +if(!dojo._hasResource["dojo.data.api.Identity"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojo.data.api.Identity"] = true; +dojo.provide("dojo.data.api.Identity"); +dojo.require("dojo.data.api.Read"); + +dojo.declare("dojo.data.api.Identity", dojo.data.api.Read, { + // summary: + // This is an abstract API that data provider implementations conform to. + // This file defines methods signatures and intentionally leaves all the + // methods unimplemented. + + getFeatures: function(){ + // summary: + // See dojo.data.api.Read.getFeatures() + return { + 'dojo.data.api.Read': true, + 'dojo.data.api.Identity': true + }; + }, + + getIdentity: function(/* item */ item){ + // summary: + // Returns a unique identifier for an item. The return value will be + // either a string or something that has a toString() method (such as, + // for example, a dojox.uuid.Uuid object). + // item: + // The item from the store from which to obtain its identifier. + // exceptions: + // Conforming implementations may throw an exception or return null if + // item is not an item. + // example: + // | var itemId = store.getIdentity(kermit); + // | assert(kermit === store.findByIdentity(store.getIdentity(kermit))); + throw new Error('Unimplemented API: dojo.data.api.Identity.getIdentity'); + var itemIdentityString = null; + return itemIdentityString; // string + }, + + getIdentityAttributes: function(/* item */ item){ + // summary: + // Returns an array of attribute names that are used to generate the identity. + // For most stores, this is a single attribute, but for some complex stores + // such as RDB backed stores that use compound (multi-attribute) identifiers + // it can be more than one. If the identity is not composed of attributes + // on the item, it will return null. This function is intended to identify + // the attributes that comprise the identity so that so that during a render + // of all attributes, the UI can hide the the identity information if it + // chooses. + // item: + // The item from the store from which to obtain the array of public attributes that + // compose the identifier, if any. + // example: + // | var itemId = store.getIdentity(kermit); + // | var identifiers = store.getIdentityAttributes(itemId); + // | assert(typeof identifiers === "array" || identifiers === null); + throw new Error('Unimplemented API: dojo.data.api.Identity.getIdentityAttributes'); + return null; // string + }, + + + fetchItemByIdentity: function(/* object */ keywordArgs){ + // summary: + // Given the identity of an item, this method returns the item that has + // that identity through the onItem callback. Conforming implementations + // should return null if there is no item with the given identity. + // Implementations of fetchItemByIdentity() may sometimes return an item + // from a local cache and may sometimes fetch an item from a remote server, + // + // keywordArgs: + // An anonymous object that defines the item to locate and callbacks to invoke when the + // item has been located and load has completed. The format of the object is as follows: + // { + // identity: string|object, + // onItem: Function, + // onError: Function, + // scope: object + // } + // The *identity* parameter. + // The identity parameter is the identity of the item you wish to locate and load + // This attribute is required. It should be a string or an object that toString() + // can be called on. + // + // The *onItem* parameter. + // Function(item) + // The onItem parameter is the callback to invoke when the item has been loaded. It takes only one + // parameter, the item located, or null if none found. + // + // The *onError* parameter. + // Function(error) + // The onError parameter is the callback to invoke when the item load encountered an error. It takes only one + // parameter, the error object + // + // The *scope* parameter. + // If a scope object is provided, all of the callback functions (onItem, + // onError, etc) will be invoked in the context of the scope object. + // In the body of the callback function, the value of the "this" + // keyword will be the scope object. If no scope object is provided, + // the callback functions will be called in the context of dojo.global. + // For example, onItem.call(scope, item, request) vs. + // onItem.call(dojo.global, item, request) + if (!this.isItemLoaded(keywordArgs.item)) { + throw new Error('Unimplemented API: dojo.data.api.Identity.fetchItemByIdentity'); + } + } +}); + +} |