From 891e55347b44e3897ba3f238849e25a71cf3dce8 Mon Sep 17 00:00:00 2001 From: Ashar Fuadi Date: Sat, 24 Jun 2023 21:49:58 +0700 Subject: [PATCH] refactor(server): pattern: properly use module dependency clients (#464) --- .../chapter/lesson/ChapterLessonResource.java | 12 +- .../problem/ChapterProblemResource.java | 14 +- .../course/chapter/CourseChapterResource.java | 6 +- .../jerahmeel/problem/ProblemResource.java | 10 +- .../problemset/ProblemSetResource.java | 8 +- .../problem/ProblemSetProblemResource.java | 38 ++--- .../jerahmeel/stats/UserStatsResource.java | 8 +- .../bundle/ItemSubmissionModule.java | 8 +- .../bundle/ItemSubmissionResource.java | 26 +-- .../programming/ContestStatsTask.java | 10 +- .../submission/programming/StatsModule.java | 8 +- .../programming/SubmissionModule.java | 2 +- .../programming/SubmissionResource.java | 24 +-- .../UserClient.java => JophielClient.java} | 18 +-- .../judgels/jophiel/profile/ProfileStore.java | 14 +- ...oblemClient.java => SandalphonClient.java} | 151 +++++++++++------- .../sandalphon/lesson/LessonClient.java | 103 ------------ .../ItemSubmissionRegradeProcessor.java | 10 +- .../UrielClient.java} | 21 +-- .../uriel/contest/ContestResource.java | 6 +- .../ContestAnnouncementResource.java | 6 +- .../ContestClarificationResource.java | 12 +- .../contestant/ContestContestantResource.java | 20 +-- .../editorial/ContestEditorialResource.java | 18 +-- .../history/ContestHistoryResource.java | 8 +- .../uriel/contest/log/ContestLogResource.java | 8 +- .../manager/ContestManagerResource.java | 14 +- .../contest/module/ContestModuleResource.java | 6 +- .../problem/ContestProblemResource.java | 16 +- .../contest/rating/ContestRatingResource.java | 6 +- .../scoreboard/ContestScoreboardResource.java | 6 +- .../scoreboard/ContestScoreboardUpdater.java | 10 +- .../ContestScoreboardUpdaterModule.java | 8 +- .../bundle/ContestItemSubmissionResource.java | 24 +-- .../ContestSubmissionResource.java | 26 +-- .../supervisor/ContestSupervisorResource.java | 14 +- .../submission/UrielSubmissionStore.java | 2 +- .../bundle/ItemSubmissionModule.java | 8 +- 38 files changed, 311 insertions(+), 398 deletions(-) rename judgels-backends/judgels-server-app/src/main/java/judgels/jophiel/{user/UserClient.java => JophielClient.java} (80%) rename judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/{problem/ProblemClient.java => SandalphonClient.java} (66%) delete mode 100644 judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/lesson/LessonClient.java rename judgels-backends/judgels-server-app/src/main/java/judgels/{jerahmeel/uriel/ContestClient.java => uriel/UrielClient.java} (61%) rename judgels-backends/judgels-server-app/src/main/java/judgels/{jerahmeel => uriel}/submission/UrielSubmissionStore.java (84%) diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/chapter/lesson/ChapterLessonResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/chapter/lesson/ChapterLessonResource.java index 33a727d41..a67082669 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/chapter/lesson/ChapterLessonResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/chapter/lesson/ChapterLessonResource.java @@ -30,9 +30,9 @@ import judgels.jerahmeel.api.chapter.lesson.ChapterLessonsResponse; import judgels.jerahmeel.chapter.ChapterStore; import judgels.jerahmeel.role.RoleChecker; +import judgels.sandalphon.SandalphonClient; import judgels.sandalphon.api.lesson.LessonInfo; import judgels.sandalphon.api.lesson.LessonStatement; -import judgels.sandalphon.lesson.LessonClient; import judgels.service.actor.ActorChecker; import judgels.service.api.actor.AuthHeader; @@ -42,7 +42,7 @@ public class ChapterLessonResource { @Inject protected RoleChecker roleChecker; @Inject protected ChapterStore chapterStore; @Inject protected ChapterLessonStore lessonStore; - @Inject protected LessonClient lessonClient; + @Inject protected SandalphonClient sandalphonClient; @Inject public ChapterLessonResource() {} @@ -65,7 +65,7 @@ public void setLessons( checkArgument(aliases.size() == data.size(), "Lesson aliases must be unique"); checkArgument(slugs.size() == data.size(), "Lesson slugs must be unique"); - Map slugToJidMap = lessonClient.translateAllowedSlugsToJids(actorJid, slugs); + Map slugToJidMap = sandalphonClient.translateAllowedLessonSlugsToJids(actorJid, slugs); List setData = data.stream().filter(cp -> slugToJidMap.containsKey(cp.getSlug())).map(lesson -> new ChapterLesson.Builder() @@ -89,7 +89,7 @@ public ChapterLessonsResponse getLessons( List lessons = lessonStore.getLessons(chapterJid); Set lessonJids = lessons.stream().map(ChapterLesson::getLessonJid).collect(Collectors.toSet()); - Map lessonsMap = lessonClient.getLessons(lessonJids); + Map lessonsMap = sandalphonClient.getLessons(lessonJids); return new ChapterLessonsResponse.Builder() .data(lessons) @@ -114,8 +114,8 @@ public ChapterLessonStatement getLessonStatement( ChapterLesson lesson = checkFound(lessonStore.getLessonByAlias(chapterJid, lessonAlias)); String lessonJid = lesson.getLessonJid(); - LessonInfo lessonInfo = lessonClient.getLesson(lessonJid); - LessonStatement statement = lessonClient.getLessonStatement(req, uriInfo, lesson.getLessonJid(), language); + LessonInfo lessonInfo = sandalphonClient.getLesson(lessonJid); + LessonStatement statement = sandalphonClient.getLessonStatement(req, uriInfo, lesson.getLessonJid(), language); return new ChapterLessonStatement.Builder() .defaultLanguage(lessonInfo.getDefaultLanguage()) diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/chapter/problem/ChapterProblemResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/chapter/problem/ChapterProblemResource.java index befe56f29..62b339377 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/chapter/problem/ChapterProblemResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/chapter/problem/ChapterProblemResource.java @@ -32,9 +32,9 @@ import judgels.jerahmeel.chapter.ChapterStore; import judgels.jerahmeel.role.RoleChecker; import judgels.jerahmeel.stats.StatsStore; +import judgels.sandalphon.SandalphonClient; import judgels.sandalphon.api.problem.ProblemInfo; import judgels.sandalphon.api.problem.ProblemType; -import judgels.sandalphon.problem.ProblemClient; import judgels.service.actor.ActorChecker; import judgels.service.api.actor.AuthHeader; @@ -44,8 +44,8 @@ public class ChapterProblemResource { @Inject protected RoleChecker roleChecker; @Inject protected ChapterStore chapterStore; @Inject protected ChapterProblemStore problemStore; - @Inject protected ProblemClient problemClient; @Inject protected StatsStore statsStore; + @Inject protected SandalphonClient sandalphonClient; @Inject public ChapterProblemResource() {} @@ -68,7 +68,7 @@ public void setProblems( checkArgument(aliases.size() == data.size(), "Problem aliases must be unique"); checkArgument(slugs.size() == data.size(), "Problem slugs must be unique"); - Map slugToJidMap = problemClient.translateAllowedSlugsToJids(actorJid, slugs); + Map slugToJidMap = sandalphonClient.translateAllowedProblemSlugsToJids(actorJid, slugs); List setData = data.stream().filter(cp -> slugToJidMap.containsKey(cp.getSlug())).map(problem -> new ChapterProblem.Builder() @@ -93,7 +93,7 @@ public ChapterProblemsResponse getProblems( List problems = problemStore.getProblems(chapterJid); Set problemJids = problems.stream().map(ChapterProblem::getProblemJid).collect(Collectors.toSet()); - Map problemsMap = problemClient.getProblems(problemJids); + Map problemsMap = sandalphonClient.getProblems(problemJids); Map problemProgressesMap = statsStore.getProblemProgressesMap(actorJid, problemJids); return new ChapterProblemsResponse.Builder() @@ -120,7 +120,7 @@ public ChapterProblemWorksheet getProblemWorksheet( ChapterProblem problem = checkFound(problemStore.getProblemByAlias(chapterJid, problemAlias)); String problemJid = problem.getProblemJid(); - ProblemInfo problemInfo = problemClient.getProblem(problemJid); + ProblemInfo problemInfo = sandalphonClient.getProblem(problemJid); Optional reasonNotAllowedToSubmit = authHeader.isPresent() ? Optional.empty() @@ -132,7 +132,7 @@ public ChapterProblemWorksheet getProblemWorksheet( .languages(problemInfo.getTitlesByLanguage().keySet()) .problem(problem) .worksheet(new judgels.sandalphon.api.problem.programming.ProblemWorksheet.Builder() - .from(problemClient.getProgrammingProblemWorksheet(req, uriInfo, problemJid, language)) + .from(sandalphonClient.getProgrammingProblemWorksheet(req, uriInfo, problemJid, language)) .reasonNotAllowedToSubmit(reasonNotAllowedToSubmit) .build()) .build(); @@ -142,7 +142,7 @@ public ChapterProblemWorksheet getProblemWorksheet( .languages(problemInfo.getTitlesByLanguage().keySet()) .problem(problem) .worksheet(new judgels.sandalphon.api.problem.bundle.ProblemWorksheet.Builder() - .from(problemClient.getBundleProblemWorksheetWithoutAnswerKey(req, uriInfo, problemJid, language)) + .from(sandalphonClient.getBundleProblemWorksheetWithoutAnswerKey(req, uriInfo, problemJid, language)) .reasonNotAllowedToSubmit(reasonNotAllowedToSubmit) .build()) .build(); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/course/chapter/CourseChapterResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/course/chapter/CourseChapterResource.java index b8e3295f2..fc2b9c677 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/course/chapter/CourseChapterResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/course/chapter/CourseChapterResource.java @@ -39,7 +39,7 @@ import judgels.jerahmeel.course.CourseStore; import judgels.jerahmeel.role.RoleChecker; import judgels.jerahmeel.stats.StatsStore; -import judgels.jophiel.user.UserClient; +import judgels.jophiel.JophielClient; import judgels.service.actor.ActorChecker; import judgels.service.api.actor.AuthHeader; @@ -52,7 +52,7 @@ public class CourseChapterResource { @Inject protected ChapterStore chapterStore; @Inject protected ChapterLessonStore chapterLessonStore; @Inject protected StatsStore statsStore; - @Inject protected UserClient userClient; + @Inject protected JophielClient jophielClient; @Inject public CourseChapterResource() {} @@ -146,7 +146,7 @@ public CourseChapterUserProgressesResponse getChapterUserProgresses( .collect(toList()); Map usernameToJidsMap = - userClient.translateUsernamesToJids(ImmutableSet.copyOf(data.getUsernames())); + jophielClient.translateUsernamesToJids(ImmutableSet.copyOf(data.getUsernames())); Map> userSolvedProblemsMap = statsStore.getUserChapterSolvedProblemsMap( ImmutableSet.copyOf(usernameToJidsMap.values()), chapterJids); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/problem/ProblemResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/problem/ProblemResource.java index 29b459761..d515a5c0e 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/problem/ProblemResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/problem/ProblemResource.java @@ -19,7 +19,7 @@ import judgels.jerahmeel.difficulty.ProblemDifficultyStore; import judgels.jerahmeel.stats.StatsStore; import judgels.persistence.api.Page; -import judgels.sandalphon.problem.ProblemClient; +import judgels.sandalphon.SandalphonClient; import judgels.service.actor.ActorChecker; import judgels.service.api.actor.AuthHeader; @@ -31,7 +31,7 @@ public class ProblemResource { @Inject protected ProblemStore problemStore; @Inject protected StatsStore statsStore; @Inject protected ProblemDifficultyStore difficultyStore; - @Inject protected ProblemClient problemClient; + @Inject protected SandalphonClient sandalphonClient; @Inject public ProblemResource() {} @@ -47,7 +47,7 @@ public ProblemsResponse getProblems( Set allowedProblemJids = null; if (!tags.isEmpty()) { - allowedProblemJids = problemClient.getProblemJidsByTags(tags); + allowedProblemJids = sandalphonClient.getProblemJidsByTags(tags); } Page problems = problemStore.getProblems(allowedProblemJids, pageNumber, PAGE_SIZE); @@ -57,8 +57,8 @@ public ProblemsResponse getProblems( return new ProblemsResponse.Builder() .data(problems) - .problemsMap(problemClient.getProblems(problemJids)) - .problemMetadatasMap(problemClient.getProblemMetadatas(problemJids)) + .problemsMap(sandalphonClient.getProblems(problemJids)) + .problemMetadatasMap(sandalphonClient.getProblemMetadatas(problemJids)) .problemDifficultiesMap(difficultyStore.getProblemDifficultiesMap(problemJids)) .problemProgressesMap(statsStore.getProblemProgressesMap(actorJid, problemJids)) .build(); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/problemset/ProblemSetResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/problemset/ProblemSetResource.java index a6cf300fd..fe39e5aca 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/problemset/ProblemSetResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/problemset/ProblemSetResource.java @@ -41,8 +41,8 @@ import judgels.jerahmeel.problemset.problem.ProblemSetProblemStore; import judgels.jerahmeel.role.RoleChecker; import judgels.jerahmeel.stats.StatsStore; +import judgels.jophiel.JophielClient; import judgels.jophiel.api.profile.Profile; -import judgels.jophiel.user.UserClient; import judgels.persistence.api.Page; import judgels.service.actor.ActorChecker; import judgels.service.api.actor.AuthHeader; @@ -57,7 +57,7 @@ public class ProblemSetResource { @Inject protected ProblemSetProblemStore problemSetProblemStore; @Inject protected ArchiveStore archiveStore; @Inject protected StatsStore statsStore; - @Inject protected UserClient userClient; + @Inject protected JophielClient jophielClient; @Inject public ProblemSetResource() {} @@ -94,7 +94,7 @@ public ProblemSetsResponse getProblemSets( for (ProblemSet problemSet : problemSets.getPage()) { descriptions = descriptions.concat(problemSet.getDescription()); } - Map profilesMap = userClient.parseProfiles(descriptions); + Map profilesMap = jophielClient.parseProfiles(descriptions); return new ProblemSetsResponse.Builder() .data(problemSets) @@ -190,7 +190,7 @@ public ProblemSetUserProgressesResponse getProblemSetUserProgresses(ProblemSetUs Map> problemsMap = problemSetProblemStore.getProblems(problemSetJids); Set usernames = ImmutableSet.copyOf(data.getUsernames()); - Map usernameToJidsMap = userClient.translateUsernamesToJids(usernames); + Map usernameToJidsMap = jophielClient.translateUsernamesToJids(usernames); Set userJids = ImmutableSet.copyOf(usernameToJidsMap.values()); Set problemJids = problemsMap diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/problemset/problem/ProblemSetProblemResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/problemset/problem/ProblemSetProblemResource.java index 3023935c9..d45441f52 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/problemset/problem/ProblemSetProblemResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/problemset/problem/ProblemSetProblemResource.java @@ -41,16 +41,16 @@ import judgels.jerahmeel.problemset.ProblemSetStore; import judgels.jerahmeel.role.RoleChecker; import judgels.jerahmeel.stats.StatsStore; -import judgels.jerahmeel.uriel.ContestClient; +import judgels.jophiel.JophielClient; import judgels.jophiel.api.profile.Profile; -import judgels.jophiel.user.UserClient; +import judgels.sandalphon.SandalphonClient; import judgels.sandalphon.api.problem.ProblemEditorialInfo; import judgels.sandalphon.api.problem.ProblemInfo; import judgels.sandalphon.api.problem.ProblemMetadata; import judgels.sandalphon.api.problem.ProblemType; -import judgels.sandalphon.problem.ProblemClient; import judgels.service.actor.ActorChecker; import judgels.service.api.actor.AuthHeader; +import judgels.uriel.UrielClient; import judgels.uriel.api.contest.ContestInfo; @Path("/api/v2/problemsets/{problemSetJid}/problems") @@ -60,10 +60,10 @@ public class ProblemSetProblemResource { @Inject protected ProblemSetStore problemSetStore; @Inject protected ProblemSetProblemStore problemStore; @Inject protected ProblemDifficultyStore difficultyStore; - @Inject protected UserClient userClient; - @Inject protected ProblemClient problemClient; - @Inject protected ContestClient contestClient; @Inject protected StatsStore statsStore; + @Inject protected JophielClient jophielClient; + @Inject protected SandalphonClient sandalphonClient; + @Inject protected UrielClient urielClient; @Inject public ProblemSetProblemResource() {} @@ -86,14 +86,14 @@ public void setProblems( checkArgument(aliases.size() == data.size(), "Problem aliases must be unique"); checkArgument(slugs.size() == data.size(), "Problem slugs must be unique"); - Map slugToJidMap = problemClient.translateAllowedSlugsToJids(actorJid, slugs); + Map slugToJidMap = sandalphonClient.translateAllowedProblemSlugsToJids(actorJid, slugs); Set contestSlugs = data.stream() .map(ProblemSetProblemData::getContestSlugs) .flatMap(List::stream) .collect(Collectors.toSet()); - Map contestSlugToJidMap = contestClient.translateSlugsToJids(contestSlugs); + Map contestSlugToJidMap = urielClient.translateContestSlugsToJids(contestSlugs); Set notAllowedContestSlugs = data.stream() .map(ProblemSetProblemData::getContestSlugs) @@ -118,7 +118,7 @@ public void setProblems( .collect(Collectors.toList()); Map problemVisibilitiesMap = problemStore.setProblems(problemSetJid, setData); - problemClient.setProblemVisibilityTagsByJids(problemVisibilitiesMap); + sandalphonClient.setProblemVisibilityTagsByJids(problemVisibilitiesMap); } @GET @@ -142,12 +142,12 @@ public ProblemSetProblemsResponse getProblems( return new ProblemSetProblemsResponse.Builder() .data(problems) - .problemsMap(problemClient.getProblems(problemJids)) - .problemMetadatasMap(problemClient.getProblemMetadatas(problemJids)) + .problemsMap(sandalphonClient.getProblems(problemJids)) + .problemMetadatasMap(sandalphonClient.getProblemMetadatas(problemJids)) .problemDifficultiesMap(difficultyStore.getProblemDifficultiesMap(problemJids)) .problemProgressesMap(statsStore.getProblemProgressesMap(actorJid, problemJids)) .contestsMap(roleChecker.isAdmin(actorJid) - ? contestClient.getContestsByJids(contestJids) + ? urielClient.getContestsByJids(contestJids) : ImmutableMap.of()) .build(); } @@ -184,7 +184,7 @@ public ProblemSetProblemWorksheet getProblemWorksheet( ProblemSetProblem problem = checkFound(problemStore.getProblemByAlias(problemSetJid, problemAlias)); String problemJid = problem.getProblemJid(); - ProblemInfo problemInfo = problemClient.getProblem(problemJid); + ProblemInfo problemInfo = sandalphonClient.getProblem(problemJid); Optional reasonNotAllowedToSubmit = authHeader.isPresent() ? Optional.empty() @@ -196,7 +196,7 @@ public ProblemSetProblemWorksheet getProblemWorksheet( .languages(problemInfo.getTitlesByLanguage().keySet()) .problem(problem) .worksheet(new judgels.sandalphon.api.problem.programming.ProblemWorksheet.Builder() - .from(problemClient.getProgrammingProblemWorksheet(req, uriInfo, problemJid, language)) + .from(sandalphonClient.getProgrammingProblemWorksheet(req, uriInfo, problemJid, language)) .reasonNotAllowedToSubmit(reasonNotAllowedToSubmit) .build()) .build(); @@ -206,7 +206,7 @@ public ProblemSetProblemWorksheet getProblemWorksheet( .languages(problemInfo.getTitlesByLanguage().keySet()) .problem(problem) .worksheet(new judgels.sandalphon.api.problem.bundle.ProblemWorksheet.Builder() - .from(problemClient.getBundleProblemWorksheetWithoutAnswerKey(req, uriInfo, problemJid, language)) + .from(sandalphonClient.getBundleProblemWorksheetWithoutAnswerKey(req, uriInfo, problemJid, language)) .reasonNotAllowedToSubmit(reasonNotAllowedToSubmit) .build()) .build(); @@ -229,12 +229,12 @@ public ProblemReportResponse getProblemReport( String problemJid = problem.getProblemJid(); Set problemJids = ImmutableSet.of(problemJid); - ProblemMetadata metadata = problemClient.getProblemMetadata(problem.getProblemJid()); + ProblemMetadata metadata = sandalphonClient.getProblemMetadata(problem.getProblemJid()); ProblemDifficulty difficulty = difficultyStore.getProblemDifficultiesMap(problemJids).get(problemJid); ProblemTopStats topStats = statsStore.getProblemTopStats(problemJid); ProblemProgress progress = statsStore.getProblemProgressesMap(actorJid, problemJids).get(problemJid); - Map contestsMap = contestClient.getContestsByJids(ImmutableSet.copyOf(problem.getContestJids())); + Map contestsMap = urielClient.getContestsByJids(ImmutableSet.copyOf(problem.getContestJids())); List contests = problem.getContestJids().stream() .filter(contestsMap::containsKey) .map(contestsMap::get) @@ -245,7 +245,7 @@ public ProblemReportResponse getProblemReport( topStats.getTopUsersByScore().forEach(e -> userJids.add(e.getUserJid())); topStats.getTopUsersByTime().forEach(e -> userJids.add(e.getUserJid())); topStats.getTopUsersByMemory().forEach(e -> userJids.add(e.getUserJid())); - Map profilesMap = userClient.getProfiles(userJids); + Map profilesMap = jophielClient.getProfiles(userJids); return new ProblemReportResponse.Builder() .metadata(metadata) @@ -270,7 +270,7 @@ public ProblemEditorialResponse getProblemEditorial( checkFound(problemSetStore.getProblemSetByJid(problemSetJid)); ProblemSetProblem problem = checkFound(problemStore.getProblemByAlias(problemSetJid, problemAlias)); - ProblemEditorialInfo editorial = checkFound(problemClient.getProblemEditorial(problem.getProblemJid(), uriInfo.getBaseUri(), language)); + ProblemEditorialInfo editorial = checkFound(sandalphonClient.getProblemEditorial(problem.getProblemJid(), uriInfo.getBaseUri(), language)); return new ProblemEditorialResponse.Builder() .editorial(editorial) .build(); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/stats/UserStatsResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/stats/UserStatsResource.java index 9963fca53..98b8bf6b7 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/stats/UserStatsResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/stats/UserStatsResource.java @@ -16,14 +16,14 @@ import judgels.jerahmeel.api.stats.UserStats; import judgels.jerahmeel.api.stats.UserTopStatsEntry; import judgels.jerahmeel.api.stats.UserTopStatsResponse; +import judgels.jophiel.JophielClient; import judgels.jophiel.api.profile.Profile; -import judgels.jophiel.user.UserClient; import judgels.persistence.api.Page; @Path("/api/v2/stats/users") public class UserStatsResource { @Inject protected StatsStore statsStore; - @Inject protected UserClient userClient; + @Inject protected JophielClient jophielClient; @Inject public UserStatsResource() {} @@ -37,7 +37,7 @@ public UserTopStatsResponse getTopUserStats( Page stats = statsStore.getTopUserStats(pageNumber, pageSize); Set userJids = stats.getPage().stream().map(UserTopStatsEntry::getUserJid).collect(toSet()); - Map profileMap = userClient.getProfiles(userJids); + Map profileMap = jophielClient.getProfiles(userJids); return new UserTopStatsResponse.Builder() .data(stats) @@ -49,7 +49,7 @@ public UserTopStatsResponse getTopUserStats( @Produces(APPLICATION_JSON) @UnitOfWork(readOnly = true) public UserStats getUserStats(@QueryParam("username") String username) { - String userJid = checkFound(userClient.translateUsernameToJid(username)); + String userJid = checkFound(jophielClient.translateUsernameToJid(username)); return statsStore.getUserStats(userJid); } } diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/bundle/ItemSubmissionModule.java b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/bundle/ItemSubmissionModule.java index dd4bc8ac1..1bb3029fd 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/bundle/ItemSubmissionModule.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/bundle/ItemSubmissionModule.java @@ -5,7 +5,7 @@ import io.dropwizard.hibernate.UnitOfWorkAwareProxyFactory; import java.util.concurrent.ExecutorService; import javax.inject.Singleton; -import judgels.sandalphon.problem.ProblemClient; +import judgels.sandalphon.SandalphonClient; import judgels.sandalphon.submission.bundle.ItemSubmissionGraderRegistry; import judgels.sandalphon.submission.bundle.ItemSubmissionRegradeProcessor; import judgels.sandalphon.submission.bundle.ItemSubmissionRegrader; @@ -33,19 +33,19 @@ static ItemSubmissionRegradeProcessor itemSubmissionRegradeProcessor( UnitOfWorkAwareProxyFactory unitOfWorkAwareProxyFactory, ItemSubmissionGraderRegistry itemSubmissionGraderRegistry, ItemSubmissionStore itemSubmissionStore, - ProblemClient problemClient) { + SandalphonClient sandalphonClient) { return unitOfWorkAwareProxyFactory.create( ItemSubmissionRegradeProcessor.class, new Class[] { ItemSubmissionGraderRegistry.class, ItemSubmissionStore.class, - ProblemClient.class + SandalphonClient.class }, new Object[] { itemSubmissionGraderRegistry, itemSubmissionStore, - problemClient + sandalphonClient } ); } diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/bundle/ItemSubmissionResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/bundle/ItemSubmissionResource.java index 57b0d9f06..ee85b3541 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/bundle/ItemSubmissionResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/bundle/ItemSubmissionResource.java @@ -36,16 +36,16 @@ import judgels.jerahmeel.problemset.problem.ProblemSetProblemStore; import judgels.jerahmeel.submission.SubmissionRoleChecker; import judgels.jerahmeel.submission.SubmissionUtils; +import judgels.jophiel.JophielClient; import judgels.jophiel.api.profile.Profile; -import judgels.jophiel.user.UserClient; import judgels.persistence.api.Page; +import judgels.sandalphon.SandalphonClient; import judgels.sandalphon.api.problem.bundle.Item; import judgels.sandalphon.api.problem.bundle.ItemType; import judgels.sandalphon.api.problem.bundle.ProblemWorksheet; import judgels.sandalphon.api.submission.bundle.Grading; import judgels.sandalphon.api.submission.bundle.ItemSubmission; import judgels.sandalphon.api.submission.bundle.ItemSubmissionData; -import judgels.sandalphon.problem.ProblemClient; import judgels.sandalphon.submission.bundle.ItemSubmissionGraderRegistry; import judgels.sandalphon.submission.bundle.ItemSubmissionRegrader; import judgels.sandalphon.submission.bundle.ItemSubmissionStore; @@ -61,8 +61,8 @@ public class ItemSubmissionResource { @Inject protected SubmissionRoleChecker submissionRoleChecker; @Inject protected ItemSubmissionGraderRegistry itemSubmissionGraderRegistry; @Inject protected ItemSubmissionRegrader itemSubmissionRegrader; - @Inject protected UserClient userClient; - @Inject protected ProblemClient problemClient; + @Inject protected JophielClient jophielClient; + @Inject protected SandalphonClient sandalphonClient; @Inject protected ProblemSetProblemStore problemSetProblemStore; @Inject protected ChapterProblemStore chapterProblemStore; @@ -83,7 +83,7 @@ public ItemSubmissionsResponse getSubmissions( boolean canManage = submissionRoleChecker.canManage(actorJid); Optional userJid = username.map( - u -> userClient.translateUsernamesToJids(ImmutableSet.of(u)).getOrDefault(u, "")); + u -> jophielClient.translateUsernamesToJids(ImmutableSet.of(u)).getOrDefault(u, "")); Optional problemJid = Optional.empty(); if (problemAlias.isPresent()) { @@ -95,7 +95,7 @@ public ItemSubmissionsResponse getSubmissions( Set userJids = submissions.getPage().stream().map(ItemSubmission::getUserJid).collect(toSet()); Set problemJids = submissions.getPage().stream().map(ItemSubmission::getProblemJid).collect(toSet()); - Map profilesMap = userClient.getProfiles(userJids); + Map profilesMap = jophielClient.getProfiles(userJids); SubmissionConfig config = new SubmissionConfig.Builder() .canManage(canManage) @@ -108,7 +108,7 @@ public ItemSubmissionsResponse getSubmissions( .map(ItemSubmission::getItemJid) .collect(toSet()); - Map itemsMap = problemClient.getItems(problemJids, itemJids); + Map itemsMap = sandalphonClient.getItems(problemJids, itemJids); Map itemNumbersMap = itemsMap.entrySet().stream() .collect(Collectors.toMap( Map.Entry::getKey, @@ -137,7 +137,7 @@ public void createItemSubmission( String actorJid = actorChecker.check(authHeader); - Item item = checkFound(problemClient.getItem(data.getProblemJid(), data.getItemJid())); + Item item = checkFound(sandalphonClient.getItem(data.getProblemJid(), data.getItemJid())); if (data.getAnswer().trim().isEmpty()) { submissionStore.deleteSubmission( @@ -172,7 +172,7 @@ public Map getLatestSubmissions( boolean canManage = submissionRoleChecker.canManage(actorJid); String userJid; if (canManage && username.isPresent()) { - userJid = checkFound(userClient.translateUsernameToJid(username.get())); + userJid = checkFound(jophielClient.translateUsernameToJid(username.get())); } else { userJid = actorJid; } @@ -205,7 +205,7 @@ public SubmissionSummaryResponse getSubmissionSummary( boolean canManage = submissionRoleChecker.canManage(actorJid); String userJid; if (canManage && username.isPresent()) { - userJid = checkFound(userClient.translateUsernameToJid(username.get())); + userJid = checkFound(jophielClient.translateUsernameToJid(username.get())); } else { userJid = actorJid; } @@ -230,7 +230,7 @@ public SubmissionSummaryResponse getSubmissionSummary( Map itemTypesByItemJid = new HashMap<>(); for (String pJid : problemJids) { - ProblemWorksheet worksheet = problemClient.getBundleProblemWorksheet(null, null, pJid, language); + ProblemWorksheet worksheet = sandalphonClient.getBundleProblemWorksheet(null, null, pJid, language); List items = worksheet.getItems().stream() .filter(item -> !item.getType().equals(ItemType.STATEMENT)) .collect(Collectors.toList()); @@ -241,8 +241,8 @@ public SubmissionSummaryResponse getSubmissionSummary( itemJidsByProblemJid.put(pJid, items.stream().map(Item::getJid).collect(Collectors.toList())); } - Map problemNamesMap = problemClient.getProblemNames(ImmutableSet.copyOf(problemJids), language); - Profile profile = userClient.getProfile(userJid); + Map problemNamesMap = sandalphonClient.getProblemNames(ImmutableSet.copyOf(problemJids), language); + Profile profile = jophielClient.getProfile(userJid); SubmissionConfig config = new SubmissionConfig.Builder() .canManage(canManage) diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/programming/ContestStatsTask.java b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/programming/ContestStatsTask.java index b709431d2..50ae4cc0b 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/programming/ContestStatsTask.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/programming/ContestStatsTask.java @@ -9,17 +9,17 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import judgels.jerahmeel.uriel.ContestClient; import judgels.sandalphon.api.submission.programming.Submission; +import judgels.uriel.UrielClient; public class ContestStatsTask extends Task { - private final ContestClient contestClient; + private final UrielClient urielClient; private final StatsProcessor statsProcessor; - public ContestStatsTask(ContestClient contestClient, StatsProcessor statsProcessor) { + public ContestStatsTask(UrielClient urielClient, StatsProcessor statsProcessor) { super("jerahmeel-stats-contest"); - this.contestClient = contestClient; + this.urielClient = urielClient; this.statsProcessor = statsProcessor; } @@ -41,7 +41,7 @@ public void execute(Map> parameters, PrintWriter output) { List limits = parameters.get("limit"); Optional limit = limits == null || limits.isEmpty() ? empty() : of(Integer.parseInt(limits.get(0))); - List submissions = contestClient.getSubmissionsForStats(contestJid, lastSubmissionId, limit); + List submissions = urielClient.getSubmissionsForStats(contestJid, lastSubmissionId, limit); Submission lastSubmission = null; for (Submission s : submissions) { diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/programming/StatsModule.java b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/programming/StatsModule.java index 0ddfa90c9..f7d4349e5 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/programming/StatsModule.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/programming/StatsModule.java @@ -5,8 +5,8 @@ import io.dropwizard.hibernate.UnitOfWorkAwareProxyFactory; import javax.inject.Singleton; import judgels.jerahmeel.submission.JerahmeelSubmissionStore; -import judgels.jerahmeel.uriel.ContestClient; import judgels.sandalphon.submission.programming.SubmissionStore; +import judgels.uriel.UrielClient; @Module public class StatsModule { @@ -33,16 +33,16 @@ static ProblemSetStatsTask problemSetStatsTask( @Singleton static ContestStatsTask contestStatsTask( UnitOfWorkAwareProxyFactory unitOfWorkAwareProxyFactory, - ContestClient contestClient, + UrielClient urielClient, StatsProcessor statsProcessor) { return unitOfWorkAwareProxyFactory.create( ContestStatsTask.class, new Class[] { - ContestClient.class, + UrielClient.class, StatsProcessor.class}, new Object[] { - contestClient, + urielClient, statsProcessor}); } } diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/programming/SubmissionModule.java b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/programming/SubmissionModule.java index b6e37a177..6ab274c17 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/programming/SubmissionModule.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/programming/SubmissionModule.java @@ -17,7 +17,6 @@ import judgels.jerahmeel.persistence.ProgrammingSubmissionDao; import judgels.jerahmeel.stats.StatsConfiguration; import judgels.jerahmeel.submission.JerahmeelSubmissionStore; -import judgels.jerahmeel.submission.UrielSubmissionStore; import judgels.messaging.MessageClient; import judgels.sandalphon.submission.bundle.BaseItemSubmissionStore; import judgels.sandalphon.submission.bundle.ItemSubmissionStore; @@ -35,6 +34,7 @@ import judgels.service.JudgelsScheduler; import judgels.uriel.persistence.ContestProgrammingGradingDao; import judgels.uriel.persistence.ContestProgrammingSubmissionDao; +import judgels.uriel.submission.UrielSubmissionStore; @Module public class SubmissionModule { diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/programming/SubmissionResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/programming/SubmissionResource.java index f289f39b4..bdde97732 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/programming/SubmissionResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/programming/SubmissionResource.java @@ -43,9 +43,10 @@ import judgels.jerahmeel.submission.JerahmeelSubmissionStore; import judgels.jerahmeel.submission.SubmissionRoleChecker; import judgels.jerahmeel.submission.SubmissionUtils; +import judgels.jophiel.JophielClient; import judgels.jophiel.api.profile.Profile; -import judgels.jophiel.user.UserClient; import judgels.persistence.api.Page; +import judgels.sandalphon.SandalphonClient; import judgels.sandalphon.SandalphonUtils; import judgels.sandalphon.api.problem.ProblemInfo; import judgels.sandalphon.api.problem.programming.ProblemSubmissionConfig; @@ -53,7 +54,6 @@ import judgels.sandalphon.api.submission.programming.SubmissionData; import judgels.sandalphon.api.submission.programming.SubmissionWithSource; import judgels.sandalphon.api.submission.programming.SubmissionWithSourceResponse; -import judgels.sandalphon.problem.ProblemClient; import judgels.sandalphon.submission.programming.SubmissionClient; import judgels.sandalphon.submission.programming.SubmissionRegrader; import judgels.sandalphon.submission.programming.SubmissionSourceBuilder; @@ -72,8 +72,8 @@ public class SubmissionResource { @Inject protected SubmissionClient submissionClient; @Inject protected SubmissionRegrader submissionRegrader; @Inject protected SubmissionRoleChecker submissionRoleChecker; - @Inject protected UserClient userClient; - @Inject protected ProblemClient problemClient; + @Inject protected JophielClient jophielClient; + @Inject protected SandalphonClient sandalphonClient; @Inject protected ProblemSetStore problemSetStore; @Inject protected ProblemSetProblemStore problemSetProblemStore; @@ -112,7 +112,7 @@ public SubmissionsResponse getSubmissions( problemJids = ImmutableSet.copyOf(chapterProblemStore.getProgrammingProblemJids(containerJid.get())); } - Map profilesMap = userClient.getProfiles(userJids); + Map profilesMap = jophielClient.getProfiles(userJids); SubmissionConfig config = new SubmissionConfig.Builder() .canManage(canManage) @@ -129,7 +129,7 @@ public SubmissionsResponse getSubmissions( Map problemNamesMap = new HashMap<>(); if (!containerJid.isPresent()) { - problemNamesMap = problemClient.getProblemNames(problemJids, Optional.empty()); + problemNamesMap = sandalphonClient.getProblemNames(problemJids, Optional.empty()); } Map containerNamesMap = new HashMap<>(); @@ -187,10 +187,10 @@ public SubmissionWithSourceResponse getSubmissionWithSourceById( problemAlias = problem.getAlias(); } - ProblemInfo problem = problemClient.getProblem(submission.getProblemJid()); + ProblemInfo problem = sandalphonClient.getProblem(submission.getProblemJid()); String userJid = submission.getUserJid(); - Profile profile = checkFound(Optional.ofNullable(userClient.getProfile(userJid))); + Profile profile = checkFound(Optional.ofNullable(jophielClient.getProfile(userJid))); SubmissionWithSource submissionWithSource; if (submissionRoleChecker.canViewSource(actorJid, submission.getUserJid())) { @@ -253,7 +253,7 @@ public void createSubmission(@HeaderParam(AUTHORIZATION) AuthHeader authHeader, .gradingLanguage(gradingLanguage) .build(); SubmissionSource source = submissionSourceBuilder.fromNewSubmission(parts); - ProblemSubmissionConfig config = problemClient.getProgrammingProblemSubmissionConfig(data.getProblemJid()); + ProblemSubmissionConfig config = sandalphonClient.getProgrammingProblemSubmissionConfig(data.getProblemJid()); Submission submission = submissionClient.submit(data, source, config); submissionSourceBuilder.storeSubmissionSource(submission.getJid(), source); @@ -270,7 +270,7 @@ public void regradeSubmission( Submission submission = checkFound(submissionStore.getSubmissionByJid(submissionJid)); checkAllowed(submissionRoleChecker.canManage(actorJid)); - ProblemSubmissionConfig config = problemClient.getProgrammingProblemSubmissionConfig(submission.getProblemJid()); + ProblemSubmissionConfig config = sandalphonClient.getProgrammingProblemSubmissionConfig(submission.getProblemJid()); submissionRegrader.regradeSubmission(submission, config); } @@ -300,13 +300,13 @@ public void regradeSubmissions( } Set problemJids = submissions.stream().map(Submission::getProblemJid).collect(toSet()); - Map configsMap = problemClient.getProgrammingProblemSubmissionConfigs(problemJids); + Map configsMap = sandalphonClient.getProgrammingProblemSubmissionConfigs(problemJids); submissionRegrader.regradeSubmissions(submissions, configsMap); } } private Optional byUserJid(Optional username) { - return username.map(u -> userClient.translateUsernameToJid(u).orElse("")); + return username.map(u -> jophielClient.translateUsernameToJid(u).orElse("")); } private Optional byProblemJid( diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/jophiel/user/UserClient.java b/judgels-backends/judgels-server-app/src/main/java/judgels/jophiel/JophielClient.java similarity index 80% rename from judgels-backends/judgels-server-app/src/main/java/judgels/jophiel/user/UserClient.java rename to judgels-backends/judgels-server-app/src/main/java/judgels/jophiel/JophielClient.java index ff6d1bc01..41fbded53 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/jophiel/user/UserClient.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/jophiel/JophielClient.java @@ -1,4 +1,4 @@ -package judgels.jophiel.user; +package judgels.jophiel; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; @@ -13,21 +13,17 @@ import judgels.jophiel.api.profile.Profile; import judgels.jophiel.api.user.rating.UserRatingEvent; import judgels.jophiel.profile.ProfileStore; +import judgels.jophiel.user.UserStore; import judgels.jophiel.user.rating.UserRatingStore; -public class UserClient { +public class JophielClient { private static final Pattern USERNAME_PATTERN = Pattern.compile("\\[user:(\\S+)]"); - private final UserStore userStore; - private final UserRatingStore userRatingStore; - private final ProfileStore profileStore; + @Inject protected UserStore userStore; + @Inject protected UserRatingStore userRatingStore; + @Inject protected ProfileStore profileStore; - @Inject - public UserClient(UserStore userStore, UserRatingStore userRatingStore, ProfileStore profileStore) { - this.userStore = userStore; - this.userRatingStore = userRatingStore; - this.profileStore = profileStore; - } + @Inject public JophielClient() {} public Optional translateUsernameToJid(String username) { return userStore.translateUsernameToJid(username); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/jophiel/profile/ProfileStore.java b/judgels-backends/judgels-server-app/src/main/java/judgels/jophiel/profile/ProfileStore.java index cdb082e21..d25191342 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/jophiel/profile/ProfileStore.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/jophiel/profile/ProfileStore.java @@ -1,12 +1,10 @@ package judgels.jophiel.profile; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; import java.time.Instant; import java.util.Map; import java.util.Optional; import java.util.Set; -import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; import javax.inject.Inject; @@ -55,21 +53,11 @@ public Map getProfiles(Set userJids, Instant time) { .rating(Optional.ofNullable(ratings.get(e.getKey()))) .build())); } + public Map getProfiles(Set userJids) { return getProfiles(userJids, Instant.now()); } - public Map parseProfiles(String str) { - Set usernames = Sets.newHashSet(); - Matcher m = USERNAME_PATTERN.matcher(str); - while (m.find()) { - usernames.add(m.group(1)); - } - - Set userJids = ImmutableSet.copyOf(userStore.translateUsernamesToJids(usernames).values()); - return getProfiles(userJids); - } - public Page getTopRatedProfiles(Instant time, int pageNumber, int pageSize) { Page ratings = ratingStore.getTopRatings(time, pageNumber, pageSize); Set userJids = ratings.getPage().stream().map(UserWithRating::getUserJid).collect(Collectors.toSet()); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/problem/ProblemClient.java b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/SandalphonClient.java similarity index 66% rename from judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/problem/ProblemClient.java rename to judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/SandalphonClient.java index d8de47ae4..2c4e1834f 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/problem/ProblemClient.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/SandalphonClient.java @@ -1,4 +1,4 @@ -package judgels.sandalphon.problem; +package judgels.sandalphon; import static java.util.stream.Collectors.toMap; import static judgels.sandalphon.resource.LanguageUtils.simplifyLanguageCode; @@ -16,7 +16,9 @@ import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.UriInfo; import judgels.gabriel.api.GradingConfig; -import judgels.sandalphon.SandalphonUtils; +import judgels.sandalphon.api.lesson.Lesson; +import judgels.sandalphon.api.lesson.LessonInfo; +import judgels.sandalphon.api.lesson.LessonStatement; import judgels.sandalphon.api.problem.Problem; import judgels.sandalphon.api.problem.ProblemEditorial; import judgels.sandalphon.api.problem.ProblemEditorialInfo; @@ -29,6 +31,8 @@ import judgels.sandalphon.api.problem.bundle.ItemConfig; import judgels.sandalphon.api.problem.programming.ProblemLimits; import judgels.sandalphon.api.problem.programming.ProblemSubmissionConfig; +import judgels.sandalphon.lesson.LessonStore; +import judgels.sandalphon.lesson.statement.LessonStatementStore; import judgels.sandalphon.problem.base.ProblemStore; import judgels.sandalphon.problem.base.editorial.ProblemEditorialStore; import judgels.sandalphon.problem.base.statement.ProblemStatementStore; @@ -39,38 +43,21 @@ import judgels.sandalphon.resource.StatementLanguageStatus; import judgels.sandalphon.role.RoleChecker; -public class ProblemClient { - private final RoleChecker roleChecker; - private final ProblemStore problemStore; - private final ProblemStatementStore statementStore; - private final ProblemEditorialStore editorialStore; - private final ProblemTagStore tagStore; - private final ProgrammingProblemStore programmingProblemStore; - private final BundleItemStore bundleItemStore; - private final ItemProcessorRegistry itemProcessorRegistry; - - @Inject - public ProblemClient( - RoleChecker roleChecker, - ProblemStore problemStore, - ProblemStatementStore statementStore, - ProblemEditorialStore editorialStore, - ProblemTagStore tagStore, - ProgrammingProblemStore programmingProblemStore, - BundleItemStore bundleItemStore, - ItemProcessorRegistry itemProcessorRegistry) { - - this.roleChecker = roleChecker; - this.problemStore = problemStore; - this.statementStore = statementStore; - this.editorialStore = editorialStore; - this.tagStore = tagStore; - this.programmingProblemStore = programmingProblemStore; - this.bundleItemStore = bundleItemStore; - this.itemProcessorRegistry = itemProcessorRegistry; - } - - public Map translateAllowedSlugsToJids(String actorJid, Set slugs) { +public class SandalphonClient { + @Inject protected RoleChecker roleChecker; + @Inject protected ProblemStore problemStore; + @Inject protected ProblemStatementStore problemStatementStore; + @Inject protected ProblemEditorialStore problemEditorialStore; + @Inject protected ProblemTagStore problemTagStore; + @Inject protected ProgrammingProblemStore programmingProblemStore; + @Inject protected BundleItemStore bundleItemStore; + @Inject protected ItemProcessorRegistry itemProcessorRegistry; + @Inject protected LessonStore lessonStore; + @Inject protected LessonStatementStore lessonStatementStore; + + @Inject public SandalphonClient() {} + + public Map translateAllowedProblemSlugsToJids(String actorJid, Set slugs) { Optional userJid = roleChecker.isAdmin(actorJid) ? Optional.empty() : Optional.of(actorJid); @@ -78,12 +65,12 @@ public Map translateAllowedSlugsToJids(String actorJid, Set getProblemJidsByTags(Set tags) { - return tagStore.filterProblemJidsByTags(null, tags); + return problemTagStore.filterProblemJidsByTags(null, tags); } public void setProblemVisibilityTagsByJids(Map problemVisibilitiesMap) { for (Map.Entry entry : problemVisibilitiesMap.entrySet()) { - tagStore.updateVisibilityTag(entry.getKey(), entry.getValue()); + problemTagStore.updateVisibilityTag(entry.getKey(), entry.getValue()); } } @@ -93,8 +80,8 @@ public ProblemInfo getProblem(String problemJid) { return new ProblemInfo.Builder() .slug(problem.getSlug()) .type(ProblemType.valueOf(problem.getType().name())) - .defaultLanguage(simplifyLanguageCode(statementStore.getStatementDefaultLanguage(null, problemJid))) - .titlesByLanguage(statementStore.getTitlesByLanguage(null, problemJid).entrySet() + .defaultLanguage(simplifyLanguageCode(problemStatementStore.getStatementDefaultLanguage(null, problemJid))) + .titlesByLanguage(problemStatementStore.getTitlesByLanguage(null, problemJid).entrySet() .stream() .collect(toMap(e -> simplifyLanguageCode(e.getKey()), e -> e.getValue()))) .build(); @@ -102,8 +89,8 @@ public ProblemInfo getProblem(String problemJid) { public ProblemMetadata getProblemMetadata(String problemJid) { return new ProblemMetadata.Builder() - .hasEditorial(editorialStore.hasEditorial(null, problemJid)) - .tags(tagStore.findTopicTags(problemJid)) + .hasEditorial(problemEditorialStore.hasEditorial(null, problemJid)) + .tags(problemTagStore.findTopicTags(problemJid)) .settersMap(problemStore.getProblemSetters(problemJid)) .build(); } @@ -159,8 +146,8 @@ public judgels.sandalphon.api.problem.programming.ProblemWorksheet getProgrammin Optional language) { GradingConfig config = programmingProblemStore.getGradingConfig(null, problemJid); - String sanitizedLanguage = sanitizeStatementLanguage(problemJid, language); - ProblemStatement statement = statementStore.getStatement(null, problemJid, sanitizedLanguage); + String sanitizedLanguage = sanitizeProblemStatementLanguage(problemJid, language); + ProblemStatement statement = problemStatementStore.getStatement(null, problemJid, sanitizedLanguage); String apiUrl = getApiUrl(req, uriInfo); return new judgels.sandalphon.api.problem.programming.ProblemWorksheet.Builder() @@ -182,8 +169,8 @@ public judgels.sandalphon.api.problem.bundle.ProblemWorksheet getBundleProblemWo String problemJid, Optional language) { - String sanitizedLanguage = sanitizeStatementLanguage(problemJid, language); - String defaultLanguage = statementStore.getStatementDefaultLanguage(null, problemJid); + String sanitizedLanguage = sanitizeProblemStatementLanguage(problemJid, language); + String defaultLanguage = problemStatementStore.getStatementDefaultLanguage(null, problemJid); List items = bundleItemStore.getNumberedItems(null, problemJid); List itemsWithConfig = new ArrayList<>(); @@ -199,7 +186,7 @@ public judgels.sandalphon.api.problem.bundle.ProblemWorksheet getBundleProblemWo itemsWithConfig.add(itemWithConfig); } - ProblemStatement statement = statementStore.getStatement(null, problemJid, sanitizedLanguage); + ProblemStatement statement = problemStatementStore.getStatement(null, problemJid, sanitizedLanguage); String apiUrl = getApiUrl(req, uriInfo); return new judgels.sandalphon.api.problem.bundle.ProblemWorksheet.Builder() @@ -232,17 +219,17 @@ public judgels.sandalphon.api.problem.bundle.ProblemWorksheet getBundleProblemWo } public Optional getProblemEditorial(String problemJid, URI baseUri, Optional language) { - if (!editorialStore.hasEditorial(null, problemJid)) { + if (!problemEditorialStore.hasEditorial(null, problemJid)) { return Optional.empty(); } - String sanitizedLanguage = sanitizeEditorialLanguage(problemJid, language); - ProblemEditorial editorial = editorialStore.getEditorial(null, problemJid, sanitizedLanguage); + String sanitizedLanguage = sanitizeProblemEditorialLanguage(problemJid, language); + ProblemEditorial editorial = problemEditorialStore.getEditorial(null, problemJid, sanitizedLanguage); return Optional.of(new ProblemEditorialInfo.Builder() .text(SandalphonUtils.replaceProblemEditorialRenderUrls(editorial.getText(), baseUri.toString(), problemJid)) - .defaultLanguage(simplifyLanguageCode(editorialStore.getEditorialDefaultLanguage(null, problemJid))) - .languages(editorialStore.getEditorialLanguages(null, problemJid).stream() + .defaultLanguage(simplifyLanguageCode(problemEditorialStore.getEditorialDefaultLanguage(null, problemJid))) + .languages(problemEditorialStore.getEditorialLanguages(null, problemJid).stream() .map(lang -> simplifyLanguageCode(lang)) .collect(Collectors.toSet())) .build()); @@ -259,29 +246,81 @@ public Map getProblemEditorials(Set proble return Collections.unmodifiableMap(editorialsMap); } - private String sanitizeStatementLanguage(String problemJid, Optional language) { - Map availableLanguages = statementStore.getStatementAvailableLanguages(null, problemJid); + private String sanitizeProblemStatementLanguage(String problemJid, Optional language) { + Map availableLanguages = problemStatementStore.getStatementAvailableLanguages(null, problemJid); Map simplifiedLanguages = availableLanguages.entrySet() .stream() .collect(Collectors.toMap(e -> simplifyLanguageCode(e.getKey()), e -> e.getKey())); String lang = language.orElse(""); if (!simplifiedLanguages.containsKey(lang) || availableLanguages.get(simplifiedLanguages.get(lang)) == StatementLanguageStatus.DISABLED) { - lang = simplifyLanguageCode(statementStore.getStatementDefaultLanguage(null, problemJid)); + lang = simplifyLanguageCode(problemStatementStore.getStatementDefaultLanguage(null, problemJid)); } return simplifiedLanguages.get(lang); } - private String sanitizeEditorialLanguage(String problemJid, Optional language) { - Map availableLanguages = editorialStore.getEditorialAvailableLanguages(null, problemJid); + private String sanitizeProblemEditorialLanguage(String problemJid, Optional language) { + Map availableLanguages = problemEditorialStore.getEditorialAvailableLanguages(null, problemJid); + Map simplifiedLanguages = availableLanguages.entrySet() + .stream() + .collect(Collectors.toMap(e -> simplifyLanguageCode(e.getKey()), e -> e.getKey())); + + String lang = language.orElse(""); + if (!simplifiedLanguages.containsKey(lang) || availableLanguages.get(simplifiedLanguages.get(lang)) == StatementLanguageStatus.DISABLED) { + lang = simplifyLanguageCode(problemEditorialStore.getEditorialDefaultLanguage(null, problemJid)); + } + + return simplifiedLanguages.get(lang); + } + + public Map translateAllowedLessonSlugsToJids(String actorJid, Set slugs) { + Optional userJid = roleChecker.isAdmin(actorJid) + ? Optional.empty() + : Optional.of(actorJid); + return lessonStore.translateAllowedSlugsToJids(userJid, slugs); + } + + public LessonInfo getLesson(String lessonJid) { + Lesson lesson = lessonStore.getLessonByJid(lessonJid).get(); + + return new LessonInfo.Builder() + .slug(lesson.getSlug()) + .defaultLanguage(simplifyLanguageCode(lessonStatementStore.getDefaultLanguage(null, lessonJid))) + .titlesByLanguage(lessonStatementStore.getTitlesByLanguage(null, lessonJid).entrySet() + .stream() + .collect(Collectors.toMap(e -> simplifyLanguageCode(e.getKey()), e -> e.getValue()))) + .build(); + } + + public Map getLessons(Set lessonJids) { + return lessonJids.stream().collect(Collectors.toMap(jid -> jid, this::getLesson)); + } + + public LessonStatement getLessonStatement( + HttpServletRequest req, + UriInfo uriInfo, + String lessonJid, Optional language) { + + String sanitizedLanguage = sanitizeLessonStatementLanguage(lessonJid, language); + LessonStatement statement = lessonStatementStore.getStatement(null, lessonJid, sanitizedLanguage); + String apiUrl = getApiUrl(req, uriInfo); + + return new LessonStatement.Builder() + .from(statement) + .text(SandalphonUtils.replaceLessonRenderUrls(statement.getText(), apiUrl, lessonJid)) + .build(); + } + + private String sanitizeLessonStatementLanguage(String problemJid, Optional language) { + Map availableLanguages = lessonStatementStore.getAvailableLanguages(null, problemJid); Map simplifiedLanguages = availableLanguages.entrySet() .stream() .collect(Collectors.toMap(e -> simplifyLanguageCode(e.getKey()), e -> e.getKey())); String lang = language.orElse(""); if (!simplifiedLanguages.containsKey(lang) || availableLanguages.get(simplifiedLanguages.get(lang)) == StatementLanguageStatus.DISABLED) { - lang = simplifyLanguageCode(editorialStore.getEditorialDefaultLanguage(null, problemJid)); + lang = simplifyLanguageCode(lessonStatementStore.getDefaultLanguage(null, problemJid)); } return simplifiedLanguages.get(lang); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/lesson/LessonClient.java b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/lesson/LessonClient.java deleted file mode 100644 index 13c9092df..000000000 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/lesson/LessonClient.java +++ /dev/null @@ -1,103 +0,0 @@ -package judgels.sandalphon.lesson; - -import static judgels.sandalphon.resource.LanguageUtils.simplifyLanguageCode; - -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; -import javax.inject.Inject; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.core.UriInfo; -import judgels.sandalphon.SandalphonUtils; -import judgels.sandalphon.api.lesson.Lesson; -import judgels.sandalphon.api.lesson.LessonInfo; -import judgels.sandalphon.api.lesson.LessonStatement; -import judgels.sandalphon.lesson.statement.LessonStatementStore; -import judgels.sandalphon.resource.StatementLanguageStatus; -import judgels.sandalphon.role.RoleChecker; - -public class LessonClient { - private final RoleChecker roleChecker; - private final LessonStore lessonStore; - private final LessonStatementStore statementStore; - - @Inject - public LessonClient( - RoleChecker roleChecker, - LessonStore lessonStore, - LessonStatementStore statementStore) { - - this.roleChecker = roleChecker; - this.lessonStore = lessonStore; - this.statementStore = statementStore; - } - - public Map translateAllowedSlugsToJids(String actorJid, Set slugs) { - Optional userJid = roleChecker.isAdmin(actorJid) - ? Optional.empty() - : Optional.of(actorJid); - return lessonStore.translateAllowedSlugsToJids(userJid, slugs); - } - - public LessonInfo getLesson(String lessonJid) { - Lesson lesson = lessonStore.getLessonByJid(lessonJid).get(); - - return new LessonInfo.Builder() - .slug(lesson.getSlug()) - .defaultLanguage(simplifyLanguageCode(statementStore.getDefaultLanguage(null, lessonJid))) - .titlesByLanguage(statementStore.getTitlesByLanguage(null, lessonJid).entrySet() - .stream() - .collect(Collectors.toMap(e -> simplifyLanguageCode(e.getKey()), e -> e.getValue()))) - .build(); - } - - public Map getLessons(Set lessonJids) { - return lessonJids.stream().collect(Collectors.toMap(jid -> jid, this::getLesson)); - } - - public LessonStatement getLessonStatement( - HttpServletRequest req, - UriInfo uriInfo, - String lessonJid, Optional language) { - - String sanitizedLanguage = sanitizeLanguage(lessonJid, language); - LessonStatement statement = statementStore.getStatement(null, lessonJid, sanitizedLanguage); - String apiUrl = getApiUrl(req, uriInfo); - - return new LessonStatement.Builder() - .from(statement) - .text(SandalphonUtils.replaceLessonRenderUrls(statement.getText(), apiUrl, lessonJid)) - .build(); - } - - private String sanitizeLanguage(String problemJid, Optional language) { - Map availableLanguages = statementStore.getAvailableLanguages(null, problemJid); - Map simplifiedLanguages = availableLanguages.entrySet() - .stream() - .collect(Collectors.toMap(e -> simplifyLanguageCode(e.getKey()), e -> e.getKey())); - - String lang = language.orElse(""); - if (!simplifiedLanguages.containsKey(lang) || availableLanguages.get(simplifiedLanguages.get(lang)) == StatementLanguageStatus.DISABLED) { - lang = simplifyLanguageCode(statementStore.getDefaultLanguage(null, problemJid)); - } - - return simplifiedLanguages.get(lang); - } - - private static String getApiUrl(HttpServletRequest req, UriInfo uriInfo) { - if (req == null) { - return ""; - } - - String oldScheme = uriInfo.getBaseUri().getScheme(); - String newScheme = oldScheme; - - String forwardedProto = req.getHeader("X-Forwarded-Proto"); - if (forwardedProto != null && !forwardedProto.isEmpty()) { - newScheme = forwardedProto; - } - - return newScheme + uriInfo.getBaseUri().toString().substring(oldScheme.length()); - } -} diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/submission/bundle/ItemSubmissionRegradeProcessor.java b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/submission/bundle/ItemSubmissionRegradeProcessor.java index 20d3886cd..c6e8e405c 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/submission/bundle/ItemSubmissionRegradeProcessor.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/submission/bundle/ItemSubmissionRegradeProcessor.java @@ -4,10 +4,10 @@ import java.util.List; import java.util.Optional; import javax.inject.Inject; +import judgels.sandalphon.SandalphonClient; import judgels.sandalphon.api.problem.bundle.Item; import judgels.sandalphon.api.submission.bundle.Grading; import judgels.sandalphon.api.submission.bundle.ItemSubmission; -import judgels.sandalphon.problem.ProblemClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -16,23 +16,23 @@ public class ItemSubmissionRegradeProcessor { private final ItemSubmissionGraderRegistry itemSubmissionGraderRegistry; private final ItemSubmissionStore itemSubmissionStore; - private final ProblemClient problemClient; + private final SandalphonClient sandalphonClient; @Inject public ItemSubmissionRegradeProcessor( ItemSubmissionGraderRegistry itemSubmissionGraderRegistry, ItemSubmissionStore itemSubmissionStore, - ProblemClient problemClient) { + SandalphonClient sandalphonClient) { this.itemSubmissionGraderRegistry = itemSubmissionGraderRegistry; this.itemSubmissionStore = itemSubmissionStore; - this.problemClient = problemClient; + this.sandalphonClient = sandalphonClient; } @UnitOfWork public void process(List submissions) { for (ItemSubmission submission : submissions) { - Optional item = problemClient.getItem(submission.getProblemJid(), submission.getItemJid()); + Optional item = sandalphonClient.getItem(submission.getProblemJid(), submission.getItemJid()); if (item.isPresent()) { Grading grading = itemSubmissionGraderRegistry .get(item.get().getType()) diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/uriel/ContestClient.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/UrielClient.java similarity index 61% rename from judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/uriel/ContestClient.java rename to judgels-backends/judgels-server-app/src/main/java/judgels/uriel/UrielClient.java index 27bd14604..0511c8ddd 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/uriel/ContestClient.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/UrielClient.java @@ -1,34 +1,27 @@ -package judgels.jerahmeel.uriel; +package judgels.uriel; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; import javax.inject.Inject; -import judgels.jerahmeel.submission.UrielSubmissionStore; import judgels.sandalphon.api.submission.programming.Submission; import judgels.sandalphon.submission.programming.SubmissionStore; import judgels.uriel.api.contest.ContestInfo; import judgels.uriel.contest.ContestStore; +import judgels.uriel.submission.UrielSubmissionStore; -public class ContestClient { - private final ContestStore contestStore; - private final SubmissionStore submissionStore; +public class UrielClient { + @Inject protected ContestStore contestStore; + @Inject @UrielSubmissionStore protected SubmissionStore submissionStore; - @Inject - public ContestClient( - ContestStore contestStore, - @UrielSubmissionStore SubmissionStore submissionStore) { - - this.contestStore = contestStore; - this.submissionStore = submissionStore; - } + @Inject public UrielClient() {} public Map getContestsByJids(Set contestJids) { return contestStore.getContestInfosByJids(contestJids); } - public Map translateSlugsToJids(Set contestSlugs) { + public Map translateContestSlugsToJids(Set contestSlugs) { return contestStore.translateSlugsToJids(contestSlugs); } diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/ContestResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/ContestResource.java index 9b5e15b25..27cd13999 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/ContestResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/ContestResource.java @@ -21,7 +21,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; -import judgels.jophiel.profile.ProfileStore; +import judgels.jophiel.JophielClient; import judgels.persistence.api.Page; import judgels.service.actor.ActorChecker; import judgels.service.api.actor.AuthHeader; @@ -48,7 +48,7 @@ public class ContestResource { @Inject protected ContestLogger contestLogger; @Inject protected ContestModuleStore moduleStore; @Inject protected ContestContestantStore contestantStore; - @Inject protected ProfileStore profileStore; + @Inject protected JophielClient jophielClient; @Inject public ContestResource() {} @@ -228,7 +228,7 @@ public ContestDescription getContestDescription( String description = contestStore.getContestDescription(contest.getJid()); return new ContestDescription.Builder() .description(description) - .profilesMap(profileStore.parseProfiles(description)) + .profilesMap(jophielClient.parseProfiles(description)) .build(); } diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/announcement/ContestAnnouncementResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/announcement/ContestAnnouncementResource.java index dce94054a..2bb0ba374 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/announcement/ContestAnnouncementResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/announcement/ContestAnnouncementResource.java @@ -22,8 +22,8 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; +import judgels.jophiel.JophielClient; import judgels.jophiel.api.profile.Profile; -import judgels.jophiel.user.UserClient; import judgels.persistence.api.Page; import judgels.service.actor.ActorChecker; import judgels.service.api.actor.AuthHeader; @@ -44,7 +44,7 @@ public class ContestAnnouncementResource { @Inject protected ContestLogger contestLogger; @Inject protected ContestAnnouncementRoleChecker announcementRoleChecker; @Inject protected ContestAnnouncementStore announcementStore; - @Inject protected UserClient userClient; + @Inject protected JophielClient jophielClient; @Inject public ContestAnnouncementResource() {} @@ -74,7 +74,7 @@ public ContestAnnouncementsResponse getAnnouncements( .stream() .map(ContestAnnouncement::getUserJid) .collect(Collectors.toSet()); - Map profilesMap = userClient.getProfiles(userJids, contest.getBeginTime()); + Map profilesMap = jophielClient.getProfiles(userJids, contest.getBeginTime()); contestLogger.log(contestJid, "OPEN_ANNOUNCEMENTS"); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/clarification/ContestClarificationResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/clarification/ContestClarificationResource.java index 7effc5f4e..da86172a7 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/clarification/ContestClarificationResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/clarification/ContestClarificationResource.java @@ -25,10 +25,10 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; +import judgels.jophiel.JophielClient; import judgels.jophiel.api.profile.Profile; -import judgels.jophiel.user.UserClient; import judgels.persistence.api.Page; -import judgels.sandalphon.problem.ProblemClient; +import judgels.sandalphon.SandalphonClient; import judgels.service.actor.ActorChecker; import judgels.service.api.actor.AuthHeader; import judgels.uriel.api.contest.Contest; @@ -51,8 +51,8 @@ public class ContestClarificationResource { @Inject protected ContestClarificationRoleChecker clarificationRoleChecker; @Inject protected ContestClarificationStore clarificationStore; @Inject protected ContestProblemStore problemStore; - @Inject protected UserClient userClient; - @Inject protected ProblemClient problemClient; + @Inject protected JophielClient jophielClient; + @Inject protected SandalphonClient sandalphonClient; @Inject public ContestClarificationResource() {} @@ -133,10 +133,10 @@ public ContestClarificationsResponse getClarifications( .map(Optional::get) .collect(Collectors.toSet()); - Map profilesMap = userClient.getProfiles(userJids, contest.getBeginTime()); + Map profilesMap = jophielClient.getProfiles(userJids, contest.getBeginTime()); Map problemAliasesMap = problemStore.getProblemAliasesByJids(contestJid, problemJids); - Map problemNamesMap = problemClient.getProblemNames(problemJids, language); + Map problemNamesMap = sandalphonClient.getProblemNames(problemJids, language); contestLogger.log(contestJid, "OPEN_CLARIFICATIONS"); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/contestant/ContestContestantResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/contestant/ContestContestantResource.java index 5560976fc..7c781962f 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/contestant/ContestContestantResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/contestant/ContestContestantResource.java @@ -24,8 +24,8 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; +import judgels.jophiel.JophielClient; import judgels.jophiel.api.profile.Profile; -import judgels.jophiel.user.UserClient; import judgels.persistence.api.Page; import judgels.service.actor.ActorChecker; import judgels.service.api.actor.AuthHeader; @@ -52,7 +52,7 @@ public class ContestContestantResource { @Inject protected ContestContestantRoleChecker contestantRoleChecker; @Inject protected ContestContestantStore contestantStore; @Inject protected ContestModuleStore moduleStore; - @Inject protected UserClient userClient; + @Inject protected JophielClient jophielClient; @Inject public ContestContestantResource() {} @@ -71,7 +71,7 @@ public ContestContestantsResponse getContestants( Page contestants = contestantStore.getContestants(contestJid, pageNumber, PAGE_SIZE); Set userJids = contestants.getPage().stream().map(ContestContestant::getUserJid).collect(Collectors.toSet()); - Map profilesMap = userClient.getProfiles(userJids, contest.getBeginTime()); + Map profilesMap = jophielClient.getProfiles(userJids, contest.getBeginTime()); boolean canManage = contestantRoleChecker.canManage(actorJid, contest); ContestContestantConfig config = new ContestContestantConfig.Builder() @@ -102,7 +102,7 @@ public ApprovedContestContestantsResponse getApprovedContestants( checkAllowed(contestantRoleChecker.canViewApproved(actorJid, contest)); Set userJids = contestantStore.getApprovedContestantJids(contestJid); - Map profilesMap = userClient.getProfiles(userJids, contest.getBeginTime()); + Map profilesMap = jophielClient.getProfiles(userJids, contest.getBeginTime()); return new ApprovedContestContestantsResponse.Builder() .data(userJids) @@ -134,7 +134,7 @@ public void registerMyselfAsContestant( String actorJid = actorChecker.check(authHeader); Contest contest = checkFound(contestStore.getContestByJid(contestJid)); - Profile profile = userClient.getProfile(actorJid); + Profile profile = jophielClient.getProfile(actorJid); checkAllowed(contestantRoleChecker.canRegister(actorJid, profile.getRating(), contest)); contestLogger.log(contestJid, "REGISTER_CONTEST"); @@ -168,7 +168,7 @@ public ContestContestantState getMyContestantState( String actorJid = actorChecker.check(authHeader); Contest contest = checkFound(contestStore.getContestByJid(contestJid)); - Profile profile = userClient.getProfile(actorJid); + Profile profile = jophielClient.getProfile(actorJid); return contestantRoleChecker.getContestantState(actorJid, profile.getRating(), contest); } @@ -189,7 +189,7 @@ public ContestContestantsUpsertResponse upsertContestants( checkArgument(usernames.size() <= 1000, "Cannot add more than 1000 users."); - Map usernameToJidMap = userClient.translateUsernamesToJids(usernames); + Map usernameToJidMap = jophielClient.translateUsernamesToJids(usernames); Set userJids = ImmutableSet.copyOf(usernameToJidMap.values()); Set insertedContestantUsernames = Sets.newHashSet(); @@ -202,7 +202,7 @@ public ContestContestantsUpsertResponse upsertContestants( } }); - Map userJidToProfileMap = userClient.getProfiles(userJids); + Map userJidToProfileMap = jophielClient.getProfiles(userJids); Map insertedContestantProfilesMap = insertedContestantUsernames .stream() .collect(Collectors.toMap(u -> u, u -> userJidToProfileMap.get(usernameToJidMap.get(u)))); @@ -234,7 +234,7 @@ public ContestContestantsDeleteResponse deleteContestants( checkArgument(usernames.size() <= 100, "Cannot remove more than 100 users."); - Map usernameToJidMap = userClient.translateUsernamesToJids(usernames); + Map usernameToJidMap = jophielClient.translateUsernamesToJids(usernames); Set userJids = ImmutableSet.copyOf(usernameToJidMap.values()); Set deletedContestantUsernames = Sets.newHashSet(); @@ -244,7 +244,7 @@ public ContestContestantsDeleteResponse deleteContestants( } }); - Map userJidToProfileMap = userClient.getProfiles(userJids); + Map userJidToProfileMap = jophielClient.getProfiles(userJids); Map deletedContestantProfilesMap = deletedContestantUsernames .stream() .collect(Collectors.toMap(u -> u, u -> userJidToProfileMap.get(usernameToJidMap.get(u)))); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/editorial/ContestEditorialResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/editorial/ContestEditorialResource.java index 5a99c4ed8..3d8c1887b 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/editorial/ContestEditorialResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/editorial/ContestEditorialResource.java @@ -20,12 +20,12 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.UriInfo; +import judgels.jophiel.JophielClient; import judgels.jophiel.api.profile.Profile; -import judgels.jophiel.user.UserClient; +import judgels.sandalphon.SandalphonClient; import judgels.sandalphon.api.problem.ProblemEditorialInfo; import judgels.sandalphon.api.problem.ProblemInfo; import judgels.sandalphon.api.problem.ProblemMetadata; -import judgels.sandalphon.problem.ProblemClient; import judgels.uriel.api.contest.Contest; import judgels.uriel.api.contest.editorial.ContestEditorialResponse; import judgels.uriel.api.contest.module.EditorialModuleConfig; @@ -42,8 +42,8 @@ public class ContestEditorialResource { @Inject protected ContestStore contestStore; @Inject protected ContestModuleStore contestModuleStore; @Inject protected ContestProblemStore problemStore; - @Inject protected UserClient userClient; - @Inject protected ProblemClient problemClient; + @Inject protected JophielClient jophielClient; + @Inject protected SandalphonClient sandalphonClient; @Inject public ContestEditorialResource() {} @@ -63,13 +63,13 @@ public ContestEditorialResponse getEditorial( List problems = problemStore.getProblems(contestJid); Set problemJids = problems.stream().map(ContestProblem::getProblemJid).collect(Collectors.toSet()); - Map problemsMap = problemClient.getProblems(problemJids); - Map problemMetadatasMap = problemClient.getProblemMetadatas(problemJids); - Map problemEditorialsMap = problemClient.getProblemEditorials(problemJids, uriInfo.getBaseUri(), language); + Map problemsMap = sandalphonClient.getProblems(problemJids); + Map problemMetadatasMap = sandalphonClient.getProblemMetadatas(problemJids); + Map problemEditorialsMap = sandalphonClient.getProblemEditorials(problemJids, uriInfo.getBaseUri(), language); Map profilesMap = Maps.newHashMap(); - profilesMap.putAll(userClient.parseProfiles(config.getPreface().orElse(""))); - profilesMap.putAll(userClient.getProfiles(problemMetadatasMap.values() + profilesMap.putAll(jophielClient.parseProfiles(config.getPreface().orElse(""))); + profilesMap.putAll(jophielClient.getProfiles(problemMetadatasMap.values() .stream() .map(ProblemMetadata::getSettersMap) .map(Map::values) diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/history/ContestHistoryResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/history/ContestHistoryResource.java index 4e15af26b..c2f2d3653 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/history/ContestHistoryResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/history/ContestHistoryResource.java @@ -13,9 +13,9 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; +import judgels.jophiel.JophielClient; import judgels.jophiel.api.user.rating.UserRating; import judgels.jophiel.api.user.rating.UserRatingEvent; -import judgels.jophiel.user.UserClient; import judgels.uriel.api.contest.Contest; import judgels.uriel.api.contest.ContestInfo; import judgels.uriel.api.contest.history.ContestHistoryEvent; @@ -27,7 +27,7 @@ public class ContestHistoryResource { @Inject protected ContestStore contestStore; @Inject protected ContestContestantStore contestantStore; - @Inject protected UserClient userClient; + @Inject protected JophielClient jophielClient; @Inject public ContestHistoryResource() {} @@ -36,10 +36,10 @@ public class ContestHistoryResource { @Produces(APPLICATION_JSON) @UnitOfWork(readOnly = true) public ContestHistoryResponse getPublicHistory(@QueryParam("username") String username) { - String userJid = checkFound(userClient.translateUsernameToJid(username)); + String userJid = checkFound(jophielClient.translateUsernameToJid(username)); List contests = contestStore.getPubliclyParticipatedContests(userJid); - Map ratingsMap = userClient.getUserRatingEvents(userJid) + Map ratingsMap = jophielClient.getUserRatingEvents(userJid) .stream() .collect(Collectors.toMap(UserRatingEvent::getEventJid, UserRatingEvent::getRating)); Map ranksMap = contestantStore.getContestantFinalRanks(userJid); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/log/ContestLogResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/log/ContestLogResource.java index 4dd9d4f34..8d512adde 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/log/ContestLogResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/log/ContestLogResource.java @@ -20,8 +20,8 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; +import judgels.jophiel.JophielClient; import judgels.jophiel.api.profile.Profile; -import judgels.jophiel.user.UserClient; import judgels.persistence.api.Page; import judgels.service.actor.ActorChecker; import judgels.service.api.actor.AuthHeader; @@ -47,7 +47,7 @@ public class ContestLogResource { @Inject protected ContestContestantStore contestantStore; @Inject protected ContestSupervisorStore supervisorStore; @Inject protected ContestProblemStore problemStore; - @Inject protected UserClient userClient; + @Inject protected JophielClient jophielClient; @Inject public ContestLogResource() {} @@ -66,7 +66,7 @@ public ContestLogsResponse getLogs( checkAllowed(contestRoleChecker.canManage(actorJid, contest)); - Optional userJid = username.map(u -> userClient.translateUsernameToJid(u).orElse("")); + Optional userJid = username.map(u -> jophielClient.translateUsernameToJid(u).orElse("")); Optional problemJid = problemAlias.map(alias -> problemStore .getProblemByAlias(contestJid, alias) .map(ContestProblem::getProblemJid) @@ -80,7 +80,7 @@ public ContestLogsResponse getLogs( .addAll(supervisorStore.getAllSupervisorJids(contestJid)) .build(); - Map profilesMap = userClient.getProfiles(userJids, contest.getBeginTime()); + Map profilesMap = jophielClient.getProfiles(userJids, contest.getBeginTime()); List userJidsSortedByUsername = Lists.newArrayList(userJids); userJidsSortedByUsername.sort((u1, u2) -> { diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/manager/ContestManagerResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/manager/ContestManagerResource.java index a8094afa2..7141ce747 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/manager/ContestManagerResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/manager/ContestManagerResource.java @@ -22,8 +22,8 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; +import judgels.jophiel.JophielClient; import judgels.jophiel.api.profile.Profile; -import judgels.jophiel.user.UserClient; import judgels.persistence.api.Page; import judgels.service.actor.ActorChecker; import judgels.service.api.actor.AuthHeader; @@ -45,7 +45,7 @@ public class ContestManagerResource { @Inject protected ContestLogger contestLogger; @Inject protected ContestManagerRoleChecker managerRoleChecker; @Inject protected ContestManagerStore managerStore; - @Inject protected UserClient userClient; + @Inject protected JophielClient jophielClient; @Inject public ContestManagerResource() {} @@ -64,7 +64,7 @@ public ContestManagersResponse getManagers( Page managers = managerStore.getManagers(contestJid, pageNumber, PAGE_SIZE); Set userJids = managers.getPage().stream().map(ContestManager::getUserJid).collect(Collectors.toSet()); - Map profilesMap = userClient.getProfiles(userJids, contest.getBeginTime()); + Map profilesMap = jophielClient.getProfiles(userJids, contest.getBeginTime()); boolean canManage = managerRoleChecker.canManage(actorJid); ContestManagerConfig config = new ContestManagerConfig.Builder() .canManage(canManage) @@ -95,7 +95,7 @@ public ContestManagersUpsertResponse upsertManagers( checkArgument(usernames.size() <= 100, "Cannot add more than 100 users."); - Map usernameToJidMap = userClient.translateUsernamesToJids(usernames); + Map usernameToJidMap = jophielClient.translateUsernamesToJids(usernames); Set userJids = ImmutableSet.copyOf(usernameToJidMap.values()); Set insertedManagerUsernames = Sets.newHashSet(); @@ -108,7 +108,7 @@ public ContestManagersUpsertResponse upsertManagers( } }); - Map userJidToProfileMap = userClient.getProfiles(userJids); + Map userJidToProfileMap = jophielClient.getProfiles(userJids); Map insertedManagerProfilesMap = insertedManagerUsernames .stream() .collect(Collectors.toMap(u -> u, u -> userJidToProfileMap.get(usernameToJidMap.get(u)))); @@ -140,7 +140,7 @@ public ContestManagersDeleteResponse deleteManagers( checkArgument(usernames.size() <= 100, "Cannot remove more than 100 users."); - Map usernameToJidMap = userClient.translateUsernamesToJids(usernames); + Map usernameToJidMap = jophielClient.translateUsernamesToJids(usernames); Set userJids = ImmutableSet.copyOf(usernameToJidMap.values()); Set deletedManagerUsernames = Sets.newHashSet(); @@ -150,7 +150,7 @@ public ContestManagersDeleteResponse deleteManagers( } }); - Map userJidToProfileMap = userClient.getProfiles(userJids); + Map userJidToProfileMap = jophielClient.getProfiles(userJids); Map deletedManagerProfilesMap = deletedManagerUsernames .stream() .collect(Collectors.toMap(u -> u, u -> userJidToProfileMap.get(usernameToJidMap.get(u)))); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/module/ContestModuleResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/module/ContestModuleResource.java index a86af4275..fb138554c 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/module/ContestModuleResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/module/ContestModuleResource.java @@ -16,7 +16,7 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; -import judgels.jophiel.user.UserClient; +import judgels.jophiel.JophielClient; import judgels.service.actor.ActorChecker; import judgels.service.api.actor.AuthHeader; import judgels.uriel.api.contest.Contest; @@ -33,7 +33,7 @@ public class ContestModuleResource { @Inject protected ContestStore contestStore; @Inject protected ContestLogger contestLogger; @Inject protected ContestModuleStore moduleStore; - @Inject protected UserClient userClient; + @Inject protected JophielClient jophielClient; @Inject public ContestModuleResource() {} @@ -104,7 +104,7 @@ public ContestModulesConfig getConfig( if (config.getEditorial().isPresent()) { config = new ContestModulesConfig.Builder() .from(config) - .profilesMap(userClient.parseProfiles(config.getEditorial().get().getPreface().orElse(""))) + .profilesMap(jophielClient.parseProfiles(config.getEditorial().get().getPreface().orElse(""))) .build(); } return config; diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/problem/ContestProblemResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/problem/ContestProblemResource.java index 40459b4a0..dbdea6ef1 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/problem/ContestProblemResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/problem/ContestProblemResource.java @@ -26,10 +26,10 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.UriInfo; import judgels.gabriel.api.LanguageRestriction; +import judgels.sandalphon.SandalphonClient; import judgels.sandalphon.api.problem.ProblemInfo; import judgels.sandalphon.api.problem.ProblemType; import judgels.sandalphon.api.problem.programming.ProblemSubmissionConfig; -import judgels.sandalphon.problem.ProblemClient; import judgels.sandalphon.submission.programming.SubmissionStore; import judgels.service.actor.ActorChecker; import judgels.service.api.actor.AuthHeader; @@ -52,7 +52,7 @@ public class ContestProblemResource { @Inject protected ContestProblemStore problemStore; @Inject protected ContestModuleStore moduleStore; @Inject protected SubmissionStore submissionStore; - @Inject protected ProblemClient problemClient; + @Inject protected SandalphonClient sandalphonClient; @Inject public ContestProblemResource() {} @@ -75,7 +75,7 @@ public void setProblems( checkArgument(aliases.size() == data.size(), "Problem aliases must be unique"); checkArgument(slugs.size() == data.size(), "Problem slugs must be unique"); - Map slugToJidMap = problemClient.translateAllowedSlugsToJids(actorJid, slugs); + Map slugToJidMap = sandalphonClient.translateAllowedProblemSlugsToJids(actorJid, slugs); Set notAllowedSlugs = data.stream() .map(ContestProblemData::getSlug) @@ -114,7 +114,7 @@ public ContestProblemsResponse getProblems( List problems = problemStore.getProblems(contestJid); Set problemJids = problems.stream().map(ContestProblem::getProblemJid).collect(Collectors.toSet()); - Map problemsMap = problemClient.getProblems(problemJids); + Map problemsMap = sandalphonClient.getProblems(problemJids); Map totalSubmissionsMap = submissionStore.getTotalSubmissionsMap(contestJid, actorJid, problemJids); @@ -162,7 +162,7 @@ public judgels.uriel.api.contest.problem.programming.ContestProblemWorksheet get ContestProblem problem = checkFound(problemStore.getProblemByAlias(contestJid, problemAlias)); String problemJid = problem.getProblemJid(); - ProblemInfo problemInfo = problemClient.getProblem(problemJid); + ProblemInfo problemInfo = sandalphonClient.getProblem(problemJid); if (problemInfo.getType() != ProblemType.PROGRAMMING) { throw ContestErrors.wrongProblemType(problemInfo.getType()); @@ -174,7 +174,7 @@ public judgels.uriel.api.contest.problem.programming.ContestProblemWorksheet get roleChecker.canSubmit(actorJid, contest, problem, totalSubmissions); judgels.sandalphon.api.problem.programming.ProblemWorksheet worksheet = - problemClient.getProgrammingProblemWorksheet(req, uriInfo, problemJid, language); + sandalphonClient.getProgrammingProblemWorksheet(req, uriInfo, problemJid, language); LanguageRestriction contestGradingLanguageRestriction = moduleStore.getStyleModuleConfig(contestJid, contest.getStyle()).getGradingLanguageRestriction(); @@ -221,7 +221,7 @@ public judgels.uriel.api.contest.problem.bundle.ContestProblemWorksheet getBundl ContestProblem problem = checkFound(problemStore.getProblemByAlias(contestJid, problemAlias)); String problemJid = problem.getProblemJid(); - ProblemInfo problemInfo = problemClient.getProblem(problemJid); + ProblemInfo problemInfo = sandalphonClient.getProblem(problemJid); if (problemInfo.getType() != ProblemType.BUNDLE) { throw ContestErrors.wrongProblemType(problemInfo.getType()); @@ -233,7 +233,7 @@ public judgels.uriel.api.contest.problem.bundle.ContestProblemWorksheet getBundl roleChecker.canSubmit(actorJid, contest, problem, totalSubmissions); judgels.sandalphon.api.problem.bundle.ProblemWorksheet worksheet = - problemClient.getBundleProblemWorksheetWithoutAnswerKey(req, uriInfo, problemJid, language); + sandalphonClient.getBundleProblemWorksheetWithoutAnswerKey(req, uriInfo, problemJid, language); judgels.sandalphon.api.problem.bundle.ProblemWorksheet finalWorksheet = new judgels.sandalphon.api.problem.bundle.ProblemWorksheet.Builder() diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/rating/ContestRatingResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/rating/ContestRatingResource.java index 27e23e1c7..e37542c1e 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/rating/ContestRatingResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/rating/ContestRatingResource.java @@ -21,11 +21,11 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; +import judgels.jophiel.JophielClient; import judgels.jophiel.api.profile.Profile; import judgels.jophiel.api.user.rating.RatingEvent; import judgels.jophiel.api.user.rating.UserRating; import judgels.jophiel.api.user.rating.UserRatingEvent; -import judgels.jophiel.profile.ProfileStore; import judgels.jophiel.user.UserStore; import judgels.jophiel.user.rating.UserRatingStore; import judgels.service.actor.ActorChecker; @@ -54,7 +54,7 @@ public class ContestRatingResource { @Inject protected ContestRatingComputer ratingComputer; @Inject protected UserStore userStore; @Inject protected UserRatingStore userRatingStore; - @Inject protected ProfileStore profileStore; + @Inject protected JophielClient jophielClient; @Inject public ContestRatingResource() {} @@ -119,7 +119,7 @@ private ContestRatingChanges getRatingChanges(Contest contest) { .filter(ScoreboardEntry::hasSubmission) .collect(Collectors.toMap(ScoreboardEntry::getContestantJid, ScoreboardEntry::getRank)); - Map profilesMap = profileStore.getProfiles(ranksMap.keySet(), contest.getBeginTime()); + Map profilesMap = jophielClient.getProfiles(ranksMap.keySet(), contest.getBeginTime()); Map publicRatingsMap = Maps.newHashMap(); Map hiddenRatingsMap = Maps.newHashMap(); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardResource.java index 96661a246..6112e47ba 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardResource.java @@ -19,8 +19,8 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; +import judgels.jophiel.JophielClient; import judgels.jophiel.api.profile.Profile; -import judgels.jophiel.user.UserClient; import judgels.service.actor.ActorChecker; import judgels.service.api.actor.AuthHeader; import judgels.uriel.api.contest.Contest; @@ -43,7 +43,7 @@ public class ContestScoreboardResource { @Inject protected ContestScoreboardFetcher scoreboardFetcher; @Inject protected ContestScoreboardPoller scoreboardUpdaterDispatcher; @Inject protected ScoreboardIncrementalMarker scoreboardIncrementalMarker; - @Inject protected UserClient userClient; + @Inject protected JophielClient jophielClient; @Inject public ContestScoreboardResource() {} @@ -85,7 +85,7 @@ public Optional getScoreboard( Set contestantJids = scoreboard.getScoreboard().getContent().getEntries().stream() .map(ScoreboardEntry::getContestantJid).collect(Collectors.toSet()); Map profilesMap = - userClient.getProfiles(contestantJids, contest.getBeginTime()); + jophielClient.getProfiles(contestantJids, contest.getBeginTime()); return new ContestScoreboardResponse.Builder() .data(scoreboard) diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardUpdater.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardUpdater.java index 1443eba85..8b4d91c99 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardUpdater.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardUpdater.java @@ -17,8 +17,8 @@ import java.util.Map; import java.util.Optional; import java.util.Set; +import judgels.jophiel.JophielClient; import judgels.jophiel.api.profile.Profile; -import judgels.jophiel.user.UserClient; import judgels.sandalphon.api.submission.bundle.ItemSubmission; import judgels.sandalphon.api.submission.programming.Submission; import judgels.sandalphon.submission.bundle.ItemSubmissionStore; @@ -50,7 +50,7 @@ public class ContestScoreboardUpdater { private final ScoreboardIncrementalMarker scoreboardIncrementalMarker; private final ScoreboardProcessorRegistry scoreboardProcessorRegistry; private final ContestScoreboardPusher scoreboardPusher; - private final UserClient userClient; + private final JophielClient jophielClient; public ContestScoreboardUpdater( ObjectMapper objectMapper, @@ -64,7 +64,7 @@ public ContestScoreboardUpdater( ScoreboardIncrementalMarker scoreboardIncrementalMarker, ScoreboardProcessorRegistry scoreboardProcessorRegistry, ContestScoreboardPusher scoreboardPusher, - UserClient userClient) { + JophielClient jophielClient) { this.objectMapper = objectMapper; this.contestTimer = contestTimer; @@ -77,7 +77,7 @@ public ContestScoreboardUpdater( this.scoreboardIncrementalMarker = scoreboardIncrementalMarker; this.scoreboardProcessorRegistry = scoreboardProcessorRegistry; this.scoreboardPusher = scoreboardPusher; - this.userClient = userClient; + this.jophielClient = jophielClient; } @UnitOfWork @@ -114,7 +114,7 @@ public void update(Contest contest) { Set contestants = ImmutableSet.copyOf(contestantsMap.values()); Set contestantJidsSet = contestants.stream().map(ContestContestant::getUserJid).collect(toSet()); - Map profilesMap = userClient.getProfiles(contestantJidsSet, contest.getBeginTime()); + Map profilesMap = jophielClient.getProfiles(contestantJidsSet, contest.getBeginTime()); ScoreboardState state = new ScoreboardState.Builder() .problemJids(problemJids) diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardUpdaterModule.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardUpdaterModule.java index aed1a38bf..ce68f884c 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardUpdaterModule.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardUpdaterModule.java @@ -6,7 +6,7 @@ import io.dropwizard.hibernate.UnitOfWorkAwareProxyFactory; import java.util.concurrent.ExecutorService; import javax.inject.Singleton; -import judgels.jophiel.user.UserClient; +import judgels.jophiel.JophielClient; import judgels.sandalphon.submission.bundle.ItemSubmissionStore; import judgels.sandalphon.submission.programming.SubmissionStore; import judgels.service.JudgelsScheduler; @@ -57,7 +57,7 @@ static ContestScoreboardUpdater contestScoreboardUpdater( ScoreboardIncrementalMarker scoreboardIncrementalMarker, ScoreboardProcessorRegistry scoreboardProcessorRegistry, ContestScoreboardPusher scoreboardPusher, - UserClient userClient) { + JophielClient jophielClient) { return unitOfWorkAwareProxyFactory.create( ContestScoreboardUpdater.class, @@ -73,7 +73,7 @@ static ContestScoreboardUpdater contestScoreboardUpdater( ScoreboardIncrementalMarker.class, ScoreboardProcessorRegistry.class, ContestScoreboardPusher.class, - UserClient.class}, + JophielClient.class}, new Object[] { objectMapper, contestTimer, @@ -86,6 +86,6 @@ static ContestScoreboardUpdater contestScoreboardUpdater( scoreboardIncrementalMarker, scoreboardProcessorRegistry, scoreboardPusher, - userClient}); + jophielClient}); } } diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/submission/bundle/ContestItemSubmissionResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/submission/bundle/ContestItemSubmissionResource.java index d6b79eb7b..92e20ff6e 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/submission/bundle/ContestItemSubmissionResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/submission/bundle/ContestItemSubmissionResource.java @@ -28,9 +28,10 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; +import judgels.jophiel.JophielClient; import judgels.jophiel.api.profile.Profile; -import judgels.jophiel.user.UserClient; import judgels.persistence.api.Page; +import judgels.sandalphon.SandalphonClient; import judgels.sandalphon.api.problem.ProblemType; import judgels.sandalphon.api.problem.bundle.Item; import judgels.sandalphon.api.problem.bundle.ItemType; @@ -38,7 +39,6 @@ import judgels.sandalphon.api.submission.bundle.Grading; import judgels.sandalphon.api.submission.bundle.ItemSubmission; import judgels.sandalphon.api.submission.bundle.ItemSubmissionData; -import judgels.sandalphon.problem.ProblemClient; import judgels.sandalphon.submission.bundle.ItemSubmissionGraderRegistry; import judgels.sandalphon.submission.bundle.ItemSubmissionRegrader; import judgels.sandalphon.submission.bundle.ItemSubmissionStore; @@ -76,8 +76,8 @@ public class ContestItemSubmissionResource { @Inject protected ContestProblemStore problemStore; @Inject protected ItemSubmissionGraderRegistry itemSubmissionGraderRegistry; @Inject protected ItemSubmissionRegrader itemSubmissionRegrader; - @Inject protected UserClient userClient; - @Inject protected ProblemClient problemClient; + @Inject protected JophielClient jophielClient; + @Inject protected SandalphonClient sandalphonClient; @Inject public ContestItemSubmissionResource() {} @@ -131,7 +131,7 @@ public ContestItemSubmissionsResponse getSubmissions( .collect(Collectors.toSet()); } - Map profilesMap = userClient.getProfiles(userJids, contest.getBeginTime()); + Map profilesMap = jophielClient.getProfiles(userJids, contest.getBeginTime()); userJidsSortedByUsername.sort((u1, u2) -> { String usernameA = profilesMap.containsKey(u1) ? profilesMap.get(u1).getUsername() : u1; @@ -152,7 +152,7 @@ public ContestItemSubmissionsResponse getSubmissions( .map(ItemSubmission::getItemJid) .collect(Collectors.toSet()); - Map itemsMap = problemClient.getItems(problemJids, itemJids); + Map itemsMap = sandalphonClient.getItems(problemJids, itemJids); Map itemNumbersMap = itemsMap.entrySet().stream() .collect(Collectors.toMap( Map.Entry::getKey, @@ -186,7 +186,7 @@ public void createItemSubmission( ContestProblem problem = checkFound(problemStore.getProblem(data.getContainerJid(), data.getProblemJid())); checkAllowed(problemRoleChecker.canSubmit(actorJid, contest, problem, 0)); - Optional item = problemClient.getItem(data.getProblemJid(), data.getItemJid()); + Optional item = sandalphonClient.getItem(data.getProblemJid(), data.getItemJid()); checkFound(item); if (data.getAnswer().trim().isEmpty()) { @@ -280,7 +280,7 @@ public ContestSubmissionSummaryResponse getSubmissionSummary( .collect(Collectors.toMap(ItemSubmission::getItemJid, Function.identity())); List bundleProblemJidsSortedByAlias = problemStore.getProblemJids(contestJid).stream() - .filter(problemJid -> problemClient.getProblem(problemJid).getType().equals(ProblemType.BUNDLE)) + .filter(problemJid -> sandalphonClient.getProblem(problemJid).getType().equals(ProblemType.BUNDLE)) .collect(Collectors.toList()); Map problemAliasesByProblemJid = problemStore.getProblemAliasesByJids( contestJid, ImmutableSet.copyOf(bundleProblemJidsSortedByAlias)); @@ -288,7 +288,7 @@ public ContestSubmissionSummaryResponse getSubmissionSummary( Map> itemJidsByProblemJid = new HashMap<>(); Map itemTypesByItemJid = new HashMap<>(); for (String problemJid : bundleProblemJidsSortedByAlias) { - ProblemWorksheet worksheet = problemClient.getBundleProblemWorksheet(null, null, problemJid, language); + ProblemWorksheet worksheet = sandalphonClient.getBundleProblemWorksheet(null, null, problemJid, language); List items = worksheet.getItems().stream() .filter(item -> !item.getType().equals(ItemType.STATEMENT)) .collect(Collectors.toList()); @@ -302,10 +302,10 @@ public ContestSubmissionSummaryResponse getSubmissionSummary( ); } - Map problemNamesByProblemJid = problemClient.getProblemNames( + Map problemNamesByProblemJid = sandalphonClient.getProblemNames( ImmutableSet.copyOf(bundleProblemJidsSortedByAlias), language); - Profile profile = userClient.getProfile(userJid, contest.getBeginTime()); + Profile profile = jophielClient.getProfile(userJid, contest.getBeginTime()); ContestSubmissionConfig config = new ContestSubmissionConfig.Builder() .canSupervise(canSupervise) @@ -365,7 +365,7 @@ public void regradeSubmissions( } private Optional byUserJid(Optional username) { - return username.map(u -> userClient.translateUsernameToJid(u).orElse("")); + return username.map(u -> jophielClient.translateUsernameToJid(u).orElse("")); } private Optional byProblemJid( diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/submission/programming/ContestSubmissionResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/submission/programming/ContestSubmissionResource.java index d0ec4de66..509111af1 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/submission/programming/ContestSubmissionResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/submission/programming/ContestSubmissionResource.java @@ -35,9 +35,10 @@ import javax.ws.rs.core.StreamingOutput; import judgels.gabriel.api.LanguageRestriction; import judgels.gabriel.api.SubmissionSource; +import judgels.jophiel.JophielClient; import judgels.jophiel.api.profile.Profile; -import judgels.jophiel.user.UserClient; import judgels.persistence.api.Page; +import judgels.sandalphon.SandalphonClient; import judgels.sandalphon.SandalphonUtils; import judgels.sandalphon.api.problem.ProblemInfo; import judgels.sandalphon.api.problem.programming.ProblemSubmissionConfig; @@ -46,7 +47,6 @@ import judgels.sandalphon.api.submission.programming.SubmissionInfo; import judgels.sandalphon.api.submission.programming.SubmissionWithSource; import judgels.sandalphon.api.submission.programming.SubmissionWithSourceResponse; -import judgels.sandalphon.problem.ProblemClient; import judgels.sandalphon.submission.programming.SubmissionClient; import judgels.sandalphon.submission.programming.SubmissionDownloader; import judgels.sandalphon.submission.programming.SubmissionRegrader; @@ -92,8 +92,8 @@ public class ContestSubmissionResource { @Inject protected ContestContestantStore contestantStore; @Inject protected ContestSupervisorStore supervisorStore; @Inject protected ContestProblemStore problemStore; - @Inject protected UserClient userClient; - @Inject protected ProblemClient problemClient; + @Inject protected JophielClient jophielClient; + @Inject protected SandalphonClient sandalphonClient; @Inject public ContestSubmissionResource() {} @@ -143,7 +143,7 @@ public ContestSubmissionsResponse getSubmissions( .collect(toSet()); } - Map profilesMap = userClient.getProfiles(userJids, contest.getBeginTime()); + Map profilesMap = jophielClient.getProfiles(userJids, contest.getBeginTime()); userJidsSortedByUsername.sort((u1, u2) -> { String usernameA = profilesMap.containsKey(u1) ? profilesMap.get(u1).getUsername() : u1; @@ -184,10 +184,10 @@ public SubmissionWithSourceResponse getSubmissionWithSourceById( ContestProblem contestProblem = checkFound(problemStore.getProblem(contest.getJid(), submission.getProblemJid())); - ProblemInfo problem = problemClient.getProblem(contestProblem.getProblemJid()); + ProblemInfo problem = sandalphonClient.getProblem(contestProblem.getProblemJid()); String userJid = submission.getUserJid(); - Profile profile = checkFound(Optional.ofNullable(userClient.getProfile(userJid, contest.getBeginTime()))); + Profile profile = checkFound(Optional.ofNullable(jophielClient.getProfile(userJid, contest.getBeginTime()))); SubmissionSource source = submissionSourceBuilder.fromPastSubmission(submission.getJid(), true); SubmissionWithSource submissionWithSource = new SubmissionWithSource.Builder() @@ -218,7 +218,7 @@ public SubmissionInfo getSubmissionInfo( Submission submission = checkFound(submissionStore .getLatestSubmission(Optional.of(contestJid), Optional.of(userJid), Optional.of(problemJid))); - Profile profile = this.userClient.getProfile(userJid); + Profile profile = this.jophielClient.getProfile(userJid); return new SubmissionInfo.Builder().id(submission.getId()).profile(profile).build(); } @@ -288,7 +288,7 @@ public void createSubmission( .additionalGradingLanguageRestriction(contestGradingLanguageRestriction) .build(); SubmissionSource source = submissionSourceBuilder.fromNewSubmission(parts); - ProblemSubmissionConfig config = problemClient.getProgrammingProblemSubmissionConfig(data.getProblemJid()); + ProblemSubmissionConfig config = sandalphonClient.getProgrammingProblemSubmissionConfig(data.getProblemJid()); Submission submission = submissionClient.submit(data, source, config); submissionSourceBuilder.storeSubmissionSource(submission.getJid(), source); @@ -308,7 +308,7 @@ public void regradeSubmission( Contest contest = checkFound(contestStore.getContestByJid(submission.getContainerJid())); checkAllowed(submissionRoleChecker.canManage(actorJid, contest)); - ProblemSubmissionConfig config = problemClient.getProgrammingProblemSubmissionConfig(submission.getProblemJid()); + ProblemSubmissionConfig config = sandalphonClient.getProgrammingProblemSubmissionConfig(submission.getProblemJid()); submissionRegrader.regradeSubmission(submission, config); scoreboardIncrementalMarker.invalidateMark(contest.getJid()); @@ -344,7 +344,7 @@ public void regradeSubmissions( } Set problemJids = submissions.stream().map(Submission::getProblemJid).collect(toSet()); - Map configsMap = problemClient.getProgrammingProblemSubmissionConfigs(problemJids); + Map configsMap = sandalphonClient.getProgrammingProblemSubmissionConfigs(problemJids); submissionRegrader.regradeSubmissions(submissions, configsMap); } scoreboardIncrementalMarker.invalidateMark(contest.getJid()); @@ -401,7 +401,7 @@ public Response downloadSubmissions( } Set userJids = contestantStore.getApprovedContestantJids(contestJid); - Map usernamesMap = userClient.getProfiles(userJids).entrySet() + Map usernamesMap = jophielClient.getProfiles(userJids).entrySet() .stream() .collect(toMap(e -> e.getKey(), e -> e.getValue().getUsername())); @@ -419,7 +419,7 @@ public Response downloadSubmissions( } private Optional byUserJid(Optional username) { - return username.map(u -> userClient.translateUsernameToJid(u).orElse("")); + return username.map(u -> jophielClient.translateUsernameToJid(u).orElse("")); } private Optional byProblemJid( diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/supervisor/ContestSupervisorResource.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/supervisor/ContestSupervisorResource.java index 60394917d..5894aee71 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/supervisor/ContestSupervisorResource.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/supervisor/ContestSupervisorResource.java @@ -22,8 +22,8 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; +import judgels.jophiel.JophielClient; import judgels.jophiel.api.profile.Profile; -import judgels.jophiel.user.UserClient; import judgels.persistence.api.Page; import judgels.service.actor.ActorChecker; import judgels.service.api.actor.AuthHeader; @@ -46,7 +46,7 @@ public class ContestSupervisorResource { @Inject protected ContestLogger contestLogger; @Inject protected ContestRoleChecker roleChecker; @Inject protected ContestSupervisorStore supervisorStore; - @Inject protected UserClient userClient; + @Inject protected JophielClient jophielClient; @Inject public ContestSupervisorResource() {} @@ -65,7 +65,7 @@ public ContestSupervisorsResponse getSupervisors( Page supervisors = supervisorStore.getSupervisors(contestJid, pageNumber, PAGE_SIZE); Set userJids = supervisors.getPage().stream().map(ContestSupervisor::getUserJid).collect(Collectors.toSet()); - Map profilesMap = userClient.getProfiles(userJids, contest.getBeginTime()); + Map profilesMap = jophielClient.getProfiles(userJids, contest.getBeginTime()); contestLogger.log(contestJid, "OPEN_SUPERVISORS"); @@ -91,7 +91,7 @@ public ContestSupervisorsUpsertResponse upsertSupervisors( checkArgument(data.getUsernames().size() <= 100, "Cannot add more than 100 users."); - Map usernameToJidMap = userClient.translateUsernamesToJids(data.getUsernames()); + Map usernameToJidMap = jophielClient.translateUsernamesToJids(data.getUsernames()); Set userJids = ImmutableSet.copyOf(usernameToJidMap.values()); Set upsertedSupervisorUsernames = Sets.newHashSet(); @@ -100,7 +100,7 @@ public ContestSupervisorsUpsertResponse upsertSupervisors( upsertedSupervisorUsernames.add(username); }); - Map userJidToProfileMap = userClient.getProfiles(userJids); + Map userJidToProfileMap = jophielClient.getProfiles(userJids); Map upsertedSupervisorProfilesMap = upsertedSupervisorUsernames .stream() .collect(Collectors.toMap(u -> u, u -> userJidToProfileMap.get(usernameToJidMap.get(u)))); @@ -128,7 +128,7 @@ public ContestSupervisorsDeleteResponse deleteSupervisors( checkArgument(usernames.size() <= 100, "Cannot remove more than 100 users."); - Map usernameToJidMap = userClient.translateUsernamesToJids(usernames); + Map usernameToJidMap = jophielClient.translateUsernamesToJids(usernames); Set userJids = ImmutableSet.copyOf(usernameToJidMap.values()); Set deletedSupervisorUsernames = Sets.newHashSet(); @@ -138,7 +138,7 @@ public ContestSupervisorsDeleteResponse deleteSupervisors( } }); - Map userJidToProfileMap = userClient.getProfiles(userJids); + Map userJidToProfileMap = jophielClient.getProfiles(userJids); Map deletedSupervisorProfilesMap = deletedSupervisorUsernames .stream() .collect(Collectors.toMap(u -> u, u -> userJidToProfileMap.get(usernameToJidMap.get(u)))); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/UrielSubmissionStore.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/submission/UrielSubmissionStore.java similarity index 84% rename from judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/UrielSubmissionStore.java rename to judgels-backends/judgels-server-app/src/main/java/judgels/uriel/submission/UrielSubmissionStore.java index ba4f33dcc..f7e2015f4 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/jerahmeel/submission/UrielSubmissionStore.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/submission/UrielSubmissionStore.java @@ -1,4 +1,4 @@ -package judgels.jerahmeel.submission; +package judgels.uriel.submission; import static java.lang.annotation.RetentionPolicy.RUNTIME; diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/submission/bundle/ItemSubmissionModule.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/submission/bundle/ItemSubmissionModule.java index 92a39e35d..abb4c6048 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/submission/bundle/ItemSubmissionModule.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/submission/bundle/ItemSubmissionModule.java @@ -5,7 +5,7 @@ import io.dropwizard.hibernate.UnitOfWorkAwareProxyFactory; import java.util.concurrent.ExecutorService; import javax.inject.Singleton; -import judgels.sandalphon.problem.ProblemClient; +import judgels.sandalphon.SandalphonClient; import judgels.sandalphon.submission.bundle.ItemSubmissionGraderRegistry; import judgels.sandalphon.submission.bundle.ItemSubmissionRegradeProcessor; import judgels.sandalphon.submission.bundle.ItemSubmissionRegrader; @@ -33,19 +33,19 @@ static ItemSubmissionRegradeProcessor itemSubmissionRegradeProcessor( UnitOfWorkAwareProxyFactory unitOfWorkAwareProxyFactory, ItemSubmissionGraderRegistry itemSubmissionGraderRegistry, ItemSubmissionStore itemSubmissionStore, - ProblemClient problemClient) { + SandalphonClient sandalphonClient) { return unitOfWorkAwareProxyFactory.create( ItemSubmissionRegradeProcessor.class, new Class[] { ItemSubmissionGraderRegistry.class, ItemSubmissionStore.class, - ProblemClient.class + SandalphonClient.class }, new Object[] { itemSubmissionGraderRegistry, itemSubmissionStore, - problemClient + sandalphonClient } ); }