/*
	Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/


window[esri._dojoScopeName||"dojo"]._xdResourceLoaded(function(_1,_2,_3){return {depends:[["provide","dojo.store.DataStore"],["require","dojo.store.util.QueryResults"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["dojo.store.DataStore"]){_4._hasResource["dojo.store.DataStore"]=true;_4.provide("dojo.store.DataStore");_4.require("dojo.store.util.QueryResults");_4.declare("dojo.store.DataStore",null,{target:"",constructor:function(_7){_4.mixin(this,_7);},_objectConverter:function(_8){var _9=this.store;return function(_a){var _b={};var _c=_9.getAttributes(_a);for(var i=0;i<_c.length;i++){_b[_c[i]]=_9.getValue(_a,_c[i]);}return _8(_b);};},get:function(id,_d){var _e,_f;var _10=new _4.Deferred();this.store.fetchItemByIdentity({identity:id,onItem:this._objectConverter(function(_11){_10.resolve(_e=_11);}),onError:function(_12){_10.reject(_f=_12);}});if(_e){return _e;}if(_f){throw _f;}return _10.promise;},put:function(_13,_14){var id=_14&&typeof _14.id!="undefined"||this.getIdentity(_13);var _15=this.store;if(typeof id=="undefined"){_15.newItem(_13);}else{_15.fetchItemByIdentity({identity:id,onItem:function(_16){if(_16){for(var i in _13){if(_15.getValue(_16,i)!=_13[i]){_15.setValue(_16,i,_13[i]);}}}else{_15.newItem(_13);}}});}},remove:function(id){var _17=this.store;this.store.fetchItemByIdentity({identity:id,onItem:function(_18){_17.deleteItem(_18);}});},query:function(_19,_1a){var _1b,_1c;var _1d=new _4.Deferred();_1d.total=new _4.Deferred();var _1e=this._objectConverter(function(_1f){return _1f;});this.store.fetch(_4.mixin({query:_19,onBegin:function(_20){_1d.total.resolve(_20);},onComplete:function(_21){_1d.resolve(_4.map(_21,_1e));},onError:function(_22){_1d.reject(_22);}},_1a));return _4.store.util.QueryResults(_1d);},getIdentity:function(_23){return _23[this.idProperty||this.store.getIdentityAttributes()[0]];}});}}};});