统一的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. pdf转html插件~~~pdf2htmlEX安装,配置及使用

    这是一个将pdf转化为html的服务,开源的. 此功能服务的代码在git上的地址为: https://github.com/coolwanglu/pdf2htmlEX/wiki 安装: 在ubuntu ...

  2. sshfs远程挂载

    一.什么是 SSHFSSSHFS(Secure SHell FileSystem)是一个客户端,可以让我们通过 SSH 文件传输协议(SFTP)挂载远程的文件系统并且在本地机器上和远程的目录和文件进行 ...

  3. bug制造者又上线了

    上一家公司,领导经常这样表扬一位同事,“你写的bug远比你的功能值钱...” 今天特么的突然觉得我好像也有这样的功能,不知道是上次回家把脑子落家里了还是,前几天淋雨脑子进了水了. 呢么简单一个功能,愣 ...

  4. GCD与LCM

    求最大公约数(GCD)和求最小公倍数(LCM): 首先是求最大公约数,我们可以利用辗转相除法来求 1 int gcd(int a,int b) 2 { 3 if(b==0) 4 return a; 5 ...

  5. Ubuntu常用操作命令

    解压文件: tar -zxvf 文件名 -C 指定目录 从当前环境进入root环境: su,然后输入root密码

  6. Codeforces 670 - A/B/C/D/E/F - (Done)

    链接:https://codeforces.com/contest/670 A - Holidays - [水] AC代码: #include<bits/stdc++.h> using n ...

  7. spark streaming集成kafka

    Kakfa起初是由LinkedIn公司开发的一个分布式的消息系统,后成为Apache的一部分,它使用Scala编写,以可水平扩展和高吞吐率而被广泛使用.目前越来越多的开源分布式处理系统如Clouder ...

  8. Python解析Linux命令行

    写了个python脚本在linux需要传入参数使用,python参数传入有几个方法, 先用了Python中命令行参数的最传统的方法sys.argv linux cmd ~& python ma ...

  9. from appium import webdriver 使用python爬虫,批量爬取抖音app视频(requests+Fiddler+appium)

    使用python爬虫,批量爬取抖音app视频(requests+Fiddler+appium) - 北平吴彦祖 - 博客园 https://www.cnblogs.com/stevenshushu/p ...

  10. 表驱动方法(Table-Driven Methods)

    表驱动方法(Table-Driven Methods) - winner_0715 - 博客园 https://www.cnblogs.com/winner-0715/p/9382048.html W ...