Job
Class
Jobs represent long running processing tasks running on ArcGIS Services. Typically these represent complex analysis tasks such as geoprocessing tasks, logistics analysis such as fleet routing or spatial analysis tasks.
To create a Job
, use the Job.submitJob
method which will return an instance of the Job
class with a unique id.
If you have an existing job you can use Job.serialize
and Job.deserialize
to save job information as a string and recreate the job to get results later.
By default event monitoring is started when you call Job.waitForCompletion
, Job.getAllResults
or, Job.getResult
and stops automatically when those promises complete. Use Job.startEventMonitoring
and Job.stopEventMonitoring
to manually start and stop event monitoring outside those methods. Starting monitoring with Job.startEventMonitoring
will not stop monitoring when Job.waitForCompletion
, Job.getAllResults
or, Job.getResult
complete.
Constructors
Properties
Property | Type | Notes |
---|---|---|
string | IAuthenticationManager | Authentication manager or access token to use for all job requests. | |
string | The job id indicating the specific job. | |
string | The base URL of the job. |
Accessors
Methods
Method | Returns | Notes |
---|---|---|
| Promise<any> | Cancels the job request and voids the job. |
| Promise<any> | Gets all the results from a successful job by ordering all the result paramUrl requests and calling each of them until all of them are complete and returns an object with all the results. |
| Promise<IJobInfo> | Retrieves the status of the current job. |
| Promise<any> | Get the specific results of a successful job by result name. To get all results see |
| void | A handler that will remove a listener after its emitted and returns a custom handler. |
| void | A handler that listens for an eventName and returns custom handler. |
| void | A handler that listens for an event once and returns a custom handler. |
| string | Converts the |
| void | Starts the event polling if the user enables the startMonitoring param. |
| void | Stops the event polling rate. This is can only be enabled if the user calls this method directly. |
| Formats the requestOptions to JSON format. | |
| Promise<IJobInfo> | Checks for job status and if the job status is successful it resolves the job information. Otherwise will throw a |
| Promise<Job> | |
| Promise<Job> | Creates a new instance of |
| Promise<Job> | Submits a job request that will return a new instance of |
cancelJob
cancelJob(): Promise<any>
Cancels the job request and voids the job.
Returns
Promise<any>
An object that has job id, job status and messages array sequencing the status of the cancellation being submitted and completed.
getAllResults
getAllResults(): Promise<any>
Gets all the results from a successful job by ordering all the result paramUrl requests and calling each of them until all of them are complete and returns an object with all the results.
If monitoring is disabled it will be enabled until the job classes resolves or rejects this promise.
Will throw a ArcGISJobError
if it encounters a cancelled or failure status in the job.
Returns
Promise<any>
An object representing all the results from a job.
getJobInfo
getJobInfo(): Promise<IJobInfo>
Retrieves the status of the current job.
Returns
Promise<IJobInfo>
An object with the job id and jobStatus.
getResult
getResult(result: string): Promise<any>
Get the specific results of a successful job by result name. To get all results see Job.getAllResults
.
If monitoring is disabled it will be enabled until the job classes resolves or rejects this promise.
Will throw a ArcGISJobError
if it encounters a cancelled or failure status in the job.
Parameters
Parameter | Type | Notes |
---|---|---|
result | string | The name of the result that you want to retrieve. |
Returns
Promise<any>
An object representing the individual result of the job.
off
off(eventName: string, handler: (e: IJobInfo) => void): void
A handler that will remove a listener after its emitted and returns a custom handler.
Parameters
Parameter | Type | Notes |
---|---|---|
event | string | A string of what event to listen for. |
handler | (e: IJobInfo) => void | A function of what to do when eventName was called. |
Returns
void
on
on(eventName: string, handler: (e: IJobInfo) => void): void
A handler that listens for an eventName and returns custom handler.
Parameters
Parameter | Type | Notes |
---|---|---|
event | string | A string of what event to listen for. |
handler | (e: IJobInfo) => void | A function of what to do when eventName was called. |
Returns
void
once
once(eventName: string, handler: (e: IJobInfo) => void): void
A handler that listens for an event once and returns a custom handler.
Parameters
Parameter | Type | Notes |
---|---|---|
event | string | A string of what event to listen for. |
handler | (e: IJobInfo) => void | A function of what to do when eventName was called. |
Returns
void
serialize
serialize(): string
Converts the Job
to a JSON string. You can rehydrate the state of the Job
with Job.deserialize
.
Returns
string
A JSON string representing the Job
.
startEventMonitoring
startEventMonitoring(pollingRate: number): void
Starts the event polling if the user enables the startMonitoring param.
Parameters
Parameter | Type | Default | Notes |
---|---|---|---|
polling | number | ... | Able to pass in a specific number or will default to 5000. |
Returns
void
stopEventMonitoring
stopEventMonitoring(): void
Stops the event polling rate. This is can only be enabled if the user calls this method directly.
Returns
void
toJSON
toJSON(): IJobOptions
Formats the requestOptions to JSON format.
Returns
IJobOptions
The Job
as a plain JavaScript object.
waitForCompletion
waitForCompletion(): Promise<IJobInfo>
Checks for job status and if the job status is successful it resolves the job information. Otherwise will throw a ArcGISJobError
if it encounters a cancelled or failure status in the job.
Returns
Promise<IJobInfo>
An object with a successful job status, id, and results.
deserialize
deserialize(serializeString: string, options?: IJobOptions): Promise<Job>
Parameters
Parameter | Type |
---|---|
serialize | string |
options | IJobOptions |
Returns
Promise<Job>
fromExistingJob
fromExistingJob(options: IJobOptions): Promise<Job>
Creates a new instance of Job
from an existing job id.
Parameters
Parameter | Type | Notes |
---|---|---|
options | IJobOptions | Requires request endpoint url and id from an existing job id. |
Returns
Promise<Job>
An new instance of Job class with options.
submitJob
submitJob(requestOptions: ISubmitJobOptions): Promise<Job>
Submits a job request that will return a new instance of Job
.
Parameters
Parameter | Type | Notes |
---|---|---|
request | ISubmitJobOptions | Requires url and params from requestOptions. |
Returns
Promise<Job>
An new instance of Job class with the returned job id from submitJob request and requestOptions;
authentication: string | IAuthenticationManager
Authentication manager or access token to use for all job requests.