bc4ed00c4fd11c8c9d754c23f1cf4aef63540ee6.svn-base 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. if (!dojo._hasResource["dojo.data.api.Identity"]) { // _hasResource checks added
  2. // by build. Do not use
  3. // _hasResource directly in
  4. // your code.
  5. dojo._hasResource["dojo.data.api.Identity"] = true;
  6. dojo.provide("dojo.data.api.Identity");
  7. dojo.require("dojo.data.api.Read");
  8. dojo.declare("dojo.data.api.Identity", dojo.data.api.Read, {
  9. // summary:
  10. // This is an abstract API that data provider implementations conform
  11. // to.
  12. // This file defines methods signatures and intentionally leaves all the
  13. // methods unimplemented.
  14. getFeatures : function() {
  15. // summary:
  16. // See dojo.data.api.Read.getFeatures()
  17. return {
  18. 'dojo.data.api.Read' : true,
  19. 'dojo.data.api.Identity' : true
  20. };
  21. },
  22. getIdentity : function(/* item */item) {
  23. // summary:
  24. // Returns a unique identifier for an item. The return value will be
  25. // either a string or something that has a toString() method (such
  26. // as,
  27. // for example, a dojox.uuid.Uuid object).
  28. // item:
  29. // The item from the store from which to obtain its identifier.
  30. // exceptions:
  31. // Conforming implementations may throw an exception or return null
  32. // if
  33. // item is not an item.
  34. // example:
  35. // | var itemId = store.getIdentity(kermit);
  36. // | assert(kermit ===
  37. // store.findByIdentity(store.getIdentity(kermit)));
  38. throw new Error('Unimplemented API: dojo.data.api.Identity.getIdentity');
  39. var itemIdentityString = null;
  40. return itemIdentityString; // string
  41. },
  42. getIdentityAttributes : function(/* item */item) {
  43. // summary:
  44. // Returns an array of attribute names that are used to generate the
  45. // identity.
  46. // For most stores, this is a single attribute, but for some complex
  47. // stores
  48. // such as RDB backed stores that use compound (multi-attribute)
  49. // identifiers
  50. // it can be more than one. If the identity is not composed of
  51. // attributes
  52. // on the item, it will return null. This function is intended to
  53. // identify
  54. // the attributes that comprise the identity so that so that during
  55. // a render
  56. // of all attributes, the UI can hide the the identity information
  57. // if it
  58. // chooses.
  59. // item:
  60. // The item from the store from which to obtain the array of public
  61. // attributes that
  62. // compose the identifier, if any.
  63. // example:
  64. // | var itemId = store.getIdentity(kermit);
  65. // | var identifiers = store.getIdentityAttributes(itemId);
  66. // | assert(typeof identifiers === "array" || identifiers === null);
  67. throw new Error('Unimplemented API: dojo.data.api.Identity.getIdentityAttributes');
  68. return null; // string
  69. },
  70. fetchItemByIdentity : function(/* object */keywordArgs) {
  71. // summary:
  72. // Given the identity of an item, this method returns the item that
  73. // has
  74. // that identity through the onItem callback. Conforming
  75. // implementations
  76. // should return null if there is no item with the given identity.
  77. // Implementations of fetchItemByIdentity() may sometimes return an
  78. // item
  79. // from a local cache and may sometimes fetch an item from a remote
  80. // server,
  81. //
  82. // keywordArgs:
  83. // An anonymous object that defines the item to locate and callbacks
  84. // to invoke when the
  85. // item has been located and load has completed. The format of the
  86. // object is as follows:
  87. // {
  88. // identity: string|object,
  89. // onItem: Function,
  90. // onError: Function,
  91. // scope: object
  92. // }
  93. // The *identity* parameter.
  94. // The identity parameter is the identity of the item you wish to
  95. // locate and load
  96. // This attribute is required. It should be a string or an object
  97. // that toString()
  98. // can be called on.
  99. //
  100. // The *onItem* parameter.
  101. // Function(item)
  102. // The onItem parameter is the callback to invoke when the item has
  103. // been loaded. It takes only one
  104. // parameter, the item located, or null if none found.
  105. //
  106. // The *onError* parameter.
  107. // Function(error)
  108. // The onError parameter is the callback to invoke when the item
  109. // load encountered an error. It takes only one
  110. // parameter, the error object
  111. //
  112. // The *scope* parameter.
  113. // If a scope object is provided, all of the callback functions
  114. // (onItem,
  115. // onError, etc) will be invoked in the context of the scope object.
  116. // In the body of the callback function, the value of the "this"
  117. // keyword will be the scope object. If no scope object is provided,
  118. // the callback functions will be called in the context of
  119. // dojo.global.
  120. // For example, onItem.call(scope, item, request) vs.
  121. // onItem.call(dojo.global, item, request)
  122. if (!this.isItemLoaded(keywordArgs.item)) {
  123. throw new Error('Unimplemented API: dojo.data.api.Identity.fetchItemByIdentity');
  124. }
  125. }
  126. });
  127. }