Merge pull request 'ts types' (#73) from 72-ts-types into master

Reviewed-on: #73
This commit is contained in:
romanov73 2022-10-16 01:16:42 +04:00
commit f59dc9b523
66 changed files with 547 additions and 462 deletions

View File

@ -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; import javax.persistence.Entity;

View File

@ -3,13 +3,13 @@
* You may use, distribute and modify this code, please write to: romanov73@gmail.com. * 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.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; 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.gitrepository.model.GitRepository;
import ru.ulstu.extractor.model.Author;
import java.util.List; import java.util.List;

View File

@ -3,13 +3,13 @@
* You may use, distribute and modify this code, please write to: romanov73@gmail.com. * 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import ru.ulstu.extractor.model.Author; import ru.ulstu.extractor.author.model.Author;
import ru.ulstu.extractor.repository.AuthorRepository; import ru.ulstu.extractor.author.repository.AuthorRepository;
import java.util.Optional; import java.util.Optional;

View File

@ -10,11 +10,11 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import ru.ulstu.extractor.branch.repository.BranchRepository; 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 springfox.documentation.annotations.ApiIgnore;
import static ru.ulstu.extractor.controller.Route.DELETE_BRANCH; import static ru.ulstu.extractor.core.Route.DELETE_BRANCH;
import static ru.ulstu.extractor.controller.Route.LIST_REPOSITORY_BRANCHES; import static ru.ulstu.extractor.core.Route.LIST_REPOSITORY_BRANCHES;
@Controller @Controller
@ApiIgnore @ApiIgnore

View File

@ -7,8 +7,8 @@ package ru.ulstu.extractor.branch.model;
import org.hibernate.annotations.Fetch; import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import ru.ulstu.extractor.core.BaseEntity;
import ru.ulstu.extractor.gitrepository.model.GitRepository; import ru.ulstu.extractor.gitrepository.model.GitRepository;
import ru.ulstu.extractor.model.BaseEntity;
import ru.ulstu.extractor.model.Commit; import ru.ulstu.extractor.model.Commit;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;

View File

@ -12,8 +12,8 @@ import org.springframework.transaction.annotation.Transactional;
import ru.ulstu.extractor.branch.model.Branch; import ru.ulstu.extractor.branch.model.Branch;
import ru.ulstu.extractor.branch.repository.BranchRepository; import ru.ulstu.extractor.branch.repository.BranchRepository;
import ru.ulstu.extractor.commit.service.CommitService; import ru.ulstu.extractor.commit.service.CommitService;
import ru.ulstu.extractor.core.BaseEntity;
import ru.ulstu.extractor.gitrepository.model.GitRepository; import ru.ulstu.extractor.gitrepository.model.GitRepository;
import ru.ulstu.extractor.model.BaseEntity;
import ru.ulstu.extractor.model.Commit; import ru.ulstu.extractor.model.Commit;
import java.util.List; import java.util.List;

View File

@ -7,7 +7,10 @@ package ru.ulstu.extractor.model;
import org.hibernate.annotations.Fetch; import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import ru.ulstu.extractor.author.model.Author;
import ru.ulstu.extractor.branch.model.Branch; 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.CascadeType;
import javax.persistence.Entity; import javax.persistence.Entity;

View File

@ -7,9 +7,9 @@ package ru.ulstu.extractor.commit.service;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import ru.ulstu.extractor.author.service.AuthorService;
import ru.ulstu.extractor.commit.repository.CommitRepository; import ru.ulstu.extractor.commit.repository.CommitRepository;
import ru.ulstu.extractor.model.Commit; import ru.ulstu.extractor.model.Commit;
import ru.ulstu.extractor.service.AuthorService;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;

View File

@ -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.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 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 @Configuration
public class MvcConfiguration implements WebMvcConfigurer { public class MvcConfiguration implements WebMvcConfigurer {

View File

@ -1,4 +1,4 @@
package ru.ulstu.extractor.model; package ru.ulstu.extractor.core;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;

View File

@ -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.Pageable;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;

View File

@ -3,7 +3,7 @@
* You may use, distribute and modify this code, please write to: romanov73@gmail.com. * 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; import org.springframework.stereotype.Component;

View File

@ -3,7 +3,7 @@
* You may use, distribute and modify this code, please write to: romanov73@gmail.com. * 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.data.domain.Page;
import org.springframework.stereotype.Controller; 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.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; 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.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 springfox.documentation.annotations.ApiIgnore;
import java.util.List; import java.util.List;
@ -22,7 +22,7 @@ import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import static ru.ulstu.extractor.controller.Route.FILTER_COMMITS; import static ru.ulstu.extractor.core.Route.FILTER_COMMITS;
@Controller @Controller
@ApiIgnore @ApiIgnore

View File

@ -3,7 +3,7 @@
* You may use, distribute and modify this code, please write to: romanov73@gmail.com. * 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.eclipse.jgit.api.errors.GitAPIException;
import org.slf4j.Logger; 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.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes; import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import ru.ulstu.extractor.branch.model.Branch; import ru.ulstu.extractor.branch.model.Branch;
import ru.ulstu.extractor.gitrepository.GitRepositoryService; import ru.ulstu.extractor.gitrepository.model.FilterForm;
import ru.ulstu.extractor.model.mvc.FilterForm; import ru.ulstu.extractor.gitrepository.model.RepoForm;
import ru.ulstu.extractor.model.mvc.RepoForm; import ru.ulstu.extractor.gitrepository.service.GitRepositoryService;
import ru.ulstu.extractor.service.IndexService; import ru.ulstu.extractor.gitrepository.service.IndexService;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import static ru.ulstu.extractor.controller.Route.FILTER_COMMITS; import static ru.ulstu.extractor.core.Route.FILTER_COMMITS;
import static ru.ulstu.extractor.controller.Route.INDEXING_NEW_REPOSITORY; import static ru.ulstu.extractor.core.Route.INDEXING_NEW_REPOSITORY;
@Controller @Controller
@ApiIgnore @ApiIgnore

View File

@ -3,7 +3,7 @@
* You may use, distribute and modify this code, please write to: romanov73@gmail.com. * 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.eclipse.jgit.api.errors.GitAPIException;
import org.slf4j.Logger; 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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; 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.model.Commit;
import ru.ulstu.extractor.service.IndexService;
import ru.ulstu.extractor.util.HttpUtils; import ru.ulstu.extractor.util.HttpUtils;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import static ru.ulstu.extractor.controller.RepoController.URL; import static ru.ulstu.extractor.gitrepository.controler.RepoController.URL;
@RestController @RestController
@RequestMapping(URL) @RequestMapping(URL)

View File

@ -3,17 +3,17 @@
* You may use, distribute and modify this code, please write to: romanov73@gmail.com. * 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.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam; 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 springfox.documentation.annotations.ApiIgnore;
import static ru.ulstu.extractor.controller.Route.DELETE_INDEXED_REPOSITORY; import static ru.ulstu.extractor.core.Route.DELETE_INDEXED_REPOSITORY;
import static ru.ulstu.extractor.controller.Route.LIST_INDEXED_REPOSITORIES; import static ru.ulstu.extractor.core.Route.LIST_INDEXED_REPOSITORIES;
@Controller @Controller
@ApiIgnore @ApiIgnore

View File

@ -3,7 +3,7 @@
* You may use, distribute and modify this code, please write to: romanov73@gmail.com. * 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.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
@ -11,15 +11,15 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import ru.ulstu.extractor.branch.service.BranchService; import ru.ulstu.extractor.branch.service.BranchService;
import ru.ulstu.extractor.commit.repository.CommitRepository; import ru.ulstu.extractor.commit.repository.CommitRepository;
import ru.ulstu.extractor.model.mvc.FilterForm; import ru.ulstu.extractor.gitrepository.model.FilterForm;
import ru.ulstu.extractor.service.FilteringService; import ru.ulstu.extractor.gitrepository.service.FilteringService;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static ru.ulstu.extractor.controller.Route.STATISTIC; import static ru.ulstu.extractor.core.Route.STATISTIC;
@Controller @Controller
@ApiIgnore @ApiIgnore

View File

@ -3,10 +3,11 @@
* You may use, distribute and modify this code, please write to: romanov73@gmail.com. * 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.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import ru.ulstu.extractor.core.BaseEntity;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Entity; import javax.persistence.Entity;

View File

@ -3,7 +3,7 @@
* You may use, distribute and modify this code, please write to: romanov73@gmail.com. * 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 org.springframework.data.domain.Page;
import ru.ulstu.extractor.model.Commit; import ru.ulstu.extractor.model.Commit;

View File

@ -1,6 +1,6 @@
package ru.ulstu.extractor.gitrepository.model; package ru.ulstu.extractor.gitrepository.model;
import ru.ulstu.extractor.model.BaseEntity; import ru.ulstu.extractor.core.BaseEntity;
import javax.persistence.Entity; import javax.persistence.Entity;

View File

@ -3,7 +3,9 @@
* You may use, distribute and modify this code, please write to: romanov73@gmail.com. * 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; import javax.persistence.Entity;

View File

@ -1,4 +1,4 @@
package ru.ulstu.extractor.model.mvc; package ru.ulstu.extractor.gitrepository.model;
public class RepoForm { public class RepoForm {
private String repo; private String repo;

View File

@ -1,4 +1,4 @@
package ru.ulstu.extractor.gitrepository; package ru.ulstu.extractor.gitrepository.repository;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import ru.ulstu.extractor.gitrepository.model.GitRepository; import ru.ulstu.extractor.gitrepository.model.GitRepository;

View File

@ -3,16 +3,16 @@
* You may use, distribute and modify this code, please write to: romanov73@gmail.com. * 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 com.sun.istack.NotNull;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import ru.ulstu.extractor.author.repository.AuthorRepository;
import ru.ulstu.extractor.commit.repository.CommitRepository; 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.model.Commit;
import ru.ulstu.extractor.repository.AuthorRepository;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;

View File

@ -1,4 +1,4 @@
package ru.ulstu.extractor.gitrepository; package ru.ulstu.extractor.gitrepository.service;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.eclipse.jgit.api.CreateBranchCommand; 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.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import ru.ulstu.extractor.author.model.Author;
import ru.ulstu.extractor.branch.model.Branch; 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.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.BusinessLogicUnit;
import ru.ulstu.extractor.heuristic.model.EntityUnit; import ru.ulstu.extractor.heuristic.model.EntityUnit;
import ru.ulstu.extractor.heuristic.model.ResourceUnit; import ru.ulstu.extractor.heuristic.model.ResourceUnit;
import ru.ulstu.extractor.heuristic.service.StructuralUnitService; import ru.ulstu.extractor.heuristic.service.StructuralUnitService;
import ru.ulstu.extractor.model.Author;
import ru.ulstu.extractor.model.Commit; 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.ByteArrayOutputStream;
import java.io.File; import java.io.File;

View File

@ -3,7 +3,7 @@
* You may use, distribute and modify this code, please write to: romanov73@gmail.com. * 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 com.sun.istack.NotNull;
import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.GitAPIException;
@ -12,11 +12,10 @@ import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import ru.ulstu.extractor.branch.model.Branch; import ru.ulstu.extractor.branch.model.Branch;
import ru.ulstu.extractor.branch.service.BranchService; 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.model.GitRepository;
import ru.ulstu.extractor.gitrepository.repository.GitRepositoryRepository;
import ru.ulstu.extractor.model.Commit; 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.io.IOException;
import java.util.Collections; import java.util.Collections;

View File

@ -11,7 +11,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; 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.BusinessLogicUnit;
import ru.ulstu.extractor.heuristic.model.EntityUnit; import ru.ulstu.extractor.heuristic.model.EntityUnit;
import ru.ulstu.extractor.heuristic.model.ResourceUnit; import ru.ulstu.extractor.heuristic.model.ResourceUnit;

View File

@ -1,6 +1,6 @@
package ru.ulstu.extractor.http; 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.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;

View File

@ -1,6 +1,6 @@
package ru.ulstu.extractor.http; 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.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;

View File

@ -1,4 +1,4 @@
package ru.ulstu.extractor.controller; package ru.ulstu.extractor.rule.controller;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; 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.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes; import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import ru.ulstu.extractor.model.mvc.AddRuleForm; import ru.ulstu.extractor.rule.model.AddRuleForm;
import ru.ulstu.extractor.service.AntecedentValueService; import ru.ulstu.extractor.rule.service.AntecedentValueService;
import ru.ulstu.extractor.service.RuleService; import ru.ulstu.extractor.rule.service.RuleService;
import ru.ulstu.extractor.service.TimeSeriesService; import ru.ulstu.extractor.ts.service.TimeSeriesService;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import static ru.ulstu.extractor.controller.Route.ADD_RULE; import static ru.ulstu.extractor.core.Route.ADD_RULE;
import static ru.ulstu.extractor.controller.Route.LIST_RULE; import static ru.ulstu.extractor.core.Route.LIST_RULE;
@Controller @Controller
@ApiIgnore @ApiIgnore
@ -23,7 +23,9 @@ public class RuleController {
private final AntecedentValueService antecedentValueService; private final AntecedentValueService antecedentValueService;
private final TimeSeriesService timeSeriesService; private final TimeSeriesService timeSeriesService;
public RuleController(RuleService ruleService, AntecedentValueService antecedentValueService, TimeSeriesService timeSeriesService) { public RuleController(RuleService ruleService,
AntecedentValueService antecedentValueService,
TimeSeriesService timeSeriesService) {
this.ruleService = ruleService; this.ruleService = ruleService;
this.antecedentValueService = antecedentValueService; this.antecedentValueService = antecedentValueService;
this.timeSeriesService = timeSeriesService; this.timeSeriesService = timeSeriesService;
@ -38,7 +40,7 @@ public class RuleController {
@GetMapping(ADD_RULE) @GetMapping(ADD_RULE)
public String getAntecedent(Model model) { public String getAntecedent(Model model) {
model.addAttribute("antecedentValues", antecedentValueService.getList()); model.addAttribute("antecedentValues", antecedentValueService.getList());
model.addAttribute("antecedents", timeSeriesService.getAllTimeSeries()); model.addAttribute("antecedents", timeSeriesService.getAllTimeSeriesTypes());
model.addAttribute("addRuleForm", new AddRuleForm()); model.addAttribute("addRuleForm", new AddRuleForm());
return ADD_RULE; return ADD_RULE;
} }

View File

@ -1,10 +1,10 @@
package ru.ulstu.extractor.model.mvc; package ru.ulstu.extractor.rule.model;
public class AddRuleForm { public class AddRuleForm {
private Integer firstAntecedentValueId; private Integer firstAntecedentValueId;
private Integer firstAntecedentId; private String firstAntecedentId;
private Integer secondAntecedentValueId; private Integer secondAntecedentValueId;
private Integer secondAntecedentId; private String secondAntecedentId;
private String consequent; private String consequent;
public AddRuleForm() { public AddRuleForm() {
@ -18,11 +18,11 @@ public class AddRuleForm {
this.firstAntecedentValueId = firstAntecedentValueId; this.firstAntecedentValueId = firstAntecedentValueId;
} }
public Integer getFirstAntecedentId() { public String getFirstAntecedentId() {
return firstAntecedentId; return firstAntecedentId;
} }
public void setFirstAntecedentId(Integer firstAntecedentId) { public void setFirstAntecedentId(String firstAntecedentId) {
this.firstAntecedentId = firstAntecedentId; this.firstAntecedentId = firstAntecedentId;
} }
@ -34,11 +34,11 @@ public class AddRuleForm {
this.secondAntecedentValueId = secondAntecedentValueId; this.secondAntecedentValueId = secondAntecedentValueId;
} }
public Integer getSecondAntecedentId() { public String getSecondAntecedentId() {
return secondAntecedentId; return secondAntecedentId;
} }
public void setSecondAntecedentId(Integer secondAntecedentId) { public void setSecondAntecedentId(String secondAntecedentId) {
this.secondAntecedentId = secondAntecedentId; this.secondAntecedentId = secondAntecedentId;
} }

View File

@ -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; import javax.persistence.Entity;

View File

@ -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.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
@Entity @Entity
@ -8,14 +13,14 @@ public class Rule extends BaseEntity {
@ManyToOne @ManyToOne
private AntecedentValue firstAntecedentValue; private AntecedentValue firstAntecedentValue;
@ManyToOne @Enumerated(EnumType.STRING)
private TimeSeries firstAntecedent; private TimeSeriesType firstAntecedent;
@ManyToOne @ManyToOne
private AntecedentValue secondAntecedentValue; private AntecedentValue secondAntecedentValue;
@ManyToOne @Enumerated(EnumType.STRING)
private TimeSeries secondAntecedent; private TimeSeriesType secondAntecedent;
private String consequent; private String consequent;
@ -23,9 +28,9 @@ public class Rule extends BaseEntity {
} }
public Rule(AntecedentValue firstAntecedentValue, public Rule(AntecedentValue firstAntecedentValue,
TimeSeries firstAntecedent, TimeSeriesType firstAntecedent,
AntecedentValue secondAntecedentValue, AntecedentValue secondAntecedentValue,
TimeSeries secondAntecedent, TimeSeriesType secondAntecedent,
String consequent) { String consequent) {
this.firstAntecedentValue = firstAntecedentValue; this.firstAntecedentValue = firstAntecedentValue;
this.firstAntecedent = firstAntecedent; this.firstAntecedent = firstAntecedent;
@ -34,21 +39,6 @@ public class Rule extends BaseEntity {
this.consequent = consequent; 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() { public AntecedentValue getFirstAntecedentValue() {
return firstAntecedentValue; return firstAntecedentValue;
} }
@ -57,11 +47,11 @@ public class Rule extends BaseEntity {
this.firstAntecedentValue = firstAntecedentValue; this.firstAntecedentValue = firstAntecedentValue;
} }
public TimeSeries getFirstAntecedent() { public TimeSeriesType getFirstAntecedent() {
return firstAntecedent; return firstAntecedent;
} }
public void setFirstAntecedent(TimeSeries firstAntecedent) { public void setFirstAntecedent(TimeSeriesType firstAntecedent) {
this.firstAntecedent = firstAntecedent; this.firstAntecedent = firstAntecedent;
} }
@ -73,11 +63,11 @@ public class Rule extends BaseEntity {
this.secondAntecedentValue = secondAntecedentValue; this.secondAntecedentValue = secondAntecedentValue;
} }
public TimeSeries getSecondAntecedent() { public TimeSeriesType getSecondAntecedent() {
return secondAntecedent; return secondAntecedent;
} }
public void setSecondAntecedent(TimeSeries secondAntecedent) { public void setSecondAntecedent(TimeSeriesType secondAntecedent) {
this.secondAntecedent = secondAntecedent; this.secondAntecedent = secondAntecedent;
} }

View File

@ -1,8 +1,8 @@
package ru.ulstu.extractor.repository; package ru.ulstu.extractor.rule.repository;
import org.springframework.data.jpa.repository.JpaRepository; 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<AntecedentValue, Integer> { public interface AntecedentValueRepository extends JpaRepository<AntecedentValue, Integer> {
} }

View File

@ -1,7 +1,7 @@
package ru.ulstu.extractor.repository; package ru.ulstu.extractor.rule.repository;
import org.springframework.data.jpa.repository.JpaRepository; 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<Rule, Integer> { public interface RuleRepository extends JpaRepository<Rule, Integer> {
} }

View File

@ -1,8 +1,8 @@
package ru.ulstu.extractor.service; package ru.ulstu.extractor.rule.service;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import ru.ulstu.extractor.model.AntecedentValue; import ru.ulstu.extractor.rule.model.AntecedentValue;
import ru.ulstu.extractor.repository.AntecedentValueRepository; import ru.ulstu.extractor.rule.repository.AntecedentValueRepository;
import java.util.List; import java.util.List;

View File

@ -1,9 +1,11 @@
package ru.ulstu.extractor.service; package ru.ulstu.extractor.rule.service;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import ru.ulstu.extractor.model.Rule; import ru.ulstu.extractor.rule.model.AddRuleForm;
import ru.ulstu.extractor.model.mvc.AddRuleForm; import ru.ulstu.extractor.rule.model.Rule;
import ru.ulstu.extractor.repository.RuleRepository; 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; import java.util.List;
@ -27,9 +29,9 @@ public class RuleService {
public void saveRule(AddRuleForm addRuleForm) { public void saveRule(AddRuleForm addRuleForm) {
ruleRepository.save(new Rule(antecedentValueService.getById(addRuleForm.getFirstAntecedentValueId()), ruleRepository.save(new Rule(antecedentValueService.getById(addRuleForm.getFirstAntecedentValueId()),
timeSeriesService.getById(addRuleForm.getFirstAntecedentId()), TimeSeriesType.valueOf(addRuleForm.getFirstAntecedentId()),
antecedentValueService.getById(addRuleForm.getSecondAntecedentValueId()), antecedentValueService.getById(addRuleForm.getSecondAntecedentValueId()),
timeSeriesService.getById(addRuleForm.getSecondAntecedentId()), TimeSeriesType.valueOf(addRuleForm.getSecondAntecedentId()),
addRuleForm.getConsequent())); addRuleForm.getConsequent()));
} }
} }

View File

@ -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<String, List<TimeSeriesValue>> getTimeSeriesValues(Integer repositoryId, String branchName);
public abstract TimeSeriesService getTimeSeriesService();
/**
* Сохранить извлеченные временные ряды
*
* @param repositoryId
* @param branchName
*/
public void addTimeSeries(Integer repositoryId, String branchName) {
// извлеченные точки временных рядов
Map<String, List<TimeSeriesValue>> timeSeriesValues = getTimeSeriesValues(repositoryId, branchName);
// сгруппированные по временным интервалам точки временных рядов
timeSeriesValues.replaceAll((k, v) -> mapTimeSeriesToInterval(getTimeSeriesService().getTimeSeriesInterval(), v));
getTimeSeriesService().save(sortTimeSeriesValues(timeSeriesValues));
}
private Map<String, List<TimeSeriesValue>> sortTimeSeriesValues(Map<String, List<TimeSeriesValue>> timeSeriesValues) {
for (Map.Entry<String, List<TimeSeriesValue>> entry : timeSeriesValues.entrySet()) {
entry.getValue().sort(Comparator.comparing(TimeSeriesValue::getDate));
}
return timeSeriesValues;
}
}

View File

@ -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<String, List<TimeSeriesValue>> getTimeSeriesValues(Integer repositoryId, String branchName) {
return new HashMap<>();
}
@Override
public TimeSeriesService getTimeSeriesService() {
return timeSeriesService;
}
}

View File

@ -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<String, List<TimeSeriesValue>> getTimeSeriesValues(Integer repositoryId, String branchName) {
//TODO: добавить постраничное чтение
Map<String, List<TimeSeriesValue>> 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;
}
}

View File

@ -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<TimeSeries> getTimeSeries(Integer repositoryId, String branchName);
public abstract TimeSeriesService getTimeSeriesService();
/**
* Сохранить извлеченные временные ряды
*
* @param repositoryId
* @param branchName
*/
public void addTimeSeries(Integer repositoryId, String branchName) {
// извлеченные временных рядов
List<TimeSeries> timeSeries = getTimeSeries(repositoryId, branchName);
// сгруппированные по временным интервалам точки временных рядов
timeSeries.forEach(ts -> ts.setValues(mapTimeSeriesToInterval(getTimeSeriesService().getTimeSeriesInterval(), ts.getValues())));
getTimeSeriesService().save(sortTimeSeries(timeSeries));
}
private List<TimeSeries> sortTimeSeries(List<TimeSeries> timeSeries) {
for (TimeSeries ts : timeSeries) {
ts.getValues().sort(Comparator.comparing(TimeSeriesValue::getDate));
}
return timeSeries;
}
}

View File

@ -1,12 +1,12 @@
package ru.ulstu.extractor.ts; package ru.ulstu.extractor.ts.creator;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import ru.ulstu.extractor.model.TimeSeriesValue; import ru.ulstu.extractor.ts.model.TimeSeries;
import ru.ulstu.extractor.service.TimeSeriesService; 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.List;
import java.util.Map;
@Component @Component
public class AuthorTS extends AbstractTimeSeriesCreator { public class AuthorTS extends AbstractTimeSeriesCreator {
@ -17,13 +17,13 @@ public class AuthorTS extends AbstractTimeSeriesCreator {
} }
@Override @Override
public String getTimeSeriesName() { public TimeSeriesType getTimeSeriesType() {
return "Количество Авторов"; return TimeSeriesType.AUTHORS;
} }
@Override @Override
public Map<String, List<TimeSeriesValue>> getTimeSeriesValues(Integer repositoryId, String branchName) { public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
return new HashMap<>(); return new ArrayList<>();
} }
@Override @Override

View File

@ -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<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
return new ArrayList<TimeSeries>();
}
@Override
public TimeSeriesService getTimeSeriesService() {
return timeSeriesService;
}
}

View File

@ -1,12 +1,12 @@
package ru.ulstu.extractor.ts; package ru.ulstu.extractor.ts.creator;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import ru.ulstu.extractor.model.TimeSeriesValue; import ru.ulstu.extractor.ts.model.TimeSeries;
import ru.ulstu.extractor.service.TimeSeriesService; 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.List;
import java.util.Map;
@Component @Component
public class AuthorsCompletedIssueTS extends AbstractTimeSeriesCreator { public class AuthorsCompletedIssueTS extends AbstractTimeSeriesCreator {
@ -17,17 +17,17 @@ public class AuthorsCompletedIssueTS extends AbstractTimeSeriesCreator {
} }
@Override @Override
public String getTimeSeriesName() { public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
return "Количество выполненных issues авторов"; return new ArrayList<>();
}
@Override
public Map<String, List<TimeSeriesValue>> getTimeSeriesValues(Integer repositoryId, String branchName) {
return new HashMap<>();
} }
@Override @Override
public TimeSeriesService getTimeSeriesService() { public TimeSeriesService getTimeSeriesService() {
return timeSeriesService; return timeSeriesService;
} }
@Override
public TimeSeriesType getTimeSeriesType() {
return TimeSeriesType.AUTHOR_COMPLETED_ISSUES;
}
} }

View File

@ -1,12 +1,12 @@
package ru.ulstu.extractor.ts; package ru.ulstu.extractor.ts.creator;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import ru.ulstu.extractor.model.TimeSeriesValue; import ru.ulstu.extractor.ts.model.TimeSeries;
import ru.ulstu.extractor.service.TimeSeriesService; 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.List;
import java.util.Map;
@Component @Component
public class AuthorsIssueTS extends AbstractTimeSeriesCreator { public class AuthorsIssueTS extends AbstractTimeSeriesCreator {
@ -17,17 +17,17 @@ public class AuthorsIssueTS extends AbstractTimeSeriesCreator {
} }
@Override @Override
public String getTimeSeriesName() { public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
return "Количество issues авторов"; return new ArrayList<TimeSeries>();
}
@Override
public Map<String, List<TimeSeriesValue>> getTimeSeriesValues(Integer repositoryId, String branchName) {
return new HashMap<>();
} }
@Override @Override
public TimeSeriesService getTimeSeriesService() { public TimeSeriesService getTimeSeriesService() {
return timeSeriesService; return timeSeriesService;
} }
@Override
public TimeSeriesType getTimeSeriesType() {
return TimeSeriesType.AUTHOR_ISSUES;
}
} }

View File

@ -1,12 +1,12 @@
package ru.ulstu.extractor.ts; package ru.ulstu.extractor.ts.creator;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import ru.ulstu.extractor.model.TimeSeriesValue; import ru.ulstu.extractor.ts.model.TimeSeries;
import ru.ulstu.extractor.service.TimeSeriesService; 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.List;
import java.util.Map;
@Component @Component
public class BranchTS extends AbstractTimeSeriesCreator { public class BranchTS extends AbstractTimeSeriesCreator {
@ -17,13 +17,13 @@ public class BranchTS extends AbstractTimeSeriesCreator {
} }
@Override @Override
public String getTimeSeriesName() { public TimeSeriesType getTimeSeriesType() {
return "Количество веток"; return TimeSeriesType.BRANCHES;
} }
@Override @Override
public Map<String, List<TimeSeriesValue>> getTimeSeriesValues(Integer repositoryId, String branchName) { public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
return new HashMap<>(); return new ArrayList<>();
} }
@Override @Override

View File

@ -1,12 +1,12 @@
package ru.ulstu.extractor.ts; package ru.ulstu.extractor.ts.creator;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import ru.ulstu.extractor.model.TimeSeriesValue; import ru.ulstu.extractor.ts.model.TimeSeries;
import ru.ulstu.extractor.service.TimeSeriesService; 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.List;
import java.util.Map;
@Component @Component
public class ClassTS extends AbstractTimeSeriesCreator { public class ClassTS extends AbstractTimeSeriesCreator {
@ -17,17 +17,17 @@ public class ClassTS extends AbstractTimeSeriesCreator {
} }
@Override @Override
public String getTimeSeriesName() { public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
return "Количество классов"; return new ArrayList<TimeSeries>();
}
@Override
public Map<String, List<TimeSeriesValue>> getTimeSeriesValues(Integer repositoryId, String branchName) {
return new HashMap<>();
} }
@Override @Override
public TimeSeriesService getTimeSeriesService() { public TimeSeriesService getTimeSeriesService() {
return timeSeriesService; return timeSeriesService;
} }
@Override
public TimeSeriesType getTimeSeriesType() {
return TimeSeriesType.CLASSES;
}
} }

