From 86f702db3e90aa0c57242ccba5f38965b9d7b70b Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Fri, 3 Jan 2025 12:37:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8A=E4=B8=8B=E6=96=87?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E6=B2=A1=E6=9C=89=E6=AD=A3=E5=B8=B8=E4=BC=A0?= =?UTF-8?q?=E9=80=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flowable/core/helper/MapHelper.java | 16 ++++++++++++++++ .../flowable/core/manager/FlowableManager.java | 1 + 2 files changed, 17 insertions(+) diff --git a/flowable-core/src/main/java/com/lanyuanxiaoyao/flowable/core/helper/MapHelper.java b/flowable-core/src/main/java/com/lanyuanxiaoyao/flowable/core/helper/MapHelper.java index d4c942c..35f8561 100644 --- a/flowable-core/src/main/java/com/lanyuanxiaoyao/flowable/core/helper/MapHelper.java +++ b/flowable-core/src/main/java/com/lanyuanxiaoyao/flowable/core/helper/MapHelper.java @@ -2,6 +2,7 @@ package com.lanyuanxiaoyao.flowable.core.helper; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import lombok.NoArgsConstructor; /** @@ -27,4 +28,19 @@ public class MapHelper { public static Map empty() { return new HashMap<>(0); } + + public static boolean isEmpty(Map map) { + return Objects.isNull(map) || map.isEmpty(); + } + + @SafeVarargs + public static Map concat(Map... maps) { + Map result = new HashMap<>(); + for (Map map : maps) { + if (Objects.nonNull(map)) { + result.putAll(map); + } + } + return result; + } } diff --git a/flowable-core/src/main/java/com/lanyuanxiaoyao/flowable/core/manager/FlowableManager.java b/flowable-core/src/main/java/com/lanyuanxiaoyao/flowable/core/manager/FlowableManager.java index f37a915..0699fb0 100644 --- a/flowable-core/src/main/java/com/lanyuanxiaoyao/flowable/core/manager/FlowableManager.java +++ b/flowable-core/src/main/java/com/lanyuanxiaoyao/flowable/core/manager/FlowableManager.java @@ -107,6 +107,7 @@ public abstract class FlowableManager { private void manualAction(String instanceId, FlowableAction action, String comment, Map metadata) { FlowableInstance instance = repository.getInstance(instanceId); FlowableNode node = repository.getNode(instance.getCurrentNodeId()); + metadata = MapHelper.isEmpty(metadata) ? instance.getMetadata() : MapHelper.concat(metadata, instance.getMetadata()); action(instance, node, action, comment, metadata); }