From 923054dfc49399cabb897fe5593e29f717f7ef63 Mon Sep 17 00:00:00 2001 From: sanagaraj-pivotal Date: Mon, 14 Nov 2022 15:18:15 +0000 Subject: [PATCH] We remove the section when running recipe succeeds. --- .../springframework/sbm/ReportController.java | 16 ++++++-- .../src/main/resources/static/js/recipe.js | 2 +- .../report/helper/MissingHelper.java | 41 +++++++++++++++++++ 3 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/MissingHelper.java diff --git a/applications/rest-service/src/main/java/org/springframework/sbm/ReportController.java b/applications/rest-service/src/main/java/org/springframework/sbm/ReportController.java index c3661fc9d..0c892aeda 100644 --- a/applications/rest-service/src/main/java/org/springframework/sbm/ReportController.java +++ b/applications/rest-service/src/main/java/org/springframework/sbm/ReportController.java @@ -15,6 +15,9 @@ */ package org.springframework.sbm; +import lombok.Getter; +import lombok.Setter; +import lombok.Value; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportRenderer; @@ -58,10 +61,17 @@ public String applyRecipes(@RequestParam("recipeNames[]") String[] recipeNames) @PostMapping(path = "/spring-boot-upgrade") @ResponseBody - public void applyRecipes2(@RequestBody String recipeNames) { + public void applyRecipes2(@RequestBody Recipe recipeNames) { ProjectContext context = contextHolder.getProjectContext(); - List.of(recipeNames).forEach(recipeName -> applyCommand.execute(context, recipeName)); + recipeNames.getRecipes().forEach( + recipeName -> applyCommand.execute(context, recipeName) + ); applyCommand.execute(context, REPORT_RECIPE); } -} \ No newline at end of file + @Getter + @Setter + static class Recipe { + private List recipes; + } +} diff --git a/applications/rest-service/src/main/resources/static/js/recipe.js b/applications/rest-service/src/main/resources/static/js/recipe.js index 5676b81e3..22292e543 100644 --- a/applications/rest-service/src/main/resources/static/js/recipe.js +++ b/applications/rest-service/src/main/resources/static/js/recipe.js @@ -72,7 +72,7 @@ function applyRecipes(btn) { url: "http://localhost:8080/spring-boot-upgrade", contentType: 'application/json', data: JSON.stringify({ - recipes: $(btn).attr('recipe') + recipes: [$(btn).attr('recipe')] }), beforeSend: function() { state.startedRunningRecipe(); diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/MissingHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/MissingHelper.java new file mode 100644 index 000000000..9aadd2ed0 --- /dev/null +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/MissingHelper.java @@ -0,0 +1,41 @@ +/* + * Copyright 2021 - 2022 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.sbm.boot.upgrade_27_30.report.helper; + +import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSection; +import org.springframework.sbm.engine.context.ProjectContext; +import org.springframework.sbm.properties.api.PropertiesSource; + +import java.util.List; +import java.util.Map; + +public class MissingHelper implements SpringBootUpgradeReportSection.Helper{ + @Override + public String getDescription() { + return null; + } + + @Override + public boolean evaluate(ProjectContext context) { + return false; + } + + @Override + public Map getData() { + return null; + } +}