// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/tasks/datareviewer/_DRSBaseTask","dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/Deferred dojo/has ../../request ../../urlUtils ../../kernel ../Task ./ReviewerSession".split(" "),function(l,h,p,m,u,n,q,v,w,t){l=l(w,{declaredClass:"esri.tasks.datareviewer.DRSBaseTask",_url:null,_queryParams:null,_reviewerMapServerUrl:null,constructor:function(a){"/"==a[a.length-1]&&(a=a.slice(0,-1));a=q.urlToObject(a);this._url=a.path;this._queryParams=a.query;a=this._url.toLowerCase().lastIndexOf("/exts/");
0<a&&(this._reviewerMapServerUrl=this._url.substring(0,a));this._successHandler=h.hitch(this,this._successHandler);this._errorHandler=h.hitch(this,this._errorHandler);this._appendQueryParams=h.hitch(this,this._appendQueryParams);this.onError=h.hitch(this,this.onError)},_appendQueryParams:function(a){if(this._queryParams)for(var b in this._queryParams)a=q.urlToObject(a).query?a+("\x26"+b+"\x3d"+this._queryParams[b]):a+("?"+b+"\x3d"+this._queryParams[b]);return a},_successHandler:function(a,b,f){b&&
this[b].apply(this,[a]);f&&f.resolve(a)},_errorHandler:function(a,b){null===a&&(a=Error("Unexpected response received from server"),a.code=500);this.onError(a);b&&b.reject(a)},getReviewerMapServerUrl:function(){var a=null;if(a=this._reviewerMapServerUrl){if(this._queryParams)for(var b in this._queryParams)a=q.urlToObject(a).query?a+("\x26"+b+"\x3d"+this._queryParams[b]):a+("?"+b+"\x3d"+this._queryParams[b]);return a}return null},getLifecycleStatusStrings:function(){var a=this._successHandler,b=this._errorHandler,
f=this._appendQueryParams,c=this._url+"/Utilities/getLifecycleStatusStrings",c=f(c),e=new m;n({callbackParamName:"callback",url:c,content:{f:"json"}}).then(h.hitch(this,function(d,g){if(void 0!==d.error){var k=Error();k.message=d.error.message;k.code=d.error.code;b(k,e)}else try{if(k=d.lifecycleStatusString,void 0===k)b(null,e);else{var c=[];p.forEach(k,function(a,b){c[a.descriptionCode]=a.descriptionString});a({lifecycleStatusStrings:c},"onGetLifecycleStatusStringsComplete",e)}}catch(r){b(r,e)}}),
function(a,g){b(a,e)});return e},createReviewerSession:function(a,b){var f=this._successHandler,c=this._errorHandler,e=this._appendQueryParams,d=this._url+"/Utilities/createReviewerSession",d=e(d),g=new m;n({callbackParamName:"callback",url:d,content:{sessionName:a,sessionProperties:b.toJsonSessionOptions(),f:"json"}}).then(h.hitch(this,function(a,b){if(void 0!==a.error){var d=Error();d.message=a.error.message;d.code=a.error.code;c(d,g)}else try{if(void 0===a.sessionAttributes)c(null,g);else{var d=
a.sessionAttributes,e=new t(d.sessionId,d.sessionName,d.userName,d.versionName);f({reviewerSession:e},"onCreateReviewerSessionComplete",g)}}catch(y){c(y,g)}}),function(a,b){c(a,g)});return g},getReviewerSessions:function(){var a=this._successHandler,b=this._errorHandler,f=this._appendQueryParams,c=this._url+"/Utilities/getReviewerSessions",c=f(c),e=new m;n({callbackParamName:"callback",url:c,content:{f:"json"}}).then(h.hitch(this,function(d,g){if(void 0!==d.error){var c=Error();c.message=d.error.message;
c.code=d.error.code;b(c,e)}else try{if(c=d.sessionAttributes,void 0===c)b(null,e);else{var f=[];p.forEach(c,function(a,b){f[b]=new t(a.sessionId,a.sessionName,a.userName,a.versionName)});a({reviewerSessions:f},"onGetReviewerSessionsComplete",e)}}catch(r){b(r,e)}}),function(a,c){b(a,e)});return e},getCustomFieldNames:function(){var a=this._successHandler,b=this._errorHandler,f="BATCHJOBCHECKGROUP CHECKTITLE FEATUREOBJECTCLASS LIFECYCLEPHASE LIFECYCLESTATUS SESSIONID SEVERITY SUBTYPE".split(" "),c=
this._appendQueryParams,e=this._url+"/Dashboard",e=c(e),d=new m;n({callbackParamName:"callback",url:e,content:{f:"json"}}).then(h.hitch(this,function(c,e){if(void 0!==c.error){var g=Error();g.message=c.error.message;g.code=c.error.code;b(g,d)}else try{var h=[];void 0===c.reviewerResultsBy&&b(null,d);p.forEach(c.reviewerResultsBy,function(a,b){-1===f.indexOf(a.name)&&h.push(a.name)});a({customFieldNames:h},"onGetCustomFieldNamesComplete",d)}catch(x){b(x,d)}}),function(a,c){b(a,d)});return d},onGetLifecycleStatusStringsComplete:function(a){},
onGetReviewerSessionsComplete:function(a){},onCreateReviewerSessionComplete:function(a){},onGetCustomFieldNamesComplete:function(a){},onError:function(a){}});u("extend-esri")&&h.setObject("tasks.datareviewer.DRSBaseTask",l,v);return l});