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:
@@ -20,6 +20,7 @@ import java.util.Set;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.Reference;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
import org.springframework.statemachine.data.RepositoryAction;
|
||||
import org.springframework.statemachine.data.RepositoryState;
|
||||
import org.springframework.statemachine.state.PseudoStateKind;
|
||||
|
||||
@@ -49,6 +50,9 @@ public class MongoDbRepositoryState extends RepositoryState {
|
||||
@Reference
|
||||
private MongoDbRepositoryState parentState;
|
||||
|
||||
@Reference
|
||||
private MongoDbRepositoryAction initialAction;
|
||||
|
||||
@Reference
|
||||
private Set<MongoDbRepositoryAction> stateActions;
|
||||
|
||||
@@ -184,6 +188,15 @@ public class MongoDbRepositoryState extends RepositoryState {
|
||||
this.initial = initial;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryAction getInitialAction() {
|
||||
return initialAction;
|
||||
}
|
||||
|
||||
public void setInitialAction(MongoDbRepositoryAction initialAction) {
|
||||
this.initialAction = initialAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<MongoDbRepositoryAction> getStateActions() {
|
||||
return stateActions;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
[
|
||||
{
|
||||
"@id": "1",
|
||||
"_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryAction",
|
||||
"spel": "extendedState.variables.put('foo', 0)"
|
||||
},
|
||||
{
|
||||
"@id": "2",
|
||||
"_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryState",
|
||||
"initial": true,
|
||||
"initialAction" : "1",
|
||||
"state": "S1"
|
||||
},
|
||||
{
|
||||
"@id": "3",
|
||||
"_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryState",
|
||||
"initial": false,
|
||||
"state": "S2"
|
||||
},
|
||||
{
|
||||
"_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryTransition",
|
||||
"source": "2",
|
||||
"target": "3",
|
||||
"event": "E1",
|
||||
"kind": "EXTERNAL"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user