diff --git a/src/main/java/ru/ulstu/extractor/core/Route.java b/src/main/java/ru/ulstu/extractor/core/Route.java index 9c56182..0b2fe3f 100644 --- a/src/main/java/ru/ulstu/extractor/core/Route.java +++ b/src/main/java/ru/ulstu/extractor/core/Route.java @@ -18,6 +18,8 @@ public class Route { public static final String DELETE_RULE = "deleteRule"; public static final String ADD_MARKUP = "addMarkup"; + public static final String GENERATION = "generation"; + public static String getLIST_INDEXED_REPOSITORIES() { return LIST_INDEXED_REPOSITORIES; } @@ -45,4 +47,8 @@ public class Route { public static String getADD_MARKUP() { return ADD_MARKUP; } + + public static String getGENERATION() { + return GENERATION; + } } diff --git a/src/main/java/ru/ulstu/extractor/generation/controller/GenerationController.java b/src/main/java/ru/ulstu/extractor/generation/controller/GenerationController.java new file mode 100644 index 0000000..fcb9dc4 --- /dev/null +++ b/src/main/java/ru/ulstu/extractor/generation/controller/GenerationController.java @@ -0,0 +1,35 @@ +package ru.ulstu.extractor.generation.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; +import ru.ulstu.extractor.generation.model.GenerationForm; +import ru.ulstu.extractor.generation.service.GenerationService; +import springfox.documentation.annotations.ApiIgnore; + +import static ru.ulstu.extractor.core.Route.GENERATION; + +@Controller +@ApiIgnore +public class GenerationController { + private final GenerationService generationService; + + public GenerationController(GenerationService generationService) { + this.generationService = generationService; + } + + @GetMapping(GENERATION) + public String getGenerationsPage(Model model) { + model.addAttribute("generationForm", new GenerationForm()); + return GENERATION; + } + + @PostMapping(GENERATION) + public String setGenerationParams(Model model, @ModelAttribute GenerationForm generationForm) { + model.addAttribute("generationForm", generationForm); + generationService.generate(generationForm); + return GENERATION; + } +} diff --git a/src/main/java/ru/ulstu/extractor/generation/model/GenerationForm.java b/src/main/java/ru/ulstu/extractor/generation/model/GenerationForm.java new file mode 100644 index 0000000..99b19f3 --- /dev/null +++ b/src/main/java/ru/ulstu/extractor/generation/model/GenerationForm.java @@ -0,0 +1,50 @@ +package ru.ulstu.extractor.generation.model; + +public class GenerationForm { + private int tsLength; + private int min; + private int max; + private int base; + + public int getTsLength() { + return tsLength; + } + + public void setTsLength(int tsLength) { + this.tsLength = tsLength; + } + + public int getMin() { + return min; + } + + public void setMin(int min) { + this.min = min; + } + + public int getMax() { + return max; + } + + public void setMax(int max) { + this.max = max; + } + + public int getBase() { + return base; + } + + public void setBase(int base) { + this.base = base; + } + + @Override + public String toString() { + return "GenerationForm{" + + "tsLength=" + tsLength + + ", min=" + min + + ", max=" + max + + ", base=" + base + + '}'; + } +} diff --git a/src/main/java/ru/ulstu/extractor/generation/service/GenerationService.java b/src/main/java/ru/ulstu/extractor/generation/service/GenerationService.java new file mode 100644 index 0000000..0a50824 --- /dev/null +++ b/src/main/java/ru/ulstu/extractor/generation/service/GenerationService.java @@ -0,0 +1,18 @@ +package ru.ulstu.extractor.generation.service; + +import org.springframework.stereotype.Service; +import ru.ulstu.extractor.generation.model.GenerationForm; +import ru.ulstu.extractor.ts.service.TimeSeriesService; + +@Service +public class GenerationService { + private final TimeSeriesService timeSeriesService; + + public GenerationService(TimeSeriesService timeSeriesService) { + this.timeSeriesService = timeSeriesService; + } + + public void generate(GenerationForm generationForm) { + System.out.print(generationForm); + } +} diff --git a/src/main/resources/templates/assessments.html b/src/main/resources/templates/assessments.html index d9a3721..aae7805 100644 --- a/src/main/resources/templates/assessments.html +++ b/src/main/resources/templates/assessments.html @@ -3,7 +3,7 @@ xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.w3.org/1999/xhtml" layout:decorate="~{default}">
-