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));
    }
  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

keep-go-on

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值