zoukankan      html  css  js  c++  java
  • flowable 获取自定义属性值

    背景

    我们在做flowable开发的时候难免会做一些自定义属性,如何去获取他们的值呢?

    我是一个有代码洁癖的人,如果哪里有写的不好的地方,请多多指教。

    代码

    1: 获取节点对象

    public FlowElement getFlowElementByActivityIdAndProcessDefinitionId(String activityId, String processDefinitionId) {
            BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
            List<Process> processes = bpmnModel.getProcesses();
            if (CollectionUtils.isNotEmpty(processes)) {
                for(Process process : processes) {
                    FlowElement flowElement = process.getFlowElement(activityId);
                    if (flowElement != null){
                        return flowElement;
                    }
                }
            }
            return null;
        }

    2:获取节点的自定义属性

    /**
         * 获取自定义属性值
         *
         * @param activityId          节点id
         * @param processDefinitionId 流程定义id
         * @param customPropertyName  属性名
         * @return
         */
        public List<ExtensionElement> getCustomProperty(String activityId, String processDefinitionId, String customPropertyName) {
            FlowElement flowElement = this.getFlowElementByActivityIdAndProcessDefinitionId(activityId,processDefinitionId);
            if (flowElement != null && flowElement instanceof UserTask) {
                UserTask userTask = (UserTask) flowElement;
                Map<String, List<ExtensionElement>> extensionElements = userTask.getExtensionElements();
                if (MapUtils.isNotEmpty(extensionElements)) {
                    List<ExtensionElement> values = extensionElements.get(customPropertyName);
                    if (CollectionUtils.isNotEmpty(values)) {
                        return values;
                    }
                }
            }
            return null;
        }
  • 相关阅读:
    sql获取当天零点
    byte[]和InputStream的相互转换
    ResultSet获取记录条数
    Java:String和Date、Timestamp之间的转换
    查询表中blob字段的大小
    Oracle中start with...connect by子句的用法
    oracle创建序列,并插入记录
    关于使用JSONArray.fromObject()方法和引入net.sf.json包所需要的jar包支持
    css来控制img正方形自适应
    上下固定中间自适应
  • 原文地址:https://www.cnblogs.com/liuwenjun/p/10312938.html
Copyright © 2011-2022 走看看