`
cutesunshineriver
  • 浏览: 200648 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Human Task - Use External Routing

阅读更多
Oracle BPM,在设计流程图的时候使用Complex User Task,对应的Human Task在分配对象的时候会采用外部路由,即自定义分配实现。

自定义类要实现oracle.bpel.services.workflow.task.IAssignmentService接口,代码如下:
package dasproject;

/* $Header: TestAssignmentService.java 24-may-2006.18:26:16 Exp $ */
/* Copyright (c) 2004, 2006, Oracle. All rights reserved. */
/*
DESCRIPTION
Interface IAssignmentService defines the callbacks an assignment
service implements. The implementation of the IAssignmentService
is called by the workflow service
PRIVATE CLASSES
<list of private classes defined - with one-line descriptions>
NOTES
<other useful comments, qualifications, etc.>
MODIFIED (MM/DD/YY)
*/
/**
* @version $Header: IAssignmentService.java 29-jun-2004.21:10:35 Exp
$
*
*
*/
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import oracle.bpel.services.workflow.metadata.routingslip.model.*;

import oracle.bpel.services.workflow.metadata.routingslip.model.Participants;
import oracle.bpel.services.workflow.metadata.routingslip.model.ParticipantsType.*;
import oracle.bpel.services.workflow.task.IAssignmentService;
import oracle.bpel.services.workflow.task.ITaskAssignee;
import oracle.bpel.services.workflow.task.model.Task;

public class TestAssignmentService implements oracle.bpel.services.workflow.task.IAssignmentService {
    static int numberOfApprovals = 0;
    static String[] users = new String[] { "zhangsan", "dangan", "liangban" };

    @Override
    public Participants onInitiation(Task task, Map propertyBag) {
        return createParticipant();
    }

    @Override
    public Participants onReinitiation(Task task, Map propertyBag) {
        return null;
    }

    @Override
    public Participants onOutcomeUpdated(Task task, Map propertyBag,
                                         String updatedBy, String outcome) {
        return createParticipant();
    }

    @Override
    public Participants onAssignmentSkipped(Task task, Map propertyBag) {
        return null;
    }
    
    @Override
    public List getAssigneesToRequestForInformation(Task task,
                                                    Map propertyBag) {
        List rfiUsers = new ArrayList();
        rfiUsers.add("jcooper");
        rfiUsers.add("zhangsan");
        rfiUsers.add("dangan");
        rfiUsers.add("liangban");
        return rfiUsers;
    }

    @Override
    public List getReapprovalAssignees(Task task, Map propertyBag,
                                       ITaskAssignee infoRequestedAssignee) {
        List reapprovalUsers = new ArrayList();
        reapprovalUsers.add("zhangsan");
        reapprovalUsers.add("dangan");
        reapprovalUsers.add("liangban");
        return reapprovalUsers;
    }

    private Participants createParticipant() {
        if (numberOfApprovals > 2) {
            numberOfApprovals = 0;
            return null;
        }
        String user = users[numberOfApprovals++];
        ObjectFactory objFactory = new ObjectFactory();
        Participants participants = objFactory.createParticipants();
        Participant participant =
            objFactory.createParticipantsTypeParticipant();
        participant.setName("Loan Agent");
        ResourceType resource2 = objFactory.createResourceType(user);
        resource2.setIsGroup(false);
        resource2.setType("STATIC");
        participant.getResource().add(resource2);
        participants.getParticipantOrSequentialParticipantOrAdhoc().add(participant);
        return participants;
    }
}

在流程项目属性上增加SOA Workflow的库依赖。
TestAssignmentService要放到SCA-INF/classes路径下。

编辑实现Complex User Task的Human Task对象,在Assignment的Tab页,设置class name为dasproject.TestAssignmentService。

发布流程项目,Complex User Task就会按照自定义类TestAssignmentService来分配任务给指定对象。
onInitiation方法,是指任务初始化的时候分配给谁。
onOutcomeUpdated方法,是指任务被更新结果的时候分配给谁。
getAssigneesToRequestForInformation方法,是指用户请求信息的时候参与方有哪些人。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics