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;
        }
  • 相关阅读:
    Live2d Test Env
    Live2d Test Env
    Spring Boot GraphQL 实战 02_增删改查和自定义标量
    Spring Boot GraphQL 实战 01_快速入门
    【MacBook】 SSH使用
    一个神奇的没有springboot注释的api文档生成器---JApiDocs
    Spring Cloud Alibaba 06:Gateway服务网关
    leetcode-300. 最长递增子序列
    leetcode-309. 最佳买卖股票时机含冷冻期
    leetcode-121. 买卖股票的最佳时机
  • 原文地址:https://www.cnblogs.com/liuwenjun/p/10312938.html
Copyright © 2011-2022 走看看