View File

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

View File

@ -1,12 +1,12 @@
package ru.ulstu.extractor.ts; package ru.ulstu.extractor.ts.creator;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import ru.ulstu.extractor.model.TimeSeriesValue; import ru.ulstu.extractor.ts.model.TimeSeries;
import ru.ulstu.extractor.service.TimeSeriesService; 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.List;
import java.util.Map;
@Component @Component
public class DependenceTS extends AbstractTimeSeriesCreator { public class DependenceTS extends AbstractTimeSeriesCreator {
@ -17,17 +17,17 @@ public class DependenceTS extends AbstractTimeSeriesCreator {
} }
@Override @Override
public String getTimeSeriesName() { public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
return "Количество зависимостей"; return new ArrayList<TimeSeries>();
}
@Override
public Map<String, List<TimeSeriesValue>> getTimeSeriesValues(Integer repositoryId, String branchName) {
return new HashMap<>();
} }
@Override @Override
public TimeSeriesService getTimeSeriesService() { public TimeSeriesService getTimeSeriesService() {
return timeSeriesService; return timeSeriesService;
} }
@Override
public TimeSeriesType getTimeSeriesType() {
return TimeSeriesType.DEPENDENCIES;
}
} }

View File

@ -1,12 +1,12 @@
package ru.ulstu.extractor.ts; package ru.ulstu.extractor.ts.creator;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import ru.ulstu.extractor.model.TimeSeriesValue; import ru.ulstu.extractor.ts.model.TimeSeries;
import ru.ulstu.extractor.service.TimeSeriesService; 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.List;
import java.util.Map;
@Component @Component
public class EntityTS extends AbstractTimeSeriesCreator { public class EntityTS extends AbstractTimeSeriesCreator {
@ -17,17 +17,17 @@ public class EntityTS extends AbstractTimeSeriesCreator {
} }
@Override @Override
public String getTimeSeriesName() { public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
return "Количество сущностей"; return new ArrayList<TimeSeries>();
}
@Override
public Map<String, List<TimeSeriesValue>> getTimeSeriesValues(Integer repositoryId, String branchName) {
return new HashMap<>();
} }
@Override @Override
public TimeSeriesService getTimeSeriesService() { public TimeSeriesService getTimeSeriesService() {
return timeSeriesService; return timeSeriesService;
} }
@Override
public TimeSeriesType getTimeSeriesType() {
return TimeSeriesType.ENTITIES;
}
} }

