1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| //>>built
| define("dojo/_base/lang dojo/_base/declare dojo/_base/xhr dojo/data/util/simpleFetch dojo/_base/query dojo/_base/array dojo/_base/kernel dojo/data/util/filter dojox/xml/parser dojox/data/XmlItem".split(" "),function(u,n,k,w,x,v,l,y,t,z){n=n("dojox.data.XmlStore",null,{constructor:function(a){a&&(this.url=a.url,this.rootItem=a.rootItem||a.rootitem||this.rootItem,this.keyAttribute=a.keyAttribute||a.keyattribute||this.keyAttribute,this._attributeMap=a.attributeMap||a.attributemap,this.label=a.label||
| this.label,this.sendQuery=a.sendQuery||a.sendquery||this.sendQuery,"urlPreventCache"in a&&(this.urlPreventCache=a.urlPreventCache?!0:!1));this._newItems=[];this._deletedItems=[];this._modifiedItems=[]},url:"",rootItem:"",keyAttribute:"",label:"",sendQuery:!1,attributeMap:null,urlPreventCache:!0,getValue:function(a,b,d){a=a.element;var c,e;if("tagName"===b)return a.nodeName;if("childNodes"===b){for(c=0;c<a.childNodes.length;c++)if(e=a.childNodes[c],1===e.nodeType)return this._getItem(e);return d}if("text()"===
| b){for(c=0;c<a.childNodes.length;c++)if(e=a.childNodes[c],3===e.nodeType||4===e.nodeType)return e.nodeValue;return d}b=this._getAttribute(a.nodeName,b);if("@"===b.charAt(0))return b=b.substring(1),(b=a.getAttribute(b))?b:d;for(c=0;c<a.childNodes.length;c++)if(e=a.childNodes[c],1===e.nodeType&&e.nodeName===b)return this._getItem(e);return d},getValues:function(a,b){a=a.element;var d=[],c,e;if("tagName"===b)return[a.nodeName];if("childNodes"===b){for(c=0;c<a.childNodes.length;c++)e=a.childNodes[c],
| 1===e.nodeType&&d.push(this._getItem(e));return d}if("text()"===b){b=a.childNodes;for(c=0;c<b.length;c++)e=b[c],3!==e.nodeType&&4!==e.nodeType||d.push(e.nodeValue);return d}b=this._getAttribute(a.nodeName,b);if("@"===b.charAt(0))return b=b.substring(1),b=a.getAttribute(b),void 0!==b?[b]:[];for(c=0;c<a.childNodes.length;c++)e=a.childNodes[c],1===e.nodeType&&e.nodeName===b&&d.push(this._getItem(e));return d},getAttributes:function(a){a=a.element;var b=[],d;b.push("tagName");if(0<a.childNodes.length){var c=
| {},e=!0,f=!1;for(d=0;d<a.childNodes.length;d++){var h=a.childNodes[d];1===h.nodeType?(e=h.nodeName,c[e]||(b.push(e),c[e]=e),e=!0):3===h.nodeType&&(f=!0)}e&&b.push("childNodes");f&&b.push("text()")}for(d=0;d<a.attributes.length;d++)b.push("@"+a.attributes[d].nodeName);if(this._attributeMap)for(var g in this._attributeMap)d=g.indexOf("."),0<d?g.substring(0,d)===a.nodeName&&b.push(g.substring(d+1)):b.push(g);return b},hasAttribute:function(a,b){return void 0!==this.getValue(a,b)},containsValue:function(a,
| b,d){a=this.getValues(a,b);for(b=0;b<a.length;b++)if("string"===typeof d){if(a[b].toString&&a[b].toString()===d)return!0}else if(a[b]===d)return!0;return!1},isItem:function(a){return a&&a.element&&a.store&&a.store===this?!0:!1},isItemLoaded:function(a){return this.isItem(a)},loadItem:function(a){},getFeatures:function(){var a={"dojo.data.api.Read":!0,"dojo.data.api.Write":!0};this.sendQuery&&""===this.keyAttribute||(a["dojo.data.api.Identity"]=!0);return a},getLabel:function(a){if(""!==this.label&&
| this.isItem(a)&&(a=this.getValue(a,this.label)))return a.toString()},getLabelAttributes:function(a){return""!==this.label?[this.label]:null},_fetchItems:function(a,b,d){var c=this._getFetchUrl(a);if(c){var e=this.sendQuery?{}:a,f=this,c=k.get({url:c,handleAs:"xml",preventCache:f.urlPreventCache});c.addCallback(function(c){(c=f._getItems(c,e))&&0<c.length?b(c,a):b([],a)});c.addErrback(function(b){d(b,a)})}else d(Error("No URL specified."),a)},_getFetchUrl:function(a){if(!this.sendQuery)return this.url;
| var b=a.query;if(!b)return this.url;if(u.isString(b))return this.url+b;a="";for(var d in b){var c=b[d];c&&(a&&(a+="\x26"),a+=d+"\x3d"+c)}if(!a)return this.url;d=this.url;d=0>d.indexOf("?")?d+"?":d+"\x26";return d+a},_getItems:function(a,b){var d=null;b&&(d=b.query);var c=[],e=null,e=""!==this.rootItem?x(this.rootItem,a):a.documentElement.childNodes;b.queryOptions&&b.queryOptions.deep&&(e=this._flattenNodes(e));for(a=0;a<e.length;a++){var f=e[a];if(1==f.nodeType)if(f=this._getItem(f),d){var h=b.queryOptions?
| b.queryOptions.ignoreCase:!1,g,m=!1,l=!0,q={},r;for(r in d)g=d[r],"string"===typeof g?q[r]=y.patternToRegExp(g,h):g&&(q[r]=g);for(var p in d){for(var l=!1,k=this.getValues(f,p),h=0;h<k.length;h++){if(g=k[h]){var n=d[p];"string"===typeof g&&q[p]?m=null!==g.match(q[p])?!0:!1:"object"===typeof g&&(m=g.toString&&q[p]?null!==g.toString().match(q[p])?!0:!1:"*"===n||n===g?!0:!1)}if(m)break}if(!m)break}(l||m)&&c.push(f)}else c.push(f)}v.forEach(c,function(a){a.element.parentNode&&a.element.parentNode.removeChild(a.element)},
| this);return c},_flattenNodes:function(a){var b=[];if(a){var d;for(d=0;d<a.length;d++){var c=a[d];b.push(c);c.childNodes&&0<c.childNodes.length&&(b=b.concat(this._flattenNodes(c.childNodes)))}}return b},close:function(a){},newItem:function(a,b){a=a||{};var d=a.tagName;if(!d&&(d=this.rootItem,""===d))return null;var c=this._getDocument(),e=c.createElement(d),f;for(f in a){var h;if("tagName"!==f)if("text()"===f)h=c.createTextNode(a[f]),e.appendChild(h);else if(f=this._getAttribute(d,f),"@"===f.charAt(0))h=
| f.substring(1),e.setAttribute(h,a[f]);else{var g=c.createElement(f);h=c.createTextNode(a[f]);g.appendChild(h);e.appendChild(g)}}a=this._getItem(e);this._newItems.push(a);d=null;b&&b.parent&&b.attribute&&(d={item:b.parent,attribute:b.attribute,oldValue:void 0},(c=this.getValues(b.parent,b.attribute))&&0<c.length?(e=c.slice(0,c.length),d.oldValue=1===c.length?c[0]:c.slice(0,c.length),e.push(a),this.setValues(b.parent,b.attribute,e),d.newValue=this.getValues(b.parent,b.attribute)):(this.setValue(b.parent,
| b.attribute,a),d.newValue=a));return a},deleteItem:function(a){var b=a.element;if(b.parentNode)return this._backupItem(a),b.parentNode.removeChild(b),!0;this._forgetItem(a);this._deletedItems.push(a);return!0},setValue:function(a,b,d){if("tagName"===b)return!1;this._backupItem(a);a=a.element;var c;if("childNodes"===b)c=d.element,a.appendChild(c);else if("text()"===b){for(;a.firstChild;)a.removeChild(a.firstChild);d=this._getDocument(a).createTextNode(d);a.appendChild(d)}else if(b=this._getAttribute(a.nodeName,
| b),"@"===b.charAt(0))c=b.substring(1),a.setAttribute(c,d);else{for(var e=0;e<a.childNodes.length;e++){var f=a.childNodes[e];if(1===f.nodeType&&f.nodeName===b){c=f;break}}e=this._getDocument(a);if(c)for(;c.firstChild;)c.removeChild(c.firstChild);else c=e.createElement(b),a.appendChild(c);d=e.createTextNode(d);c.appendChild(d)}return!0},setValues:function(a,b,d){if("tagName"===b)return!1;this._backupItem(a);a=a.element;var c,e,f;if("childNodes"===b){for(;a.firstChild;)a.removeChild(a.firstChild);for(c=
| 0;c<d.length;c++)e=d[c].element,a.appendChild(e)}else if("text()"===b){for(;a.firstChild;)a.removeChild(a.firstChild);b="";for(c=0;c<d.length;c++)b+=d[c];f=this._getDocument(a).createTextNode(b);a.appendChild(f)}else if(b=this._getAttribute(a.nodeName,b),"@"===b.charAt(0))b=b.substring(1),a.setAttribute(b,d[0]);else{for(c=a.childNodes.length-1;0<=c;c--)e=a.childNodes[c],1===e.nodeType&&e.nodeName===b&&a.removeChild(e);var h=this._getDocument(a);for(c=0;c<d.length;c++)e=h.createElement(b),f=h.createTextNode(d[c]),
| e.appendChild(f),a.appendChild(e)}return!0},unsetAttribute:function(a,b){if("tagName"===b)return!1;this._backupItem(a);a=a.element;if("childNodes"===b||"text()"===b)for(;a.firstChild;)a.removeChild(a.firstChild);else if(b=this._getAttribute(a.nodeName,b),"@"===b.charAt(0))b=b.substring(1),a.removeAttribute(b);else for(var d=a.childNodes.length-1;0<=d;d--){var c=a.childNodes[d];1===c.nodeType&&c.nodeName===b&&a.removeChild(c)}return!0},save:function(a){a||(a={});var b;for(b=0;b<this._modifiedItems.length;b++)this._saveItem(this._modifiedItems[b],
| a,"PUT");for(b=0;b<this._newItems.length;b++)this._newItems[b].element.parentNode?(this._newItems.splice(b,1),b--):this._saveItem(this._newItems[b],a,"POST");for(b=0;b<this._deletedItems.length;b++)this._saveItem(this._deletedItems[b],a,"DELETE")},revert:function(){this._newItems=[];this._restoreItems(this._deletedItems);this._deletedItems=[];this._restoreItems(this._modifiedItems);this._modifiedItems=[];return!0},isDirty:function(a){return a?(a=this._getRootElement(a.element),0<=this._getItemIndex(this._newItems,
| a)||0<=this._getItemIndex(this._deletedItems,a)||0<=this._getItemIndex(this._modifiedItems,a)):0<this._newItems.length||0<this._deletedItems.length||0<this._modifiedItems.length},_saveItem:function(a,b,d){var c,e;if(c="PUT"===d?this._getPutUrl(a):"DELETE"===d?this._getDeleteUrl(a):this._getPostUrl(a)){c={url:c,method:d||"POST",contentType:"text/xml",handleAs:"xml"};"PUT"===d?(c.putData=this._getPutContent(a),d=k.put(c)):"DELETE"===d?d=k.del(c):(c.postData=this._getPostContent(a),d=k.post(c));e=b.scope||
| l.global;var f=this;d.addCallback(function(c){f._forgetItem(a);b.onComplete&&b.onComplete.call(e)});d.addErrback(function(a){b.onError&&b.onError.call(e,a)})}else b.onError&&(e=b.scope||l.global,b.onError.call(e,Error("No URL for saving content: "+this._getPostContent(a))))},_getPostUrl:function(a){return this.url},_getPutUrl:function(a){return this.url},_getDeleteUrl:function(a){var b=this.url;if(a&&""!==this.keyAttribute&&(a=this.getValue(a,this.keyAttribute)))var d="@"===this.keyAttribute.charAt(0)?
| this.keyAttribute.substring(1):this.keyAttribute,b=b+(0>b.indexOf("?")?"?":"\x26"),b=b+(d+"\x3d"+a);return b},_getPostContent:function(a){return"\x3c?xml version\x3d'1.0'?\x3e"+t.innerXML(a.element)},_getPutContent:function(a){return"\x3c?xml version\x3d'1.0'?\x3e"+t.innerXML(a.element)},_getAttribute:function(a,b){this._attributeMap&&((a=this._attributeMap[a+"."+b])?b=a:(a=this._attributeMap[b])&&(b=a));return b},_getItem:function(a){try{var b=null;""===this.keyAttribute&&(b=this._getXPath(a));return new z(a,
| this,b)}catch(d){console.log(d)}return null},_getItemIndex:function(a,b){for(var d=0;d<a.length;d++)if(a[d].element===b)return d;return-1},_backupItem:function(a){var b=this._getRootElement(a.element);0<=this._getItemIndex(this._newItems,b)||0<=this._getItemIndex(this._modifiedItems,b)||(b!=a.element&&(a=this._getItem(b)),a._backup=b.cloneNode(!0),this._modifiedItems.push(a))},_restoreItems:function(a){v.forEach(a,function(a){a._backup&&(a.element=a._backup,a._backup=null)},this)},_forgetItem:function(a){a=
| a.element;var b=this._getItemIndex(this._newItems,a);0<=b&&this._newItems.splice(b,1);b=this._getItemIndex(this._deletedItems,a);0<=b&&this._deletedItems.splice(b,1);b=this._getItemIndex(this._modifiedItems,a);0<=b&&this._modifiedItems.splice(b,1)},_getDocument:function(a){return a?a.ownerDocument:this._document?null:t.parse()},_getRootElement:function(a){for(;a.parentNode;)a=a.parentNode;return a},_getXPath:function(a){var b=null;if(!this.sendQuery)for(var d=a,b="";d&&d!=a.ownerDocument;){for(var c=
| 0,e=d,f=d.nodeName;e;)(e=e.previousSibling)&&e.nodeName===f&&c++;c="/"+f+"["+c+"]";b=b?c+b:c;d=d.parentNode}return b},getIdentity:function(a){if(this.isItem(a)){var b=null;this.sendQuery&&""!==this.keyAttribute?b=this.getValue(a,this.keyAttribute).toString():this.serverQuery||(b=""!==this.keyAttribute?this.getValue(a,this.keyAttribute).toString():a.q);return b}throw Error("dojox.data.XmlStore: Object supplied to getIdentity is not an item");},getIdentityAttributes:function(a){if(this.isItem(a))return""!==
| this.keyAttribute?[this.keyAttribute]:null;throw Error("dojox.data.XmlStore: Object supplied to getIdentity is not an item");},fetchItemByIdentity:function(a){var b=null,d=null,c=this,e=null,e=e=null;c.sendQuery?""!==c.keyAttribute?(b={query:{}},b.query[c.keyAttribute]=a.identity,e=this._getFetchUrl(b),b=function(b){var d=null;b&&(b=c._getItems(b,{}),1===b.length?d=b[0]:a.onError&&(b=a.scope||l.global,a.onError.call(b,Error("More than one item was returned from the server for the denoted identity"))));
| a.onItem&&(b=a.scope||l.global,a.onItem.call(b,d))},e={url:e,handleAs:"xml",preventCache:c.urlPreventCache},e=k.get(e),e.addCallback(b),a.onError&&e.addErrback(function(b){a.onError.call(a.scope||l.global,b)})):a.onError&&a.onError.call(a.scope||l.global,Error("XmlStore is not told that the server to provides identity support. No keyAttribute specified.")):(b=function(b){if(b)if(""!==c.keyAttribute){var e={query:{}};e.query[c.keyAttribute]=a.identity;e.queryOptions={deep:!0};e=c._getItems(b,e);d=
| a.scope||l.global;1===e.length?a.onItem&&a.onItem.call(d,e[0]):0===e.length?a.onItem&&a.onItem.call(d,null):a.onError&&a.onError.call(d,Error("Items array size for identity lookup greater than 1, invalid keyAttribute."))}else{var e=a.identity.split("/"),f=b;for(b=0;b<e.length;b++)if(e[b]&&""!==e[b]){var m=e[b],m=m.substring(0,m.length-1),k=m.split("["),m=k[0],k=parseInt(k[1],10),q=0;if(f)if(f=f.childNodes){var r,p=null;for(r=0;r<f.length;r++){var n=f[r];if(n.nodeName===m)if(q<k)q++;else{p=n;break}}f=
| p?p:null}else f=null;else break}e=null;f&&(e=c._getItem(f),e.element.parentNode&&e.element.parentNode.removeChild(e.element));a.onItem&&(d=a.scope||l.global,a.onItem.call(d,e))}},e=this._getFetchUrl(null),e={url:e,handleAs:"xml",preventCache:c.urlPreventCache},e=k.get(e),e.addCallback(b),a.onError&&e.addErrback(function(b){a.onError.call(a.scope||l.global,b)}))}});u.extend(n,w);return n});
|
|