/*
 COPYRIGHT 2009 ESRI

 TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
 Unpublished material - all rights reserved under the
 Copyright Laws of the United States and applicable international
 laws, treaties, and conventions.

 For additional information, contact:
 Environmental Systems Research Institute, Inc.
 Attn: Contracts and Legal Services Department
 380 New York Street
 Redlands, California, 92373
 USA

 email: contracts@esri.com
 */

window[esri._dojoScopeName||"dojo"]._xdResourceLoaded(function(_1,_2,_3){return {depends:[["provide","esri.tasks.query"],["require","esri.tasks._task"],["require","esri._time"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["esri.tasks.query"]){_4._hasResource["esri.tasks.query"]=true;_4.provide("esri.tasks.query");_4.require("esri.tasks._task");_4.require("esri._time");_4.declare("esri.tasks.QueryTask",esri.tasks._Task,{constructor:function(_7,_8){this._handler=_4.hitch(this,this._handler);this._relationshipQueryHandler=_4.hitch(this,this._relationshipQueryHandler);this._executeForIdsHandler=_4.hitch(this,this._executeForIdsHandler);this._countHandler=_4.hitch(this,this._countHandler);this.source=_8&&_8.source;this.gdbVersion=_8&&_8.gdbVersion;},__msigns:[{n:"execute",c:4,a:[{i:0,p:["geometry"]}],e:2},{n:"executeForIds",c:3,a:[{i:0,p:["geometry"]}],e:2},{n:"executeForCount",c:3,a:[{i:0,p:["geometry"]}],e:2}],onComplete:function(){},onExecuteRelationshipQueryComplete:function(){},onExecuteForIdsComplete:function(){},onExecuteForCountComplete:function(){},execute:function(_9,_a,_b,_c,_d){var _e=_d.assembly,_f=this._encode(_4.mixin({},this._url.query,{f:"json"},_9.toJson(_e&&_e[0]))),_10=this._handler,_11=this._errorHandler;if(this.source){var _12={source:this.source.toJson()};_f.layer=_4.toJson(_12);}if(this.gdbVersion){_f.gdbVersion=this.gdbVersion;}return esri.request({url:this._url.path+"/query",content:_f,callbackParamName:"callback",load:function(r,i){_10(r,i,_a,_b,_d.dfd);},error:function(r){_11(r,_b,_d.dfd);},callbackSuffix:_c});},executeRelationshipQuery:function(_13,_14,_15){var _16=this._encode(_4.mixin({},this._url.query,{f:"json"},_13.toJson())),_17=this._relationshipQueryHandler,_18=this._errorHandler;if(this.gdbVersion){_16.gdbVersion=this.gdbVersion;}var dfd=new _4.Deferred(esri._dfdCanceller);dfd._pendingDfd=esri.request({url:this._url.path+"/queryRelatedRecords",content:_16,callbackParamName:"callback",load:function(r,i){_17(r,i,_14,_15,dfd);},error:function(r){_18(r,_15,dfd);}});return dfd;},executeForIds:function(_19,_1a,_1b,_1c){var _1d=_1c.assembly,_1e=this._encode(_4.mixin({},this._url.query,{f:"json",returnIdsOnly:true},_19.toJson(_1d&&_1d[0]))),_1f=this._executeForIdsHandler,_20=this._errorHandler;if(this.source){var _21={source:this.source.toJson()};_1e.layer=_4.toJson(_21);}if(this.gdbVersion){_1e.gdbVersion=this.gdbVersion;}return esri.request({url:this._url.path+"/query",content:_1e,callbackParamName:"callback",load:function(r,i){_1f(r,i,_1a,_1b,_1c.dfd);},error:function(r){_20(r,_1b,_1c.dfd);}});},executeForCount:function(_22,_23,_24,_25){var _26=_25.assembly,_27=this._encode(_4.mixin({},this._url.query,{f:"json",returnIdsOnly:true,returnCountOnly:true},_22.toJson(_26&&_26[0]))),_28=this._countHandler,_29=this._errorHandler;if(this.source){var _2a={source:this.source.toJson()};_27.layer=_4.toJson(_2a);}if(this.gdbVersion){_27.gdbVersion=this.gdbVersion;}return esri.request({url:this._url.path+"/query",content:_27,callbackParamName:"callback",load:function(r,i){_28(r,i,_23,_24,_25.dfd);},error:function(r){_29(r,_24,_25.dfd);}});},_handler:function(_2b,io,_2c,_2d,dfd){try{var _2e=new esri.tasks.FeatureSet(_2b);this._successHandler([_2e],"onComplete",_2c,dfd);}catch(err){this._errorHandler(err,_2d,dfd);}},_relationshipQueryHandler:function(_2f,io,_30,_31,dfd){try{var gt=_2f.geometryType,sr=_2f.spatialReference,_32={};_4.forEach(_2f.relatedRecordGroups,function(gr){var _33={};_33.geometryType=gt;_33.spatialReference=sr;_33.features=gr.relatedRecords;var _34=new esri.tasks.FeatureSet(_33);_32[gr.objectId]=_34;});this._successHandler([_32],"onExecuteRelationshipQueryComplete",_30,dfd);}catch(err){this._errorHandler(err,_31,dfd);}},_executeForIdsHandler:function(_35,io,_36,_37,dfd){try{this._successHandler([_35.objectIds],"onExecuteForIdsComplete",_36,dfd);}catch(err){this._errorHandler(err,_37,dfd);}},_countHandler:function(_38,io,_39,_3a,dfd){try{var _3b,_3c=_38.features,ids=_38.objectIds;if(ids){_3b=ids.length;}else{if(_3c){throw new Error(esri.bundle.tasks.query.invalid);}else{_3b=_38.count;}}this._successHandler([_3b],"onExecuteForCountComplete",_39,dfd);}catch(err){this._errorHandler(err,_3a,dfd);}}});esri._createWrappers("esri.tasks.QueryTask");_4.declare("esri.tasks.Query",null,{constructor:function(){this.spatialRelationship=esri.tasks.Query.SPATIAL_REL_INTERSECTS;},text:null,where:"",geometry:null,groupByFieldsForStatistics:null,objectIds:null,returnGeometry:false,orderByFields:null,outSpatialReference:null,outFields:null,outStatistics:null,timeExtent:null,relationParam:null,toJson:function(_3d){var _3e={text:this.text,where:this.where,returnGeometry:this.returnGeometry,spatialRel:this.spatialRelationship,maxAllowableOffset:this.maxAllowableOffset},g=_3d&&_3d["geometry"]||this.geometry,ids=this.objectIds,_3f=this.outFields,_40=this.outSpatialReference,_41=this.groupByFieldsForStatistics,_42=this.orderByFields,_43=this.outStatistics;if(g){_3e.geometry=g;_3e.geometryType=esri.geometry.getJsonType(g);_3e.inSR=g.spatialReference.wkid||_4.toJson(g.spatialReference.toJson());}if(ids){_3e.objectIds=ids.join(",");}if(_3f){_3e.outFields=_3f.join(",");}if(_41){_3e.groupByFieldsForStatistics=_41.join(",");}if(_42){_3e.orderByFields=_42.join(",");}if(_43){var _44=[];_4.forEach(_43,function(_45,idx){_44.push(_45.toJson());});_3e.outStatistics=_4.toJson(_44);}if(_40!==null){_3e.outSR=_40.wkid||_4.toJson(_40.toJson());}else{if(g){_3e.outSR=g.spatialReference.wkid||_4.toJson(g.spatialReference.toJson());}}var _46=this.timeExtent;_3e.time=_46?_46.toJson().join(","):null;var _47=this.relationParam;if(_47&&this.spatialRelationship===esri.tasks.Query.SPATIAL_REL_RELATION){_3e.relationParam=_47;}_3e._ts=this._ts;return _3e;}});_4.mixin(esri.tasks.Query,esri.tasks._SpatialRelationship);_4.declare("esri.tasks.RelationshipQuery",null,{definitionExpression:"",relationshipId:null,returnGeometry:false,objectIds:null,outSpatialReference:null,outFields:null,toJson:function(){var _48={definitionExpression:this.definitionExpression,relationshipId:this.relationshipId,returnGeometry:this.returnGeometry,maxAllowableOffset:this.maxAllowableOffset},_49=this.objectIds,_4a=this.outFields,_4b=this.outSpatialReference;if(_49){_48.objectIds=_49.join(",");}if(_4a){_48.outFields=_4a.join(",");}if(_4b){_48.outSR=_4b.toJson();}_48._ts=this._ts;return _48;}});_4.declare("esri.tasks.StatisticDefinition",null,{statisticType:null,onStatisticField:null,outStatisticFieldName:null,toJson:function(){var _4c={statisticType:this.statisticType,onStatisticField:this.onStatisticField};if(this.outStatisticFieldName){_4c.outStatisticFieldName=this.outStatisticFieldName;}return _4c;}});}}};});