activiti5/6 系列之--Activiti 读取并转换BPMN2文件
统一的BPMN标准,对工作流的流程定义采用BPMN统一格式。BPMN流程文件可以使用eclipse bpmn2插件开发比如eclipse bpmn2 modeler或者idea activiti插件。
<?xml version="1.0" encoding="UTF-8"?>
<!-- origin at X=0.0 Y=0.0 -->
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:java="http://www.java.com/javaTypes" xmlns:tns="http://www.jboss.org/drools" xmlns="http://www.jboss.org/drools" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd http://www.jboss.org/drools drools.xsd http://www.bpsim.org/schemas/1.0 bpsim.xsd" id="Definition" exporter="org.eclipse.bpmn2.modeler.core" exporterVersion="1.1.6.Final-v20160330-1631-B1306" expressionLanguage="http://www.mvel.org/2.0" targetNamespace="http://www.jboss.org/drools" typeLanguage="http://www.java.com/javaTypes">
<bpmn2:itemDefinition id="ItemDefinition_1" isCollection="false" structureRef="String"/>
<bpmn2:itemDefinition id="ItemDefinition_2" isCollection="false" structureRef="Integer"/>
<bpmn2:itemDefinition id="ItemDefinition_3" isCollection="false" structureRef="Boolean"/>
<bpmn2:process id="net.hs.cw.bpme.ta.flow_index_mainflow" tns:packageName="net.hs.cw.bpme.ta" name="flow_index_mainflow" isExecutable="true" processType="Private">
<bpmn2:startEvent id="StartEvent_1" name="StartProcess">
<bpmn2:extensionElements>
<tns:metaData name="elementname">
<tns:metaValue><![CDATA[StartProcess]]></tns:metaValue>
</tns:metaData>
</bpmn2:extensionElements>
<bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:userTask id="UserTask_1" name="指数行情导入">
<bpmn2:extensionElements>
<tns:metaData name="elementname">
<tns:metaValue><![CDATA[指数行情导入]]></tns:metaValue>
</tns:metaData>
</bpmn2:extensionElements>
<bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>
<bpmn2:ioSpecification id="InputOutputSpecification_2">
<bpmn2:dataInput id="DataInput_8" itemSubjectRef="ItemDefinition_1" name="TaskName"/>
<bpmn2:dataInput id="DataInput_9" itemSubjectRef="ItemDefinition_2" name="Priority"/>
<bpmn2:dataInput id="DataInput_10" itemSubjectRef="ItemDefinition_1" name="Comment"/>
<bpmn2:dataInput id="DataInput_11" itemSubjectRef="ItemDefinition_1" name="GroupId"/>
<bpmn2:dataInput id="DataInput_12" itemSubjectRef="ItemDefinition_3" name="Skippable"/>
<bpmn2:dataInput id="DataInput_13" itemSubjectRef="ItemDefinition_1" name="Content"/>
<bpmn2:dataInput id="DataInput_14" itemSubjectRef="ItemDefinition_1" name="Locale"/>
<bpmn2:inputSet id="_InputSet_209">
<bpmn2:dataInputRefs>DataInput_8</bpmn2:dataInputRefs>
<bpmn2:dataInputRefs>DataInput_9</bpmn2:dataInputRefs>
<bpmn2:dataInputRefs>DataInput_10</bpmn2:dataInputRefs>
<bpmn2:dataInputRefs>DataInput_11</bpmn2:dataInputRefs>
<bpmn2:dataInputRefs>DataInput_12</bpmn2:dataInputRefs>
<bpmn2:dataInputRefs>DataInput_13</bpmn2:dataInputRefs>
<bpmn2:dataInputRefs>DataInput_14</bpmn2:dataInputRefs>
</bpmn2:inputSet>
<bpmn2:outputSet id="OutputSet_2" name="Output Set"/>
</bpmn2:ioSpecification>
<bpmn2:dataInputAssociation id="DataInputAssociation_8">
<bpmn2:targetRef>DataInput_8</bpmn2:targetRef>
<bpmn2:assignment id="Assignment_8">
<bpmn2:from xsi:type="bpmn2:tFormalExpression" id="FormalExpression_15">ImpIndexFile</bpmn2:from>
<bpmn2:to xsi:type="bpmn2:tFormalExpression" id="FormalExpression_16">DataInput_8</bpmn2:to>
</bpmn2:assignment>
</bpmn2:dataInputAssociation>
<bpmn2:dataInputAssociation id="DataInputAssociation_9">
<bpmn2:targetRef>DataInput_9</bpmn2:targetRef>
<bpmn2:assignment id="Assignment_9">
<bpmn2:from xsi:type="bpmn2:tFormalExpression" id="FormalExpression_17">1</bpmn2:from>
<bpmn2:to xsi:type="bpmn2:tFormalExpression" id="FormalExpression_18">DataInput_9</bpmn2:to>
</bpmn2:assignment>
</bpmn2:dataInputAssociation>
<bpmn2:dataInputAssociation id="DataInputAssociation_10">
<bpmn2:targetRef>DataInput_10</bpmn2:targetRef>
</bpmn2:dataInputAssociation>
<bpmn2:dataInputAssociation id="DataInputAssociation_11">
<bpmn2:targetRef>DataInput_11</bpmn2:targetRef>
</bpmn2:dataInputAssociation>
<bpmn2:dataInputAssociation id="DataInputAssociation_12">
<bpmn2:targetRef>DataInput_12</bpmn2:targetRef>
<bpmn2:assignment id="Assignment_12">
<bpmn2:from xsi:type="bpmn2:tFormalExpression" id="FormalExpression_23">true</bpmn2:from>
<bpmn2:to xsi:type="bpmn2:tFormalExpression" id="FormalExpression_24">DataInput_12</bpmn2:to>
</bpmn2:assignment>
</bpmn2:dataInputAssociation>
<bpmn2:dataInputAssociation id="DataInputAssociation_13">
<bpmn2:targetRef>DataInput_13</bpmn2:targetRef>
<bpmn2:assignment id="Assignment_13">
<bpmn2:from xsi:type="bpmn2:tFormalExpression" id="FormalExpression_25">{"executeMode":"manual"}</bpmn2:from>
<bpmn2:to xsi:type="bpmn2:tFormalExpression" id="FormalExpression_26">DataInput_13</bpmn2:to>
</bpmn2:assignment>
</bpmn2:dataInputAssociation>
<bpmn2:dataInputAssociation id="DataInputAssociation_14">
<bpmn2:targetRef>DataInput_14</bpmn2:targetRef>
<bpmn2:assignment id="Assignment_14">
<bpmn2:from xsi:type="bpmn2:tFormalExpression" id="FormalExpression_27">en-UK</bpmn2:from>
<bpmn2:to xsi:type="bpmn2:tFormalExpression" id="FormalExpression_28">DataInput_14</bpmn2:to>
</bpmn2:assignment>
</bpmn2:dataInputAssociation>
</bpmn2:userTask>
<bpmn2:sequenceFlow id="SequenceFlow_1" tns:priority="1" sourceRef="StartEvent_1" targetRef="UserTask_1"/>
<bpmn2:endEvent id="EndEvent_1" name="End Event 1">
<bpmn2:extensionElements>
<tns:metaData name="elementname">
<tns:metaValue><![CDATA[End Event 1]]></tns:metaValue>
</tns:metaData>
</bpmn2:extensionElements>
<bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>
</bpmn2:endEvent>
<bpmn2:sequenceFlow id="SequenceFlow_2" tns:priority="1" sourceRef="UserTask_1" targetRef="EndEvent_1"/>
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_Process_1" bpmnElement="net.hs.cw.bpme.ta.flow_index_mainflow">
<bpmndi:BPMNShape id="BPMNShape_StartEvent_1" bpmnElement="StartEvent_1">
<dc:Bounds height="36.0" width="36.0" x="377.0" y="30.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_1">
<dc:Bounds height="15.0" width="71.0" x="360.0" y="66.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_UserTask_1" bpmnElement="UserTask_1">
<dc:Bounds height="47.0" width="231.0" x="280.0" y="119.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_2">
<dc:Bounds height="15.0" width="72.0" x="359.0" y="135.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_EndEvent_1" bpmnElement="EndEvent_1">
<dc:Bounds height="36.0" width="36.0" x="377.0" y="217.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_3">
<dc:Bounds height="15.0" width="65.0" x="363.0" y="253.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="BPMNShape_StartEvent_1" targetElement="BPMNShape_UserTask_1">
<di:waypoint xsi:type="dc:Point" x="395.0" y="66.0"/>
<di:waypoint xsi:type="dc:Point" x="395.0" y="85.0"/>
<di:waypoint xsi:type="dc:Point" x="395.0" y="119.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_4"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="BPMNShape_UserTask_1" targetElement="BPMNShape_EndEvent_1">
<di:waypoint xsi:type="dc:Point" x="395.0" y="166.0"/>
<di:waypoint xsi:type="dc:Point" x="395.0" y="191.0"/>
<di:waypoint xsi:type="dc:Point" x="395.0" y="191.0"/>
<di:waypoint xsi:type="dc:Point" x="395.0" y="217.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_5"/>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
如下是对该类型文件的解析工具类和方法。
public void init() throws XMLStreamException, IOException {
for (int i = 0; i < bpmnLocation.length; i++) {
InputStream is = bpmnLocation[i].getInputStream();
byte[] encoded = IOUtils.toByteArray(is);
String bpmnResource = new String(encoded, Charset.forName("UTF-8"));
BpmnXMLConverter converter = new BpmnXMLConverter();
XMLInputFactory factory = XMLInputFactory.newInstance();
@Cleanup XMLStreamReader reader = factory.createXMLStreamReader(bpmnLocation[i].getInputStream());
BpmnModel bpmnModel = converter.convertToBpmnModel(reader);
Process process = bpmnModel.getProcesses().get(0);
ProcessDefinition processDefinition = new ProcessDefinition();
processDefinition.setProcessSource(bpmnResource);
processDefinition.setProcessId(process.getId());
processDefinition.setProcessName(process.getName());
List<FlowElement> flowElementList = (List<FlowElement>) process.getFlowElements();
Map<String,FlowElement> flowElementMap = new HashMap();
for (FlowElement flowElement : flowElementList) {
flowElementMap.put(flowElement.getId(),flowElement);
}
processDefinition.setFlowElementMap(flowElementMap);
ProcessDataUtil.processDefinitionMap.put(process.getId(), processDefinition);
}
}
activiti5/6 系列之--Activiti 读取并转换BPMN2文件的更多相关文章
- activiti5/6 系列之--Activiti与BPMN2.0规范相关节点对应关系
根据BPMN2.0规范的分类划分为以下部分: 1.启动与结束事件(event) 2.顺序流(Sequence Flow) 3.任务(Task) 4.网关(Gateway) 5.子流程(Subproce ...
- mybatis&plus系列------Mysql的JSON字段的读取和转换
mybatis&plus系列------Mysql的JSON字段的读取和转换 一. 背景 在平常的开发中,我们可能会有这样的需求: 业务数据在存储的时候,并不是以mysql中的varchar丶 ...
- .38-浅析webpack源码之读取babel-loader并转换js文件
经过非常非常长无聊的流程,只是将获取到的module信息做了一些缓存,然后生成了loaderContext对象. 这里上个图整理一下这节的流程: 这一节来看webpack是如何将babel-loade ...
- 【ABAP系列】SAP 读取生产订单 记入文档的货物移动明细
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP 读取生产订单 记入文档的 ...
- 使用 PySide2 开发 Maya 插件系列二:继承 uic 转换出来的 py 文件中的类 Ui_Form
使用 PySide2 开发 Maya 插件系列二:继承 uic 转换出来的 py 文件中的类 Ui_Form 开发环境: Wing IDE 6.1 步骤1: 打开 Wing IDE,创建一个新的 pr ...
- lodash用法系列(4),使用Map/Reduce转换
Lodash用来操作对象和集合,比Underscore拥有更多的功能和更好的性能. 官网:https://lodash.com/引用:<script src="//cdnjs.clou ...
- 【HANA系列】SAP HANA行列转换
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[HANA系列]SAP HANA行列转换 前 ...
- 【ABAP系列】SAP ABAP 行列转换的方法
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP 行列转换的方法 ...
- 将一个读取流转换成bitmap对象
将一个读取流转换成bitmap对象: BitmapFactory:可以将文件,读取流,字节数组转换成一个Bitmap对象. Bitmap bitmap = Bitma ...
随机推荐
- css背景图撑开盒子高度
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- I - All X
F(x,m) 代表一个全是由数字x组成的m位数字.请计算,以下式子是否成立: F(x,m) mod k ≡ c Input 第一行一个整数T,表示T组数据. 每组测试数据占一行,包含四个数字x,m,k ...
- vue里的样式添加之行间样式
一:行间样式 :和绑定其他dom的属性一样, v-bind:style= <div v-bind:style={backgroundColor:color}>2</ ...
- python开发 *进程数据隔离.守护进程,进程同步工具 * 180725
进程数据隔离.守护进程,进程同步工具 一.进程之间的数据隔离: from multiprocessing import Process n=100 #主程序中变量n= def func(): glob ...
- gui小计算器的程序写法
import java.awt.BorderLayout; import java.awt.EventQueue; import javax.swing.JFrame; import javax.sw ...
- pytorch入门与实践-2.2-CIFAR10分类网络
1--数据载入 |----流程: DataSet->DataLoader->调用DataLoader |----DataLoader迭代器读不到数据,无报错,一直卡住的显现: DataLo ...
- java_BufferedReader的一个应用
应用来自于我做网页的时候,来读出一个txt文档,由于输出到页面的时候总是没有排版,但是原文件中有换行符,之前是使用的byte数组传输,但是这样无法换行 就使用了BufferedReader,因为它是一 ...
- 【立体几何】分类讨论很细节 Gym - 101967I Путешествие по тору
http://codeforces.com/gym/101967/attachments 题意:定义了一个甜甜圈.(torus) 不是让你二重积分啦233 现在有一个星球是甜甜圈形状的,它有四条很关键 ...
- vimrc同步文档
目录 vimrc ims.vim vimrc if has("syntax") syntax on endif set nocompatible "取消vi 兼容模式 & ...
- C#中的一些基础
值类型与引用类型 值类型包括:[基本数据类型,如int,double,char,bool等][枚举类型enum][结构类型struct] 引用类型包括:[类类型,如基类Object,字符串类Strin ...