activiti踩坑2-camunda-modeler设计器与activiti7不兼容

Posted keep-go-on

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了activiti踩坑2-camunda-modeler设计器与activiti7不兼容相关的知识,希望对你有一定的参考价值。

camunda-modeler设计的BPMN参数无效

    <bpmn:userTask id="issue_contract_task" name="发起合同" camunda:candidateUsers="$signs">
      <bpmn:extensionElements>
        <camunda:properties>
          <camunda:property name="companyId" value="$companyId" />
        </camunda:properties>
      </bpmn:extensionElements>
      <bpmn:incoming>SequenceFlow_1nclnae</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_13n4ysw</bpmn:outgoing>
    </bpmn:userTask>

设计的 $signs$companyId参数不生效。

解决方案

  • 第一步:camunda: 替换为 activiti:
  • 第二步:添加activiti的头定义 :
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xmlns:activiti="http://activiti.org/bpmn" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_03io3g1"
                  targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.9.0"
                  modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.15.0">

使用代码解决 :

    @Test
    @Order(1)
    public void testDeployFormBPMNModel() throws UnsupportedEncodingException, XMLStreamException 
        File bpmnFile = new File("D:\\\\tools\\\\idea\\\\bpmn\\\\contract.flowlean.bpmn");
        Document xmlDoc = XmlUtil.readXML(bpmnFile);
        Element rootElement = XmlUtil.getRootElement(xmlDoc);
        rootElement.setAttribute("xmlns:activiti","http://activiti.org/bpmn");
        rootElement.setAttribute("xmlns:modeler","http://camunda.org/schema/modeler/1.0");
        rootElement.setAttribute("modeler:executionPlatform","Camunda Platform");
        rootElement.setAttribute("modeler:executionPlatformVersion","7.15.0");
        String xmlFileStr = XmlUtil.toStr(xmlDoc);
        xmlFileStr = xmlFileStr.replace("camunda:","activiti:");


        InputStream bpmnStream = new ByteArrayInputStream(xmlFileStr.getBytes());
        XMLInputFactory xif = XMLInputFactory.newInstance();
        InputStreamReader in = new InputStreamReader(bpmnStream, "UTF-8");
        XMLStreamReader xtr = xif.createXMLStreamReader(in);
        BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);

        RepositoryService repositoryService = processEngine.getRepositoryService();
        Deployment deployment = repositoryService.createDeployment()
                .name("测试合同审批流程_"+ RandomUtil.randomString(5))
                .addBpmnModel("合同审签_model.bpmn",bpmnModel)
                .key("contract_sign_flow_by_model_"+RandomUtil.randomString(5))
                .tenantId("T_"+System.currentTimeMillis())
                .deploy();
        log.info("流程部署ID :  ,流程部署名称 :  ,部署Key :  ",deployment.getId(),deployment.getName(),deployment.getKey());
        log.info("流程部署 ", JSON.toJSONString(deployment));
    

以上是关于activiti踩坑2-camunda-modeler设计器与activiti7不兼容的主要内容,如果未能解决你的问题,请参考以下文章

activiti踩坑2-camunda-modeler设计器与activiti7不兼容

避免踩坑,内存不足时系统回收Activity的流程解析

踩坑日记: springcloud多环境Maven配置报错 active: @profileActive@

activiti7踩坑1-通过BpmnModel部署时流程act_re_procdef表中无数据

activiti7踩坑1-通过BpmnModel部署时流程act_re_procdef表中无数据

activiti7踩坑1-通过BpmnModel部署时流程act_re_procdef表中无数据