# Task Worker Control Interface

The Task Worker control enables a business process or UI to assume ownership of Tasks, work on them, and complete them. It offers administrative operations, such as operations to start, stop, delete, and assign. The Task Worker controls allow operations on several Task instances simultaneously. You can extend this control.

The following are the Task Worker control methods:

    package com.bea.control;

    import weblogic.jws.control.Control;
    import com.bea.control.Extensible;
    import com.bea.wli.worklist.api.TaskInfo;
    import com.bea.wli.worklist.xml.TaskCreationXMLDocument;

    /**
     * Task control interface.
     */

    public interface TaskWorkerControl extends Control {

        /**
         * the control jc tag.
         */

        public static final String TAG_TASK_WORKER = "jc:task-worker";

        /**
         * Create and optionally assigns a new task using an XML interface=
         * @param doc the task parameters
         * @return the taskId
         */

        public String createTask(TaskCreationXMLDocument doc);

        /**
         * The @jc:task-create tag is used to annotate a JBCX method that
         * creates a new task. This method returns the taskId of the created task.
         */

        static final String TAG_TASK_WORKER_CREATE  = "jc:task-create";

        static final String ATTR_CREATE_NAME                = "name";

        static final String ATTR_CREATE_DESCRIPTION         = "description"; // optional

        static final String ATTR_CREATE_COMMENT             = "comment"; //optional

        static final String ATTR_CREATE_PRIORITY            = "priority"; // optional

        static final String ATTR_CREATE_CLAIM_DUE_DATE      = "claim-due-date"; // optional

        static final String ATTR_CREATE_COMPLETION_DUE_DATE   = "completion-due-date";
        // optional, if no expiration date is specified the task will never expire.

        static final String ATTR_CREATE_CLAIM_DUE_BUSINESS_DATE =
        "claim-due-business-date"; //optional

        static final String ATTR_CREATE_CLAIM_USER_CALENDAR = "claim-user-calendar"; //optional

        static final String ATTR_CREATE_CLAIM_CALENDAR      = "claim-calendar"; //optional

        static final String ATTR_CREATE_COMPLETION_DUE_BUSINESS_DATE =
        "completion-due-business-date"; //optional

        static final String ATTR_CREATE_COMPLETION_USER_CALENDAR =
        "completion-user-calendar"; //optional

        static final String ATTR_CREATE_COMPLETION_CALENDAR   = "completion-calendar"; //optional

        static final String ATTR_CREATE_OWNER               = "owner";

        static final String ATTR_CREATE_CAN_BE_REASSIGNED   = "can-be-reassigned";
     // optional: by default true

        static final String ATTR_CREATE_CAN_BE_RETURNED     = "can-be-returned";
    // optional by default false

        static final String ATTR_CREATE_CAN_BE_ABORTED      = "can-be-aborted";
    // optional by default true

        static final String ATTR_CREATE_REQUEST             = "request";
    // optional, can be mapped to any serializable object.

        static final String ATTR_CREATE_REQUEST_MIME_TYPE   = "request-mime-type"; //optional

        public static final String TAG_TASK_WORKER_ABORT    = "jc:task-abort";

        public static final String TAG_TASK_WORKER_CLAIM    = "jc:task-claim";

        public static final String ATTR_CLAIM_CLAIMANT      = "claimant";
    // to claim the task on behalf of a user.

        public static final String TAG_TASK_WORKER_COMPLETE = "jc:task-complete";

        public static final String TAG_TASK_WORKER_DELETE   = "jc:task-delete";

        public static final String TAG_TASK_WORKER_RESUME   = "jc:task-resume";

        public static final String TAG_TASK_WORKER_RETURN   = "jc:task-return";

        public static final String TAG_TASK_WORKER_START    = "jc:task-start";

        public static final String TAG_TASK_WORKER_STOP     = "jc:task-stop";

        public static final String TAG_TASK_WORKER_SUSPEND  = "jc:task-suspend";

        /**
         * The @jc:task-assign tag is used to annotate a JBCX method that
         * assign or reassign a task. The algorithm name is used to determine the way
         * a task is assigned. If no name is pecified the default algorithm is used
         * and the args must be of type String[];
         * In any case the attribute "args" is required and must be of type Object[].
         */

        public static final String TAG_TASK_WORKER_ASSIGN    = "jc:task-assign";

        static final String ATTR_ASSIGN_USER         = "user";

        static final String ATTR_ASSIGN_GROUP        = "group";

        static final String ATTR_ASSIGN_ALGORITHM    = "algorithm";

        /**
         *  The return type of the method JBCX is used to determine
         *  what is returned:
         *  TaskInfo[]
         *  TaskInfoXML[]
         */

        public static final String TAG_TASK_WORKER_GET_INFO        = "jc:task-get-info";

        /**
         *  The return type of the method JBCX is used to determine
         *  what is returned.
         */

        public static final String TAG_TASK_WORKER_GET_REQUEST     = "jc:task-get-request";

        /**
         *  The return type of the method JBCX is used to determine
         *  what is returned.
         */

        public static final String TAG_TASK_WORKER_GET_RESPONSE     = "jc:task-get-response";

        public static final String TAG_TASK_WORKER_GET_PROPERTY_NAME = "jc:task-get-property-name";

        public static final String TAG_TASK_WORKER_GET_PROPERTY    = "jc:task-get-property";

        public static final String ATTR_GET_PROPERTY_NAME   = "name";

        public static final String TAG_TASK_WORKER_SET_PROPERTY    = "jc:task-set-property";

        public static final String ATTR_SET_PROPERTY_NAME   = "name";

        public static final String ATTR_SET_PROPERTY_VALUE  = "value";

        public static final String TAG_TASK_WORKER_REMOVE_PROPERTY = "jc:task-remove-property";

        public static final String ATTR_REMOVE_PROPERTY_NAME= "name";

        /**
         * The @jc:task-update tag is used to annotate a JBCX method that
         * update the task properties. You can modify one or more properties at the same time.
         */

        public static final String TAG_TASK_WORKER_UPDATE          = "jc:task-update";

        public static final String ATTR_UPDATE_CAN_BE_ABORTED         = "can-be-aborted"; // optional

        public static final String ATTR_UPDATE_CAN_BE_REASSIGNED      = "can-be-reassigned"; // optional

        public static final String ATTR_UPDATE_CAN_BE_RETURNED        = "can-be-returned"; // optional

        public static final String ATTR_UPDATE_CLAIM_DUE_DATE         = "claim-due-date"; //optional

        public static final String ATTR_UPDATE_CLAIM_DUE_BUSINESS_DATE = "claim-due-business-date"; //optional

        public static final String ATTR_UPDATE_COMPLETION_DUE_DATE     = "completion-due-date"; //optional

        static final String ATTR_UPDATE_CLAIM_USER_CALENDAR = "claim-user-calendar"; //optional

        static final String ATTR_UPDATE_CLAIM_CALENDAR      = "claim-calendar"; //optional

        static final String ATTR_UPDATE_COMPLETION_DUE_BUSINESS_DATE = "completion-due-business-date"; //optional

        static final String ATTR_UPDATE_COMPLETION_USER_CALENDAR = "completion-user-calendar"; //optional

        static final String ATTR_UPDATE_COMPLETION_CALENDAR = "completion-calendar"; //optional

        public static final String ATTR_UPDATE_COMMENT            = "comment"; //optional

        public static final String ATTR_UPDATE_OWNER            = "owner"; //optional

        public static final String ATTR_UPDATE_PRIORITY        = "priority"; // optional

        public static final String ATTR_UPDATE_REQUEST            = "request"; //optional

        public static final String ATTR_UPDATE_REQUEST_MIME_TYPE            = "request-mime-type"; //optional

        public static final String ATTR_UPDATE_RESPONSE            = "response"; //optional

        public static final String ATTR_UPDATE_RESPONSE_MIME_TYPE     = "response-mime-type"; //optional

        /**
         * The @jc:select tag is used in correlation with the other method tags of this control.
         * It is used to determine the tasks concerned by the operation.
         */

        public static final String TAG_TASK_WORKER_SELECT            = "jc:select";

        public static final String ATTR_SELECT_TASK_ID            = "task-id"; //optional

        public static final String ATTR_SELECT_TASK_NAME            = "task-name"; //optional

        public static final String ATTR_SELECT_TASK_COMMENT           = "comment"; //optional

        public static final String ATTR_SELECT_TASK_OWNER             = "owner"; //optional

        public static final String ATTR_SELECT_CLAIMANT               = "claimant"; //optional

        public static final String ATTR_SELECT_ASSIGNED_USER          = "assigned-user"; //optional

        public static final String ATTR_SELECT_ASSIGNED_GROUP         = "assigned-group"; //optional

        public static final String ATTR_SELECT_MIN_PRIORITY           = "min-priority"; //optional

        public static final String ATTR_SELECT_MAX_PRIORITY           = "max-priority"; //optional

        public static final String ATTR_SELECT_STATES                 = "states"; //optional

        public static final String ATTR_SELECT_COMPLETION_DUE_DATE_BEFORE = "completion-due-date-before"; //optional

        public static final String ATTR_SELECT_COMPLETION_DUE_DATE_AFTER = "completion-due-date-after"; //optional

        public static final String ATTR_SELECT_CLAIM_DUE_DATE_BEFORE  = "claim-due-date-before"; //optional

        public static final String ATTR_SELECT_CLAIM_DUE_DATE_AFTER   = "claim-due-date-after"; //optional

        public static final String ATTR_SELECT_CREATION_DATE_BEFORE   = "creation-date-before"; //optional

        public static final String ATTR_SELECT_CREATION_DATE_AFTER    = "creation-date-after"; //optional

        public static final String ATTR_SELECT_PROPERTY_NAME          = "property-name"; //optional

        public static final String ATTR_SELECT_PROPERTY_VALUE         = "property-value"; //optional

        public static final String ATTR_SELECT_SELECTOR               = "selector";
        //optional to use a java TaskSelector instead

        /**
         * Archive the tasks that are in the state aborted or completed
         */

        public void archiveTasks();

        /**
         * Purge the tasks that are ready to be purged:
         * completed or aborted time > purgDelay.
         * if archiver is on the task must be archived first.
         */

        public void purgeTasks();
    }

