#96 -- Add generation page

This commit is contained in:
Anton Romanov 2024-05-10 12:11:17 +04:00
parent 5a97d107c3
commit e5d5d7312b
7 changed files with 163 additions and 1 deletions

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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 +
'}';
}
}

View File

@ -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);
}
}

View File

@ -3,7 +3,7 @@
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.w3.org/1999/xhtml"
layout:decorate="~{default}">
<head>
<title>Простая обработка формы на Spring MVC</title>
<title>Оценка репозиториев</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<div class="container" layout:fragment="content">

View File

@ -38,6 +38,9 @@
<li class="nav-item">
<a class="nav-link" href="/listRules">Правила</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/generation">Синтетические данные</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/assessments">Рекомендации</a>
</li>

View File

@ -0,0 +1,50 @@
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.w3.org/1999/xhtml"
layout:decorate="~{default}">
<head>
<title>Генерация</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<div class="container" layout:fragment="content">
<form action="#" th:action="${@route.GENERATION}" th:object="${generationForm}" method="post">
<div class="row">
<div class="col-md-4 col-sm-12">
Длина временных рядов
</div>
<div class="col-md-6 col-sm-12">
<input type="text" class="form-control m-1" th:field="*{tsLength}">
</div>
</div>
<div class="row">
<div class="col-md-4 col-sm-12">
Минимум
</div>
<div class="col-md-6 col-sm-12">
<input type="text" class="form-control m-1" th:field="*{min}">
</div>
</div>
<div class="row">
<div class="col-md-4 col-sm-12">
Максимум
</div>
<div class="col-md-6 col-sm-12">
<input type="text" class="form-control m-1" th:field="*{max}">
</div>
</div>
<div class="row">
<div class="col-md-4 col-sm-12">
Основное значение
</div>
<div class="col-md-6 col-sm-12">
<input type="text" class="form-control m-1" th:field="*{base}">
</div>
</div>
<div class="row">
<div class="col-md-4 col-sm-12">
<input type="submit" class="btn btn-outline-success form-control" value="Сгенерировать временные ряды"/>
</div>
</div>
</form>
</div>
</html>