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:
@@ -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;
|
||||
|
||||
27
spring-statemachine-data/jpa/src/test/resources/data14.json
Normal file
27
spring-statemachine-data/jpa/src/test/resources/data14.json
Normal 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"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user