Package ome.api

Interface JobHandle

  • All Superinterfaces:
    ServiceInterface, StatefulServiceInterface

    public interface JobHandle
    extends StatefulServiceInterface
    Allows submission of asynchronous jobs.

    NOTE: The calling order for the service is as follows:

    1. submit(Job) or attach(long)
    2. any of the other methods
    3. close()

    Calling close() does not cancel or otherwise change the Job state. See cancelJob().
    Since:
    3.0-Beta2
    • Method Detail

      • submit

        long submit​(ome.model.jobs.Job job)
        Submits a Job and returns its database id. The only fields directly on status which are editable are message, scheduledFor and status. The latter two must be sensible.
        Parameters:
        job - Not null
        Returns:
        id
      • attach

        ome.model.jobs.JobStatus attach​(long jobId)
                                 throws ome.conditions.ApiUsageException
        Returns:
        the current JobStatus for the id
        Throws:
        ome.conditions.ApiUsageException - if the id does not exist.
      • getJob

        ome.model.jobs.Job getJob()
        Returns:
        the current Job
      • jobStatus

        ome.model.jobs.JobStatus jobStatus()
        Returns:
        the current JobStatus. Will never return null.
      • jobFinished

        java.sql.Timestamp jobFinished()
        Returns:
        null if the Job is not finished, otherwise the Timestamp for when it completed.
      • jobMessage

        java.lang.String jobMessage()
        Returns:
        current message for job. May be set during processing.
      • jobRunning

        boolean jobRunning()
        Returns true if the Job is running, i.e. has an attached Process.
      • jobError

        boolean jobError()
        Returns true if the Job has thrown an error.
      • cancelJob

        void cancelJob()
        Marks a job for cancellation. Not every processor will check for the cancelled flag for a running job, but no non-running job will start if it has been cancelled.
      • setStatus

        java.lang.String setStatus​(java.lang.String status)
        Updates the JobStatus for the current job. The previous status is returned as a string. If the status is CANCELLED, this method is equivalent to cancelJob().
      • setStatusAndMessage

        java.lang.String setStatusAndMessage​(java.lang.String status,
                                             java.lang.String message)
        Like setStatus(String) but also sets the message.
      • setMessage

        java.lang.String setMessage​(java.lang.String message)
        Sets the job's message string, and returns the previous value.
        Parameters:
        message -
        Returns:
        the previous message value