From 33e426e7f5c82f63830f816acbb380254171e0b5 Mon Sep 17 00:00:00 2001 From: alexandra Date: Thu, 22 Dec 2022 15:53:08 +0400 Subject: [PATCH] #78 - Add Dummy --- .../extractor/ts/creator/AuthorsCommitTS.java | 18 +++++++++++++++--- .../ts/creator/AuthorsCompletedIssueTS.java | 19 ++++++++++++++++--- .../extractor/ts/creator/AuthorsIssueTS.java | 18 +++++++++++++++--- .../ulstu/extractor/ts/creator/BranchTS.java | 18 +++++++++++++++--- .../ulstu/extractor/ts/creator/ClassTS.java | 18 +++++++++++++++--- .../extractor/ts/creator/DependenceTS.java | 18 +++++++++++++++--- .../extractor/ts/creator/InterfaceTS.java | 18 +++++++++++++++--- .../ulstu/extractor/ts/creator/IssuesTS.java | 18 +++++++++++++++--- .../ulstu/extractor/ts/creator/ProcessTS.java | 18 +++++++++++++++--- .../ru/ulstu/extractor/ts/creator/StarTS.java | 19 ++++++++++++++++--- .../ru/ulstu/extractor/ts/util/DateUtils.java | 13 +++++++++++++ .../ru/ulstu/extractor/ts/util/Dummy.java | 15 +++++++++++++++ 12 files changed, 180 insertions(+), 30 deletions(-) create mode 100644 src/main/java/ru/ulstu/extractor/ts/util/DateUtils.java create mode 100644 src/main/java/ru/ulstu/extractor/ts/util/Dummy.java diff --git a/src/main/java/ru/ulstu/extractor/ts/creator/AuthorsCommitTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/AuthorsCommitTS.java index 4be4592..005cda2 100644 --- a/src/main/java/ru/ulstu/extractor/ts/creator/AuthorsCommitTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/AuthorsCommitTS.java @@ -1,19 +1,24 @@ package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; +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.service.TimeSeriesService; +import ru.ulstu.extractor.ts.util.Dummy; -import java.util.ArrayList; +import java.util.Collections; import java.util.List; @Component public class AuthorsCommitTS extends AbstractTimeSeriesCreator { private final TimeSeriesService timeSeriesService; - public AuthorsCommitTS(TimeSeriesService timeSeriesService) { + private final GitRepositoryService gitRepositoryService; + + public AuthorsCommitTS(TimeSeriesService timeSeriesService, GitRepositoryService gitRepositoryService) { this.timeSeriesService = timeSeriesService; + this.gitRepositoryService = gitRepositoryService; } @Override @@ -23,7 +28,14 @@ public class AuthorsCommitTS extends AbstractTimeSeriesCreator { @Override public List getTimeSeries(Integer repositoryId, String branchName) { - return new ArrayList(); + return Collections.singletonList( + new TimeSeries( + String.format("%s %s %s", + gitRepositoryService.findById(repositoryId).getName(), + branchName, + getTimeSeriesType().getDescription()), + getTimeSeriesType(), + Dummy.getDefaultTimeSeries())); } @Override diff --git a/src/main/java/ru/ulstu/extractor/ts/creator/AuthorsCompletedIssueTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/AuthorsCompletedIssueTS.java index 1fa3ebb..fc25833 100644 --- a/src/main/java/ru/ulstu/extractor/ts/creator/AuthorsCompletedIssueTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/AuthorsCompletedIssueTS.java @@ -1,24 +1,37 @@ package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; +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.service.TimeSeriesService; +import ru.ulstu.extractor.ts.util.Dummy; -import java.util.ArrayList; + +import java.util.Collections; import java.util.List; @Component public class AuthorsCompletedIssueTS extends AbstractTimeSeriesCreator { private final TimeSeriesService timeSeriesService; - public AuthorsCompletedIssueTS(TimeSeriesService timeSeriesService) { + private final GitRepositoryService gitRepositoryService; + + public AuthorsCompletedIssueTS(TimeSeriesService timeSeriesService, GitRepositoryService gitRepositoryService) { this.timeSeriesService = timeSeriesService; + this.gitRepositoryService = gitRepositoryService; } @Override public List getTimeSeries(Integer repositoryId, String branchName) { - return new ArrayList<>(); + return Collections.singletonList( + new TimeSeries( + String.format("%s %s %s", + gitRepositoryService.findById(repositoryId).getName(), + branchName, + getTimeSeriesType().getDescription()), + getTimeSeriesType(), + Dummy.getDefaultTimeSeries())); } @Override diff --git a/src/main/java/ru/ulstu/extractor/ts/creator/AuthorsIssueTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/AuthorsIssueTS.java index 4ba5df2..f279362 100644 --- a/src/main/java/ru/ulstu/extractor/ts/creator/AuthorsIssueTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/AuthorsIssueTS.java @@ -1,24 +1,36 @@ package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; +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.service.TimeSeriesService; +import ru.ulstu.extractor.ts.util.Dummy; -import java.util.ArrayList; +import java.util.Collections; import java.util.List; @Component public class AuthorsIssueTS extends AbstractTimeSeriesCreator { private final TimeSeriesService timeSeriesService; - public AuthorsIssueTS(TimeSeriesService timeSeriesService) { + private final GitRepositoryService gitRepositoryService; + + public AuthorsIssueTS(TimeSeriesService timeSeriesService, GitRepositoryService gitRepositoryService) { this.timeSeriesService = timeSeriesService; + this.gitRepositoryService = gitRepositoryService; } @Override public List getTimeSeries(Integer repositoryId, String branchName) { - return new ArrayList(); + return Collections.singletonList( + new TimeSeries( + String.format("%s %s %s", + gitRepositoryService.findById(repositoryId).getName(), + branchName, + getTimeSeriesType().getDescription()), + getTimeSeriesType(), + Dummy.getDefaultTimeSeries())); } @Override diff --git a/src/main/java/ru/ulstu/extractor/ts/creator/BranchTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/BranchTS.java index aa6592e..b358cc7 100644 --- a/src/main/java/ru/ulstu/extractor/ts/creator/BranchTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/BranchTS.java @@ -1,19 +1,24 @@ package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; +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.service.TimeSeriesService; +import ru.ulstu.extractor.ts.util.Dummy; -import java.util.ArrayList; +import java.util.Collections; import java.util.List; @Component public class BranchTS extends AbstractTimeSeriesCreator { private final TimeSeriesService timeSeriesService; - public BranchTS(TimeSeriesService timeSeriesService) { + private final GitRepositoryService gitRepositoryService; + + public BranchTS(TimeSeriesService timeSeriesService, GitRepositoryService gitRepositoryService) { this.timeSeriesService = timeSeriesService; + this.gitRepositoryService = gitRepositoryService; } @Override @@ -23,7 +28,14 @@ public class BranchTS extends AbstractTimeSeriesCreator { @Override public List getTimeSeries(Integer repositoryId, String branchName) { - return new ArrayList<>(); + return Collections.singletonList( + new TimeSeries( + String.format("%s %s %s", + gitRepositoryService.findById(repositoryId).getName(), + branchName, + getTimeSeriesType().getDescription()), + getTimeSeriesType(), + Dummy.getDefaultTimeSeries())); } @Override diff --git a/src/main/java/ru/ulstu/extractor/ts/creator/ClassTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/ClassTS.java index 2e7e8ea..406bd43 100644 --- a/src/main/java/ru/ulstu/extractor/ts/creator/ClassTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/ClassTS.java @@ -1,24 +1,36 @@ package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; +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.service.TimeSeriesService; +import ru.ulstu.extractor.ts.util.Dummy; -import java.util.ArrayList; +import java.util.Collections; import java.util.List; @Component public class ClassTS extends AbstractTimeSeriesCreator { private final TimeSeriesService timeSeriesService; - public ClassTS(TimeSeriesService timeSeriesService) { + private final GitRepositoryService gitRepositoryService; + + public ClassTS(TimeSeriesService timeSeriesService, GitRepositoryService gitRepositoryService) { this.timeSeriesService = timeSeriesService; + this.gitRepositoryService = gitRepositoryService; } @Override public List getTimeSeries(Integer repositoryId, String branchName) { - return new ArrayList(); + return Collections.singletonList( + new TimeSeries( + String.format("%s %s %s", + gitRepositoryService.findById(repositoryId).getName(), + branchName, + getTimeSeriesType().getDescription()), + getTimeSeriesType(), + Dummy.getDefaultTimeSeries())); } @Override diff --git a/src/main/java/ru/ulstu/extractor/ts/creator/DependenceTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/DependenceTS.java index e534627..d0ba6cb 100644 --- a/src/main/java/ru/ulstu/extractor/ts/creator/DependenceTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/DependenceTS.java @@ -1,24 +1,36 @@ package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; +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.service.TimeSeriesService; +import ru.ulstu.extractor.ts.util.Dummy; -import java.util.ArrayList; +import java.util.Collections; import java.util.List; @Component public class DependenceTS extends AbstractTimeSeriesCreator { private final TimeSeriesService timeSeriesService; - public DependenceTS(TimeSeriesService timeSeriesService) { + private final GitRepositoryService gitRepositoryService; + + public DependenceTS(TimeSeriesService timeSeriesService, GitRepositoryService gitRepositoryService) { this.timeSeriesService = timeSeriesService; + this.gitRepositoryService = gitRepositoryService; } @Override public List getTimeSeries(Integer repositoryId, String branchName) { - return new ArrayList(); + return Collections.singletonList( + new TimeSeries( + String.format("%s %s %s", + gitRepositoryService.findById(repositoryId).getName(), + branchName, + getTimeSeriesType().getDescription()), + getTimeSeriesType(), + Dummy.getDefaultTimeSeries())); } @Override diff --git a/src/main/java/ru/ulstu/extractor/ts/creator/InterfaceTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/InterfaceTS.java index 8821f8c..0e3d3e5 100644 --- a/src/main/java/ru/ulstu/extractor/ts/creator/InterfaceTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/InterfaceTS.java @@ -1,24 +1,36 @@ package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; +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.service.TimeSeriesService; +import ru.ulstu.extractor.ts.util.Dummy; -import java.util.ArrayList; +import java.util.Collections; import java.util.List; @Component public class InterfaceTS extends AbstractTimeSeriesCreator { private final TimeSeriesService timeSeriesService; - public InterfaceTS(TimeSeriesService timeSeriesService) { + private final GitRepositoryService gitRepositoryService; + + public InterfaceTS(TimeSeriesService timeSeriesService, GitRepositoryService gitRepositoryService) { this.timeSeriesService = timeSeriesService; + this.gitRepositoryService = gitRepositoryService; } @Override public List getTimeSeries(Integer repositoryId, String branchName) { - return new ArrayList(); + return Collections.singletonList( + new TimeSeries( + String.format("%s %s %s", + gitRepositoryService.findById(repositoryId).getName(), + branchName, + getTimeSeriesType().getDescription()), + getTimeSeriesType(), + Dummy.getDefaultTimeSeries())); } @Override diff --git a/src/main/java/ru/ulstu/extractor/ts/creator/IssuesTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/IssuesTS.java index eef0e20..20ef996 100644 --- a/src/main/java/ru/ulstu/extractor/ts/creator/IssuesTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/IssuesTS.java @@ -1,24 +1,36 @@ package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; +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.service.TimeSeriesService; +import ru.ulstu.extractor.ts.util.Dummy; -import java.util.ArrayList; +import java.util.Collections; import java.util.List; @Component public class IssuesTS extends AbstractTimeSeriesCreator { private final TimeSeriesService timeSeriesService; - public IssuesTS(TimeSeriesService timeSeriesService) { + private final GitRepositoryService gitRepositoryService; + + public IssuesTS(TimeSeriesService timeSeriesService, GitRepositoryService gitRepositoryService) { this.timeSeriesService = timeSeriesService; + this.gitRepositoryService = gitRepositoryService; } @Override public List getTimeSeries(Integer repositoryId, String branchName) { - return new ArrayList<>(); + return Collections.singletonList( + new TimeSeries( + String.format("%s %s %s", + gitRepositoryService.findById(repositoryId).getName(), + branchName, + getTimeSeriesType().getDescription()), + getTimeSeriesType(), + Dummy.getDefaultTimeSeries())); } @Override diff --git a/src/main/java/ru/ulstu/extractor/ts/creator/ProcessTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/ProcessTS.java index f375b66..0000758 100644 --- a/src/main/java/ru/ulstu/extractor/ts/creator/ProcessTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/ProcessTS.java @@ -1,24 +1,36 @@ package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; +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.service.TimeSeriesService; +import ru.ulstu.extractor.ts.util.Dummy; -import java.util.ArrayList; +import java.util.Collections; import java.util.List; @Component public class ProcessTS extends AbstractTimeSeriesCreator { private final TimeSeriesService timeSeriesService; - public ProcessTS(TimeSeriesService timeSeriesService) { + private final GitRepositoryService gitRepositoryService; + + public ProcessTS(TimeSeriesService timeSeriesService, GitRepositoryService gitRepositoryService) { this.timeSeriesService = timeSeriesService; + this.gitRepositoryService = gitRepositoryService; } @Override public List getTimeSeries(Integer repositoryId, String branchName) { - return new ArrayList<>(); + return Collections.singletonList( + new TimeSeries( + String.format("%s %s %s", + gitRepositoryService.findById(repositoryId).getName(), + branchName, + getTimeSeriesType().getDescription()), + getTimeSeriesType(), + Dummy.getDefaultTimeSeries())); } @Override diff --git a/src/main/java/ru/ulstu/extractor/ts/creator/StarTS.java b/src/main/java/ru/ulstu/extractor/ts/creator/StarTS.java index 557e9be..b628576 100644 --- a/src/main/java/ru/ulstu/extractor/ts/creator/StarTS.java +++ b/src/main/java/ru/ulstu/extractor/ts/creator/StarTS.java @@ -1,24 +1,37 @@ package ru.ulstu.extractor.ts.creator; import org.springframework.stereotype.Component; +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.service.TimeSeriesService; +import ru.ulstu.extractor.ts.util.Dummy; -import java.util.ArrayList; + +import java.util.Collections; import java.util.List; @Component public class StarTS extends AbstractTimeSeriesCreator { private final TimeSeriesService timeSeriesService; - public StarTS(TimeSeriesService timeSeriesService) { + private final GitRepositoryService gitRepositoryService; + + public StarTS(TimeSeriesService timeSeriesService, GitRepositoryService gitRepositoryService) { this.timeSeriesService = timeSeriesService; + this.gitRepositoryService = gitRepositoryService; } @Override public List getTimeSeries(Integer repositoryId, String branchName) { - return new ArrayList<>(); + return Collections.singletonList( + new TimeSeries( + String.format("%s %s %s", + gitRepositoryService.findById(repositoryId).getName(), + branchName, + getTimeSeriesType().getDescription()), + getTimeSeriesType(), + Dummy.getDefaultTimeSeries())); } @Override diff --git a/src/main/java/ru/ulstu/extractor/ts/util/DateUtils.java b/src/main/java/ru/ulstu/extractor/ts/util/DateUtils.java new file mode 100644 index 0000000..773e9e0 --- /dev/null +++ b/src/main/java/ru/ulstu/extractor/ts/util/DateUtils.java @@ -0,0 +1,13 @@ +package ru.ulstu.extractor.ts.util; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +public class DateUtils { + public static Date addMonths(int amount) { + Calendar c = GregorianCalendar.getInstance(); + c.add(Calendar.DAY_OF_MONTH, amount); + return c.getTime(); + } +} diff --git a/src/main/java/ru/ulstu/extractor/ts/util/Dummy.java b/src/main/java/ru/ulstu/extractor/ts/util/Dummy.java new file mode 100644 index 0000000..61b0389 --- /dev/null +++ b/src/main/java/ru/ulstu/extractor/ts/util/Dummy.java @@ -0,0 +1,15 @@ +package ru.ulstu.extractor.ts.util; + +import ru.ulstu.extractor.ts.model.TimeSeriesValue; + +import java.util.List; + +public class Dummy { + public static List getDefaultTimeSeries (){ + return List.of(new TimeSeriesValue(DateUtils.addMonths(-5), 1.0), + new TimeSeriesValue(DateUtils.addMonths(-4), 2.0), + new TimeSeriesValue(DateUtils.addMonths(-3), 3.0), + new TimeSeriesValue(DateUtils.addMonths(-2), 4.0), + new TimeSeriesValue(DateUtils.addMonths(-1), 5.0)); + } +}