From 3f4a310ae539cb8a06a675a8e8f9714f2a8f6079 Mon Sep 17 00:00:00 2001 From: upagge Date: Sun, 20 Sep 2020 10:07:08 +0300 Subject: [PATCH] Change -> Notify --- .../properties/CommentSchedulerProperty.java | 1 - .../Change.java => notify/Notify.java} | 8 +- .../NotifyType.java} | 4 +- .../comment/AnswerCommentNotify.java} | 12 +- .../comment/CommentNotify.java} | 12 +- .../pullrequest/ConflictPrNotify.java} | 10 +- .../pullrequest/NewPrNotify.java} | 10 +- .../pullrequest/PrNotify.java} | 10 +- .../pullrequest/ReviewersPrNotify.java} | 10 +- .../pullrequest/StatusPrNotify.java} | 10 +- .../pullrequest/UpdatePrNotify.java} | 10 +- .../task/TaskCloseNotify.java} | 10 +- .../task/TaskNewNotify.java} | 10 +- .../task/TaskNotify.java} | 12 +- .../vcs/core/domain/util/ReviewerChange.java | 4 +- .../vcs/core/repository/ChangeRepository.java | 16 -- .../vcs/core/repository/NotifyRepository.java | 16 ++ .../repository/impl/ChangeRepositoryImpl.java | 35 --- .../repository/impl/NotifyRepositoryImpl.java | 35 +++ ...cation.java => NotificationScheduler.java} | 2 +- ...rsing.java => NotifyParsingScheduler.java} | 18 +- .../vcs/core/scheduler/SchedulerComments.java | 224 ------------------ ...{ChangeService.java => NotifyService.java} | 10 +- .../core/service/impl/ChangeServiceImpl.java | 29 --- .../core/service/impl/CommentServiceImpl.java | 20 +- .../core/service/impl/NotifyServiceImpl.java | 29 +++ .../service/impl/PullRequestsServiceImpl.java | 38 +-- .../core/service/impl/TaskServiceImpl.java | 36 +-- 28 files changed, 208 insertions(+), 433 deletions(-) rename bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/{change/Change.java => notify/Notify.java} (73%) rename bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/{change/ChangeType.java => notify/NotifyType.java} (71%) rename bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/{change/comment/AnswerCommentChange.java => notify/comment/AnswerCommentNotify.java} (80%) rename bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/{change/comment/CommentChange.java => notify/comment/CommentNotify.java} (75%) rename bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/{change/pullrequest/ConflictPrChange.java => notify/pullrequest/ConflictPrNotify.java} (68%) rename bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/{change/pullrequest/NewPrChange.java => notify/pullrequest/NewPrNotify.java} (79%) rename bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/{change/pullrequest/PrChange.java => notify/pullrequest/PrNotify.java} (52%) rename bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/{change/pullrequest/ReviewersPrChange.java => notify/pullrequest/ReviewersPrNotify.java} (91%) rename bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/{change/pullrequest/StatusPrChange.java => notify/pullrequest/StatusPrNotify.java} (79%) rename bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/{change/pullrequest/UpdatePrChange.java => notify/pullrequest/UpdatePrNotify.java} (75%) rename bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/{change/task/TaskCloseChange.java => notify/task/TaskCloseNotify.java} (72%) rename bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/{change/task/TaskNewChange.java => notify/task/TaskNewNotify.java} (73%) rename bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/{change/task/TaskChange.java => notify/task/TaskNotify.java} (65%) delete mode 100644 bot-core/src/main/java/org/sadtech/bot/vcs/core/repository/ChangeRepository.java create mode 100644 bot-core/src/main/java/org/sadtech/bot/vcs/core/repository/NotifyRepository.java delete mode 100644 bot-core/src/main/java/org/sadtech/bot/vcs/core/repository/impl/ChangeRepositoryImpl.java create mode 100644 bot-core/src/main/java/org/sadtech/bot/vcs/core/repository/impl/NotifyRepositoryImpl.java rename bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/{SchedulerNotification.java => NotificationScheduler.java} (98%) rename bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/{SchedulerChangeParsing.java => NotifyParsingScheduler.java} (74%) delete mode 100644 bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/SchedulerComments.java rename bot-core/src/main/java/org/sadtech/bot/vcs/core/service/{ChangeService.java => NotifyService.java} (61%) delete mode 100644 bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/ChangeServiceImpl.java create mode 100644 bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/NotifyServiceImpl.java diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/config/properties/CommentSchedulerProperty.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/config/properties/CommentSchedulerProperty.java index 63b107d..65eed4e 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/config/properties/CommentSchedulerProperty.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/config/properties/CommentSchedulerProperty.java @@ -2,7 +2,6 @@ package org.sadtech.bot.vcs.core.config.properties; import lombok.Getter; import lombok.Setter; -import org.sadtech.bot.vcs.core.scheduler.SchedulerComments; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/Change.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/Notify.java similarity index 73% rename from bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/Change.java rename to bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/Notify.java index bafbaa0..24bcc56 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/Change.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/Notify.java @@ -1,4 +1,4 @@ -package org.sadtech.bot.vcs.core.domain.change; +package org.sadtech.bot.vcs.core.domain.notify; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -9,9 +9,9 @@ import java.util.Set; @Getter @EqualsAndHashCode(onlyExplicitlyIncluded = true) -public abstract class Change { +public abstract class Notify { - protected final ChangeType type; + protected final NotifyType type; protected final LocalDateTime localDateTime = LocalDateTime.now(); protected final Set telegramIds; @@ -19,7 +19,7 @@ public abstract class Change { @EqualsAndHashCode.Include protected Long id; - protected Change(ChangeType type, Set telegramIds) { + protected Notify(NotifyType type, Set telegramIds) { this.type = type; this.telegramIds = telegramIds; } diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/ChangeType.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/NotifyType.java similarity index 71% rename from bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/ChangeType.java rename to bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/NotifyType.java index 1c34b87..c34151a 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/ChangeType.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/NotifyType.java @@ -1,6 +1,6 @@ -package org.sadtech.bot.vcs.core.domain.change; +package org.sadtech.bot.vcs.core.domain.notify; -public enum ChangeType { +public enum NotifyType { STATUS_PR, UPDATE_PR, diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/comment/AnswerCommentChange.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/comment/AnswerCommentNotify.java similarity index 80% rename from bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/comment/AnswerCommentChange.java rename to bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/comment/AnswerCommentNotify.java index b093360..c80fd1a 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/comment/AnswerCommentChange.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/comment/AnswerCommentNotify.java @@ -1,11 +1,11 @@ -package org.sadtech.bot.vcs.core.domain.change.comment; +package org.sadtech.bot.vcs.core.domain.notify.comment; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; import org.sadtech.bot.vcs.core.domain.Answer; -import org.sadtech.bot.vcs.core.domain.change.Change; -import org.sadtech.bot.vcs.core.domain.change.ChangeType; +import org.sadtech.bot.vcs.core.domain.notify.Notify; +import org.sadtech.bot.vcs.core.domain.notify.NotifyType; import org.sadtech.bot.vcs.core.utils.Smile; import java.text.MessageFormat; @@ -15,20 +15,20 @@ import java.util.stream.Collectors; @Getter @EqualsAndHashCode(callSuper = true) -public class AnswerCommentChange extends Change { +public class AnswerCommentNotify extends Notify { private final String youMessage; private final String url; private final List answers; @Builder - protected AnswerCommentChange( + protected AnswerCommentNotify( Set telegramIds, String youMessage, String url, List answers ) { - super(ChangeType.NEW_ANSWERS_COMMENT, telegramIds); + super(NotifyType.NEW_ANSWERS_COMMENT, telegramIds); this.youMessage = youMessage; this.url = url; this.answers = answers; diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/comment/CommentChange.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/comment/CommentNotify.java similarity index 75% rename from bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/comment/CommentChange.java rename to bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/comment/CommentNotify.java index ae88df4..df08609 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/comment/CommentChange.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/comment/CommentNotify.java @@ -1,10 +1,10 @@ -package org.sadtech.bot.vcs.core.domain.change.comment; +package org.sadtech.bot.vcs.core.domain.notify.comment; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; -import org.sadtech.bot.vcs.core.domain.change.Change; -import org.sadtech.bot.vcs.core.domain.change.ChangeType; +import org.sadtech.bot.vcs.core.domain.notify.Notify; +import org.sadtech.bot.vcs.core.domain.notify.NotifyType; import org.sadtech.bot.vcs.core.utils.Smile; import java.text.MessageFormat; @@ -12,20 +12,20 @@ import java.util.Set; @Getter @EqualsAndHashCode(callSuper = true) -public class CommentChange extends Change { +public class CommentNotify extends Notify { private final String authorName; private final String message; private final String url; @Builder - private CommentChange( + private CommentNotify( Set telegramIds, String url, String authorName, String message ) { - super(ChangeType.NEW_COMMENT, telegramIds); + super(NotifyType.NEW_COMMENT, telegramIds); this.authorName = authorName; this.message = message; this.url = url; diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/pullrequest/ConflictPrChange.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/ConflictPrNotify.java similarity index 68% rename from bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/pullrequest/ConflictPrChange.java rename to bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/ConflictPrNotify.java index 4caa4db..39ffce0 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/pullrequest/ConflictPrChange.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/ConflictPrNotify.java @@ -1,23 +1,23 @@ -package org.sadtech.bot.vcs.core.domain.change.pullrequest; +package org.sadtech.bot.vcs.core.domain.notify.pullrequest; import lombok.Builder; import lombok.Getter; -import org.sadtech.bot.vcs.core.domain.change.ChangeType; +import org.sadtech.bot.vcs.core.domain.notify.NotifyType; import org.sadtech.bot.vcs.core.utils.Smile; import java.text.MessageFormat; import java.util.Set; @Getter -public class ConflictPrChange extends PrChange { +public class ConflictPrNotify extends PrNotify { @Builder - private ConflictPrChange( + private ConflictPrNotify( Set telegramIds, String name, String url ) { - super(ChangeType.CONFLICT_PR, telegramIds, name, url); + super(NotifyType.CONFLICT_PR, telegramIds, name, url); } @Override diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/pullrequest/NewPrChange.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/NewPrNotify.java similarity index 79% rename from bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/pullrequest/NewPrChange.java rename to bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/NewPrNotify.java index 9a5f2b1..6b9374b 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/pullrequest/NewPrChange.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/NewPrNotify.java @@ -1,9 +1,9 @@ -package org.sadtech.bot.vcs.core.domain.change.pullrequest; +package org.sadtech.bot.vcs.core.domain.notify.pullrequest; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; -import org.sadtech.bot.vcs.core.domain.change.ChangeType; +import org.sadtech.bot.vcs.core.domain.notify.NotifyType; import org.sadtech.bot.vcs.core.utils.Smile; import java.text.MessageFormat; @@ -11,19 +11,19 @@ import java.util.Set; @Getter @EqualsAndHashCode(callSuper = true) -public class NewPrChange extends PrChange { +public class NewPrNotify extends PrNotify { private final String description; private final String author; @Builder - private NewPrChange( + private NewPrNotify( Set telegramIds, String title, String url, String description, String author) { - super(ChangeType.NEW_PR, telegramIds, title, url); + super(NotifyType.NEW_PR, telegramIds, title, url); this.description = description; this.author = author; } diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/pullrequest/PrChange.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/PrNotify.java similarity index 52% rename from bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/pullrequest/PrChange.java rename to bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/PrNotify.java index bb7369e..c3f5f14 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/pullrequest/PrChange.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/PrNotify.java @@ -1,20 +1,20 @@ -package org.sadtech.bot.vcs.core.domain.change.pullrequest; +package org.sadtech.bot.vcs.core.domain.notify.pullrequest; import lombok.EqualsAndHashCode; import lombok.Getter; -import org.sadtech.bot.vcs.core.domain.change.Change; -import org.sadtech.bot.vcs.core.domain.change.ChangeType; +import org.sadtech.bot.vcs.core.domain.notify.Notify; +import org.sadtech.bot.vcs.core.domain.notify.NotifyType; import java.util.Set; @Getter @EqualsAndHashCode(callSuper = true) -public abstract class PrChange extends Change { +public abstract class PrNotify extends Notify { protected final String title; protected final String url; - protected PrChange(ChangeType type, Set telegramIds, String title, String url) { + protected PrNotify(NotifyType type, Set telegramIds, String title, String url) { super(type, telegramIds); this.title = title; this.url = url; diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/pullrequest/ReviewersPrChange.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/ReviewersPrNotify.java similarity index 91% rename from bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/pullrequest/ReviewersPrChange.java rename to bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/ReviewersPrNotify.java index f224494..929645d 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/pullrequest/ReviewersPrChange.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/ReviewersPrNotify.java @@ -1,9 +1,9 @@ -package org.sadtech.bot.vcs.core.domain.change.pullrequest; +package org.sadtech.bot.vcs.core.domain.notify.pullrequest; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; -import org.sadtech.bot.vcs.core.domain.change.ChangeType; +import org.sadtech.bot.vcs.core.domain.notify.NotifyType; import org.sadtech.bot.vcs.core.domain.util.ReviewerChange; import org.sadtech.bot.vcs.core.utils.Smile; @@ -18,17 +18,17 @@ import static org.sadtech.bot.vcs.core.domain.util.ReviewerChange.Type.OLD; @Getter @EqualsAndHashCode(callSuper = true) -public class ReviewersPrChange extends PrChange { +public class ReviewersPrNotify extends PrNotify { private final List reviewerChanges; @Builder - private ReviewersPrChange( + private ReviewersPrNotify( Set telegramIds, String title, String url, List reviewerChanges) { - super(ChangeType.REVIEWERS, telegramIds, title, url); + super(NotifyType.REVIEWERS, telegramIds, title, url); this.reviewerChanges = reviewerChanges; } diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/pullrequest/StatusPrChange.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/StatusPrNotify.java similarity index 79% rename from bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/pullrequest/StatusPrChange.java rename to bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/StatusPrNotify.java index 8e8a1db..bda9414 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/pullrequest/StatusPrChange.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/StatusPrNotify.java @@ -1,10 +1,10 @@ -package org.sadtech.bot.vcs.core.domain.change.pullrequest; +package org.sadtech.bot.vcs.core.domain.notify.pullrequest; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; import org.sadtech.bot.vcs.core.domain.PullRequestStatus; -import org.sadtech.bot.vcs.core.domain.change.ChangeType; +import org.sadtech.bot.vcs.core.domain.notify.NotifyType; import org.sadtech.bot.vcs.core.utils.Smile; import java.text.MessageFormat; @@ -12,19 +12,19 @@ import java.util.Set; @Getter @EqualsAndHashCode(callSuper = true) -public class StatusPrChange extends PrChange { +public class StatusPrNotify extends PrNotify { private final PullRequestStatus oldStatus; private final PullRequestStatus newStatus; @Builder - private StatusPrChange( + private StatusPrNotify( Set telegramIds, String name, String url, PullRequestStatus oldStatus, PullRequestStatus newStatus) { - super(ChangeType.STATUS_PR, telegramIds, name, url); + super(NotifyType.STATUS_PR, telegramIds, name, url); this.oldStatus = oldStatus; this.newStatus = newStatus; } diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/pullrequest/UpdatePrChange.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/UpdatePrNotify.java similarity index 75% rename from bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/pullrequest/UpdatePrChange.java rename to bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/UpdatePrNotify.java index 1666c44..faa4b42 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/pullrequest/UpdatePrChange.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/UpdatePrNotify.java @@ -1,9 +1,9 @@ -package org.sadtech.bot.vcs.core.domain.change.pullrequest; +package org.sadtech.bot.vcs.core.domain.notify.pullrequest; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; -import org.sadtech.bot.vcs.core.domain.change.ChangeType; +import org.sadtech.bot.vcs.core.domain.notify.NotifyType; import org.sadtech.bot.vcs.core.utils.Smile; import java.text.MessageFormat; @@ -11,16 +11,16 @@ import java.util.Set; @Getter @EqualsAndHashCode(callSuper = true) -public class UpdatePrChange extends PrChange { +public class UpdatePrNotify extends PrNotify { private final String author; @Builder - private UpdatePrChange( + private UpdatePrNotify( Set telegramIds, String name, String url, String author) { - super(ChangeType.UPDATE_PR, telegramIds, name, url); + super(NotifyType.UPDATE_PR, telegramIds, name, url); this.author = author; } diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/task/TaskCloseChange.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/task/TaskCloseNotify.java similarity index 72% rename from bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/task/TaskCloseChange.java rename to bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/task/TaskCloseNotify.java index 6f21cf4..84686ba 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/task/TaskCloseChange.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/task/TaskCloseNotify.java @@ -1,7 +1,7 @@ -package org.sadtech.bot.vcs.core.domain.change.task; +package org.sadtech.bot.vcs.core.domain.notify.task; import lombok.Builder; -import org.sadtech.bot.vcs.core.domain.change.ChangeType; +import org.sadtech.bot.vcs.core.domain.notify.NotifyType; import org.sadtech.bot.vcs.core.utils.Smile; import java.text.MessageFormat; @@ -12,16 +12,16 @@ import java.util.Set; * * @author upagge 10.09.2020 */ -public class TaskCloseChange extends TaskChange { +public class TaskCloseNotify extends TaskNotify { @Builder - protected TaskCloseChange( + protected TaskCloseNotify( Set telegramIds, String authorName, String url, String messageTask ) { - super(ChangeType.RESOLVED_TASK, telegramIds, authorName, url, messageTask); + super(NotifyType.RESOLVED_TASK, telegramIds, authorName, url, messageTask); } @Override diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/task/TaskNewChange.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/task/TaskNewNotify.java similarity index 73% rename from bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/task/TaskNewChange.java rename to bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/task/TaskNewNotify.java index 6dcb53d..f7b1eec 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/task/TaskNewChange.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/task/TaskNewNotify.java @@ -1,8 +1,8 @@ -package org.sadtech.bot.vcs.core.domain.change.task; +package org.sadtech.bot.vcs.core.domain.notify.task; import lombok.Builder; import lombok.Getter; -import org.sadtech.bot.vcs.core.domain.change.ChangeType; +import org.sadtech.bot.vcs.core.domain.notify.NotifyType; import org.sadtech.bot.vcs.core.utils.Smile; import java.text.MessageFormat; @@ -14,16 +14,16 @@ import java.util.Set; * @author upagge 10.09.2020 */ @Getter -public class TaskNewChange extends TaskChange { +public class TaskNewNotify extends TaskNotify { @Builder - protected TaskNewChange( + protected TaskNewNotify( Set telegramIds, String authorName, String url, String messageTask ) { - super(ChangeType.NEW_TASK, telegramIds, authorName, url, messageTask); + super(NotifyType.NEW_TASK, telegramIds, authorName, url, messageTask); } @Override diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/task/TaskChange.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/task/TaskNotify.java similarity index 65% rename from bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/task/TaskChange.java rename to bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/task/TaskNotify.java index 62b5c10..7564b7e 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/change/task/TaskChange.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/task/TaskNotify.java @@ -1,22 +1,22 @@ -package org.sadtech.bot.vcs.core.domain.change.task; +package org.sadtech.bot.vcs.core.domain.notify.task; import lombok.EqualsAndHashCode; import lombok.Getter; -import org.sadtech.bot.vcs.core.domain.change.Change; -import org.sadtech.bot.vcs.core.domain.change.ChangeType; +import org.sadtech.bot.vcs.core.domain.notify.Notify; +import org.sadtech.bot.vcs.core.domain.notify.NotifyType; import java.util.Set; @Getter @EqualsAndHashCode(callSuper = true) -public abstract class TaskChange extends Change { +public abstract class TaskNotify extends Notify { protected final String authorName; protected final String url; protected final String messageTask; - protected TaskChange( - ChangeType type, + protected TaskNotify( + NotifyType type, Set telegramIds, String authorName, String url, diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/util/ReviewerChange.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/util/ReviewerChange.java index 3fbba61..58ebe5c 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/util/ReviewerChange.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/util/ReviewerChange.java @@ -12,8 +12,8 @@ import org.sadtech.bot.vcs.core.domain.ReviewerStatus; @Getter public class ReviewerChange { - private String name; - private Type type; + private final String name; + private final Type type; private ReviewerStatus status; private ReviewerStatus oldStatus; diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/repository/ChangeRepository.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/repository/ChangeRepository.java deleted file mode 100644 index b921f80..0000000 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/repository/ChangeRepository.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.sadtech.bot.vcs.core.repository; - -import lombok.NonNull; -import org.sadtech.bot.vcs.core.domain.change.Change; - -import java.util.List; - -public interface ChangeRepository { - - T add(@NonNull T change); - - List getAll(); - - void deleteAll(@NonNull List changes); - -} diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/repository/NotifyRepository.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/repository/NotifyRepository.java new file mode 100644 index 0000000..90211ba --- /dev/null +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/repository/NotifyRepository.java @@ -0,0 +1,16 @@ +package org.sadtech.bot.vcs.core.repository; + +import lombok.NonNull; +import org.sadtech.bot.vcs.core.domain.notify.Notify; + +import java.util.List; + +public interface NotifyRepository { + + T add(@NonNull T notify); + + List getAll(); + + void deleteAll(@NonNull List notifies); + +} diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/repository/impl/ChangeRepositoryImpl.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/repository/impl/ChangeRepositoryImpl.java deleted file mode 100644 index b028896..0000000 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/repository/impl/ChangeRepositoryImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.sadtech.bot.vcs.core.repository.impl; - -import lombok.NonNull; -import org.sadtech.bot.vcs.core.domain.change.Change; -import org.sadtech.bot.vcs.core.repository.ChangeRepository; -import org.springframework.stereotype.Repository; - -import java.util.ArrayList; -import java.util.List; - -@Repository -public class ChangeRepositoryImpl implements ChangeRepository { - - private final List list = new ArrayList<>(); - private long count = 0; - - @Override - public T add(@NonNull T change) { - change.setId(count++); - list.add(change); - return change; - } - - @Override - public List getAll() { - return new ArrayList<>(list); - } - - @Override - public void deleteAll(@NonNull List changes) { - list.removeAll(changes); - } - - -} diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/repository/impl/NotifyRepositoryImpl.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/repository/impl/NotifyRepositoryImpl.java new file mode 100644 index 0000000..b4db0e0 --- /dev/null +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/repository/impl/NotifyRepositoryImpl.java @@ -0,0 +1,35 @@ +package org.sadtech.bot.vcs.core.repository.impl; + +import lombok.NonNull; +import org.sadtech.bot.vcs.core.domain.notify.Notify; +import org.sadtech.bot.vcs.core.repository.NotifyRepository; +import org.springframework.stereotype.Repository; + +import java.util.ArrayList; +import java.util.List; + +@Repository +public class NotifyRepositoryImpl implements NotifyRepository { + + private final List list = new ArrayList<>(); + private long count = 0; + + @Override + public T add(@NonNull T notify) { + notify.setId(count++); + list.add(notify); + return notify; + } + + @Override + public List getAll() { + return new ArrayList<>(list); + } + + @Override + public void deleteAll(@NonNull List notifies) { + list.removeAll(notifies); + } + + +} diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/SchedulerNotification.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/NotificationScheduler.java similarity index 98% rename from bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/SchedulerNotification.java rename to bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/NotificationScheduler.java index a699efe..b12bed1 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/SchedulerNotification.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/NotificationScheduler.java @@ -23,7 +23,7 @@ import java.util.stream.Collectors; @Service @RequiredArgsConstructor -public class SchedulerNotification { +public class NotificationScheduler { private static final Set tksLoginNotify = new HashSet<>(Arrays.asList( "mstruchkov", "dganin", "emukhin", "ktorgaeva", "imescheryakov", "kkeglev" diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/SchedulerChangeParsing.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/NotifyParsingScheduler.java similarity index 74% rename from bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/SchedulerChangeParsing.java rename to bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/NotifyParsingScheduler.java index 393e3b6..6199dd9 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/SchedulerChangeParsing.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/NotifyParsingScheduler.java @@ -2,8 +2,8 @@ package org.sadtech.bot.vcs.core.scheduler; import lombok.RequiredArgsConstructor; import org.sadtech.bot.vcs.core.domain.MessageSend; -import org.sadtech.bot.vcs.core.domain.change.Change; -import org.sadtech.bot.vcs.core.service.ChangeService; +import org.sadtech.bot.vcs.core.domain.notify.Notify; +import org.sadtech.bot.vcs.core.service.NotifyService; import org.sadtech.bot.vcs.core.service.MessageSendService; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; @@ -19,10 +19,10 @@ import java.util.stream.Collectors; */ @Service @RequiredArgsConstructor -public class SchedulerChangeParsing { +public class NotifyParsingScheduler { private final MessageSendService messageSendService; - private final ChangeService changeService; + private final NotifyService notifyService; /** * Проверяет наличие новых изменений. Если изменения найдены, то создает новое сообщение и отправляет @@ -30,12 +30,12 @@ public class SchedulerChangeParsing { */ @Scheduled(cron = "*/15 * * * * *") public void parsing() { - final List newChange = changeService.getNew().stream() - .filter(change -> change.getTelegramIds() != null && !change.getTelegramIds().isEmpty()) + final List newNotify = notifyService.getNew().stream() + .filter(notify -> notify.getTelegramIds() != null && !notify.getTelegramIds().isEmpty()) .collect(Collectors.toList()); - for (Change change : newChange) { - final String message = change.generateMessage(); - change.getTelegramIds().forEach( + for (Notify notify : newNotify) { + final String message = notify.generateMessage(); + notify.getTelegramIds().forEach( telegramId -> messageSendService.add( MessageSend.builder() .telegramId(telegramId) diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/SchedulerComments.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/SchedulerComments.java deleted file mode 100644 index 5998e94..0000000 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/SchedulerComments.java +++ /dev/null @@ -1,224 +0,0 @@ -package org.sadtech.bot.vcs.core.scheduler; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -/** - * Шедулер отвечает за работу с комментариями. Поиск новых комментариев, проверка старых. Так как таски в - * битбакете реализуются через комментарии, то этот шедулер так же работает с тасками. - * - * @author upagge - */ -@Slf4j -@Service -@RequiredArgsConstructor -public class SchedulerComments { - -// private static final Pattern PATTERN = Pattern.compile("@[\\w]+"); -// -// private final CommentService commentService; -// private final PullRequestsService pullRequestsService; -// private final PersonService personService; -// private final ChangeService changeService; -// private final ExecutorScanner executorScanner; -// private final TaskService taskService; -// private final ConversionService conversionService; -// -// private final BitbucketProperty bitbucketProperty; -// private final CommentSchedulerProperty commentSchedulerProperty; -// -// /** -// * Сканирует появление новых комментариев -// */ -// @Scheduled(cron = "0 */3 * * * *") -// public void newComments() { -// long commentId = commentService.getLastCommentId() + 1; -// int count = 0; -// do { -// final List dataScans = generatingLinksToPossibleComments(commentId); -// executorScanner.registration(dataScans); -// final List resultScans = executorScanner.getResult(); -// if (!resultScans.isEmpty()) { -// final List comments = getCommentsByResultScan(resultScans); -// final List newComments = commentService.createAll(comments); -// checkNewTask(newComments); -// notificationPersonal(newComments); -// count = 0; -// } -// } while (count++ < commentSchedulerProperty.getNoCommentCount()); -// } -// -// private List getCommentsByResultScan(List resultScans) { -// return resultScans.stream() -// .map(result -> conversionService.convert(result, Comment.class)) -// .collect(Collectors.toList()); -// } -// -// private List generatingLinksToPossibleComments(@NonNull Long commentId) { -// List commentUrls = new ArrayList<>(); -// for (int i = 0; i < 5; i++) { -// int page = 0; -// Page pullRequestPage = pullRequestsService.getAll( -// Pagination.of(page, commentSchedulerProperty.getCommentCount()) -// ); -// while (pullRequestPage.hasContent()) { -// long finalCommentId = commentId; -// commentUrls.addAll(pullRequestPage.getContent().stream() -// .map( -// pullRequest -> new DataScan( -// getCommentUrl(finalCommentId, pullRequest), -// pullRequest.getId() -// ) -// ) -// .collect(Collectors.toList())); -// pullRequestPage = pullRequestsService.getAll( -// Pagination.of(++page, commentSchedulerProperty.getCommentCount()) -// ); -// } -// commentId++; -// } -// return commentUrls; -// } -// -// -// private void checkNewTask(CommentJson commentJson, String urlPr, String authorLoginPr) { -// if (Severity.BLOCKER.equals(commentJson.getSeverity())) { -// final Task task = new Task(); -// task.setStatus(Converter.taskStatus(commentJson.getState())); -// task.setComment(commentService.getProxyById(commentJson.getId()).orElseThrow(() -> new NotFoundException("Неожиданная ошибка"))); -// -// taskService.create(task); -// -// if (TaskStatus.OPEN.equals(task.getStatus())) { -// changeService.add( -// TaskChange.builder() -// .type(ChangeType.NEW_TASK) -// .authorName(commentJson.getAuthor().getDisplayName()) -// .messageTask(commentJson.getText()) -// .telegramIds(personService.getAllTelegramIdByLogin(Collections.singleton(authorLoginPr))) -// .url(urlPr) -// .build() -// ); -// } -// } -// } -// -// -// /** -// * Проверяет состояние старых комментариев -// */ -// @Scheduled(cron = "0 */1 * * * *") -// public void oldComments() { -// @NonNull final List comments = commentService.getAllBetweenDate( -// LocalDateTime.now().minusDays(10), LocalDateTime.now() -// ); -// for (Comment comment : comments) { -// final Optional optCommentJson = Utils.urlToJson( -// comment.getUrl(), -// bitbucketProperty.getToken(), -// CommentJson.class -// ); -// if (optCommentJson.isPresent()) { -// final CommentJson commentJson = optCommentJson.get(); -// checkNewAnswers(comment, commentJson); -// checkOldTask(comment, commentJson); -// } -// } -// } -// -// private void checkOldTask(Comment comment, CommentJson commentJson) { -// final Task task = comment.getTask(); -// if (task == null) { -// checkNewTask(commentJson, comment.getPrUrl(), commentJson.getAuthor().getName()); -// } else { -// if (Severity.NORMAL.equals(commentJson.getSeverity())) { -// taskService.deleteById(comment.getId()); -// -// changeService.add( -// TaskChange.builder() -// .type(ChangeType.DELETED_TASK) -// .telegramIds(personService.getAllTelegramIdByLogin(Collections.singleton(commentJson.getAuthor().getName()))) -// .authorName(commentJson.getAuthor().getDisplayName()) -// .url(comment.getPrUrl()) -// .messageTask(commentJson.getText()) -// .build() -// ); -// } else { -// final TaskStatus taskStatus = task.getStatus(); -// final TaskStatus newTaskStatus = Converter.taskStatus(commentJson.getState()); -// task.setStatus(newTaskStatus); -// taskService.update(task); -// if (!taskStatus.equals(newTaskStatus)) { -// changeService.add( -// TaskChange.builder() -// .type(TaskStatus.RESOLVED.equals(newTaskStatus) ? ChangeType.RESOLVED_TASK : ChangeType.OPEN_TASK) -// .authorName(commentJson.getAuthor().getDisplayName()) -// .url(comment.getPrUrl()) -// .messageTask(commentJson.getText()) -// .telegramIds( -// TaskStatus.RESOLVED.equals(newTaskStatus) -// ? personService.getAllTelegramIdByLogin(Collections.singleton(commentJson.getAuthor().getName())) -// : personService.getAllTelegramIdByLogin(Collections.singleton(commentJson.getAuthor().getName())) -// ) -// .build() -// ); -// } -// } -// } -// } -// -// private void checkNewAnswers(Comment comment, CommentJson commentJson) { -// final Set oldAnswerIds = comment.getAnswers(); -// final List newAnswers = commentJson.getComments().stream() -// .filter(answerJson -> !oldAnswerIds.contains(answerJson.getId())) -// .collect(Collectors.toList()); -// if (!newAnswers.isEmpty()) { -// changeService.add( -// AnswerCommentChange.builder() -// .telegramIds( -// personService.getTelegramIdByLogin(commentJson.getAuthor().getName()) -// .map(Collections::singleton) -// .orElse(Collections.emptySet()) -// ) -// .url(comment.getPrUrl()) -// .youMessage(commentJson.getText()) -// .answers( -// newAnswers.stream() -// .map(json -> Answer.of(json.getAuthor().getName(), json.getText())) -// .collect(Collectors.toList()) -// ) -// .build() -// ); -// comment.getAnswers().addAll(newAnswers.stream().map(CommentJson::getId).collect(Collectors.toList())); -// commentService.save(comment); -// } -// } -// -// private String getCommentUrl(long commentId, PullRequest pullRequest) { -// return bitbucketProperty.getUrlPullRequestComment() -// .replace("{projectKey}", pullRequest.getProjectKey()) -// .replace("{repositorySlug}", pullRequest.getRepositorySlug()) -// .replace("{pullRequestId}", pullRequest.getBitbucketId().toString()) -// .replace("{commentId}", String.valueOf(commentId)); -// } -// -// private void notificationPersonal(@NonNull Comment comment) { -// Matcher matcher = PATTERN.matcher(comment.getMessage()); -// Set recipientsLogins = new HashSet<>(); -// while (matcher.find()) { -// final String login = matcher.group(0).replace("@", ""); -// recipientsLogins.add(login); -// } -// final Set recipientsIds = personService.getAllTelegramIdByLogin(recipientsLogins); -// changeService.add( -// CommentChange.builder() -// .authorName(comment.getAuthor().getLogin()) -// .url(comment.getPullRequest()) -// .telegramIds(recipientsIds) -// .message(comment.getMessage()) -// .build() -// ); -// } - -} diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/ChangeService.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/NotifyService.java similarity index 61% rename from bot-core/src/main/java/org/sadtech/bot/vcs/core/service/ChangeService.java rename to bot-core/src/main/java/org/sadtech/bot/vcs/core/service/NotifyService.java index c97a9a0..5403590 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/ChangeService.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/NotifyService.java @@ -1,6 +1,6 @@ package org.sadtech.bot.vcs.core.service; -import org.sadtech.bot.vcs.core.domain.change.Change; +import org.sadtech.bot.vcs.core.domain.notify.Notify; import java.util.List; @@ -8,15 +8,15 @@ import java.util.List; * Сервис по работе с изменениями в битбакете. * * @author upagge - * @see Change + * @see Notify */ -public interface ChangeService { +public interface NotifyService { - void save(T task); + void save(T notify); /** * Позволяет получить новые изменения. */ - List getNew(); + List getNew(); } diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/ChangeServiceImpl.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/ChangeServiceImpl.java deleted file mode 100644 index 1ca19c4..0000000 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/ChangeServiceImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.sadtech.bot.vcs.core.service.impl; - -import lombok.RequiredArgsConstructor; -import org.sadtech.bot.vcs.core.domain.change.Change; -import org.sadtech.bot.vcs.core.repository.ChangeRepository; -import org.sadtech.bot.vcs.core.service.ChangeService; -import org.springframework.stereotype.Service; - -import java.util.List; - -@Service -@RequiredArgsConstructor -public class ChangeServiceImpl implements ChangeService { - - private final ChangeRepository changeRepository; - - @Override - public void save(T change) { - changeRepository.add(change); - } - - @Override - public List getNew() { - final List changes = changeRepository.getAll(); - changeRepository.deleteAll(changes); - return changes; - } - -} diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/CommentServiceImpl.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/CommentServiceImpl.java index 7e09fe1..781c7ee 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/CommentServiceImpl.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/CommentServiceImpl.java @@ -3,13 +3,13 @@ package org.sadtech.bot.vcs.core.service.impl; import lombok.NonNull; import org.sadtech.basic.core.service.AbstractSimpleManagerService; import org.sadtech.bot.vcs.core.domain.Answer; -import org.sadtech.bot.vcs.core.domain.change.comment.AnswerCommentChange; -import org.sadtech.bot.vcs.core.domain.change.comment.CommentChange; +import org.sadtech.bot.vcs.core.domain.notify.comment.AnswerCommentNotify; +import org.sadtech.bot.vcs.core.domain.notify.comment.CommentNotify; import org.sadtech.bot.vcs.core.domain.entity.Comment; import org.sadtech.bot.vcs.core.domain.entity.Task; import org.sadtech.bot.vcs.core.exception.NotFoundException; import org.sadtech.bot.vcs.core.repository.CommentRepository; -import org.sadtech.bot.vcs.core.service.ChangeService; +import org.sadtech.bot.vcs.core.service.NotifyService; import org.sadtech.bot.vcs.core.service.CommentService; import org.sadtech.bot.vcs.core.service.PersonService; import org.sadtech.bot.vcs.core.service.TaskService; @@ -33,7 +33,7 @@ public class CommentServiceImpl extends AbstractSimpleManagerService recipientsIds = personService.getAllTelegramIdByLogin(recipientsLogins); - changeService.save( - CommentChange.builder() + notifyService.save( + CommentNotify.builder() .authorName(comment.getAuthor()) .url(comment.getUrl()) .telegramIds(recipientsIds) @@ -132,8 +132,8 @@ public class CommentServiceImpl extends AbstractSimpleManagerService void save(T notify) { + notifyRepository.add(notify); + } + + @Override + public List getNew() { + final List notifies = notifyRepository.getAll(); + notifyRepository.deleteAll(notifies); + return notifies; + } + +} diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/PullRequestsServiceImpl.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/PullRequestsServiceImpl.java index b86249d..7a91934 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/PullRequestsServiceImpl.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/PullRequestsServiceImpl.java @@ -11,11 +11,11 @@ import org.sadtech.basic.filter.criteria.CriteriaQuery; import org.sadtech.bot.vcs.core.domain.IdAndStatusPr; import org.sadtech.bot.vcs.core.domain.PullRequestStatus; import org.sadtech.bot.vcs.core.domain.ReviewerStatus; -import org.sadtech.bot.vcs.core.domain.change.pullrequest.ConflictPrChange; -import org.sadtech.bot.vcs.core.domain.change.pullrequest.NewPrChange; -import org.sadtech.bot.vcs.core.domain.change.pullrequest.ReviewersPrChange; -import org.sadtech.bot.vcs.core.domain.change.pullrequest.StatusPrChange; -import org.sadtech.bot.vcs.core.domain.change.pullrequest.UpdatePrChange; +import org.sadtech.bot.vcs.core.domain.notify.pullrequest.ConflictPrNotify; +import org.sadtech.bot.vcs.core.domain.notify.pullrequest.NewPrNotify; +import org.sadtech.bot.vcs.core.domain.notify.pullrequest.ReviewersPrNotify; +import org.sadtech.bot.vcs.core.domain.notify.pullrequest.StatusPrNotify; +import org.sadtech.bot.vcs.core.domain.notify.pullrequest.UpdatePrNotify; import org.sadtech.bot.vcs.core.domain.entity.PullRequest; import org.sadtech.bot.vcs.core.domain.entity.PullRequestMini; import org.sadtech.bot.vcs.core.domain.entity.PullRequest_; @@ -24,7 +24,7 @@ import org.sadtech.bot.vcs.core.domain.filter.PullRequestFilter; import org.sadtech.bot.vcs.core.domain.util.ReviewerChange; import org.sadtech.bot.vcs.core.exception.UpdateException; import org.sadtech.bot.vcs.core.repository.PullRequestsRepository; -import org.sadtech.bot.vcs.core.service.ChangeService; +import org.sadtech.bot.vcs.core.service.NotifyService; import org.sadtech.bot.vcs.core.service.PersonService; import org.sadtech.bot.vcs.core.service.PullRequestsService; import org.springframework.beans.factory.annotation.Qualifier; @@ -41,18 +41,18 @@ import java.util.stream.Collectors; @Service public class PullRequestsServiceImpl extends AbstractSimpleManagerService implements PullRequestsService { - private final ChangeService changeService; + private final NotifyService notifyService; private final PullRequestsRepository pullRequestsRepository; private final PersonService personService; private final FilterService filterService; protected PullRequestsServiceImpl( PullRequestsRepository pullRequestsRepository, - ChangeService changeService, + NotifyService notifyService, PersonService personService, @Qualifier("pullRequestFilterService") FilterService pullRequestsFilterService ) { super(pullRequestsRepository); - this.changeService = changeService; + this.notifyService = notifyService; this.pullRequestsRepository = pullRequestsRepository; this.personService = personService; this.filterService = pullRequestsFilterService; @@ -64,8 +64,8 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService oldIds.contains(reviewer.getPersonLogin())); if (!reviewerChanges.isEmpty()) { - changeService.save( - ReviewersPrChange.builder() + notifyService.save( + ReviewersPrNotify.builder() .title(newPullRequest.getTitle()) .url(newPullRequest.getUrl()) .telegramIds( diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/TaskServiceImpl.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/TaskServiceImpl.java index 5d335ff..3810ff2 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/TaskServiceImpl.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/TaskServiceImpl.java @@ -5,16 +5,16 @@ import org.sadtech.basic.core.service.AbstractSimpleManagerService; import org.sadtech.basic.core.util.Assert; import org.sadtech.bot.vcs.core.domain.Answer; import org.sadtech.bot.vcs.core.domain.TaskStatus; -import org.sadtech.bot.vcs.core.domain.change.comment.AnswerCommentChange; -import org.sadtech.bot.vcs.core.domain.change.comment.CommentChange; -import org.sadtech.bot.vcs.core.domain.change.task.TaskCloseChange; -import org.sadtech.bot.vcs.core.domain.change.task.TaskNewChange; +import org.sadtech.bot.vcs.core.domain.notify.comment.AnswerCommentNotify; +import org.sadtech.bot.vcs.core.domain.notify.comment.CommentNotify; +import org.sadtech.bot.vcs.core.domain.notify.task.TaskCloseNotify; +import org.sadtech.bot.vcs.core.domain.notify.task.TaskNewNotify; import org.sadtech.bot.vcs.core.domain.entity.Comment; import org.sadtech.bot.vcs.core.domain.entity.PullRequest; import org.sadtech.bot.vcs.core.domain.entity.Task; import org.sadtech.bot.vcs.core.exception.NotFoundException; import org.sadtech.bot.vcs.core.repository.TaskRepository; -import org.sadtech.bot.vcs.core.service.ChangeService; +import org.sadtech.bot.vcs.core.service.NotifyService; import org.sadtech.bot.vcs.core.service.CommentService; import org.sadtech.bot.vcs.core.service.PersonService; import org.sadtech.bot.vcs.core.service.PullRequestsService; @@ -39,7 +39,7 @@ public class TaskServiceImpl extends AbstractSimpleManagerService im private final TaskRepository taskRepository; private final PullRequestsService pullRequestsService; - private final ChangeService changeService; + private final NotifyService notifyService; private final PersonService personService; private final CommentService commentService; @@ -48,7 +48,7 @@ public class TaskServiceImpl extends AbstractSimpleManagerService im public TaskServiceImpl( TaskRepository taskRepository, PullRequestsService pullRequestsService, - ChangeService changeService, + NotifyService notifyService, PersonService personService, CommentService commentService, ConversionService conversionService @@ -56,7 +56,7 @@ public class TaskServiceImpl extends AbstractSimpleManagerService im super(taskRepository); this.taskRepository = taskRepository; this.pullRequestsService = pullRequestsService; - this.changeService = changeService; + this.notifyService = notifyService; this.personService = personService; this.commentService = commentService; this.conversionService = conversionService; @@ -93,8 +93,8 @@ public class TaskServiceImpl extends AbstractSimpleManagerService im if (!oldStatus.equals(newStatus)) { switch (newStatus) { case OPEN: - changeService.save( - TaskNewChange.builder() + notifyService.save( + TaskNewNotify.builder() .messageTask(task.getDescription()) .authorName(oldTask.getAuthor()) .url(oldTask.getUrl()) @@ -105,8 +105,8 @@ public class TaskServiceImpl extends AbstractSimpleManagerService im ); break; case RESOLVED: - changeService.save( - TaskCloseChange.builder() + notifyService.save( + TaskCloseNotify.builder() .messageTask(oldTask.getDescription()) .authorName(oldTask.getAuthor()) .url(oldTask.getUrl()) @@ -133,8 +133,8 @@ public class TaskServiceImpl extends AbstractSimpleManagerService im .collect(Collectors.toList()); oldTask.getAnswers().clear(); oldTask.setAnswers(existsNewAnswersIds); - changeService.save( - AnswerCommentChange.builder() + notifyService.save( + AnswerCommentNotify.builder() .telegramIds( personService.getAllTelegramIdByLogin(Collections.singleton(oldTask.getAuthor())) ) @@ -178,8 +178,8 @@ public class TaskServiceImpl extends AbstractSimpleManagerService im final PullRequest pullRequest = pullRequestsService.getById(task.getPullRequestId()) .orElseThrow(() -> new NotFoundException("ПР не найден")); - changeService.save( - TaskNewChange.builder() + notifyService.save( + TaskNewNotify.builder() .authorName(task.getAuthor()) .messageTask(task.getDescription()) .url(task.getUrl()) @@ -200,8 +200,8 @@ public class TaskServiceImpl extends AbstractSimpleManagerService im recipientsLogins.add(login); } final Set recipientsIds = personService.getAllTelegramIdByLogin(recipientsLogins); - changeService.save( - CommentChange.builder() + notifyService.save( + CommentNotify.builder() .authorName(task.getAuthor()) .url(task.getUrl()) .telegramIds(recipientsIds)