@@ -134,28 +134,13 @@ func (h ApplicationHandler) Get(ctx *gin.Context) {
134
134
return
135
135
}
136
136
resolver := assessment .NewApplicationResolver (m , tagsResolver , membership , questionnaire )
137
- archetypes , err := resolver .Archetypes ()
138
- if err != nil {
139
- _ = ctx .Error (err )
140
- return
141
- }
142
- archetypeTags , err := resolver .ArchetypeTags ()
143
- if err != nil {
144
- _ = ctx .Error (err )
145
- return
146
- }
147
-
148
137
r := Application {}
149
138
r .With (m , tags )
150
- r .WithArchetypes (archetypes )
151
- r .WithVirtualTags (archetypeTags , SourceArchetype )
152
- r .WithVirtualTags (resolver .AssessmentTags (), SourceAssessment )
153
- r .Assessed , err = resolver .Assessed ()
139
+ err = r .WithResolver (resolver )
154
140
if err != nil {
155
141
_ = ctx .Error (err )
156
142
return
157
143
}
158
-
159
144
h .Respond (ctx , http .StatusOK , r )
160
145
}
161
146
@@ -198,22 +183,9 @@ func (h ApplicationHandler) List(ctx *gin.Context) {
198
183
return
199
184
}
200
185
resolver := assessment .NewApplicationResolver (& list [i ], tagsResolver , membership , questionnaire )
201
- archetypes , aErr := resolver .Archetypes ()
202
- if aErr != nil {
203
- _ = ctx .Error (aErr )
204
- return
205
- }
206
- archetypeTags , aErr := resolver .ArchetypeTags ()
207
- if aErr != nil {
208
- _ = ctx .Error (aErr )
209
- return
210
- }
211
186
r := Application {}
212
187
r .With (& list [i ], tags )
213
- r .WithArchetypes (archetypes )
214
- r .WithVirtualTags (archetypeTags , SourceArchetype )
215
- r .WithVirtualTags (resolver .AssessmentTags (), SourceAssessment )
216
- r .Assessed , err = resolver .Assessed ()
188
+ err = r .WithResolver (resolver )
217
189
if err != nil {
218
190
_ = ctx .Error (err )
219
191
return
@@ -274,27 +246,12 @@ func (h ApplicationHandler) Create(ctx *gin.Context) {
274
246
return
275
247
}
276
248
resolver := assessment .NewApplicationResolver (m , tagsResolver , membership , questionnaire )
277
- archetypes , err := resolver .Archetypes ()
278
- if err != nil {
279
- _ = ctx .Error (err )
280
- return
281
- }
282
- archetypeTags , err := resolver .ArchetypeTags ()
283
- if err != nil {
284
- _ = ctx .Error (err )
285
- return
286
- }
287
-
288
249
r .With (m , tags )
289
- r .WithArchetypes (archetypes )
290
- r .WithVirtualTags (archetypeTags , SourceArchetype )
291
- r .WithVirtualTags (resolver .AssessmentTags (), SourceArchetype )
292
- r .Assessed , err = resolver .Assessed ()
250
+ err = r .WithResolver (resolver )
293
251
if err != nil {
294
252
_ = ctx .Error (err )
295
253
return
296
254
}
297
-
298
255
h .Respond (ctx , http .StatusCreated , r )
299
256
}
300
257
@@ -1018,12 +975,12 @@ func (h ApplicationHandler) AssessmentList(ctx *gin.Context) {
1018
975
_ = ctx .Error (err )
1019
976
return
1020
977
}
1021
-
1022
978
assessments := m .Assessments
1023
- for _ , a := range archetypes {
1024
- assessments = append (assessments , a .Assessments ... )
979
+ for _ , arch := range archetypes {
980
+ for _ , a := range arch .Assessments {
981
+ assessments = append (assessments , * a .Assessment )
982
+ }
1025
983
}
1026
-
1027
984
resources := []Assessment {}
1028
985
for i := range assessments {
1029
986
r := Assessment {}
@@ -1112,13 +1069,15 @@ type Application struct {
1112
1069
Comments string `json:"comments"`
1113
1070
Identities []Ref `json:"identities"`
1114
1071
Tags []TagRef `json:"tags"`
1115
- BusinessService * Ref `json:"businessService"`
1072
+ BusinessService * Ref `json:"businessService" yaml:"businessService" `
1116
1073
Owner * Ref `json:"owner"`
1117
1074
Contributors []Ref `json:"contributors"`
1118
- MigrationWave * Ref `json:"migrationWave"`
1075
+ MigrationWave * Ref `json:"migrationWave" yaml:"migrationWave" `
1119
1076
Archetypes []Ref `json:"archetypes"`
1120
1077
Assessments []Ref `json:"assessments"`
1121
1078
Assessed bool `json:"assessed"`
1079
+ Risk string `json:"risk"`
1080
+ Confidence int `json:"confidence"`
1122
1081
}
1123
1082
1124
1083
//
@@ -1168,16 +1127,6 @@ func (r *Application) With(m *model.Application, tags []model.ApplicationTag) {
1168
1127
}
1169
1128
}
1170
1129
1171
- //
1172
- // WithArchetypes updates the resource with archetypes.
1173
- func (r * Application ) WithArchetypes (archetypes []model.Archetype ) {
1174
- for _ , a := range archetypes {
1175
- ref := Ref {}
1176
- ref .With (a .ID , a .Name )
1177
- r .Archetypes = append (r .Archetypes , ref )
1178
- }
1179
- }
1180
-
1181
1130
//
1182
1131
// WithVirtualTags updates the resource with tags derived from assessments.
1183
1132
func (r * Application ) WithVirtualTags (tags []model.Tag , source string ) {
@@ -1188,6 +1137,40 @@ func (r *Application) WithVirtualTags(tags []model.Tag, source string) {
1188
1137
}
1189
1138
}
1190
1139
1140
+ //
1141
+ // WithResolver uses an ApplicationResolver to update the resource with
1142
+ // values derived from the application's assessments and archetypes.
1143
+ func (r * Application ) WithResolver (resolver * assessment.ApplicationResolver ) (err error ) {
1144
+ archetypes , err := resolver .Archetypes ()
1145
+ if err != nil {
1146
+ return
1147
+ }
1148
+ for _ , a := range archetypes {
1149
+ ref := Ref {}
1150
+ ref .With (a .ID , a .Name )
1151
+ r .Archetypes = append (r .Archetypes , ref )
1152
+ }
1153
+ archetypeTags , err := resolver .ArchetypeTags ()
1154
+ if err != nil {
1155
+ return
1156
+ }
1157
+ r .WithVirtualTags (archetypeTags , SourceArchetype )
1158
+ r .WithVirtualTags (resolver .AssessmentTags (), SourceAssessment )
1159
+ r .Assessed , err = resolver .Assessed ()
1160
+ if err != nil {
1161
+ return
1162
+ }
1163
+ r .Confidence , err = resolver .Confidence ()
1164
+ if err != nil {
1165
+ return
1166
+ }
1167
+ r .Risk , err = resolver .Risk ()
1168
+ if err != nil {
1169
+ return
1170
+ }
1171
+ return
1172
+ }
1173
+
1191
1174
//
1192
1175
// Model builds a model.
1193
1176
func (r * Application ) Model () (m * model.Application ) {
0 commit comments