From c42dc008cc22a833edf5203c1e1e057bc225eb4d 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 #976 --- .../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 a1aad370..fce7e109 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-2017 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. @@ -199,6 +199,7 @@ public class RepositoryStateMachineModelFactory extends AbstractStateMachineMode for (RepositoryTransition t : transitionRepository.findByMachineId(machineId == null ? "" : machineId)) { Collection> actions = new ArrayList>(); + Collection> originalActions = new ArrayList<>(); Set repositoryActions = t.getActions(); if (repositoryActions != null) { for (RepositoryAction repositoryAction : repositoryActions) { @@ -213,6 +214,7 @@ public class RepositoryStateMachineModelFactory extends AbstractStateMachineMode } if (action != null) { actions.add(action); + originalActions.add(action); } } } @@ -232,12 +234,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()); @@ -245,12 +246,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());