gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 10:51:08 24 4
gpt4 key购买 nike

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

enter image description here

现在,如果我被分配了一项审阅任务,我可以选择修改、拒绝或批准它。我想要做的是动态地提取可用的传出转换(修订、拒绝、批准)并向用户显示它从任何 jBPM 服务动态地对任务采取操作。请指导我。

最佳答案

您想要获取下一个不同网关节点的转换。

首先,您必须获取 Activity 节点(请注意,根据工作流程的复杂性,可能有多个 Activity 节点)

public static List<Node> getProcessActiveNodeList(final StatefulKnowledgeSession inSession,
final WorkflowProcessInstanceImpl inInstance) {
final List<Node> nodes = new ArrayList<>();
final WorkflowProcess process = (WorkflowProcess) inSession.getKnowledgeBase().getProcess(inInstance.getProcessId());
for (Node node : process.getNodes()) {
if (node instanceof EventNode && ((EventNode) node).getFrom() == null) {
// a free-standing event, without an entry point; this would be a start of an "optional" branch
nodes.add(node);
} else {
// a node that has an inbound connection; all nodes on the main branch are of this kind
List<NodeInstance> nodeInstances = inInstance.getNodeInstances(node.getId());
if (nodeInstances != null && !nodeInstances.isEmpty()) {
for (NodeInstance nodeInstance : nodeInstances) {
Node nodeInstanceNode = process.getNode(nodeInstance.getNodeId());
nodes.add(0, nodeInstanceNode);
}
}
}
}
return nodes;
}

接下来您需要获取下一个不同网关节点的约束:

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;
}

每个 ConnectionRef 都指向一个 Node,并且 Constraint 应包含条件(修订、拒绝、接受)

关于java - jBPM 6.2 - 如何获取当前分配任务的传出转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33895669/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com