统一的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. nuxt跨域

    根据nuxt官方文档提供的axios module 安装: npm install @nuxtjs/axios @nuxtjs/proxy --save nuxt.config.js modules: ...

  2. git clean(转载)

    git clean命令用来从你的工作目录中删除所有没有tracked过的文件. git clean经常和git reset --hard一起结合使用. 记住reset只影响被track过的文件, 所以 ...

  3. react+dva+antd项目构建

    一:版本升级 首先说明一下这里的dva是最新版: 2.3.2 1.初始化项目构建 npm install dva-cli -g dva -v dva-cli version 注:通过 npm 安装 d ...

  4. css小知识 2

    效果为 为什么还出现出现不同的效果? 浏览器在解析第二个p的时候,因为第二个字母见没有空格,它会认为这是一个单词没有写完,所以不会换行 列表 1.无序列表ul 第二,内部必须有子代标签<li&g ...

  5. 实战一个职业技术学校。 by:hack某某

    这是我们的目标,某一技术学院,这是一个注入点 上sqlmap 跑出了管理账号密码 扫后台 没有找到,注入就相当鸡肋了 换换其他思路 dba权限,想到了直接写入 找找路径之类的 找到了,运气相当的好 直 ...

  6. awt多线程聊天

    public class ChatServer { boolean started = false; ServerSocket serverSocket = null; public void sta ...

  7. Oracle对于敏感数据的处理,可以采用策略(dbms_rls.add_policy)

    Oracle Policy的简单说明: Policy应用于数据行访问权限控制时,其作用简而言之,就是在查询数据表时,自动在查询结果上加上一个Where子句.假如该查询已有where子句,则在该Wher ...

  8. Java项目引用外部jar包时,使用bat启动

    1.将项目导出为jar包 1)点击项目—>右击—>点击Export—>进入export页面 2)点击JAR file——>Next——>勾选项目——>选择jar包存 ...

  9. RoR - Advanced Querying

    Seeding the Database: db/seed.rb 可以提供预设data rake db:seed #seeds.rb Person.create! [ {first_name : &q ...

  10. java框架之SpringBoot(8)-嵌入式Servlet容器

    前言 SpringBoot 默认使用的嵌入式 Servlet 容器为 Tomcat,通过依赖关系就可以看到: 问题: 如何定制和修改 Servlet 容器相关配置? SpringBoot 能否支持其它 ...