Skip to content

Commit c42dc00

Browse files
danieldingzjujvalkeal
authored andcommitted
Fix repository factory choice junction action construction
- add actions to CHOICE & JUNCTION node - Backport #934 - Fixes #976
1 parent 1ec371c commit c42dc00

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-2017 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.
@@ -199,6 +199,7 @@ public StateMachineModel<String, String> build(String machineId) {
199199
for (RepositoryTransition t : transitionRepository.findByMachineId(machineId == null ? "" : machineId)) {
200200

201201
Collection<Action<String, String>> actions = new ArrayList<Action<String, String>>();
202+
Collection<Action<String, String>> originalActions = new ArrayList<>();
202203
Set<? extends RepositoryAction> repositoryActions = t.getActions();
203204
if (repositoryActions != null) {
204205
for (RepositoryAction repositoryAction : repositoryActions) {
@@ -213,6 +214,7 @@ public StateMachineModel<String, String> build(String machineId) {
213214
}
214215
if (action != null) {
215216
actions.add(action);
217+
originalActions.add(action);
216218
}
217219
}
218220
}
@@ -232,25 +234,23 @@ public StateMachineModel<String, String> build(String machineId) {
232234
list = new LinkedList<ChoiceData<String, String>>();
233235
choices.put(t.getSource().getState(), list);
234236
}
235-
guard = resolveGuard(t);
236237
// we want null guards to be at the end
237238
if (guard == null) {
238-
list.addLast(new ChoiceData<String, String>(t.getSource().getState(), t.getTarget().getState(), guard));
239+
list.addLast(new ChoiceData<String, String>(t.getSource().getState(), t.getTarget().getState(), guard, originalActions));
239240
} else {
240-
list.addFirst(new ChoiceData<String, String>(t.getSource().getState(), t.getTarget().getState(), guard));
241+
list.addFirst(new ChoiceData<String, String>(t.getSource().getState(), t.getTarget().getState(), guard, originalActions));
241242
}
242243
} else if (t.getSource().getKind() == PseudoStateKind.JUNCTION) {
243244
LinkedList<JunctionData<String, String>> list = junctions.get(t.getSource().getState());
244245
if (list == null) {
245246
list = new LinkedList<JunctionData<String, String>>();
246247
junctions.put(t.getSource().getState(), list);
247248
}
248-
guard = resolveGuard(t);
249249
// we want null guards to be at the end
250250
if (guard == null) {
251-
list.addLast(new JunctionData<String, String>(t.getSource().getState(), t.getTarget().getState(), guard));
251+
list.addLast(new JunctionData<String, String>(t.getSource().getState(), t.getTarget().getState(), guard, originalActions));
252252
} else {
253-
list.addFirst(new JunctionData<String, String>(t.getSource().getState(), t.getTarget().getState(), guard));
253+
list.addFirst(new JunctionData<String, String>(t.getSource().getState(), t.getTarget().getState(), guard, originalActions));
254254
}
255255
} else if (t.getSource().getKind() == PseudoStateKind.FORK) {
256256
List<String> list = forks.get(t.getSource().getState());

0 commit comments

Comments
 (0)