Skip to content

Commit 9b9e3e7

Browse files
committed
Web app demo
- Section gets removed when running recipe succeeds, closes #551 - Move report generation into runner - Add button and change Controller to accept all applicable recipes - Commented out all code related to "run all recipes" button - Section fades out before being removed - Related section in sidebar fades out and gets removed - page scrolls to the next section
1 parent 54d6016 commit 9b9e3e7

File tree

20 files changed

+893
-158
lines changed

20 files changed

+893
-158
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright 2021 - 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.sbm;
17+
18+
import lombok.Getter;
19+
import lombok.Setter;
20+
import lombok.Value;
21+
import org.springframework.beans.factory.annotation.Autowired;
22+
import org.springframework.http.MediaType;
23+
import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportRenderer;
24+
import org.springframework.sbm.engine.commands.ApplyCommand;
25+
import org.springframework.sbm.engine.context.ProjectContext;
26+
import org.springframework.sbm.engine.context.ProjectContextHolder;
27+
import org.springframework.stereotype.Controller;
28+
import org.springframework.web.bind.annotation.*;
29+
30+
import java.util.List;
31+
32+
@Controller
33+
@CrossOrigin
34+
class ReportController{
35+
36+
@Autowired
37+
private ApplyCommand applyCommand;
38+
@Autowired
39+
private ReportHolder reportHolder;
40+
41+
@Autowired
42+
private ProjectContextHolder contextHolder;
43+
44+
private final String REPORT_RECIPE = "sbu30-report";
45+
46+
@GetMapping(path = "/spring-boot-upgrade", produces = MediaType.TEXT_HTML_VALUE)
47+
@ResponseBody
48+
public String upgrade() {
49+
// applyCommand.execute(contextHolder.getProjectContext(), "boot-2.7-3.0-upgrade-report2");
50+
return reportHolder.getReport();
51+
}
52+
53+
@PostMapping(path = "/spring-boot-upgrade", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.TEXT_HTML_VALUE)
54+
@ResponseBody
55+
public String applyRecipes(@RequestParam("recipeNames[]") String[] recipeNames) {
56+
ProjectContext context = contextHolder.getProjectContext();
57+
List.of(recipeNames).forEach(recipeName -> applyCommand.execute(context, recipeName));
58+
applyCommand.execute(context, REPORT_RECIPE);
59+
return reportHolder.getReport();
60+
}
61+
62+
@PostMapping(path = "/spring-boot-upgrade")
63+
@ResponseBody
64+
public void applyRecipes2(@RequestBody Recipe recipeNames) {
65+
ProjectContext context = contextHolder.getProjectContext();
66+
recipeNames.getRecipes().forEach(
67+
recipeName -> applyCommand.execute(context, recipeName)
68+
);
69+
applyCommand.execute(context, REPORT_RECIPE);
70+
}
71+
72+
@Getter
73+
@Setter
74+
static class Recipe {
75+
private List<String> recipes;
76+
}
77+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright 2021 - 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.sbm;
17+
18+
import lombok.RequiredArgsConstructor;
19+
import org.springframework.boot.ApplicationArguments;
20+
import org.springframework.boot.ApplicationRunner;
21+
import org.springframework.context.annotation.Configuration;
22+
import org.springframework.sbm.engine.commands.ApplyCommand;
23+
import org.springframework.sbm.engine.commands.ScanCommand;
24+
import org.springframework.sbm.engine.context.ProjectContext;
25+
import org.springframework.sbm.engine.context.ProjectContextHolder;
26+
27+
@Configuration
28+
@RequiredArgsConstructor
29+
public class SpringBootMigratorRunner implements ApplicationRunner {
30+
31+
private final ScanCommand scanCommand;
32+
private final ProjectContextHolder contextHolder;
33+
private final ApplyCommand applyCommand;
34+
private final String REPORT_RECIPE = "sbu30-report";
35+
36+
@Override
37+
public void run(ApplicationArguments args) {
38+
if (args.getSourceArgs().length == 0) {
39+
System.err.println("PLease provide the path to the application as parameter.");
40+
return;
41+
}
42+
String applicationPath = args.getSourceArgs()[0];
43+
System.out.println("Scanning " + applicationPath);
44+
ProjectContext context = scanCommand.execute(applicationPath);
45+
contextHolder.setProjectContext(context);
46+
applyCommand.execute(contextHolder.getProjectContext(), REPORT_RECIPE);
47+
System.out.println("finished scan. Please open: http://localhost:8080/spring-boot-upgrade");
48+
}
49+
50+
51+
}

applications/rest-service/src/main/java/org/springframework/sbm/SpringBootMigratorServiceApp.java

Lines changed: 0 additions & 100 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2021 - 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.sbm;
17+
18+
import org.springframework.boot.SpringApplication;
19+
import org.springframework.boot.autoconfigure.SpringBootApplication;
20+
import org.springframework.context.annotation.Bean;
21+
import org.springframework.web.servlet.config.annotation.CorsRegistry;
22+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
23+
24+
/**
25+
* @author Fabian Krüger
26+
*/
27+
@SpringBootApplication
28+
public class SpringBootUpgradeReportApp {
29+
public static void main(String[] args) {
30+
try {
31+
SpringApplication.run(SpringBootUpgradeReportApp.class, args);
32+
} catch (Exception exception) {
33+
System.err.println(exception.getMessage());
34+
exception.printStackTrace();
35+
}
36+
}
37+
38+
@Bean
39+
public WebMvcConfigurer corsConfigurer() {
40+
return new WebMvcConfigurer() {
41+
@Override
42+
public void addCorsMappings(CorsRegistry registry) {
43+
registry.addMapping("/**").allowedMethods("*");
44+
}
45+
};
46+
}
47+
}

applications/rest-service/src/main/java/org/springframework/sbm/SpringBootUpgradeReportStringRenderer.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,28 @@
2727
@Component
2828
@Primary
2929
public class SpringBootUpgradeReportStringRenderer implements SpringBootUpgradeReportRenderer {
30-
3130
@Autowired
3231
private ReportHolder reportHolder;
3332
@Override
3433
public void processReport(String renderedReport) {
3534
String htmlReport = UpgradeReportUtil.renderHtml(renderedReport);
35+
String closingHeadTag = "</head>";
36+
37+
String additionalHeader =
38+
// "<link rel=\"stylesheet\" href=\"css/button.css\">\n" +
39+
// "<script src=\"js/setup2.js\"></script>\n" +
40+
// "<script src=\"js/site2.js\"></script>\n" +
41+
42+
// "<script src=\"js/java.min.js\"></script>\n";
43+
// htmlReport = htmlReport.replace(closingHeadTag, additionalHeader + closingHeadTag);
44+
45+
htmlReport = htmlReport.replace("</body>", """
46+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
47+
<script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
48+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script>
49+
<script src="js/recipe.js"></script>
50+
</body>
51+
""");
3652
reportHolder.setReport(htmlReport);
3753
}
3854
}
Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,27 @@
11

2-
,╓╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔µ, ,
3-
#╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╦ ]╬⌐
4-
@╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╦ ╔╣╚╣
5-
║╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▒ ║╩ ╟▒
6-
,╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣#╣└ ╣╕
7-
╔╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╝└ ╙╣
8-
@╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╙ ╫▒
9-
╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╝╙ "╬
10-
,╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╩╙ ╫▒
11-
φ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╣╬╝╩╙╙└² ]╣
12-
Å╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╩╙└└ ╬b
13-
.╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╩└ . ║▒
14-
╒╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╩ ,⌐ ╚╬
15-
#╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╩ ╓╩ ]╬
16-
║╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣ @╩ ]╬▒
17-
║╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ φ╣╙ ]╬╬▒
18-
╫╬╬╬╬╬╬╬╬╬╬╬╬╬╣ ╔╣╣` ║╬╬╬
19-
╚╬╬╬╬╬╬╬╬╬╬╬╬╬▒ é╣╬╜ ╣╬╬╛
20-
╙╬╬╬╬╬╬╬╬╬╬╬╬⌐ ╓▒╬╬╩ ]╬╬╙
21-
└╣╬╬╬╬╬╬╬╬╬╬⌐ »▒╣╬╬╩² ╣╣└
22-
╬╬╬╬╬╬╬╬╬╬▒ ,╔▒╬╬╬╣╙ ╟╬
23-
╚╬╬╬╬╬╬╬╬╬⌐ ╓#▒╣╬╬╬╬╩└ ╬╩
24-
╙╬╬╬╬╬╬╬╬╣ε ²╓╗▒╬╣╬╬╬╬╬╣╨└ ╔╣╙
25-
"╣╬╬╬╬╬╬╬╬▒┐ ,╓╔╗@▒╣╬╬╬╬╬╬╬╬╬╣╨╙ ╔╬╣
26-
╢╬╬╬╬╬╬╬╬╬╣▒▒╬╣╬╬╬╬╬╬╬╬╬╬╬╬╣╩╙└ ╓▒╣╬╬
27-
╚╬╬╬╬╜ ╙╣╬╬╬╬╬╬╬╬╝╩╙└ ,╓φ▒╣╬╬╬╬╨
28-
╙╣╬▒ .╬╬╬╬╬╠╗╗@@###@@╗╗╗╗╗╗╗╗╗╗╗╗╗╗#@▒▒╬╣╣╬╬╬╬╬╬╬╬╬┘
29-
²╣╣╓ ,║╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣
30-
║╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╩
31-
╙╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╙
32-
└╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣└
33-
└╜╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╨└
34-
²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²
2+
_____ _ ______ _ _____
3+
/ ___| (_) | ___ \ | | |____ |
4+
\ `--. _ __ _ __ _ _ __ __ _ | |_/ / ___ ___ | |_ / /
5+
`--. \ '_ \| '__| | '_ \ / _` | | ___ \/ _ \ / _ \| __| \ \
6+
/\__/ / |_) | | | | | | | (_| | | |_/ / (_) | (_) | |_ .___/ /
7+
\____/| .__/|_| |_|_| |_|\__, | \____/ \___/ \___/ \__| \____/
8+
| | __/ |
9+
|_| |___/
10+
_ _ _ ______ _
11+
| | | | | | | ___ \ | |
12+
| | | |_ __ __ _ _ __ __ _ __| | ___ | |_/ /___ _ __ ___ _ __| |_
13+
| | | | '_ \ / _` | '__/ _` |/ _` |/ _ \ | // _ \ '_ \ / _ \| '__| __|
14+
| |_| | |_) | (_| | | | (_| | (_| | __/ | |\ \ __/ |_) | (_) | | | |_
15+
\___/| .__/ \__, |_| \__,_|\__,_|\___| \_| \_\___| .__/ \___/|_| \__|
16+
| | __/ | | |
17+
|_| |___/ |_|
3518

19+
powered by Spring Boot Migrator
3620

37-
_______ _______ _______ _______ _______ _______ __ __ _______ _______ ______ _______ ______ _______
38-
| _ || || || | | | | _ | | | | || || || _ | | _ || | | |
39-
| |_| || _ || _ ||_ _| |___ | | | | | | | | || _ || ___|| | || | |_| || _ || ___|
40-
| || | | || | | | | | ___| | | | | | | |_| || |_| || | __ | |_||_ | || | | || |___
41-
| _ | | |_| || |_| | | | |___ | ___ | |_| | | || ___|| || || __ || || |_| || ___|
42-
| |_| || || | | | ___| || | | | | || | | |_| || | | || _ || || |___
43-
|_______||_______||_______| |___| |_______||___| |_______| |_______||___| |_______||___| |_||__| |__||______| |_______|
21+
-------------------------------------------------------------------------
22+
23+
Find us on GitHub: https://via.vmw.com/8AD63p
24+
25+
Please report all errors: https://via.vmw.com/bXlqJC
26+
27+
-------------------------------------------------------------------------

0 commit comments

Comments
 (0)