@@ -82,36 +82,30 @@ public ModelAndView newWorkflowFromGithubURL(@Valid WorkflowForm workflowForm, B
82
82
// Go back to index if there are validation errors
83
83
return new ModelAndView ("index" );
84
84
} else {
85
- // The ID of the workflow to be redirected to
86
- String workflowID ;
87
-
88
85
// Check database for existing workflow
89
- Workflow existingWorkflow = workflowRepository .findByRetrievedFrom (githubInfo );
90
- if (existingWorkflow != null ) {
86
+ Workflow workflow = workflowRepository .findByRetrievedFrom (githubInfo );
87
+ if (workflow != null ) {
91
88
logger .info ("Fetching existing workflow from DB" );
92
-
93
- // Get the ID from the existing workflow
94
- workflowID = existingWorkflow .getID ();
95
89
} else {
96
90
// New workflow from Github URL
97
- Workflow newWorkflow = workflowFactory .workflowFromGithub (githubInfo );
91
+ workflow = workflowFactory .workflowFromGithub (githubInfo );
98
92
99
93
// Runtime error
100
- if (newWorkflow == null ) {
94
+ if (workflow == null ) {
101
95
bindingResult .rejectValue ("githubURL" , "githubURL.parsingError" );
102
96
return new ModelAndView ("index" );
103
97
}
104
98
105
99
// Save to the MongoDB database
106
100
logger .info ("Adding new workflow to DB" );
107
- workflowRepository .save (newWorkflow );
108
-
109
- // Get the ID from the new workflow
110
- workflowID = newWorkflow .getID ();
101
+ workflowRepository .save (workflow );
111
102
}
112
103
113
104
// Redirect to the workflow
114
- return new ModelAndView ("redirect:/workflows/" + workflowID );
105
+ GithubDetails githubDetails = workflow .getRetrievedFrom ();
106
+ return new ModelAndView ("redirect:/workflows/github.com/" + githubDetails .getOwner ()
107
+ + "/" + githubDetails .getRepoName () + "/tree/" + githubDetails .getBranch ()
108
+ + "/" + githubDetails .getPath ());
115
109
}
116
110
}
117
111
0 commit comments