Class Job<T>
java.lang.Object
org.noise_planet.noisemodelling.webserver.script.Job<T>
- All Implemented Interfaces:
Callable<T>
Manage the execution of a Groovy Script
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Configurationprotected ExecutionPlanprotected booleanprotected Exceptionprotected intprotected org.h2gis.api.ProgressVisitorprotected DataSourceprotected DataSourceprotected intstatic final intNoiseModelling DataBase for the user -
Constructor Summary
ConstructorsConstructorDescriptionJob(int userId, ExecutionPlan executionPlan, DataSource serverDataSource, DataSource userDataSource, Configuration configuration) -
Method Summary
Modifier and TypeMethodDescriptioncall()voidcancel()Retrieves the execution plan associated with the job.intgetId()Retrieves the exception associated with the job, if any.static StringgetThreadName(int jobId) intGet the user id of the jobbooleanstatic ObjectrunScript(ExecutionPlan currentPlan, org.h2gis.api.ProgressVisitor progressVisitor, DataSource userDataSource) Executes a Groovy script defined in the given execution plan.void
-
Field Details
-
WPS_RESPONSE_LOGGING_LENGTH_LIMIT
public static final int WPS_RESPONSE_LOGGING_LENGTH_LIMITNoiseModelling DataBase for the user- See Also:
-
userDataSource
-
serverDataSource
-
isRunning
protected boolean isRunning -
userId
protected int userId -
jobId
protected int jobId -
configuration
-
future
-
progressVisitor
protected org.h2gis.api.ProgressVisitor progressVisitor -
executionPlan
-
jobException
-
-
Constructor Details
-
Job
public Job(int userId, ExecutionPlan executionPlan, DataSource serverDataSource, DataSource userDataSource, Configuration configuration) throws SQLException - Throws:
SQLException
-
-
Method Details
-
getUserId
public int getUserId()Get the user id of the job- Returns:
- User id
-
getFuture
-
setFuture
-
call
-
getExecutionPlan
Retrieves the execution plan associated with the job. The execution plan encapsulates the metadata, inputs, outputs, and other details required for script execution within the job.- Returns:
- The execution plan instance linked to this job.
-
getJobException
Retrieves the exception associated with the job, if any.- Returns:
- The exception that occurred during the job execution, or null if no exception was thrown.
-
runScript
public static Object runScript(ExecutionPlan currentPlan, org.h2gis.api.ProgressVisitor progressVisitor, DataSource userDataSource) throws IOException, SQLException Executes a Groovy script defined in the given execution plan. The script must have an `exec` method with one of the following signatures: - `exec(Connection connection, Map input)` - `exec(DataSource dataSource, Map input)` - `exec(Connection connection, Map input, ProgressVisitor progressVisitor)` - `exec(DataSource dataSource, Map input, ProgressVisitor progressVisitor)`This method handles script execution by dynamically invoking the appropriate `exec` method and passing in the required arguments, which may include a database connection, input parameters, and a progress visitor. The outputs of the script, if any, are stored in the execution plan.
- Parameters:
currentPlan- The execution plan that contains the script metadata, input parameters, and stores outputs.progressVisitor- An instance of `ProgressVisitor` used for reporting progress during script execution.userDataSource- The data source to provide a database connection for the script- Returns:
- The result produced by the executed script, or null if no result is returned.
- Throws:
IOException- If an I/O error occurs during script execution.SQLException- If a database access error occurs.RuntimeException- If the `exec` method's argument types are invalid or other runtime exceptions occur.
-
cancel
public void cancel() -
isRunning
public boolean isRunning() -
getThreadName
-
getId
public int getId()- Returns:
- Job id
-
getProgression
-