TaskQueryService

oracle.bpel.services.workflow.query
Interface ITaskQueryService


public interface ITaskQueryService
 This class provides a programmatic means for retrieving tasks, task details, etc
 
 A typical usage would be as follows:
  1. Use an authentication method to authenticate a user and obtain a context
  2. Use the context and a task list method to retrieve tasks that match some filter criterion
  3. Use the context and a task details method to drill down on a task in the list (retrieve task details
        and actions that can be performed on the task)
  4. Use task service, to perform operations on the task
  
 A sample code fragment that shows the usage in the above pattern in shown below:
 
   import java.util.ArrayList;
   import java.util.Date;
   import java.util.List;    
   import oracle.bpel.services.workflow.IWorkflowConstants;
   import oracle.bpel.services.workflow.client.IWorkflowServiceClient;
   import oracle.bpel.services.workflow.client.IWorkflowServiceClientConstants;
   import oracle.bpel.services.workflow.client.WorkflowServiceClientFactory;
   import oracle.bpel.services.workflow.query.ITaskQueryService;
   import oracle.bpel.services.workflow.repos.Ordering;
   import oracle.bpel.services.workflow.repos.Predicate;
   import oracle.bpel.services.workflow.repos.TableConstants;
   import oracle.bpel.services.workflow.task.ITaskService;
   import oracle.bpel.services.workflow.task.model.Task;
   import oracle.bpel.services.workflow.verification.IWorkflowContext;      
   
   //User whose task list needs to be queried
   String userid="jstein";
   // Password for the user
   String password = "welcome1";
   
   // You can use keyword to specify sql % around the keyword like: %keyword% on the following
   // attributes: task title, identification key, all textAttributes in task, task number (only
   // if the keyword is a number)
   
   String keyword = null;
   String nullParam = null;
 
   // Get workflow service client
   IWorkflowServiceClient wfSvcClient = WorkflowServiceClientFactory.getWorkflowServiceClient(WorkflowServiceClientFactory.SOAP_CLIENT);
   // Get the workflow context
   IWorkflowContext wfCtx = wfSvcClient.getTaskQueryService().authenticate(userId, password, 
                                 oracle.tip.pc.services.identity.config.ISConfiguration.getDefaultRealmName(),
                                 null);
   // Admin can authenticate on behalf of another user
   //IWorkflowContext adminCtx = wfSvcClient.getTaskQueryService().authenticate(adminUserId, pwd, 
   //                              oracle.tip.pc.services.identity.config.ISConfiguration.getDefaultRealmName(),
   //                              userId);
   
   ITaskQueryService querySvc = wfSvcClient.getTaskQueryService();      
   
   // Only for SOAP clients and it is mandatory for SOAP clients
   Predicate.enableXMLSerialization(true);
   
   // Build the predicate
   Predicate statePredicate = new Predicate(TableConstants.WFTASK_STATE_COLUMN,
                                Predicate.OP_NEQ,
                                IWorkflowConstants.TASK_STATE_ASSIGNED);
        statePredicate.addClause(Predicate.AND,
                         TableConstants.WFTASK_NUMBERATTRIBUTE1_COLUMN,
                         Predicate.OP_IS_NULL,
                         nullParam);
   Predicate datePredicate = new Predicate(TableConstants.WFTASK_ENDDATE_COLUMN,
                                Predicate.OP_ON,
                                new Date());
   Predicate predicate = new Predicate(statePredicate, Predicate.AND, datePredicate);
   
   // Create the ordering
   Ordering ordering = new Ordering(TableConstants.WFTASK_TITLE_COLUMN, true, true);        
     ordering.addClause(TableConstants.WFTASK_PRIORITY_COLUMN, true, true);
     
   // List of display columns
   // For those columns that are not specified here, the queried Task object will not hold any value.
   // For example: If TITLE is not specified, task.getTitle() will return null
   // For the list of most comonly used columns, check the table below
   // Note: TASKID is fetched by default. So there is no need to explicitly specity it.
   List queryColumns = new ArrayList();
     queryColumns.add("TASKNUMBER");     
     queryColumns.add("TITLE");
     queryColumns.add("PRIORITY");
     queryColumns.add("STATE");
     queryColumns.add("ENDDATE");
     queryColumns.add("NUMBERATTRIBUTE1");
     queryColumns.add("TEXTATTRIBUTE1");
     
   // List of optional info
   // Any optionalInfo specified can be fetched from the Task object
   // For example: if you have specified "CustomActions", you can retrieve
   // it using task.getSystemAttributes().getCustomActions();
   // "Actions" (All Actions) - task.getSystemAttributes().getSystemActions()
   // "GroupActions" (Only group Actions: Actions that can be permoded by the user as a member of a group)
   //                - task.getSystemAttributes().getSystemActions()
   // "ShortHistory" - task.getSystemAttributes().getShortHistory()
   List optionalInfo = new ArrayList();
     optionalInfo.add("Actions");
     //optionalInfo.add("GroupActions");
     //optionalInfo.add("CustomActions");
     //optionalInfo.add("ShortHistory");
     // The following is reserved for future use. 
     // If you need them, please use getTaskDetailsById (or) getTaskDetailsByNumber,
     // which will fetch all information related to a task, which includes these
        //optionalInfo.add("Attachments");
        //optionalInfo.add("Comments");
        //optionalInfo.add("Payload");

   List tasksList = querySvc.queryTasks(wfCtx,
                               queryColumns,
                               optionalInfo,
                               ITaskQueryService.ASSIGNMENT_FILTER_MY_AND_GROUP,
                               keyword,
                               predicate, 
                               ordering, 
                               0,0); // No Paging
                               
   // How to use paging:
   // 1. If you need to dynamically calculate paging size (or) to display/find 
   //    out the number of pages, the user has to scroll (Like page X of Y)
   //      Call queryTasks to find out the number of tasks it returns. Using this 
   //      calculate your paging size (The number of taks you want in a page)
   //      Call queryTasks successively varing the startRow and endRow params.  
   //      For example: If the total number of tasks is 30 and your want a paging size
   //      of 10, you can call with (startRow, endRow): (1, 10) (11, 20) (21, 30) 
   // 2. If you have fixed paging size, just keep calling queryTasks successively with 
   //      the paging size (If your paging size is 10, you can call with (startRow, endRow): 
   //      (1, 10) (11, 20) (21, 30) (31, 40).....  until the number of tasks returned is 
   //      less than your paging size (or) there are no more tasks returned     

   if (tasksList != null) { // There are tasks 
     System.out.println("Total number of tasks: " + tasksList.size()); 
     System.out.println("Tasks List: ");
     Task task = null; 
     for (int i = 0; i < tasksList.size(); i++) { 
       task = (Task) tasksList.get(i);          
       System.out.println("Task Number: " + task.getSystemAttributes().getTaskNumber());
       System.out.println("Task Id: " + task.getSystemAttributes().getTaskId());
       System.out.println("Title: " + task.getTitle());
       System.out.println("Priority: " + task.getPriority());
       System.out.println("State: " + task.getSystemAttributes().getState());
       System.out.println();
       // Retrive any Optional Info specified
       // Use task service, to perform operations on the task
     }
   }
   
 Beyond authentication, all methods require the worklist context as the first argument. The worklist context 
 helps the worklist service determine the user requesting the action, whether the user has permission to 
 perform the requested action on the task and so forth. The context also contains information about the 
 user's locale and timezone information.
 