View File

@ -1,12 +1,12 @@
package ru.ulstu.extractor.ts; package ru.ulstu.extractor.ts.creator;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import ru.ulstu.extractor.model.TimeSeriesValue; import ru.ulstu.extractor.ts.model.TimeSeries;
import ru.ulstu.extractor.service.TimeSeriesService; 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.List;
import java.util.Map;
@Component @Component
public class FileTS extends AbstractTimeSeriesCreator { public class FileTS extends AbstractTimeSeriesCreator {
@ -17,17 +17,17 @@ public class FileTS extends AbstractTimeSeriesCreator {
} }
@Override @Override
public String getTimeSeriesName() { public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
return "Количество файлов"; return new ArrayList<TimeSeries>();
}
@Override
public Map<String, List<TimeSeriesValue>> getTimeSeriesValues(Integer repositoryId, String branchName) {
return new HashMap<>();
} }
@Override @Override
public TimeSeriesService getTimeSeriesService() { public TimeSeriesService getTimeSeriesService() {
return timeSeriesService; return timeSeriesService;
} }
@Override
public TimeSeriesType getTimeSeriesType() {
return TimeSeriesType.FILES;
}
} }

View File

@ -1,12 +1,12 @@
package ru.ulstu.extractor.ts; package ru.ulstu.extractor.ts.creator;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import ru.ulstu.extractor.model.TimeSeriesValue; import ru.ulstu.extractor.ts.model.TimeSeries;
import ru.ulstu.extractor.service.TimeSeriesService; 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.List;
import java.util.Map;
@Component @Component
public class InterfaceTS extends AbstractTimeSeriesCreator { public class InterfaceTS extends AbstractTimeSeriesCreator {
@ -17,17 +17,17 @@ public class InterfaceTS extends AbstractTimeSeriesCreator {
} }
@Override @Override
public String getTimeSeriesName() { public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
return "Количество интерфейсов"; return new ArrayList<TimeSeries>();
}
@Override
public Map<String, List<TimeSeriesValue>> getTimeSeriesValues(Integer repositoryId, String branchName) {
return new HashMap<>();
} }
@Override @Override
public TimeSeriesService getTimeSeriesService() { public TimeSeriesService getTimeSeriesService() {
return timeSeriesService; return timeSeriesService;
} }
@Override
public TimeSeriesType getTimeSeriesType() {
return TimeSeriesType.INTERFACES;
}
} }

