Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension attribute delegateExpression defined for a ServiceTask is lost while using BpmnXMLConverter #3942

Closed
janslee opened this issue Aug 6, 2024 · 2 comments

Comments

@janslee
Copy link

janslee commented Aug 6, 2024

Describe the bug
When using the BpmnXMLConverter to convert a BpmnModel to XML, I defined a delegateExpression for the servicetask element, but it is lost during the conversion process,

Expected behavior
conversion process can convert the delegateExpression attribute

Code
BpmnModel model = new BpmnModel();
Process process = new Process();
...
flowElement = new ServiceTask();
...
ExtensionAttribute extensionAttribute = new ExtensionAttribute();
extensionAttribute.setNamespace(BpmnXMLConstants.FLOWABLE_EXTENSIONS_NAMESPACE);
extensionAttribute.setNamespacePrefix(BpmnXMLConstants.FLOWABLE_EXTENSIONS_PREFIX);
extensionAttribute.setName("delegateExpression");
extensionAttribute.setValue("${" + delegateExpression + "}");
flowElement.addAttribute(extensionAttribute);

      BpmnAutoLayout bpmnLayout = new BpmnAutoLayout(model); //debug can see the delegateExpression attribute
        bpmnLayout.execute();
        // convert to xml
        BpmnXMLConverter converter = new BpmnXMLConverter();
        xmlBytes = converter.convertToXML(model, "UTF-8");
        String xmlString = new String(xmlBytes, "UTF-8");  //missing the delegateExpression attribute in XML

Additional context
flowable version: 6.8.1, using mysql database, spring boot:2.7.18

@filiphr
Copy link
Contributor

filiphr commented Aug 6, 2024

Hey @janslee,

Some attributes are treated specially by Flowable. In order to achieve what you are looking for you should not use an extension attribute. Rather use the setters on the ServiceTask itself.

e.g.

ServiceTask serviceTask = new ServiceTask();
serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
serviceTask.setImplementation("${" + delegateExpression + "}");

Doing it this way should export the delegate expression attribute in the XML.

@janslee
Copy link
Author

janslee commented Aug 6, 2024

Thanks a lot!you da man, it works perfectly

@filiphr filiphr closed this as completed Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants