//>>built define("dojox/data/AndOrReadStore",["dojo/_base/kernel","dojo/_base/declare","dojo/_base/lang","dojo/data/util/filter","dojo/data/util/simpleFetch","dojo/_base/array","dojo/date/stamp","dojo/_base/json","dojo/_base/window","dojo/_base/xhr"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a){ var _b=_2("dojox.data.AndOrReadStore",null,{constructor:function(_c){ this._arrayOfAllItems=[]; this._arrayOfTopLevelItems=[]; this._loadFinished=false; this._jsonFileUrl=_c.url; this._ccUrl=_c.url; this.url=_c.url; this._jsonData=_c.data; this.data=null; this._datatypeMap=_c.typeMap||{}; if(!this._datatypeMap["Date"]){ this._datatypeMap["Date"]={type:Date,deserialize:function(_d){ return _7.fromISOString(_d); }}; } this._features={"dojo.data.api.Read":true,"dojo.data.api.Identity":true}; this._itemsByIdentity=null; this._storeRefPropName="_S"; this._itemNumPropName="_0"; this._rootItemPropName="_RI"; this._reverseRefMap="_RRM"; this._loadInProgress=false; this._queuedFetches=[]; if(_c.urlPreventCache!==undefined){ this.urlPreventCache=_c.urlPreventCache?true:false; } if(_c.hierarchical!==undefined){ this.hierarchical=_c.hierarchical?true:false; } if(_c.clearOnClose){ this.clearOnClose=true; } },url:"",_ccUrl:"",data:null,typeMap:null,clearOnClose:false,urlPreventCache:false,hierarchical:true,_assertIsItem:function(_e){ if(!this.isItem(_e)){ throw new Error("dojox.data.AndOrReadStore: Invalid item argument."); } },_assertIsAttribute:function(_f){ if(typeof _f!=="string"){ throw new Error("dojox.data.AndOrReadStore: Invalid attribute argument."); } },getValue:function(_10,_11,_12){ var _13=this.getValues(_10,_11); return (_13.length>0)?_13[0]:_12; },getValues:function(_14,_15){ this._assertIsItem(_14); this._assertIsAttribute(_15); var arr=_14[_15]||[]; return arr.slice(0,arr.length); },getAttributes:function(_16){ this._assertIsItem(_16); var _17=[]; for(var key in _16){ if((key!==this._storeRefPropName)&&(key!==this._itemNumPropName)&&(key!==this._rootItemPropName)&&(key!==this._reverseRefMap)){ _17.push(key); } } return _17; },hasAttribute:function(_18,_19){ this._assertIsItem(_18); this._assertIsAttribute(_19); return (_19 in _18); },containsValue:function(_1a,_1b,_1c){ var _1d=undefined; if(typeof _1c==="string"){ _1d=_4.patternToRegExp(_1c,false); } return this._containsValue(_1a,_1b,_1c,_1d); },_containsValue:function(_1e,_1f,_20,_21){ return _6.some(this.getValues(_1e,_1f),function(_22){ if(_22!==null&&!_3.isObject(_22)&&_21){ if(_22.toString().match(_21)){ return true; } }else{ if(_20===_22){ return true; }else{ return false; } } }); },isItem:function(_23){ if(_23&&_23[this._storeRefPropName]===this){ if(this._arrayOfAllItems[_23[this._itemNumPropName]]===_23){ return true; } } return false; },isItemLoaded:function(_24){ return this.isItem(_24); },loadItem:function(_25){ this._assertIsItem(_25.item); },getFeatures:function(){ return this._features; },getLabel:function(_26){ if(this._labelAttr&&this.isItem(_26)){ return this.getValue(_26,this._labelAttr); } return undefined; },getLabelAttributes:function(_27){ if(this._labelAttr){ return [this._labelAttr]; } return null; },_fetchItems:function(_28,_29,_2a){ var _2b=this; var _2c=function(_2d,_2e){ var _2f=[]; if(_2d.query){ var _30=_8.fromJson(_8.toJson(_2d.query)); if(typeof _30=="object"){ var _31=0; var p; for(p in _30){ _31++; } if(_31>1&&_30.complexQuery){ var cq=_30.complexQuery; var _32=false; for(p in _30){ if(p!=="complexQuery"){ if(!_32){ cq="( "+cq+" )"; _32=true; } var v=_2d.query[p]; if(_3.isString(v)){ v="'"+v+"'"; } cq+=" AND "+p+":"+v; delete _30[p]; } } _30.complexQuery=cq; } } var _33=_2d.queryOptions?_2d.queryOptions.ignoreCase:false; if(typeof _30!="string"){ _30=_8.toJson(_30); _30=_30.replace(/\\\\/g,"\\"); } _30=_30.replace(/\\"/g,"\""); var _34=_3.trim(_30.replace(/{|}/g,"")); var _35,i; if(_34.match(/"? *complexQuery *"?:/)){ _34=_3.trim(_34.replace(/"?\s*complexQuery\s*"?:/,"")); var _36=["'","\""]; var _37,_38; var _39=false; for(i=0;i<_36.length;i++){ _37=_34.indexOf(_36[i]); _35=_34.indexOf(_36[i],1); _38=_34.indexOf(":",1); if(_37===0&&_35!=-1&&_38<_35){ _39=true; break; } } if(_39){ _34=_34.replace(/^\"|^\'|\"$|\'$/g,""); } } var _3a=_34; var _3b=/^,|^NOT |^AND |^OR |^\(|^\)|^!|^&&|^\|\|/i; var _3c=""; var op=""; var val=""; var pos=-1; var err=false; var key=""; var _3d=""; var tok=""; _35=-1; for(i=0;i<_2e.length;++i){ var _3e=true; var _3f=_2e[i]; if(_3f===null){ _3e=false; }else{ _34=_3a; _3c=""; while(_34.length>0&&!err){ op=_34.match(_3b); while(op&&!err){ _34=_3.trim(_34.replace(op[0],"")); op=_3.trim(op[0]).toUpperCase(); op=op=="NOT"?"!":op=="AND"||op==","?"&&":op=="OR"?"||":op; op=" "+op+" "; _3c+=op; op=_34.match(_3b); } if(_34.length>0){ pos=_34.indexOf(":"); if(pos==-1){ err=true; break; }else{ key=_3.trim(_34.substring(0,pos).replace(/\"|\'/g,"")); _34=_3.trim(_34.substring(pos+1)); tok=_34.match(/^\'|^\"/); if(tok){ tok=tok[0]; pos=_34.indexOf(tok); _35=_34.indexOf(tok,pos+1); if(_35==-1){ err=true; break; } _3d=_34.substring(pos+1,_35); if(_35==_34.length-1){ _34=""; }else{ _34=_3.trim(_34.substring(_35+1)); } _3c+=_2b._containsValue(_3f,key,_3d,_4.patternToRegExp(_3d,_33)); }else{ tok=_34.match(/\s|\)|,/); if(tok){ var _40=new Array(tok.length); for(var j=0;j1){ for(var j=1;j<_40.length;j++){ pos=Math.min(pos,_40[j]); } } _3d=_3.trim(_34.substring(0,pos)); _34=_3.trim(_34.substring(pos)); }else{ _3d=_3.trim(_34); _34=""; } _3c+=_2b._containsValue(_3f,key,_3d,_4.patternToRegExp(_3d,_33)); } } } } _3e=eval(_3c); } if(_3e){ _2f.push(_3f); } } if(err){ _2f=[]; } _29(_2f,_2d); }else{ for(var i=0;i<_2e.length;++i){ var _41=_2e[i]; if(_41!==null){ _2f.push(_41); } } _29(_2f,_2d); } }; if(this._loadFinished){ _2c(_28,this._getItemsArray(_28.queryOptions)); }else{ if(this._jsonFileUrl!==this._ccUrl){ _1.deprecated("dojox.data.AndOrReadStore: ","To change the url, set the url property of the store,"+" not _jsonFileUrl. _jsonFileUrl support will be removed in 2.0"); this._ccUrl=this._jsonFileUrl; this.url=this._jsonFileUrl; }else{ if(this.url!==this._ccUrl){ this._jsonFileUrl=this.url; this._ccUrl=this.url; } } if(this.data!=null&&this._jsonData==null){ this._jsonData=this.data; this.data=null; } if(this._jsonFileUrl){ if(this._loadInProgress){ this._queuedFetches.push({args:_28,filter:_2c}); }else{ this._loadInProgress=true; var _42={url:_2b._jsonFileUrl,handleAs:"json-comment-optional",preventCache:this.urlPreventCache}; var _43=_a.get(_42); _43.addCallback(function(_44){ try{ _2b._getItemsFromLoadedData(_44); _2b._loadFinished=true; _2b._loadInProgress=false; _2c(_28,_2b._getItemsArray(_28.queryOptions)); _2b._handleQueuedFetches(); } catch(e){ _2b._loadFinished=true; _2b._loadInProgress=false; _2a(e,_28); } }); _43.addErrback(function(_45){ _2b._loadInProgress=false; _2a(_45,_28); }); var _46=null; if(_28.abort){ _46=_28.abort; } _28.abort=function(){ var df=_43; if(df&&df.fired===-1){ df.cancel(); df=null; } if(_46){ _46.call(_28); } }; } }else{ if(this._jsonData){ try{ this._loadFinished=true; this._getItemsFromLoadedData(this._jsonData); this._jsonData=null; _2c(_28,this._getItemsArray(_28.queryOptions)); } catch(e){ _2a(e,_28); } }else{ _2a(new Error("dojox.data.AndOrReadStore: No JSON source data was provided as either URL or a nested Javascript object."),_28); } } } },_handleQueuedFetches:function(){ if(this._queuedFetches.length>0){ for(var i=0;i