diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/WebConfig.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/WebConfig.java new file mode 100644 index 00000000..6afaac48 --- /dev/null +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/WebConfig.java @@ -0,0 +1,27 @@ +package de.tum.in.www1.hephaestus; + +import org.springframework.context.annotation.Configuration; +import org.springframework.format.FormatterRegistry; +import org.springframework.lang.NonNull; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import de.tum.in.www1.hephaestus.codereview.comment.IssueCommentConverter; +import de.tum.in.www1.hephaestus.codereview.comment.review.PullRequestReviewCommentConverter; +import de.tum.in.www1.hephaestus.codereview.pullrequest.PullRequestConverter; +import de.tum.in.www1.hephaestus.codereview.pullrequest.review.PullRequestReviewConverter; +import de.tum.in.www1.hephaestus.codereview.repository.RepositoryConverter; +import de.tum.in.www1.hephaestus.codereview.user.UserConverter; + +@Configuration +public class WebConfig implements WebMvcConfigurer { + + @Override + public void addFormatters(@NonNull FormatterRegistry registry) { + registry.addConverter(new UserConverter()); + registry.addConverter(new RepositoryConverter()); + registry.addConverter(new PullRequestConverter()); + registry.addConverter(new PullRequestReviewConverter()); + registry.addConverter(new IssueCommentConverter()); + registry.addConverter(new PullRequestReviewCommentConverter()); + } +} \ No newline at end of file diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/scheduler/GitHubDataSyncService.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/scheduler/GitHubDataSyncService.java index 934ba522..e2171c25 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/scheduler/GitHubDataSyncService.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/scheduler/GitHubDataSyncService.java @@ -23,6 +23,7 @@ import org.kohsuke.github.GHPullRequestQueryBuilder.Sort; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -68,12 +69,18 @@ public class GitHubDataSyncService { private final PullRequestReviewCommentRepository reviewCommentRepository; private final UserRepository userRepository; - private final RepositoryConverter repositoryConverter; - private final PullRequestConverter pullRequestConverter; - private final PullRequestReviewConverter reviewConverter; - private final IssueCommentConverter commentConverter; - private final PullRequestReviewCommentConverter reviewCommentConverter; - private final UserConverter userConverter; + @Autowired + private RepositoryConverter repositoryConverter; + @Autowired + private PullRequestConverter pullRequestConverter; + @Autowired + private PullRequestReviewConverter reviewConverter; + @Autowired + private IssueCommentConverter commentConverter; + @Autowired + private PullRequestReviewCommentConverter reviewCommentConverter; + @Autowired + private UserConverter userConverter; private Set users = new HashSet<>(); private Set reviews = new HashSet<>(); @@ -81,10 +88,7 @@ public class GitHubDataSyncService { public GitHubDataSyncService(RepositoryRepository repositoryRepository, PullRequestRepository pullRequestRepository, PullRequestReviewRepository prReviewRepository, IssueCommentRepository commentRepository, PullRequestReviewCommentRepository reviewCommentRepository, - UserRepository userRepository, - RepositoryConverter repositoryConverter, PullRequestConverter pullRequestConverter, - PullRequestReviewConverter reviewConverter, IssueCommentConverter commentConverter, - PullRequestReviewCommentConverter reviewCommentConverter, UserConverter userConverter) { + UserRepository userRepository) { logger.info("Hello from GitHubDataSyncService!"); this.repositoryRepository = repositoryRepository; @@ -93,13 +97,6 @@ public GitHubDataSyncService(RepositoryRepository repositoryRepository, PullRequ this.commentRepository = commentRepository; this.reviewCommentRepository = reviewCommentRepository; this.userRepository = userRepository; - - this.repositoryConverter = repositoryConverter; - this.pullRequestConverter = pullRequestConverter; - this.reviewConverter = reviewConverter; - this.commentConverter = commentConverter; - this.reviewCommentConverter = reviewCommentConverter; - this.userConverter = userConverter; } public void syncData() {