TaskQueryService

21 篇文章 0 订阅

 

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).

ColumnDescriptionColumn ObjectHow to retrieve
ACQUIREDBYAcquired ByWFTASK_ACQUIREDBY_COLUMNtask.getSystemAttributes().getAcquiredBy()
ASSIGNEESAssigneesWFTASK_ASSIGNEES_COLUMNtask.getSystemAttributes().getAssignees()
REVIEWERSReviewersWFTASK_REVIEWERS_COLUMNtask.getSystemAttributes().getReviewers()
ASSIGNEEGROUPSAssignee GroupsWFTASK_ASSIGNEEGROUPS_COLUMNtask.getSystemAttributes().getAssigneeGroups()
ASSIGNEEUSERSAssignee UsersWFTASK_ASSIGNEEUSERS_COLUMNtask.getSystemAttributes().getAssigneeUsers()
CREATORCreatorWFTASK_CREATOR_COLUMNtask.getCreator()
DIGITALSIGNATUREREQUIREDDigital Signature RequiredWFTASK_DIGITALSIGNATUREREQUIRED_COLUMNtask.getSystemAttributes().isDigitalSignatureRequired()
EXPIRATIONDATEExpiration DateWFTASK_EXPIRATIONDATE_COLUMNtask.getSystemAttributes().getExpirationDate()
IDENTITYCONTEXTIdentity ContextWFTASK_IDENTITYCONTEXT_COLUMNtask.getIdentityContext()
OWNERUSEROwner UserWFTASK_OWNERUSER_COLUMNtask.getOwnerUser()
OWNERGROUPOwner GroupWFTASK_OWNERGROUP_COLUMNtask.getOwnerGroup()
PASSWORDREQUIREDONUPDATEPassword Required On UpdateWFTASK_PASSWORDREQUIREDONUPDATE_COLUMNtask.getSystemAttributes().isPasswordRequiredOnUpdate()
PRIORITYPriorityWFTASK_PRIORITY_COLUMNtask.getPriority()
SECURENOTIFICATIONSSecure NotificationsWFTASK_SECURENOTIFICATIONS_COLUMNtask.getSystemAttributes().isSecureNotifications()
ASSIGNEDDATEAssigned DateWFTASK_ASSIGNEDDATE_COLUMNtask.getSystemAttributes().getAssignedDate()
CREATEDDATECreated DateWFTASK_CREATEDDATE_COLUMNtask.getSystemAttributes().getCreatedDate()
ENDDATEEnd DateWFTASK_ENDDATE_COLUMNtask.getSystemAttributes().getEndDate()
FROMUSERFrom UserWFTASK_FROMUSER_COLUMNtask.getSystemAttributes().getFromUser()
HASSUBTASKHas SubtaskWFTASK_HASSUBTASK_COLUMNtask.getSystemAttributes().isHasSubTasks()
ISGROUPIs GroupWFTASK_ISGROUP_COLUMNtask.getSystemAttributes().isIsGroup()
ORIGINALASSIGNEEUSEROriginal Assignee UserWFTASK_ORIGINALASSIGNEEUSER_COLUMNtask.getSystemAttributes().()
OUTCOMEOutcomeWFTASK_OUTCOME_COLUMNtask.getSystemAttributes().getOriginalAssigneeUser()
STATEStateWFTASK_STATE_COLUMNtask.getSystemAttributes().getState()
TASKIDTask IdWFTASK_TASKID_COLUMNtask.getSystemAttributes().getTaskId()
TASKNUMBERTask NumberWFTASK_TASKNUMBER_COLUMNtask.getSystemAttributes().getTaskNumber()
UPDATEDBYUpdated ByWFTASK_UPDATEDBY_COLUMNtask.getSystemAttributes().getUpdatedBy()
UPDATEDDATEUpdated DateWFTASK_UPDATEDDATE_COLUMNtask.getSystemAttributes().getUpdatedDate()
TEXTATTRIBUTE1 to TEXTATTRIBUTE10Textattribute1 to Textattribute10WFTASK_TEXTATTRIBUTE1_COLUMN to WFTASK_TEXTATTRIBUTE10_COLUMNtask.getSystemMessageAttributes().getTextAttribute1() to task.getSystemMessageAttributes().getTextAttribute10()
FORMATTRIBUTE1 to FORMATTRIBUTE5FormAttribute1 to FormAttribute5WFTASK_FORMATTRIBUTE1_COLUMN to WFTASK_FORMATTRIBUTE5_COLUMNtask.getSystemMessageAttributes().getFormAttribute1() to task.getSystemMessageAttributes().getFormAttribute5()
URLATTRIBUTE1 to URLATTRIBUTE5UrlAttribute1 to UrlAttribute5WFTASK_URLATTRIBUTE1_COLUMN to WFTASK_URLATTRIBUTE5_COLUMNtask.getSystemMessageAttributes().getUrlAttribute1() to task.getSystemMessageAttributes().getUrlAttribute5()
DATEATTRIBUTE1 to DATEATTRIBUTE5DateAttribute1 to DateAttribute5WFTASK_DATEATTRIBUTE1_COLUMN to WFTASK_DATEATTRIBUTE5_COLUMNtask.getSystemMessageAttributes().getDateAttribute1() to task.getSystemMessageAttributes().getDateAttribute5()
NUMBERATTRIBUTE1 to NUMBERATTRIBUTE5NumberAttribute1 to NumberAttribute5WFTASK_NUMBERATTRIBUTE1_COLUMN to WFTASK_NUMBERATTRIBUTE5_COLUMNtask.getSystemMessageAttributes().getNumberAttribute1() to task.getSystemMessageAttributes().getNumberAttribute5()
TITLETitleWFTASK_TITLE_COLUMNtask.getTitle()
IDENTIFICATIONKEYIdentification keyWFTASK_IDENTIFICATIONKEY_COLUMNtask.getIdentificationKey()
TASKDEFINITIONIDTask Definition IdWFTASK_TASKDEFINITIONID_COLUMNtask.getTaskDefinitionId()
TASKDEFINITIONNAMETask Definition NameWFTASK_TASKDEFINITIONNAME_COLUMNtask.getSystemAttributes().getTaskDefinitionName()
PROTECTEDTEXTATTRIBUTE1 to PROTECTEDTEXTATTRIBUTE10ProtectedTextAttribute1 to ProtectedTextAttribute10WFTASK_PROTECTEDTEXTATTRIBUTE1_COLUMN to WFTASK_PROTECTEDTEXTATTRIBUTE10_COLUMNtask.getSystemMessageAttributes().getProtectedTextAttribute1() to task.getSystemMessageAttributes().getProtectedTextAttribute10()
PROTECTEDFORMATTRIBUTE1 to PROTECTEDFORMATTRIBUTE5ProtectedFormAttribute1 to ProtectedFormAttribute5WFTASK_PROTECTEDFORMATTRIBUTE1_COLUMN to WFTASK_PROTECTEDFORMATTRIBUTE5_COLUMNtask.getSystemMessageAttributes().getFormAttribute1() to task.getSystemMessageAttributes().getFormAttribute5()
PROTECTEDURLATTRIBUTE1 to PROTECTEDURLATTRIBUTE5ProtectedURLAttribute1 to ProtectedURLAttribute5WFTASK_PROTECTEDURLATTRIBUTE1_COLUMN to WFTASK_PROTECTEDURLATTRIBUTE5_COLUMNtask.getSystemMessageAttributes().getProtectedURLAttribute1() to task.getSystemMessageAttributes().getProtectedURLAttribute5()
PROTECTEDDATEATTRIBUTE1 to PROTECTEDDATEATTRIBUTE5ProtectedDateAttribute1 to ProtectedDateAttribute5WFTASK_PROTECTEDDATEATTRIBUTE1_COLUMN to WFTASK_PROTECTEDDATEATTRIBUTE5_COLUMNtask.getSystemMessageAttributes().getProtectedDateAttribute1() to task.getSystemMessageAttributes().getProtectedDateAttribute5()
PROTECTEDNUMBERATTRIBUTE1 to PROTECTEDNUMBERATTRIBUTE5ProtectedNumberAttribute1 to ProtectedNumberAttribute5WFTASK_PROTECTEDNUMBERATTRIBUTE1_COLUMN to WFTASK_PROTECTEDNUMBERATTRIBUTE5_COLUMNtask.getSystemMessageAttributes().getProtectedNumberAttribute1() to task.getSystemMessageAttributes().getProtectedNumberAttribute5()
APPLICATIONCONTEXTApplication ContextWFTASK_APPLICATIONCONTEXT_COLUMNtask.getApplicationContext()
CATEGORYCategoryWFTASK_CATEGORY_COLUMNtask.getCategory()
DUEDATEDue DateWFTASK_DUEDATE_COLUMNtask.getDueDate()
ISPUBLICIs PublicWFTASK_ISPUBLIC_COLUMNtask.isIsPublic()
PARTICIPANTNAMEParticipant NameWFTASK_PARTICIPANTNAME_COLUMNtask.getSystemAttributes().getParticipantName()
PERCENTAGECOMPLETEPercentage CompleteWFTASK_PERCENTAGECOMPLETE_COLUMNtask.getPercentageComplete()
STARTDATEStart DateWFTASK_STARTDATE_COLUMNtask.getStartDate()
TASKDISPLAYURLTask Display UrlWFTASK_TASKDISPLAYURL_COLUMNtask.getTaskDisplayUrl()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值