- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
请问一下关于在maven依赖activiti-bpmn-layout中使用BpmnAutoLayout类的问题吗?
我使用 activiti-bpmn-model api 以编程方式创建了一个不带 DI 信息的 XML 格式 .bpmn 文件 (bpmnWithoutDI.bpmn)。我想使用 BpmnAutoLayout 类自动为我的 bpmnWithoutDI.bpmn xml 文件生成 DI 信息。但是当我运行我的程序时,我收到以下异常:
谁能告诉我如何解决这个问题吗?
您可以从以下网址下载我的源代码:
https://drive.google.com/file/d/1V9LUZLLZ1c-3JWzcSqDyM7IyywKB7Bvj/view?usp=sharing
它是 Eclipse maven 项目的 zip 文件,其中包含我的 java 源代码和输入文件 bpmnWithoutDI.bpmn 。您只需导入maven项目并运行AutoLayoutDemo.java即可重现该异常。
我还在下面添加了我的代码:
AutoLayoutDemo.java
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import org.activiti.bpmn.BpmnAutoLayout;
import org.activiti.bpmn.converter.BpmnXMLConverter;
import org.activiti.bpmn.model.BpmnModel;
public class AutoLayoutDemo {
private BpmnModel convertXmlFileWithoutDIToBpmnModel(String fileName) throws FileNotFoundException, UnsupportedEncodingException, XMLStreamException {
InputStream xmlStream = new FileInputStream(new File(fileName));
XMLInputFactory xif = XMLInputFactory.newInstance();
InputStreamReader in = new InputStreamReader(xmlStream, "UTF-8");
XMLStreamReader xtr = xif.createXMLStreamReader(in);
return new BpmnXMLConverter().convertToBpmnModel(xtr);
}
private void autoLayoutBpmnModel(BpmnModel model) {
BpmnAutoLayout autoLayout = new BpmnAutoLayout(model);
autoLayout.execute();
}
private void generateXmlFileWithDI(BpmnModel model, String fileName) {
File file = new File(fileName);
try (FileOutputStream fos = new FileOutputStream(file)) {
if (!file.exists()) {
file.createNewFile();
}
byte[] byteArray = new BpmnXMLConverter().convertToXML(model);
fos.write(byteArray);
fos.flush();
fos.close();
System.out.println("Done");
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException, XMLStreamException {
AutoLayoutDemo demo = new AutoLayoutDemo();
BpmnModel model = demo.convertXmlFileWithoutDIToBpmnModel("bpmnWithoutDI.bpmn");
demo.autoLayoutBpmnModel(model);
demo.generateXmlFileWithDI(model, "bpmnWithDI.bpmn");
}
}
bpmnWithoutDI.bpmn
<?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:activiti="http://activiti.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.activiti.org/test">
<process id="process_dispute_extractor" name="dispute_extractor" isExecutable="true">
<subProcess id="process_dispute_extractor-extract_urls" name="STEP extract_urls: This step opens the AVC portal and gathers all the unresolved chargeback urls">
<startEvent id="process_dispute_extractor-extract_urls-start" name="start"></startEvent>
<endEvent id="process_dispute_extractor-extract_urls-end" name="end"></endEvent>
<exclusiveGateway id="process_dispute_extractor-extract_urls-0"></exclusiveGateway>
<subProcess id="process_dispute_extractor-extract_urls-1" name="get the chargeback id">
<startEvent id="process_dispute_extractor-extract_urls-1-0" name="Start"></startEvent>
<exclusiveGateway id="process_dispute_extractor-extract_urls-1-1"></exclusiveGateway>
<exclusiveGateway id="process_dispute_extractor-extract_urls-1-2"></exclusiveGateway>
<serviceTask id="process_dispute_extractor-extract_urls-1-3" name="add to the list of urls to process" activiti:delegateExpression="process_dispute_extractor-extract_urls-1-3implementation"></serviceTask>
<endEvent id="process_dispute_extractor-extract_urls-1-4" name="End"></endEvent>
</subProcess>
<exclusiveGateway id="process_dispute_extractor-extract_urls-2"></exclusiveGateway>
<subProcess id="process_dispute_extractor-extract_urls-3" name="Send 150 urls to image analyzer process module">
<startEvent id="process_dispute_extractor-extract_urls-3-0" name="Start"></startEvent>
<serviceTask id="process_dispute_extractor-extract_urls-3-1" name="JUMP TO image_analyzer" activiti:delegateExpression="process_dispute_extractor-extract_urls-3-1implementation"></serviceTask>
<endEvent id="process_dispute_extractor-extract_urls-3-2" name="End"></endEvent>
</subProcess>
</subProcess>
<sequenceFlow id="process_dispute_extractor-extract_urls-1-1--process_dispute_extractor-extract_urls-1-2" name="Else" sourceRef="process_dispute_extractor-extract_urls-1-1" targetRef="process_dispute_extractor-extract_urls-1-2"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-1-1--process_dispute_extractor-extract_urls-1-3" name="If the id hasn't been processed" sourceRef="process_dispute_extractor-extract_urls-1-1" targetRef="process_dispute_extractor-extract_urls-1-3"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-1-3--process_dispute_extractor-extract_urls-1-2" sourceRef="process_dispute_extractor-extract_urls-1-3" targetRef="process_dispute_extractor-extract_urls-1-2"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-1-0--process_dispute_extractor-extract_urls-1-1" sourceRef="process_dispute_extractor-extract_urls-1-0" targetRef="process_dispute_extractor-extract_urls-1-1"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-1-2--process_dispute_extractor-extract_urls-1-4" sourceRef="process_dispute_extractor-extract_urls-1-2" targetRef="process_dispute_extractor-extract_urls-1-4"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-0--process_dispute_extractor-extract_urls-1" name="For each url" sourceRef="process_dispute_extractor-extract_urls-0" targetRef="process_dispute_extractor-extract_urls-1"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-1--process_dispute_extractor-extract_urls-0" sourceRef="process_dispute_extractor-extract_urls-1" targetRef="process_dispute_extractor-extract_urls-0"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-3-0--process_dispute_extractor-extract_urls-3-1" sourceRef="process_dispute_extractor-extract_urls-3-0" targetRef="process_dispute_extractor-extract_urls-3-1"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-3-1--process_dispute_extractor-extract_urls-3-2" sourceRef="process_dispute_extractor-extract_urls-3-1" targetRef="process_dispute_extractor-extract_urls-3-2"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-2--process_dispute_extractor-extract_urls-3" name="For each time" sourceRef="process_dispute_extractor-extract_urls-2" targetRef="process_dispute_extractor-extract_urls-3"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-3--process_dispute_extractor-extract_urls-2" sourceRef="process_dispute_extractor-extract_urls-3" targetRef="process_dispute_extractor-extract_urls-2"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-0--process_dispute_extractor-extract_urls-2" name="Loop over" sourceRef="process_dispute_extractor-extract_urls-0" targetRef="process_dispute_extractor-extract_urls-2"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-start--process_dispute_extractor-extract_urls-0" sourceRef="process_dispute_extractor-extract_urls-start" targetRef="process_dispute_extractor-extract_urls-0"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-2--process_dispute_extractor-extract_urls-end" sourceRef="process_dispute_extractor-extract_urls-2" targetRef="process_dispute_extractor-extract_urls-end"></sequenceFlow>
<startEvent id="process_dispute_extractor-start" name="Start"></startEvent>
<endEvent id="process_dispute_extractor-end" name="End"></endEvent>
<sequenceFlow id="process_dispute_extractor-start--process_dispute_extractor-extract_urls" sourceRef="process_dispute_extractor-start" targetRef="process_dispute_extractor-extract_urls"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls--process_dispute_extractor-end" sourceRef="process_dispute_extractor-extract_urls" targetRef="process_dispute_extractor-end"></sequenceFlow>
</process>
</definitions>
谢谢!
最佳答案
您正确的bpmn文件如下,我已经更改并测试了它,希望这可以帮助您。
<?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:activiti="http://activiti.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.activiti.org/test">
<process id="process_dispute_extractor" name="dispute_extractor" isExecutable="true">
<subProcess id="process_dispute_extractor-extract_urls" name="STEP extract_urls: This step opens the AVC portal and gathers all the unresolved chargeback urls">
<startEvent id="process_dispute_extractor-extract_urls-start" name="start"></startEvent>
<endEvent id="process_dispute_extractor-extract_urls-end" name="end"></endEvent>
<exclusiveGateway id="process_dispute_extractor-extract_urls-0"></exclusiveGateway>
<subProcess id="process_dispute_extractor-extract_urls-1" name="get the chargeback id">
<startEvent id="process_dispute_extractor-extract_urls-1-0" name="Start"></startEvent>
<exclusiveGateway id="process_dispute_extractor-extract_urls-1-1"></exclusiveGateway>
<exclusiveGateway id="process_dispute_extractor-extract_urls-1-2"></exclusiveGateway>
<serviceTask id="process_dispute_extractor-extract_urls-1-3" name="add to the list of urls to process" activiti:delegateExpression="process_dispute_extractor-extract_urls-1-3implementation"></serviceTask>
<endEvent id="process_dispute_extractor-extract_urls-1-4" name="End"></endEvent>
<sequenceFlow id="xprocess_dispute_extractor-extract_urls-1-2" sourceRef="process_dispute_extractor-extract_urls-1-1" targetRef="process_dispute_extractor-extract_urls-1-2"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-1-1--process_dispute_extractor-extract_urls-1-3" name="If the id hasn't been processed" sourceRef="process_dispute_extractor-extract_urls-1-1" targetRef="process_dispute_extractor-extract_urls-1-3"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-1-3--process_dispute_extractor-extract_urls-1-2" sourceRef="process_dispute_extractor-extract_urls-1-3" targetRef="process_dispute_extractor-extract_urls-1-2"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-1-0--process_dispute_extractor-extract_urls-1-1" sourceRef="process_dispute_extractor-extract_urls-1-0" targetRef="process_dispute_extractor-extract_urls-1-1"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-1-2--process_dispute_extractor-extract_urls-1-4" sourceRef="process_dispute_extractor-extract_urls-1-2" targetRef="process_dispute_extractor-extract_urls-1-4"></sequenceFlow>
</subProcess>
<exclusiveGateway id="process_dispute_extractor-extract_urls-2"></exclusiveGateway>
<sequenceFlow id="process_dispute_extractor-extract_urls-2--process_dispute_extractor-extract_urls-3" name="For each time" sourceRef="process_dispute_extractor-extract_urls-2" targetRef="process_dispute_extractor-extract_urls-3"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-3--process_dispute_extractor-extract_urls-2" sourceRef="process_dispute_extractor-extract_urls-3" targetRef="process_dispute_extractor-extract_urls-2"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-0--process_dispute_extractor-extract_urls-2" name="Loop over" sourceRef="process_dispute_extractor-extract_urls-0" targetRef="process_dispute_extractor-extract_urls-2"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-start--process_dispute_extractor-extract_urls-0" sourceRef="process_dispute_extractor-extract_urls-start" targetRef="process_dispute_extractor-extract_urls-0"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-2--process_dispute_extractor-extract_urls-end" sourceRef="process_dispute_extractor-extract_urls-2" targetRef="process_dispute_extractor-extract_urls-end"></sequenceFlow>
<subProcess id="process_dispute_extractor-extract_urls-3" name="Send 150 urls to image analyzer process module">
<startEvent id="process_dispute_extractor-extract_urls-3-0" name="Start"></startEvent>
<serviceTask id="process_dispute_extractor-extract_urls-3-1" name="JUMP TO image_analyzer" activiti:delegateExpression="process_dispute_extractor-extract_urls-3-1implementation"></serviceTask>
<endEvent id="process_dispute_extractor-extract_urls-3-2" name="End"></endEvent>
<sequenceFlow id="process_dispute_extractor-extract_urls-3-0--process_dispute_extractor-extract_urls-3-1" sourceRef="process_dispute_extractor-extract_urls-3-0" targetRef="process_dispute_extractor-extract_urls-3-1"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-3-1--process_dispute_extractor-extract_urls-3-2" sourceRef="process_dispute_extractor-extract_urls-3-1" targetRef="process_dispute_extractor-extract_urls-3-2"></sequenceFlow>
</subProcess>
<sequenceFlow id="process_dispute_extractor-extract_urls-0--process_dispute_extractor-extract_urls-1" name="For each url" sourceRef="process_dispute_extractor-extract_urls-0" targetRef="process_dispute_extractor-extract_urls-1"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls-1--process_dispute_extractor-extract_urls-0" sourceRef="process_dispute_extractor-extract_urls-1" targetRef="process_dispute_extractor-extract_urls-0"></sequenceFlow>
</subProcess>
<startEvent id="process_dispute_extractor-start" name="Start"></startEvent>
<endEvent id="process_dispute_extractor-end" name="End"></endEvent>
<sequenceFlow id="process_dispute_extractor-start--process_dispute_extractor-extract_urls" sourceRef="process_dispute_extractor-start" targetRef="process_dispute_extractor-extract_urls"></sequenceFlow>
<sequenceFlow id="process_dispute_extractor-extract_urls--process_dispute_extractor-end" sourceRef="process_dispute_extractor-extract_urls" targetRef="process_dispute_extractor-end"></sequenceFlow>
</process>
</definitions>
BPMN 导出的图像:
关于java - 为什么在没有它的情况下使用 org.activiti.bpmn.BpmnAutoLayout 为我的 bpmn 文件生成 DI 信息时会出现 NullPointerException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51825199/
请问一下关于在maven依赖activiti-bpmn-layout中使用BpmnAutoLayout类的问题吗? 我使用 activiti-bpmn-model api 以编程方式创建了一个不带 D
我是一名优秀的程序员,十分优秀!