### Sample Extended Task Worker Control

The following code shows an example of an extended control. This code is automatically created by the control wizard.

    package processes;

    import weblogic.jws.*;
    import com.bea.control.TaskWorkerControl;
    import com.bea.wli.worklist.api.*;
    import com.bea.wli.worklist.xml.*;
    import com.bea.xml.XmlObject;
    import java.util.Date;

    /**
     * @jc:task-worker
     */

    public interface taskworker1 extends TaskWorkerControl, com.bea.control.ControlExtension

    {
        /**
        * @jc:task-create
        *   name="{name}"
        */

        public String createTaskByName(String name);

        /**
         * @jc:task-assign
         * user="{users}"
         * group="{groups}"
         * algorithm="ToUsersAndGroups"
         * @jc:select task-id="{taskIds}"
         */

        public void assignTaskToUsersAndGroups(String[] users, String[] groups, String[] taskIds);

        /**
         * @jc:task-assign
         * user="{user}"
         * algorithm="ToUser"
         * @jc:select task-id="{taskIds}"
         */

        public void assignTaskToUser(String user, String[] taskIds);

       /**
         * @jc:task-assign
         * group="{group}"
         * algorithm="ToUserInGroup"
         * @jc:select task-id="{taskIds}"
         */

        public void assignTaskToUserInGroup(String group, String[] taskIds);

        /**
         * @jc:task-update request-mime-type="{type}"
         * request={xml}
         * @jc:select task-id="{taskIds}"
         */

        public void setRequest(XmlObject xml, String type, String[] taskIds);

        /**
         * @jc:task-update response-mime-type="{type}"
         * response={xml}
         * @jc:select task-id="{taskIds}"
         */

        public void setResponse(XmlObject xml, String type, String[] taskIds);

        /**
         * @jc:task-update
         * comment={comment}
         * @jc:select task-id="{taskIds}"
         */

        public void setComment(String comment, String[] taskIds);

        /**
         * @jc:task-update
         * priority={priority}
         * @jc:select task-id="{taskIds}"
         */

        public void setPriority(Integer priority, String[] taskIds);

        /**
         * @jc:task-update
         * owner={owner}
         * @jc:select task-id="{taskIds}"
         */

        public void setOwner(String owner, String[] taskIds);

        /**
         * @jc:task-update can-be-aborted="{aborted}" can-be-returned="{returned}" can-be-reassigned="{reassigned}"
         * @jc:select task-id="{taskIds}"
         */

        public void setPermissions(Boolean aborted, Boolean returned, Boolean reassigned, String[] taskIds);

        /**
         * @jc:task-update completion-due-date="{date}"
         * @jc:select task-id="{taskIds}"
         */

        public void setCompletionDueDate(Date date, String[] taskIds);

        /**
         * @jc:task-update completion-due-business-date={duration}
         * completion-calendar={calendarID}
         * @jc:select task-id="{taskIds}"
         */

        public void setCompletionDueBusinessDate(String duration, String calendarID, String[] taskIds);

       /**
         * @jc:task-update claim-due-business-date={duration}
         * @jc:select task-id="{taskIds}"
         */

        public void setClaimDueBusinessDateSystemCalendar(String duration, String[] taskIds);

        /**
         * @jc:task-update completion-due-business-date={duration}
         * @jc:select task-id="{taskIds}"
         */

        public void setCompletionDueBusinessDateSystemCalendar(String duration, String[] taskIds);

        /**
         * @jc:task-update claim-due-business-date={duration}
         * claim-calendar={calendarID}
         * @jc:select task-id="{taskIds}"
         */

        public void setClaimDueBusinessDate(String duration, String calendarID, String[] taskIds);

        /**
         * @jc:task-update claim-due-date="{date}"
         * @jc:select task-id="{taskIds}"
         */

        public void setClaimDueDate(Date date, String[] taskIds);

        /**
         * @jc:task-abort enabled="true"
         * @jc:select task-id="{taskIds}"
         */

        public void abortTask(String[] taskIds);

        /**
         * @jc:task-resume enabled="true"
         * @jc:select task-id="{taskIds}"
         */

        public void resumeTask(String[] taskIds);

        /**
         * @jc:task-suspend
         * @jc:select task-id="{taskIds}"
         */

        public void suspendTask(String[] taskIds);

        /**
         * @jc:task-claim enabled="true" claimant="{claimant}"
         * @jc:select task-id="{taskIds}"
         */

        public void claimTaskOnBehalfOf(String claimant, String[] taskIds);

        /**
         * @jc:task-claim enabled="true"
         * @jc:select task-id="{taskIds}"
         */

        public void claimTask(String[] taskIds);

        /**
         * @jc:task-complete enabled="true"
         * @jc:select task-id="{taskIds}"
         */

        public void completeTask(String[] taskIds);

        /**
         * @jc:task-return enabled="true"
         * @jc:select task-id="{taskIds}"
         */

        public void returnTask(String[] taskIds);

        /**
         * @jc:task-start enabled="true"
         * @jc:select task-id="{taskIds}"
         */

        public void startTask(String[] taskIds);

        /**
         * @jc:task-stop enabled="true"
         * @jc:select task-id="{taskIds}"
         */

        public void stopTask(String[] taskIds);

        /**
         * @jc:task-get-request enabled="true"
         * @jc:select task-id="{taskIds}"
         */

        public XmlObject[] getRequest(String[] taskIds);

        /**
         * @jc:task-get-response enabled="true"
         * @jc:select task-id="{taskIds}"
         */

        public XmlObject[] getResponse(String[] taskIds);

        /**
         * @jc:task-get-info enabled="true"
         * @jc:select task-id="{taskIds}"
         */

        public TaskInfo[] getTaskInfo(String[] taskIds);

        /**
         * @jc:task-get-info enabled="true"
         * @jc:select task-id="{taskIds}"
         */

        public TaskInfoXMLDocument[] getTaskInfoXML(String[] taskIds);

        /**
         * @jc:task-get-property name="{name}"
         * @jc:select task-id="{taskIds}"
         */

        public String[] getProperty(String name, String[] taskIds);

        /**
         * @jc:task-set-property name="{name}" value="{value}"
         * @jc:select task-id="{taskIds}"
         */

        public void setProperty(String name, String value, String[] taskIds);

        /**

         * @jc:task-remove-property name="{name}"
         * @jc:select task-id="{taskIds}"
         */

        public void removeProperty(String name, String[] taskIds);

        /**
         * @jc:task-delete enabled="true"
         * @jc:select task-id="{taskIds}"
         */

        public void deleteTask(String[] taskIds);

    }