Java jBPM 6.2-如何获取当前分配任务的传出转换

Java jBPM 6.2-如何获取当前分配任务的传出转换,java,jbpm,Java,Jbpm,我是jBPM的新手,正在努力寻找为当前用户任务提取可用传出转换的方法。例如,如果我的工作流为: 现在,如果我被分配了一个审查任务,我可以选择修改、拒绝或批准它。我想做的是动态地拉取可用的传出转换(修订、拒绝、批准),并将其显示给从任何jBPM服务动态执行任务的用户。请指导我。您希望获得下一个发散网关节点的转换 首先,您必须获得活动节点(注意,根据工作流的复杂性,可能有多个活动节点) 公共静态列表getProcessActiveNodeList(最终状态KnowledgeSession inSe

我是jBPM的新手,正在努力寻找为当前用户任务提取可用传出转换的方法。例如,如果我的工作流为:


现在,如果我被分配了一个审查任务,我可以选择修改、拒绝或批准它。我想做的是动态地拉取可用的传出转换(修订、拒绝、批准),并将其显示给从任何jBPM服务动态执行任务的用户。请指导我。

您希望获得下一个发散网关节点的转换

首先,您必须获得活动节点(注意,根据工作流的复杂性,可能有多个活动节点)

公共静态列表getProcessActiveNodeList(最终状态KnowledgeSession inSession,
最终工作流过程实例(实例){
最终列表节点=新的ArrayList();
final WorkflowProcess process=(WorkflowProcess)inSession.getKnowledgeBase().getProcess(inInstance.getProcessId());
for(节点:process.getNodes()){
if(EventNode&((EventNode)节点的节点实例)。getFrom()==null){
//一个独立的事件,没有入口点;这将是一个“可选”分支的开始
nodes.add(node);
}否则{
//具有入站连接的节点;主分支上的所有节点都属于这种类型
List nodeInstances=inInstance.getNodeInstances(node.getId());
if(nodeInstances!=null&&!nodeInstances.isEmpty()){
用于(节点实例节点实例:节点实例){
Node nodeInstanceNode=process.getNode(nodeInstance.getNodeId());
添加(0,nodeInstanceNode);
}
}
}
}
返回节点;
}
接下来,您需要获取下一个发散网关节点的约束:

public static Map<ConnectionRef, Constraint> getNextGatewayConstraints(final StatefulKnowledgeSession inSession,
                                                                       final WorkflowProcessInstanceImpl inInstance,
                                                                       final Node inTaskNode) {
    final Map<ConnectionRef, Constraint> constraints = new HashMap<>();
    final WorkflowProcess process = (WorkflowProcess) inSession.getKnowledgeBase().getProcess(inInstance.getProcessId());
    for (Node node : process.getNodes()) {
        if (!node.equals(inTaskNode)) {
            continue;
        }
        final List<Connection> nodeConnections = node.getOutgoingConnections(org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE);
        if (nodeConnections != null && !nodeConnections.isEmpty()) {
            for (Connection c : nodeConnections) {
                final Node nextNode = c.getTo();
                if (nextNode instanceof Split) {
                    constraints.putAll(((Split) nextNode).getConstraints());
                    return constraints;
                }
            }
        }
        break;
    }
    return constraints;
}
公共静态映射getNextGatewayConstraints(最终状态KnowledgeSession inSession,
最终工作流程InstanceImpl inInstance,
最终节点(在节点中){
最终映射约束=新HashMap();
final WorkflowProcess process=(WorkflowProcess)inSession.getKnowledgeBase().getProcess(inInstance.getProcessId());
for(节点:process.getNodes()){
如果(!node.equals(inTaskNode)){
继续;
}
最终列表nodeConnections=node.getOutgoingConnections(org.jbpm.workflow.core.node.CONNECTION\u DEFAULT\u TYPE);
if(nodeConnections!=null&&!nodeConnections.isEmpty()){
用于(连接c:节点连接){
最终节点nextNode=c.getTo();
if(拆分的下一个节点实例){
putAll(((拆分)nextNode.getConstraints());
回报约束;
}
}
}
打破
}
回报约束;
}

每个ConnectionRef指向一个节点,约束应该包含条件(修订、拒绝、接受)

谢谢John,我会尝试一下,很快会通知您。
public static Map<ConnectionRef, Constraint> getNextGatewayConstraints(final StatefulKnowledgeSession inSession,
                                                                       final WorkflowProcessInstanceImpl inInstance,
                                                                       final Node inTaskNode) {
    final Map<ConnectionRef, Constraint> constraints = new HashMap<>();
    final WorkflowProcess process = (WorkflowProcess) inSession.getKnowledgeBase().getProcess(inInstance.getProcessId());
    for (Node node : process.getNodes()) {
        if (!node.equals(inTaskNode)) {
            continue;
        }
        final List<Connection> nodeConnections = node.getOutgoingConnections(org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE);
        if (nodeConnections != null && !nodeConnections.isEmpty()) {
            for (Connection c : nodeConnections) {
                final Node nextNode = c.getTo();
                if (nextNode instanceof Split) {
                    constraints.putAll(((Split) nextNode).getConstraints());
                    return constraints;
                }
            }
        }
        break;
    }
    return constraints;
}