Skip to content

Commit c930c54

Browse files
Fix repository factory choice junction action construction
- add actions to CHOICE & JUNCTION node - Fixes #934
1 parent acb6f1d commit c930c54

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

spring-statemachine-data/src/main/java/org/springframework/statemachine/data/RepositoryStateMachineModelFactory.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2020 the original author or authors.
2+
* Copyright 2016-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -156,6 +156,7 @@ public StateMachineModel<String, String> build(String machineId) {
156156
for (RepositoryTransition t : transitionRepository.findByMachineId(machineId == null ? "" : machineId)) {
157157

158158
Collection<Function<StateContext<String, String>, Mono<Void>>> actions = new ArrayList<>();
159+
Collection<Action<String, String>> originalActions = new ArrayList<>();
159160
Set<? extends RepositoryAction> repositoryActions = t.getActions();
160161
if (repositoryActions != null) {
161162
for (RepositoryAction repositoryAction : repositoryActions) {
@@ -170,6 +171,7 @@ public StateMachineModel<String, String> build(String machineId) {
170171
}
171172
if (action != null) {
172173
actions.add(Actions.from(action));
174+
originalActions.add(action);
173175
}
174176
}
175177
}
@@ -190,25 +192,23 @@ public StateMachineModel<String, String> build(String machineId) {
190192
list = new LinkedList<ChoiceData<String, String>>();
191193
choices.put(t.getSource().getState(), list);
192194
}
193-
guard = resolveGuard(t);
194195
// we want null guards to be at the end
195196
if (guard == null) {
196-
list.addLast(new ChoiceData<String, String>(t.getSource().getState(), t.getTarget().getState(), guard));
197+
list.addLast(new ChoiceData<String, String>(t.getSource().getState(), t.getTarget().getState(), guard, originalActions));
197198
} else {
198-
list.addFirst(new ChoiceData<String, String>(t.getSource().getState(), t.getTarget().getState(), guard));
199+
list.addFirst(new ChoiceData<String, String>(t.getSource().getState(), t.getTarget().getState(), guard, originalActions));
199200
}
200201
} else if (t.getSource().getKind() == PseudoStateKind.JUNCTION) {
201202
LinkedList<JunctionData<String, String>> list = junctions.get(t.getSource().getState());
202203
if (list == null) {
203204
list = new LinkedList<JunctionData<String, String>>();
204205
junctions.put(t.getSource().getState(), list);
205206
}
206-
guard = resolveGuard(t);
207207
// we want null guards to be at the end
208208
if (guard == null) {
209-
list.addLast(new JunctionData<String, String>(t.getSource().getState(), t.getTarget().getState(), guard));
209+
list.addLast(new JunctionData<String, String>(t.getSource().getState(), t.getTarget().getState(), guard, originalActions));
210210
} else {
211-
list.addFirst(new JunctionData<String, String>(t.getSource().getState(), t.getTarget().getState(), guard));
211+
list.addFirst(new JunctionData<String, String>(t.getSource().getState(), t.getTarget().getState(), guard, originalActions));
212212
}
213213
} else if (t.getSource().getKind() == PseudoStateKind.FORK) {
214214
List<String> list = forks.get(t.getSource().getState());

0 commit comments

Comments
 (0)