• 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;
        }
  • 相关阅读:
    删除:恶意主页
    Winuser.h
    安天磁盘免疫工具研究的初步解答
    C#读写XML文件
    阻止系统关机
    在WebBrowser中屏蔽对话框
    如何用正确的方法写出高质量软件的75条体会
    怪事~
    GRUB4DOS中文自述文档;Grub4dos中文ReadMe
    开始菜单变成的经典样式,XPsuaa样式丢失
  • 原文地址:https://www.cnblogs.com/liuwenjun/p/10312938.html
Copyright © 2020-2023  润新知