// 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/ReviewerResultsTask","dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/Deferred dojo/json dojo/has ./_DRSBaseTask ../../request ../FeatureSet ../../layers/FeatureEditResult ../../kernel".split(" "),function(r,l,v,m,t,w,x,n,u,y,z){r=r(x,{declaredClass:"esri.tasks.datareviewer.ReviewerResultsTask",constructor:function(f){this.onGetResultsComplete=l.hitch(this,this.onGetResultsComplete);this.onWriteResultComplete=l.hitch(this,this.onWriteResultComplete);this.onWriteFeatureAsResultComplete=
l.hitch(this,this.onWriteFeatureAsResultComplete);this.onGetLayerDefinitionComplete=l.hitch(this,this.onGetLayerDefinitionComplete);this.onGetBatchRunDetailsComplete=l.hitch(this,this.onGetBatchRunDetailsComplete)},getResults:function(f,k){var h=this._successHandler,c=this._errorHandler,g=this._appendQueryParams,d=this._url+"/ReviewerResults/getResults",d=g(d),a=new m,g={queryParameters:f.toJSON(),f:"json"};null!==k&&void 0!==k&&(g.filtersArray=k.toJSON());n({callbackParamName:"callback",url:d,content:g}).then(l.hitch(this,
function(b,d){if(void 0!==b.error){var e=Error();e.message=b.error.message;e.code=b.error.code;c(e,a)}else try{void 0===b.features||void 0===b.fieldAliases||void 0===b.fields?c(null,a):(e=new u(b),h({featureSet:e},"onGetResultsComplete",a))}catch(q){c(q,a)}}),function(b,d){c(b,a)});return a},writeResult:function(f,k){var h=this._successHandler,c=this._errorHandler,g=this._appendQueryParams,d=this._url+"/ReviewerResults/writeResult",d=g(d),a=new m;n({callbackParamName:"callback",url:d,content:{reviewerAttributes:f.toJSON(),
geometry:t.stringify(k.toJson()),f:"json"}}).then(l.hitch(this,function(b,d){var e=Error();if(void 0!==b.error)e.message=b.error.message,e.code=b.error.code,c(e,a);else try{void 0!==b.result&&"error"===b.result?(e.message=b.messages,e.code=b.result,c(e,a)):"success"===b.result?h({success:!0},"onWriteResultComplete",a):c(null,a)}catch(q){c(q,a)}}),function(b,d){c(b,a)});return a},writeFeatureAsResult:function(f,k){var h=this._successHandler,c=this._errorHandler,g=this._appendQueryParams,d=this._url+
"/ReviewerResults/writeFeatureAsResult",d=g(d),a=new m;n({callbackParamName:"callback",url:d,content:{reviewerAttributes:f.toJSON(),feature:t.stringify(k.toJson()),f:"json"}}).then(l.hitch(this,function(b,d){var e=Error();if(void 0!==b.error)e.message=b.error.message,e.code=b.error.code,c(e,a);else try{void 0!==b.result&&"error"===b.result?(e.message=b.messages,e.code=b.result,c(e,a)):"success"===b.result?h({success:!0},"onWriteFeatureAsResultComplete",a):c(null,a)}catch(q){c(q,a)}}),function(b,d){c(b,
a)});return a},getLayerDefinition:function(f){var k=this._successHandler,h=this._errorHandler,c=this._appendQueryParams,g=this._url+"/ReviewerResults/getLayerDefinition",g=c(g),d=new m,c={f:"json"};if(null!==f||void 0!==f)c.filtersArray=f.toJSON();n({callbackParamName:"callback",url:g,content:c}).then(l.hitch(this,function(a,b){if(void 0!==a.error){var c=Error();c.message=a.error.message;c.code=a.error.code;h(c,d)}else try{void 0===a.whereClause?h(null,d):k({whereClause:a.whereClause},"onGetLayerDefinitionComplete",
d)}catch(e){h(e,d)}}),function(a,b){h(a,d)});return d},getBatchRunDetails:function(f){var k=this._successHandler,h=this._errorHandler,c=this._appendQueryParams,g=this._url+"/ReviewerResults/getBatchRunDetails",g=c(g),d=new m;n({callbackParamName:"callback",url:g,content:{batchRunIds:t.stringify(f),f:"json"}}).then(l.hitch(this,function(a,b){if(void 0!==a.error){var c=Error();c.message=a.error.message;c.code=a.error.code;h(c,d)}else try{void 0===a.features||void 0===a.fieldAliases||void 0===a.fields?
h(null,d):(c=new u(a),k({featureSet:c},"onGetBatchRunDetailsComplete",d))}catch(e){h(e,d)}}),function(a,b){h(a,d)});return d},updateLifecycleStatus:function(f,k,h,c){var g=this._successHandler,d=this._errorHandler,a=this._appendQueryParams,b=this._url+"/ReviewerResults/updateLifecycleStatus",b=a(b),p=new m;n({callbackParamName:"callback",url:b,content:{sessionId:f,lifecycleStatus:k,technicianName:h,filtersArray:c.toJSON(),f:"json"}}).then(l.hitch(this,function(a,b){if(void 0!==a.error){var c=Error();
c.message=a.error.message;c.code=a.error.code;d(c,p)}else try{var e=[];v.forEach(a.updateResults,function(a){var b=new y;b.error=Error(a.description);b.success=a.success;b.objectId=a.objectId;e.push(b)});g({featureEditResults:e},"onUpdateLifecycleStatusComplete",p)}catch(A){d(A,p)}}),function(a,b){d(a,p)});return p},getResultsFieldNames:function(){return"recordId objectId subtype category sessionId checktitle resourceName checkName notes severity reviewStatus correctionStatus verificationStatus reviewTechnician correctionTechnician verificationTechnician reviewDateUtc correctionDateUtc verificationDateUtc lifecycleStatus".split(" ")},
onGetResultsComplete:function(f){},onWriteResultComplete:function(f){},onWriteFeatureAsResultComplete:function(f){},onGetLayerDefinitionComplete:function(f){},onGetBatchRunDetailsComplete:function(f){},onUpdateLifecycleStatusComplete:function(f){}});w("extend-esri")&&l.setObject("tasks.datareviewer.ReviewerResultsTask",r,z);return r});