Most commonly used columns
Column objects are defined in oracle.bpel.services.workflow.repos.TableConstants, and they can also be obtained by passing the column name to the static method getColumn() on oracle.bpel.services.workflow.repos.Column.
A list task attributes and column names can be obtained by calling the method ITaskMetadataService.getTaskAttributes(oracle.bpel.services.workflow.verification.IWorkflowContext) or ITaskMetadataService.getTaskAttributesForTaskDefinition(oracle.bpel.services.workflow.verification.IWorkflowContext, java.lang.String).

Column Description Column Object How to retrieve
ACQUIREDBY Acquired By WFTASK_ACQUIREDBY_COLUMN task.getSystemAttributes().getAcquiredBy()
ASSIGNEES Assignees WFTASK_ASSIGNEES_COLUMN task.getSystemAttributes().getAssignees()
REVIEWERS Reviewers WFTASK_REVIEWERS_COLUMN task.getSystemAttributes().getReviewers()
ASSIGNEEGROUPS Assignee Groups WFTASK_ASSIGNEEGROUPS_COLUMN task.getSystemAttributes().getAssigneeGroups()
ASSIGNEEUSERS Assignee Users WFTASK_ASSIGNEEUSERS_COLUMN task.getSystemAttributes().getAssigneeUsers()
CREATOR Creator WFTASK_CREATOR_COLUMN task.getCreator()
DIGITALSIGNATUREREQUIRED Digital Signature Required WFTASK_DIGITALSIGNATUREREQUIRED_COLUMN task.getSystemAttributes().isDigitalSignatureRequired()
EXPIRATIONDATE Expiration Date WFTASK_EXPIRATIONDATE_COLUMN task.getSystemAttributes().getExpirationDate()
IDENTITYCONTEXT Identity Context WFTASK_IDENTITYCONTEXT_COLUMN task.getIdentityContext()
OWNERUSER Owner User WFTASK_OWNERUSER_COLUMN task.getOwnerUser()
OWNERGROUP Owner Group WFTASK_OWNERGROUP_COLUMN task.getOwnerGroup()
PASSWORDREQUIREDONUPDATE Password Required On Update WFTASK_PASSWORDREQUIREDONUPDATE_COLUMN task.getSystemAttributes().isPasswordRequiredOnUpdate()
PRIORITY Priority WFTASK_PRIORITY_COLUMN task.getPriority()
SECURENOTIFICATIONS Secure Notifications WFTASK_SECURENOTIFICATIONS_COLUMN task.getSystemAttributes().isSecureNotifications()
ASSIGNEDDATE Assigned Date WFTASK_ASSIGNEDDATE_COLUMN task.getSystemAttributes().getAssignedDate()
CREATEDDATE Created Date WFTASK_CREATEDDATE_COLUMN task.getSystemAttributes().getCreatedDate()
ENDDATE End Date WFTASK_ENDDATE_COLUMN task.getSystemAttributes().getEndDate()
FROMUSER From User WFTASK_FROMUSER_COLUMN task.getSystemAttributes().getFromUser()
HASSUBTASK Has Subtask WFTASK_HASSUBTASK_COLUMN task.getSystemAttributes().isHasSubTasks()
ISGROUP Is Group WFTASK_ISGROUP_COLUMN task.getSystemAttributes().isIsGroup()
ORIGINALASSIGNEEUSER Original Assignee User WFTASK_ORIGINALASSIGNEEUSER_COLUMN task.getSystemAttributes().()
OUTCOME Outcome WFTASK_OUTCOME_COLUMN task.getSystemAttributes().getOriginalAssigneeUser()
STATE State WFTASK_STATE_COLUMN task.getSystemAttributes().getState()
TASKID Task Id WFTASK_TASKID_COLUMN task.getSystemAttributes().getTaskId()
TASKNUMBER Task Number WFTASK_TASKNUMBER_COLUMN task.getSystemAttributes().getTaskNumber()
UPDATEDBY Updated By WFTASK_UPDATEDBY_COLUMN task.getSystemAttributes().getUpdatedBy()
UPDATEDDATE Updated Date WFTASK_UPDATEDDATE_COLUMN task.getSystemAttributes().getUpdatedDate()
TEXTATTRIBUTE1 to TEXTATTRIBUTE10 Textattribute1 to Textattribute10 WFTASK_TEXTATTRIBUTE1_COLUMN to WFTASK_TEXTATTRIBUTE10_COLUMN task.getSystemMessageAttributes().getTextAttribute1() to task.getSystemMessageAttributes().getTextAttribute10()
FORMATTRIBUTE1 to FORMATTRIBUTE5 FormAttribute1 to FormAttribute5 WFTASK_FORMATTRIBUTE1_COLUMN to WFTASK_FORMATTRIBUTE5_COLUMN task.getSystemMessageAttributes().getFormAttribute1() to task.getSystemMessageAttributes().getFormAttribute5()
URLATTRIBUTE1 to URLATTRIBUTE5 UrlAttribute1 to UrlAttribute5 WFTASK_URLATTRIBUTE1_COLUMN to WFTASK_URLATTRIBUTE5_COLUMN task.getSystemMessageAttributes().getUrlAttribute1() to task.getSystemMessageAttributes().getUrlAttribute5()
DATEATTRIBUTE1 to DATEATTRIBUTE5 DateAttribute1 to DateAttribute5 WFTASK_DATEATTRIBUTE1_COLUMN to WFTASK_DATEATTRIBUTE5_COLUMN task.getSystemMessageAttributes().getDateAttribute1() to task.getSystemMessageAttributes().getDateAttribute5()
NUMBERATTRIBUTE1 to NUMBERATTRIBUTE5 NumberAttribute1 to NumberAttribute5 WFTASK_NUMBERATTRIBUTE1_COLUMN to WFTASK_NUMBERATTRIBUTE5_COLUMN task.getSystemMessageAttributes().getNumberAttribute1() to task.getSystemMessageAttributes().getNumberAttribute5()
TITLE Title WFTASK_TITLE_COLUMN task.getTitle()
IDENTIFICATIONKEY Identification key WFTASK_IDENTIFICATIONKEY_COLUMN task.getIdentificationKey()
TASKDEFINITIONID Task Definition Id WFTASK_TASKDEFINITIONID_COLUMN task.getTaskDefinitionId()
TASKDEFINITIONNAME Task Definition Name WFTASK_TASKDEFINITIONNAME_COLUMN task.getSystemAttributes().getTaskDefinitionName()
PROTECTEDTEXTATTRIBUTE1 to PROTECTEDTEXTATTRIBUTE10 ProtectedTextAttribute1 to ProtectedTextAttribute10 WFTASK_PROTECTEDTEXTATTRIBUTE1_COLUMN to WFTASK_PROTECTEDTEXTATTRIBUTE10_COLUMN task.getSystemMessageAttributes().getProtectedTextAttribute1() to task.getSystemMessageAttributes().getProtectedTextAttribute10()
PROTECTEDFORMATTRIBUTE1 to PROTECTEDFORMATTRIBUTE5 ProtectedFormAttribute1 to ProtectedFormAttribute5 WFTASK_PROTECTEDFORMATTRIBUTE1_COLUMN to WFTASK_PROTECTEDFORMATTRIBUTE5_COLUMN task.getSystemMessageAttributes().getFormAttribute1() to task.getSystemMessageAttributes().getFormAttribute5()
PROTECTEDURLATTRIBUTE1 to PROTECTEDURLATTRIBUTE5 ProtectedURLAttribute1 to ProtectedURLAttribute5 WFTASK_PROTECTEDURLATTRIBUTE1_COLUMN to WFTASK_PROTECTEDURLATTRIBUTE5_COLUMN task.getSystemMessageAttributes().getProtectedURLAttribute1() to task.getSystemMessageAttributes().getProtectedURLAttribute5()
PROTECTEDDATEATTRIBUTE1 to PROTECTEDDATEATTRIBUTE5 ProtectedDateAttribute1 to ProtectedDateAttribute5 WFTASK_PROTECTEDDATEATTRIBUTE1_COLUMN to WFTASK_PROTECTEDDATEATTRIBUTE5_COLUMN task.getSystemMessageAttributes().getProtectedDateAttribute1() to task.getSystemMessageAttributes().getProtectedDateAttribute5()
PROTECTEDNUMBERATTRIBUTE1 to PROTECTEDNUMBERATTRIBUTE5 ProtectedNumberAttribute1 to ProtectedNumberAttribute5 WFTASK_PROTECTEDNUMBERATTRIBUTE1_COLUMN to WFTASK_PROTECTEDNUMBERATTRIBUTE5_COLUMN task.getSystemMessageAttributes().getProtectedNumberAttribute1() to task.getSystemMessageAttributes().getProtectedNumberAttribute5()
APPLICATIONCONTEXT Application Context WFTASK_APPLICATIONCONTEXT_COLUMN task.getApplicationContext()
CATEGORY Category WFTASK_CATEGORY_COLUMN task.getCategory()
DUEDATE Due Date WFTASK_DUEDATE_COLUMN task.getDueDate()
ISPUBLIC Is Public WFTASK_ISPUBLIC_COLUMN task.isIsPublic()
PARTICIPANTNAME Participant Name WFTASK_PARTICIPANTNAME_COLUMN task.getSystemAttributes().getParticipantName()
PERCENTAGECOMPLETE Percentage Complete WFTASK_PERCENTAGECOMPLETE_COLUMN task.getPercentageComplete()
STARTDATE Start Date WFTASK_STARTDATE_COLUMN task.getStartDate()
TASKDISPLAYURL Task Display Url WFTASK_TASKDISPLAYURL_COLUMN task.getTaskDisplayUrl()

你可能感兴趣的:(service)