1-method-choosing #2

Merged
romanov73 merged 6 commits from 1-method-choosing into master 2022-04-18 13:11:46 +04:00
12 changed files with 77 additions and 50 deletions
Showing only changes of commit ce41f9846c - Show all commits

View File

@ -1,14 +1,13 @@
/*
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
* Copyright (C) 2022 Anton Romanov - All Rights Reserved
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
*
*/
plugins {
id 'java'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'org.springframework.boot' version '2.3.3.RELEASE'
id "org.sonarqube" version "2.7"
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'org.springframework.boot' version '2.6.4'
}
jar {
@ -16,26 +15,29 @@ jar {
}
repositories {
mavenLocal()
mavenCentral()
maven {
url "https://repo.athene.tech/repository/maven-central/"
}
maven {
url "https://repo.athene.tech/repository/maven-releases/"
}
}
sourceCompatibility = 11
targetCompatibility = 11
sourceCompatibility = '11'
targetCompatibility = '11'
dependencies {
ext {
versionSLF4J = '1.7.24'
versionJetty = '9.3.16.v20170120'
versionJackson = '2.9.4'
versionSwagger = '2.5.0'
}
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-jetty'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf'
implementation group: 'org.slf4j', name: 'slf4j-api', version: versionSLF4J
implementation group: 'nz.net.ultraq.thymeleaf', name: 'thymeleaf-layout-dialect'
implementation group: 'nz.net.ultraq.thymeleaf', name: 'thymeleaf-layout-dialect', version: '3.1.0'
implementation group: 'org.javassist', name: 'javassist', version: '3.25.0-GA'
implementation group: 'org.eclipse.jetty', name: 'jetty-servlet', version: versionJetty
@ -43,8 +45,7 @@ dependencies {
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: versionJackson
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: versionJackson
implementation group: 'io.springfox', name: 'springfox-swagger2', version: versionSwagger
implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: versionSwagger
implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.5'
implementation group: 'org.webjars', name: 'jquery', version: '3.6.0'
implementation group: 'org.webjars', name: 'bootstrap', version: '4.6.0'

View File

@ -1,6 +1,12 @@
#
# Copyright (C) 2022 Anton Romanov - All Rights Reserved
# You may use, distribute and modify this code, please write to: romanov73@gmail.com.
#
#
#Mon Dec 28 10:00:20 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip

View File

@ -1,24 +1,27 @@
/*
* Copyright (C) 2022 Anton Romanov - All Rights Reserved
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
*
*/
package ru.ulstu.configuration;
import com.google.common.base.Predicates;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfiguration {
private final Logger log = LoggerFactory.getLogger(SwaggerConfiguration.class);
@Bean
public Docket swaggerApi() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(Predicates.not(PathSelectors.regex("/error")))
public GroupedOpenApi swaggerApi() {
log.info("Creating Swagger API configuration bean");
return GroupedOpenApi.builder()
.group("timetable-api")
.pathsToMatch(ApiConfiguration.API_1_0 + "**")
.build();
}
}

View File

@ -1,12 +1,12 @@
/*
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
* Copyright (C) 2022 Anton Romanov - All Rights Reserved
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
*
*/
package ru.ulstu.configuration;
import nz.net.ultraq.thymeleaf.LayoutDialect;
import nz.net.ultraq.thymeleaf.layoutdialect.LayoutDialect;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;

View File

@ -1,11 +1,12 @@
/*
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
* Copyright (C) 2022 Anton Romanov - All Rights Reserved
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
*
*/
package ru.ulstu.controller;
import io.swagger.v3.oas.annotations.Hidden;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
@ -17,7 +18,6 @@ import ru.ulstu.datamodel.ts.TimeSeries;
import ru.ulstu.datamodel.ts.TimeSeriesValue;
import ru.ulstu.db.DbService;
import ru.ulstu.service.TimeSeriesService;
import springfox.documentation.annotations.ApiIgnore;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
@ -29,7 +29,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
@Controller
@ApiIgnore
@Hidden
public class IndexController {
private final TimeSeriesService timeSeriesService;
private final DbService dbService;

View File

@ -1,12 +1,12 @@
/*
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
* Copyright (C) 2022 Anton Romanov - All Rights Reserved
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
*
*/
package ru.ulstu.controller;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
@ -43,7 +43,7 @@ public class TimeSeriesController {
}
@PostMapping("getForecast")
@ApiOperation("Получить прогноз временного ряда")
@Operation(description = "Получить прогноз временного ряда")
public ResponseEntity<ModelingResult> getForecastTimeSeries(@RequestBody ForecastParams forecastParams, HttpServletRequest request) throws ExecutionException, InterruptedException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException, ModelingException {
LOGGER.info("User ip: " + HttpUtils.getUserIp(request));
LOGGER.info("Forecast: " + forecastParams);
@ -54,7 +54,7 @@ public class TimeSeriesController {
}
@PostMapping("getSmoothed")
@ApiOperation("Получить сглаженный временной ряд")
@Operation(description = "Получить сглаженный временной ряд")
public ResponseEntity<ModelingResult> getSmoothedTimeSeries(@RequestBody TimeSeries timeSeries, HttpServletRequest request) throws ExecutionException, InterruptedException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
LOGGER.info("User ip: " + HttpUtils.getUserIp(request));
LOGGER.info("Time series for smoothing: " + timeSeries);

View File

@ -1,12 +1,12 @@
/*
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
* Copyright (C) 2022 Anton Romanov - All Rights Reserved
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
*
*/
package ru.ulstu.controller;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
@ -30,25 +30,25 @@ public class UtilController {
}
@GetMapping("isAlive")
@ApiOperation("Проверка сервиса")
@Operation(description = "Проверка сервиса")
public ResponseEntity<Boolean> isAlive() {
return new ResponseEntity<>(true, HttpStatus.OK);
}
@GetMapping("getRandom")
@ApiOperation("Получить временной ряд рандомной длины")
@Operation(description = "Получить временной ряд рандомной длины")
public ResponseEntity<TimeSeries> getRandomTimeSeries(@RequestParam("length") int length) {
return new ResponseEntity<>(utilService.getRandomTimeSeries(length), HttpStatus.OK);
}
@GetMapping("getFromString")
@ApiOperation("Преобразовать строку с разделителями во временной ряд")
@Operation(description = "Преобразовать строку с разделителями во временной ряд")
public ResponseEntity<TimeSeries> getTimeSeriesFromString(@RequestParam("tsString") String tsString) {
return new ResponseEntity<>(utilService.getTimeSeriesFromString(tsString), HttpStatus.OK);
}
@PostMapping("timeSeriesToString")
@ApiOperation("Преобразовать временной ряд в строку с разделителями")
@Operation(description = "Преобразовать временной ряд в строку с разделителями")
public ResponseEntity<String> getTimeSeriesToString(@RequestBody TimeSeries timeSeries) {
return new ResponseEntity<>(utilService.getTimeSeriesToString(timeSeries), HttpStatus.OK);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
* Copyright (C) 2022 Anton Romanov - All Rights Reserved
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
*
*/
@ -7,7 +7,6 @@
package ru.ulstu.method;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import ru.ulstu.TimeSeriesUtils;
import ru.ulstu.datamodel.Model;
import ru.ulstu.datamodel.exception.ForecastValidateException;
@ -20,7 +19,7 @@ import java.time.temporal.ChronoUnit;
import java.util.List;
/**
* Наиболее общая логика моделировании и прогнозирования временных рядов
* Наиболее общая логика моделирования и прогнозирования временных рядов
*/
public abstract class Method {
@JsonIgnore
@ -117,8 +116,10 @@ public abstract class Method {
}
@Override
@JsonProperty("name")
//@JsonProperty("name")
public String toString() {
return getClass().getSimpleName();
return getName();
}
public abstract String getName();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
* Copyright (C) 2022 Anton Romanov - All Rights Reserved
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
*
*/
@ -92,4 +92,9 @@ public class AddTrendAddSeason extends Method {
public List<MethodParameter> getAvailableParameters() {
return AddTrendAddSeasonModel.getAvailableParameters();
}
@Override
public String getName() {
return "Экспоненциальный метод с аддитивным трендом и аддитивной сезонностью (метод Хольта-Уинтерса)";
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
* Copyright (C) 2022 Anton Romanov - All Rights Reserved
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
*
*/
@ -58,4 +58,9 @@ public class AddTrendNoSeason extends Method {
public List<MethodParameter> getAvailableParameters() {
return AddTrendNoSeasonModel.getAvailableParameters();
}
@Override
public String getName() {
return "Экспоненциальный метод с аддитивным трендом без сезонной компоненты (метод Хольта)";
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
* Copyright (C) 2022 Anton Romanov - All Rights Reserved
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
*
*/
@ -48,4 +48,9 @@ public class NoTrendNoSeason extends Method {
public List<MethodParameter> getAvailableParameters() {
return NoTrendNoSeasonModel.getAvailableParameters();
}
@Override
public String getName() {
return "Экспоненциальный метод без трендовой и сезонной компоненты";
}
}

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2021 Anton Romanov - All Rights Reserved
# Copyright (C) 2022 Anton Romanov - All Rights Reserved
# You may use, distribute and modify this code, please write to: romanov73@gmail.com.
#
#
@ -10,4 +10,5 @@ server.port=8080
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false
joinfaces.primefaces.theme=afterwork
joinfaces.primefaces.font-awesome=true
time-series.db-path=time-series-db
time-series.db-path=time-series-db
messages.basename.path=messages_en.properties