WIP: страницы для правил #62
@ -1,17 +1,18 @@
|
|||||||
package ru.ulstu.extractor.ts.creator;
|
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.model.TimeSeriesValue;
|
||||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static ru.ulstu.extractor.ts.util.TimeSeriesDateMapper.mapTimeSeriesToInterval;
|
import static ru.ulstu.extractor.ts.util.TimeSeriesDateMapper.mapTimeSeriesToInterval;
|
||||||
|
|
||||||
public abstract class AbstractTimeSeriesCreator {
|
public abstract class AbstractTimeSeriesCreator {
|
||||||
|
|
||||||
public abstract String getTimeSeriesName();
|
public abstract TimeSeriesType getTimeSeriesType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Извлечь список точек временных рядов
|
* Извлечь список точек временных рядов
|
||||||
@ -20,7 +21,7 @@ public abstract class AbstractTimeSeriesCreator {
|
|||||||
* @param branchName
|
* @param branchName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public abstract Map<String, List<TimeSeriesValue>> getTimeSeriesValues(Integer repositoryId, String branchName);
|
public abstract List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName);
|
||||||
|
|
||||||
public abstract TimeSeriesService getTimeSeriesService();
|
public abstract TimeSeriesService getTimeSeriesService();
|
||||||
|
|
||||||
@ -31,18 +32,18 @@ public abstract class AbstractTimeSeriesCreator {
|
|||||||
* @param branchName
|
* @param branchName
|
||||||
*/
|
*/
|
||||||
public void addTimeSeries(Integer repositoryId, String branchName) {
|
public void addTimeSeries(Integer repositoryId, String branchName) {
|
||||||
// извлеченные точки временных рядов
|
// извлеченные временных рядов
|
||||||
Map<String, List<TimeSeriesValue>> timeSeriesValues = getTimeSeriesValues(repositoryId, branchName);
|
List<TimeSeries> timeSeries = getTimeSeries(repositoryId, branchName);
|
||||||
|
|
||||||
// сгруппированные по временным интервалам точки временных рядов
|
// сгруппированные по временным интервалам точки временных рядов
|
||||||
timeSeriesValues.replaceAll((k, v) -> mapTimeSeriesToInterval(getTimeSeriesService().getTimeSeriesInterval(), v));
|
timeSeries.forEach(ts -> ts.setValues(mapTimeSeriesToInterval(getTimeSeriesService().getTimeSeriesInterval(), ts.getValues())));
|
||||||
getTimeSeriesService().save(sortTimeSeriesValues(timeSeriesValues));
|
getTimeSeriesService().save(sortTimeSeries(timeSeries));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, List<TimeSeriesValue>> sortTimeSeriesValues(Map<String, List<TimeSeriesValue>> timeSeriesValues) {
|
private List<TimeSeries> sortTimeSeries(List<TimeSeries> timeSeries) {
|
||||||
for (Map.Entry<String, List<TimeSeriesValue>> entry : timeSeriesValues.entrySet()) {
|
for (TimeSeries ts : timeSeries) {
|
||||||
entry.getValue().sort(Comparator.comparing(TimeSeriesValue::getDate));
|
ts.getValues().sort(Comparator.comparing(TimeSeriesValue::getDate));
|
||||||
}
|
}
|
||||||
return timeSeriesValues;
|
return timeSeries;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package ru.ulstu.extractor.ts.creator;
|
package ru.ulstu.extractor.ts.creator;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
import ru.ulstu.extractor.ts.model.TimeSeries;
|
||||||
|
import ru.ulstu.extractor.ts.model.TimeSeriesType;
|
||||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
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
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
package ru.ulstu.extractor.ts.creator;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
|
||||||
import ru.ulstu.extractor.ts.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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,12 @@
|
|||||||
package ru.ulstu.extractor.ts.creator;
|
package ru.ulstu.extractor.ts.creator;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
import ru.ulstu.extractor.ts.model.TimeSeries;
|
||||||
|
import ru.ulstu.extractor.ts.model.TimeSeriesType;
|
||||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package ru.ulstu.extractor.ts.creator;
|
package ru.ulstu.extractor.ts.creator;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
import ru.ulstu.extractor.ts.model.TimeSeries;
|
||||||
|
import ru.ulstu.extractor.ts.model.TimeSeriesType;
|
||||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package ru.ulstu.extractor.ts.creator;
|
package ru.ulstu.extractor.ts.creator;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
import ru.ulstu.extractor.ts.model.TimeSeries;
|
||||||
|
import ru.ulstu.extractor.ts.model.TimeSeriesType;
|
||||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
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
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package ru.ulstu.extractor.ts.creator;
|
package ru.ulstu.extractor.ts.creator;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
import ru.ulstu.extractor.ts.model.TimeSeries;
|
||||||
|
import ru.ulstu.extractor.ts.model.TimeSeriesType;
|
||||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,13 @@ package ru.ulstu.extractor.ts.creator;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import ru.ulstu.extractor.commit.service.CommitService;
|
import ru.ulstu.extractor.commit.service.CommitService;
|
||||||
import ru.ulstu.extractor.gitrepository.service.GitRepositoryService;
|
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.model.TimeSeriesValue;
|
||||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@ -26,26 +27,28 @@ public class CommitsTS extends AbstractTimeSeriesCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTimeSeriesName() {
|
public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
|
||||||
return "Количество коммитов во времени";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, List<TimeSeriesValue>> getTimeSeriesValues(Integer repositoryId, String branchName) {
|
|
||||||
//TODO: добавить постраничное чтение
|
//TODO: добавить постраничное чтение
|
||||||
Map<String, List<TimeSeriesValue>> result = new HashMap<>();
|
return Collections.singletonList(
|
||||||
result.put(String.format("%s %s %s", gitRepositoryService.findById(repositoryId).getName(),
|
new TimeSeries(
|
||||||
|
String.format("%s %s %s",
|
||||||
|
gitRepositoryService.findById(repositoryId).getName(),
|
||||||
branchName,
|
branchName,
|
||||||
getTimeSeriesName()),
|
getTimeSeriesType().getDescription()),
|
||||||
|
getTimeSeriesType(),
|
||||||
commitService.findByRepositoryIdAndName(repositoryId, branchName)
|
commitService.findByRepositoryIdAndName(repositoryId, branchName)
|
||||||
.stream()
|
.stream()
|
||||||
.map(c -> new TimeSeriesValue(c.getDate(), 1.0))
|
.map(c -> new TimeSeriesValue(c.getDate(), 1.0))
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList())));
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TimeSeriesService getTimeSeriesService() {
|
public TimeSeriesService getTimeSeriesService() {
|
||||||
return timeSeriesService;
|
return timeSeriesService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TimeSeriesType getTimeSeriesType() {
|
||||||
|
return TimeSeriesType.COMMITS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package ru.ulstu.extractor.ts.creator;
|
package ru.ulstu.extractor.ts.creator;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
import ru.ulstu.extractor.ts.model.TimeSeries;
|
||||||
|
import ru.ulstu.extractor.ts.model.TimeSeriesType;
|
||||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package ru.ulstu.extractor.ts.creator;
|
package ru.ulstu.extractor.ts.creator;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
import ru.ulstu.extractor.ts.model.TimeSeries;
|
||||||
|
import ru.ulstu.extractor.ts.model.TimeSeriesType;
|
||||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package ru.ulstu.extractor.ts.creator;
|
package ru.ulstu.extractor.ts.creator;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
import ru.ulstu.extractor.ts.model.TimeSeries;
|
||||||
|
import ru.ulstu.extractor.ts.model.TimeSeriesType;
|
||||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package ru.ulstu.extractor.ts.creator;
|
package ru.ulstu.extractor.ts.creator;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
import ru.ulstu.extractor.ts.model.TimeSeries;
|
||||||
|
import ru.ulstu.extractor.ts.model.TimeSeriesType;
|
||||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package ru.ulstu.extractor.ts.creator;
|
package ru.ulstu.extractor.ts.creator;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
import ru.ulstu.extractor.ts.model.TimeSeries;
|
||||||
|
import ru.ulstu.extractor.ts.model.TimeSeriesType;
|
||||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package ru.ulstu.extractor.ts.creator;
|
package ru.ulstu.extractor.ts.creator;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
import ru.ulstu.extractor.ts.model.TimeSeries;
|
||||||
|
import ru.ulstu.extractor.ts.model.TimeSeriesType;
|
||||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package ru.ulstu.extractor.ts.creator;
|
package ru.ulstu.extractor.ts.creator;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
import ru.ulstu.extractor.ts.model.TimeSeries;
|
||||||
|
import ru.ulstu.extractor.ts.model.TimeSeriesType;
|
||||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ 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;
|
||||||
@ -20,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() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,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;
|
||||||
}
|
}
|
||||||
@ -48,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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -12,6 +12,7 @@ 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.ts.model.TimeSeries;
|
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.model.TimeSeriesValue;
|
||||||
import ru.ulstu.extractor.ts.repository.TimeSeriesRepository;
|
import ru.ulstu.extractor.ts.repository.TimeSeriesRepository;
|
||||||
import ru.ulstu.extractor.ts.repository.TimeSeriesValueRepository;
|
import ru.ulstu.extractor.ts.repository.TimeSeriesValueRepository;
|
||||||
@ -19,11 +20,8 @@ import ru.ulstu.extractor.ts.util.TimeSeriesDateMapper;
|
|||||||
|
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class TimeSeriesService {
|
public class TimeSeriesService {
|
||||||
@ -42,27 +40,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());
|
||||||
@ -80,23 +64,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() {
|
||||||
|
@ -44,4 +44,9 @@
|
|||||||
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>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
Loading…
Reference in New Issue
Block a user