@@ -21,39 +21,25 @@ class DevtiFlow(
21
21
private val flowAction : DevtiFlowAction ,
22
22
private val processor : CrudProcessor ? = null
23
23
) {
24
- // fun processAll(id: String) {
25
- // val storyDetail = fillStoryDetail(id)
26
- //
27
- // val target = fetchSuggestEndpoint(storyDetail)
28
- // if (target == null) {
29
- // logger.warn("no suggest endpoint found")
30
- // return
31
- // }
32
- //
33
- // updateEndpointMethod(target, storyDetail)
34
- // }
35
-
36
24
/* *
37
- * Step 3: update endpoint method
25
+ * Step 1: check story detail is valid, if not, fill story detail
38
26
*/
39
- fun updateEndpointMethod (target : TargetEndpoint , storyDetail : String ) {
40
- try {
41
- val code = fetchCode(target.endpoint, target.controller, storyDetail).trimIndent()
42
- if (code.isEmpty()) {
43
- logger.warn(" update method code is empty, skip" )
44
- } else {
45
- processor?.createControllerOrUpdateMethod(target.controller.name, code, target.hasMatchedController)
46
- }
47
- } catch (e: Exception ) {
48
- logger.warn(" update method failed: $e , try to fill update method 2nd" )
27
+ fun fillStoryDetail (id : String ): String {
28
+ val simpleProject = kanban.getProjectInfo()
29
+ val story = kanban.getStoryById(id)
49
30
50
- val code = fetchCode(target.endpoint, target.controller, storyDetail).trimIndent()
51
- if (code.isEmpty()) {
52
- logger.warn(" update method code is empty, skip" )
53
- } else {
54
- processor?.createControllerOrUpdateMethod(target.controller.name, code, target.hasMatchedController)
55
- }
31
+ // 1. check story detail is valid, if not, fill story detail
32
+ var storyDetail = story.description
33
+ if (! kanban.isValidStory(storyDetail)) {
34
+ logger.warn(" story detail is not valid, fill story detail" )
35
+
36
+ storyDetail = flowAction.fillStoryDetail(simpleProject, story.description)
37
+
38
+ val newStory = SimpleStory (story.id, story.title, storyDetail)
39
+ kanban.updateStoryDetail(newStory)
56
40
}
41
+ logger.warn(" user story detail: $storyDetail " )
42
+ return storyDetail
57
43
}
58
44
59
45
/* *
@@ -81,32 +67,34 @@ class DevtiFlow(
81
67
}
82
68
83
69
/* *
84
- * Step 1: check story detail is valid, if not, fill story detail
70
+ * Step 3: update endpoint method
85
71
*/
86
- fun fillStoryDetail ( id : String ) : String {
87
- val simpleProject = kanban.getProjectInfo()
88
- val story = kanban.getStoryById(id )
89
-
90
- // 1. check story detail is valid, if not, fill story detail
91
- var storyDetail = story.description
92
- if ( ! kanban.isValidStory(storyDetail)) {
93
- logger.warn( " story detail is not valid, fill story detail " )
94
-
95
- storyDetail = flowAction.fillStoryDetail(simpleProject, story.description )
72
+ fun updateEndpointMethod ( target : TargetEndpoint , storyDetail : String ) {
73
+ try {
74
+ val code = fetchEndpoint(target.endpoint, target.controller, storyDetail).trimIndent( )
75
+ if (code.isEmpty()) {
76
+ logger.warn( " update method code is empty, skip " )
77
+ } else {
78
+ processor?.createControllerOrUpdateMethod(target.controller.name, code, target.hasMatchedController)
79
+ }
80
+ } catch (e : Exception ) {
81
+ logger.warn( " update method failed: $e , try to fill update method 2nd " )
96
82
97
- val newStory = SimpleStory (story.id, story.title, storyDetail)
98
- kanban.updateStoryDetail(newStory)
83
+ val code = fetchEndpoint(target.endpoint, target.controller, storyDetail).trimIndent()
84
+ if (code.isEmpty()) {
85
+ logger.warn(" update method code is empty, skip" )
86
+ } else {
87
+ processor?.createControllerOrUpdateMethod(target.controller.name, code, target.hasMatchedController)
88
+ }
99
89
}
100
- logger.warn(" user story detail: $storyDetail " )
101
- return storyDetail
102
90
}
103
91
104
- private fun fetchCode (
92
+ private fun fetchEndpoint (
105
93
targetEndpoint : String ,
106
94
targetController : DtClass ,
107
95
storyDetail : String
108
96
): String {
109
- val content = flowAction.needUpdateMethodForController (targetEndpoint, targetController, storyDetail)
97
+ val content = flowAction.needUpdateMethodOfController (targetEndpoint, targetController, storyDetail)
110
98
val code = parseCodeFromString(content)
111
99
logger.warn(" update method code: $code " )
112
100
return code
0 commit comments