View File

@ -1,12 +1,12 @@
package ru.ulstu.extractor.ts; package ru.ulstu.extractor.ts.creator;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import ru.ulstu.extractor.model.TimeSeriesValue; import ru.ulstu.extractor.ts.model.TimeSeries;
import ru.ulstu.extractor.service.TimeSeriesService; 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.List;
import java.util.Map;
@Component @Component
public class IssuesTS extends AbstractTimeSeriesCreator { public class IssuesTS extends AbstractTimeSeriesCreator {
@ -17,17 +17,17 @@ public class IssuesTS extends AbstractTimeSeriesCreator {
} }
@Override @Override
public String getTimeSeriesName() { public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
return "Количество issues созданных во времени"; return new ArrayList<>();
}
@Override
public Map<String, List<TimeSeriesValue>> getTimeSeriesValues(Integer repositoryId, String branchName) {
return new HashMap<>();
} }
@Override @Override
public TimeSeriesService getTimeSeriesService() { public TimeSeriesService getTimeSeriesService() {
return timeSeriesService; return timeSeriesService;
} }
@Override
public TimeSeriesType getTimeSeriesType() {
return TimeSeriesType.ISSUES;
}
} }

View File

@ -1,12 +1,12 @@
package ru.ulstu.extractor.ts; package ru.ulstu.extractor.ts.creator;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import ru.ulstu.extractor.model.TimeSeriesValue; import ru.ulstu.extractor.ts.model.TimeSeries;
import ru.ulstu.extractor.service.TimeSeriesService; 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.List;
import java.util.Map;
@Component @Component
public class ProcessTS extends AbstractTimeSeriesCreator { public class ProcessTS extends AbstractTimeSeriesCreator {
@ -17,17 +17,17 @@ public class ProcessTS extends AbstractTimeSeriesCreator {
} }
@Override @Override
public String getTimeSeriesName() { public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
return "Количество процессов"; return new ArrayList<>();
}
@Override
public Map<String, List<TimeSeriesValue>> getTimeSeriesValues(Integer repositoryId, String branchName) {
return new HashMap<>();
} }
@Override @Override
public TimeSeriesService getTimeSeriesService() { public TimeSeriesService getTimeSeriesService() {
return timeSeriesService; return timeSeriesService;
} }
@Override
public TimeSeriesType getTimeSeriesType() {
return TimeSeriesType.PROCESSES;
}
} }

