diff --git a/build.gradle b/build.gradle index 7a3fc2e..84ce866 100644 --- a/build.gradle +++ b/build.gradle @@ -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' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 83d6bd2..e3c92db 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/src/main/java/ru/ulstu/configuration/SwaggerConfiguration.java b/src/main/java/ru/ulstu/configuration/SwaggerConfiguration.java index 02d616a..d6981a6 100644 --- a/src/main/java/ru/ulstu/configuration/SwaggerConfiguration.java +++ b/src/main/java/ru/ulstu/configuration/SwaggerConfiguration.java @@ -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(); } } diff --git a/src/main/java/ru/ulstu/configuration/TemplateConfiguration.java b/src/main/java/ru/ulstu/configuration/TemplateConfiguration.java index 258d542..1dd639f 100644 --- a/src/main/java/ru/ulstu/configuration/TemplateConfiguration.java +++ b/src/main/java/ru/ulstu/configuration/TemplateConfiguration.java @@ -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; diff --git a/src/main/java/ru/ulstu/controller/IndexController.java b/src/main/java/ru/ulstu/controller/IndexController.java index 247dd0b..be301fa 100644 --- a/src/main/java/ru/ulstu/controller/IndexController.java +++ b/src/main/java/ru/ulstu/controller/IndexController.java @@ -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; diff --git a/src/main/java/ru/ulstu/controller/TimeSeriesController.java b/src/main/java/ru/ulstu/controller/TimeSeriesController.java index ac7fba5..0d4d6bf 100644 --- a/src/main/java/ru/ulstu/controller/TimeSeriesController.java +++ b/src/main/java/ru/ulstu/controller/TimeSeriesController.java @@ -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 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 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); diff --git a/src/main/java/ru/ulstu/controller/UtilController.java b/src/main/java/ru/ulstu/controller/UtilController.java index 01a8831..2e85f86 100644 --- a/src/main/java/ru/ulstu/controller/UtilController.java +++ b/src/main/java/ru/ulstu/controller/UtilController.java @@ -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 isAlive() { return new ResponseEntity<>(true, HttpStatus.OK); } @GetMapping("getRandom") - @ApiOperation("Получить временной ряд рандомной длины") + @Operation(description = "Получить временной ряд рандомной длины") public ResponseEntity getRandomTimeSeries(@RequestParam("length") int length) { return new ResponseEntity<>(utilService.getRandomTimeSeries(length), HttpStatus.OK); } @GetMapping("getFromString") - @ApiOperation("Преобразовать строку с разделителями во временной ряд") + @Operation(description = "Преобразовать строку с разделителями во временной ряд") public ResponseEntity getTimeSeriesFromString(@RequestParam("tsString") String tsString) { return new ResponseEntity<>(utilService.getTimeSeriesFromString(tsString), HttpStatus.OK); } @PostMapping("timeSeriesToString") - @ApiOperation("Преобразовать временной ряд в строку с разделителями") + @Operation(description = "Преобразовать временной ряд в строку с разделителями") public ResponseEntity getTimeSeriesToString(@RequestBody TimeSeries timeSeries) { return new ResponseEntity<>(utilService.getTimeSeriesToString(timeSeries), HttpStatus.OK); } diff --git a/src/main/java/ru/ulstu/method/Method.java b/src/main/java/ru/ulstu/method/Method.java index 9a4e459..e1e33ab 100644 --- a/src/main/java/ru/ulstu/method/Method.java +++ b/src/main/java/ru/ulstu/method/Method.java @@ -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(); } diff --git a/src/main/java/ru/ulstu/method/exponential/addtrendaddseason/AddTrendAddSeason.java b/src/main/java/ru/ulstu/method/exponential/addtrendaddseason/AddTrendAddSeason.java index a14df9f..0205d81 100644 --- a/src/main/java/ru/ulstu/method/exponential/addtrendaddseason/AddTrendAddSeason.java +++ b/src/main/java/ru/ulstu/method/exponential/addtrendaddseason/AddTrendAddSeason.java @@ -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 getAvailableParameters() { return AddTrendAddSeasonModel.getAvailableParameters(); } + + @Override + public String getName() { + return "Экспоненциальный метод с аддитивным трендом и аддитивной сезонностью (метод Хольта-Уинтерса)"; + } } diff --git a/src/main/java/ru/ulstu/method/exponential/addtrendnoseason/AddTrendNoSeason.java b/src/main/java/ru/ulstu/method/exponential/addtrendnoseason/AddTrendNoSeason.java index bbe28ce..fce087d 100644 --- a/src/main/java/ru/ulstu/method/exponential/addtrendnoseason/AddTrendNoSeason.java +++ b/src/main/java/ru/ulstu/method/exponential/addtrendnoseason/AddTrendNoSeason.java @@ -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 getAvailableParameters() { return AddTrendNoSeasonModel.getAvailableParameters(); } + + @Override + public String getName() { + return "Экспоненциальный метод с аддитивным трендом без сезонной компоненты (метод Хольта)"; + } } diff --git a/src/main/java/ru/ulstu/method/exponential/notrendnoseason/NoTrendNoSeason.java b/src/main/java/ru/ulstu/method/exponential/notrendnoseason/NoTrendNoSeason.java index f4918da..5891e1f 100644 --- a/src/main/java/ru/ulstu/method/exponential/notrendnoseason/NoTrendNoSeason.java +++ b/src/main/java/ru/ulstu/method/exponential/notrendnoseason/NoTrendNoSeason.java @@ -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 getAvailableParameters() { return NoTrendNoSeasonModel.getAvailableParameters(); } + + @Override + public String getName() { + return "Экспоненциальный метод без трендовой и сезонной компоненты"; + } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 125dbda..9befdff 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -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 \ No newline at end of file +time-series.db-path=time-series-db +messages.basename.path=messages_en.properties \ No newline at end of file