-
Notifications
You must be signed in to change notification settings - Fork 0
/
states.cljc
191 lines (172 loc) · 7.37 KB
/
states.cljc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
(ns lupapiste-commons.states)
(def
^{:doc "Possible state transitions for applications.
Key is the starting state, first in the value vector is the default next state and
the rest are other possible next states."}
default-application-state-graph
{:draft [:open :submitted :canceled]
:open [:submitted :canceled]
:submitted [:sent :draft :verdictGiven :canceled]
:sent [:verdictGiven :complementNeeded :canceled]
:complementNeeded [:sent :verdictGiven :canceled]
:verdictGiven [:constructionStarted :appealed :closed :extinct :canceled]
:constructionStarted [:closed :extinct]
:closed []
:canceled []
:extinct [] ; Rauennut
:appealed [:verdictGiven :canceled]
})
(def
^{:doc "Possible state transitions for inforequests.
Key is the starting state, first in the value vector is the default next state and
the rest are other possible next states."}
default-inforequest-state-graph
(array-map
:info [:answered :canceled]
:answered [:info]
:canceled []))
(def
^{:doc "See default-application-state-graph"}
tj-ilmoitus-state-graph
(merge
(select-keys default-application-state-graph [:draft :open :canceled])
{:submitted [:acknowledged :draft :canceled]
; must be for tj-hakemus-state-graph compatibility:
; if foreman application is in complementNeeded state it can be converted
; to use this state graph
:complementNeeded [:acknowledged :canceled]
:acknowledged [:complementNeeded]}))
(def
^{:doc "See default-application-state-graph"}
tj-hakemus-state-graph
(merge
(select-keys default-application-state-graph [:draft :open :canceled])
{:submitted [:sent :draft :canceled]
:sent [:foremanVerdictGiven :complementNeeded :canceled]
:complementNeeded [:sent :canceled]
:foremanVerdictGiven [:canceled :appealed]
:appealed [:foremanVerdictGiven :canceled]}))
(def
^{:doc "See default-application-state-graph"}
tonttijako-application-state-graph
(merge
(select-keys default-application-state-graph [:draft :open :canceled])
{:submitted [:hearing :draft :canceled]
:hearing [:proposal :canceled]
:proposal [:proposalApproved :canceled]
:proposalApproved [:final :appealed :canceled]
:appealed [:final :canceled] ; Oikaisuvaatimus
:final [] ; Lain voimainen
}))
(def ya-tyolupa-state-graph default-application-state-graph)
(def
^{:doc "Possible state transitions for YA käyttölupa applications."}
ya-kayttolupa-state-graph
(merge
(select-keys default-application-state-graph
[:draft :open :submitted :sent
:complementNeeded :extinct :canceled])
{:verdictGiven [:finished :appealed :extinct :canceled :verdictGiven]
:finished []
:appealed [:verdictGiven]}))
(def ya-sijoittaminen-shared-states ; Shared states for sijoittaminen
{:draft [:open :submitted :canceled]
:open [:submitted :canceled]
:complementNeeded [:sent :canceled]
:canceled []})
(def
^{:doc "Possible state transitions for YA sijoituslupa subtype."}
ya-sijoituslupa-state-graph
(merge ya-sijoittaminen-shared-states
{:submitted [:sent :draft :canceled :verdictGiven]
:sent [:verdictGiven :complementNeeded :canceled]
:verdictGiven [:finished :appealed :extinct :verdictGiven]
:appealed [:verdictGiven]
:finished []
:extinct []}))
(def
^{:doc "Possible state transitions for YA sijoitussopimus subtype."}
ya-sijoitussopimus-state-graph
(merge ya-sijoittaminen-shared-states
;;Transition from submitted to AgreementSigned is allowed because sometimes decisions are made outside of ALLU
;;process. In these cases the agreementPrepared state needs to be skipped.
{:submitted [:sent :draft :canceled :agreementPrepared :agreementSigned]
:sent [:agreementPrepared :complementNeeded :canceled]
:agreementPrepared [:agreementSigned :canceled :agreementPrepared]
:agreementSigned []}))
(def
^{:doc "Possible state transitions for YA jatkoaika applications."}
ya-jatkoaika-state-graph
{:draft [:open :submitted :canceled]
:open [:submitted :canceled]
:submitted [:sent :draft :canceled]
:sent [:finished :complementNeeded :canceled]
:complementNeeded [:sent :finished :canceled]
:finished [:appealed :extinct :canceled]
:appealed [:finished :canceled]
:canceled []
:extinct [] ; Rauennut
})
(def
^{:doc "State transitions for archiving / digitizing projects (ARK)"}
ark-state-graph
{:open [:underReview :archived :canceled]
:underReview [:archived :open :canceled]
:archived []
:canceled []})
(def
^{:doc "Possible state transitions for Allu operations."}
allu-state-graph
{:draft [:open :submitted :canceled]
:open [:submitted :canceled]
:submitted [:sent :draft :canceled]
:sent [:verdictGiven :complementNeeded :canceled]
:complementNeeded [:sent :canceled]
:verdictGiven [:canceled]
:canceled []})
(def
^{:doc "Possible state transitions for R jatkoaika operations."}
r-jatkoaika-state-graph
(merge
(select-keys default-application-state-graph
[:draft :open :submitted :extinct :canceled])
{:sent [:ready :complementNeeded :canceled]
:complementNeeded [:sent :ready :canceled]
:ready [:appealed :extinct :canceled]
:appealed [:ready :canceled]}))
(def
^{:doc "Possible state transitions for muutoslupa operations."}
r-muutoslupa-state-graph
r-jatkoaika-state-graph)
(def full-ya-application-state-graph
(merge-with (comp vec distinct concat)
ya-jatkoaika-state-graph
ya-kayttolupa-state-graph
ya-sijoituslupa-state-graph
ya-sijoitussopimus-state-graph
ya-tyolupa-state-graph))
(def
^{:doc "All states for (currently R and P) applications.
Includes new states from KRYSP reader, which currently can't be reached via UI."}
full-application-state-graph
(-> default-application-state-graph
(assoc
:verdictGiven [:constructionStarted :inUse :onHold :appealed :closed :extinct :canceled]
:constructionStarted [:inUse :onHold :closed :extinct]
:inUse [:closed :onHold :extinct]
:onHold [:closed :constructionStarted :inUse :extinct])))
(def all-transitions-graph
(merge-with (comp vec distinct concat)
full-application-state-graph
full-ya-application-state-graph
tj-ilmoitus-state-graph
tj-hakemus-state-graph
tonttijako-application-state-graph
default-inforequest-state-graph
allu-state-graph))
(def r-and-tj-transitions
(merge-with (comp vec distinct concat)
full-application-state-graph
default-inforequest-state-graph
tj-ilmoitus-state-graph
tj-hakemus-state-graph))