I used code to get all flows from current activity described here Submit Form
In Flowable v6.3.1 interface changed and I don’t know how to get it.
I know that:
Process process = ...?...
Activity activity = (Activity) process.getFlowElement(activityId, true);
List<SequenceFlow> outgoingFlows = activity.getOutgoingFlows();
but how can I get Process object?
public class GetOutgoingFlowsCommand implements Command<List<String>>, Serializable {
private String processDefinitionId;
private String activityId;
public GetOutgoingFlowsCommand(String processDefinitionId, String activityId) {
this.processDefinitionId = processDefinitionId;
this.activityId = activityId;
}
public List<String> execute(CommandContext commandContext) {
List<String> possibleSequenceFlowIds = new ArrayList<String>();
Process process = ProcessDefinitionUtil.getProcess(processDefinitionId);
Activity activity = (Activity) process.getFlowElement(activityId, true);
for (SequenceFlow sequenceFlow : activity.getOutgoingFlows()) {
possibleSequenceFlowIds.add(sequenceFlow.getId());
}
return possibleSequenceFlowIds;
}
}
filiphr
September 13, 2018, 3:40pm
3
@Jakub_Ferschmann this looks quite complex.
Have you looked at RepositoryService#getBpmnModel(String)
? This returns you back BpmnModel
and then you can do BpmnModel#getMainProcess()
ksv
November 29, 2018, 2:37pm
4
How to fetch Extension elements on TaskListener.notify()
public class MyTaskCreateListener implements TaskListener {
@Override
public void notify(DelegateTask delegateTask) {
Map<String, List<ExtensionElement>> exelements = ProcessDefinitionUtil.getBpmnModel(delegateTask.getProcessDefinitionId()).getFlowElement(delegateTask.getTaskDefinitionKey()).getExtensionElements();
System.out.println(exelements.size());
}
}
Is this the way or do we have any better way
I would not use the ProcessDefinitionUtil
that’s an internal API. You can use the RepositoryService#getBpmnModel
from the API package to get the BpmnModel
Cheers,
Filip
ksv
December 5, 2018, 6:21am
6
Hi
I believe we need to give the class names of the listener at extensionElements. In my case MyTaskCreateListener does not have any access to Repository Service. From the context of MyTaskCreateListener how can we get access to RepositoryServerObject,
filiphr
December 10, 2018, 7:51am
7
@ksv have a look at the CommandContextUtil
from the flowable-engine
, you can get access to the RepositoryService
through it