Add initial action to repository config

- Now RepositoryState can have initial action
  if it is an initial state.
- Implement all needed tests.
- Fixes #281
This commit is contained in:
Janne Valkealahti
2016-11-23 13:55:52 +00:00
parent ea511b8ed8
commit 0c3ea7fb2d
10 changed files with 188 additions and 1 deletions

View File

@@ -26,6 +26,7 @@ import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import org.springframework.statemachine.data.RepositoryAction;
import org.springframework.statemachine.data.RepositoryState;
import org.springframework.statemachine.state.PseudoStateKind;
@@ -53,6 +54,9 @@ public class JpaRepositoryState extends RepositoryState {
private PseudoStateKind kind;
private String submachineId;
@OneToOne(fetch = FetchType.EAGER)
private JpaRepositoryAction initialAction;
@OneToOne(fetch = FetchType.EAGER)
private JpaRepositoryState parentState;
@@ -193,6 +197,15 @@ public class JpaRepositoryState extends RepositoryState {
this.initial = initial;
}
@Override
public RepositoryAction getInitialAction() {
return initialAction;
}
public void setInitialAction(JpaRepositoryAction initialAction) {
this.initialAction = initialAction;
}
@Override
public Set<JpaRepositoryAction> getStateActions() {
return stateActions;

View File

@@ -0,0 +1,27 @@
[
{
"@id": "1",
"_class": "org.springframework.statemachine.data.jpa.JpaRepositoryAction",
"spel": "extendedState.variables.put('foo', 0)"
},
{
"@id": "2",
"_class": "org.springframework.statemachine.data.jpa.JpaRepositoryState",
"initial": true,
"initialAction" : "1",
"state": "S1"
},
{
"@id": "3",
"_class": "org.springframework.statemachine.data.jpa.JpaRepositoryState",
"initial": false,
"state": "S2"
},
{
"_class": "org.springframework.statemachine.data.jpa.JpaRepositoryTransition",
"source": "2",
"target": "3",
"event": "E1",
"kind": "EXTERNAL"
}
]