java.lang.Object
org.noise_planet.noisemodelling.webserver.script.Job<T>
All Implemented Interfaces:
Callable<T>

public class Job<T> extends Object implements Callable<T>
Manage the execution of a Groovy Script
  • Field Details

    • WPS_RESPONSE_LOGGING_LENGTH_LIMIT

      public static final int WPS_RESPONSE_LOGGING_LENGTH_LIMIT
      NoiseModelling DataBase for the user
      See Also:
    • userDataSource

      protected DataSource userDataSource
    • serverDataSource

      protected DataSource serverDataSource
    • isRunning

      protected boolean isRunning
    • userId

      protected int userId
    • jobId

      protected int jobId
    • configuration

      protected Configuration configuration
    • future

      protected Future<T> future
    • progressVisitor

      protected org.h2gis.api.ProgressVisitor progressVisitor
    • executionPlan

      protected ExecutionPlan executionPlan
    • jobException

      protected Exception jobException
  • Constructor Details

  • Method Details

    • getUserId

      public int getUserId()
      Get the user id of the job
      Returns:
      User id
    • getFuture

      public Future<T> getFuture()
    • setFuture

      public void setFuture(Future<T> future)
    • call

      public T call() throws Exception
      Specified by:
      call in interface Callable<T>
      Throws:
      Exception
    • getExecutionPlan

      public ExecutionPlan 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

      public Exception 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

      @NotNull public static String getThreadName(int jobId)
    • getId

      public int getId()
      Returns:
      Job id
    • getProgression

      public BigInteger getProgression()