another test state machine

This commit is contained in:
2026-06-28 11:42:18 +02:00
parent 20b4ed780b
commit 16dccbf81b
39 changed files with 889 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
digraph statemachine {
rankdir=LR;
node [shape=rounded, style=filled, fillcolor=white, fontname="Arial"];
edge [fontname="Arial", fontsize=10];
_start [shape=circle, label="", fillcolor=black, width=0.1];
_start -> DRAFT;
APPROVED [fillcolor=lightgray];
DRAFT -> IN_REVIEW [label="DocumentEvent.SUBMIT", style="solid", color="black"];
IN_REVIEW -> APPROVED [label="DocumentEvent.APPROVE", style="solid", color="black"];
IN_REVIEW -> DRAFT [label="DocumentEvent.REJECT", style="solid", color="black"];
}

View File

@@ -0,0 +1,89 @@
{
"metadata" : {
"triggers" : [ ],
"entryPoints" : [ {
"type" : "REST",
"name" : "POST /api/machine/{machineType}/transition/{event}",
"className" : "click.kamil.enterprise.web.StateMachineController",
"methodName" : "transition",
"sourceFile" : "src/main/java/click/kamil/enterprise/web/StateMachineController.java",
"metadata" : {
"path" : "/api/machine/{machineType}/transition/{event}",
"verb" : "POST"
},
"parameters" : [ {
"name" : "machineType",
"type" : "String",
"annotations" : [ "PathVariable" ]
}, {
"name" : "event",
"type" : "String",
"annotations" : [ "PathVariable" ]
}, {
"name" : "userId",
"type" : "String",
"annotations" : [ "RequestParam" ]
} ]
} ],
"callChains" : [ ],
"properties" : {
"default" : { }
}
},
"name" : "click.kamil.enterprise.machines.document.DocumentStateMachineConfiguration",
"renderChoicesAsDiamonds" : true,
"startStates" : [ "DocumentState.DRAFT" ],
"transitions" : [ {
"type" : "EXTERNAL",
"sourceStates" : [ {
"rawName" : "DocumentState.DRAFT",
"fullIdentifier" : "DocumentState.DRAFT"
} ],
"targetStates" : [ {
"rawName" : "DocumentState.IN_REVIEW",
"fullIdentifier" : "DocumentState.IN_REVIEW"
} ],
"event" : {
"rawName" : "DocumentEvent.SUBMIT",
"fullIdentifier" : "DocumentEvent.SUBMIT"
},
"guard" : null,
"actions" : [ ],
"order" : null
}, {
"type" : "EXTERNAL",
"sourceStates" : [ {
"rawName" : "DocumentState.IN_REVIEW",
"fullIdentifier" : "DocumentState.IN_REVIEW"
} ],
"targetStates" : [ {
"rawName" : "DocumentState.APPROVED",
"fullIdentifier" : "DocumentState.APPROVED"
} ],
"event" : {
"rawName" : "DocumentEvent.APPROVE",
"fullIdentifier" : "DocumentEvent.APPROVE"
},
"guard" : null,
"actions" : [ ],
"order" : null
}, {
"type" : "EXTERNAL",
"sourceStates" : [ {
"rawName" : "DocumentState.IN_REVIEW",
"fullIdentifier" : "DocumentState.IN_REVIEW"
} ],
"targetStates" : [ {
"rawName" : "DocumentState.DRAFT",
"fullIdentifier" : "DocumentState.DRAFT"
} ],
"event" : {
"rawName" : "DocumentEvent.REJECT",
"fullIdentifier" : "DocumentEvent.REJECT"
},
"guard" : null,
"actions" : [ ],
"order" : null
} ],
"endStates" : [ "DocumentState.APPROVED" ]
}

View File

@@ -0,0 +1,33 @@
@startuml
!pragma layout smetana
set separator none
hide empty description
hide stereotype
skinparam state {
BackgroundColor white
BorderColor #94a3b8
BorderThickness 1
FontName Inter
FontSize 9
FontStyle bold
RoundCorner 20
Padding 1
}
skinparam shadowing false
skinparam ArrowFontName JetBrains Mono
skinparam ArrowFontSize 8
skinparam ArrowColor #cbd5e1
skinparam ArrowThickness 1
skinparam dpi 110
skinparam svgLinkTarget _self
[*] --> DocumentState.DRAFT
DocumentState.DRAFT -[#1E90FF,bold]-> DocumentState.IN_REVIEW <<external>> : DocumentEvent.SUBMIT
DocumentState.IN_REVIEW -[#1E90FF,bold]-> DocumentState.APPROVED <<external>> : DocumentEvent.APPROVE
DocumentState.IN_REVIEW -[#1E90FF,bold]-> DocumentState.DRAFT <<external>> : DocumentEvent.REJECT
DocumentState.APPROVED --> [*]
@enduml

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initial="DRAFT">
<state id="DRAFT">
<transition target="IN_REVIEW" event="DocumentEvent.SUBMIT"/>
</state>
<state id="IN_REVIEW">
<transition target="APPROVED" event="DocumentEvent.APPROVE"/>
<transition target="DRAFT" event="DocumentEvent.REJECT"/>
</state>
<state id="APPROVED">
</state>
</scxml>