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

When I use the convertToXML method of BpmnXMLConverter to convert BpmnModel into an XML file, if the ServiceTask defines setCustoms Properties, the converted XML file has problems #3977

Open
fuuhoo opened this issue Oct 10, 2024 · 0 comments

Comments

@fuuhoo
Copy link

fuuhoo commented Oct 10, 2024

Describe the bug
BpmnModel:

image

i got this wrong xml:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:flowable="http://flowable.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.flowable.org/test">
  <process id="processid" name="process" isExecutable="true">
    <startEvent id="start" name="开始" flowable:formKey="11111"></startEvent>
    <sequenceFlow sourceRef="start" targetRef="serviceTask"></sequenceFlow>
    <serviceTask id="serviceTask">
      <extensionElements>
        <flowable:field name="flowable:test">
          <flowable:string>testSimpleValue</flowable:string>
        </flowable:field>
      </extensionElements>
      <sequenceFlow sourceRef="serviceTask" targetRef="end"></sequenceFlow>
      <endEvent id="end" name="结束"></endEvent>
    </serviceTask>
    <bpmndi:BPMNDiagram id="BPMNDiagram_processid">
      <bpmndi:BPMNPlane bpmnElement="processid" id="BPMNPlane_processid"></bpmndi:BPMNPlane>
    </bpmndi:BPMNDiagram>
  </process></definitions>

when i add another xtw.writeEndElement() in writeCustomProperties function ,ServiceTaskXMLConverter class,org.flowable.bpmn.converter package
image

I got xml that looks correct

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:flowable="http://flowable.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.flowable.org/test">
  <process id="processid" name="process" isExecutable="true">
    <startEvent id="start" name="开始" flowable:formKey="11111"></startEvent>
    <sequenceFlow sourceRef="start" targetRef="serviceTask"></sequenceFlow>
    <serviceTask id="serviceTask">
      <extensionElements>
        <flowable:field name="flowable:test">
          <flowable:string>testSimpleValue</flowable:string>
        </flowable:field>
      </extensionElements>
    </serviceTask>
    <sequenceFlow sourceRef="serviceTask" targetRef="end"></sequenceFlow>
    <endEvent id="end" name="结束"></endEvent>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_processid">
    <bpmndi:BPMNPlane bpmnElement="processid" id="BPMNPlane_processid"></bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

Expected behavior
A clear and concise description of what you expected to happen.

Code

@Test
    void contextLoads() {

        BpmnModel bpmnModel=new BpmnModel();
        ServiceTask serviceTask=new ServiceTask();

        ArrayList<CustomProperty> customProperties = new ArrayList<>();
        CustomProperty customPropertyRole = new CustomProperty();
        customPropertyRole.setName("flowable:test");
        customPropertyRole.setSimpleValue("testSimpleValue");
        customProperties.add(customPropertyRole);
        serviceTask.setCustomProperties(customProperties);
        serviceTask.setId("serviceTask");

        Process process = new Process();
        StartEvent startEvent = new StartEvent();
        startEvent.setId("start");
        startEvent.setName("开始");
        startEvent.setFormKey("11111");

        process.addFlowElement(startEvent);
        SequenceFlow sequenceFlow = new SequenceFlow();
        sequenceFlow.setSourceRef("start");
        sequenceFlow.setTargetRef("serviceTask");
        process.addFlowElement(sequenceFlow);
        process.addFlowElement(serviceTask);


        EndEvent endEvent = new EndEvent();
        endEvent.setId("end");
        endEvent.setName("结束");


        SequenceFlow sequenceFlow2 = new SequenceFlow();
        sequenceFlow2.setSourceRef("serviceTask");
        sequenceFlow2.setTargetRef("end");

        process.addFlowElement(sequenceFlow2);
        process.addFlowElement(endEvent);
        process.setName("process");
        process.setId("processid");
        bpmnModel.addProcess(process);


        BpmnXMLConverter xmlConverter = new BpmnXMLConverter();
        String writer = StrUtil.utf8Str(xmlConverter.convertToXML(bpmnModel));
        System.out.println(writer);



    }

Additional context
Add the version of Flowable that you are using, the database vendor and if you are using Flowable within Spring Boot, the Flowable Task application etc.

flowable:6.8.1

database:mysql-8.0

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

1 participant