如何确定通话活动的通道?

时间:2014-10-15 12:52:12

标签: java bpm bpmn camunda

我有一个Call Activity,它在我的BPMN图的不同通道中使用。 “呼叫活动”中有一项任务。是否可以从任务中确定呼叫活动的通道?

在这里的图片中看起来像这样:

Process Diagram

Call Activity

我想从任务“Get parent Lane”中分别确定“MyLane1”“MyLane2”。

2 个答案:

答案 0 :(得分:5)

您可以使用BPMN Model API来确定引用活动的通道:

ProcessDefinition procDef  = repositoryService.createProcessDefinitionQuery().processDefinitionKey("idOfProcess").singleResult();
BpmnModelInstance bpmnModelInstance = repositoryService.getBpmnModelInstance(procDef.getId());

CallActivity callActivity = null;

Collection<Lane> lanes = bpmnModelInstance.getModelElementsByType(Lane.class);
// iterate the lanes
for (Lane lane : lanes) {
  // iterate the flownodes referenced by the lane:
  for (FlowNode flowNode : lane.getFlowNodeRefs()) {
    if("idOfCallactivity".equals(flowNode.getId())) {
      callActivity = (CallActivity) flowNode;
      break;
    }
  }
}


if(callActivity != null) {
  // work with callactivity
}

答案 1 :(得分:1)

使用内部API也可以

public void execute(DelegateExecution e) {

  ((ExecutionEntity)e).getProcessInstance()
    .getSuperExecution()
    .getActivityId()
}
相关问题