• activiti--bpmnmodel


    //实例化BpmnModel对象
    BpmnModel bpmnModel=new BpmnModel();
    //开始节点的属性
    StartEvent startEvent=new StartEvent();
    startEvent.setId("start1shareniu");
    startEvent.setName("start1shareniu");
    //普通的UserTask节点
    UserTask userTask=new UserTask();
    userTask.setId("userTask1shareniu");
    userTask.setName("userTask1shareniu");
    //结束节点属性
    EndEvent endEvent=new EndEvent();
    endEvent.setId("endEventshareniu");
    endEvent.setName("endEventshareniu");
    //连线信息
    List<SequenceFlow> sequenceFlows=new ArrayList<SequenceFlow>();
    List<SequenceFlow> toEnd=new ArrayList<SequenceFlow>();
    SequenceFlow s1=new SequenceFlow();
    s1.setId("starttouserTask");
    s1.setName("starttouserTask");
    s1.setSourceRef("start1shareniu");
    s1.setTargetRef("userTask1shareniu");
    sequenceFlows.add(s1);
    SequenceFlow s2=new SequenceFlow();
    s2.setId("userTasktoend");
    s2.setName("userTasktoend");
    s2.setSourceRef("userTask1shareniu");
    s2.setTargetRef("endEventshareniu");
    toEnd.add(s2);
    startEvent.setOutgoingFlows(sequenceFlows);
    userTask.setOutgoingFlows(toEnd);
    userTask.setIncomingFlows(sequenceFlows);
    endEvent.setIncomingFlows(toEnd);
    //Process对象
    Process process=new Process();
    process.setId("process1");
    process.addFlowElement(startEvent);
    process.addFlowElement(s1);
    process.addFlowElement(userTask);
    process.addFlowElement(s2);
    process.addFlowElement(endEvent);
    bpmnModel.addProcess(process);
    //BpmnModel转化xml
    
    //将上面的对象转化为标准的xml代码如下所示:
    
    //bpmnModel 转换为标准的bpmn xml文件
    
    BpmnXMLConverter bpmnXMLConverter=new BpmnXMLConverter();
    
    byte[] convertToXML = bpmnXMLConverter.convertToXML(bpmnModel);
    
    String bytes=new String(convertToXML);
    
    System.out.println(bytes);
    ProcessValidatorFactory processValidatorFactory=new ProcessValidatorFactory();
    
    ProcessValidator defaultProcessValidator = processValidatorFactory.createDefaultProcessValidator();
    
    //验证失败信息的封装ValidationError
    
    List<ValidationError> validate = defaultProcessValidator.validate(bpmnModel);
    
    System.out.println(validate.size());
    
    //需要说明的是:ValidationError封装的是验证信息,如果size为0说明,bpmnmodel正确,大于0,说明自定义的bpmnmodel是错误的,不可以使用的。
  • 相关阅读:
    Spring5基础
    前端离职工作项目交接清单
    【Elastic2】SpringBoot整合ELK、SpringBoot写ES
    【Elastic1】ELK基本概念、环境搭建、快速开始文档
    文件挂载(四) windows挂载linux文件夹
    mysql锁排查
    文件挂载(二) windows挂载windows文件夹
    Netty源码死磕(ChannelPipeline的执行过程)
    使用 NetCoreBeauty 优化 .NET CORE 独立部署目录结构
    WPF学习笔记(四):AvalonEdit 代码高亮编辑控件专题
  • 原文地址:https://www.cnblogs.com/jentary/p/14005602.html
Copyright © 2020-2023  润新知