Write Reviewer Results
WriteReviewerResults.mxml
<?xml version="1.0" encoding="utf-8"?> <!-- //////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2008-2014 Esri // // All rights reserved under the copyright laws of the United States // and applicable international laws, treaties, and conventions. // // You may freely redistribute and use this software, with or without // modification, provided you include the original copyright and use // restrictions. See use restrictions in the file use_restrictions.txt. // //////////////////////////////////////////////////////////////////////////////// --> <s:Application minHeight="400" minWidth="600" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:drs="com.esri.drs.*" xmlns:esri="http://www.esri.com/2008/ags" pageTitle="DRS Write Reviewer Result Sample" applicationComplete="displayReviewerResults()"> <!-- Data Reviewer provides the ability to capture manually submitted results from manual inspection. These results represent a feature or an area of features that has been marked by a user and stored in a Reviewer workspace. This sample allows you to create a point, polyline or polygon feature and write it as Reviewer result to the Reviewer workspace. Information about the result are captured in the parameters and stored in attributes in the Reviewer workspace tables. NOTE: Use of a file geodatabase as the Reviewer workspace for this sample (or any applications that use the write methods in ReviewerResultsTask) is not supported. Use only enterprise geodatabases as the Reviewer workspace for this sample or any applications that use the write methods in ReviewerResultsTask. --> <fx:Declarations> <!-- Create a Reviewer Results task and configure its URL and event handlers --> <drs:ReviewerResultsTask id="resultTask" url="{_soeUrl}" writeResultComplete="resultTask_writeResultCompleteHandler(event)" fault="faultHandler(event)" showBusyCursor="true" disableClientCaching="true"/> <esri:Graphic id="resultGraphic"/> <esri:SimpleMarkerSymbol id="symbolPoint"/> <esri:SimpleLineSymbol id="symbolLine" width="2" color="#0000FF" alpha="0.3"/> <esri:SimpleFillSymbol id="symbolPolygon" color="#0000FF" alpha="0.1"> <esri:SimpleLineSymbol width="1" color="#0000FF" alpha="0.5"/> </esri:SimpleFillSymbol> <esri:DrawTool id="resultDrawTool" markerSymbol="{symbolPoint}" lineSymbol="{symbolLine}" fillSymbol="{symbolPolygon}" graphicsLayer="{resultGraphicsLayer}" map="{map}" drawEnd="drawTool_drawEndHandler(event)"/> </fx:Declarations> <fx:Script> <![CDATA[ import com.esri.ags.events.DrawEvent; import com.esri.drs.DataReviewerTaskEvent; import com.esri.drs.ReviewerAttributes; import com.esri.drs.utils.ReviewerMapServerHelper; import mx.controls.Alert; import mx.events.ItemClickEvent; import mx.rpc.Fault; import mx.rpc.events.FaultEvent; import spark.components.ButtonBarButton; import spark.events.TextOperationEvent; [Bindable]private var _mapServerUrl:String = null; //private var _soeUrl:String = "http://localhost:6080/arcgis/rest/services/reviewer/MapServer/exts/DataReviewerServer"; //Amazon instance for Data Reviewer Server. Change to your Data Reviewer Server SOE URL to run this sample in your environment private var _soeUrl:String = "http://datareviewer.arcgisonline.com/arcgis/rest/services/Samples/reviewerWriteResults/MapServer/exts/DataReviewerServer"; //Handles the click event of draw tools protected function drawToolButtonBar_itemClickHandler(event:ItemClickEvent):void { // Clear graphics clearGraphic(); if (!event.relatedObject["selected"]) { // Selected button was toggled off clearDrawTool(); } else { // Setup DrawTool switch (drawToolButtonBar.selectedIndex) { case 0: resultDrawTool.activate(DrawTool.MAPPOINT); break; case 1: resultDrawTool.activate(DrawTool.POLYLINE); break; case 2: resultDrawTool.activate(DrawTool.POLYGON); break; } } } //Handles the draw end event of draw tools protected function drawTool_drawEndHandler(event:DrawEvent):void { resultGraphic = event.graphic; // reset after finished drawing a feature clearDrawTool(); } //Handles application complete event protected function displayReviewerResults():void { _mapServerUrl= getReviewerMapServiceUrl(_soeUrl) } //Returns the Url of the Reviewer map service private function getReviewerMapServiceUrl(drsSoeURL: String): String { //Reset DRS SOE Url based on changed URL text input. var revMapServerHelper:ReviewerMapServerHelper = new ReviewerMapServerHelper(drsSoeURL); if (null != revMapServerHelper.getReviewerMapServerUrl()) { return revMapServerHelper.getReviewerMapServerUrl(); } else { return "InvalidMapServiceUrl"; } } // Handles click event for Write Result button protected function writeResult_clickHandler(event:MouseEvent):void { // Clear any messages currentState = "normal"; resultMessage.text = ""; // Input validations if (resultGraphic == null || resultGraphic.geometry == null) { Alert.show("Please draw a geometry on the map.", "Invalid Geometry"); return; } if (inputSessionId.text == null || inputSessionId.text.length < 1 || isNaN(Number(inputSessionId.text)) || inputSeverity.text == null || inputSeverity.text.length < 1 || isNaN(Number(inputSeverity.text)) || inputLayerName.text == null || inputLayerName.text.length < 1 || inputReviewStatus.text == null || inputReviewStatus.text.length < 1 || inputReviewedBy.text == null || inputReviewedBy.text.length < 1) { Alert.show("Please fill out the form.", "Invalid Entries"); return; } // deactivate the drawTool clearDrawTool(); currentState = "processing"; // Send the input parameters to the ReviewerResultsTask var reviewerAttributes:ReviewerAttributes = new ReviewerAttributes(); //set session id to which the results will be written reviewerAttributes.sessionId = Number(inputSessionId.text); //set severity of the result reviewerAttributes.severity = Number(inputSeverity.text); //set the resource name reviewerAttributes.resourceName = inputLayerName.text; //set the status for the result reviewerAttributes.reviewStatus = inputReviewStatus.text; //set the user name under which results or features are written reviewerAttributes.reviewTechnician = inputReviewedBy.text; //set the notes to describe the result reviewerAttributes.notes = inputNotes.text; //write results using the ReviewerResultsTask resultTask.writeResult(reviewerAttributes, resultGraphic.geometry); } //Handles the ReviewerResultsTask writeResult completed event private function resultTask_writeResultCompleteHandler(event:DataReviewerTaskEvent):void { if (event.result) { currentState = "normal"; clearGraphic(); clearForm(); // refresh the layer to show the result added to reviewer workspace reviewerWorkspaceLayer.refresh(); resultMessage.text = "New result successfully written"; } else { currentState = "error"; errorMessage.text = "Error: Unable to write result."; } } //Handles fault private function faultHandler(event:FaultEvent):void { //Set the current state of the application to error currentState = "error"; var fault:Fault = event.fault; var msg:String = fault.faultString; //Get fault content and messages and append to error message text if (fault.content != null && fault.content as Array != null) { msg = fault.content[1].message; } //Set error message to text for displaying errors to user errorMessage.text = "Error : " + msg; } //clear the draw toolbar selection private function clearDrawTool():void { if (resultDrawTool != null && drawToolButtonBar != null) { resultDrawTool.deactivate(); if (drawToolButtonBar.selectedIndex >= 0) drawToolButtonBar.selectedIndex = -1; } } //clear graphics on the map private function clearGraphic():void { if (resultGraphicsLayer != null) { resultGraphic = null; resultGraphicsLayer.clear(); } } //reset the form private function clearForm():void { currentState = "normal"; if (inputForm != null) { inputSessionId.text = null; inputSeverity.text = null; inputLayerName.text = null; inputReviewStatus.text = null; inputReviewedBy.text = null; inputNotes.text = null; } } ]]> </fx:Script> <s:states> <s:State name="normal"/> <s:State name="processing"/> <s:State name="error"/> </s:states> <s:controlBarContent> <s:Label width="100%" text="The following sample submits a Reviewer result to an ArcGIS Data Reviewer for Server hosted on Amazon. Click on Point, Line, or Polygon and digitize a geometry on the map. Populate the text fields, and click Write Result to submit the feature to the Reviewer workspace. To run the sample against your own Data Reviewer Server, see comments in code for _soeUrl variable."/> </s:controlBarContent> <s:Scroller width="100%" height="100%"> <s:VGroup width="100%" paddingLeft="20" paddingRight="20" paddingTop="20"> <s:Spacer height="10"/> <s:HGroup id="mainContent" width="100%"> <!-- MainContent - Map control --> <esri:Map id="map" width="600" height="400" logoVisible="false" scaleBarVisible="false" wrapAround180="false"> <esri:extent> <esri:Extent id="initialExtent" xmin="-17219734" ymin="-4304933" xmax="6261721" ymax="11349370"> <esri:SpatialReference wkid="102100"/> </esri:Extent> </esri:extent> <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer"/> <esri:ArcGISDynamicMapServiceLayer id="reviewerWorkspaceLayer" url="{_mapServerUrl}"/> <esri:GraphicsLayer id="resultGraphicsLayer" graphicProvider="{resultGraphic}"/> </esri:Map> <!-- MainContent - Input form --> <s:VGroup> <s:Form id="inputForm" width="450" height="100%"> <s:layout> <s:FormLayout gap="-10"/> </s:layout> <s:FormHeading label="New Reviewer Result"/> <s:FormItem label="Geometry type:"> <mx:ToggleButtonBar id="drawToolButtonBar" width="100%" horizontalGap="5" selectedIndex="-1" itemClick="drawToolButtonBar_itemClickHandler(event)" toggleOnClick="true"> <fx:Object label="Point"/> <fx:Object label="Line"/> <fx:Object label="Polygon"/> </mx:ToggleButtonBar> </s:FormItem> <s:FormItem label="Session ID:"> <s:TextInput id="inputSessionId" width="100%" toolTip="the ID of an existing Reviewer Session" prompt="the ID of an existing Reviewer Session"/> </s:FormItem> <s:FormItem label="Severity:"> <s:TextInput id="inputSeverity" width="100%" toolTip="from 1-High to 5-Low" prompt="from 1-High to 5-Low"/> </s:FormItem> <s:FormItem label="Layer Name:"> <s:TextInput id="inputLayerName" width="100%" toolTip="layer name e.g. Streets, Roads, Lakes" prompt="layer name e.g. Streets, Roads, Lakes"/> </s:FormItem> <s:FormItem label="Review Status:"> <s:TextInput id="inputReviewStatus" width="100%" toolTip="e.g. missing feature" prompt="e.g. missing feature"/> </s:FormItem> <s:FormItem label="Reviewed By:"> <s:TextInput id="inputReviewedBy" width="100%" toolTip="type your name here" prompt="type your name here"/> </s:FormItem> <s:FormItem label="Notes:"> <s:TextArea id="inputNotes" width="100%" maxChars="256" heightInLines="3"/> </s:FormItem> </s:Form> <s:HGroup width="{400}" paddingLeft="20" paddingRight="15"> <s:Label width="75%" color="#0000FF" text="processing..." includeIn="processing"/> <s:Label id="resultMessage" width="75%" color="#00FF00" text="" includeIn="normal"/> <s:Label id="errorMessage" width="75%" color="#FF0000" text="" includeIn="error"/> <s:VGroup horizontalAlign="right" verticalAlign="top"> <s:Button id="writeResult" height="25" label="Write Result" click="writeResult_clickHandler(event)"/> </s:VGroup> </s:HGroup> </s:VGroup> </s:HGroup> </s:VGroup> </s:Scroller> </s:Application>
Copyright © 1995-2015 Esri. All rights reserved.
2/23/2015