View File

@ -1,12 +1,12 @@
package ru.ulstu.extractor.ts; package ru.ulstu.extractor.ts.creator;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import ru.ulstu.extractor.model.TimeSeriesValue; import ru.ulstu.extractor.ts.model.TimeSeries;
import ru.ulstu.extractor.service.TimeSeriesService; 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.List;
import java.util.Map;
@Component @Component
public class StarTS extends AbstractTimeSeriesCreator { public class StarTS extends AbstractTimeSeriesCreator {
@ -17,17 +17,17 @@ public class StarTS extends AbstractTimeSeriesCreator {
} }
@Override @Override
public String getTimeSeriesName() { public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
return "Количество звезд"; return new ArrayList<>();
}
@Override
public Map<String, List<TimeSeriesValue>> getTimeSeriesValues(Integer repositoryId, String branchName) {
return new HashMap<>();
} }
@Override @Override
public TimeSeriesService getTimeSeriesService() { public TimeSeriesService getTimeSeriesService() {
return timeSeriesService; return timeSeriesService;
} }
@Override
public TimeSeriesType getTimeSeriesType() {
return TimeSeriesType.STARS;
}
} }

View File

@ -1,10 +1,13 @@
package ru.ulstu.extractor.model; package ru.ulstu.extractor.ts.model;
import org.hibernate.annotations.Fetch; import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import ru.ulstu.extractor.core.BaseEntity;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType; import javax.persistence.FetchType;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
@ -19,6 +22,9 @@ public class TimeSeries extends BaseEntity {
@Fetch(FetchMode.SUBSELECT) @Fetch(FetchMode.SUBSELECT)
private List<TimeSeriesValue> values = new ArrayList<>(); private List<TimeSeriesValue> values = new ArrayList<>();
@Enumerated(EnumType.STRING)
private TimeSeriesType timeSeriesType;
public TimeSeries() { public TimeSeries() {
} }
@ -31,6 +37,12 @@ public class TimeSeries extends BaseEntity {
this.values = values; this.values = values;
} }
public TimeSeries(String name, TimeSeriesType timeSeriesType, List<TimeSeriesValue> values) {
this.name = name;
this.values = values;
this.timeSeriesType = timeSeriesType;
}
public String getName() { public String getName() {
return name; return name;
} }
@ -47,4 +59,11 @@ public class TimeSeries extends BaseEntity {
this.values = values; this.values = values;
} }
public TimeSeriesType getTimeSeriesType() {
return timeSeriesType;
}
public void setTimeSeriesType(TimeSeriesType timeSeriesType) {
this.timeSeriesType = timeSeriesType;
}
} }

