Packagecom.esri.bacore.client
Classpublic class BatchTaskParameters
InheritanceBatchTaskParameters Inheritance Object

The BatchTaskParameters class provides parameters for a Community Analyst batch task.

Task Providers

The taskProviders array contains task provider objects. Three types of objects are allowed in this array—an object implementing the IBATaskParameters interface, an instance of the BACommand class, or a function. In the last case, the calling function should have the following signature:

taskProvider(parameters:BatchTaskParameters, ...args):Object;

Additional parameters passed to the task provider depend on the batch task (see concrete batch tasks for detail). The result of this function should be either an object implementing the IBATaskParameters interface or an instance of the BACommand class or null.

The task provider function receives on input the current context of parameters, prepares parameters of the task to be executed, and returns them or a BACommand wrapper or another task provider function. If it returns null, the batch task processor executes the task provided with the next task provider object.

If a task provider function throws an error or execution of any task in the batch task fails, the batch task stops execution, and notifies its responder and listeners on the fault event.

Other Batch Task Parameters

The currentStep property specifies a zero-based index of the step currently executed. Since a task provider function has an access to the parameters of the batch task, it can change a step to be executed next by setting the currentStep value to a zero-based index of the step before the next one. For example, if you want to go from the step 3 to 5, set the currentStep value to 4 at the end of the step 3.

The sharedData object is intended for sharing data between steps of the batch task. It can be populated with some initial data before executing the batch task and its contents can be updated in a task provider method executed at the current step.

Batch task execution results are collected in the results array as instances of the BatchTaskResult type. When a task is successfully completed, its result is pushed to the end of this array and becomes available via lastResult property.

Batch Task Director

A special batch task director function, onStepComplete, can be specified in the constructor of this class. It has the following signature:

onStepComplete(parameters : BatchTaskParameters, completedStep : int) : void;

When this function is called, the completedStep parameter specifies a zero-based index of the step completed; the parameters.currentStep value specifies a zero-based index of the step to be executed next; and the parameters.lastResult value contains the result of completion of the last step. This function can perform validation of the last result, logging the execution process, store results in shared data, change a step to be executed next, and so on. In order to complete the whole task after execution a step, set parameters.currentStep=parameters.tokenProviders.length in the scope of this function.

The onStepComplete function can throw an error to prevent execution of the next step. In this case, the execution of the batch task immediately stops and the task responder and listeners are notified on the fault event.

See also

BACommand
IBATaskParameters
BatchTaskProcessor
BatchTaskResult


Public Properties
 PropertyDefined By
  currentStep : int
Zero-based index of the currently executed step.
BatchTaskParameters
  lastResult : BatchTaskResult
[read-only] Last task execution result.
BatchTaskParameters
  results : Array
[read-only] Array of task results containing instances of the BatchTaskResult type.
BatchTaskParameters
  sharedData : Object
[read-only] Object containing data shared between steps.
BatchTaskParameters
  taskName : String
Name associated with this batch task.
BatchTaskParameters
  taskProviders : Array
[read-only] Array of task provider objects.
BatchTaskParameters
Public Methods
 MethodDefined By
  
BatchTaskParameters(taskProviders:Array = null, onStepComplete:Function = null)
Creates a new instance of the BatchTaskParameters class.
BatchTaskParameters
  
addTask(taskProvider:Object):void
Adds a task provider to the end of list of task providers.
BatchTaskParameters
Property Detail
currentStepproperty
currentStep:int

Zero-based index of the currently executed step. Before execution a batch task, this property value specifies a zero-based index of a step to start execution from. The default initial value is zero.


Implementation
    public function get currentStep():int
    public function set currentStep(value:int):void
lastResultproperty 
lastResult:BatchTaskResult  [read-only]

Last task execution result. This is the last object in the results array. If this array is empty, the last result is null.


Implementation
    public function get lastResult():BatchTaskResult
resultsproperty 
results:Array  [read-only]

Array of task results containing instances of the BatchTaskResult type.


Implementation
    public function get results():Array

See also

sharedDataproperty 
sharedData:Object  [read-only]

Object containing data shared between steps.


Implementation
    public function get sharedData():Object
taskNameproperty 
taskName:String

Name associated with this batch task.

The default value is "BatchTask".


Implementation
    public function get taskName():String
    public function set taskName(value:String):void
taskProvidersproperty 
taskProviders:Array  [read-only]

Array of task provider objects.


Implementation
    public function get taskProviders():Array
Constructor Detail
BatchTaskParameters()Constructor
public function BatchTaskParameters(taskProviders:Array = null, onStepComplete:Function = null)

Creates a new instance of the BatchTaskParameters class.

Parameters
taskProviders:Array (default = null) — Array of task provider objects.
 
onStepComplete:Function (default = null) — An optional director function to be executed after completion of every step.
Method Detail
addTask()method
public function addTask(taskProvider:Object):void

Adds a task provider to the end of list of task providers.

Parameters

taskProvider:Object — Object : .