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;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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.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 {

View File

@ -1,4 +1,4 @@
package ru.ulstu.extractor.model;
package ru.ulstu.extractor.core;
import javax.persistence.GeneratedValue;
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.Sort;

View File

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

View File

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

View File

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

View File

@ -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)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
package ru.ulstu.extractor.model.mvc;
package ru.ulstu.extractor.gitrepository.model;
public class RepoForm {
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 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.
*/
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;

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.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;

View File

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

View File

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

View File

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

View File

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

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

View File

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

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;

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

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 ru.ulstu.extractor.model.AntecedentValue;
import ru.ulstu.extractor.rule.model.AntecedentValue;
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 ru.ulstu.extractor.model.Rule;
import ru.ulstu.extractor.rule.model.Rule;
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 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;

View File

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

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

View File

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

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 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 ru.ulstu.extractor.model.TimeSeries;
import ru.ulstu.extractor.ts.model.TimeSeries;
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 ru.ulstu.extractor.model.TimeSeriesValue;
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
import java.util.List;

View File

@ -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<TimeSeries> save(Map<String, 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) {
public TimeSeries save(String timeSeriesName, TimeSeriesType timeSeriesType, List<TimeSeriesValue> timeSeriesValues) {
LOG.debug("Start save {} time series with {} time series values ", timeSeriesName, timeSeriesValues.size());
final TimeSeries timeSeries = findOrCreate(timeSeriesName);
List<TimeSeriesValue> 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<TimeSeriesValue> save(List<TimeSeriesValue> timeSeriesValues) {
return timeSeriesValues.stream()
.map(timeSeriesValue -> {
timeSeriesValue.setValue((timeSeriesValue.getValue()));
timeSeriesValue.setDate((timeSeriesValue.getDate()));
return timeSeriesValueRepository.save(timeSeriesValue);
}).collect(Collectors.toList());
/**
* Сохранить список временных рядов
*
* @param timeSeries список ВР
* @return сохраненный список ВР
*/
@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()));
}
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();
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<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 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;

View File

@ -44,4 +44,40 @@
referencedTableName="time_series"
referencedColumnNames="id"/>
</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>

View File

@ -12,6 +12,19 @@
<div class="col-md-2 col-sm-12">
Если
</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">
<select id="select-measures" class="selectpicker" data-live-search="true"
th:field="*{firstAntecedentValueId}"
@ -23,20 +36,20 @@
</select>
</div>
<div class="col-md-2 col-sm-12">
временной ряд
и
</div>
<div class="col-md-6 col-sm-12">
<select id="select-antecedent" class="selectpicker" data-live-search="true"
th:field="*{firstAntecedentId}"
<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}">
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">
<select id="select-second-measures" class="selectpicker" data-live-search="true"
@ -48,26 +61,16 @@
</option>
</select>
</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>
<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}">
</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="Создать правило"/>
</div>
</div>

View File

@ -16,10 +16,10 @@
<tbody>
<tr th:each="rule: ${rules}">
<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-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-info">то</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.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;