View File

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

View File

@ -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 javax.persistence.Entity;
import java.util.Date; import java.util.Date;

View File

@ -1,7 +1,7 @@
package ru.ulstu.extractor.repository; package ru.ulstu.extractor.ts.repository;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import ru.ulstu.extractor.model.TimeSeries; import ru.ulstu.extractor.ts.model.TimeSeries;
import java.util.Optional; import java.util.Optional;

View File

@ -1,7 +1,7 @@
package ru.ulstu.extractor.repository; package ru.ulstu.extractor.ts.repository;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import ru.ulstu.extractor.model.TimeSeriesValue; import ru.ulstu.extractor.ts.model.TimeSeriesValue;
import java.util.List; import java.util.List;

View File

@ -3,7 +3,7 @@
* You may use, distribute and modify this code, please write to: romanov73@gmail.com. * 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.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -11,15 +11,18 @@ import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import ru.ulstu.extractor.http.HttpService; import ru.ulstu.extractor.http.HttpService;
import ru.ulstu.extractor.http.JsonTimeSeries; import ru.ulstu.extractor.http.JsonTimeSeries;
import ru.ulstu.extractor.model.TimeSeries; import ru.ulstu.extractor.ts.model.TimeSeries;
import ru.ulstu.extractor.model.TimeSeriesValue; import ru.ulstu.extractor.ts.model.TimeSeriesType;
import ru.ulstu.extractor.repository.TimeSeriesRepository; import ru.ulstu.extractor.ts.model.TimeSeriesValue;
import ru.ulstu.extractor.repository.TimeSeriesValueRepository; import ru.ulstu.extractor.ts.repository.TimeSeriesRepository;
import ru.ulstu.extractor.ts.TimeSeriesDateMapper; import ru.ulstu.extractor.ts.repository.TimeSeriesValueRepository;
import ru.ulstu.extractor.ts.util.TimeSeriesDateMapper;
import javax.transaction.Transactional; import javax.transaction.Transactional;
import java.util.*; import java.util.ArrayList;
import java.util.stream.Collectors; import java.util.Arrays;
import java.util.List;
import java.util.Optional;
@Service @Service
public class TimeSeriesService { public class TimeSeriesService {
@ -38,27 +41,13 @@ public class TimeSeriesService {
this.httpService = httpService; this.httpService = httpService;
} }
/**
* Сохранить список временных рядов
*
* @param timeSeriesValues
* @return
*/
@Transactional @Transactional
public List<TimeSeries> save(Map<String, List<TimeSeriesValue>> timeSeriesValues) { public TimeSeries save(String timeSeriesName, TimeSeriesType timeSeriesType, List<TimeSeriesValue> timeSeriesValues) {
List<TimeSeries> results = new ArrayList<>();
for (Map.Entry<String, List<TimeSeriesValue>> entry : timeSeriesValues.entrySet()) {
results.add(save(entry.getKey(), entry.getValue()));
}
return results;
}
@Transactional
public TimeSeries save(String timeSeriesName, List<TimeSeriesValue> timeSeriesValues) {
LOG.debug("Start save {} time series with {} time series values ", timeSeriesName, timeSeriesValues.size()); LOG.debug("Start save {} time series with {} time series values ", timeSeriesName, timeSeriesValues.size());
final TimeSeries timeSeries = findOrCreate(timeSeriesName); final TimeSeries timeSeries = findOrCreate(timeSeriesName);
List<TimeSeriesValue> timeSeriesValuesToRemove = timeSeries.getValues(); List<TimeSeriesValue> timeSeriesValuesToRemove = timeSeries.getValues();
timeSeries.setValues(timeSeriesValues); timeSeries.setValues(timeSeriesValues);
timeSeries.setTimeSeriesType(timeSeriesType);
LOG.debug("Save time series {} ", timeSeries.getName()); LOG.debug("Save time series {} ", timeSeries.getName());
TimeSeries savedTimeSeries = timeSeriesRepository.save(timeSeries); TimeSeries savedTimeSeries = timeSeriesRepository.save(timeSeries);
LOG.debug("Clear {} time series values ", timeSeriesValuesToRemove.size()); LOG.debug("Clear {} time series values ", timeSeriesValuesToRemove.size());
@ -76,23 +65,19 @@ public class TimeSeriesService {
return timeSeriesRepository.save(new TimeSeries(timeSeriesName)); return timeSeriesRepository.save(new TimeSeries(timeSeriesName));
} }
public List<TimeSeriesValue> save(List<TimeSeriesValue> timeSeriesValues) { /**
return timeSeriesValues.stream() * Сохранить список временных рядов
.map(timeSeriesValue -> { *
timeSeriesValue.setValue((timeSeriesValue.getValue())); * @param timeSeries список ВР
timeSeriesValue.setDate((timeSeriesValue.getDate())); * @return сохраненный список ВР
return timeSeriesValueRepository.save(timeSeriesValue); */
}).collect(Collectors.toList()); @Transactional
public List<TimeSeries> save(List<TimeSeries> timeSeries) {
List<TimeSeries> results = new ArrayList<>();
for (TimeSeries ts : timeSeries) {
results.add(save(ts.getName(), ts.getTimeSeriesType(), ts.getValues()));
} }
return results;
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<TimeSeriesValue> findAll() {
return timeSeriesValueRepository.findAll();
} }
public TimeSeriesDateMapper.TimeSeriesInterval getTimeSeriesInterval() { public TimeSeriesDateMapper.TimeSeriesInterval getTimeSeriesInterval() {
@ -118,4 +103,8 @@ public class TimeSeriesService {
return timeSeriesRepository.findById(tsId) return timeSeriesRepository.findById(tsId)
.orElseThrow(() -> new RuntimeException("Time series not found by id " + tsId)); .orElseThrow(() -> new RuntimeException("Time series not found by id " + tsId));
} }
public List<TimeSeriesType> getAllTimeSeriesTypes() {
return Arrays.asList(TimeSeriesType.values());
}
} }

