Interface BBjAdminTaskGroup

All Superinterfaces:
BBjAdminPropertyReader, BBjAdminPropertyWriter, Remote
All Known Implementing Classes:
BBjAdminClientTaskGroup

public interface BBjAdminTaskGroup extends BBjAdminPropertyWriter

A task group represents a set of one or more tasks to be executed serially at a specific point in time or when BBjServices is started/restarted. The task group can execute tasks such as BBj programs, system calls, and pause/resume replication jobs. To create/view task groups in the Enterprise Manager, see the Scheduling item under BBjServices.

Task groups are used to schedule autorun jobs as well. Autorun jobs are run one time at the time BBjServices starts. The following example shows how to create an autorun task group:

BBj Sample Code

REM Make sure to inclue the use anytime you will reference constants from a class or interface.
use com.basis.api.admin.BBjAdminTask
use com.basis.api.admin.BBjAdminBBjTask
use com.basis.api.admin.BBjAdminSCALLTask
use com.basis.api.admin.BBjAdminTaskGroup

declare BBjAdminBase api!
declare BBjAdminList programList!
declare BBjAdminTaskGroup taskGroup!
declare BBjAdminTask task!

REM Create the API instance.
api! = BBjAdminFactory.getBBjAdmin("admin", "admin123")

REM Create a new autorun BBjAdminTaskGroup instance.
taskGroup! = api!.newTaskGroup()
taskGroup!.setBoolean(BBjAdminTaskGroup.AUTORUN, 1)
taskGroup!.setString(BBjAdminTaskGroup.NAME, "My Autorun Job")

REM Create a new BBj program task to be run by the job.
task! = taskGroup!.newTask(BBjAdminTask.TaskType.BBJ_PROGRAM)
task!.setString(BBjAdminBBjTask.PROGRAM, "/programs/myprogram.bbj")

REM These are all optional. Just a sample of options.
task!.setString(BBjAdminBBjTask.RUN_AS, "jdoe")
task!.setString(BBjAdminBBjTask.RUN_AS_PASSWORD, "mypassword")
task!.setString(BBjAdminBBjTask.CONFIG, "/programs/config.bbx")
task!.setString(BBjAdminBBjTask.WORKING_DIR, "/programs")

REM Add the new task to the task group.
taskGroup!.getTasks().add(task!)

REM Save the task group configuration. taskGroup!.commit()


REM ================================================================
REM Create another task group that is scheduled to run every Monday.
REM ================================================================
declare BBjAdminTaskGroup mondayGroup!

mondayGroup! = api!.newTaskGroup()
mondayGroup!.setString(BBjAdminTaskGroup.NAME, "MondayGroup")

REM Create a new task to add to the group. Valid types are BBJ_PROGRAM, SCALL, PAUSE, RESUME
REM PAUSE and RESUME refer to replication jobs. See BBjAdminBBjTask, BBjAdminSCALLTask,
REM BBjAdminPauseTask, and BBjAdminResumeTask for all the properties available.
task! = mondayGroup!.newTask(BBjAdminTask.TaskType.BBJ_PROGRAM)
task!.setString(BBjAdminBBjTask.PROGRAM, "/path/to/myProgram.bbj")
task!.setString(BBjAdminBBjTask.CONFIG, "myconfig.bbx")
mondayGroup!.getTasks().add(task!)

task! = mondayGroup!.newTask(BBjAdminTask.TaskType.SCALL)
task!.setString(BBjAdminSCALLTask.COMMAND, "mycommand -arg1 -arg2")
mondayGroup!.getTasks().add(task!)

REM Set scheduling settings. See START_DATE for details on generating start date value.
mondayGroup!.setLong(BBjAdminTaskGroup.START_DATE, new java.util.Date().getTime())
mondayGroup!.setInt(BBjAdminTaskGroup.REPEAT_TYPE, BBjAdminTaskGroup.WEEKLY)

REM REPEAT_FREQUENCY set to 1 for every week. Set to 2 for every other week, and so on.
mondayGroup!.setDouble(BBjAdminTaskGroup.REPEAT_FREQUENCY, 1)

REM Set it to repeat on Mondays. See REPEAT_DAYS for more info.
mondayGroup!.setInt(BBjAdminTaskGroup.REPEAT_DAYS, BBjAdminTaskGroup.MONDAY)

REM Save the group
mondayGroup!.commit()

REM Get the task queue which contains all the running jobs.
queue! = api!.getTaskQueue()

REM Get list of task groups
groupList! = queue!.getTaskGroups()

REM Get a specific task group by name
someGroup! = queue!.getTaskGroup("MyTaskGroup")

