Add generation #97

Merged
romanov73 merged 5 commits from 96-generation into master 2024-05-13 00:54:18 +04:00
7 changed files with 163 additions and 1 deletions
Showing only changes of commit e5d5d7312b - Show all commits

View File

@ -18,6 +18,8 @@ public class Route {
public static final String DELETE_RULE = "deleteRule"; public static final String DELETE_RULE = "deleteRule";
public static final String ADD_MARKUP = "addMarkup"; public static final String ADD_MARKUP = "addMarkup";
public static final String GENERATION = "generation";
public static String getLIST_INDEXED_REPOSITORIES() { public static String getLIST_INDEXED_REPOSITORIES() {
return LIST_INDEXED_REPOSITORIES; return LIST_INDEXED_REPOSITORIES;
} }
@ -45,4 +47,8 @@ public class Route {
public static String getADD_MARKUP() { public static String getADD_MARKUP() {
return ADD_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" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.w3.org/1999/xhtml"
layout:decorate="~{default}"> layout:decorate="~{default}">
<head> <head>
<title>Простая обработка формы на Spring MVC</title> <title>Оценка репозиториев</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head> </head>
<div class="container" layout:fragment="content"> <div class="container" layout:fragment="content">

View File

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