diff --git a/bot-app/pom.xml b/bot-app/pom.xml index bb7694d..0bf51f3 100644 --- a/bot-app/pom.xml +++ b/bot-app/pom.xml @@ -95,6 +95,7 @@ org.springframework.boot spring-boot-starter + diff --git a/bot-app/src/main/java/org/sadtech/bot/gitlab/app/config/AppConfig.java b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/config/AppConfig.java index a615ff0..8304ca2 100644 --- a/bot-app/src/main/java/org/sadtech/bot/gitlab/app/config/AppConfig.java +++ b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/config/AppConfig.java @@ -2,10 +2,14 @@ package org.sadtech.bot.gitlab.app.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.convert.ConversionService; +import org.springframework.core.convert.converter.Converter; +import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.scheduling.TaskScheduler; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; +import java.util.Arrays; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -33,4 +37,11 @@ public class AppConfig { return Executors.newFixedThreadPool(3); } + @Bean + public ConversionService conversionService(Converter... converters) { + final DefaultConversionService defaultConversionService = new DefaultConversionService(); + Arrays.stream(converters).forEach(defaultConversionService::addConverter); + return defaultConversionService; + } + } diff --git a/bot-app/src/main/java/org/sadtech/bot/gitlab/app/scheduler/CommentAndTaskScheduler.java b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/scheduler/CommentAndTaskScheduler.java index df0f804..5628070 100644 --- a/bot-app/src/main/java/org/sadtech/bot/gitlab/app/scheduler/CommentAndTaskScheduler.java +++ b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/scheduler/CommentAndTaskScheduler.java @@ -1,29 +1,27 @@ package org.sadtech.bot.gitlab.app.scheduler; import lombok.RequiredArgsConstructor; -import org.sadtech.bot.gitlab.app.service.CommentAndTaskParser; -import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @Component @RequiredArgsConstructor public class CommentAndTaskScheduler { - - private final CommentAndTaskParser commentAndTaskParser; - - @Scheduled(cron = "0 */1 * * * *") - public void scanNewCommentAndTask() { - commentAndTaskParser.scanNewCommentAndTask(); - } - - @Scheduled(cron = "0 */1 * * * *") - public void scanOldComment() { - commentAndTaskParser.scanOldComment(); - } - - @Scheduled(cron = "0 */1 * * * *") - public void scanOldTask() { - commentAndTaskParser.scanOldTask(); - } +// +// private final CommentAndTaskParser commentAndTaskParser; +// +// @Scheduled(cron = "0 */1 * * * *") +// public void scanNewCommentAndTask() { +// commentAndTaskParser.scanNewCommentAndTask(); +// } +// +// @Scheduled(cron = "0 */1 * * * *") +// public void scanOldComment() { +// commentAndTaskParser.scanOldComment(); +// } +// +// @Scheduled(cron = "0 */1 * * * *") +// public void scanOldTask() { +// commentAndTaskParser.scanOldTask(); +// } } diff --git a/bot-app/src/main/java/org/sadtech/bot/gitlab/app/scheduler/PullRequestParserScheduler.java b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/scheduler/PullRequestParserScheduler.java index ea1e5fe..eb7b752 100644 --- a/bot-app/src/main/java/org/sadtech/bot/gitlab/app/scheduler/PullRequestParserScheduler.java +++ b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/scheduler/PullRequestParserScheduler.java @@ -2,8 +2,6 @@ package org.sadtech.bot.gitlab.app.scheduler; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.sadtech.bot.vsc.context.service.PullRequestParser; -import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; /** @@ -16,16 +14,16 @@ import org.springframework.stereotype.Service; @RequiredArgsConstructor public class PullRequestParserScheduler { - private final PullRequestParser pullRequestParser; - - @Scheduled(cron = "0 */1 * * * *") - public void parsingOldPullRequest() { - pullRequestParser.parsingOldPullRequest(); - } - - @Scheduled(cron = "0 */1 * * * *") - public void parsingNewPullRequest() { - pullRequestParser.parsingNewPullRequest(); - } +// private final PullRequestParser pullRequestParser; +// +// @Scheduled(cron = "0 */1 * * * *") +// public void parsingOldPullRequest() { +// pullRequestParser.parsingOldPullRequest(); +// } +// +// @Scheduled(cron = "0 */1 * * * *") +// public void parsingNewPullRequest() { +// pullRequestParser.parsingNewPullRequest(); +// } } diff --git a/bot-app/src/main/java/org/sadtech/bot/gitlab/app/scheduler/SchedulerService.java b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/scheduler/SchedulerService.java new file mode 100644 index 0000000..3fcf16a --- /dev/null +++ b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/scheduler/SchedulerService.java @@ -0,0 +1,26 @@ +package org.sadtech.bot.gitlab.app.scheduler; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.sadtech.bot.gitlab.app.service.parser.ProjectParser; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; + +/** + * // TODO: 14.01.2021 Добавить описание. + * + * @author upagge 14.01.2021 + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class SchedulerService { + + private final ProjectParser projectParser; + + @Scheduled(cron = "0 */1 * * * *") + public void newProjectParse() { + projectParser.parseNewProject(); + } + +} diff --git a/bot-app/src/main/java/org/sadtech/bot/gitlab/app/service/convert/ProjectJsonConverter.java b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/service/convert/ProjectJsonConverter.java new file mode 100644 index 0000000..52a4ba0 --- /dev/null +++ b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/service/convert/ProjectJsonConverter.java @@ -0,0 +1,27 @@ +package org.sadtech.bot.gitlab.app.service.convert; + +import org.sadtech.bot.gitlab.context.domain.entity.Project; +import org.sadtech.bot.gitlab.sdk.domain.ProjectJson; +import org.springframework.core.convert.converter.Converter; +import org.springframework.stereotype.Component; + +/** + * // TODO: 14.01.2021 Добавить описание. + * + * @author upagge 14.01.2021 + */ +@Component +public class ProjectJsonConverter implements Converter { + + @Override + public Project convert(ProjectJson source) { + final Project project = new Project(); + project.setId(source.getId()); + project.setCreatedDate(source.getCreatedDate()); + project.setCreatorId(source.getCreatorId()); + project.setDescription(source.getDescription()); + project.setName(source.getName()); + return project; + } + +} diff --git a/bot-app/src/main/java/org/sadtech/bot/gitlab/app/service/executor/Seeker.java b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/service/executor/Seeker.java index 074827f..ef3a297 100644 --- a/bot-app/src/main/java/org/sadtech/bot/gitlab/app/service/executor/Seeker.java +++ b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/service/executor/Seeker.java @@ -14,14 +14,15 @@ public class Seeker implements Callable> { @Override public Optional call() { - return Utils.urlToJson(dataScan.getUrlComment(), token, CommentJson.class) - .map( - commentJson -> { - commentJson.setCustomPullRequestId(dataScan.getPullRequestId()); - commentJson.setCustomCommentApiUrl(dataScan.getUrlComment()); - return commentJson; - } - ); +// return Utils.urlToJson(dataScan.getUrlComment(), token, CommentJson.class) +// .map( +// commentJson -> { +// commentJson.setCustomPullRequestId(dataScan.getPullRequestId()); +// commentJson.setCustomCommentApiUrl(dataScan.getUrlComment()); +// return commentJson; +// } +// ); + return Optional.empty(); } } diff --git a/bot-app/src/main/java/org/sadtech/bot/gitlab/app/service/CommentAndTaskParser.java b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/service/parser/CommentAndTaskParser.java similarity index 79% rename from bot-app/src/main/java/org/sadtech/bot/gitlab/app/service/CommentAndTaskParser.java rename to bot-app/src/main/java/org/sadtech/bot/gitlab/app/service/parser/CommentAndTaskParser.java index d6a9bc4..42a3ee3 100644 --- a/bot-app/src/main/java/org/sadtech/bot/gitlab/app/service/CommentAndTaskParser.java +++ b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/service/parser/CommentAndTaskParser.java @@ -1,7 +1,8 @@ -package org.sadtech.bot.gitlab.app.service; +package org.sadtech.bot.gitlab.app.service.parser; import lombok.NonNull; import org.sadtech.bot.gitlab.app.config.property.CommentSchedulerProperty; +import org.sadtech.bot.gitlab.app.service.ExecutorScanner; import org.sadtech.bot.gitlab.app.service.executor.DataScan; import org.sadtech.bot.gitlab.context.domain.entity.Comment; import org.sadtech.bot.gitlab.context.domain.entity.PullRequest; @@ -18,20 +19,17 @@ import org.sadtech.bot.gitlab.sdk.domain.Severity; import org.sadtech.haiti.context.page.Sheet; import org.sadtech.haiti.core.page.PaginationImpl; import org.springframework.core.convert.ConversionService; -import org.springframework.stereotype.Component; import java.text.MessageFormat; -import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; -import java.util.Optional; import java.util.stream.Collectors; /** *

Поиск новых комментариев и задач.

*

К несчастью, у битбакета не очень удобный API, и у них таска это то же самое что и комментарий, только с флагом

*/ -@Component +//@Component public class CommentAndTaskParser { private final CommentService commentService; @@ -164,51 +162,51 @@ public class CommentAndTaskParser { } public void scanOldComment() { - final List comments = commentService.getAllBetweenDate( - LocalDateTime.now().minusDays(20), LocalDateTime.now() - ); - for (Comment oldComment : comments) { - final Optional optCommentJson = Utils.urlToJson( - oldComment.getUrlApi(), - gitlabProperty.getToken(), - CommentJson.class - ); - if (optCommentJson.isPresent()) { - final CommentJson json = optCommentJson.get(); - if (Severity.BLOCKER.equals(json.getSeverity())) { - taskService.convert(oldComment); - } else { - final Comment newComment = conversionService.convert(json, Comment.class); - commentService.update(newComment); - } - } else { - commentService.deleteById(oldComment.getId()); - } - } +// final List comments = commentService.getAllBetweenDate( +// LocalDateTime.now().minusDays(20), LocalDateTime.now() +// ); +// for (Comment oldComment : comments) { +// final Optional optCommentJson = Utils.urlToJson( +// oldComment.getUrlApi(), +// gitlabProperty.getToken(), +// CommentJson.class +// ); +// if (optCommentJson.isPresent()) { +// final CommentJson json = optCommentJson.get(); +// if (Severity.BLOCKER.equals(json.getSeverity())) { +// taskService.convert(oldComment); +// } else { +// final Comment newComment = conversionService.convert(json, Comment.class); +// commentService.update(newComment); +// } +// } else { +// commentService.deleteById(oldComment.getId()); +// } +// } } public void scanOldTask() { - final List tasks = taskService.getAllBetweenDate( - LocalDateTime.now().minusDays(20), LocalDateTime.now() - ); - for (Task oldTask : tasks) { - final Optional optCommentJson = Utils.urlToJson( - oldTask.getUrlApi(), - gitlabProperty.getToken(), - CommentJson.class - ); - if (optCommentJson.isPresent()) { - final CommentJson json = optCommentJson.get(); - if (Severity.NORMAL.equals(json.getSeverity())) { - commentService.convert(oldTask); - } else { - final Task newTask = conversionService.convert(json, Task.class); - taskService.update(newTask); - } - } else { - taskService.deleteById(oldTask.getId()); - } - } +// final List tasks = taskService.getAllBetweenDate( +// LocalDateTime.now().minusDays(20), LocalDateTime.now() +// ); +// for (Task oldTask : tasks) { +// final Optional optCommentJson = Utils.urlToJson( +// oldTask.getUrlApi(), +// gitlabProperty.getToken(), +// CommentJson.class +// ); +// if (optCommentJson.isPresent()) { +// final CommentJson json = optCommentJson.get(); +// if (Severity.NORMAL.equals(json.getSeverity())) { +// commentService.convert(oldTask); +// } else { +// final Task newTask = conversionService.convert(json, Task.class); +// taskService.update(newTask); +// } +// } else { +// taskService.deleteById(oldTask.getId()); +// } +// } } } diff --git a/bot-app/src/main/java/org/sadtech/bot/gitlab/app/service/parser/ProjectParser.java b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/service/parser/ProjectParser.java new file mode 100644 index 0000000..a050fdd --- /dev/null +++ b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/service/parser/ProjectParser.java @@ -0,0 +1,66 @@ +package org.sadtech.bot.gitlab.app.service.parser; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.sadtech.bot.gitlab.app.config.property.CommentSchedulerProperty; +import org.sadtech.bot.gitlab.context.domain.entity.Project; +import org.sadtech.bot.gitlab.context.service.ProjectService; +import org.sadtech.bot.gitlab.core.config.properties.GitlabProperty; +import org.sadtech.bot.gitlab.core.config.properties.InitProperty; +import org.sadtech.bot.gitlab.sdk.domain.ProjectJson; +import org.sadtech.haiti.context.domain.ExistsContainer; +import org.sadtech.haiti.utils.network.HttpHeader; +import org.sadtech.haiti.utils.network.HttpParse; +import org.springframework.core.convert.ConversionService; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import static org.sadtech.haiti.utils.network.HttpParse.ACCEPT; +import static org.sadtech.haiti.utils.network.HttpParse.AUTHORIZATION; +import static org.sadtech.haiti.utils.network.HttpParse.BEARER; + +/** + * // TODO: 14.01.2021 Добавить описание. + * + * @author upagge 14.01.2021 + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class ProjectParser { + + private final ProjectService projectService; + + private final ConversionService conversionService; + + private final GitlabProperty gitlabProperty; + private final CommentSchedulerProperty commentSchedulerProperty; + private final InitProperty initProperty; + + @Scheduled(cron = "0 */1 * * * *") + public void parseNewProject() { + final List projectJsons = HttpParse.request(gitlabProperty.getUrlProject()) + .header(ACCEPT) + .header(HttpHeader.of(AUTHORIZATION, BEARER + gitlabProperty.getToken())) + .executeList(ProjectJson.class); + + final Set jsonIds = projectJsons.stream() + .map(ProjectJson::getId) + .collect(Collectors.toSet()); + + final ExistsContainer existsContainer = projectService.existsById(jsonIds); + final List newProjects = projectJsons.stream() + .filter(json -> existsContainer.getIdNoFound().contains(json.getId())) + .map(json -> conversionService.convert(json, Project.class)) + .collect(Collectors.toList()); + + if (!newProjects.isEmpty()) { + projectService.createAll(newProjects); + } + } + +} diff --git a/bot-app/src/main/java/org/sadtech/bot/gitlab/app/service/parser/PullRequestBitbucketParser.java b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/service/parser/PullRequestBitbucketParser.java index 6627a79..09add97 100644 --- a/bot-app/src/main/java/org/sadtech/bot/gitlab/app/service/parser/PullRequestBitbucketParser.java +++ b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/service/parser/PullRequestBitbucketParser.java @@ -2,17 +2,14 @@ package org.sadtech.bot.gitlab.app.service.parser; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.sadtech.bot.gitlab.context.domain.entity.PullRequest; import org.sadtech.bot.gitlab.context.service.PullRequestsService; import org.sadtech.bot.gitlab.core.config.properties.GitlabProperty; -import org.sadtech.bot.gitlab.core.utils.Pair; -import org.sadtech.bot.gitlab.sdk.domain.PullRequestJson; +import org.sadtech.bot.gitlab.sdk.domain.MergeRequestJson; import org.sadtech.bot.vsc.context.domain.PullRequestStatus; import org.sadtech.bot.vsc.context.service.PullRequestParser; import org.sadtech.haiti.utils.network.HttpHeader; import org.sadtech.haiti.utils.network.HttpParse; import org.springframework.core.convert.ConversionService; -import org.springframework.stereotype.Service; import java.util.List; import java.util.Set; @@ -24,7 +21,7 @@ import static org.sadtech.haiti.utils.network.HttpParse.AUTHORIZATION; import static org.sadtech.haiti.utils.network.HttpParse.BEARER; @Slf4j -@Service +//@Service @RequiredArgsConstructor public class PullRequestBitbucketParser implements PullRequestParser { @@ -41,23 +38,22 @@ public class PullRequestBitbucketParser implements PullRequestParser { @Override public void parsingNewPullRequest() { - - final List pullRequestJsons = HttpParse.request(gitlabProperty.getUrlPullRequestOpen()) + final List mergeRequestJsons = HttpParse.request(gitlabProperty.getUrlPullRequestOpen()) .header(HttpHeader.of(AUTHORIZATION, BEARER + gitlabProperty.getToken())) .header(ACCEPT) - .executeList(PullRequestJson.class); + .executeList(MergeRequestJson.class); - while (pullRequestJsons != null && !pullRequestJsons.isEmpty()) { - final List newPullRequest = pullRequestJsons.stream() - .collect(Collectors.toMap(pullRequestJson -> new Pair<>(pullRequestJson.getId(), pullRequestJson.getFromRef().getRepository().getId()), pullRequestJson -> pullRequestJson)) - .values() - .stream() +// while (mergeRequestJsons != null && !mergeRequestJsons.isEmpty()) { +// final List newPullRequest = mergeRequestJsons.stream() +// .collect(Collectors.toMap(mergeRequestJson -> new Pair<>(mergeRequestJson.getId(), mergeRequestJson.getFromRef().getRepository().getId()), mergeRequestJson -> mergeRequestJson)) +// .values() +// .stream() // .filter(pullRequestJson -> !pullRequestsService.exists(bitbucketIdAndPullRequestId(pullRequestJson))) - .map(pullRequestJson -> conversionService.convert(pullRequestJson, PullRequest.class)) - .collect(Collectors.toList()); - - pullRequestsService.createAll(newPullRequest); - } +// .map(pullRequestJson -> conversionService.convert(pullRequestJson, PullRequest.class)) +// .collect(Collectors.toList()); +// +// pullRequestsService.createAll(newPullRequest); +// } } // private Set getExistsPullRequestIds(String bitbucketUrl) { diff --git a/bot-app/src/main/resources/application.yaml b/bot-app/src/main/resources/application.yaml index edb30e6..b8cd64d 100644 --- a/bot-app/src/main/resources/application.yaml +++ b/bot-app/src/main/resources/application.yaml @@ -32,11 +32,11 @@ gitlab-bot: token: ${GITLAB_PERSONAL_TOKEN} username: ${GITLAB_USERNAME} full-name: ${GITLAB_FULLNAME} - url-pull-request-open: ${GITLAB_URL}/rest/api/1.0/dashboard/pull-requests?limit=150&state=OPEN - url-pull-request-close: ${GITLAB_URL}/rest/api/1.0/dashboard/pull-requests?limit=150&closedSince=86400 - url-pull-request-comment: ${GITLAB_URL}/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId} - url-pull-request: ${GITLAB_URL}/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/overview - url-users: ${GITLAB_URL}/rest/api/1.0/admin/users + url-project: ${GITLAB_URL}/api/v4/projects + url-pull-request-open: ${GITLAB_URL}/api/v4/projects/18/merge_requests?state=opened + url-pull-request-close: ${GITLAB_URL} + url-pull-request-comment: ${GITLAB_URL} + url-pull-request: ${GITLAB_URL} teamcity: token: ${TEAMCITY_ADMIN_TOKEN} project-url: ${TEAMCITY_URL}/app/rest/projects diff --git a/bot-app/src/main/resources/liquibase/change-log.xml b/bot-app/src/main/resources/liquibase/change-log.xml index f06f7b5..cec031a 100644 --- a/bot-app/src/main/resources/liquibase/change-log.xml +++ b/bot-app/src/main/resources/liquibase/change-log.xml @@ -3,7 +3,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd"> - - + \ No newline at end of file diff --git a/bot-app/src/main/resources/liquibase/v.1.0.0/2020-09-06-create-table.xml b/bot-app/src/main/resources/liquibase/v.1.0.0/2020-09-06-create-table.xml deleted file mode 100644 index 02d3a18..0000000 --- a/bot-app/src/main/resources/liquibase/v.1.0.0/2020-09-06-create-table.xml +++ /dev/null @@ -1,191 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/bot-app/src/main/resources/liquibase/v.1.0.0/2021-01-14-create-tables.xml b/bot-app/src/main/resources/liquibase/v.1.0.0/2021-01-14-create-tables.xml new file mode 100644 index 0000000..146c2c6 --- /dev/null +++ b/bot-app/src/main/resources/liquibase/v.1.0.0/2021-01-14-create-tables.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bot-app/src/main/resources/liquibase/v.3.0.0/cumulative.xml b/bot-app/src/main/resources/liquibase/v.1.0.0/cumulative.xml similarity index 80% rename from bot-app/src/main/resources/liquibase/v.3.0.0/cumulative.xml rename to bot-app/src/main/resources/liquibase/v.1.0.0/cumulative.xml index 7a29266..15252f0 100644 --- a/bot-app/src/main/resources/liquibase/v.3.0.0/cumulative.xml +++ b/bot-app/src/main/resources/liquibase/v.1.0.0/cumulative.xml @@ -1,8 +1,8 @@ - + \ No newline at end of file diff --git a/bot-app/src/main/resources/liquibase/v.2.0.0/2020-09-06-cumulative.xml b/bot-app/src/main/resources/liquibase/v.2.0.0/2020-09-06-cumulative.xml deleted file mode 100644 index 915fb6a..0000000 --- a/bot-app/src/main/resources/liquibase/v.2.0.0/2020-09-06-cumulative.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/bot-app/src/main/resources/liquibase/v.2.0.0/2020-09-15-fix-task-comments.xml b/bot-app/src/main/resources/liquibase/v.2.0.0/2020-09-15-fix-task-comments.xml deleted file mode 100644 index de774df..0000000 --- a/bot-app/src/main/resources/liquibase/v.2.0.0/2020-09-15-fix-task-comments.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/bot-app/src/main/resources/liquibase/v.2.0.0/2020-09-20-setting-notify.xml b/bot-app/src/main/resources/liquibase/v.2.0.0/2020-09-20-setting-notify.xml deleted file mode 100644 index c58f977..0000000 --- a/bot-app/src/main/resources/liquibase/v.2.0.0/2020-09-20-setting-notify.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/bot-app/src/main/resources/liquibase/v.2.0.0/2020-09-20-teamcity.xml b/bot-app/src/main/resources/liquibase/v.2.0.0/2020-09-20-teamcity.xml deleted file mode 100644 index 6e6c2fa..0000000 --- a/bot-app/src/main/resources/liquibase/v.2.0.0/2020-09-20-teamcity.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/bot-app/src/main/resources/liquibase/v.2.0.0/2020-10-01-rating.xml b/bot-app/src/main/resources/liquibase/v.2.0.0/2020-10-01-rating.xml deleted file mode 100644 index 195b4ed..0000000 --- a/bot-app/src/main/resources/liquibase/v.2.0.0/2020-10-01-rating.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/bot-app/src/main/resources/liquibase/v.2.0.0/2020-10-02-add-column-status-teamcity.xml b/bot-app/src/main/resources/liquibase/v.2.0.0/2020-10-02-add-column-status-teamcity.xml deleted file mode 100644 index 3268baf..0000000 --- a/bot-app/src/main/resources/liquibase/v.2.0.0/2020-10-02-add-column-status-teamcity.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/bot-app/src/main/resources/liquibase/v.2.0.0/2020-10-07-add-colum-reviewer-date.xml b/bot-app/src/main/resources/liquibase/v.2.0.0/2020-10-07-add-colum-reviewer-date.xml deleted file mode 100644 index b0952f7..0000000 --- a/bot-app/src/main/resources/liquibase/v.2.0.0/2020-10-07-add-colum-reviewer-date.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/bot-app/src/main/resources/liquibase/v.2.0.0/2020-10-11-new-colum-reviewer.xml b/bot-app/src/main/resources/liquibase/v.2.0.0/2020-10-11-new-colum-reviewer.xml deleted file mode 100644 index 4fdcbbe..0000000 --- a/bot-app/src/main/resources/liquibase/v.2.0.0/2020-10-11-new-colum-reviewer.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/bot-app/src/main/resources/liquibase/v.2.0.0/2020-10-11-teamcity-refactoring.xml b/bot-app/src/main/resources/liquibase/v.2.0.0/2020-10-11-teamcity-refactoring.xml deleted file mode 100644 index 85d9f05..0000000 --- a/bot-app/src/main/resources/liquibase/v.2.0.0/2020-10-11-teamcity-refactoring.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/bot-app/src/main/resources/liquibase/v.3.0.0/2020-10-31-add-new-columns-pr.xml b/bot-app/src/main/resources/liquibase/v.3.0.0/2020-10-31-add-new-columns-pr.xml deleted file mode 100644 index d879bfa..0000000 --- a/bot-app/src/main/resources/liquibase/v.3.0.0/2020-10-31-add-new-columns-pr.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Chat.java b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Chat.java index 6b4ac1d..64c7ed0 100644 --- a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Chat.java +++ b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Chat.java @@ -3,11 +3,10 @@ package org.sadtech.bot.gitlab.context.domain.entity; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; +import org.sadtech.haiti.context.domain.BasicEntity; import javax.persistence.Column; -import javax.persistence.Entity; import javax.persistence.Id; -import javax.persistence.Table; /** * // TODO: 11.10.2020 Добавить описание. @@ -16,17 +15,24 @@ import javax.persistence.Table; */ @Getter @Setter -@Entity -@Table(name = "chat") +//@Entity +//@Table(name = "chat") @EqualsAndHashCode(onlyExplicitlyIncluded = true) -public class Chat { - - @Id - @Column(name = "key") - @EqualsAndHashCode.Include - private String key; +public class Chat extends BasicEntity { @Column(name = "telegram_id") private Long telegramId; + @Override + @Id + @Column(name = "key") + @EqualsAndHashCode.Include + public String getId() { + return super.getId(); + } + + @Override + public void setId(String id) { + super.setId(id); + } } diff --git a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Comment.java b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Comment.java index ddb2629..31922eb 100644 --- a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Comment.java +++ b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Comment.java @@ -3,32 +3,23 @@ package org.sadtech.bot.gitlab.context.domain.entity; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; +import org.sadtech.haiti.context.domain.BasicEntity; import javax.persistence.CollectionTable; import javax.persistence.Column; import javax.persistence.ElementCollection; -import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.JoinColumn; -import javax.persistence.Table; import java.time.LocalDateTime; import java.util.Set; @Getter @Setter -@Entity -@Table(name = "comment") -@EqualsAndHashCode(onlyExplicitlyIncluded = true) -public class Comment { - - /** - * Идентификатор - */ - @Id - @Column(name = "id") - @EqualsAndHashCode.Include - private Long id; +//@Entity +//@Table(name = "comment") +@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) +public class Comment extends BasicEntity { @Column(name = "url_api") private String urlApi; @@ -62,4 +53,16 @@ public class Comment { @Column(name = "child_id") private Set answers; + @Override + @Id + @Column(name = "id") + @EqualsAndHashCode.Include + public Long getId() { + return super.getId(); + } + + @Override + public void setId(Long id) { + super.setId(id); + } } diff --git a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/NotifySetting.java b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/NotifySetting.java index d1b2c59..9b622f0 100644 --- a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/NotifySetting.java +++ b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/NotifySetting.java @@ -3,11 +3,10 @@ package org.sadtech.bot.gitlab.context.domain.entity; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; +import org.sadtech.haiti.context.domain.BasicEntity; import javax.persistence.Column; -import javax.persistence.Entity; import javax.persistence.Id; -import javax.persistence.Table; import java.time.LocalDateTime; /** @@ -17,18 +16,10 @@ import java.time.LocalDateTime; */ @Getter @Setter -@Entity -@Table(name = "setting_notify") +//@Entity +//@Table(name = "setting_notify") @EqualsAndHashCode(onlyExplicitlyIncluded = true) -public class NotifySetting { - - /** - * Логин пользователя, которому принадлежат настройки - */ - @Id - @Column(name = "login") - @EqualsAndHashCode.Include - private String login; +public class NotifySetting extends BasicEntity { /** * Дата, после которой пользователю будут поступать уведомления. @@ -36,4 +27,16 @@ public class NotifySetting { @Column(name = "start_receiving") private LocalDateTime startReceiving; + @Override + @Id + @Column(name = "login") + @EqualsAndHashCode.Include + public String getId() { + return super.getId(); + } + + @Override + public void setId(String id) { + super.setId(id); + } } diff --git a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Project.java b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Project.java new file mode 100644 index 0000000..483e2ab --- /dev/null +++ b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Project.java @@ -0,0 +1,49 @@ +package org.sadtech.bot.gitlab.context.domain.entity; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import org.sadtech.haiti.context.domain.BasicEntity; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import java.time.LocalDateTime; + +/** + * // TODO: 14.01.2021 Добавить описание. + * + * @author upagge 14.01.2021 + */ +@Getter +@Setter +@Entity +@Table(name = "project") +@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) +public class Project extends BasicEntity { + + @Column(name = "name") + private String name; + + @Column(name = "description") + private String description; + + @Column(name = "created_date") + private LocalDateTime createdDate; + + @Column(name = "creator_id") + private Integer creatorId; + + @Id + @Column(name = "id") + @Override + public Long getId() { + return super.getId(); + } + + @Override + public void setId(Long id) { + super.setId(id); + } +} diff --git a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/PullRequest.java b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/PullRequest.java index ff50102..ceb19cc 100644 --- a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/PullRequest.java +++ b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/PullRequest.java @@ -4,10 +4,10 @@ import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import org.sadtech.bot.vsc.context.domain.PullRequestStatus; +import org.sadtech.haiti.context.domain.BasicEntity; import javax.persistence.CascadeType; import javax.persistence.Column; -import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.persistence.FetchType; @@ -15,7 +15,6 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany; -import javax.persistence.Table; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -27,19 +26,10 @@ import java.util.List; */ @Getter @Setter -@Entity -@Table(name = "pull_request") -@EqualsAndHashCode(onlyExplicitlyIncluded = true) -public class PullRequest { - - /** - * Идентификатор - */ - @Id - @Column(name = "id") - @GeneratedValue(strategy = GenerationType.IDENTITY) - @EqualsAndHashCode.Include - private Long id; +//@Entity +//@Table(name = "pull_request") +@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) +public class PullRequest extends BasicEntity { /** * Идентификатор на стороне битбакета @@ -140,4 +130,17 @@ public class PullRequest { this.reviewers = reviewers; } + @Id + @Override + @Column(name = "id") + @EqualsAndHashCode.Include + @GeneratedValue(strategy = GenerationType.IDENTITY) + public Long getId() { + return super.getId(); + } + + @Override + public void setId(Long id) { + super.setId(id); + } } diff --git a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/PullRequestMini.java b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/PullRequestMini.java index fc2ac33..6ee54aa 100644 --- a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/PullRequestMini.java +++ b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/PullRequestMini.java @@ -5,11 +5,9 @@ import lombok.Getter; import lombok.Setter; import javax.persistence.Column; -import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; -import javax.persistence.Table; /** * // TODO: 12.09.2020 Добавить описание. @@ -18,8 +16,8 @@ import javax.persistence.Table; */ @Getter @Setter -@Entity -@Table(name = "pull_request") +//@Entity +//@Table(name = "pull_request") @EqualsAndHashCode(onlyExplicitlyIncluded = true) public class PullRequestMini { diff --git a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Reviewer.java b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Reviewer.java index aafdec0..65220c1 100644 --- a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Reviewer.java +++ b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Reviewer.java @@ -7,7 +7,6 @@ import org.sadtech.bot.vsc.context.domain.ReviewerStatus; import javax.persistence.CascadeType; import javax.persistence.Column; -import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.persistence.FetchType; @@ -16,7 +15,6 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; -import javax.persistence.Table; import java.time.LocalDateTime; /** @@ -24,10 +22,10 @@ import java.time.LocalDateTime; * * @author upagge [01.02.2020] */ -@Entity +//@Entity @Getter @Setter -@Table(name = "reviewer") +//@Table(name = "reviewer") @EqualsAndHashCode(onlyExplicitlyIncluded = true) public class Reviewer { diff --git a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Task.java b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Task.java index 3b858a8..f08c1ad 100644 --- a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Task.java +++ b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Task.java @@ -4,35 +4,26 @@ import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import org.sadtech.bot.gitlab.context.domain.TaskStatus; +import org.sadtech.haiti.context.domain.BasicEntity; import javax.persistence.CollectionTable; import javax.persistence.Column; import javax.persistence.ElementCollection; -import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.JoinColumn; -import javax.persistence.Table; import java.time.LocalDateTime; import java.util.HashSet; import java.util.Set; -@Entity +//@Entity @Getter @Setter -@Table(name = "task") -@EqualsAndHashCode(onlyExplicitlyIncluded = true) -public class Task { - - /** - * Идентификатор - */ - @Id - @Column(name = "id") - @EqualsAndHashCode.Include - private Long id; +//@Table(name = "task") +@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) +public class Task extends BasicEntity { /** * Описание задачи @@ -73,4 +64,16 @@ public class Task { @Column(name = "comment_id") private Set answers = new HashSet<>(); + @Override + @Id + @Column(name = "id") + @EqualsAndHashCode.Include + public Long getId() { + return super.getId(); + } + + @Override + public void setId(Long id) { + super.setId(id); + } } diff --git a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/repository/ProjectRepository.java b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/repository/ProjectRepository.java new file mode 100644 index 0000000..74f456d --- /dev/null +++ b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/repository/ProjectRepository.java @@ -0,0 +1,13 @@ +package org.sadtech.bot.gitlab.context.repository; + +import org.sadtech.bot.gitlab.context.domain.entity.Project; +import org.sadtech.haiti.context.repository.SimpleManagerRepository; + +/** + * // TODO: 14.01.2021 Добавить описание. + * + * @author upagge 14.01.2021 + */ +public interface ProjectRepository extends SimpleManagerRepository { + +} diff --git a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/service/ProjectService.java b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/service/ProjectService.java new file mode 100644 index 0000000..ccfeae7 --- /dev/null +++ b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/service/ProjectService.java @@ -0,0 +1,14 @@ +package org.sadtech.bot.gitlab.context.service; + +import org.sadtech.bot.gitlab.context.domain.entity.Project; +import org.sadtech.haiti.context.service.SimpleManagerService; + +/** + * // TODO: 14.01.2021 Добавить описание. + * + * @author upagge 14.01.2021 + */ +public interface ProjectService extends SimpleManagerService { + + +} diff --git a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/config/properties/GitlabProperty.java b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/config/properties/GitlabProperty.java index 3fa4ab5..2bd4870 100644 --- a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/config/properties/GitlabProperty.java +++ b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/config/properties/GitlabProperty.java @@ -42,4 +42,6 @@ public class GitlabProperty { */ private String urlPullRequest; + private String urlProject; + } diff --git a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/scheduler/NotificationScheduler.java b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/scheduler/NotificationScheduler.java index 6160c31..a5c77c6 100644 --- a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/scheduler/NotificationScheduler.java +++ b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/scheduler/NotificationScheduler.java @@ -1,98 +1,70 @@ package org.sadtech.bot.gitlab.core.scheduler; import lombok.RequiredArgsConstructor; -import org.sadtech.bot.gitlab.context.domain.EntityType; -import org.sadtech.bot.gitlab.context.domain.entity.PullRequest; -import org.sadtech.bot.gitlab.context.domain.notify.GoodMorningNotify; -import org.sadtech.bot.gitlab.context.domain.notify.SimpleTextNotify; -import org.sadtech.bot.gitlab.context.service.NotifyService; -import org.sadtech.bot.gitlab.context.service.PullRequestsService; -import org.sadtech.bot.gitlab.context.utils.Smile; -import org.sadtech.bot.gitlab.core.config.properties.AppProperty; -import org.sadtech.bot.vsc.context.domain.PullRequestStatus; -import org.sadtech.bot.vsc.context.domain.ReviewerStatus; -import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - @Service @RequiredArgsConstructor public class NotificationScheduler { - - private static final Set tksLoginNotify = new HashSet<>(Arrays.asList( - "mstruchkov", "emukhin", "imescheryakov", "kkeglev" - )); - - private final PullRequestsService pullRequestsService; - - private final NotifyService notifyService; - - private final AppProperty appProperty; - - // Утреннее сообщение - @Scheduled(cron = "0 15 8 * * MON-FRI") - public void goodMorning() { - List allRegister = personService.getAllRegister(); - for (Person user : allRegister) { - List pullRequestsReviews = pullRequestsService.getAllByReviewerAndStatuses( - user.getLogin(), - ReviewerStatus.NEEDS_WORK, - Collections.singleton(PullRequestStatus.OPEN) - ); - List pullRequestsNeedWork = pullRequestsService.getAllByAuthorAndReviewerStatus(user.getLogin(), ReviewerStatus.UNAPPROVED); - notifyService.send( - GoodMorningNotify.builder() - .personName(user.getFullName()) - .pullRequestsNeedWork(pullRequestsNeedWork) - .pullRequestsReviews(pullRequestsReviews) - .recipients(Collections.singleton(user.getLogin())) - .version(appProperty.getVersion()) - .build() - ); - } - } - - @Scheduled(cron = "0 44 10 * * MON-FRI") - public void tks() { - List usersTks = personService.getAllRegister().stream() - .filter(user -> tksLoginNotify.contains(user.getLogin())) - .collect(Collectors.toList()); - notifyService.send( - SimpleTextNotify - .builder() - .recipients( - usersTks.stream() - .map(Person::getLogin) - .collect(Collectors.toSet()) - ) - .message("☎️ Внимание созвон" + Smile.HR + "https://meet.google.com/avj-cdyy-enu") - .build() - ); - - } - - @Scheduled(cron = "0 0 18 * * FRI") - public void goodWeekEnd() { - List allRegister = personService.getAllRegister(); - notifyService.send( - SimpleTextNotify.builder() - .entityType(EntityType.PERSON) - .message("Ну вот и все! Веселых выходных " + Smile.MIG + Smile.BR + - "До понедельника" + Smile.BUY + Smile.TWO_BR) - .recipients( - allRegister.stream() - .map(Person::getLogin) - .collect(Collectors.toSet()) - ) - .build() - ); - } +// +// private final PullRequestsService pullRequestsService; +// private final NotifyService notifyService; +// private final AppProperty appProperty; +// +// // Утреннее сообщение +// @Scheduled(cron = "0 15 8 * * MON-FRI") +// public void goodMorning() { +// List allRegister = personService.getAllRegister(); +// for (Person user : allRegister) { +// List pullRequestsReviews = pullRequestsService.getAllByReviewerAndStatuses( +// user.getLogin(), +// ReviewerStatus.NEEDS_WORK, +// Collections.singleton(PullRequestStatus.OPEN) +// ); +// List pullRequestsNeedWork = pullRequestsService.getAllByAuthorAndReviewerStatus(user.getLogin(), ReviewerStatus.UNAPPROVED); +// notifyService.send( +// GoodMorningNotify.builder() +// .personName(user.getFullName()) +// .pullRequestsNeedWork(pullRequestsNeedWork) +// .pullRequestsReviews(pullRequestsReviews) +// .recipients(Collections.singleton(user.getLogin())) +// .version(appProperty.getVersion()) +// .build() +// ); +// } +// } +// +// @Scheduled(cron = "0 44 10 * * MON-FRI") +// public void tks() { +// notifyService.send( +// SimpleTextNotify +// .builder() +// .recipients( +// usersTks.stream() +// .map(Person::getLogin) +// .collect(Collectors.toSet()) +// ) +// .message("☎️ Внимание созвон" + Smile.HR + "https://meet.google.com/avj-cdyy-enu") +// .build() +// ); +// } +// +// @Scheduled(cron = "0 0 18 * * FRI") +// public void goodWeekEnd() { +// List allRegister = personService.getAllRegister(); +// notifyService.send( +// SimpleTextNotify.builder() +// .entityType(EntityType.PERSON) +// .message("Ну вот и все! Веселых выходных " + Smile.MIG + Smile.BR + +// "До понедельника" + Smile.BUY + Smile.TWO_BR) +// .recipients( +// allRegister.stream() +// .map(Person::getLogin) +// .collect(Collectors.toSet()) +// ) +// .build() +// ); +// } } diff --git a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/ChatServiceImpl.java b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/ChatServiceImpl.java index c21584a..ea66584 100644 --- a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/ChatServiceImpl.java +++ b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/ChatServiceImpl.java @@ -4,7 +4,6 @@ import lombok.NonNull; import lombok.RequiredArgsConstructor; import org.sadtech.bot.gitlab.context.repository.ChatRepository; import org.sadtech.bot.gitlab.context.service.ChatService; -import org.springframework.stereotype.Service; import java.util.Set; @@ -13,7 +12,7 @@ import java.util.Set; * * @author upagge 11.10.2020 */ -@Service +//@Service @RequiredArgsConstructor public class ChatServiceImpl implements ChatService { diff --git a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/CommentServiceImpl.java b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/CommentServiceImpl.java index 4fd92a0..d639dca 100644 --- a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/CommentServiceImpl.java +++ b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/CommentServiceImpl.java @@ -2,7 +2,6 @@ package org.sadtech.bot.gitlab.core.service.impl; import lombok.NonNull; import org.sadtech.bot.gitlab.context.domain.Answer; -import org.sadtech.bot.gitlab.context.domain.PointType; import org.sadtech.bot.gitlab.context.domain.entity.Comment; import org.sadtech.bot.gitlab.context.domain.entity.Task; import org.sadtech.bot.gitlab.context.domain.notify.comment.AnswerCommentNotify; @@ -12,13 +11,14 @@ import org.sadtech.bot.gitlab.context.repository.CommentRepository; import org.sadtech.bot.gitlab.context.service.CommentService; import org.sadtech.bot.gitlab.context.service.NotifyService; import org.sadtech.bot.gitlab.context.service.TaskService; +import org.sadtech.haiti.context.domain.ExistsContainer; import org.sadtech.haiti.core.service.AbstractSimpleManagerService; import org.sadtech.haiti.core.util.Assert; import org.springframework.context.annotation.Lazy; import org.springframework.core.convert.ConversionService; -import org.springframework.stereotype.Service; import java.time.LocalDateTime; +import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -27,7 +27,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; -@Service +//@Service public class CommentServiceImpl extends AbstractSimpleManagerService implements CommentService { private static final Pattern PATTERN = Pattern.compile("@[\\w]+"); @@ -35,7 +35,6 @@ public class CommentServiceImpl extends AbstractSimpleManagerService recipientsLogins = new HashSet<>(); @@ -118,9 +110,7 @@ public class CommentServiceImpl extends AbstractSimpleManagerService new NotFoundException("Комментарий не найден")); - ratingService.addRating(comment.getAuthor(), PointType.COMMENT_DELETE, PointType.COMMENT_DELETE.getPoints()); - super.deleteById(id); + public ExistsContainer existsById(@NonNull Collection collection) { + return null; } + } diff --git a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/NotifyServiceImpl.java b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/NotifyServiceImpl.java index 9059388..da65187 100644 --- a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/NotifyServiceImpl.java +++ b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/NotifyServiceImpl.java @@ -8,12 +8,11 @@ import org.sadtech.bot.gitlab.context.domain.notify.Notify; import org.sadtech.bot.gitlab.context.repository.NotifySettingRepository; import org.sadtech.bot.gitlab.context.service.MessageSendService; import org.sadtech.bot.gitlab.context.service.NotifyService; -import org.springframework.stereotype.Service; import java.util.Optional; import java.util.Set; -@Service +//@Service @RequiredArgsConstructor public class NotifyServiceImpl implements NotifyService { diff --git a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/ProjectServiceImpl.java b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/ProjectServiceImpl.java new file mode 100644 index 0000000..2cf829e --- /dev/null +++ b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/ProjectServiceImpl.java @@ -0,0 +1,36 @@ +package org.sadtech.bot.gitlab.core.service.impl; + +import lombok.NonNull; +import org.sadtech.bot.gitlab.context.domain.entity.Project; +import org.sadtech.bot.gitlab.context.repository.ProjectRepository; +import org.sadtech.bot.gitlab.context.service.ProjectService; +import org.sadtech.haiti.context.repository.SimpleManagerRepository; +import org.sadtech.haiti.core.service.AbstractSimpleManagerService; +import org.springframework.stereotype.Service; + +/** + * // TODO: 14.01.2021 Добавить описание. + * + * @author upagge 14.01.2021 + */ +@Service +public class ProjectServiceImpl extends AbstractSimpleManagerService implements ProjectService { + + private final ProjectRepository projectRepository; + + public ProjectServiceImpl(SimpleManagerRepository repository, ProjectRepository projectRepository) { + super(repository); + this.projectRepository = projectRepository; + } + + @Override + public Project create(@NonNull Project project) { + return projectRepository.save(project); + } + + @Override + public Project update(@NonNull Project project) { + return projectRepository.save(project); + } + +} diff --git a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/PullRequestsServiceImpl.java b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/PullRequestsServiceImpl.java index dd91e10..d8ca87e 100644 --- a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/PullRequestsServiceImpl.java +++ b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/PullRequestsServiceImpl.java @@ -2,7 +2,6 @@ package org.sadtech.bot.gitlab.core.service.impl; import lombok.NonNull; import org.sadtech.bot.gitlab.context.domain.IdAndStatusPr; -import org.sadtech.bot.gitlab.context.domain.PointType; import org.sadtech.bot.gitlab.context.domain.entity.PullRequest; import org.sadtech.bot.gitlab.context.domain.entity.PullRequestMini; import org.sadtech.bot.gitlab.context.domain.entity.Reviewer; @@ -21,6 +20,7 @@ import org.sadtech.bot.gitlab.context.service.NotifyService; import org.sadtech.bot.gitlab.context.service.PullRequestsService; import org.sadtech.bot.vsc.context.domain.PullRequestStatus; import org.sadtech.bot.vsc.context.domain.ReviewerStatus; +import org.sadtech.haiti.context.domain.ExistsContainer; import org.sadtech.haiti.context.page.Pagination; import org.sadtech.haiti.context.page.Sheet; import org.sadtech.haiti.core.service.AbstractSimpleManagerService; @@ -29,10 +29,10 @@ import org.sadtech.haiti.filter.FilterService; import org.sadtech.haiti.filter.criteria.CriteriaFilter; import org.sadtech.haiti.filter.criteria.CriteriaQuery; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; @@ -40,29 +40,23 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; -@Service +//@Service public class PullRequestsServiceImpl extends AbstractSimpleManagerService implements PullRequestsService { protected final NotifyService notifyService; protected final PullRequestsRepository pullRequestsRepository; - protected final RatingService ratingService; protected final FilterService filterService; - protected final RatingProperty ratingProperty; protected PullRequestsServiceImpl( PullRequestsRepository pullRequestsRepository, NotifyService notifyService, - RatingService ratingService, - @Qualifier("pullRequestFilterService") FilterService pullRequestsFilterService, - RatingProperty ratingProperty - ) { + @Qualifier("pullRequestFilterService") FilterService pullRequestsFilterService + ) { super(pullRequestsRepository); this.notifyService = notifyService; this.pullRequestsRepository = pullRequestsRepository; - this.ratingService = ratingService; this.filterService = pullRequestsFilterService; - this.ratingProperty = ratingProperty; } @Override @@ -75,8 +69,6 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService oldReviewers = oldPullRequest.getReviewers().stream() .collect(Collectors.toMap(Reviewer::getPersonLogin, reviewer -> reviewer)); @@ -354,4 +322,9 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService new UpdateException("ПР с таким id не существует")); } + @Override + public ExistsContainer existsById(@NonNull Collection collection) { + return null; + } + } diff --git a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/TaskServiceImpl.java b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/TaskServiceImpl.java index 713274d..ca7cca5 100644 --- a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/TaskServiceImpl.java +++ b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/TaskServiceImpl.java @@ -2,7 +2,6 @@ package org.sadtech.bot.gitlab.core.service.impl; import lombok.NonNull; import org.sadtech.bot.gitlab.context.domain.Answer; -import org.sadtech.bot.gitlab.context.domain.PointType; import org.sadtech.bot.gitlab.context.domain.TaskStatus; import org.sadtech.bot.gitlab.context.domain.entity.Comment; import org.sadtech.bot.gitlab.context.domain.entity.PullRequest; @@ -17,12 +16,13 @@ import org.sadtech.bot.gitlab.context.service.CommentService; import org.sadtech.bot.gitlab.context.service.NotifyService; import org.sadtech.bot.gitlab.context.service.PullRequestsService; import org.sadtech.bot.gitlab.context.service.TaskService; +import org.sadtech.haiti.context.domain.ExistsContainer; import org.sadtech.haiti.core.service.AbstractSimpleManagerService; import org.sadtech.haiti.core.util.Assert; import org.springframework.core.convert.ConversionService; -import org.springframework.stereotype.Service; import java.time.LocalDateTime; +import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -31,7 +31,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; -@Service +//@Service public class TaskServiceImpl extends AbstractSimpleManagerService implements TaskService { private static final Pattern PATTERN = Pattern.compile("@[\\w]+"); @@ -41,7 +41,6 @@ public class TaskServiceImpl extends AbstractSimpleManagerService im private final PullRequestsService pullRequestsService; private final NotifyService notifyService; private final CommentService commentService; - private final RatingService ratingService; private final ConversionService conversionService; @@ -50,7 +49,6 @@ public class TaskServiceImpl extends AbstractSimpleManagerService im PullRequestsService pullRequestsService, NotifyService notifyService, CommentService commentService, - RatingService ratingService, ConversionService conversionService ) { super(taskRepository); @@ -58,7 +56,6 @@ public class TaskServiceImpl extends AbstractSimpleManagerService im this.pullRequestsService = pullRequestsService; this.notifyService = notifyService; this.commentService = commentService; - this.ratingService = ratingService; this.conversionService = conversionService; } @@ -69,7 +66,6 @@ public class TaskServiceImpl extends AbstractSimpleManagerService im final Task newTask = taskRepository.save(task); notifyNewTask(task); notificationPersonal(task); - ratingCreateTask(task.getAuthor(), task.getResponsible()); return newTask; } @@ -204,19 +200,12 @@ public class TaskServiceImpl extends AbstractSimpleManagerService im @Override public void deleteById(@NonNull Long id) { - final Task task = taskRepository.findById(id).orElseThrow(() -> new NotFoundException("Задача не найдена")); - ratingDeleteTask(task.getAuthor(), task.getResponsible()); super.deleteById(id); } - private void ratingCreateTask(String authorLogin, String responsibleLogin) { - ratingService.addRating(authorLogin, PointType.TASK_CREATE, PointType.TASK_CREATE.getPoints()); - ratingService.addRating(responsibleLogin, PointType.TASK_RECIPIENT, PointType.TASK_RECIPIENT.getPoints()); - } - - private void ratingDeleteTask(String authorLogin, String responsibleLogin) { - ratingService.addRating(authorLogin, PointType.TASK_DELETE, PointType.TASK_DELETE.getPoints()); - ratingService.addRating(responsibleLogin, PointType.TASK_DELETE_RECIPIENT, PointType.TASK_DELETE_RECIPIENT.getPoints()); + @Override + public ExistsContainer existsById(@NonNull Collection collection) { + return null; } } diff --git a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/filter/PullRequestFilterService.java b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/filter/PullRequestFilterService.java index 1494f6a..00a3e34 100644 --- a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/filter/PullRequestFilterService.java +++ b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/filter/PullRequestFilterService.java @@ -9,9 +9,8 @@ import org.sadtech.haiti.filter.Filter; import org.sadtech.haiti.filter.FilterQuery; import org.sadtech.haiti.filter.criteria.CriteriaFilter; import org.sadtech.haiti.filter.criteria.CriteriaQuery; -import org.springframework.stereotype.Service; -@Service +//@Service public class PullRequestFilterService extends AbstractFilterService { public PullRequestFilterService(PullRequestsRepository filterOperation) { diff --git a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/ChatRepositoryImpl.java b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/ChatRepositoryImpl.java index f07645a..e729b07 100644 --- a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/ChatRepositoryImpl.java +++ b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/ChatRepositoryImpl.java @@ -5,7 +5,6 @@ import org.sadtech.bot.gitlab.context.domain.entity.Chat; import org.sadtech.bot.gitlab.context.repository.ChatRepository; import org.sadtech.bot.gitlab.data.jpa.ChatJpaRepository; import org.sadtech.haiti.database.repository.manager.AbstractSimpleManagerRepository; -import org.springframework.stereotype.Repository; import java.util.Set; @@ -14,7 +13,7 @@ import java.util.Set; * * @author upagge 11.10.2020 */ -@Repository +//@Repository public class ChatRepositoryImpl extends AbstractSimpleManagerRepository implements ChatRepository { private final ChatJpaRepository jpaRepository; diff --git a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/CommentRepositoryImpl.java b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/CommentRepositoryImpl.java index 8911e00..3ada4be 100644 --- a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/CommentRepositoryImpl.java +++ b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/CommentRepositoryImpl.java @@ -5,7 +5,6 @@ import org.sadtech.bot.gitlab.context.domain.entity.Comment; import org.sadtech.bot.gitlab.context.repository.CommentRepository; import org.sadtech.bot.gitlab.data.jpa.CommentRepositoryJpa; import org.sadtech.haiti.database.repository.manager.AbstractSimpleManagerRepository; -import org.springframework.stereotype.Repository; import java.time.LocalDateTime; import java.util.List; @@ -17,7 +16,7 @@ import java.util.Set; * * @author upagge 08.09.2020 */ -@Repository +//@Repository public class CommentRepositoryImpl extends AbstractSimpleManagerRepository implements CommentRepository { private final CommentRepositoryJpa repositoryJpa; diff --git a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/NotifySettingRepositoryImpl.java b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/NotifySettingRepositoryImpl.java index a9915b1..1b10627 100644 --- a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/NotifySettingRepositoryImpl.java +++ b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/NotifySettingRepositoryImpl.java @@ -5,7 +5,6 @@ import org.sadtech.bot.gitlab.context.domain.entity.NotifySetting; import org.sadtech.bot.gitlab.context.repository.NotifySettingRepository; import org.sadtech.bot.gitlab.data.jpa.NotifySettingJpaRepository; import org.sadtech.haiti.database.repository.manager.AbstractSimpleManagerRepository; -import org.springframework.stereotype.Repository; import java.time.LocalDateTime; import java.util.Set; @@ -15,7 +14,7 @@ import java.util.Set; * * @author upagge 20.09.2020 */ -@Repository +//@Repository public class NotifySettingRepositoryImpl extends AbstractSimpleManagerRepository implements NotifySettingRepository { private final NotifySettingJpaRepository jpaRepository; diff --git a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/ProjectRepositoryImpl.java b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/ProjectRepositoryImpl.java new file mode 100644 index 0000000..6481642 --- /dev/null +++ b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/ProjectRepositoryImpl.java @@ -0,0 +1,21 @@ +package org.sadtech.bot.gitlab.data.impl; + +import org.sadtech.bot.gitlab.context.domain.entity.Project; +import org.sadtech.bot.gitlab.context.repository.ProjectRepository; +import org.sadtech.haiti.database.repository.manager.AbstractSimpleManagerRepository; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * // TODO: 14.01.2021 Добавить описание. + * + * @author upagge 14.01.2021 + */ +@Repository +public class ProjectRepositoryImpl extends AbstractSimpleManagerRepository implements ProjectRepository { + + public ProjectRepositoryImpl(JpaRepository jpaRepository) { + super(jpaRepository); + } + +} diff --git a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/PullRequestsRepositoryImpl.java b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/PullRequestsRepositoryImpl.java index 052b60f..4db8550 100644 --- a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/PullRequestsRepositoryImpl.java +++ b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/PullRequestsRepositoryImpl.java @@ -10,13 +10,12 @@ import org.sadtech.bot.gitlab.data.jpa.PullRequestsRepositoryJpa; import org.sadtech.bot.vsc.context.domain.PullRequestStatus; import org.sadtech.bot.vsc.context.domain.ReviewerStatus; import org.sadtech.haiti.database.repository.manager.FilterManagerRepository; -import org.springframework.stereotype.Repository; import java.util.List; import java.util.Optional; import java.util.Set; -@Repository +//@Repository public class PullRequestsRepositoryImpl extends FilterManagerRepository implements PullRequestsRepository { private final PullRequestsRepositoryJpa repositoryJpa; diff --git a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/TaskRepositoryImpl.java b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/TaskRepositoryImpl.java index 1aab95a..0221ec2 100644 --- a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/TaskRepositoryImpl.java +++ b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/TaskRepositoryImpl.java @@ -6,13 +6,12 @@ import org.sadtech.bot.gitlab.context.domain.entity.Task; import org.sadtech.bot.gitlab.context.repository.TaskRepository; import org.sadtech.bot.gitlab.data.jpa.TaskRepositoryJpa; import org.sadtech.haiti.database.repository.manager.AbstractSimpleManagerRepository; -import org.springframework.stereotype.Repository; import java.time.LocalDateTime; import java.util.List; import java.util.Optional; -@Repository +//@Repository public class TaskRepositoryImpl extends AbstractSimpleManagerRepository implements TaskRepository { private final TaskRepositoryJpa taskRepositoryJpa; diff --git a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/ChatJpaRepository.java b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/ChatJpaRepository.java index 314fad8..8d05127 100644 --- a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/ChatJpaRepository.java +++ b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/ChatJpaRepository.java @@ -2,7 +2,7 @@ package org.sadtech.bot.gitlab.data.jpa; import org.sadtech.bot.gitlab.context.domain.entity.Chat; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.NoRepositoryBean; import org.springframework.data.repository.query.Param; import java.util.Set; @@ -12,9 +12,10 @@ import java.util.Set; * * @author upagge 11.10.2020 */ +@NoRepositoryBean public interface ChatJpaRepository extends JpaRepository { - @Query("SELECT c.telegramId FROM Chat c WHERE c.key IN :keys AND c.telegramId IS NOT NULL") +// @Query("SELECT c.telegramId FROM Chat c WHERE c.key IN :keys AND c.telegramId IS NOT NULL") Set findAllTelegramIdByKey(@Param("keys") Set keys); } diff --git a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/CommentRepositoryJpa.java b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/CommentRepositoryJpa.java index 48e6a2f..fc4e46a 100644 --- a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/CommentRepositoryJpa.java +++ b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/CommentRepositoryJpa.java @@ -3,20 +3,21 @@ package org.sadtech.bot.gitlab.data.jpa; import lombok.NonNull; import org.sadtech.bot.gitlab.context.domain.entity.Comment; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.NoRepositoryBean; import java.time.LocalDateTime; import java.util.List; import java.util.Optional; import java.util.Set; +@NoRepositoryBean public interface CommentRepositoryJpa extends JpaRepository { Optional findFirstByOrderByIdDesc(); List findByCreateDateBetween(@NonNull LocalDateTime dateFrom, @NonNull LocalDateTime dateTo); - @Query("SELECT c.id FROM Comment c WHERE c.id IN :ids") +// @Query("SELECT c.id FROM Comment c WHERE c.id IN :ids") Set existsAllById(@NonNull Set ids); } diff --git a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/NotifySettingJpaRepository.java b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/NotifySettingJpaRepository.java index eed2131..4e796b9 100644 --- a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/NotifySettingJpaRepository.java +++ b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/NotifySettingJpaRepository.java @@ -2,7 +2,7 @@ package org.sadtech.bot.gitlab.data.jpa; import org.sadtech.bot.gitlab.context.domain.entity.NotifySetting; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.NoRepositoryBean; import org.springframework.data.repository.query.Param; import java.time.LocalDateTime; @@ -13,11 +13,13 @@ import java.util.Set; * * @author upagge 20.09.2020 */ + +@NoRepositoryBean public interface NotifySettingJpaRepository extends JpaRepository { boolean findByLoginAndStartReceivingAfter(String login, LocalDateTime date); - @Query("SELECT n.login FROM NotifySetting n WHERE n.login IN :logins AND n.startReceiving < :date") +// @Query("SELECT n.login FROM NotifySetting n WHERE n.login IN :logins AND n.startReceiving < :date") Set findAllByLoginInAndStartReceivingAfter(@Param("logins") Set logins, @Param("date") LocalDateTime date); } diff --git a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/ProjectJpaRepository.java b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/ProjectJpaRepository.java new file mode 100644 index 0000000..30ca07b --- /dev/null +++ b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/ProjectJpaRepository.java @@ -0,0 +1,13 @@ +package org.sadtech.bot.gitlab.data.jpa; + +import org.sadtech.bot.gitlab.context.domain.entity.Project; +import org.springframework.data.jpa.repository.JpaRepository; + +/** + * // TODO: 14.01.2021 Добавить описание. + * + * @author upagge 14.01.2021 + */ +public interface ProjectJpaRepository extends JpaRepository { + +} diff --git a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/PullRequestMiniRepositoryJpa.java b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/PullRequestMiniRepositoryJpa.java index a379a47..f205272 100644 --- a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/PullRequestMiniRepositoryJpa.java +++ b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/PullRequestMiniRepositoryJpa.java @@ -2,12 +2,15 @@ package org.sadtech.bot.gitlab.data.jpa; import org.sadtech.bot.gitlab.context.domain.entity.PullRequestMini; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.repository.NoRepositoryBean; /** * // TODO: 12.09.2020 Добавить описание. * * @author upagge 12.09.2020 */ + +@NoRepositoryBean public interface PullRequestMiniRepositoryJpa extends JpaRepository { } diff --git a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/PullRequestsRepositoryJpa.java b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/PullRequestsRepositoryJpa.java index 05e31cf..1d1e437 100644 --- a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/PullRequestsRepositoryJpa.java +++ b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/PullRequestsRepositoryJpa.java @@ -4,8 +4,8 @@ import org.sadtech.bot.gitlab.context.domain.IdAndStatusPr; import org.sadtech.bot.gitlab.context.domain.entity.PullRequest; import org.sadtech.bot.vsc.context.domain.PullRequestStatus; import org.sadtech.bot.vsc.context.domain.ReviewerStatus; -import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation; +import org.springframework.data.repository.NoRepositoryBean; import org.springframework.data.repository.query.Param; import java.util.Collection; @@ -16,30 +16,32 @@ import java.util.Set; /** * @author upagge [31.01.2020] */ + +@NoRepositoryBean public interface PullRequestsRepositoryJpa extends JpaRepositoryImplementation { Set findAllByIdIn(Set ids); Boolean existsByBitbucketIdAndRepositoryId(Long bitbucketId, Long repositoryId); - @Query("SELECT p.id FROM PullRequest p WHERE p.bitbucketId=:bitbucketId AND p.repositoryId=:repositoryId") +// @Query("SELECT p.id FROM PullRequest p WHERE p.bitbucketId=:bitbucketId AND p.repositoryId=:repositoryId") Optional findIdByBitbucketIdAndRepositoryId(@Param("bitbucketId") Long bitbucketId, @Param("repositoryId") Long repositoryId); void deleteAllByIdIn(Collection id); - @Query("SELECT p FROM PullRequest p LEFT JOIN p.reviewers r WHERE r.personLogin=:reviewer AND r.status =:reviewerStatus AND p.status IN :pullRequestStatus") +// @Query("SELECT p FROM PullRequest p LEFT JOIN p.reviewers r WHERE r.personLogin=:reviewer AND r.status =:reviewerStatus AND p.status IN :pullRequestStatus") List findAllByReviewerAndStatuses(@Param("reviewer") String reviewer, @Param("reviewerStatus") ReviewerStatus reviewerStatus, @Param("pullRequestStatus") Set pullRequestStatus); - @Query("SELECT p FROM PullRequest p LEFT JOIN p.reviewers r WHERE p.authorLogin=:author AND r.status=:reviewerStatus") +// @Query("SELECT p FROM PullRequest p LEFT JOIN p.reviewers r WHERE p.authorLogin=:author AND r.status=:reviewerStatus") List findAllByAuthorAndReviewerStatus(@Param("author") String author, @Param("reviewerStatus") ReviewerStatus reviewerStatus); // @Query("SELECT new org.sadtech.bot.bitbucketbot.domain.IdAndStatusPr(p.id, p.status) FROM PullRequest p WHERE p.status IN :statuses") Set findAllIdByStatusIn(@Param("statuses") Set statuses); - @Query("SELECT p.id from PullRequest p") +// @Query("SELECT p.id from PullRequest p") Set findAllIds(); - @Query("SELECT p.authorLogin from PullRequest p WHERE p.id = :id") +// @Query("SELECT p.authorLogin from PullRequest p WHERE p.id = :id") Optional findAuthorById(@Param("id") Long id); } diff --git a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/TaskRepositoryJpa.java b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/TaskRepositoryJpa.java index 43d6a13..6fe2d17 100644 --- a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/TaskRepositoryJpa.java +++ b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/TaskRepositoryJpa.java @@ -4,11 +4,13 @@ import lombok.NonNull; import org.sadtech.bot.gitlab.context.domain.TaskStatus; import org.sadtech.bot.gitlab.context.domain.entity.Task; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.repository.NoRepositoryBean; import java.time.LocalDateTime; import java.util.List; import java.util.Optional; +@NoRepositoryBean public interface TaskRepositoryJpa extends JpaRepository { Optional findFirstByOrderByIdDesc(); diff --git a/gitlab-core/src/main/java/org/sadtech/bot/vcs/bitbucket/core/service/converter/CommentJsonToComment.java b/gitlab-core/src/main/java/org/sadtech/bot/gitalb/core/service/converter/CommentJsonToComment.java similarity index 95% rename from gitlab-core/src/main/java/org/sadtech/bot/vcs/bitbucket/core/service/converter/CommentJsonToComment.java rename to gitlab-core/src/main/java/org/sadtech/bot/gitalb/core/service/converter/CommentJsonToComment.java index 20d7802..3b51658 100644 --- a/gitlab-core/src/main/java/org/sadtech/bot/vcs/bitbucket/core/service/converter/CommentJsonToComment.java +++ b/gitlab-core/src/main/java/org/sadtech/bot/gitalb/core/service/converter/CommentJsonToComment.java @@ -1,4 +1,4 @@ -package org.sadtech.bot.vcs.bitbucket.core.service.converter; +package org.sadtech.bot.gitalb.core.service.converter; import org.sadtech.bot.gitlab.context.domain.entity.Comment; import org.sadtech.bot.gitlab.core.utils.StringUtils; diff --git a/gitlab-core/src/main/java/org/sadtech/bot/vcs/bitbucket/core/service/converter/CommentJsonToTaskConvert.java b/gitlab-core/src/main/java/org/sadtech/bot/gitalb/core/service/converter/CommentJsonToTaskConvert.java similarity index 96% rename from gitlab-core/src/main/java/org/sadtech/bot/vcs/bitbucket/core/service/converter/CommentJsonToTaskConvert.java rename to gitlab-core/src/main/java/org/sadtech/bot/gitalb/core/service/converter/CommentJsonToTaskConvert.java index 594af7e..fa97591 100644 --- a/gitlab-core/src/main/java/org/sadtech/bot/vcs/bitbucket/core/service/converter/CommentJsonToTaskConvert.java +++ b/gitlab-core/src/main/java/org/sadtech/bot/gitalb/core/service/converter/CommentJsonToTaskConvert.java @@ -1,4 +1,4 @@ -package org.sadtech.bot.vcs.bitbucket.core.service.converter; +package org.sadtech.bot.gitalb.core.service.converter; import org.sadtech.bot.gitlab.context.domain.TaskStatus; import org.sadtech.bot.gitlab.context.domain.entity.Task; diff --git a/gitlab-core/src/main/java/org/sadtech/bot/gitalb/core/service/converter/PullRequestJsonConverter.java b/gitlab-core/src/main/java/org/sadtech/bot/gitalb/core/service/converter/PullRequestJsonConverter.java new file mode 100644 index 0000000..f412034 --- /dev/null +++ b/gitlab-core/src/main/java/org/sadtech/bot/gitalb/core/service/converter/PullRequestJsonConverter.java @@ -0,0 +1,61 @@ +package org.sadtech.bot.gitalb.core.service.converter; + +import lombok.RequiredArgsConstructor; +import org.sadtech.bot.gitlab.context.domain.entity.PullRequest; +import org.sadtech.bot.gitlab.sdk.domain.MergeRequestJson; +import org.sadtech.bot.gitlab.sdk.domain.Outcome; +import org.sadtech.bot.gitlab.sdk.domain.Properties; +import org.sadtech.bot.gitlab.sdk.domain.PullRequestState; +import org.sadtech.bot.gitlab.sdk.domain.UserPullRequestStatus; +import org.sadtech.bot.vsc.context.domain.PullRequestStatus; +import org.sadtech.bot.vsc.context.domain.ReviewerStatus; +import org.sadtech.haiti.context.exception.ConvertException; +import org.springframework.core.convert.converter.Converter; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +public class PullRequestJsonConverter implements Converter { + + public static PullRequestStatus convertPullRequestStatus(PullRequestState state) { + switch (state) { + case OPENED: + return PullRequestStatus.OPEN; + case MERGED: + return PullRequestStatus.MERGED; + case DECLINED: + return PullRequestStatus.DECLINED; + default: + throw new ConvertException("Неподдерживаемый тип ПР"); + } + } + + private static ReviewerStatus convertStatusReviewer(UserPullRequestStatus status) { + switch (status) { + case APPROVED: + return ReviewerStatus.APPROVED; + case NEEDS_WORK: + return ReviewerStatus.UNAPPROVED; + case UNAPPROVED: + return ReviewerStatus.NEEDS_WORK; + default: + throw new ConvertException("Неподдерживаемый статус ревьювера"); + } + } + + @Override + public PullRequest convert(MergeRequestJson json) { + + final PullRequest pullRequest = new PullRequest(); + + return pullRequest; + } + + private boolean convertConflict(Properties properties) { + return properties != null + && properties.getMergeResult() != null + && properties.getMergeResult().getOutcome() != null + && Outcome.CONFLICTED.equals(properties.getMergeResult().getOutcome()); + } + +} diff --git a/gitlab-core/src/main/java/org/sadtech/bot/vcs/bitbucket/core/service/converter/PullRequestJsonConverter.java b/gitlab-core/src/main/java/org/sadtech/bot/vcs/bitbucket/core/service/converter/PullRequestJsonConverter.java deleted file mode 100644 index c09f5c4..0000000 --- a/gitlab-core/src/main/java/org/sadtech/bot/vcs/bitbucket/core/service/converter/PullRequestJsonConverter.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.sadtech.bot.vcs.bitbucket.core.service.converter; - -import lombok.RequiredArgsConstructor; -import org.sadtech.bot.gitlab.context.domain.entity.PullRequest; -import org.sadtech.bot.gitlab.context.domain.entity.Reviewer; -import org.sadtech.bot.gitlab.core.utils.StringUtils; -import org.sadtech.bot.gitlab.sdk.domain.AuthorJson; -import org.sadtech.bot.gitlab.sdk.domain.Outcome; -import org.sadtech.bot.gitlab.sdk.domain.Properties; -import org.sadtech.bot.gitlab.sdk.domain.PullRequestJson; -import org.sadtech.bot.gitlab.sdk.domain.PullRequestState; -import org.sadtech.bot.gitlab.sdk.domain.UserPullRequestStatus; -import org.sadtech.bot.vsc.context.domain.PullRequestStatus; -import org.sadtech.bot.vsc.context.domain.ReviewerStatus; -import org.sadtech.haiti.context.exception.ConvertException; -import org.springframework.core.convert.converter.Converter; -import org.springframework.stereotype.Component; - -import java.util.List; -import java.util.stream.Collectors; - -@Component -@RequiredArgsConstructor -public class PullRequestJsonConverter implements Converter { - - public static PullRequestStatus convertPullRequestStatus(PullRequestState state) { - switch (state) { - case OPENED: - return PullRequestStatus.OPEN; - case MERGED: - return PullRequestStatus.MERGED; - case DECLINED: - return PullRequestStatus.DECLINED; - default: - throw new ConvertException("Неподдерживаемый тип ПР"); - } - } - - private static ReviewerStatus convertStatusReviewer(UserPullRequestStatus status) { - switch (status) { - case APPROVED: - return ReviewerStatus.APPROVED; - case NEEDS_WORK: - return ReviewerStatus.UNAPPROVED; - case UNAPPROVED: - return ReviewerStatus.NEEDS_WORK; - default: - throw new ConvertException("Неподдерживаемый статус ревьювера"); - } - } - - @Override - public PullRequest convert(PullRequestJson json) { - - final PullRequest pullRequest = new PullRequest(); - pullRequest.setBitbucketId(json.getId()); - pullRequest.setCreateDate(json.getCreatedDate()); - pullRequest.setUpdateDate(json.getUpdatedDate()); - pullRequest.setConflict(convertConflict(json.getProperties())); - pullRequest.setDescription(StringUtils.cutOff(json.getDescription(), 180)); - pullRequest.setAuthorLogin(json.getAuthor().getUser().getName()); - pullRequest.setTitle(StringUtils.cutOff(json.getTitle(), 90)); - pullRequest.setUrl(json.getLinks().getSelf().get(0).getHref()); - pullRequest.setStatus(convertPullRequestStatus(json.getState())); - pullRequest.setProjectKey(json.getFromRef().getRepository().getProject().getKey()); - pullRequest.setRepositorySlug(json.getFromRef().getRepository().getSlug()); - pullRequest.setReviewers(convertReviewers(json.getReviewers())); - pullRequest.setBitbucketVersion(json.getVersion()); - pullRequest.setRepositoryId(json.getFromRef().getRepository().getId()); - pullRequest.setResolvedTaskCount(json.getProperties().getResolvedTaskCount()); - pullRequest.setCommentCount(json.getProperties().getCommentCount()); - pullRequest.setOpenTaskCount(json.getProperties().getOpenTaskCount()); - return pullRequest; - } - - private boolean convertConflict(Properties properties) { - return properties != null - && properties.getMergeResult() != null - && properties.getMergeResult().getOutcome() != null - && Outcome.CONFLICTED.equals(properties.getMergeResult().getOutcome()); - } - - private List convertReviewers(List jsonReviewers) { - return jsonReviewers.stream() - .map( - jsonReviewer -> { - final Reviewer reviewer = new Reviewer(); - reviewer.setPersonLogin(jsonReviewer.getUser().getName()); - reviewer.setStatus(convertStatusReviewer(jsonReviewer.getStatus())); - return reviewer; - } - ) - .collect(Collectors.toList()); - } - -} diff --git a/gitlab-core/src/main/java/org/sadtech/bot/vcs/bitbucket/core/service/converter/UserJsonConverter.java b/gitlab-core/src/main/java/org/sadtech/bot/vcs/bitbucket/core/service/converter/UserJsonConverter.java deleted file mode 100644 index 4c194b8..0000000 --- a/gitlab-core/src/main/java/org/sadtech/bot/vcs/bitbucket/core/service/converter/UserJsonConverter.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.sadtech.bot.vcs.bitbucket.core.service.converter; - -import org.sadtech.bot.gitlab.sdk.domain.UserJson; -import org.springframework.core.convert.converter.Converter; -import org.springframework.stereotype.Component; - -@Component -public class UserJsonConverter implements Converter { - - @Override - public Person convert(UserJson source) { - final Person person = new Person(); - person.setFullName(source.getDisplayName()); - person.setLogin(source.getName()); - return person; - } - -} diff --git a/gitlab-sdk/pom.xml b/gitlab-sdk/pom.xml index 9e10727..0b32a50 100644 --- a/gitlab-sdk/pom.xml +++ b/gitlab-sdk/pom.xml @@ -22,6 +22,12 @@ com.fasterxml.jackson.core jackson-databind + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + 2.12.1 + diff --git a/gitlab-sdk/src/main/java/org/sadtech/bot/gitlab/sdk/domain/GroupJson.java b/gitlab-sdk/src/main/java/org/sadtech/bot/gitlab/sdk/domain/GroupJson.java new file mode 100644 index 0000000..c1f5bdd --- /dev/null +++ b/gitlab-sdk/src/main/java/org/sadtech/bot/gitlab/sdk/domain/GroupJson.java @@ -0,0 +1,21 @@ +package org.sadtech.bot.gitlab.sdk.domain; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +/** + * // TODO: 14.01.2021 Добавить описание. + * + * @author upagge 14.01.2021 + */ +@Data +public class GroupJson { + + private Long id; + + @JsonProperty("web_url") + private String webUrl; + + private String name; + +} diff --git a/gitlab-sdk/src/main/java/org/sadtech/bot/gitlab/sdk/domain/PullRequestJson.java b/gitlab-sdk/src/main/java/org/sadtech/bot/gitlab/sdk/domain/MergeRequestJson.java similarity index 97% rename from gitlab-sdk/src/main/java/org/sadtech/bot/gitlab/sdk/domain/PullRequestJson.java rename to gitlab-sdk/src/main/java/org/sadtech/bot/gitlab/sdk/domain/MergeRequestJson.java index 1c2ccac..8f67e75 100644 --- a/gitlab-sdk/src/main/java/org/sadtech/bot/gitlab/sdk/domain/PullRequestJson.java +++ b/gitlab-sdk/src/main/java/org/sadtech/bot/gitlab/sdk/domain/MergeRequestJson.java @@ -13,7 +13,7 @@ import java.time.LocalDateTime; * @author upagge [30.01.2020] */ @Data -public class PullRequestJson { +public class MergeRequestJson { private Long id; diff --git a/gitlab-sdk/src/main/java/org/sadtech/bot/gitlab/sdk/domain/ProjectJson.java b/gitlab-sdk/src/main/java/org/sadtech/bot/gitlab/sdk/domain/ProjectJson.java index 40f4e0a..35c8ca7 100644 --- a/gitlab-sdk/src/main/java/org/sadtech/bot/gitlab/sdk/domain/ProjectJson.java +++ b/gitlab-sdk/src/main/java/org/sadtech/bot/gitlab/sdk/domain/ProjectJson.java @@ -1,10 +1,32 @@ package org.sadtech.bot.gitlab.sdk.domain; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; import lombok.Data; +import java.time.LocalDateTime; + +/** + * // TODO: 14.01.2021 Добавить описание. + * + * @author upagge 14.01.2021 + */ @Data public class ProjectJson { - private String key; + private Long id; + private String name; + private String description; + + @JsonSerialize(using = LocalDateTimeSerializer.class) + @JsonDeserialize(using = LocalDateTimeDeserializer.class) + @JsonProperty("created_at") + private LocalDateTime createdDate; + + @JsonProperty("creator_id") + private Integer creatorId; } diff --git a/gitlab-sdk/src/main/java/org/sadtech/bot/gitlab/sdk/domain/sheet/UserSheetJson.java b/gitlab-sdk/src/main/java/org/sadtech/bot/gitlab/sdk/domain/sheet/UserSheetJson.java deleted file mode 100644 index c24ab84..0000000 --- a/gitlab-sdk/src/main/java/org/sadtech/bot/gitlab/sdk/domain/sheet/UserSheetJson.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.sadtech.bot.gitlab.sdk.domain.sheet; - -import org.sadtech.bot.gitlab.sdk.domain.Sheet; -import org.sadtech.bot.gitlab.sdk.domain.UserJson; - -/** - * TODO: Добавить описание класса. - * - * @author upagge [02.02.2020] - */ -public class UserSheetJson extends Sheet { - -} diff --git a/pom.xml b/pom.xml index 3ab693d..9c7d461 100644 --- a/pom.xml +++ b/pom.xml @@ -89,8 +89,8 @@ 3.0.1-RELEASE 3.0.1-RELEASE - 0.0.1-RELEASE - 0.0.2-RELEASE + 0.0.2-SNAPSHOT + 0.0.3-SNAPSHOT 0.0.2-RELEASE 0.0.1-RELEASE 0.0.1-RELEASE diff --git a/teamcity/teamcity-core/pom.xml b/teamcity/teamcity-core/pom.xml index 9ae8472..e172c57 100644 --- a/teamcity/teamcity-core/pom.xml +++ b/teamcity/teamcity-core/pom.xml @@ -33,6 +33,11 @@ org.springframework.boot spring-boot-starter + + + org.sadtech.haiti + haiti-utils + diff --git a/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/domain/entity/BuildShort.java b/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/domain/entity/BuildShort.java index 29c9b85..6001ce9 100644 --- a/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/domain/entity/BuildShort.java +++ b/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/domain/entity/BuildShort.java @@ -5,6 +5,7 @@ import lombok.Getter; import lombok.Setter; import org.sadtech.bot.gitlab.teamcity.sdk.BuildState; import org.sadtech.bot.gitlab.teamcity.sdk.BuildStatus; +import org.sadtech.haiti.context.domain.BasicEntity; import javax.persistence.Column; import javax.persistence.Entity; @@ -23,12 +24,7 @@ import javax.persistence.Table; @Entity @Table(name = "teamcity_build") @EqualsAndHashCode(onlyExplicitlyIncluded = true) -public class BuildShort { - - @Id - @Column(name = "id") - @EqualsAndHashCode.Include - private Long id; +public class BuildShort extends BasicEntity { @Column(name = "project_id") private String projectId; @@ -56,4 +52,16 @@ public class BuildShort { @Column(name = "url") private String url; + @Override + @Id + @Column(name = "id") + @EqualsAndHashCode.Include + public Long getId() { + return super.getId(); + } + + @Override + public void setId(Long id) { + super.setId(id); + } } diff --git a/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/domain/entity/TeamcityProject.java b/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/domain/entity/TeamcityProject.java index aa514a4..4dcb2e4 100644 --- a/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/domain/entity/TeamcityProject.java +++ b/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/domain/entity/TeamcityProject.java @@ -3,6 +3,7 @@ package org.sadtech.bot.gitlab.teamcity.core.domain.entity; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; +import org.sadtech.haiti.context.domain.BasicEntity; import javax.persistence.Column; import javax.persistence.Entity; @@ -19,12 +20,7 @@ import javax.persistence.Table; @Entity @Table(name = "teamcity_project") @EqualsAndHashCode(onlyExplicitlyIncluded = true) -public class TeamcityProject { - - @Id - @Column(name = "id") - @EqualsAndHashCode.Include - private String id; +public class TeamcityProject extends BasicEntity { @Column(name = "name") private String name; @@ -35,4 +31,16 @@ public class TeamcityProject { @Column(name = "url") private String url; + @Override + @Id + @Column(name = "id") + @EqualsAndHashCode.Include + public String getId() { + return super.getId(); + } + + @Override + public void setId(String id) { + super.setId(id); + } } diff --git a/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/domain/entity/TeamcitySetting.java b/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/domain/entity/TeamcitySetting.java index cf00d38..8e95491 100644 --- a/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/domain/entity/TeamcitySetting.java +++ b/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/domain/entity/TeamcitySetting.java @@ -4,6 +4,7 @@ import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import org.sadtech.bot.gitlab.context.domain.EntityType; +import org.sadtech.haiti.context.domain.BasicEntity; import javax.persistence.Column; import javax.persistence.Entity; @@ -24,13 +25,7 @@ import javax.persistence.Table; @Entity @Table(name = "teamcity_setting") @EqualsAndHashCode(onlyExplicitlyIncluded = true) -public class TeamcitySetting { - - @Id - @Column(name = "id") - @EqualsAndHashCode.Include - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; +public class TeamcitySetting extends BasicEntity { @Column(name = "recipient_id") private String recipientId; @@ -51,4 +46,17 @@ public class TeamcitySetting { @Column(name = "failure") private boolean failure; + @Override + @Id + @Column(name = "id") + @EqualsAndHashCode.Include + @GeneratedValue(strategy = GenerationType.IDENTITY) + public Long getId() { + return super.getId(); + } + + @Override + public void setId(Long id) { + super.setId(id); + } } diff --git a/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/scheduler/TeamcityProjectScheduler.java b/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/scheduler/TeamcityProjectScheduler.java index 0465677..0122158 100644 --- a/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/scheduler/TeamcityProjectScheduler.java +++ b/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/scheduler/TeamcityProjectScheduler.java @@ -3,29 +3,27 @@ package org.sadtech.bot.gitlab.teamcity.core.scheduler; import lombok.RequiredArgsConstructor; import org.sadtech.bot.gitlab.teamcity.core.service.parser.BuildShortParser; import org.sadtech.bot.gitlab.teamcity.core.service.parser.TeamcityProjectParser; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; /** * // TODO: 21.09.2020 Добавить описание. * * @author upagge 21.09.2020 */ -@Component +//@Component @RequiredArgsConstructor public class TeamcityProjectScheduler { private final TeamcityProjectParser projectParser; private final BuildShortParser buildShortParser; - @Scheduled(cron = "0 */1 * * * *") - public void parseNewProject() { - projectParser.parseNewProject(); - } - - @Scheduled(cron = "0 */1 * * * *") - public void parseNewBuilds() { - buildShortParser.parseNewBuilds(); - } +// @Scheduled(cron = "0 */1 * * * *") +// public void parseNewProject() { +// projectParser.parseNewProject(); +// } +// +// @Scheduled(cron = "0 */1 * * * *") +// public void parseNewBuilds() { +// buildShortParser.parseNewBuilds(); +// } } diff --git a/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/service/impl/BuildShortServiceImpl.java b/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/service/impl/BuildShortServiceImpl.java index 6a8948b..1120ac7 100644 --- a/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/service/impl/BuildShortServiceImpl.java +++ b/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/service/impl/BuildShortServiceImpl.java @@ -9,9 +9,10 @@ import org.sadtech.bot.gitlab.teamcity.core.repository.BuildShortRepository; import org.sadtech.bot.gitlab.teamcity.core.service.BuildShortService; import org.sadtech.bot.gitlab.teamcity.core.service.TeamcitySettingService; import org.sadtech.bot.gitlab.teamcity.sdk.BuildStatus; +import org.sadtech.haiti.context.domain.ExistsContainer; import org.sadtech.haiti.core.service.AbstractSimpleManagerService; -import org.springframework.stereotype.Service; +import java.util.Collection; import java.util.Collections; import java.util.Set; @@ -20,7 +21,7 @@ import java.util.Set; * * @author upagge 21.09.2020 */ -@Service +//@Service public class BuildShortServiceImpl extends AbstractSimpleManagerService implements BuildShortService { private final TeamcitySettingService teamcitySettingService; @@ -76,4 +77,9 @@ public class BuildShortServiceImpl extends AbstractSimpleManagerService existsById(@NonNull Collection collection) { + return null; + } + } diff --git a/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/service/impl/TeamcityProjectServiceImpl.java b/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/service/impl/TeamcityProjectServiceImpl.java index 9eb35ee..759f41c 100644 --- a/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/service/impl/TeamcityProjectServiceImpl.java +++ b/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/service/impl/TeamcityProjectServiceImpl.java @@ -4,9 +4,10 @@ import lombok.NonNull; import org.sadtech.bot.gitlab.teamcity.core.domain.entity.TeamcityProject; import org.sadtech.bot.gitlab.teamcity.core.repository.TeamcityProjectRepository; import org.sadtech.bot.gitlab.teamcity.core.service.TeamcityProjectService; +import org.sadtech.haiti.context.domain.ExistsContainer; import org.sadtech.haiti.core.service.AbstractSimpleManagerService; -import org.springframework.stereotype.Service; +import java.util.Collection; import java.util.List; import java.util.Set; @@ -15,7 +16,7 @@ import java.util.Set; * * @author upagge 21.09.2020 */ -@Service +//@Service public class TeamcityProjectServiceImpl extends AbstractSimpleManagerService implements TeamcityProjectService { private final TeamcityProjectRepository teamcityProjectRepository; @@ -40,4 +41,9 @@ public class TeamcityProjectServiceImpl extends AbstractSimpleManagerService existsById(@NonNull Collection collection) { + return null; + } + } diff --git a/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/service/impl/TeamcitySettingServiceImpl.java b/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/service/impl/TeamcitySettingServiceImpl.java index d55d72b..1cd0c85 100644 --- a/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/service/impl/TeamcitySettingServiceImpl.java +++ b/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/service/impl/TeamcitySettingServiceImpl.java @@ -4,9 +4,10 @@ import lombok.NonNull; import org.sadtech.bot.gitlab.teamcity.core.domain.entity.TeamcitySetting; import org.sadtech.bot.gitlab.teamcity.core.repository.TeamcitySettingRepository; import org.sadtech.bot.gitlab.teamcity.core.service.TeamcitySettingService; +import org.sadtech.haiti.context.domain.ExistsContainer; import org.sadtech.haiti.core.service.AbstractSimpleManagerService; -import org.springframework.stereotype.Service; +import java.util.Collection; import java.util.List; /** @@ -14,7 +15,7 @@ import java.util.List; * * @author upagge 21.09.2020 */ -@Service +//@Service public class TeamcitySettingServiceImpl extends AbstractSimpleManagerService implements TeamcitySettingService { private final TeamcitySettingRepository teamcitySettingRepository; @@ -39,4 +40,9 @@ public class TeamcitySettingServiceImpl extends AbstractSimpleManagerService existsById(@NonNull Collection collection) { + return null; + } + } diff --git a/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/service/parser/BuildShortParser.java b/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/service/parser/BuildShortParser.java index f945cb4..9a176b4 100644 --- a/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/service/parser/BuildShortParser.java +++ b/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/service/parser/BuildShortParser.java @@ -13,19 +13,22 @@ import org.sadtech.bot.gitlab.teamcity.core.domain.entity.TeamcityProject; import org.sadtech.bot.gitlab.teamcity.core.service.BuildShortService; import org.sadtech.bot.gitlab.teamcity.core.service.TeamcityProjectService; import org.sadtech.bot.gitlab.teamcity.sdk.BuildShortJson; -import org.sadtech.bot.gitlab.teamcity.sdk.sheet.BuildShortJsonSheet; import org.sadtech.haiti.context.page.Sheet; import org.sadtech.haiti.core.page.PaginationImpl; +import org.sadtech.haiti.utils.network.HttpHeader; +import org.sadtech.haiti.utils.network.HttpParse; import org.springframework.core.convert.ConversionService; -import org.springframework.stereotype.Service; import java.text.MessageFormat; import java.util.List; -import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; -@Service +import static org.sadtech.haiti.utils.network.HttpParse.ACCEPT; +import static org.sadtech.haiti.utils.network.HttpParse.AUTHORIZATION; +import static org.sadtech.haiti.utils.network.HttpParse.BEARER; + +//@Service @RequiredArgsConstructor public class BuildShortParser { @@ -42,16 +45,11 @@ public class BuildShortParser { } private void parse(TeamcityProject project) { - final Optional buildShortJsonSheet = Utils.urlToJson( - MessageFormat.format( - teamcityProperty.getBuildUrl(), - project.getId() - ), - teamcityProperty.getToken(), - BuildShortJsonSheet.class - ); - if (buildShortJsonSheet.isPresent()) { - final List buildShortJsons = buildShortJsonSheet.get().getContent(); + final List buildShortJsons = HttpParse.request(MessageFormat.format(teamcityProperty.getBuildUrl(), project.getId())) + .header(ACCEPT) + .header(HttpHeader.of(AUTHORIZATION, BEARER + teamcityProperty.getToken())) + .executeList(BuildShortJson.class); + if (!buildShortJsons.isEmpty()) { final Set buildIds = buildShortJsons.stream() .map(BuildShortJson::getId) .collect(Collectors.toSet()); diff --git a/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/service/parser/TeamcityProjectParser.java b/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/service/parser/TeamcityProjectParser.java index 8399087..f852e69 100644 --- a/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/service/parser/TeamcityProjectParser.java +++ b/teamcity/teamcity-core/src/main/java/org/sadtech/bot/gitlab/teamcity/core/service/parser/TeamcityProjectParser.java @@ -5,21 +5,24 @@ import org.sadtech.bot.gitlab.teamcity.core.config.property.TeamcityProperty; import org.sadtech.bot.gitlab.teamcity.core.domain.entity.TeamcityProject; import org.sadtech.bot.gitlab.teamcity.core.service.TeamcityProjectService; import org.sadtech.bot.gitlab.teamcity.sdk.TeamcityProjectJson; -import org.sadtech.bot.gitlab.teamcity.sdk.sheet.TeamcityProjectJsonSheet; +import org.sadtech.haiti.utils.network.HttpHeader; +import org.sadtech.haiti.utils.network.HttpParse; import org.springframework.core.convert.ConversionService; -import org.springframework.stereotype.Component; import java.util.List; -import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; +import static org.sadtech.haiti.utils.network.HttpParse.ACCEPT; +import static org.sadtech.haiti.utils.network.HttpParse.AUTHORIZATION; +import static org.sadtech.haiti.utils.network.HttpParse.BEARER; + /** * // TODO: 21.09.2020 Добавить описание. * * @author upagge 21.09.2020 */ -@Component +//@Component @RequiredArgsConstructor public class TeamcityProjectParser { @@ -30,13 +33,13 @@ public class TeamcityProjectParser { private final ConversionService conversionService; public void parseNewProject() { - final Optional optTeamcityProjectJsonSheet = Utils.urlToJson( - teamcityProperty.getProjectUrl(), - teamcityProperty.getToken(), - TeamcityProjectJsonSheet.class - ); - if (optTeamcityProjectJsonSheet.isPresent()) { - final List teamcityProjectJsons = optTeamcityProjectJsonSheet.get().getContent(); + + final List teamcityProjectJsons = HttpParse.request(teamcityProperty.getProjectUrl()) + .header(ACCEPT) + .header(HttpHeader.of(AUTHORIZATION, BEARER + teamcityProperty.getToken())) + .executeList(TeamcityProjectJson.class); + + if (!teamcityProjectJsons.isEmpty()) { final Set projectIds = teamcityProjectJsons.stream() .map(TeamcityProjectJson::getId) .collect(Collectors.toSet()); diff --git a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/config/TelegramBotConfig.java b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/config/TelegramBotConfig.java index 26b39c2..8ea0722 100644 --- a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/config/TelegramBotConfig.java +++ b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/config/TelegramBotConfig.java @@ -9,7 +9,7 @@ import org.sadtech.bot.godfather.telegram.listen.EventDistributor; import org.sadtech.bot.godfather.telegram.listen.EventDistributorImpl; import org.sadtech.bot.godfather.telegram.listen.TelegramConnect; import org.sadtech.bot.godfather.telegram.listen.TelegramSender; -import org.sadtech.social.bot.domain.unit.AnswerCheck; +import org.sadtech.social.bot.domain.unit.AnswerText; import org.sadtech.social.core.domain.content.Mail; import org.sadtech.social.core.repository.impl.local.MailRepositoryList; import org.sadtech.social.core.service.MailService; @@ -18,7 +18,6 @@ import org.sadtech.social.core.service.impl.MailServiceImpl; import org.sadtech.social.core.service.sender.Sending; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling; import java.util.Collections; @@ -28,7 +27,7 @@ import java.util.Collections; * * @author upagge [30.01.2020] */ -@Configuration +//@Configuration @EnableScheduling public class TelegramBotConfig { @@ -44,13 +43,12 @@ public class TelegramBotConfig { @Bean public MessageAutoresponderTelegram messageAutoresponderTelegram( - AnswerCheck regCheck, Sending sending, MessageService messageService, UnitPointerRepository unitPointerRepository ) { return new MessageAutoresponderTelegram( - Collections.singleton(regCheck), + Collections.singleton(AnswerText.of("TEST")), sending, messageService, unitPointerRepository diff --git a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/scheduler/CheckNewMessage.java b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/scheduler/CheckNewMessage.java index fc3800f..fbd1835 100644 --- a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/scheduler/CheckNewMessage.java +++ b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/scheduler/CheckNewMessage.java @@ -3,9 +3,8 @@ package org.sadtech.bot.gitlab.telegram.scheduler; import lombok.RequiredArgsConstructor; import org.sadtech.bot.godfather.telegram.autoresponder.MessageAutoresponderTelegram; import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Service; -@Service +//@Service @RequiredArgsConstructor public class CheckNewMessage { diff --git a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/service/MessageSendTelegramService.java b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/service/MessageSendTelegramService.java index 98b6d12..f1669ed 100644 --- a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/service/MessageSendTelegramService.java +++ b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/service/MessageSendTelegramService.java @@ -3,13 +3,12 @@ package org.sadtech.bot.gitlab.telegram.service; import lombok.NonNull; import lombok.RequiredArgsConstructor; import org.sadtech.bot.gitlab.context.domain.notify.Notify; -import org.sadtech.bot.gitlab.context.exception.NotFoundException; import org.sadtech.bot.gitlab.context.service.ChatService; import org.sadtech.bot.gitlab.context.service.MessageSendService; import org.sadtech.social.core.domain.BoxAnswer; import org.sadtech.social.core.service.sender.Sending; -import org.springframework.stereotype.Service; +import java.util.Collections; import java.util.Set; /** @@ -17,13 +16,12 @@ import java.util.Set; * * @author upagge 17.09.2020 */ -@Service +//@Service @RequiredArgsConstructor public class MessageSendTelegramService implements MessageSendService { private final Sending sending; - private final PersonService personService; private final ChatService chatService; @Override @@ -35,14 +33,15 @@ public class MessageSendTelegramService implements MessageSendService { } private Set getTelegramIds(Notify notify) { - switch (notify.getEntityType()) { - case PERSON: - return personService.getAllTelegramIdByLogin(notify.getRecipients()); - case CHAT: - return chatService.getAllTelegramIdByKey(notify.getRecipients()); - default: - throw new NotFoundException("Отправка сообщения этому типу не возможна"); - } +// switch (notify.getEntityType()) { +// case PERSON: +// return personService.getAllTelegramIdByLogin(notify.getRecipients()); +// case CHAT: +// return chatService.getAllTelegramIdByKey(notify.getRecipients()); +// default: +// throw new NotFoundException("Отправка сообщения этому типу не возможна"); +// } + return Collections.emptySet(); } } diff --git a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/service/ReplaceUrlLocalhost.java b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/service/ReplaceUrlLocalhost.java index e18f548..6ccb465 100644 --- a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/service/ReplaceUrlLocalhost.java +++ b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/service/ReplaceUrlLocalhost.java @@ -1,14 +1,13 @@ package org.sadtech.bot.gitlab.telegram.service; import org.sadtech.bot.godfather.telegram.service.SendPreProcessing; -import org.springframework.stereotype.Component; /** * // TODO: 18.09.2020 Добавить описание. * * @author upagge 18.09.2020 */ -@Component +//@Component public class ReplaceUrlLocalhost implements SendPreProcessing { @Override diff --git a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/service/unit/TaskProcessing.java b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/service/unit/TaskProcessing.java index 16c4570..702de5c 100644 --- a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/service/unit/TaskProcessing.java +++ b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/service/unit/TaskProcessing.java @@ -1,49 +1,44 @@ package org.sadtech.bot.gitlab.telegram.service.unit; import lombok.RequiredArgsConstructor; -import org.sadtech.bot.gitlab.context.domain.TaskStatus; import org.sadtech.bot.gitlab.context.domain.entity.Task; -import org.sadtech.bot.gitlab.context.exception.NotFoundException; import org.sadtech.bot.gitlab.context.service.TaskService; import org.sadtech.social.bot.service.usercode.ProcessingData; import org.sadtech.social.core.domain.BoxAnswer; import org.sadtech.social.core.domain.content.Message; -import org.springframework.stereotype.Component; import java.text.MessageFormat; -import java.util.List; -import java.util.stream.Collectors; /** * // TODO: 17.09.2020 Добавить описание. * * @author upagge 17.09.2020 */ -@Component +//@Component @RequiredArgsConstructor public class TaskProcessing implements ProcessingData { - private final PersonService personService; private final TaskService taskService; @Override public BoxAnswer processing(Message message) { - final Person person = personService.getByTelegramId(message.getPersonId()) - .orElseThrow(() -> new NotFoundException("Ошибочка")); - final List tasks = taskService.getAllByResponsibleAndStatus(person.getLogin(), TaskStatus.OPEN); - String messageText; - if (tasks.isEmpty()) { - messageText = "Задач нет"; - } else { - final String tasksString = tasks.stream() - .map(this::createTaskString) - .collect(Collectors.joining("\n")); - messageText = MessageFormat.format( - "Список ваших задач:\n\n{0}", - tasksString - ); - } - return BoxAnswer.of(messageText); +// final Person person = personService.getByTelegramId(message.getPersonId()) +// .orElseThrow(() -> new NotFoundException("Ошибочка")); +// final List tasks = taskService.getAllByResponsibleAndStatus(person.getLogin(), TaskStatus.OPEN); +// String messageText; +// if (tasks.isEmpty()) { +// messageText = "Задач нет"; +// } else { +// final String tasksString = tasks.stream() +// .map(this::createTaskString) +// .collect(Collectors.joining("\n")); +// messageText = MessageFormat.format( +// "Список ваших задач:\n\n{0}", +// tasksString +// ); +// } +// return BoxAnswer.of(messageText); + return null; } private String createTaskString(Task task) { diff --git a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/service/unit/pullrequest/PullRequestNeedWorkProcessing.java b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/service/unit/pullrequest/PullRequestNeedWorkProcessing.java index 6b43fe1..caac6aa 100644 --- a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/service/unit/pullrequest/PullRequestNeedWorkProcessing.java +++ b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/service/unit/pullrequest/PullRequestNeedWorkProcessing.java @@ -1,39 +1,32 @@ package org.sadtech.bot.gitlab.telegram.service.unit.pullrequest; import lombok.RequiredArgsConstructor; -import org.sadtech.bot.gitlab.context.domain.entity.PullRequest; -import org.sadtech.bot.gitlab.context.exception.NotFoundException; import org.sadtech.bot.gitlab.context.service.PullRequestsService; -import org.sadtech.bot.gitlab.context.utils.MessageUtils; -import org.sadtech.bot.vsc.context.domain.ReviewerStatus; import org.sadtech.social.bot.service.usercode.ProcessingData; import org.sadtech.social.core.domain.BoxAnswer; import org.sadtech.social.core.domain.content.Message; -import org.springframework.stereotype.Component; - -import java.util.List; /** * // TODO: 17.09.2020 Добавить описание. * * @author upagge 17.09.2020 */ -@Component +//@Component @RequiredArgsConstructor public class PullRequestNeedWorkProcessing implements ProcessingData { - private final PersonService personService; private final PullRequestsService pullRequestsService; @Override public BoxAnswer processing(Message message) { - final Person person = personService.getByTelegramId(message.getPersonId()) - .orElseThrow(() -> new NotFoundException("Пользователь не найден")); - final List pullRequests = pullRequestsService.getAllByAuthorAndReviewerStatus(person.getLogin(), ReviewerStatus.UNAPPROVED); - return BoxAnswer.of( - MessageUtils.pullRequestForNeedWork(pullRequests) - .orElse("Не найдено ПРов, которые нуждаются в доработке :)") - ); +// final Person person = personService.getByTelegramId(message.getPersonId()) +// .orElseThrow(() -> new NotFoundException("Пользователь не найден")); +// final List pullRequests = pullRequestsService.getAllByAuthorAndReviewerStatus(person.getLogin(), ReviewerStatus.UNAPPROVED); +// return BoxAnswer.of( +// MessageUtils.pullRequestForNeedWork(pullRequests) +// .orElse("Не найдено ПРов, которые нуждаются в доработке :)") +// ); + return null; } } diff --git a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/service/unit/pullrequest/PullRequestReviewProcessing.java b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/service/unit/pullrequest/PullRequestReviewProcessing.java index 8a0e4c9..65879fa 100644 --- a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/service/unit/pullrequest/PullRequestReviewProcessing.java +++ b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/service/unit/pullrequest/PullRequestReviewProcessing.java @@ -1,45 +1,36 @@ package org.sadtech.bot.gitlab.telegram.service.unit.pullrequest; import lombok.RequiredArgsConstructor; -import org.sadtech.bot.gitlab.context.domain.entity.PullRequest; -import org.sadtech.bot.gitlab.context.exception.NotFoundException; import org.sadtech.bot.gitlab.context.service.PullRequestsService; -import org.sadtech.bot.gitlab.context.utils.MessageUtils; -import org.sadtech.bot.vsc.context.domain.PullRequestStatus; -import org.sadtech.bot.vsc.context.domain.ReviewerStatus; import org.sadtech.social.bot.service.usercode.ProcessingData; import org.sadtech.social.core.domain.BoxAnswer; import org.sadtech.social.core.domain.content.Message; -import org.springframework.stereotype.Component; - -import java.util.Collections; -import java.util.List; /** * // TODO: 17.09.2020 Добавить описание. * * @author upagge 17.09.2020 */ -@Component +//@Component @RequiredArgsConstructor public class PullRequestReviewProcessing implements ProcessingData { - private final PersonService personService; private final PullRequestsService pullRequestsService; @Override public BoxAnswer processing(Message message) { - final Person person = personService.getByTelegramId(message.getPersonId()) - .orElseThrow(() -> new NotFoundException("Пользователь не найден")); - final List pullRequests = pullRequestsService.getAllByReviewerAndStatuses( - person.getLogin(), - ReviewerStatus.NEEDS_WORK, - Collections.singleton(PullRequestStatus.OPEN) - ); - return BoxAnswer.of( - MessageUtils.pullRequestForReview(pullRequests) - .orElse("Все ПР проверены :)") - ); +// final Person person = personService.getByTelegramId(message.getPersonId()) +// .orElseThrow(() -> new NotFoundException("Пользователь не найден")); +// final List pullRequests = pullRequestsService.getAllByReviewerAndStatuses( +// person.getLogin(), +// ReviewerStatus.NEEDS_WORK, +// Collections.singleton(PullRequestStatus.OPEN) +// ); +// return BoxAnswer.of( +// MessageUtils.pullRequestForReview(pullRequests) +// .orElse("Все ПР проверены :)") +// ); + return null; } } diff --git a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/unit/NotifySettingUnit.java b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/unit/NotifySettingUnit.java index b7c1f5a..b32ce78 100644 --- a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/unit/NotifySettingUnit.java +++ b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/unit/NotifySettingUnit.java @@ -3,7 +3,6 @@ package org.sadtech.bot.gitlab.telegram.unit; import lombok.Getter; import lombok.NonNull; import lombok.RequiredArgsConstructor; -import org.sadtech.bot.gitlab.context.domain.entity.NotifySetting; import org.sadtech.bot.gitlab.context.exception.NotFoundException; import org.sadtech.bot.gitlab.context.service.NotifyService; import org.sadtech.social.bot.domain.unit.AnswerProcessing; @@ -12,9 +11,7 @@ import org.sadtech.social.core.domain.BoxAnswer; import org.sadtech.social.core.domain.content.Message; import org.sadtech.social.core.utils.KeyBoards; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import java.time.LocalDateTime; import java.util.Arrays; import java.util.stream.Collectors; @@ -23,11 +20,10 @@ import java.util.stream.Collectors; * * @author upagge 20.09.2020 */ -@Configuration +//@Configuration @RequiredArgsConstructor public class NotifySettingUnit { - private final PersonService personService; private final NotifyService notifyService; @Bean @@ -57,15 +53,16 @@ public class NotifySettingUnit { return AnswerProcessing.builder() .processingData( message -> { - final Person person = personService.getByTelegramId(message.getPersonId()) - .orElseThrow(() -> new NotFoundException("Не найдено")); - final NotifySetting notifySetting = notifyService.getSetting(person.getLogin()) - .orElseThrow(() -> new NotFoundException("Не найдено")); - notifySetting.setStartReceiving( - LocalDateTime.now().plusMinutes(DisableMenu.from(message.getText()).getMinutes()) - ); - notifyService.saveSettings(notifySetting); - return BoxAnswer.of("Настройки сохранены"); +// final Person person = personService.getByTelegramId(message.getPersonId()) +// .orElseThrow(() -> new NotFoundException("Не найдено")); +// final NotifySetting notifySetting = notifyService.getSetting(person.getLogin()) +// .orElseThrow(() -> new NotFoundException("Не найдено")); +// notifySetting.setStartReceiving( +// LocalDateTime.now().plusMinutes(DisableMenu.from(message.getText()).getMinutes()) +// ); +// notifyService.saveSettings(notifySetting); +// return BoxAnswer.of("Настройки сохранены"); + return null; } ) .build(); diff --git a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/unit/PullRequestUnitConfig.java b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/unit/PullRequestUnitConfig.java index deb568b..44ac0a7 100644 --- a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/unit/PullRequestUnitConfig.java +++ b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/unit/PullRequestUnitConfig.java @@ -8,14 +8,13 @@ import org.sadtech.social.core.domain.BoxAnswer; import org.sadtech.social.core.domain.content.Message; import org.sadtech.social.core.utils.KeyBoards; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; /** * // TODO: 02.10.2020 Добавить описание. * * @author upagge 02.10.2020 */ -@Configuration +//@Configuration public class PullRequestUnitConfig { @Bean diff --git a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/unit/UnitConfig.java b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/unit/UnitConfig.java index 9c88b9e..71f6fe7 100644 --- a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/unit/UnitConfig.java +++ b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/unit/UnitConfig.java @@ -3,7 +3,6 @@ package org.sadtech.bot.gitlab.telegram.unit; import lombok.RequiredArgsConstructor; import org.sadtech.bot.gitlab.telegram.service.unit.TaskProcessing; import org.sadtech.bot.gitlab.telegram.utils.GeneratorKeyBoards; -import org.sadtech.social.bot.domain.unit.AnswerCheck; import org.sadtech.social.bot.domain.unit.AnswerProcessing; import org.sadtech.social.bot.domain.unit.AnswerText; import org.sadtech.social.core.domain.BoxAnswer; @@ -11,39 +10,22 @@ import org.sadtech.social.core.domain.content.Mail; import org.sadtech.social.core.domain.content.Message; import org.sadtech.social.core.utils.KeyBoards; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; /** * TODO: Добавить описание класса. * * @author upagge [30.01.2020] */ -@Configuration +//@Configuration @RequiredArgsConstructor public class UnitConfig { - private final PersonService personService; - - @Bean - public AnswerCheck regCheck( - AnswerProcessing noRegister, - AnswerText menu - ) { - return AnswerCheck.builder() - .check( - message -> personService.existsByTelegram(message.getPersonId()) - ) - .unitFalse(noRegister) - .unitTrue(menu) - .build(); - } @Bean public AnswerText menu( AnswerProcessing getTasks, AnswerText menuPullRequest, - AnswerText settings, - AnswerProcessing getTopRating + AnswerText settings ) { return AnswerText.builder() .boxAnswer( @@ -55,7 +37,6 @@ public class UnitConfig { .nextUnit(getTasks) .nextUnit(menuPullRequest) .nextUnit(settings) - .nextUnit(getTopRating) .build(); } @@ -87,17 +68,6 @@ public class UnitConfig { .build(); } - @Bean - AnswerProcessing getTopRating( - RatingTopProcessing ratingTopProcessing - ) { - return AnswerProcessing.builder() - .processingData(ratingTopProcessing) - .keyWord("таблица") - .keyWord("рейтинга") - .build(); - } - @Bean public AnswerProcessing noRegister() { return AnswerProcessing.builder()