|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.esri.core.tasks.ags.geoprocessing.Geoprocessor
public class Geoprocessor
This class represents a single GP task as specified by the URL passed to the constructor.
Many of the methods on this class have both synchronous and asynchronous versions. The synchronous versions will return a value once the process has completed. The asynchronous versions will call a callback when the process has completed. Information on the GP service hosting the task can be queried withgetGPServiceInfo()
or
getGPServiceInfoAsync(CallbackListener)
. Information on the task itself can be queried with
getGPTaskInfo()
or getGPTaskInfoAsync(CallbackListener)
.
The GP task can be run synchronously with #execute(GPParameter[])
or
#executeAsync(GPParameter[], CallbackListener)
. When running an asynchronous GP task with submit, there are a
couple of options:
The first option is to call
submitJobAndGetResultsAsync(List, String[], String[], GPJobResultCallbackListener)
which will call back with
a list of result parameters and a GPJobResource
. The result parameters to be returned are set by the two
String
array parameters. The first lists the names of output parameters we want returned as data and the
second lists the names of output parameters we want returned as images.
The second option is to call #submitJobAsync(GPParameter[], CallbackListener)
. This will call back with a
GPJobResource
instance that can be used with getJobStatus()
or
getJobStatusAsync(CallbackListener)
to get the current status of the job. Once the job is determined to be
complete, getResult(GPJobResource, String, boolean)
or
getResultAsync(GPJobResource, String, boolean, CallbackListener)
can be used to get back the named output
parameter.
Constructor Summary | |
---|---|
Geoprocessor(String url)
Instantiates a new geoprocessor instance with the given task url. |
|
Geoprocessor(String url,
UserCredentials credentials)
Instantiates a new geoprocessor instance with the given task url and user credentials. |
Method Summary | |
---|---|
void |
cancelJob()
Cancel the current submitted job. |
GPParameter[] |
execute(List<GPParameter> parameters)
Synchronously execute a GP task. |
void |
executeAsync(List<GPParameter> parameters,
CallbackListener<GPParameter[]> callback)
Asynchronously execute a GP task. |
UserCredentials |
getCredentials()
Gets the credentials. |
GPServiceInfo |
getGPServiceInfo()
Synchronously get the GP service info for the service this GP task belongs to. |
void |
getGPServiceInfoAsync(CallbackListener<GPServiceInfo> callback)
Asynchronously get the GP service info for the service this GP task belongs to. |
GPTaskInfo |
getGPTaskInfo()
Synchronously get the GP task info for this GP task. |
void |
getGPTaskInfoAsync(CallbackListener<GPTaskInfo> callback)
Asynchronously get the GP task info for this GP task. |
GPJobResource |
getJobStatus()
Synchronously gets the status of the current submitted task. |
void |
getJobStatusAsync(CallbackListener<GPJobResource> callback)
Asynchronously gets the status of the current submitted task. |
SpatialReference |
getOutSR()
Returns the output spatial reference set for this geoprocessing task. |
SpatialReference |
getProcessSR()
Returns the process spatial reference set for this geoprocessing task. |
GPParameter |
getResult(GPJobResource jobResource,
String parameterName,
boolean getAsImageResult)
Synchronously gets the named output parameter. |
void |
getResultAsync(GPJobResource jobResource,
String parameterName,
boolean getAsImageResult,
CallbackListener<GPParameter> callback)
Asynchronously gets the named output parameter. |
GPJobStatusCallback |
getStatusCallback()
Gets the status callback. |
long |
getStatusCallbackInterval()
Gets the status callback interval. |
String |
getUrl()
Gets the url. |
boolean |
isReturnM()
If returned geometry should include M values. |
boolean |
isReturnZ()
If returned geometry should include Z values. |
boolean |
isRunning()
Indicates whether or not this instance is running an asynchronous GP task. |
void |
setCredentials(UserCredentials credentials)
Sets the credentials required to access a secure service. |
void |
setOutSR(SpatialReference outSR)
Sets the well-known ID of the spatial reference of the output geometries. |
void |
setProcessSR(SpatialReference processSR)
The well-known ID of the spatial reference that the model will use to perform geometry operations. |
void |
setReturnM(boolean returnM)
Sets if returned geometry should contain M values. |
void |
setReturnZ(boolean returnZ)
Sets if returned geometry should contain Z values. |
protected void |
setRunning(boolean running)
Sets whether or not we are running submitJobAndGetResultsAsync. |
void |
setStatusCallback(GPJobStatusCallback statusCallback)
Sets the status callback. |
void |
setStatusCallbackInterval(long statusCallbackInterval)
Sets the status callback interval. |
protected void |
setUrl(String url)
Sets the url. |
void |
submitJobAndGetResultsAsync(List<GPParameter> parameters,
String[] outputDataParamNames,
String[] outputImageParamNames,
GPJobResultCallbackListener callback)
Asynchronously submit a GP task and notify the caller via a callback when the results are available. |
void |
submitJobAsync(List<GPParameter> parameters,
CallbackListener<GPJobResource> callback)
Asynchronously submit a GP task. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Geoprocessor(String url)
url
- the url of a GP task of the form http://[gpservice-url]/[taskName]
public Geoprocessor(String url, UserCredentials credentials)
url
- the url of a GP task of the form http://[gpservice-url]/[taskName]
credentials
- the user credentials required to access a secure GP serviceMethod Detail |
---|
protected void setUrl(String url)
url
- the new urlpublic String getUrl()
public void setCredentials(UserCredentials credentials)
credentials
- the new credentialspublic UserCredentials getCredentials()
public void setStatusCallback(GPJobStatusCallback statusCallback)
statusCallback
- the new status callback
#submitJobAndGetResultsAsync(GPParameter[], String[], String[], CallbackListener)
.public GPJobStatusCallback getStatusCallback()
public SpatialReference getOutSR()
public void setOutSR(SpatialReference outSR)
outSR
- The well-known ID of the spatial reference of the output geometries to set.public void setReturnZ(boolean returnZ)
returnZ
- true if Z values are to be returned.public boolean isReturnZ()
public void setReturnM(boolean returnM)
returnM
- true if M values are to be returned.public boolean isReturnM()
public long getStatusCallbackInterval()
public void setStatusCallbackInterval(long statusCallbackInterval)
statusCallbackInterval
- the new status callback intervalpublic SpatialReference getProcessSR()
public void setProcessSR(SpatialReference processSR)
processSR
- The well-known ID of the spatial reference that the model will use to perform geometry operations
to setpublic boolean isRunning()
#submitJobAndGetResultsAsync(GPParameter[], String[], String[], CallbackListener)
starts. It will then be
set to false once the task's result is ready.protected void setRunning(boolean running)
running
- true if we are running, false otherwisepublic GPParameter[] execute(List<GPParameter> parameters) throws Exception
parameters
- the parameters required by the task
Exception
- the exceptionpublic void executeAsync(List<GPParameter> parameters, CallbackListener<GPParameter[]> callback)
parameters
- the parameters required by the taskcallback
- the callback that will be called when the GP task completespublic void submitJobAsync(List<GPParameter> parameters, CallbackListener<GPJobResource> callback)
GPJobResource
instance indicating the current status of the submitted task. If
you wish to get the current status of the submitted task before it completes, call either getJobStatus()
or getJobStatusAsync(CallbackListener)
Once it is determined that the task has completed, the results can
be read with getResult(GPJobResource, String, boolean)
.
parameters
- the parameters required by the taskcallback
- the callback that will be called once the GP task is successfully submitted
getResultAsync(GPJobResource, String, boolean, CallbackListener)
.public void submitJobAndGetResultsAsync(List<GPParameter> parameters, String[] outputDataParamNames, String[] outputImageParamNames, GPJobResultCallbackListener callback)
parameters
- the parameters required by the taskoutputDataParamNames
- a list of names of output parameters we want returned as dataoutputImageParamNames
- a list of names of output parameters we want returned as imagescallback
- the callback that will be called once the requested results are available
setStatusCallback(GPJobStatusCallback)
to set a callback to be called each time the task is polled.
To set which output parameters you want returned, use the outputDataParamNames
parameter to list the
names of output parameters you want as data and outputImageParamNames
to list the names of those you
want as images. Note that a parameter name can go in both lists if you want it returned as both data and an image.
The returned output parameters will be ordered as all of the data results followed by all of the image results.public GPJobResource getJobStatus() throws Exception
GPJobResource
indicates
that the task has completed successfully, it can be used with getResult(GPJobResource, String, boolean)
.
Exception
- the exception
getResultAsync(GPJobResource, String, boolean, CallbackListener)
to get a named output parameter.public void getJobStatusAsync(CallbackListener<GPJobResource> callback)
GPJobResource
indicates that the task has completed successfully, it can be
used with getResult(GPJobResource, String, boolean)
.
callback
- the callback that will be called when the current status is availablepublic void cancelJob()
public GPParameter getResult(GPJobResource jobResource, String parameterName, boolean getAsImageResult) throws Exception
GPJobResource
parameter, it can
be used to request the outputs of any successful run of the GP task represented by this Geoprocessor
instance. This method can be used to return the output parameter as either data or an image by setting the
getAsImageResult
parameter.
jobResource
- a job resource returned by a successfully completed GP taskparameterName
- the parameter namegetAsImageResult
- set true to return the output parameter as an image and false to return it as data
Exception
- the exceptionpublic void getResultAsync(GPJobResource jobResource, String parameterName, boolean getAsImageResult, CallbackListener<GPParameter> callback)
GPJobResource
parameter, it can
be used to request the outputs of any successful run of the GP task represented by this Geoprocessor
instance. When the output parameter is ready it will be passed to the given callback. The output parameter will be
returned as data if the getAsImageResult
parameter is false and as an image if
getAsImageResult
is true.
jobResource
- a job resource returned by a successfully completed GP taskparameterName
- the parameter namegetAsImageResult
- set true to return the output parameter as an image and false to return it as datacallback
- the callbackpublic GPServiceInfo getGPServiceInfo() throws Exception
Exception
- the exceptionGPServiceInfo
public void getGPServiceInfoAsync(CallbackListener<GPServiceInfo> callback)
callback
- the callbackGPServiceInfo
public GPTaskInfo getGPTaskInfo() throws Exception
Exception
- the exceptionGPTaskInfo
public void getGPTaskInfoAsync(CallbackListener<GPTaskInfo> callback)
callback
- the callbackGPTaskInfo
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |