Class Context


  • public class Context
    extends java.lang.Object
    Provides parameterization and execution context to a SchedulableJob.

    Most jobs will use the JobConfig object returned by instances of this class to retrieve defined and/or custom parameter values.

    Beyond job configuration, this class provides access to information regarding the executing job, such as the name of the job, the scheduled time, etc.

    • Method Detail

      • getSourceJobHistoryId

        public java.lang.Long getSourceJobHistoryId()
        Returns:
        The source JobHistoryId that triggered chaining to this job.
      • getConfig

        public JobConfig getConfig()
        Returns:
        JobConfig containing all parameterization.
      • getJobHistoryId

        public long getJobHistoryId()
        Returns:
        JobHistoryId
      • getScheduledTime

        public com.carfey.jdk.lang.DateTime getScheduledTime()
        Returns:
        Scheduled runtime.
      • getPickupTime

        public com.carfey.jdk.lang.DateTime getPickupTime()
        Returns:
        Pickup time
        Since:
        4.9.0
      • getJobId

        public long getJobId()
        Returns:
        JobId
      • getJobNickname

        public java.lang.String getJobNickname()
        Returns:
        Job Nickname
      • isAdHoc

        public boolean isAdHoc()
        Returns:
        whether this is an ad hoc execution
      • getRunningHost

        public java.lang.String getRunningHost()
        Returns:
        host job is running on
        Since:
        4.9.0
      • setInterruptUser

        protected void setInterruptUser​(java.lang.String interruptUser)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getSourceConfig

        public JobConfig getSourceConfig()
                                  throws com.carfey.jdk.db.Database.DBException,
                                         ParameterException
        Returns job config from the job that chained to this job. This allows configuring the source job and inheriting the config in a target job of a chain.
        Returns:
        map of source job config
        Throws:
        ParameterException - when an error is encountered building the configuration
        com.carfey.jdk.db.Database.DBException - any type of database error
        Since:
        3.8.0
      • getSourceJobResults

        public java.util.Map<java.lang.String,​java.util.List<java.lang.Object>> getSourceJobResults()
                                                                                                   throws ParameterException,
                                                                                                          com.carfey.jdk.db.Database.DBException
        Returns job results from the job that chained to this job. This allows to using output from one job as input to another job.
        Returns:
        map of all job results from the job that triggered chaining to this job.
        Throws:
        ParameterException - when an error is encountered building the configuration
        com.carfey.jdk.db.Database.DBException - any type of database error
      • saveJobResult

        public void saveJobResult​(java.lang.String name,
                                  java.lang.Object value)
                           throws com.carfey.jdk.db.Database.DBException
        Save a job result, which will be viewable in the Obsidian web application, and is available to jobs chained from this one, as well as the REST and Embedded APIs.
        Parameters:
        name - name of job result
        value - value for job result (type is preserved)
        Throws:
        com.carfey.jdk.db.Database.DBException - any type of database error
      • replaceJobResult

        public void replaceJobResult​(java.lang.String name,
                                     java.lang.Object value)
                              throws com.carfey.jdk.db.Database.DBException
        Replace a job result with new value. Any job results that exist with the given name will be deleted, after which saveJobResult(String, Object) is invoked.
        Parameters:
        name - name of job result to replace
        value - value for job result (type is preserved)
        Throws:
        com.carfey.jdk.db.Database.DBException - any type of database error
        Since:
        3.6
      • replaceMultipleJobResults

        public void replaceMultipleJobResults​(java.lang.String name,
                                              java.util.Collection<?> values)
                                       throws com.carfey.jdk.db.Database.DBException
        Replace all existing job results with new values. Any job results that exist with the given name will be deleted, after which saveMultipleJobResults(String, Collection) is invoked.
        Parameters:
        name - name of job result to replace
        values - values for job result (type is preserved)
        Throws:
        com.carfey.jdk.db.Database.DBException - any type of database error
        Since:
        3.6
      • runAutonomous

        protected <T> T runAutonomous​(java.util.concurrent.Callable<T> callable)
                               throws com.carfey.jdk.db.Database.DBException
        Throws:
        com.carfey.jdk.db.Database.DBException
      • saveMultipleJobResults

        public void saveMultipleJobResults​(java.lang.String name,
                                           java.util.Collection<?> values)
                                    throws com.carfey.jdk.db.Database.DBException
        Save multiple job results, which will be viewable in the Obsidian web application, and are available to jobs chained from this one, as well as the REST and Embedded APIs.
        Parameters:
        name - name of job result
        values - zero or more values of the same type (type preserved)
        Throws:
        com.carfey.jdk.db.Database.DBException - any type of database error
        Since:
        2.2