ワークフロー・サービスのクライアント作成に関する概要
Javaクライアント・アプリケーションを作成して、ヒューマン・ワークフロー・サービスをコールする場合、JRFがJavaクライアント・アプリケーションと同じ環境で実行されている必要があります。
簡単なワークリスト・アプリケーションを作成するには:
次に、簡単なワークリスト・アプリケーションを作成する際の典型的なコール順序を示します。
IWorklistServiceClient
へのハンドルをWorkflowServiceClientFactory
から取得します。ITaskQueryService
へのハンドルをIWorklistServiceClient
から取得します。- ユーザー名とパスワードを
ITaskQueryService
の認証メソッドに渡して、ユーザーを認証します。IWorkflowContext
へのハンドルを取得します。 ITaskQueryService
を使用してタスク・リストを問い合せます。ITaskService
へのハンドルをIWorklistServiceClient
から取得します。- 返されたタスク・リストを反復し、
ITaskService
を使用してタスクに対するアクションを実行します。
次のコード・サンプルは、ワークフロー・サービスのクライアントの作成方法を示しています。jstein
に割り当てられている全タスクのリストに対して問合せが実行されます。結果が設定されていないタスクが承認されます。
try { //Create JAVA WorflowServiceClient IWorkflowServiceClient wfSvcClient = WorkflowServiceClientFactory.getWorkflowServiceClient( WorkflowServiceClientFactory.REMOTE_CLIENT); //Get the task query service ITaskQueryService querySvc = wfSvcClient.getTaskQueryService(); //Login as jstein IWorkflowContext ctx = querySvc.authenticate("jstein","welcome1".toCharArry(),null); //Set up list of columns to query List queryColumns = new ArrayList(); queryColumns.add("TASKID"); queryColumns.add("TASKNUMBER"); queryColumns.add("TITLE"); queryColumns.add("OUTCOME"); //Query a list of tasks assigned to jstein List tasks = querySvc.queryTasks(ctx, queryColumns, null, //Do not query additional info ITaskQueryService.AssignmentFilter.MY, null, //No keywords null, //No custom predicate null, //No special ordering 0, //Do not page the query result 0); //Get the task service ITaskService taskSvc = wfSvcClient.getTaskService(); //Loop over the tasks, outputting task information, and approving any //tasks whose outcome has not been set... for(int i = 0 ; i < tasks.size() ; i ++) { Task task = (Task)tasks.get(i); int taskNumber = task.getSystemAttributes().getTaskNumber(); String title = task.getTitle(); String taskId = task.getSystemAttributes().getTaskId(); String outcome = task.getSystemAttributes().getOutcome(); if(outcome == null) { outcome = "APPROVE"; taskSvc.updateTaskOutcome(ctx,taskId,outcome); } System.out.println("Task #"+taskNumber+" ("+title+") is "+outcome); } } catch (Exception e) { //Handle any exceptions raised here... System.out.println("Caught workflow exception: "+e.getMessage()); }