View File

@ -1,8 +1,8 @@
package ru.ulstu.extractor.ts; package ru.ulstu.extractor.ts.util;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import ru.ulstu.extractor.model.TimeSeries; import ru.ulstu.extractor.ts.model.TimeSeries;
import ru.ulstu.extractor.model.TimeSeriesValue; import ru.ulstu.extractor.ts.model.TimeSeriesValue;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;

View File

@ -44,4 +44,40 @@
referencedTableName="time_series" referencedTableName="time_series"
referencedColumnNames="id"/> referencedColumnNames="id"/>
</changeSet> </changeSet>
<changeSet author="orion" id="20221012-170000-2">
<addColumn tableName="time_series">
<column name="time_series_type" type="varchar(100)"></column>
</addColumn>
</changeSet>
<changeSet author="orion" id="20221012-170000-3">
<dropForeignKeyConstraint baseTableName="rule" constraintName="fk_first_time_series"/>
<dropForeignKeyConstraint baseTableName="rule" constraintName="fk_second_antecedent_value"/>
<delete tableName="rule"/>
<dropColumn tableName="rule" columnName="first_antecedent_id"/>
<dropColumn tableName="rule" columnName="second_antecedent_id"/>
<addColumn tableName="rule">
<column name="first_antecedent" type="varchar(100)"/>
</addColumn>
<addColumn tableName="rule">
<column name="second_antecedent" type="varchar(100)"/>
</addColumn>
</changeSet>
<changeSet author="orion" id="20221012-170000-4">
<delete tableName="antecedent_value"/>
<insert tableName="antecedent_value">
<column name="id" value="1"/>
<column name="version" value="0"/>
<column name="antecedent_value" value="спад"/>
</insert>
<insert tableName="antecedent_value">
<column name="id" value="2"/>
<column name="version" value="0"/>
<column name="antecedent_value" value="стабильно"/>
</insert>
<insert tableName="antecedent_value">
<column name="id" value="3"/>
<column name="version" value="0"/>
<column name="antecedent_value" value="рост"/>
</insert>
</changeSet>
</databaseChangeLog> </databaseChangeLog>

