From caaf5ecc43ddf47ccd6ea6652e279956a946e7af Mon Sep 17 00:00:00 2001 From: daniel ding Date: Sat, 26 Jun 2021 23:04:53 +0800 Subject: [PATCH] Fix repository factory choice junction action construction - add actions to CHOICE & JUNCTION node - Backport #934 - Fixes #977 --- .../data/RepositoryStateMachineModelFactory.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spring-statemachine-data/src/main/java/org/springframework/statemachine/data/RepositoryStateMachineModelFactory.java b/spring-statemachine-data/src/main/java/org/springframework/statemachine/data/RepositoryStateMachineModelFactory.java index a9b5f4f7..c7f5a8c9 100644 --- a/spring-statemachine-data/src/main/java/org/springframework/statemachine/data/RepositoryStateMachineModelFactory.java +++ b/spring-statemachine-data/src/main/java/org/springframework/statemachine/data/RepositoryStateMachineModelFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 the original author or authors. + * Copyright 2016-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -156,6 +156,7 @@ public class RepositoryStateMachineModelFactory extends AbstractStateMachineMode for (RepositoryTransition t : transitionRepository.findByMachineId(machineId == null ? "" : machineId)) { Collection, Mono>> actions = new ArrayList<>(); + Collection> originalActions = new ArrayList<>(); Set repositoryActions = t.getActions(); if (repositoryActions != null) { for (RepositoryAction repositoryAction : repositoryActions) { @@ -170,6 +171,7 @@ public class RepositoryStateMachineModelFactory extends AbstractStateMachineMode } if (action != null) { actions.add(Actions.from(action)); + originalActions.add(action); } } } @@ -190,12 +192,11 @@ public class RepositoryStateMachineModelFactory extends AbstractStateMachineMode list = new LinkedList>(); choices.put(t.getSource().getState(), list); } - guard = resolveGuard(t); // we want null guards to be at the end if (guard == null) { - list.addLast(new ChoiceData(t.getSource().getState(), t.getTarget().getState(), guard)); + list.addLast(new ChoiceData(t.getSource().getState(), t.getTarget().getState(), guard, originalActions)); } else { - list.addFirst(new ChoiceData(t.getSource().getState(), t.getTarget().getState(), guard)); + list.addFirst(new ChoiceData(t.getSource().getState(), t.getTarget().getState(), guard, originalActions)); } } else if (t.getSource().getKind() == PseudoStateKind.JUNCTION) { LinkedList> list = junctions.get(t.getSource().getState()); @@ -203,12 +204,11 @@ public class RepositoryStateMachineModelFactory extends AbstractStateMachineMode list = new LinkedList>(); junctions.put(t.getSource().getState(), list); } - guard = resolveGuard(t); // we want null guards to be at the end if (guard == null) { - list.addLast(new JunctionData(t.getSource().getState(), t.getTarget().getState(), guard)); + list.addLast(new JunctionData(t.getSource().getState(), t.getTarget().getState(), guard, originalActions)); } else { - list.addFirst(new JunctionData(t.getSource().getState(), t.getTarget().getState(), guard)); + list.addFirst(new JunctionData(t.getSource().getState(), t.getTarget().getState(), guard, originalActions)); } } else if (t.getSource().getKind() == PseudoStateKind.FORK) { List list = forks.get(t.getSource().getState());