统一的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">{&quot;executeMode&quot;:&quot;manual&quot;}</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文件的更多相关文章

  1. activiti5/6 系列之--Activiti与BPMN2.0规范相关节点对应关系

    根据BPMN2.0规范的分类划分为以下部分: 1.启动与结束事件(event) 2.顺序流(Sequence Flow) 3.任务(Task) 4.网关(Gateway) 5.子流程(Subproce ...

  2. mybatis&plus系列------Mysql的JSON字段的读取和转换

    mybatis&plus系列------Mysql的JSON字段的读取和转换 一. 背景 在平常的开发中,我们可能会有这样的需求: 业务数据在存储的时候,并不是以mysql中的varchar丶 ...

  3. .38-浅析webpack源码之读取babel-loader并转换js文件

    经过非常非常长无聊的流程,只是将获取到的module信息做了一些缓存,然后生成了loaderContext对象. 这里上个图整理一下这节的流程: 这一节来看webpack是如何将babel-loade ...

  4. 【ABAP系列】SAP 读取生产订单 记入文档的货物移动明细

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP 读取生产订单 记入文档的 ...

  5. 使用 PySide2 开发 Maya 插件系列二:继承 uic 转换出来的 py 文件中的类 Ui_Form

    使用 PySide2 开发 Maya 插件系列二:继承 uic 转换出来的 py 文件中的类 Ui_Form 开发环境: Wing IDE 6.1 步骤1: 打开 Wing IDE,创建一个新的 pr ...

  6. lodash用法系列(4),使用Map/Reduce转换

    Lodash用来操作对象和集合,比Underscore拥有更多的功能和更好的性能. 官网:https://lodash.com/引用:<script src="//cdnjs.clou ...

  7. 【HANA系列】SAP HANA行列转换

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[HANA系列]SAP HANA行列转换   前 ...

  8. 【ABAP系列】SAP ABAP 行列转换的方法

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP 行列转换的方法 ...

  9. 将一个读取流转换成bitmap对象

     将一个读取流转换成bitmap对象:         BitmapFactory:可以将文件,读取流,字节数组转换成一个Bitmap对象.         Bitmap bitmap = Bitma ...

随机推荐

  1. Go VSCode配置编译task

    菜单栏Tasks->Configure Tasks { "version": "2.0.0", "tasks": [ { " ...

  2. 【CF613D】Kingdom and its Cities 虚树+树形DP

    [CF613D]Kingdom and its Cities 题意:给你一棵树,每次询问给出k个关键点,问做多干掉多少个非关键点才能使得所有关键点两两不连通. $n,\sum k\le 10^5$ 题 ...

  3. js中级小知识1

    首先我们复习之前的小知识,本期博客与之前有关 js数据类型 基本数据类型:string    undefined         null         boolean          numbe ...

  4. UUID、GUID、SID、SUSID

    1. UUID: (Universally Unique Identifier) 通用唯一标识符, 是一个标识符标准用于软件架构,由开放软件基金会(OSF)作为分布式计算环境(DCE)的一部分而制作的 ...

  5. InnoDB中锁的算法(1)

    Ⅰ.InnoDB锁算法的介绍 首先明确一点,锁锁住的是什么?锁锁住的是索引 Record Lock 单个行记录上的锁 Gap Lock 锁定一个范围,但不包含记录本身 Next-key Lock Ga ...

  6. luogu3830 [SHOI2012]随机树

    传送门:洛谷 题目大意:对于一个只有一个节点的二叉树,一次操作随机将这棵树的叶节点的下方增加两个节点.$n-1$次操作后变为$n$个叶节点的二叉树.求:(1)叶节点平均深度的期望值(2)树深度的数学期 ...

  7. 斑马打印机ZT410中文打印

    ^XA ^CW1, E:SIMSUN.TTF^CI28^FO50,50^A1N,50,50^FD汉字^FS^XZ ******************************************* ...

  8. java框架之SpringBoot(6)-Restful风格的CRUD示例

    准备 环境 IDE:Idea SpringBoot版本:1.5.19 UI:BootStrap 4 模板引擎:thymeleaf 3 效果:Restful 风格 CRUD 功能的 Demo 依赖 &l ...

  9. window.onload和jquery等待加载的区别

    1.区别 window.onload是等待页面所有文档,图片等元素都加载完成再进行操作,是javascript原生语法. jquery是等待页面文档加载完成时,就进行操作. $(function(){ ...

  10. 467A

    #include <stdio.h> int main() { int n; int p, q; int rooms=0; scanf("%d", &n); i ...