View File

@ -12,6 +12,19 @@
<div class="col-md-2 col-sm-12"> <div class="col-md-2 col-sm-12">
Если Если
</div> </div>
<div class="col-md-6 col-sm-12">
<select id="select-antecedent" class="selectpicker" data-live-search="true"
th:field="*{firstAntecedentId}"
data-width="90%">
<option th:each="antecedent : ${antecedents}"
th:value="${antecedent}"
th:utext="${antecedent.description}">
</option>
</select>
</div>
<div class="col-md-2 col-sm-12">
имеет тенденцию
</div>
<div class="col-md-2 col-sm-12"> <div class="col-md-2 col-sm-12">
<select id="select-measures" class="selectpicker" data-live-search="true" <select id="select-measures" class="selectpicker" data-live-search="true"
th:field="*{firstAntecedentValueId}" th:field="*{firstAntecedentValueId}"
@ -23,20 +36,20 @@
</select> </select>
</div> </div>
<div class="col-md-2 col-sm-12"> <div class="col-md-2 col-sm-12">
временной ряд и
</div> </div>
<div class="col-md-6 col-sm-12"> <div class="col-md-6 col-sm-12">
<select id="select-antecedent" class="selectpicker" data-live-search="true" <select id="select-second-antecedent" class="selectpicker" data-live-search="true"
th:field="*{firstAntecedentId}" th:field="*{secondAntecedentId}"
data-width="90%"> data-width="90%">
<option th:each="antecedent : ${antecedents}" <option th:each="antecedent : ${antecedents}"
th:value="${antecedent.id}" th:value="${antecedent}"
th:utext="${antecedent.name}"> th:utext="${antecedent.description}">
</option> </option>
</select> </select>
</div> </div>
<div class="col-md-2 col-sm-12"> <div class="col-md-2 col-sm-12">
и имеет тенденцию
</div> </div>
<div class="col-md-2 col-sm-12"> <div class="col-md-2 col-sm-12">
<select id="select-second-measures" class="selectpicker" data-live-search="true" <select id="select-second-measures" class="selectpicker" data-live-search="true"
@ -48,26 +61,16 @@
</option> </option>
</select> </select>
</div> </div>
<div class="col-md-2 col-sm-12">
временной ряд
</div>
<div class="col-md-6 col-sm-12">
<select id="select-second-antecedent" class="selectpicker" data-live-search="true"
th:field="*{secondAntecedentId}"
data-width="90%">
<option th:each="antecedent : ${antecedents}"
th:value="${antecedent.id}"
th:utext="${antecedent.name}">
</option>
</select>
</div>
<div class="col-md-2 col-sm-12"> <div class="col-md-2 col-sm-12">
то: то:
</div> </div>
<div class="col-md-2 col-sm-12"> <div class="col-md-6 col-sm-12">
<input type="text" class="form-control" th:field="*{consequent}"> <input type="text" class="form-control" th:field="*{consequent}">
</div> </div>
<div class="col-md-8 col-sm-12"> </div>
<div class="row">
<div class="col-md-4 col-sm-12"></div>
<div class="col-md-4 col-sm-12">
<input type="submit" class="btn btn-outline-success" value="Создать правило"/> <input type="submit" class="btn btn-outline-success" value="Создать правило"/>
</div> </div>
</div> </div>

View File

@ -16,10 +16,10 @@
<tbody> <tbody>
<tr th:each="rule: ${rules}"> <tr th:each="rule: ${rules}">
<td><span class="badge badge-info">Если</span></td> <td><span class="badge badge-info">Если</span></td>
<td><span class="badge badge-success" th:text="${rule.firstAntecedent.name}"></span></td> <td><span class="badge badge-success" th:text="${rule.firstAntecedent.description}"></span></td>
<td><span class="badge badge-success" th:text="${rule.firstAntecedentValue.antecedentValue}"></span></td> <td><span class="badge badge-success" th:text="${rule.firstAntecedentValue.antecedentValue}"></span></td>
<td><span class="badge badge-info">и</span></td> <td><span class="badge badge-info">и</span></td>
<td><span class="badge badge-success" th:text="${rule.secondAntecedent.name}"></span></td> <td><span class="badge badge-success" th:text="${rule.secondAntecedent.description }"></span></td>
<td><span class="badge badge-success" th:text="${rule.secondAntecedentValue.antecedentValue}"></span></td> <td><span class="badge badge-success" th:text="${rule.secondAntecedentValue.antecedentValue}"></span></td>
<td><span class="badge badge-info">то</span></td> <td><span class="badge badge-info">то</span></td>
<td><span class="badge badge-warning" th:text="${rule.consequent}"></span></td> <td><span class="badge badge-warning" th:text="${rule.consequent}"></span></td>

View File

@ -2,9 +2,9 @@ package ru.ulstu;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import ru.ulstu.extractor.model.TimeSeries; import ru.ulstu.extractor.ts.model.TimeSeries;
import ru.ulstu.extractor.model.TimeSeriesValue; import ru.ulstu.extractor.ts.model.TimeSeriesValue;
import ru.ulstu.extractor.ts.TimeSeriesDateMapper; import ru.ulstu.extractor.ts.util.TimeSeriesDateMapper;
import java.util.Arrays; import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;