Packagecom.esri.bacore.client
Classpublic class BATask
InheritanceBATask Inheritance AbstractTask Inheritance flash.events.EventDispatcher
Implements IBATask
Subclasses BAOnlineTask, BAServerTask

The BATask class is the base abstract class for any Community Analyst Task.

A Community Analyst Task can be constructed in two ways — as a standalone task using its own instance of the BAClient class or as a task sharing BAClient with other tasks.

Public properties specified in this class are proxies to the properties of an underlying BAClient class. In other words, modification of a property value in an instance of BATask class leads to modification of the corresponding property value in an associated instance of the BAClient class and in all tasks sharing this BAClient instance.

See also

BAClient


Public Properties
 PropertyDefined By
 Inheritedconcurrency : String
Value that indicates how to handle multiple calls to the same task.
AbstractTask
 InheriteddisableClientCaching : Boolean
If true, adds a timestamp parameter ("_ts") to the REST request to prevent the request from being loaded from the browser's cache.
AbstractTask
 InheritedproxyURL : String
The URL to proxy the request through.
AbstractTask
 InheritedrequestTimeout : Number
The request timeout in seconds.
AbstractTask
 InheritedshowBusyCursor : Boolean
If true, a busy cursor is displayed while a service is executing.
AbstractTask
 Inheritedtoken : String
Token for accessing a secure task.
AbstractTask
  tokenProvider : ITokenProvider
Provider responsible for updating the security token if the last one expires.
BATask
 Inheritedurl : String
URL of the task.
AbstractTask
Public Methods
 MethodDefined By
  
Creates a new instance of the BATask class.
BATask
Protected Methods
 MethodDefined By
  
resultHandler(asyncToken:AsyncToken):void
Processes the result of task execution.
BATask
  
send(parameters:IBATaskParameters, responder:IResponder):AsyncToken
Sends a request to Community Analyst HTTP Service associated with this task.
BATask
Events
 Event Summary Defined By
  The fault event is dispatched when an asynchronous execution of a Community Analyst Task fails.BATask
  The taskCompleted event is dispatched when an asynchronous execution of a Community Analyst Task successfully completes.BATask
Property Detail
tokenProviderproperty
tokenProvider:ITokenProvider

Provider responsible for updating the security token if the last one expires.


Implementation
    public function get tokenProvider():ITokenProvider
    public function set tokenProvider(value:ITokenProvider):void
Constructor Detail
BATask()Constructor
public function BATask()

Creates a new instance of the BATask class.

Method Detail
resultHandler()method
protected function resultHandler(asyncToken:AsyncToken):void

Processes the result of task execution.

This function processes a value of the asyncToken.resultObject property. It additionally can use the asyncToken.taskName property to get the name of the completed Community Analyst Task and the asyncToken.resultType to get a BAResultType instance identifying the type that must be received.

The input instance of the result object is either an object decoded from JSON or an object already processed by a result processor registered for the given result type. If the result type is BAResultType.SPECIAL, the JSON-decoded object is received. Otherwise, an object of the required result type is received as the value of asyncToken.resultObject property. The result handler can do additional processing of the result, but we recommend to do post-processing of the result by implementing the IBAResultProcessor interface for the class of input parameters. In this case, parameters of such a task can be executed with generic and batch tasks.

If the result handler modifies the result object, it should update it in the asyncToken.resultObject property instance in order to allow the listeners of the BATaskCompletedEvent event to get the last result processed.

To get the result object from async token properties or to set the updated object to async token properties, use the GPResultProcessors.getProcessedResult and GPResultProcessors.setProcessedResult methods, respectively.

This method is "abstract" (its base implementation throws an error). It should be overriden in subclasses.

Parameters

asyncToken:AsyncToken — Asynch token associated with the response.

See also

send()method 
protected function send(parameters:IBATaskParameters, responder:IResponder):AsyncToken

Sends a request to Community Analyst HTTP Service associated with this task.

The responder.fault function is invoked with an instance of the FaultEvent type and the responder.result function is invoked with an instance of the BATaskCompletedEvent type.

The resultHandler function should be overriden in subclasses.

Parameters

parameters:IBATaskParameters — Community Analyst Task parameters.
 
responder:IResponder — A responder processing events.

Returns
AsyncToken — Asynch token associated with the response.

See also

Event Detail
fault Event
Event Object Type: mx.rpc.events.FaultEvent
FaultEvent.type property = mx.rpc.events.FaultEvent.FAULT

The fault event is dispatched when an asynchronous execution of a Community Analyst Task fails.

taskCompleted Event  
Event Object Type: com.esri.bacore.BATaskCompletedEvent
BATaskCompletedEvent.type property = com.esri.bacore.BATaskCompletedEvent.COMPLETE

The taskCompleted event is dispatched when an asynchronous execution of a Community Analyst Task successfully completes.

The BATaskCompletedEvent.COMPLETE constant defines the value of the type property of the event object for a taskCompleted event.

The properties of the event object have the following values:

PropertyValue
babblesfalse
cancelablefalse
currentTargetThe Object that defines the event listener that handles the event.
targetThe BATask object that dispatched the event. This is an instance of a Community Analyst Task that was executed.
taskNameName of a Community Analyst Task that was executed.
resultTask execution result object.
messagesOptional array of TaskMessage objects received.

The currentTarget and target properties are specified after the event was dispatched. A responder object passed in parameters of a Community Analyst Task execute method receives the event before it is dispatched.