From 78fe8236bef5962befcdb2b8853bf92d2fdeb161 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Tue, 25 Feb 2025 12:21:16 +0400 Subject: [PATCH] #3 -- Parse rule for list --- .../controller/ProjectRunController.java | 37 +++++++++++ ...ervice.java => FuzzyRuleParseService.java} | 4 +- .../resources/templates/project/edit.html | 65 +++++++++++-------- src/main/resources/templates/rule/edit.html | 4 +- 4 files changed, 80 insertions(+), 30 deletions(-) create mode 100644 src/main/java/ru/ulstu/fc/project/controller/ProjectRunController.java rename src/main/java/ru/ulstu/fc/rule/service/{RuleParseService.java => FuzzyRuleParseService.java} (94%) diff --git a/src/main/java/ru/ulstu/fc/project/controller/ProjectRunController.java b/src/main/java/ru/ulstu/fc/project/controller/ProjectRunController.java new file mode 100644 index 0000000..c2ca79a --- /dev/null +++ b/src/main/java/ru/ulstu/fc/project/controller/ProjectRunController.java @@ -0,0 +1,37 @@ +package ru.ulstu.fc.project.controller; + +import io.swagger.v3.oas.annotations.Hidden; +import org.springframework.security.access.annotation.Secured; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import ru.ulstu.fc.project.service.ProjectRulesService; +import ru.ulstu.fc.project.service.ProjectService; +import ru.ulstu.fc.project.service.ProjectVariableService; +import ru.ulstu.fc.user.model.UserRoleConstants; + +@Controller +@Hidden +@RequestMapping("runProject") +@Secured({UserRoleConstants.ADMIN}) +public class ProjectRunController { + private final ProjectService projectService; + private final ProjectRulesService projectRulesService; + private final ProjectVariableService projectVariableService; + + public ProjectRunController(ProjectService projectService, + ProjectRulesService projectRulesService, + ProjectVariableService projectVariableService) { + this.projectService = projectService; + this.projectRulesService = projectRulesService; + this.projectVariableService = projectVariableService; + } + + @GetMapping("init/{projectId}") + public String getProjects(@PathVariable(value = "projectId") Integer projectId, Model model) { + model.addAttribute("project", projectService.getById(projectId)); + return "project/init"; + } +} diff --git a/src/main/java/ru/ulstu/fc/rule/service/RuleParseService.java b/src/main/java/ru/ulstu/fc/rule/service/FuzzyRuleParseService.java similarity index 94% rename from src/main/java/ru/ulstu/fc/rule/service/RuleParseService.java rename to src/main/java/ru/ulstu/fc/rule/service/FuzzyRuleParseService.java index 7461a17..5209a70 100644 --- a/src/main/java/ru/ulstu/fc/rule/service/RuleParseService.java +++ b/src/main/java/ru/ulstu/fc/rule/service/FuzzyRuleParseService.java @@ -8,7 +8,7 @@ import java.util.List; import java.util.stream.Collectors; @Service -public class RuleParseService { +public class FuzzyRuleParseService { private final static String RU_IF_STATEMENT = "если"; private final static String ENG_IF_STATEMENT = "if"; private final static String RU_THEN_STATEMENT = "то"; @@ -21,7 +21,7 @@ public class RuleParseService { private final Engine fuzzyEngine; - public RuleParseService(Engine fuzzyEngine) { + public FuzzyRuleParseService(Engine fuzzyEngine) { this.fuzzyEngine = fuzzyEngine; } diff --git a/src/main/resources/templates/project/edit.html b/src/main/resources/templates/project/edit.html index 3a138d2..bb51180 100644 --- a/src/main/resources/templates/project/edit.html +++ b/src/main/resources/templates/project/edit.html @@ -48,39 +48,52 @@
- Добавить правило + + \ No newline at end of file diff --git a/src/main/resources/templates/rule/edit.html b/src/main/resources/templates/rule/edit.html index ad6c1f3..bbe6824 100644 --- a/src/main/resources/templates/rule/edit.html +++ b/src/main/resources/templates/rule/edit.html @@ -12,9 +12,9 @@
- +