diff --git a/src/main/java/ru/ulstu/extractor/model/Author.java b/src/main/java/ru/ulstu/extractor/author/model/Author.java similarity index 79% rename from src/main/java/ru/ulstu/extractor/model/Author.java rename to src/main/java/ru/ulstu/extractor/author/model/Author.java index 2462d5b..efd5ba1 100644 --- a/src/main/java/ru/ulstu/extractor/model/Author.java +++ b/src/main/java/ru/ulstu/extractor/author/model/Author.java @@ -1,4 +1,6 @@ -package ru.ulstu.extractor.model; +package ru.ulstu.extractor.author.model; + +import ru.ulstu.extractor.core.BaseEntity; import javax.persistence.Entity; diff --git a/src/main/java/ru/ulstu/extractor/repository/AuthorRepository.java b/src/main/java/ru/ulstu/extractor/author/repository/AuthorRepository.java similarity index 93% rename from src/main/java/ru/ulstu/extractor/repository/AuthorRepository.java rename to src/main/java/ru/ulstu/extractor/author/repository/AuthorRepository.java index 0ae8a20..e20f19d 100644 --- a/src/main/java/ru/ulstu/extractor/repository/AuthorRepository.java +++ b/src/main/java/ru/ulstu/extractor/author/repository/AuthorRepository.java @@ -3,13 +3,13 @@ * You may use, distribute and modify this code, please write to: romanov73@gmail.com. */ -package ru.ulstu.extractor.repository; +package ru.ulstu.extractor.author.repository; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; +import ru.ulstu.extractor.author.model.Author; import ru.ulstu.extractor.gitrepository.model.GitRepository; -import ru.ulstu.extractor.model.Author; import java.util.List; diff --git a/src/main/java/ru/ulstu/extractor/service/AuthorService.java b/src/main/java/ru/ulstu/extractor/author/service/AuthorService.java similarity index 85% rename from src/main/java/ru/ulstu/extractor/service/AuthorService.java rename to src/main/java/ru/ulstu/extractor/author/service/AuthorService.java index c04cfd1..659e17c 100644 --- a/src/main/java/ru/ulstu/extractor/service/AuthorService.java +++ b/src/main/java/ru/ulstu/extractor/author/service/AuthorService.java @@ -3,13 +3,13 @@ * You may use, distribute and modify this code, please write to: romanov73@gmail.com. */ -package ru.ulstu.extractor.service; +package ru.ulstu.extractor.author.service; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; -import ru.ulstu.extractor.model.Author; -import ru.ulstu.extractor.repository.AuthorRepository; +import ru.ulstu.extractor.author.model.Author; +import ru.ulstu.extractor.author.repository.AuthorRepository; import java.util.Optional; diff --git a/src/main/java/ru/ulstu/extractor/branch/controller/BranchController.java b/src/main/java/ru/ulstu/extractor/branch/controller/BranchController.java index 22432bd..8b79a93 100644 --- a/src/main/java/ru/ulstu/extractor/branch/controller/BranchController.java +++ b/src/main/java/ru/ulstu/extractor/branch/controller/BranchController.java @@ -10,11 +10,11 @@ import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import ru.ulstu.extractor.branch.repository.BranchRepository; -import ru.ulstu.extractor.gitrepository.GitRepositoryRepository; +import ru.ulstu.extractor.gitrepository.repository.GitRepositoryRepository; import springfox.documentation.annotations.ApiIgnore; -import static ru.ulstu.extractor.controller.Route.DELETE_BRANCH; -import static ru.ulstu.extractor.controller.Route.LIST_REPOSITORY_BRANCHES; +import static ru.ulstu.extractor.core.Route.DELETE_BRANCH; +import static ru.ulstu.extractor.core.Route.LIST_REPOSITORY_BRANCHES; @Controller @ApiIgnore diff --git a/src/main/java/ru/ulstu/extractor/branch/model/Branch.java b/src/main/java/ru/ulstu/extractor/branch/model/Branch.java index 6837771..12a9f01 100644 --- a/src/main/java/ru/ulstu/extractor/branch/model/Branch.java +++ b/src/main/java/ru/ulstu/extractor/branch/model/Branch.java @@ -7,8 +7,8 @@ package ru.ulstu.extractor.branch.model; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; +import ru.ulstu.extractor.core.BaseEntity; import ru.ulstu.extractor.gitrepository.model.GitRepository; -import ru.ulstu.extractor.model.BaseEntity; import ru.ulstu.extractor.model.Commit; import javax.persistence.CascadeType; diff --git a/src/main/java/ru/ulstu/extractor/branch/service/BranchService.java b/src/main/java/ru/ulstu/extractor/branch/service/BranchService.java index 3d6fd28..ebb51aa 100644 --- a/src/main/java/ru/ulstu/extractor/branch/service/BranchService.java +++ b/src/main/java/ru/ulstu/extractor/branch/service/BranchService.java @@ -12,8 +12,8 @@ import org.springframework.transaction.annotation.Transactional; import ru.ulstu.extractor.branch.model.Branch; import ru.ulstu.extractor.branch.repository.BranchRepository; import ru.ulstu.extractor.commit.service.CommitService; +import ru.ulstu.extractor.core.BaseEntity; import ru.ulstu.extractor.gitrepository.model.GitRepository; -import ru.ulstu.extractor.model.BaseEntity; import ru.ulstu.extractor.model.Commit; import java.util.List; diff --git a/src/main/java/ru/ulstu/extractor/commit/model/Commit.java b/src/main/java/ru/ulstu/extractor/commit/model/Commit.java index 699ff94..9f8f109 100644 --- a/src/main/java/ru/ulstu/extractor/commit/model/Commit.java +++ b/src/main/java/ru/ulstu/extractor/commit/model/Commit.java @@ -7,7 +7,10 @@ package ru.ulstu.extractor.model; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; +import ru.ulstu.extractor.author.model.Author; import ru.ulstu.extractor.branch.model.Branch; +import ru.ulstu.extractor.core.BaseEntity; +import ru.ulstu.extractor.gitrepository.model.FileChange; import javax.persistence.CascadeType; import javax.persistence.Entity; diff --git a/src/main/java/ru/ulstu/extractor/commit/service/CommitService.java b/src/main/java/ru/ulstu/extractor/commit/service/CommitService.java index fd1c449..050437a 100644 --- a/src/main/java/ru/ulstu/extractor/commit/service/CommitService.java +++ b/src/main/java/ru/ulstu/extractor/commit/service/CommitService.java @@ -7,9 +7,9 @@ package ru.ulstu.extractor.commit.service; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; +import ru.ulstu.extractor.author.service.AuthorService; import ru.ulstu.extractor.commit.repository.CommitRepository; import ru.ulstu.extractor.model.Commit; -import ru.ulstu.extractor.service.AuthorService; import java.util.List; import java.util.stream.Collectors; diff --git a/src/main/java/ru/ulstu/extractor/config/MvcConfiguration.java b/src/main/java/ru/ulstu/extractor/config/MvcConfiguration.java index 035f359..d4f9a9c 100644 --- a/src/main/java/ru/ulstu/extractor/config/MvcConfiguration.java +++ b/src/main/java/ru/ulstu/extractor/config/MvcConfiguration.java @@ -10,7 +10,7 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import static ru.ulstu.extractor.controller.Route.LIST_INDEXED_REPOSITORIES; +import static ru.ulstu.extractor.core.Route.LIST_INDEXED_REPOSITORIES; @Configuration public class MvcConfiguration implements WebMvcConfigurer { diff --git a/src/main/java/ru/ulstu/extractor/model/BaseEntity.java b/src/main/java/ru/ulstu/extractor/core/BaseEntity.java similarity index 98% rename from src/main/java/ru/ulstu/extractor/model/BaseEntity.java rename to src/main/java/ru/ulstu/extractor/core/BaseEntity.java index 0859807..43690f1 100644 --- a/src/main/java/ru/ulstu/extractor/model/BaseEntity.java +++ b/src/main/java/ru/ulstu/extractor/core/BaseEntity.java @@ -1,4 +1,4 @@ -package ru.ulstu.extractor.model; +package ru.ulstu.extractor.core; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; diff --git a/src/main/java/ru/ulstu/extractor/model/OffsetablePageRequest.java b/src/main/java/ru/ulstu/extractor/core/OffsetablePageRequest.java similarity index 98% rename from src/main/java/ru/ulstu/extractor/model/OffsetablePageRequest.java rename to src/main/java/ru/ulstu/extractor/core/OffsetablePageRequest.java index e96673b..f48e7cc 100644 --- a/src/main/java/ru/ulstu/extractor/model/OffsetablePageRequest.java +++ b/src/main/java/ru/ulstu/extractor/core/OffsetablePageRequest.java @@ -1,4 +1,4 @@ -package ru.ulstu.extractor.model; +package ru.ulstu.extractor.core; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; diff --git a/src/main/java/ru/ulstu/extractor/controller/Route.java b/src/main/java/ru/ulstu/extractor/core/Route.java similarity index 97% rename from src/main/java/ru/ulstu/extractor/controller/Route.java rename to src/main/java/ru/ulstu/extractor/core/Route.java index 77e1efe..9627848 100644 --- a/src/main/java/ru/ulstu/extractor/controller/Route.java +++ b/src/main/java/ru/ulstu/extractor/core/Route.java @@ -3,7 +3,7 @@ * You may use, distribute and modify this code, please write to: romanov73@gmail.com. */ -package ru.ulstu.extractor.controller; +package ru.ulstu.extractor.core; import org.springframework.stereotype.Component; diff --git a/src/main/java/ru/ulstu/extractor/controller/GitFilteringController.java b/src/main/java/ru/ulstu/extractor/gitrepository/controler/GitFilteringController.java similarity index 91% rename from src/main/java/ru/ulstu/extractor/controller/GitFilteringController.java rename to src/main/java/ru/ulstu/extractor/gitrepository/controler/GitFilteringController.java index 5c036a8..25f9ee7 100644 --- a/src/main/java/ru/ulstu/extractor/controller/GitFilteringController.java +++ b/src/main/java/ru/ulstu/extractor/gitrepository/controler/GitFilteringController.java @@ -3,7 +3,7 @@ * You may use, distribute and modify this code, please write to: romanov73@gmail.com. */ -package ru.ulstu.extractor.controller; +package ru.ulstu.extractor.gitrepository.controler; import org.springframework.data.domain.Page; import org.springframework.stereotype.Controller; @@ -11,10 +11,10 @@ import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; +import ru.ulstu.extractor.core.OffsetablePageRequest; +import ru.ulstu.extractor.gitrepository.model.FilterForm; +import ru.ulstu.extractor.gitrepository.service.FilteringService; import ru.ulstu.extractor.model.Commit; -import ru.ulstu.extractor.model.OffsetablePageRequest; -import ru.ulstu.extractor.model.mvc.FilterForm; -import ru.ulstu.extractor.service.FilteringService; import springfox.documentation.annotations.ApiIgnore; import java.util.List; @@ -22,7 +22,7 @@ import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.IntStream; -import static ru.ulstu.extractor.controller.Route.FILTER_COMMITS; +import static ru.ulstu.extractor.core.Route.FILTER_COMMITS; @Controller @ApiIgnore diff --git a/src/main/java/ru/ulstu/extractor/controller/GitIndexingController.java b/src/main/java/ru/ulstu/extractor/gitrepository/controler/GitIndexingController.java similarity index 87% rename from src/main/java/ru/ulstu/extractor/controller/GitIndexingController.java rename to src/main/java/ru/ulstu/extractor/gitrepository/controler/GitIndexingController.java index 7708a1f..e610db7 100644 --- a/src/main/java/ru/ulstu/extractor/controller/GitIndexingController.java +++ b/src/main/java/ru/ulstu/extractor/gitrepository/controler/GitIndexingController.java @@ -3,7 +3,7 @@ * You may use, distribute and modify this code, please write to: romanov73@gmail.com. */ -package ru.ulstu.extractor.controller; +package ru.ulstu.extractor.gitrepository.controler; import org.eclipse.jgit.api.errors.GitAPIException; import org.slf4j.Logger; @@ -16,17 +16,17 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.mvc.support.RedirectAttributes; import ru.ulstu.extractor.branch.model.Branch; -import ru.ulstu.extractor.gitrepository.GitRepositoryService; -import ru.ulstu.extractor.model.mvc.FilterForm; -import ru.ulstu.extractor.model.mvc.RepoForm; -import ru.ulstu.extractor.service.IndexService; +import ru.ulstu.extractor.gitrepository.model.FilterForm; +import ru.ulstu.extractor.gitrepository.model.RepoForm; +import ru.ulstu.extractor.gitrepository.service.GitRepositoryService; +import ru.ulstu.extractor.gitrepository.service.IndexService; import springfox.documentation.annotations.ApiIgnore; import java.io.IOException; import java.util.List; -import static ru.ulstu.extractor.controller.Route.FILTER_COMMITS; -import static ru.ulstu.extractor.controller.Route.INDEXING_NEW_REPOSITORY; +import static ru.ulstu.extractor.core.Route.FILTER_COMMITS; +import static ru.ulstu.extractor.core.Route.INDEXING_NEW_REPOSITORY; @Controller @ApiIgnore diff --git a/src/main/java/ru/ulstu/extractor/controller/RepoController.java b/src/main/java/ru/ulstu/extractor/gitrepository/controler/RepoController.java similarity index 89% rename from src/main/java/ru/ulstu/extractor/controller/RepoController.java rename to src/main/java/ru/ulstu/extractor/gitrepository/controler/RepoController.java index 847003d..bc14f79 100644 --- a/src/main/java/ru/ulstu/extractor/controller/RepoController.java +++ b/src/main/java/ru/ulstu/extractor/gitrepository/controler/RepoController.java @@ -3,7 +3,7 @@ * You may use, distribute and modify this code, please write to: romanov73@gmail.com. */ -package ru.ulstu.extractor.controller; +package ru.ulstu.extractor.gitrepository.controler; import org.eclipse.jgit.api.errors.GitAPIException; import org.slf4j.Logger; @@ -12,16 +12,16 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import ru.ulstu.extractor.gitrepository.GitRepositoryService; +import ru.ulstu.extractor.gitrepository.service.GitRepositoryService; +import ru.ulstu.extractor.gitrepository.service.IndexService; import ru.ulstu.extractor.model.Commit; -import ru.ulstu.extractor.service.IndexService; import ru.ulstu.extractor.util.HttpUtils; import javax.servlet.http.HttpServletRequest; import java.io.IOException; import java.util.List; -import static ru.ulstu.extractor.controller.RepoController.URL; +import static ru.ulstu.extractor.gitrepository.controler.RepoController.URL; @RestController @RequestMapping(URL) diff --git a/src/main/java/ru/ulstu/extractor/controller/RepositoryController.java b/src/main/java/ru/ulstu/extractor/gitrepository/controler/RepositoryController.java similarity index 82% rename from src/main/java/ru/ulstu/extractor/controller/RepositoryController.java rename to src/main/java/ru/ulstu/extractor/gitrepository/controler/RepositoryController.java index ee5de82..69b643b 100644 --- a/src/main/java/ru/ulstu/extractor/controller/RepositoryController.java +++ b/src/main/java/ru/ulstu/extractor/gitrepository/controler/RepositoryController.java @@ -3,17 +3,17 @@ * You may use, distribute and modify this code, please write to: romanov73@gmail.com. */ -package ru.ulstu.extractor.controller; +package ru.ulstu.extractor.gitrepository.controler; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; -import ru.ulstu.extractor.gitrepository.GitRepositoryRepository; +import ru.ulstu.extractor.gitrepository.repository.GitRepositoryRepository; import springfox.documentation.annotations.ApiIgnore; -import static ru.ulstu.extractor.controller.Route.DELETE_INDEXED_REPOSITORY; -import static ru.ulstu.extractor.controller.Route.LIST_INDEXED_REPOSITORIES; +import static ru.ulstu.extractor.core.Route.DELETE_INDEXED_REPOSITORY; +import static ru.ulstu.extractor.core.Route.LIST_INDEXED_REPOSITORIES; @Controller @ApiIgnore diff --git a/src/main/java/ru/ulstu/extractor/controller/StatisticController.java b/src/main/java/ru/ulstu/extractor/gitrepository/controler/StatisticController.java similarity index 96% rename from src/main/java/ru/ulstu/extractor/controller/StatisticController.java rename to src/main/java/ru/ulstu/extractor/gitrepository/controler/StatisticController.java index 771a5a0..eb2024e 100644 --- a/src/main/java/ru/ulstu/extractor/controller/StatisticController.java +++ b/src/main/java/ru/ulstu/extractor/gitrepository/controler/StatisticController.java @@ -3,7 +3,7 @@ * You may use, distribute and modify this code, please write to: romanov73@gmail.com. */ -package ru.ulstu.extractor.controller; +package ru.ulstu.extractor.gitrepository.controler; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -11,15 +11,15 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import ru.ulstu.extractor.branch.service.BranchService; import ru.ulstu.extractor.commit.repository.CommitRepository; -import ru.ulstu.extractor.model.mvc.FilterForm; -import ru.ulstu.extractor.service.FilteringService; +import ru.ulstu.extractor.gitrepository.model.FilterForm; +import ru.ulstu.extractor.gitrepository.service.FilteringService; import springfox.documentation.annotations.ApiIgnore; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; -import static ru.ulstu.extractor.controller.Route.STATISTIC; +import static ru.ulstu.extractor.core.Route.STATISTIC; @Controller @ApiIgnore diff --git a/src/main/java/ru/ulstu/extractor/model/FileChange.java b/src/main/java/ru/ulstu/extractor/gitrepository/model/FileChange.java similarity index 96% rename from src/main/java/ru/ulstu/extractor/model/FileChange.java rename to src/main/java/ru/ulstu/extractor/gitrepository/model/FileChange.java index 5f33725..65d0815 100644 --- a/src/main/java/ru/ulstu/extractor/model/FileChange.java +++ b/src/main/java/ru/ulstu/extractor/gitrepository/model/FileChange.java @@ -3,10 +3,11 @@ * You may use, distribute and modify this code, please write to: romanov73@gmail.com. */ -package ru.ulstu.extractor.model; +package ru.ulstu.extractor.gitrepository.model; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; +import ru.ulstu.extractor.core.BaseEntity; import javax.persistence.CascadeType; import javax.persistence.Entity; diff --git a/src/main/java/ru/ulstu/extractor/model/mvc/FilterForm.java b/src/main/java/ru/ulstu/extractor/gitrepository/model/FilterForm.java similarity index 97% rename from src/main/java/ru/ulstu/extractor/model/mvc/FilterForm.java rename to src/main/java/ru/ulstu/extractor/gitrepository/model/FilterForm.java index 1db7616..d25271f 100644 --- a/src/main/java/ru/ulstu/extractor/model/mvc/FilterForm.java +++ b/src/main/java/ru/ulstu/extractor/gitrepository/model/FilterForm.java @@ -3,7 +3,7 @@ * You may use, distribute and modify this code, please write to: romanov73@gmail.com. */ -package ru.ulstu.extractor.model.mvc; +package ru.ulstu.extractor.gitrepository.model; import org.springframework.data.domain.Page; import ru.ulstu.extractor.model.Commit; diff --git a/src/main/java/ru/ulstu/extractor/gitrepository/model/GitRepository.java b/src/main/java/ru/ulstu/extractor/gitrepository/model/GitRepository.java index 3d5c605..f2b8276 100644 --- a/src/main/java/ru/ulstu/extractor/gitrepository/model/GitRepository.java +++ b/src/main/java/ru/ulstu/extractor/gitrepository/model/GitRepository.java @@ -1,6 +1,6 @@ package ru.ulstu.extractor.gitrepository.model; -import ru.ulstu.extractor.model.BaseEntity; +import ru.ulstu.extractor.core.BaseEntity; import javax.persistence.Entity; diff --git a/src/main/java/ru/ulstu/extractor/model/LineChange.java b/src/main/java/ru/ulstu/extractor/gitrepository/model/LineChange.java similarity index 93% rename from src/main/java/ru/ulstu/extractor/model/LineChange.java rename to src/main/java/ru/ulstu/extractor/gitrepository/model/LineChange.java index 923909b..99d78b3 100644 --- a/src/main/java/ru/ulstu/extractor/model/LineChange.java +++ b/src/main/java/ru/ulstu/extractor/gitrepository/model/LineChange.java @@ -3,7 +3,9 @@ * You may use, distribute and modify this code, please write to: romanov73@gmail.com. */ -package ru.ulstu.extractor.model; +package ru.ulstu.extractor.gitrepository.model; + +import ru.ulstu.extractor.core.BaseEntity; import javax.persistence.Entity; diff --git a/src/main/java/ru/ulstu/extractor/model/mvc/RepoForm.java b/src/main/java/ru/ulstu/extractor/gitrepository/model/RepoForm.java similarity index 91% rename from src/main/java/ru/ulstu/extractor/model/mvc/RepoForm.java rename to src/main/java/ru/ulstu/extractor/gitrepository/model/RepoForm.java index e0ca0aa..0540820 100644 --- a/src/main/java/ru/ulstu/extractor/model/mvc/RepoForm.java +++ b/src/main/java/ru/ulstu/extractor/gitrepository/model/RepoForm.java @@ -1,4 +1,4 @@ -package ru.ulstu.extractor.model.mvc; +package ru.ulstu.extractor.gitrepository.model; public class RepoForm { private String repo; diff --git a/src/main/java/ru/ulstu/extractor/gitrepository/GitRepositoryRepository.java b/src/main/java/ru/ulstu/extractor/gitrepository/repository/GitRepositoryRepository.java similarity index 82% rename from src/main/java/ru/ulstu/extractor/gitrepository/GitRepositoryRepository.java rename to src/main/java/ru/ulstu/extractor/gitrepository/repository/GitRepositoryRepository.java index ae9e821..40307d7 100644 --- a/src/main/java/ru/ulstu/extractor/gitrepository/GitRepositoryRepository.java +++ b/src/main/java/ru/ulstu/extractor/gitrepository/repository/GitRepositoryRepository.java @@ -1,4 +1,4 @@ -package ru.ulstu.extractor.gitrepository; +package ru.ulstu.extractor.gitrepository.repository; import org.springframework.data.jpa.repository.JpaRepository; import ru.ulstu.extractor.gitrepository.model.GitRepository; diff --git a/src/main/java/ru/ulstu/extractor/service/FilteringService.java b/src/main/java/ru/ulstu/extractor/gitrepository/service/FilteringService.java similarity index 92% rename from src/main/java/ru/ulstu/extractor/service/FilteringService.java rename to src/main/java/ru/ulstu/extractor/gitrepository/service/FilteringService.java index ddeda0c..ccc29de 100644 --- a/src/main/java/ru/ulstu/extractor/service/FilteringService.java +++ b/src/main/java/ru/ulstu/extractor/gitrepository/service/FilteringService.java @@ -3,16 +3,16 @@ * You may use, distribute and modify this code, please write to: romanov73@gmail.com. */ -package ru.ulstu.extractor.service; +package ru.ulstu.extractor.gitrepository.service; import com.sun.istack.NotNull; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import ru.ulstu.extractor.author.repository.AuthorRepository; import ru.ulstu.extractor.commit.repository.CommitRepository; -import ru.ulstu.extractor.gitrepository.GitRepositoryRepository; +import ru.ulstu.extractor.gitrepository.repository.GitRepositoryRepository; import ru.ulstu.extractor.model.Commit; -import ru.ulstu.extractor.repository.AuthorRepository; import java.util.List; import java.util.Map; diff --git a/src/main/java/ru/ulstu/extractor/gitrepository/GitRepositoryService.java b/src/main/java/ru/ulstu/extractor/gitrepository/service/GitRepositoryService.java similarity index 98% rename from src/main/java/ru/ulstu/extractor/gitrepository/GitRepositoryService.java rename to src/main/java/ru/ulstu/extractor/gitrepository/service/GitRepositoryService.java index 934f920..78038ad 100644 --- a/src/main/java/ru/ulstu/extractor/gitrepository/GitRepositoryService.java +++ b/src/main/java/ru/ulstu/extractor/gitrepository/service/GitRepositoryService.java @@ -1,4 +1,4 @@ -package ru.ulstu.extractor.gitrepository; +package ru.ulstu.extractor.gitrepository.service; import org.apache.commons.io.FileUtils; import org.eclipse.jgit.api.CreateBranchCommand; @@ -18,16 +18,17 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import ru.ulstu.extractor.author.model.Author; import ru.ulstu.extractor.branch.model.Branch; +import ru.ulstu.extractor.gitrepository.model.FileChange; import ru.ulstu.extractor.gitrepository.model.GitRepository; +import ru.ulstu.extractor.gitrepository.model.LineChange; +import ru.ulstu.extractor.gitrepository.repository.GitRepositoryRepository; import ru.ulstu.extractor.heuristic.model.BusinessLogicUnit; import ru.ulstu.extractor.heuristic.model.EntityUnit; import ru.ulstu.extractor.heuristic.model.ResourceUnit; import ru.ulstu.extractor.heuristic.service.StructuralUnitService; -import ru.ulstu.extractor.model.Author; import ru.ulstu.extractor.model.Commit; -import ru.ulstu.extractor.model.FileChange; -import ru.ulstu.extractor.model.LineChange; import java.io.ByteArrayOutputStream; import java.io.File; diff --git a/src/main/java/ru/ulstu/extractor/service/IndexService.java b/src/main/java/ru/ulstu/extractor/gitrepository/service/IndexService.java similarity index 93% rename from src/main/java/ru/ulstu/extractor/service/IndexService.java rename to src/main/java/ru/ulstu/extractor/gitrepository/service/IndexService.java index d5415e2..5d2c1c2 100644 --- a/src/main/java/ru/ulstu/extractor/service/IndexService.java +++ b/src/main/java/ru/ulstu/extractor/gitrepository/service/IndexService.java @@ -3,7 +3,7 @@ * You may use, distribute and modify this code, please write to: romanov73@gmail.com. */ -package ru.ulstu.extractor.service; +package ru.ulstu.extractor.gitrepository.service; import com.sun.istack.NotNull; import org.eclipse.jgit.api.errors.GitAPIException; @@ -12,11 +12,10 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import ru.ulstu.extractor.branch.model.Branch; import ru.ulstu.extractor.branch.service.BranchService; -import ru.ulstu.extractor.gitrepository.GitRepositoryRepository; -import ru.ulstu.extractor.gitrepository.GitRepositoryService; import ru.ulstu.extractor.gitrepository.model.GitRepository; +import ru.ulstu.extractor.gitrepository.repository.GitRepositoryRepository; import ru.ulstu.extractor.model.Commit; -import ru.ulstu.extractor.ts.AbstractTimeSeriesCreator; +import ru.ulstu.extractor.ts.creator.AbstractTimeSeriesCreator; import java.io.IOException; import java.util.Collections; diff --git a/src/main/java/ru/ulstu/extractor/heuristic/controller/StructuralUnitController.java b/src/main/java/ru/ulstu/extractor/heuristic/controller/StructuralUnitController.java index ccedc05..db95ab2 100644 --- a/src/main/java/ru/ulstu/extractor/heuristic/controller/StructuralUnitController.java +++ b/src/main/java/ru/ulstu/extractor/heuristic/controller/StructuralUnitController.java @@ -11,7 +11,7 @@ import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import ru.ulstu.extractor.gitrepository.GitRepositoryService; +import ru.ulstu.extractor.gitrepository.service.GitRepositoryService; import ru.ulstu.extractor.heuristic.model.BusinessLogicUnit; import ru.ulstu.extractor.heuristic.model.EntityUnit; import ru.ulstu.extractor.heuristic.model.ResourceUnit; diff --git a/src/main/java/ru/ulstu/extractor/http/JsonTimeSeries.java b/src/main/java/ru/ulstu/extractor/http/JsonTimeSeries.java index 71506d1..957869c 100644 --- a/src/main/java/ru/ulstu/extractor/http/JsonTimeSeries.java +++ b/src/main/java/ru/ulstu/extractor/http/JsonTimeSeries.java @@ -1,6 +1,6 @@ package ru.ulstu.extractor.http; -import ru.ulstu.extractor.model.TimeSeries; +import ru.ulstu.extractor.ts.model.TimeSeries; import java.util.List; import java.util.stream.Collectors; diff --git a/src/main/java/ru/ulstu/extractor/http/JsonTimeSeriesValue.java b/src/main/java/ru/ulstu/extractor/http/JsonTimeSeriesValue.java index f615f7d..a50681c 100644 --- a/src/main/java/ru/ulstu/extractor/http/JsonTimeSeriesValue.java +++ b/src/main/java/ru/ulstu/extractor/http/JsonTimeSeriesValue.java @@ -1,6 +1,6 @@ package ru.ulstu.extractor.http; -import ru.ulstu.extractor.model.TimeSeriesValue; +import ru.ulstu.extractor.ts.model.TimeSeriesValue; import java.time.LocalDateTime; import java.time.ZoneId; diff --git a/src/main/java/ru/ulstu/extractor/controller/RuleController.java b/src/main/java/ru/ulstu/extractor/rule/controller/RuleController.java similarity index 73% rename from src/main/java/ru/ulstu/extractor/controller/RuleController.java rename to src/main/java/ru/ulstu/extractor/rule/controller/RuleController.java index 038005b..7aeeff1 100644 --- a/src/main/java/ru/ulstu/extractor/controller/RuleController.java +++ b/src/main/java/ru/ulstu/extractor/rule/controller/RuleController.java @@ -1,4 +1,4 @@ -package ru.ulstu.extractor.controller; +package ru.ulstu.extractor.rule.controller; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -7,14 +7,14 @@ import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.mvc.support.RedirectAttributes; -import ru.ulstu.extractor.model.mvc.AddRuleForm; -import ru.ulstu.extractor.service.AntecedentValueService; -import ru.ulstu.extractor.service.RuleService; -import ru.ulstu.extractor.service.TimeSeriesService; +import ru.ulstu.extractor.rule.model.AddRuleForm; +import ru.ulstu.extractor.rule.service.AntecedentValueService; +import ru.ulstu.extractor.rule.service.RuleService; +import ru.ulstu.extractor.ts.service.TimeSeriesService; import springfox.documentation.annotations.ApiIgnore; -import static ru.ulstu.extractor.controller.Route.ADD_RULE; -import static ru.ulstu.extractor.controller.Route.LIST_RULE; +import static ru.ulstu.extractor.core.Route.ADD_RULE; +import static ru.ulstu.extractor.core.Route.LIST_RULE; @Controller @ApiIgnore @@ -23,7 +23,9 @@ public class RuleController { private final AntecedentValueService antecedentValueService; private final TimeSeriesService timeSeriesService; - public RuleController(RuleService ruleService, AntecedentValueService antecedentValueService, TimeSeriesService timeSeriesService) { + public RuleController(RuleService ruleService, + AntecedentValueService antecedentValueService, + TimeSeriesService timeSeriesService) { this.ruleService = ruleService; this.antecedentValueService = antecedentValueService; this.timeSeriesService = timeSeriesService; @@ -38,7 +40,7 @@ public class RuleController { @GetMapping(ADD_RULE) public String getAntecedent(Model model) { model.addAttribute("antecedentValues", antecedentValueService.getList()); - model.addAttribute("antecedents", timeSeriesService.getAllTimeSeries()); + model.addAttribute("antecedents", timeSeriesService.getAllTimeSeriesTypes()); model.addAttribute("addRuleForm", new AddRuleForm()); return ADD_RULE; } diff --git a/src/main/java/ru/ulstu/extractor/model/mvc/AddRuleForm.java b/src/main/java/ru/ulstu/extractor/rule/model/AddRuleForm.java similarity index 81% rename from src/main/java/ru/ulstu/extractor/model/mvc/AddRuleForm.java rename to src/main/java/ru/ulstu/extractor/rule/model/AddRuleForm.java index cf164d8..3b64bdd 100644 --- a/src/main/java/ru/ulstu/extractor/model/mvc/AddRuleForm.java +++ b/src/main/java/ru/ulstu/extractor/rule/model/AddRuleForm.java @@ -1,10 +1,10 @@ -package ru.ulstu.extractor.model.mvc; +package ru.ulstu.extractor.rule.model; public class AddRuleForm { private Integer firstAntecedentValueId; - private Integer firstAntecedentId; + private String firstAntecedentId; private Integer secondAntecedentValueId; - private Integer secondAntecedentId; + private String secondAntecedentId; private String consequent; public AddRuleForm() { @@ -18,11 +18,11 @@ public class AddRuleForm { this.firstAntecedentValueId = firstAntecedentValueId; } - public Integer getFirstAntecedentId() { + public String getFirstAntecedentId() { return firstAntecedentId; } - public void setFirstAntecedentId(Integer firstAntecedentId) { + public void setFirstAntecedentId(String firstAntecedentId) { this.firstAntecedentId = firstAntecedentId; } @@ -34,11 +34,11 @@ public class AddRuleForm { this.secondAntecedentValueId = secondAntecedentValueId; } - public Integer getSecondAntecedentId() { + public String getSecondAntecedentId() { return secondAntecedentId; } - public void setSecondAntecedentId(Integer secondAntecedentId) { + public void setSecondAntecedentId(String secondAntecedentId) { this.secondAntecedentId = secondAntecedentId; } diff --git a/src/main/java/ru/ulstu/extractor/model/AntecedentValue.java b/src/main/java/ru/ulstu/extractor/rule/model/AntecedentValue.java similarity index 85% rename from src/main/java/ru/ulstu/extractor/model/AntecedentValue.java rename to src/main/java/ru/ulstu/extractor/rule/model/AntecedentValue.java index 1ed3473..39b5eb6 100644 --- a/src/main/java/ru/ulstu/extractor/model/AntecedentValue.java +++ b/src/main/java/ru/ulstu/extractor/rule/model/AntecedentValue.java @@ -1,4 +1,6 @@ -package ru.ulstu.extractor.model; +package ru.ulstu.extractor.rule.model; + +import ru.ulstu.extractor.core.BaseEntity; import javax.persistence.Entity; diff --git a/src/main/java/ru/ulstu/extractor/model/Rule.java b/src/main/java/ru/ulstu/extractor/rule/model/Rule.java similarity index 60% rename from src/main/java/ru/ulstu/extractor/model/Rule.java rename to src/main/java/ru/ulstu/extractor/rule/model/Rule.java index baf8565..73d015c 100644 --- a/src/main/java/ru/ulstu/extractor/model/Rule.java +++ b/src/main/java/ru/ulstu/extractor/rule/model/Rule.java @@ -1,6 +1,11 @@ -package ru.ulstu.extractor.model; +package ru.ulstu.extractor.rule.model; + +import ru.ulstu.extractor.core.BaseEntity; +import ru.ulstu.extractor.ts.model.TimeSeriesType; import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; import javax.persistence.ManyToOne; @Entity @@ -8,14 +13,14 @@ public class Rule extends BaseEntity { @ManyToOne private AntecedentValue firstAntecedentValue; - @ManyToOne - private TimeSeries firstAntecedent; + @Enumerated(EnumType.STRING) + private TimeSeriesType firstAntecedent; @ManyToOne private AntecedentValue secondAntecedentValue; - @ManyToOne - private TimeSeries secondAntecedent; + @Enumerated(EnumType.STRING) + private TimeSeriesType secondAntecedent; private String consequent; @@ -23,9 +28,9 @@ public class Rule extends BaseEntity { } public Rule(AntecedentValue firstAntecedentValue, - TimeSeries firstAntecedent, + TimeSeriesType firstAntecedent, AntecedentValue secondAntecedentValue, - TimeSeries secondAntecedent, + TimeSeriesType secondAntecedent, String consequent) { this.firstAntecedentValue = firstAntecedentValue; this.firstAntecedent = firstAntecedent; @@ -34,21 +39,6 @@ public class Rule extends BaseEntity { this.consequent = consequent; } - public Rule(Integer id, - Integer version, - AntecedentValue firstAntecedentValue, - TimeSeries firstAntecedent, - AntecedentValue secondAntecedentValue, - TimeSeries secondAntecedent, - String consequent) { - super(id, version); - this.firstAntecedentValue = firstAntecedentValue; - this.firstAntecedent = firstAntecedent; - this.secondAntecedentValue = secondAntecedentValue; - this.secondAntecedent = secondAntecedent; - this.consequent = consequent; - } - public AntecedentValue getFirstAntecedentValue() { return firstAntecedentValue; } @@ -57,11 +47,11 @@ public class Rule extends BaseEntity { this.firstAntecedentValue = firstAntecedentValue; } - public TimeSeries getFirstAntecedent() { + public TimeSeriesType getFirstAntecedent() { return firstAntecedent; } - public void setFirstAntecedent(TimeSeries firstAntecedent) { + public void setFirstAntecedent(TimeSeriesType firstAntecedent) { this.firstAntecedent = firstAntecedent; } @@ -73,11 +63,11 @@ public class Rule extends BaseEntity { this.secondAntecedentValue = secondAntecedentValue; } - public TimeSeries getSecondAntecedent() { + public TimeSeriesType getSecondAntecedent() { return secondAntecedent; } - public void setSecondAntecedent(TimeSeries secondAntecedent) { + public void setSecondAntecedent(TimeSeriesType secondAntecedent) { this.secondAntecedent = secondAntecedent; } diff --git a/src/main/java/ru/ulstu/extractor/repository/AntecedentValueRepository.java b/src/main/java/ru/ulstu/extractor/rule/repository/AntecedentValueRepository.java similarity index 62% rename from src/main/java/ru/ulstu/extractor/repository/AntecedentValueRepository.java rename to src/main/java/ru/ulstu/extractor/rule/repository/AntecedentValueRepository.java index 86ea561..1ea84d7 100644 --- a/src/main/java/ru/ulstu/extractor/repository/AntecedentValueRepository.java +++ b/src/main/java/ru/ulstu/extractor/rule/repository/AntecedentValueRepository.java @@ -1,8 +1,8 @@ -package ru.ulstu.extractor.repository; +package ru.ulstu.extractor.rule.repository; import org.springframework.data.jpa.repository.JpaRepository; -import ru.ulstu.extractor.model.AntecedentValue; +import ru.ulstu.extractor.rule.model.AntecedentValue; public interface AntecedentValueRepository extends JpaRepository { } diff --git a/src/main/java/ru/ulstu/extractor/repository/RuleRepository.java b/src/main/java/ru/ulstu/extractor/rule/repository/RuleRepository.java similarity index 61% rename from src/main/java/ru/ulstu/extractor/repository/RuleRepository.java rename to src/main/java/ru/ulstu/extractor/rule/repository/RuleRepository.java index e931488..2504386 100644 --- a/src/main/java/ru/ulstu/extractor/repository/RuleRepository.java +++ b/src/main/java/ru/ulstu/extractor/rule/repository/RuleRepository.java @@ -1,7 +1,7 @@ -package ru.ulstu.extractor.repository; +package ru.ulstu.extractor.rule.repository; import org.springframework.data.jpa.repository.JpaRepository; -import ru.ulstu.extractor.model.Rule; +import ru.ulstu.extractor.rule.model.Rule; public interface RuleRepository extends JpaRepository { } diff --git a/src/main/java/ru/ulstu/extractor/service/AntecedentValueService.java b/src/main/java/ru/ulstu/extractor/rule/service/AntecedentValueService.java similarity index 81% rename from src/main/java/ru/ulstu/extractor/service/AntecedentValueService.java rename to src/main/java/ru/ulstu/extractor/rule/service/AntecedentValueService.java index e2c48e6..ef3c124 100644 --- a/src/main/java/ru/ulstu/extractor/service/AntecedentValueService.java +++ b/src/main/java/ru/ulstu/extractor/rule/service/AntecedentValueService.java @@ -1,8 +1,8 @@ -package ru.ulstu.extractor.service; +package ru.ulstu.extractor.rule.service; import org.springframework.stereotype.Service; -import ru.ulstu.extractor.model.AntecedentValue; -import ru.ulstu.extractor.repository.AntecedentValueRepository; +import ru.ulstu.extractor.rule.model.AntecedentValue; +import ru.ulstu.extractor.rule.repository.AntecedentValueRepository; import java.util.List; diff --git a/src/main/java/ru/ulstu/extractor/service/RuleService.java b/src/main/java/ru/ulstu/extractor/rule/service/RuleService.java similarity index 69% rename from src/main/java/ru/ulstu/extractor/service/RuleService.java rename to src/main/java/ru/ulstu/extractor/rule/service/RuleService.java index 5c8acd7..63413b9 100644 --- a/src/main/java/ru/ulstu/extractor/service/RuleService.java +++ b/src/main/java/ru/ulstu/extractor/rule/service/RuleService.java @@ -1,9 +1,11 @@ -package ru.ulstu.extractor.service; +package ru.ulstu.extractor.rule.service; import org.springframework.stereotype.Service; -import ru.ulstu.extractor.model.Rule; -import ru.ulstu.extractor.model.mvc.AddRuleForm; -import ru.ulstu.extractor.repository.RuleRepository; +import ru.ulstu.extractor.rule.model.AddRuleForm; +import ru.ulstu.extractor.rule.model.Rule; +import ru.ulstu.extractor.rule.repository.RuleRepository; +import ru.ulstu.extractor.ts.model.TimeSeriesType; +import ru.ulstu.extractor.ts.service.TimeSeriesService; import java.util.List; @@ -27,9 +29,9 @@ public class RuleService { public void saveRule(AddRuleForm addRuleForm) { ruleRepository.save(new Rule(antecedentValueService.getById(addRuleForm.getFirstAntecedentValueId()), - timeSeriesService.getById(addRuleForm.getFirstAntecedentId()), + TimeSeriesType.valueOf(addRuleForm.getFirstAntecedentId()), antecedentValueService.getById(addRuleForm.getSecondAntecedentValueId()), - timeSeriesService.getById(addRuleForm.getSecondAntecedentId()), + TimeSeriesType.valueOf(addRuleForm.getSecondAntecedentId()), addRuleForm.getConsequent())); } } diff --git a/src/main/java/ru/ulstu/extractor/ts/AbstractTimeSeriesCreator.java b/src/main/java/ru/ulstu/extractor/ts/AbstractTimeSeriesCreator.java deleted file mode 100644 index 07b516b..0000000 --- a/src/main/java/ru/ulstu/extractor/ts/AbstractTimeSeriesCreator.java +++ /dev/null @@ -1,48 +0,0 @@ -package ru.ulstu.extractor.ts; - -import ru.ulstu.extractor.model.TimeSeriesValue; -import ru.ulstu.extractor.service.TimeSeriesService; - -import java.util.Comparator; -import java.util.List; -import java.util.Map; - -import static ru.ulstu.extractor.ts.TimeSeriesDateMapper.mapTimeSeriesToInterval; - -public abstract class AbstractTimeSeriesCreator { - - public abstract String getTimeSeriesName(); - - /** - * Извлечь список точек временных рядов - * - * @param repositoryId - * @param branchName - * @return - */ - public abstract Map> getTimeSeriesValues(Integer repositoryId, String branchName); - - public abstract TimeSeriesService getTimeSeriesService(); - - /** - * Сохранить извлеченные временные ряды - * - * @param repositoryId - * @param branchName - */ - public void addTimeSeries(Integer repositoryId, String branchName) { - // извлеченные точки временных рядов - Map> timeSeriesValues = getTimeSeriesValues(repositoryId, branchName); - - // сгруппированные по временным интервалам точки временных рядов - timeSeriesValues.replaceAll((k, v) -> mapTimeSeriesToInterval(getTimeSeriesService().getTimeSeriesInterval(), v)); - getTimeSeriesService().save(sortTimeSeriesValues(timeSeriesValues)); - } - - private Map> sortTimeSeriesValues(Map> timeSeriesValues) { - for (Map.Entry> entry : timeSeriesValues.entrySet()) { - entry.getValue().sort(Comparator.comparing(TimeSeriesValue::getDate)); - } - return timeSeriesValues; - } -} diff --git a/src/main/java/ru/ulstu/extractor/ts/AuthorsCommentTS.java b/src/main/java/ru/ulstu/extractor/ts/AuthorsCommentTS.java deleted file mode 100644 index 62ea9a7..0000000 --- a/src/main/java/ru/ulstu/extractor/ts/AuthorsCommentTS.java +++ /dev/null @@ -1,33 +0,0 @@ -package ru.ulstu.extractor.ts; - -import org.springframework.stereotype.Component; -import ru.ulstu.extractor.model.TimeSeriesValue; -import ru.ulstu.extractor.service.TimeSeriesService; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Component -public class AuthorsCommentTS extends AbstractTimeSeriesCreator { - private final TimeSeriesService timeSeriesService; - - public AuthorsCommentTS(TimeSeriesService timeSeriesService) { - this.timeSeriesService = timeSeriesService; - } - - @Override - public String getTimeSeriesName() { - return "Количество коммитов авторов"; - } - - @Override - public Map> getTimeSeriesValues(Integer repositoryId, String branchName) { - return new HashMap<>(); - } - - @Override - public TimeSeriesService getTimeSeriesService() { - return timeSeriesService; - } -} diff --git a/src/main/java/ru/ulstu/extractor/ts/CommitsTS.java b/src/main/java/ru/ulstu/extractor/ts/CommitsTS.java deleted file mode 100644 index 2196c20..0000000 --- a/src/main/java/ru/ulstu/extractor/ts/CommitsTS.java +++ /dev/null @@ -1,51 +0,0 @@ -package ru.ulstu.extractor.ts; - -import org.springframework.stereotype.Component; -import ru.ulstu.extractor.commit.service.CommitService; -import ru.ulstu.extractor.gitrepository.GitRepositoryService; -import ru.ulstu.extractor.model.TimeSeriesValue; -import ru.ulstu.extractor.service.TimeSeriesService; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -@Component -public class CommitsTS extends AbstractTimeSeriesCreator { - private final TimeSeriesService timeSeriesService; - private final CommitService commitService; - private final GitRepositoryService gitRepositoryService; - - public CommitsTS(TimeSeriesService timeSeriesService, - CommitService commitService, - GitRepositoryService gitRepositoryService) { - this.timeSeriesService = timeSeriesService; - this.commitService = commitService; - this.gitRepositoryService = gitRepositoryService; - } - - @Override - public String getTimeSeriesName() { - return "Количество коммитов во времени"; - } - - @Override - public Map> getTimeSeriesValues(Integer repositoryId, String branchName) { - //TODO: добавить постраничное чтение - Map> result = new HashMap<>(); - result.put(String.format("%s %s %s", gitRepositoryService.findById(repositoryId).getName(), - branchName, - getTimeSeriesName()), - commitService.findByRepositoryIdAndName(repositoryId, branchName) - .stream() - .map(c -> new TimeSeriesValue(c.getDate(), 1.0)) - .collect(Collectors.toList())); - return result; - } - - @Override - public TimeSeriesService getTimeSeriesService() { - return timeSeriesService; - } -} diff --git a/src/main/java/ru/ulstu/extractor/ts/creator/AbstractTimeSeriesCreator.java b/src/main/java/ru/ulstu/extractor/ts/creator/AbstractTimeSeriesCreator.java new file mode 100644 index 0000000..0f470f5 --- /dev/null +++ b/src/main/java/ru/ulstu/extractor/ts/creator/AbstractTimeSeriesCreator.java @@ -0,0 +1,49 @@ +package ru.ulstu.extractor.ts.creator; + +import ru.ulstu.extractor.ts.model.TimeSeries; +import ru.ulstu.extractor.ts.model.TimeSeriesType; +import ru.ulstu.extractor.ts.model.TimeSeriesValue; +import ru.ulstu.extractor.ts.service.TimeSeriesService; + +import java.util.Comparator; +import java.util.List; + +import static ru.ulstu.extractor.ts.util.TimeSeriesDateMapper.mapTimeSeriesToInterval; + +public abstract class AbstractTimeSeriesCreator { + + public abstract TimeSeriesType getTimeSeriesType(); + + /** + * Извлечь список точек временных рядов + * + * @param repositoryId + * @param branchName + * @return + */ + public abstract List getTimeSeries(Integer repositoryId, String branchName); + + public abstract TimeSeriesService getTimeSeriesService(); + + /** + * Сохранить извлеченные временные ряды + * + * @param repositoryId + * @param branchName + */ + public void addTimeSeries(Integer repositoryId, String branchName) { + // извлеченные временных рядов + List timeSeries = getTimeSeries(repositoryId, branchName); + + // сгруппированные по временным интервалам точки временных рядов + timeSeries.forEach(ts -> ts.setValues(mapTimeSeriesToInterval(getTimeSeriesService().getTimeSeriesInterval(), ts.getValues()))); + getTimeSeriesService().save(sortTimeSeries(timeSeries)); + } + + private List sortTimeSeries(List timeSeries) { + for (TimeSeries ts : timeSeries) { + ts.getValues().sort(Comparator.comparing(TimeSeriesValue::getDate)); + } + return timeSeries; + } +} diff --git a/src/main/java/ru/ulstu/extractor/ts/AuthorTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/AuthorTS.java similarity index 52% rename from src/main/java/ru/ulstu/extractor/ts/AuthorTS.java rename to src/main/java/ru/ulstu/extractor/ts/creator/AuthorTS.java index a6d01dc..ae71399 100644 --- a/src/main/java/ru/ulstu/extractor/ts/AuthorTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/AuthorTS.java @@ -1,12 +1,12 @@ -package ru.ulstu.extractor.ts; +package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; -import ru.ulstu.extractor.model.TimeSeriesValue; -import ru.ulstu.extractor.service.TimeSeriesService; +import ru.ulstu.extractor.ts.model.TimeSeries; +import ru.ulstu.extractor.ts.model.TimeSeriesType; +import ru.ulstu.extractor.ts.service.TimeSeriesService; -import java.util.HashMap; +import java.util.ArrayList; import java.util.List; -import java.util.Map; @Component public class AuthorTS extends AbstractTimeSeriesCreator { @@ -17,13 +17,13 @@ public class AuthorTS extends AbstractTimeSeriesCreator { } @Override - public String getTimeSeriesName() { - return "Количество Авторов"; + public TimeSeriesType getTimeSeriesType() { + return TimeSeriesType.AUTHORS; } @Override - public Map> getTimeSeriesValues(Integer repositoryId, String branchName) { - return new HashMap<>(); + public List getTimeSeries(Integer repositoryId, String branchName) { + return new ArrayList<>(); } @Override diff --git a/src/main/java/ru/ulstu/extractor/ts/creator/AuthorsCommitTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/AuthorsCommitTS.java new file mode 100644 index 0000000..4be4592 --- /dev/null +++ b/src/main/java/ru/ulstu/extractor/ts/creator/AuthorsCommitTS.java @@ -0,0 +1,33 @@ +package ru.ulstu.extractor.ts.creator; + +import org.springframework.stereotype.Component; +import ru.ulstu.extractor.ts.model.TimeSeries; +import ru.ulstu.extractor.ts.model.TimeSeriesType; +import ru.ulstu.extractor.ts.service.TimeSeriesService; + +import java.util.ArrayList; +import java.util.List; + +@Component +public class AuthorsCommitTS extends AbstractTimeSeriesCreator { + private final TimeSeriesService timeSeriesService; + + public AuthorsCommitTS(TimeSeriesService timeSeriesService) { + this.timeSeriesService = timeSeriesService; + } + + @Override + public TimeSeriesType getTimeSeriesType() { + return TimeSeriesType.AUTHOR_COMMITS; + } + + @Override + public List getTimeSeries(Integer repositoryId, String branchName) { + return new ArrayList(); + } + + @Override + public TimeSeriesService getTimeSeriesService() { + return timeSeriesService; + } +} diff --git a/src/main/java/ru/ulstu/extractor/ts/AuthorsCompletedIssueTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/AuthorsCompletedIssueTS.java similarity index 52% rename from src/main/java/ru/ulstu/extractor/ts/AuthorsCompletedIssueTS.java rename to src/main/java/ru/ulstu/extractor/ts/creator/AuthorsCompletedIssueTS.java index 7453fdb..1fa3ebb 100644 --- a/src/main/java/ru/ulstu/extractor/ts/AuthorsCompletedIssueTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/AuthorsCompletedIssueTS.java @@ -1,12 +1,12 @@ -package ru.ulstu.extractor.ts; +package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; -import ru.ulstu.extractor.model.TimeSeriesValue; -import ru.ulstu.extractor.service.TimeSeriesService; +import ru.ulstu.extractor.ts.model.TimeSeries; +import ru.ulstu.extractor.ts.model.TimeSeriesType; +import ru.ulstu.extractor.ts.service.TimeSeriesService; -import java.util.HashMap; +import java.util.ArrayList; import java.util.List; -import java.util.Map; @Component public class AuthorsCompletedIssueTS extends AbstractTimeSeriesCreator { @@ -17,17 +17,17 @@ public class AuthorsCompletedIssueTS extends AbstractTimeSeriesCreator { } @Override - public String getTimeSeriesName() { - return "Количество выполненных issues авторов"; - } - - @Override - public Map> getTimeSeriesValues(Integer repositoryId, String branchName) { - return new HashMap<>(); + public List getTimeSeries(Integer repositoryId, String branchName) { + return new ArrayList<>(); } @Override public TimeSeriesService getTimeSeriesService() { return timeSeriesService; } + + @Override + public TimeSeriesType getTimeSeriesType() { + return TimeSeriesType.AUTHOR_COMPLETED_ISSUES; + } } diff --git a/src/main/java/ru/ulstu/extractor/ts/AuthorsIssueTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/AuthorsIssueTS.java similarity index 52% rename from src/main/java/ru/ulstu/extractor/ts/AuthorsIssueTS.java rename to src/main/java/ru/ulstu/extractor/ts/creator/AuthorsIssueTS.java index d7318da..4ba5df2 100644 --- a/src/main/java/ru/ulstu/extractor/ts/AuthorsIssueTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/AuthorsIssueTS.java @@ -1,12 +1,12 @@ -package ru.ulstu.extractor.ts; +package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; -import ru.ulstu.extractor.model.TimeSeriesValue; -import ru.ulstu.extractor.service.TimeSeriesService; +import ru.ulstu.extractor.ts.model.TimeSeries; +import ru.ulstu.extractor.ts.model.TimeSeriesType; +import ru.ulstu.extractor.ts.service.TimeSeriesService; -import java.util.HashMap; +import java.util.ArrayList; import java.util.List; -import java.util.Map; @Component public class AuthorsIssueTS extends AbstractTimeSeriesCreator { @@ -17,17 +17,17 @@ public class AuthorsIssueTS extends AbstractTimeSeriesCreator { } @Override - public String getTimeSeriesName() { - return "Количество issues авторов"; - } - - @Override - public Map> getTimeSeriesValues(Integer repositoryId, String branchName) { - return new HashMap<>(); + public List getTimeSeries(Integer repositoryId, String branchName) { + return new ArrayList(); } @Override public TimeSeriesService getTimeSeriesService() { return timeSeriesService; } + + @Override + public TimeSeriesType getTimeSeriesType() { + return TimeSeriesType.AUTHOR_ISSUES; + } } diff --git a/src/main/java/ru/ulstu/extractor/ts/BranchTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/BranchTS.java similarity index 52% rename from src/main/java/ru/ulstu/extractor/ts/BranchTS.java rename to src/main/java/ru/ulstu/extractor/ts/creator/BranchTS.java index 6233909..aa6592e 100644 --- a/src/main/java/ru/ulstu/extractor/ts/BranchTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/BranchTS.java @@ -1,12 +1,12 @@ -package ru.ulstu.extractor.ts; +package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; -import ru.ulstu.extractor.model.TimeSeriesValue; -import ru.ulstu.extractor.service.TimeSeriesService; +import ru.ulstu.extractor.ts.model.TimeSeries; +import ru.ulstu.extractor.ts.model.TimeSeriesType; +import ru.ulstu.extractor.ts.service.TimeSeriesService; -import java.util.HashMap; +import java.util.ArrayList; import java.util.List; -import java.util.Map; @Component public class BranchTS extends AbstractTimeSeriesCreator { @@ -17,13 +17,13 @@ public class BranchTS extends AbstractTimeSeriesCreator { } @Override - public String getTimeSeriesName() { - return "Количество веток"; + public TimeSeriesType getTimeSeriesType() { + return TimeSeriesType.BRANCHES; } @Override - public Map> getTimeSeriesValues(Integer repositoryId, String branchName) { - return new HashMap<>(); + public List getTimeSeries(Integer repositoryId, String branchName) { + return new ArrayList<>(); } @Override diff --git a/src/main/java/ru/ulstu/extractor/ts/ClassTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/ClassTS.java similarity index 51% rename from src/main/java/ru/ulstu/extractor/ts/ClassTS.java rename to src/main/java/ru/ulstu/extractor/ts/creator/ClassTS.java index 1fdf504..2e7e8ea 100644 --- a/src/main/java/ru/ulstu/extractor/ts/ClassTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/ClassTS.java @@ -1,12 +1,12 @@ -package ru.ulstu.extractor.ts; +package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; -import ru.ulstu.extractor.model.TimeSeriesValue; -import ru.ulstu.extractor.service.TimeSeriesService; +import ru.ulstu.extractor.ts.model.TimeSeries; +import ru.ulstu.extractor.ts.model.TimeSeriesType; +import ru.ulstu.extractor.ts.service.TimeSeriesService; -import java.util.HashMap; +import java.util.ArrayList; import java.util.List; -import java.util.Map; @Component public class ClassTS extends AbstractTimeSeriesCreator { @@ -17,17 +17,17 @@ public class ClassTS extends AbstractTimeSeriesCreator { } @Override - public String getTimeSeriesName() { - return "Количество классов"; - } - - @Override - public Map> getTimeSeriesValues(Integer repositoryId, String branchName) { - return new HashMap<>(); + public List getTimeSeries(Integer repositoryId, String branchName) { + return new ArrayList(); } @Override public TimeSeriesService getTimeSeriesService() { return timeSeriesService; } + + @Override + public TimeSeriesType getTimeSeriesType() { + return TimeSeriesType.CLASSES; + } } diff --git a/src/main/java/ru/ulstu/extractor/ts/creator/CommitsTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/CommitsTS.java new file mode 100644 index 0000000..c686a90 --- /dev/null +++ b/src/main/java/ru/ulstu/extractor/ts/creator/CommitsTS.java @@ -0,0 +1,54 @@ +package ru.ulstu.extractor.ts.creator; + +import org.springframework.stereotype.Component; +import ru.ulstu.extractor.commit.service.CommitService; +import ru.ulstu.extractor.gitrepository.service.GitRepositoryService; +import ru.ulstu.extractor.ts.model.TimeSeries; +import ru.ulstu.extractor.ts.model.TimeSeriesType; +import ru.ulstu.extractor.ts.model.TimeSeriesValue; +import ru.ulstu.extractor.ts.service.TimeSeriesService; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +@Component +public class CommitsTS extends AbstractTimeSeriesCreator { + private final TimeSeriesService timeSeriesService; + private final CommitService commitService; + private final GitRepositoryService gitRepositoryService; + + public CommitsTS(TimeSeriesService timeSeriesService, + CommitService commitService, + GitRepositoryService gitRepositoryService) { + this.timeSeriesService = timeSeriesService; + this.commitService = commitService; + this.gitRepositoryService = gitRepositoryService; + } + + @Override + public List getTimeSeries(Integer repositoryId, String branchName) { + //TODO: добавить постраничное чтение + return Collections.singletonList( + new TimeSeries( + String.format("%s %s %s", + gitRepositoryService.findById(repositoryId).getName(), + branchName, + getTimeSeriesType().getDescription()), + getTimeSeriesType(), + commitService.findByRepositoryIdAndName(repositoryId, branchName) + .stream() + .map(c -> new TimeSeriesValue(c.getDate(), 1.0)) + .collect(Collectors.toList()))); + } + + @Override + public TimeSeriesService getTimeSeriesService() { + return timeSeriesService; + } + + @Override + public TimeSeriesType getTimeSeriesType() { + return TimeSeriesType.COMMITS; + } +} diff --git a/src/main/java/ru/ulstu/extractor/ts/DependenceTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/DependenceTS.java similarity index 51% rename from src/main/java/ru/ulstu/extractor/ts/DependenceTS.java rename to src/main/java/ru/ulstu/extractor/ts/creator/DependenceTS.java index 26c0e39..e534627 100644 --- a/src/main/java/ru/ulstu/extractor/ts/DependenceTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/DependenceTS.java @@ -1,12 +1,12 @@ -package ru.ulstu.extractor.ts; +package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; -import ru.ulstu.extractor.model.TimeSeriesValue; -import ru.ulstu.extractor.service.TimeSeriesService; +import ru.ulstu.extractor.ts.model.TimeSeries; +import ru.ulstu.extractor.ts.model.TimeSeriesType; +import ru.ulstu.extractor.ts.service.TimeSeriesService; -import java.util.HashMap; +import java.util.ArrayList; import java.util.List; -import java.util.Map; @Component public class DependenceTS extends AbstractTimeSeriesCreator { @@ -17,17 +17,17 @@ public class DependenceTS extends AbstractTimeSeriesCreator { } @Override - public String getTimeSeriesName() { - return "Количество зависимостей"; - } - - @Override - public Map> getTimeSeriesValues(Integer repositoryId, String branchName) { - return new HashMap<>(); + public List getTimeSeries(Integer repositoryId, String branchName) { + return new ArrayList(); } @Override public TimeSeriesService getTimeSeriesService() { return timeSeriesService; } + + @Override + public TimeSeriesType getTimeSeriesType() { + return TimeSeriesType.DEPENDENCIES; + } } diff --git a/src/main/java/ru/ulstu/extractor/ts/EntityTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/EntityTS.java similarity index 51% rename from src/main/java/ru/ulstu/extractor/ts/EntityTS.java rename to src/main/java/ru/ulstu/extractor/ts/creator/EntityTS.java index ff6a2d9..c635556 100644 --- a/src/main/java/ru/ulstu/extractor/ts/EntityTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/EntityTS.java @@ -1,12 +1,12 @@ -package ru.ulstu.extractor.ts; +package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; -import ru.ulstu.extractor.model.TimeSeriesValue; -import ru.ulstu.extractor.service.TimeSeriesService; +import ru.ulstu.extractor.ts.model.TimeSeries; +import ru.ulstu.extractor.ts.model.TimeSeriesType; +import ru.ulstu.extractor.ts.service.TimeSeriesService; -import java.util.HashMap; +import java.util.ArrayList; import java.util.List; -import java.util.Map; @Component public class EntityTS extends AbstractTimeSeriesCreator { @@ -17,17 +17,17 @@ public class EntityTS extends AbstractTimeSeriesCreator { } @Override - public String getTimeSeriesName() { - return "Количество сущностей"; - } - - @Override - public Map> getTimeSeriesValues(Integer repositoryId, String branchName) { - return new HashMap<>(); + public List getTimeSeries(Integer repositoryId, String branchName) { + return new ArrayList(); } @Override public TimeSeriesService getTimeSeriesService() { return timeSeriesService; } + + @Override + public TimeSeriesType getTimeSeriesType() { + return TimeSeriesType.ENTITIES; + } } diff --git a/src/main/java/ru/ulstu/extractor/ts/FileTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/FileTS.java similarity index 51% rename from src/main/java/ru/ulstu/extractor/ts/FileTS.java rename to src/main/java/ru/ulstu/extractor/ts/creator/FileTS.java index e90ce57..5797212 100644 --- a/src/main/java/ru/ulstu/extractor/ts/FileTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/FileTS.java @@ -1,12 +1,12 @@ -package ru.ulstu.extractor.ts; +package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; -import ru.ulstu.extractor.model.TimeSeriesValue; -import ru.ulstu.extractor.service.TimeSeriesService; +import ru.ulstu.extractor.ts.model.TimeSeries; +import ru.ulstu.extractor.ts.model.TimeSeriesType; +import ru.ulstu.extractor.ts.service.TimeSeriesService; -import java.util.HashMap; +import java.util.ArrayList; import java.util.List; -import java.util.Map; @Component public class FileTS extends AbstractTimeSeriesCreator { @@ -17,17 +17,17 @@ public class FileTS extends AbstractTimeSeriesCreator { } @Override - public String getTimeSeriesName() { - return "Количество файлов"; - } - - @Override - public Map> getTimeSeriesValues(Integer repositoryId, String branchName) { - return new HashMap<>(); + public List getTimeSeries(Integer repositoryId, String branchName) { + return new ArrayList(); } @Override public TimeSeriesService getTimeSeriesService() { return timeSeriesService; } + + @Override + public TimeSeriesType getTimeSeriesType() { + return TimeSeriesType.FILES; + } } diff --git a/src/main/java/ru/ulstu/extractor/ts/InterfaceTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/InterfaceTS.java similarity index 51% rename from src/main/java/ru/ulstu/extractor/ts/InterfaceTS.java rename to src/main/java/ru/ulstu/extractor/ts/creator/InterfaceTS.java index 7d26f00..8821f8c 100644 --- a/src/main/java/ru/ulstu/extractor/ts/InterfaceTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/InterfaceTS.java @@ -1,12 +1,12 @@ -package ru.ulstu.extractor.ts; +package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; -import ru.ulstu.extractor.model.TimeSeriesValue; -import ru.ulstu.extractor.service.TimeSeriesService; +import ru.ulstu.extractor.ts.model.TimeSeries; +import ru.ulstu.extractor.ts.model.TimeSeriesType; +import ru.ulstu.extractor.ts.service.TimeSeriesService; -import java.util.HashMap; +import java.util.ArrayList; import java.util.List; -import java.util.Map; @Component public class InterfaceTS extends AbstractTimeSeriesCreator { @@ -17,17 +17,17 @@ public class InterfaceTS extends AbstractTimeSeriesCreator { } @Override - public String getTimeSeriesName() { - return "Количество интерфейсов"; - } - - @Override - public Map> getTimeSeriesValues(Integer repositoryId, String branchName) { - return new HashMap<>(); + public List getTimeSeries(Integer repositoryId, String branchName) { + return new ArrayList(); } @Override public TimeSeriesService getTimeSeriesService() { return timeSeriesService; } + + @Override + public TimeSeriesType getTimeSeriesType() { + return TimeSeriesType.INTERFACES; + } } diff --git a/src/main/java/ru/ulstu/extractor/ts/IssuesTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/IssuesTS.java similarity index 51% rename from src/main/java/ru/ulstu/extractor/ts/IssuesTS.java rename to src/main/java/ru/ulstu/extractor/ts/creator/IssuesTS.java index 51ecffd..eef0e20 100644 --- a/src/main/java/ru/ulstu/extractor/ts/IssuesTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/IssuesTS.java @@ -1,12 +1,12 @@ -package ru.ulstu.extractor.ts; +package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; -import ru.ulstu.extractor.model.TimeSeriesValue; -import ru.ulstu.extractor.service.TimeSeriesService; +import ru.ulstu.extractor.ts.model.TimeSeries; +import ru.ulstu.extractor.ts.model.TimeSeriesType; +import ru.ulstu.extractor.ts.service.TimeSeriesService; -import java.util.HashMap; +import java.util.ArrayList; import java.util.List; -import java.util.Map; @Component public class IssuesTS extends AbstractTimeSeriesCreator { @@ -17,17 +17,17 @@ public class IssuesTS extends AbstractTimeSeriesCreator { } @Override - public String getTimeSeriesName() { - return "Количество issues созданных во времени"; - } - - @Override - public Map> getTimeSeriesValues(Integer repositoryId, String branchName) { - return new HashMap<>(); + public List getTimeSeries(Integer repositoryId, String branchName) { + return new ArrayList<>(); } @Override public TimeSeriesService getTimeSeriesService() { return timeSeriesService; } + + @Override + public TimeSeriesType getTimeSeriesType() { + return TimeSeriesType.ISSUES; + } } diff --git a/src/main/java/ru/ulstu/extractor/ts/ProcessTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/ProcessTS.java similarity index 52% rename from src/main/java/ru/ulstu/extractor/ts/ProcessTS.java rename to src/main/java/ru/ulstu/extractor/ts/creator/ProcessTS.java index bc4b322..f375b66 100644 --- a/src/main/java/ru/ulstu/extractor/ts/ProcessTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/ProcessTS.java @@ -1,12 +1,12 @@ -package ru.ulstu.extractor.ts; +package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; -import ru.ulstu.extractor.model.TimeSeriesValue; -import ru.ulstu.extractor.service.TimeSeriesService; +import ru.ulstu.extractor.ts.model.TimeSeries; +import ru.ulstu.extractor.ts.model.TimeSeriesType; +import ru.ulstu.extractor.ts.service.TimeSeriesService; -import java.util.HashMap; +import java.util.ArrayList; import java.util.List; -import java.util.Map; @Component public class ProcessTS extends AbstractTimeSeriesCreator { @@ -17,17 +17,17 @@ public class ProcessTS extends AbstractTimeSeriesCreator { } @Override - public String getTimeSeriesName() { - return "Количество процессов"; - } - - @Override - public Map> getTimeSeriesValues(Integer repositoryId, String branchName) { - return new HashMap<>(); + public List getTimeSeries(Integer repositoryId, String branchName) { + return new ArrayList<>(); } @Override public TimeSeriesService getTimeSeriesService() { return timeSeriesService; } + + @Override + public TimeSeriesType getTimeSeriesType() { + return TimeSeriesType.PROCESSES; + } } diff --git a/src/main/java/ru/ulstu/extractor/ts/StarTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/StarTS.java similarity index 52% rename from src/main/java/ru/ulstu/extractor/ts/StarTS.java rename to src/main/java/ru/ulstu/extractor/ts/creator/StarTS.java index 38455a3..557e9be 100644 --- a/src/main/java/ru/ulstu/extractor/ts/StarTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/StarTS.java @@ -1,12 +1,12 @@ -package ru.ulstu.extractor.ts; +package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; -import ru.ulstu.extractor.model.TimeSeriesValue; -import ru.ulstu.extractor.service.TimeSeriesService; +import ru.ulstu.extractor.ts.model.TimeSeries; +import ru.ulstu.extractor.ts.model.TimeSeriesType; +import ru.ulstu.extractor.ts.service.TimeSeriesService; -import java.util.HashMap; +import java.util.ArrayList; import java.util.List; -import java.util.Map; @Component public class StarTS extends AbstractTimeSeriesCreator { @@ -17,17 +17,17 @@ public class StarTS extends AbstractTimeSeriesCreator { } @Override - public String getTimeSeriesName() { - return "Количество звезд"; - } - - @Override - public Map> getTimeSeriesValues(Integer repositoryId, String branchName) { - return new HashMap<>(); + public List getTimeSeries(Integer repositoryId, String branchName) { + return new ArrayList<>(); } @Override public TimeSeriesService getTimeSeriesService() { return timeSeriesService; } + + @Override + public TimeSeriesType getTimeSeriesType() { + return TimeSeriesType.STARS; + } } diff --git a/src/main/java/ru/ulstu/extractor/model/TimeSeries.java b/src/main/java/ru/ulstu/extractor/ts/model/TimeSeries.java similarity index 63% rename from src/main/java/ru/ulstu/extractor/model/TimeSeries.java rename to src/main/java/ru/ulstu/extractor/ts/model/TimeSeries.java index d04db07..b6d6931 100644 --- a/src/main/java/ru/ulstu/extractor/model/TimeSeries.java +++ b/src/main/java/ru/ulstu/extractor/ts/model/TimeSeries.java @@ -1,10 +1,13 @@ -package ru.ulstu.extractor.model; +package ru.ulstu.extractor.ts.model; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; +import ru.ulstu.extractor.core.BaseEntity; import javax.persistence.CascadeType; import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; import javax.persistence.FetchType; import javax.persistence.JoinColumn; import javax.persistence.OneToMany; @@ -19,6 +22,9 @@ public class TimeSeries extends BaseEntity { @Fetch(FetchMode.SUBSELECT) private List values = new ArrayList<>(); + @Enumerated(EnumType.STRING) + private TimeSeriesType timeSeriesType; + public TimeSeries() { } @@ -31,6 +37,12 @@ public class TimeSeries extends BaseEntity { this.values = values; } + public TimeSeries(String name, TimeSeriesType timeSeriesType, List values) { + this.name = name; + this.values = values; + this.timeSeriesType = timeSeriesType; + } + public String getName() { return name; } @@ -47,4 +59,11 @@ public class TimeSeries extends BaseEntity { this.values = values; } + public TimeSeriesType getTimeSeriesType() { + return timeSeriesType; + } + + public void setTimeSeriesType(TimeSeriesType timeSeriesType) { + this.timeSeriesType = timeSeriesType; + } } diff --git a/src/main/java/ru/ulstu/extractor/ts/model/TimeSeriesType.java b/src/main/java/ru/ulstu/extractor/ts/model/TimeSeriesType.java new file mode 100644 index 0000000..636061e --- /dev/null +++ b/src/main/java/ru/ulstu/extractor/ts/model/TimeSeriesType.java @@ -0,0 +1,28 @@ +package ru.ulstu.extractor.ts.model; + +public enum TimeSeriesType { + COMMITS("Временной ряд коммитов"), + AUTHOR_COMMITS("Временной ряд коммитов авторов"), + AUTHOR_ISSUES("Временной ряд задач авторов"), + AUTHOR_COMPLETED_ISSUES("Временной ряд завершенных задач авторов"), + AUTHORS("Временной ряд авторов"), + BRANCHES("Временной ряд веток"), + CLASSES("Временной ряд кклассов"), + DEPENDENCIES("Временной ряд зависимостей"), + ENTITIES("Временной ряд сущностей"), + FILES("Временной файлов"), + INTERFACES("Временной ряд интерфейсов"), + ISSUES("Временной ряд задач"), + PROCESSES("Временной ряд процессов"), + STARS("Временной ряд звезд"); + + private final String description; + + TimeSeriesType(String description) { + this.description = description; + } + + public String getDescription() { + return description; + } +} diff --git a/src/main/java/ru/ulstu/extractor/model/TimeSeriesValue.java b/src/main/java/ru/ulstu/extractor/ts/model/TimeSeriesValue.java similarity index 89% rename from src/main/java/ru/ulstu/extractor/model/TimeSeriesValue.java rename to src/main/java/ru/ulstu/extractor/ts/model/TimeSeriesValue.java index 06fc168..112b4c5 100644 --- a/src/main/java/ru/ulstu/extractor/model/TimeSeriesValue.java +++ b/src/main/java/ru/ulstu/extractor/ts/model/TimeSeriesValue.java @@ -1,4 +1,6 @@ -package ru.ulstu.extractor.model; +package ru.ulstu.extractor.ts.model; + +import ru.ulstu.extractor.core.BaseEntity; import javax.persistence.Entity; import java.util.Date; diff --git a/src/main/java/ru/ulstu/extractor/repository/TimeSeriesRepository.java b/src/main/java/ru/ulstu/extractor/ts/repository/TimeSeriesRepository.java similarity index 71% rename from src/main/java/ru/ulstu/extractor/repository/TimeSeriesRepository.java rename to src/main/java/ru/ulstu/extractor/ts/repository/TimeSeriesRepository.java index e324774..fbb123e 100644 --- a/src/main/java/ru/ulstu/extractor/repository/TimeSeriesRepository.java +++ b/src/main/java/ru/ulstu/extractor/ts/repository/TimeSeriesRepository.java @@ -1,7 +1,7 @@ -package ru.ulstu.extractor.repository; +package ru.ulstu.extractor.ts.repository; import org.springframework.data.jpa.repository.JpaRepository; -import ru.ulstu.extractor.model.TimeSeries; +import ru.ulstu.extractor.ts.model.TimeSeries; import java.util.Optional; diff --git a/src/main/java/ru/ulstu/extractor/repository/TimeSeriesValueRepository.java b/src/main/java/ru/ulstu/extractor/ts/repository/TimeSeriesValueRepository.java similarity index 80% rename from src/main/java/ru/ulstu/extractor/repository/TimeSeriesValueRepository.java rename to src/main/java/ru/ulstu/extractor/ts/repository/TimeSeriesValueRepository.java index b603ed5..e334bf2 100644 --- a/src/main/java/ru/ulstu/extractor/repository/TimeSeriesValueRepository.java +++ b/src/main/java/ru/ulstu/extractor/ts/repository/TimeSeriesValueRepository.java @@ -1,7 +1,7 @@ -package ru.ulstu.extractor.repository; +package ru.ulstu.extractor.ts.repository; import org.springframework.data.jpa.repository.JpaRepository; -import ru.ulstu.extractor.model.TimeSeriesValue; +import ru.ulstu.extractor.ts.model.TimeSeriesValue; import java.util.List; diff --git a/src/main/java/ru/ulstu/extractor/service/TimeSeriesService.java b/src/main/java/ru/ulstu/extractor/ts/service/TimeSeriesService.java similarity index 68% rename from src/main/java/ru/ulstu/extractor/service/TimeSeriesService.java rename to src/main/java/ru/ulstu/extractor/ts/service/TimeSeriesService.java index f978433..9c79d0f 100644 --- a/src/main/java/ru/ulstu/extractor/service/TimeSeriesService.java +++ b/src/main/java/ru/ulstu/extractor/ts/service/TimeSeriesService.java @@ -3,7 +3,7 @@ * You may use, distribute and modify this code, please write to: romanov73@gmail.com. */ -package ru.ulstu.extractor.service; +package ru.ulstu.extractor.ts.service; import org.json.JSONObject; import org.slf4j.Logger; @@ -11,15 +11,18 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import ru.ulstu.extractor.http.HttpService; import ru.ulstu.extractor.http.JsonTimeSeries; -import ru.ulstu.extractor.model.TimeSeries; -import ru.ulstu.extractor.model.TimeSeriesValue; -import ru.ulstu.extractor.repository.TimeSeriesRepository; -import ru.ulstu.extractor.repository.TimeSeriesValueRepository; -import ru.ulstu.extractor.ts.TimeSeriesDateMapper; +import ru.ulstu.extractor.ts.model.TimeSeries; +import ru.ulstu.extractor.ts.model.TimeSeriesType; +import ru.ulstu.extractor.ts.model.TimeSeriesValue; +import ru.ulstu.extractor.ts.repository.TimeSeriesRepository; +import ru.ulstu.extractor.ts.repository.TimeSeriesValueRepository; +import ru.ulstu.extractor.ts.util.TimeSeriesDateMapper; import javax.transaction.Transactional; -import java.util.*; -import java.util.stream.Collectors; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; @Service public class TimeSeriesService { @@ -38,27 +41,13 @@ public class TimeSeriesService { this.httpService = httpService; } - /** - * Сохранить список временных рядов - * - * @param timeSeriesValues - * @return - */ @Transactional - public List save(Map> timeSeriesValues) { - List results = new ArrayList<>(); - for (Map.Entry> entry : timeSeriesValues.entrySet()) { - results.add(save(entry.getKey(), entry.getValue())); - } - return results; - } - - @Transactional - public TimeSeries save(String timeSeriesName, List timeSeriesValues) { + public TimeSeries save(String timeSeriesName, TimeSeriesType timeSeriesType, List timeSeriesValues) { LOG.debug("Start save {} time series with {} time series values ", timeSeriesName, timeSeriesValues.size()); final TimeSeries timeSeries = findOrCreate(timeSeriesName); List timeSeriesValuesToRemove = timeSeries.getValues(); timeSeries.setValues(timeSeriesValues); + timeSeries.setTimeSeriesType(timeSeriesType); LOG.debug("Save time series {} ", timeSeries.getName()); TimeSeries savedTimeSeries = timeSeriesRepository.save(timeSeries); LOG.debug("Clear {} time series values ", timeSeriesValuesToRemove.size()); @@ -76,23 +65,19 @@ public class TimeSeriesService { return timeSeriesRepository.save(new TimeSeries(timeSeriesName)); } - public List save(List timeSeriesValues) { - return timeSeriesValues.stream() - .map(timeSeriesValue -> { - timeSeriesValue.setValue((timeSeriesValue.getValue())); - timeSeriesValue.setDate((timeSeriesValue.getDate())); - return timeSeriesValueRepository.save(timeSeriesValue); - }).collect(Collectors.toList()); - } - - public void addTimeSeriesValue(String timeSeriesName, Date date, Double value) { - LOG.debug("Start add time series values to {} time series values ", timeSeriesName); - TimeSeries timeSeries = findOrCreate(timeSeriesName); - timeSeriesValueRepository.save(new TimeSeriesValue(timeSeries, date, value)); - } - - public List findAll() { - return timeSeriesValueRepository.findAll(); + /** + * Сохранить список временных рядов + * + * @param timeSeries список ВР + * @return сохраненный список ВР + */ + @Transactional + public List save(List timeSeries) { + List results = new ArrayList<>(); + for (TimeSeries ts : timeSeries) { + results.add(save(ts.getName(), ts.getTimeSeriesType(), ts.getValues())); + } + return results; } public TimeSeriesDateMapper.TimeSeriesInterval getTimeSeriesInterval() { @@ -118,4 +103,8 @@ public class TimeSeriesService { return timeSeriesRepository.findById(tsId) .orElseThrow(() -> new RuntimeException("Time series not found by id " + tsId)); } + + public List getAllTimeSeriesTypes() { + return Arrays.asList(TimeSeriesType.values()); + } } diff --git a/src/main/java/ru/ulstu/extractor/ts/TimeSeriesDateMapper.java b/src/main/java/ru/ulstu/extractor/ts/util/TimeSeriesDateMapper.java similarity index 94% rename from src/main/java/ru/ulstu/extractor/ts/TimeSeriesDateMapper.java rename to src/main/java/ru/ulstu/extractor/ts/util/TimeSeriesDateMapper.java index dec6918..7a17646 100644 --- a/src/main/java/ru/ulstu/extractor/ts/TimeSeriesDateMapper.java +++ b/src/main/java/ru/ulstu/extractor/ts/util/TimeSeriesDateMapper.java @@ -1,8 +1,8 @@ -package ru.ulstu.extractor.ts; +package ru.ulstu.extractor.ts.util; import org.apache.commons.lang3.time.DateUtils; -import ru.ulstu.extractor.model.TimeSeries; -import ru.ulstu.extractor.model.TimeSeriesValue; +import ru.ulstu.extractor.ts.model.TimeSeries; +import ru.ulstu.extractor.ts.model.TimeSeriesValue; import java.util.Calendar; import java.util.Date; diff --git a/src/main/resources/db/changelog-20221012_170000-schema.xml b/src/main/resources/db/changelog-20221012_170000-schema.xml index 76ad715..765df26 100644 --- a/src/main/resources/db/changelog-20221012_170000-schema.xml +++ b/src/main/resources/db/changelog-20221012_170000-schema.xml @@ -44,4 +44,40 @@ referencedTableName="time_series" referencedColumnNames="id"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/addRule.html b/src/main/resources/templates/addRule.html index 8c709d0..191e07a 100644 --- a/src/main/resources/templates/addRule.html +++ b/src/main/resources/templates/addRule.html @@ -12,6 +12,19 @@
Если
+
+ +
+
+ имеет тенденцию +
- и + имеет тенденцию
-
- временной ряд -
-
- -
то:
-
+
-
+
+
+
+
diff --git a/src/main/resources/templates/listRules.html b/src/main/resources/templates/listRules.html index 93e139a..1f71b46 100644 --- a/src/main/resources/templates/listRules.html +++ b/src/main/resources/templates/listRules.html @@ -16,10 +16,10 @@ Если - + и - + то diff --git a/src/test/java/ru/ulstu/TimeSeriesMapperTest.java b/src/test/java/ru/ulstu/TimeSeriesMapperTest.java index 91030f9..c1cae8d 100644 --- a/src/test/java/ru/ulstu/TimeSeriesMapperTest.java +++ b/src/test/java/ru/ulstu/TimeSeriesMapperTest.java @@ -2,9 +2,9 @@ package ru.ulstu; import org.junit.Assert; import org.junit.Test; -import ru.ulstu.extractor.model.TimeSeries; -import ru.ulstu.extractor.model.TimeSeriesValue; -import ru.ulstu.extractor.ts.TimeSeriesDateMapper; +import ru.ulstu.extractor.ts.model.TimeSeries; +import ru.ulstu.extractor.ts.model.TimeSeriesValue; +import ru.ulstu.extractor.ts.util.TimeSeriesDateMapper; import java.util.Arrays; import java.util.Calendar;