REM Clean up the API resources.
api!.release()
  • Field Details

    • NAME

      static final String NAME
      Name of the task group.
      See Also:
    • ID

      static final String ID
      Group unique ID
      See Also:
    • SCHEUDULING_PREFIX

      static final String SCHEUDULING_PREFIX
      Not a property. Used internally as a constant.
      See Also:
    • START_DATE

      static final String START_DATE
      Date and time that this group should start. This value is the Java date long value which represents the number of milliseconds since the epoch. In BBj you would use code something like the following to calculate your value:

      use java.util.Calendar
      declare Calendar cal!
      REM Use date of March 13, 2014 2:00 PM
      myYear = 2014
      myMonth = 3
      myDay = 13
      myHour = 14
      myMinute = 30
      cal! = Calendar.getInstance()
      cal!.set(Calendar.YEAR, myYear)
      cal!.set(Calendar.MONTH, myMonth - 1); REM Uses 0 based month numbers 0-11
      cal!.set(Calendar.DAY_OF_MONTH, myDay)
      cal!.set(Calendar.HOUR_OF_DAY, myHour)
      cal!.set(Calendar.MINUTE, myMinute)
      cal!.set(Calendar.SECOND, 0)
      cal!.set(Calendar.MILLISECOND, 0)
      taskGroup!.setLong(BBjAdminTaskGroup.START_DATE, cal!.getDate())
      See Also:
    • REPEAT_TYPE

      static final String REPEAT_TYPE
      Type of repeat that should occur or NONE if it should only run once.
      See Also:
    • NONE

      static final int NONE
      See Also:
    • HOURLY

      static final int HOURLY
      See Also:
    • DAILY

      static final int DAILY
      See Also:
    • WEEKLY

      static final int WEEKLY
      See Also:
    • MONTHLY

      static final int MONTHLY
      See Also:
    • YEARLY

      static final int YEARLY
      See Also:
    • REPEAT_FREQUENCY

      static final String REPEAT_FREQUENCY
      Works in conjunction with the repeat type. Value of 3 for type WEEKLY would mean Repeat every 3 weeks.
      See Also:
    • REPEAT_DAYS

      static final String REPEAT_DAYS
      Used in conjunction with the REPEAT_TYPE of WEEKLY. Flag with days OR'd together to specify the list of days for the repeat. In Java you would use something like the following to set it to repeat on Monday and Wednesday:
      int daysFlag = BBjAdminTaskGroup.MONDAY | BBjAdminTaskGroup.WEDNESDAY; For the equivalent in BBj code, use:
      LET daysFlag = IOR($02$, $08$)
      See Also:
    • SUNDAY

      static final int SUNDAY
      Flag to include Sunday in the repeat days. See REPEAT_DAYS.
      See Also:
    • MONDAY

      static final int MONDAY
      Flag to include Monday in the repeat days. See REPEAT_DAYS.
      See Also:
    • TUESDAY

      static final int TUESDAY
      Flag to include Tuesday in the repeat days. See REPEAT_DAYS.
      See Also:
    • WEDNESDAY

      static final int WEDNESDAY
      Flag to include Wednesday in the repeat days. See REPEAT_DAYS.
      See Also:
    • THURSDAY

      static final int THURSDAY
      Flag to include Thursday in the repeat days. See REPEAT_DAYS.
      See Also:
    • FRIDAY

      static final int FRIDAY
      Flag to include Friday in the repeat days. See REPEAT_DAYS.
      See Also:
    • SATURDAY

      static final int SATURDAY
      Flag to include Saturday in the repeat days. See REPEAT_DAYS.
      See Also:
    • AUTORUN

      static final String AUTORUN
      Property to indicate if the group should run automatically at BBj Services startup. The default is false/0 or don't run automatically at startup. If this property is set to true, then the REPEAT_TYPE, REPEAT_FREQUENCY, and REPEAT_DAYS will be ignored.
      See Also:
    • END_DATE

      static final String END_DATE
      End date and time for this group to stop running. Please see START_DATE for details regarding use in a BBj program.
      See Also:
    • LAST_RUN

      static final String LAST_RUN
      Last time the group was run. Value returned is the number of milliseconds since the epoch.
      See Also:
    • NEXT_RUN

      static final String NEXT_RUN
      Next time the group will run. Value returned is the number of milliseconds since the epoch.
      See Also:
    • LAST_STATUS

      static final String LAST_STATUS
      Message indicating the status of the last time the group was run.
      See Also:
  • Method Details

    • executeIfAppropriate

      boolean executeIfAppropriate() throws BBjAdminException
      Call this method to execute the scheduled task and its items if it is the appropriate time according to its configuration. If it was time and it executed it returns true. Otherwise returns false.
      Throws:
      BBjAdminException
    • getTasks

      Returns a list of tasks within this group. When you execute the group, all of its tasks will be executed in the order they appear in the group.
      Returns:
      List of the tasks in this group.
    • setTasks

      void setTasks(BBjAdminList<BBjAdminTask> p_tasks)
    • getSchedulingDescription

      String getSchedulingDescription() throws BBjAdminException
      Returns a human readable description of the scheduling for this group. If it is a date, it will show the date and time. If a day of the week, the name of the day of the week. Etc.....
      Returns:
      The description of how this task group is scheduled. Takes all the scheduling criteria and builds a human readable string.
      Throws:
      BBjAdminException
    • newTask

      Creates a new instance of a task but does NOT add it to the list of tasks. Make sure to add the instance to the list of tasks returned by a call to getTasks().
      Returns:
      New instance of the specified type. Always use this method to create new task instances, never use the implementation classes of BBjAdminTask.
      Throws:
      BBjAdminException
    • getXML

      Element getXML(Document p_xmlDoc) throws BBjAdminException
      Internal use only.
      Parameters:
      p_xmlDoc -
      Throws:
      BBjAdminException
    • commit

      void commit() throws BBjAdminException
      Stores any changes made, to the task definition file.
      Throws:
      BBjAdminException
    • executeIfAutorun

      void executeIfAutorun() throws BBjAdminException
      Executes the task group only if it is configured as autorun.
      Throws:
      BBjAdminException
    • isEnabled

      boolean isEnabled() throws BBjAdminException
      Returns true if the group is currently enabled and scheduled run.
      Returns:
      True if the task group is enabled. False if not.
      Throws:
      BBjAdminException
    • setEnabled

      void setEnabled(boolean p_enabled) throws BBjAdminException
      Enables or disables the task group. A disabled task group will not run the next time it is scheduled to. NOTE: You must call commit() on the BBjAdminTaskGroup in order for the enabled state to be saved and updated.
      Parameters:
      p_enabled -
      Throws:
      BBjAdminException