Burn
October 13, 2019, 9:41am
1
I need attribute of BusinessRuleTask#implementation to do something in my global listener, i try to get it like below way but failed.
DelegateExecution execution = xxx;
ActivityExecution activityExecution = (ActivityExecution) execution;
FlowElement bpmnModelElementInstance = execution.getBpmnModelElementInstance();
ModelElementInstance documentElement = execution.getBpmnModelInstance().getDocumentElement();
// below result is '#unspecifed'
String implementation = bpmnModelElementInstance.getAttributeValue("implementation");
PvmActivity activity = activityExecution.getActivity();
Object property = activity.getProperty(BpmnProperties.TYPE.getName());
if (!Objects.isNull(property) && ActivityTypes.TASK_BUSINESS_RULE.equalsIgnoreCase(property.toString())) {
// do something..
}
I find type hierarchy with org.camunda.bpm.model.xml.instance.ModelElementInstance below.
ModelElementInstance → InteractionNode → Activity → Task → BusinessRuleTask
What can i do? Tell me please.
Thank you very much.
hassang
October 13, 2019, 12:48pm
2
Hi @Burn ,
Did you try below
FlowElement bpmnModelElementInstance = execution.getBpmnModelElementInstance();
if (bpmnModelElementInstance instanceof BusinessRuleTask) {
BusinessRuleTask brt = (BusinessRuleTask) bpmnModelElementInstance;
String impl = brt.getImplementation();
}
Burn
October 13, 2019, 1:30pm
3
Thank for your reply, unfortunately i try that get same result(’##unspecified ’) as above code, may be Camunda extended occur after BPMN doc render, i will try other way until find answer.
Burn
October 13, 2019, 3:35pm
5
As you can see, It doesn’t work!
Thanks again for your reply anyway.
Hi @Burn ,
I found the reason for that
If you have a look at the XML view of your model, you would find that no implementation attribute at all but there is camunda:decisionRef attribute
<bpmn:businessRuleTask id="Task_18ufkc9" name="Task 1" camunda:decisionRef="DR01">
<bpmn:extensionElements>
<camunda:executionListener class="com.ap.testapp.RTListener" event="end" />
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_0xqa8he</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0y6as71</bpmn:outgoing>
</bpmn:businessRuleTask>
Because of that if you try below code
public void notify(DelegateExecution execution) throws Exception {
FlowElement bpmnModelElementInstance = execution.getBpmnModelElementInstance();
if (bpmnModelElementInstance instanceof BusinessRuleTask) {
BusinessRuleTask brt = (BusinessRuleTask) bpmnModelElementInstance;
String decisionRef = brt.getCamundaDecisionRef();
System.out.println("decisionRef: " + decisionRef);
String impl = brt.getImplementation();
System.out.println("impl: " + impl);
}
}
You will get a value for decisionRef but nothing for impl
decisionRef: DR01
impl: ##unspecified
For that exact reason I have implemented a scanner that allows to retrieve said information.
You can check the following lines of code here . Maybe you can use that as starting point, because there are several cases where the API does not return the proper values and thus I extracted the needed values directly from the BPMN.
Best regards
Sascha
1 Like
Burn
October 16, 2019, 2:40am
8
hassang:
getCamundaDecisionRef
You are right, i realized decision structure that exist ‘camunda:decisionRef’ not ‘implementation’ attribute but i not found some api(BusinessRuleTask#getCamundaDecisionRef) between camunda and bpmn element
I should really try more so I don’t waste your time, i’m sorry.
Thanks.
Burn
October 16, 2019, 3:33am
9
Thank you very much.
If it wasn’t @ hassang answer, I would have parsed the XML to get the value as your suggest.