From 5aaafb66dd97f4fe6901272fe63e3861bd4d0049 Mon Sep 17 00:00:00 2001 From: Ashar Fuadi Date: Thu, 5 Sep 2024 21:39:35 +0700 Subject: [PATCH] Implement contest-dump admin task (#661) --- .../judgels/JudgelsServerApplication.java | 2 + .../hibernate/UnmodifiableHibernateDao.java | 39 ++++++++ ...bstractProgrammingGradingHibernateDao.java | 29 ++++++ ...ractProgrammingSubmissionHibernateDao.java | 36 +++++++ .../BaseProgrammingGradingDao.java | 2 + .../BaseProgrammingSubmissionDao.java | 3 +- .../java/judgels/uriel/UrielComponent.java | 8 +- .../uriel/contest/dump/ContestDumpModule.java | 70 +++++++++++++ .../uriel/contest/dump/ContestDumpTask.java | 97 +++++++++++++++++++ .../uriel/contest/log/ContestLogStore.java | 2 +- .../ContestAnnouncementHibernateDao.java | 32 ++++++ .../ContestClarificationHibernateDao.java | 34 +++++++ .../ContestContestantHibernateDao.java | 32 ++++++ .../uriel/hibernate/ContestHibernateDao.java | 25 +++++ .../hibernate/ContestLogHibernateDao.java | 29 ++++++ .../hibernate/ContestManagerHibernateDao.java | 28 ++++++ .../hibernate/ContestModuleHibernateDao.java | 31 ++++++ .../hibernate/ContestProblemHibernateDao.java | 32 ++++++ .../ContestScoreboardHibernateDao.java | 37 +++++++ .../ContestSupervisorHibernateDao.java | 30 ++++++ .../persistence/ContestAnnouncementDao.java | 2 + .../persistence/ContestClarificationDao.java | 2 + .../persistence/ContestContestantDao.java | 2 + .../judgels/uriel/persistence/ContestDao.java | 2 + .../uriel/persistence/ContestLogDao.java | 2 + .../uriel/persistence/ContestManagerDao.java | 2 + .../uriel/persistence/ContestModuleDao.java | 2 + .../uriel/persistence/ContestProblemDao.java | 2 + .../persistence/ContestScoreboardDao.java | 4 + .../persistence/ContestSupervisorDao.java | 2 + 30 files changed, 617 insertions(+), 3 deletions(-) create mode 100644 judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/dump/ContestDumpModule.java create mode 100644 judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/dump/ContestDumpTask.java diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/JudgelsServerApplication.java b/judgels-backends/judgels-server-app/src/main/java/judgels/JudgelsServerApplication.java index 446d8930a..250cd0443 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/JudgelsServerApplication.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/JudgelsServerApplication.java @@ -228,6 +228,8 @@ private void runUriel(JudgelsServerApplicationConfiguration config, Environment "uriel-grading-response-poller", component.gradingResponsePoller()); } + + env.admin().addTask(component.contestDumpTask()); } private void runJerahmeel(JudgelsServerApplicationConfiguration config, Environment env) { diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/persistence/hibernate/UnmodifiableHibernateDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/persistence/hibernate/UnmodifiableHibernateDao.java index bccab11ef..0fde8204f 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/persistence/hibernate/UnmodifiableHibernateDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/persistence/hibernate/UnmodifiableHibernateDao.java @@ -4,6 +4,7 @@ import io.dropwizard.hibernate.AbstractDAO; import java.time.Clock; +import java.time.Instant; import java.util.Collection; import java.util.Optional; import javax.persistence.metamodel.SingularAttribute; @@ -76,4 +77,42 @@ protected static CriteriaPredicate columnIn(SingularAttribute root.get(column).in(values); } + + protected static String escape(String val) { + if (val == null) { + return "NULL"; + } + return "'" + val + .replace("\\", "\\\\") + .replace("'", "\\'") + .replace("\"", "\\\"") + .replace("\t", "\\t") + .replace("\r", "\\r") + .replace("\n", "\\n") + + "'"; + } + + protected static String escape(Integer val) { + if (val == null) { + return "NULL"; + } + return "" + val; + } + + protected static String escape(long val) { + return "" + val; + } + + protected static String escape(boolean val) { + return "b'" + (val ? '1' : '0') + "'"; + } + + protected static String escape(Instant val) { + if (val == null) { + return "NULL"; + } + + String valString = val.toString().replace("T", " ").replace("Z", ""); + return "'" + valString + "'"; + } } diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/hibernate/AbstractProgrammingGradingHibernateDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/hibernate/AbstractProgrammingGradingHibernateDao.java index 64491b54c..3af54dcd8 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/hibernate/AbstractProgrammingGradingHibernateDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/hibernate/AbstractProgrammingGradingHibernateDao.java @@ -2,6 +2,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; +import java.io.PrintWriter; import java.util.Collection; import java.util.List; import java.util.Map; @@ -88,4 +89,32 @@ public Map selectAllLatestWithDetailsBySubmissionJids(Collection submissionJids) { + List results = select().where(columnIn(AbstractProgrammingGradingModel_.submissionJid, submissionJids)).orderBy(Model_.ID, OrderDir.ASC).all(); + if (results.isEmpty()) { + return; + } + + output.write("INSERT IGNORE INTO uriel_contest_programming_grading (jid, submissionJid, verdictCode, verdictName, score, details, createdBy, createdAt, updatedAt) VALUES\n"); + + for (int i = 0; i < results.size(); i++) { + M m = results.get(i); + if (i > 0) { + output.write(",\n"); + } + output.write(String.format("(%s, %s, %s, %s, %s, %s, %s, %s, %s)", + escape(m.jid), + escape(m.submissionJid), + escape(m.verdictCode), + escape(""), + escape(m.score), + escape(m.details), + escape(m.createdBy), + escape(m.createdAt), + escape(m.updatedAt))); + } + output.write(";\n"); + } } diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/hibernate/AbstractProgrammingSubmissionHibernateDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/hibernate/AbstractProgrammingSubmissionHibernateDao.java index 6e2799ca5..d57c0027b 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/hibernate/AbstractProgrammingSubmissionHibernateDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/hibernate/AbstractProgrammingSubmissionHibernateDao.java @@ -1,7 +1,10 @@ package judgels.sandalphon.hibernate; +import java.io.PrintWriter; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.stream.Collectors; import javax.persistence.Tuple; @@ -9,7 +12,9 @@ import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; import judgels.persistence.JudgelsModel_; +import judgels.persistence.Model_; import judgels.persistence.UnmodifiableModel_; +import judgels.persistence.api.OrderDir; import judgels.persistence.hibernate.HibernateDaoData; import judgels.persistence.hibernate.HibernateQueryBuilder; import judgels.persistence.hibernate.JudgelsHibernateDao; @@ -57,6 +62,37 @@ public Map selectCounts(String containerJid, String userJid, Colle .collect(Collectors.toMap(tuple -> tuple.get(0, String.class), tuple -> tuple.get(1, Long.class))); } + @Override + public Collection dump(PrintWriter output, String containerJid) { + List results = select().whereContainerIs(containerJid).orderBy(Model_.ID, OrderDir.ASC).all(); + if (results.isEmpty()) { + return List.of(); + } + + output.write("INSERT IGNORE INTO uriel_contest_programming_submission (jid, problemJid, containerJid, gradingEngine, gradingLanguage, createdBy, createdAt, updatedBy, updatedAt) VALUES\n"); + + List submissionJids = new ArrayList<>(); + for (int i = 0; i < results.size(); i++) { + M m = results.get(i); + if (i > 0) { + output.write(",\n"); + } + output.write(String.format("(%s, %s, %s, %s, %s, %s, %s, %s, %s)", + escape(m.jid), + escape(m.problemJid), + escape(m.containerJid), + escape(m.gradingEngine), + escape(m.gradingLanguage), + escape(m.createdBy), + escape(m.createdAt), + escape(m.updatedBy), + escape(m.updatedAt))); + submissionJids.add(m.jid); + } + output.write(";\n"); + return submissionJids; + } + private static class AbstractProgrammingSubmissionHibernateQueryBuilder extends HibernateQueryBuilder implements BaseProgrammingSubmissionQueryBuilder { AbstractProgrammingSubmissionHibernateQueryBuilder(Session currentSession, Class entityClass) { super(currentSession, entityClass); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/persistence/BaseProgrammingGradingDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/persistence/BaseProgrammingGradingDao.java index b8d8170c2..0b109f1ad 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/persistence/BaseProgrammingGradingDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/persistence/BaseProgrammingGradingDao.java @@ -1,5 +1,6 @@ package judgels.sandalphon.persistence; +import java.io.PrintWriter; import java.util.Collection; import java.util.Map; import java.util.Optional; @@ -11,4 +12,5 @@ public interface BaseProgrammingGradingDao selectLatestBySubmissionJid(String submissionJid); Map selectAllLatestBySubmissionJids(Collection submissionJids); Map selectAllLatestWithDetailsBySubmissionJids(Collection submissionJids); + void dump(PrintWriter output, Collection submissionJids); } diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/persistence/BaseProgrammingSubmissionDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/persistence/BaseProgrammingSubmissionDao.java index ec9a688c4..5c15cd5f1 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/persistence/BaseProgrammingSubmissionDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/persistence/BaseProgrammingSubmissionDao.java @@ -1,5 +1,6 @@ package judgels.sandalphon.persistence; +import java.io.PrintWriter; import java.util.Collection; import java.util.Map; import judgels.persistence.JudgelsDao; @@ -7,9 +8,9 @@ public interface BaseProgrammingSubmissionDao extends JudgelsDao { M createSubmissionModel(); - BaseProgrammingSubmissionQueryBuilder select(); Map selectCounts(String containerJid, String userJid, Collection problemJids); + Collection dump(PrintWriter output, String containerJid); interface BaseProgrammingSubmissionQueryBuilder extends QueryBuilder { BaseProgrammingSubmissionQueryBuilder whereContainerIs(String containerJid); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/UrielComponent.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/UrielComponent.java index 496c5f1a2..3be9797f4 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/UrielComponent.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/UrielComponent.java @@ -19,6 +19,8 @@ import judgels.uriel.contest.announcement.ContestAnnouncementResource; import judgels.uriel.contest.clarification.ContestClarificationResource; import judgels.uriel.contest.contestant.ContestContestantResource; +import judgels.uriel.contest.dump.ContestDumpModule; +import judgels.uriel.contest.dump.ContestDumpTask; import judgels.uriel.contest.editorial.ContestEditorialResource; import judgels.uriel.contest.file.ContestFileResource; import judgels.uriel.contest.history.ContestHistoryResource; @@ -65,7 +67,9 @@ SubmissionModule.class, ItemSubmissionModule.class, ContestLogModule.class, - ContestScoreboardUpdaterModule.class}) + ContestScoreboardUpdaterModule.class, + + ContestDumpModule.class}) @Singleton public interface UrielComponent { ContestAnnouncementResource contestAnnouncementResource(); @@ -90,4 +94,6 @@ public interface UrielComponent { ContestLogPoller contestLogPoller(); ContestScoreboardPoller contestScoreboardPoller(); GradingResponsePoller gradingResponsePoller(); + + ContestDumpTask contestDumpTask(); } diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/dump/ContestDumpModule.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/dump/ContestDumpModule.java new file mode 100644 index 000000000..48dda5541 --- /dev/null +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/dump/ContestDumpModule.java @@ -0,0 +1,70 @@ +package judgels.uriel.contest.dump; + +import dagger.Module; +import dagger.Provides; +import io.dropwizard.hibernate.UnitOfWorkAwareProxyFactory; +import javax.inject.Singleton; +import judgels.uriel.persistence.ContestAnnouncementDao; +import judgels.uriel.persistence.ContestClarificationDao; +import judgels.uriel.persistence.ContestContestantDao; +import judgels.uriel.persistence.ContestDao; +import judgels.uriel.persistence.ContestLogDao; +import judgels.uriel.persistence.ContestManagerDao; +import judgels.uriel.persistence.ContestModuleDao; +import judgels.uriel.persistence.ContestProblemDao; +import judgels.uriel.persistence.ContestProgrammingGradingDao; +import judgels.uriel.persistence.ContestProgrammingSubmissionDao; +import judgels.uriel.persistence.ContestScoreboardDao; +import judgels.uriel.persistence.ContestSupervisorDao; + +@Module +public class ContestDumpModule { + private ContestDumpModule() {} + + @Provides + @Singleton + static ContestDumpTask contestDumpTask( + UnitOfWorkAwareProxyFactory unitOfWorkAwareProxyFactory, + ContestDao contestDao, + ContestModuleDao moduleDao, + ContestManagerDao managerDao, + ContestSupervisorDao supervisorDao, + ContestContestantDao contestantDao, + ContestProblemDao problemDao, + ContestAnnouncementDao announcementDao, + ContestClarificationDao clarificationDao, + ContestScoreboardDao scoreboardDao, + ContestLogDao logDao, + ContestProgrammingSubmissionDao programmingSubmissionDao, + ContestProgrammingGradingDao programmingGradingDao) { + + return unitOfWorkAwareProxyFactory.create( + ContestDumpTask.class, + new Class[] { + ContestDao.class, + ContestModuleDao.class, + ContestManagerDao.class, + ContestSupervisorDao.class, + ContestContestantDao.class, + ContestProblemDao.class, + ContestAnnouncementDao.class, + ContestClarificationDao.class, + ContestScoreboardDao.class, + ContestLogDao.class, + ContestProgrammingSubmissionDao.class, + ContestProgrammingGradingDao.class}, + new Object[] { + contestDao, + moduleDao, + managerDao, + supervisorDao, + contestantDao, + problemDao, + announcementDao, + clarificationDao, + scoreboardDao, + logDao, + programmingSubmissionDao, + programmingGradingDao}); + } +} diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/dump/ContestDumpTask.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/dump/ContestDumpTask.java new file mode 100644 index 000000000..f4b65cb81 --- /dev/null +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/dump/ContestDumpTask.java @@ -0,0 +1,97 @@ +package judgels.uriel.contest.dump; + +import io.dropwizard.hibernate.UnitOfWork; +import io.dropwizard.servlets.tasks.Task; +import java.io.PrintWriter; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import judgels.uriel.persistence.ContestAnnouncementDao; +import judgels.uriel.persistence.ContestClarificationDao; +import judgels.uriel.persistence.ContestContestantDao; +import judgels.uriel.persistence.ContestDao; +import judgels.uriel.persistence.ContestLogDao; +import judgels.uriel.persistence.ContestManagerDao; +import judgels.uriel.persistence.ContestModel; +import judgels.uriel.persistence.ContestModuleDao; +import judgels.uriel.persistence.ContestProblemDao; +import judgels.uriel.persistence.ContestProgrammingGradingDao; +import judgels.uriel.persistence.ContestProgrammingSubmissionDao; +import judgels.uriel.persistence.ContestScoreboardDao; +import judgels.uriel.persistence.ContestSupervisorDao; + +public class ContestDumpTask extends Task { + private final ContestDao contestDao; + private final ContestModuleDao moduleDao; + private final ContestManagerDao managerDao; + private final ContestSupervisorDao supervisorDao; + private final ContestContestantDao contestantDao; + private final ContestProblemDao problemDao; + private final ContestAnnouncementDao announcementDao; + private final ContestClarificationDao clarificationDao; + private final ContestProgrammingSubmissionDao programmingSubmissionDao; + private final ContestProgrammingGradingDao programmingGradingDao; + private final ContestScoreboardDao scoreboardDao; + private final ContestLogDao logDao; + + public ContestDumpTask( + ContestDao contestDao, + ContestModuleDao moduleDao, + ContestManagerDao managerDao, + ContestSupervisorDao supervisorDao, + ContestContestantDao contestantDao, + ContestProblemDao problemDao, + ContestAnnouncementDao announcementDao, + ContestClarificationDao clarificationDao, + ContestScoreboardDao scoreboardDao, + ContestLogDao logDao, + ContestProgrammingSubmissionDao programmingSubmissionDao, + ContestProgrammingGradingDao programmingGradingDao) { + + super("contest-dump"); + + this.contestDao = contestDao; + this.moduleDao = moduleDao; + this.managerDao = managerDao; + this.supervisorDao = supervisorDao; + this.contestantDao = contestantDao; + this.problemDao = problemDao; + this.announcementDao = announcementDao; + this.clarificationDao = clarificationDao; + this.scoreboardDao = scoreboardDao; + this.logDao = logDao; + this.programmingSubmissionDao = programmingSubmissionDao; + this.programmingGradingDao = programmingGradingDao; + } + + @Override + @UnitOfWork(readOnly = true) + public void execute(Map> parameters, PrintWriter output) { + List contestSlugs = parameters.get("contestSlug"); + if (contestSlugs == null || contestSlugs.isEmpty()) { + return; + } + String contestSlug = contestSlugs.get(0); + Optional maybeModel = contestDao.selectBySlug(contestSlug); + if (maybeModel.isEmpty()) { + return; + } + + String contestJid = maybeModel.get().jid; + + contestDao.dump(output, contestJid); + moduleDao.dump(output, contestJid); + managerDao.dump(output, contestJid); + supervisorDao.dump(output, contestJid); + contestantDao.dump(output, contestJid); + problemDao.dump(output, contestJid); + announcementDao.dump(output, contestJid); + clarificationDao.dump(output, contestJid); + scoreboardDao.dump(output, contestJid); + logDao.dump(output, contestJid); + + Collection submissionJids = programmingSubmissionDao.dump(output, contestJid); + programmingGradingDao.dump(output, submissionJids); + } +} diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/log/ContestLogStore.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/log/ContestLogStore.java index 757c5c059..60b32bb38 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/log/ContestLogStore.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/log/ContestLogStore.java @@ -62,7 +62,7 @@ private static ContestLog fromModel(ContestLogModel model) { .problemJid(Optional.ofNullable(model.problemJid)) .userJid(model.createdBy) .time(model.createdAt) - .ipAddress(model.createdIp) + .ipAddress(Optional.ofNullable(model.createdIp)) .build(); } } diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestAnnouncementHibernateDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestAnnouncementHibernateDao.java index 6026366fb..b5e45a519 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestAnnouncementHibernateDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestAnnouncementHibernateDao.java @@ -1,6 +1,10 @@ package judgels.uriel.hibernate; +import java.io.PrintWriter; +import java.util.List; import javax.inject.Inject; +import judgels.persistence.Model_; +import judgels.persistence.api.OrderDir; import judgels.persistence.hibernate.HibernateDaoData; import judgels.persistence.hibernate.HibernateQueryBuilder; import judgels.persistence.hibernate.JudgelsHibernateDao; @@ -20,6 +24,34 @@ public ContestAnnouncementQueryBuilder selectByContestJid(String contestJid) { return new ContestAnnouncementHibernateQueryBuilder(currentSession(), contestJid); } + @Override + public void dump(PrintWriter output, String contestJid) { + List results = selectByContestJid(contestJid).orderBy(Model_.ID, OrderDir.ASC).all(); + if (results.isEmpty()) { + return; + } + + output.write("INSERT IGNORE INTO uriel_contest_announcement (jid, contestJid, title, content, status, createdBy, createdAt, updatedBy, updatedAt) VALUES\n"); + + for (int i = 0; i < results.size(); i++) { + ContestAnnouncementModel m = results.get(i); + if (i > 0) { + output.write(",\n"); + } + output.write(String.format("(%s, %s, %s, %s, %s, %s, %s, %s, %s)", + escape(m.jid), + escape(m.contestJid), + escape(m.title), + escape(m.content), + escape(m.status), + escape(m.createdBy), + escape(m.createdAt), + escape(m.updatedBy), + escape(m.updatedAt))); + } + output.write(";\n"); + } + private static class ContestAnnouncementHibernateQueryBuilder extends HibernateQueryBuilder implements ContestAnnouncementQueryBuilder { ContestAnnouncementHibernateQueryBuilder(Session currentSession, String contestJid) { super(currentSession, ContestAnnouncementModel.class); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestClarificationHibernateDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestClarificationHibernateDao.java index acb8e2685..b356de833 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestClarificationHibernateDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestClarificationHibernateDao.java @@ -1,9 +1,13 @@ package judgels.uriel.hibernate; +import java.io.PrintWriter; +import java.util.List; import java.util.Optional; import javax.inject.Inject; import judgels.persistence.JudgelsModel_; +import judgels.persistence.Model_; import judgels.persistence.UnmodifiableModel_; +import judgels.persistence.api.OrderDir; import judgels.persistence.hibernate.HibernateDaoData; import judgels.persistence.hibernate.HibernateQueryBuilder; import judgels.persistence.hibernate.JudgelsHibernateDao; @@ -30,6 +34,36 @@ public Optional selectByContestJidAndClarificationJid .unique(); } + @Override + public void dump(PrintWriter output, String contestJid) { + List results = selectByContestJid(contestJid).orderBy(Model_.ID, OrderDir.ASC).all(); + if (results.isEmpty()) { + return; + } + + output.write("INSERT IGNORE INTO uriel_contest_clarification (jid, contestJid, topicJid, title, question, answer, status, createdBy, createdAt, updatedBy, updatedAt) VALUES\n"); + + for (int i = 0; i < results.size(); i++) { + ContestClarificationModel m = results.get(i); + if (i > 0) { + output.write(",\n"); + } + output.write(String.format("(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", + escape(m.jid), + escape(m.contestJid), + escape(m.topicJid), + escape(m.title), + escape(m.question), + escape(m.answer), + escape(m.status), + escape(m.createdBy), + escape(m.createdAt), + escape(m.updatedBy), + escape(m.updatedAt))); + } + output.write(";\n"); + } + private static class ContestClarificationHibernateQueryBuilder extends HibernateQueryBuilder implements ContestClarificationQueryBuilder { ContestClarificationHibernateQueryBuilder(Session currentSession, String contestJid) { super(currentSession, ContestClarificationModel.class); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestContestantHibernateDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestContestantHibernateDao.java index f8d80a44f..5badd70ce 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestContestantHibernateDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestContestantHibernateDao.java @@ -2,8 +2,12 @@ import static judgels.uriel.api.contest.contestant.ContestContestantStatus.APPROVED; +import java.io.PrintWriter; +import java.util.List; import java.util.Optional; import javax.inject.Inject; +import judgels.persistence.Model_; +import judgels.persistence.api.OrderDir; import judgels.persistence.hibernate.HibernateDao; import judgels.persistence.hibernate.HibernateDaoData; import judgels.persistence.hibernate.HibernateQueryBuilder; @@ -35,6 +39,34 @@ public Optional selectByContestJidAndUserJid(String cont .unique(); } + @Override + public void dump(PrintWriter output, String contestJid) { + List results = selectByContestJid(contestJid).orderBy(Model_.ID, OrderDir.ASC).all(); + if (results.isEmpty()) { + return; + } + + output.write("INSERT IGNORE INTO uriel_contest_contestant (contestJid, userJid, status, contestStartTime, finalRank, createdBy, createdAt, updatedBy, updatedAt) VALUES\n"); + + for (int i = 0; i < results.size(); i++) { + ContestContestantModel m = results.get(i); + if (i > 0) { + output.write(",\n"); + } + output.write(String.format("(%s, %s, %s, %s, %s, %s, %s, %s, %s)", + escape(m.contestJid), + escape(m.userJid), + escape(m.status), + escape(m.contestStartTime), + escape(m.finalRank), + escape(m.createdBy), + escape(m.createdAt), + escape(m.updatedBy), + escape(m.updatedAt))); + } + output.write(";\n"); + } + private static class ContestContestantHibernateQueryBuilder extends HibernateQueryBuilder implements ContestContestantQueryBuilder { ContestContestantHibernateQueryBuilder(Session currentSession) { super(currentSession, ContestContestantModel.class); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestHibernateDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestHibernateDao.java index b2653d068..137c2bbf4 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestHibernateDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestHibernateDao.java @@ -4,6 +4,7 @@ import static judgels.uriel.hibernate.ContestRoleHibernateDao.userCanView; import static judgels.uriel.hibernate.ContestRoleHibernateDao.userParticipated; +import java.io.PrintWriter; import java.time.Clock; import java.time.Duration; import java.time.Instant; @@ -53,6 +54,30 @@ public List selectAllBySlugs(Collection contestSlugs) { return select().where(columnIn(ContestModel_.slug, contestSlugs)).all(); } + @Override + public void dump(PrintWriter output, String contestJid) { + Optional maybeModel = selectByJid(contestJid); + if (maybeModel.isEmpty()) { + return; + } + + ContestModel m = maybeModel.get(); + + output.write("INSERT IGNORE INTO uriel_contest (jid, slug, name, description, style, beginTime, duration, createdBy, createdAt, updatedBy, updatedAt) VALUES\n"); + output.write(String.format("(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);\n", + escape(m.jid), + escape(m.slug), + escape(m.name), + escape(m.description), + escape(m.style), + escape(m.beginTime), + escape(m.duration), + escape(m.createdBy), + escape(m.createdAt), + escape(m.updatedBy), + escape(m.updatedAt))); + } + private static class ContestHibernateQueryBuilder extends HibernateQueryBuilder implements ContestQueryBuilder { private final Clock clock; diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestLogHibernateDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestLogHibernateDao.java index 7c154662d..2739eb896 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestLogHibernateDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestLogHibernateDao.java @@ -1,7 +1,11 @@ package judgels.uriel.hibernate; +import java.io.PrintWriter; +import java.util.List; import javax.inject.Inject; +import judgels.persistence.Model_; import judgels.persistence.UnmodifiableModel_; +import judgels.persistence.api.OrderDir; import judgels.persistence.hibernate.HibernateDaoData; import judgels.persistence.hibernate.HibernateQueryBuilder; import judgels.persistence.hibernate.UnmodifiableHibernateDao; @@ -21,6 +25,31 @@ public ContestLogQueryBuilder selectByContestJid(String contestJid) { return new ContestLogHibernateQueryBuilder(currentSession(), contestJid); } + @Override + public void dump(PrintWriter output, String contestJid) { + List results = selectByContestJid(contestJid).orderBy(Model_.ID, OrderDir.ASC).all(); + if (results.isEmpty()) { + return; + } + + output.write("INSERT IGNORE INTO uriel_contest_log (contestJid, event, object, problemJid, createdBy, createdAt) VALUES\n"); + + for (int i = 0; i < results.size(); i++) { + ContestLogModel m = results.get(i); + if (i > 0) { + output.write(",\n"); + } + output.write(String.format("(%s, %s, %s, %s, %s, %s)", + escape(m.contestJid), + escape(m.event), + escape(m.object), + escape(m.problemJid), + escape(m.createdBy), + escape(m.createdAt))); + } + output.write(";\n"); + } + private static class ContestLogHibernateQueryBuilder extends HibernateQueryBuilder implements ContestLogQueryBuilder { ContestLogHibernateQueryBuilder(Session currentSession, String contestJid) { super(currentSession, ContestLogModel.class); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestManagerHibernateDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestManagerHibernateDao.java index 7bb8f3d50..c2aef9619 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestManagerHibernateDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestManagerHibernateDao.java @@ -1,8 +1,12 @@ package judgels.uriel.hibernate; +import java.io.PrintWriter; +import java.util.List; import java.util.Optional; import javax.inject.Inject; +import judgels.persistence.Model_; import judgels.persistence.QueryBuilder; +import judgels.persistence.api.OrderDir; import judgels.persistence.hibernate.HibernateDao; import judgels.persistence.hibernate.HibernateDaoData; import judgels.persistence.hibernate.HibernateQueryBuilder; @@ -28,4 +32,28 @@ public Optional selectByContestJidAndUserJid(String contest .where(columnEq(ContestManagerModel_.userJid, userJid)) .unique(); } + + @Override + public void dump(PrintWriter output, String contestJid) { + List results = selectByContestJid(contestJid).orderBy(Model_.ID, OrderDir.ASC).all(); + if (results.isEmpty()) { + return; + } + + output.write("INSERT IGNORE INTO uriel_contest_manager (contestJid, userJid, createdBy, createdAt, updatedAt) VALUES\n"); + + for (int i = 0; i < results.size(); i++) { + ContestManagerModel m = results.get(i); + if (i > 0) { + output.write(",\n"); + } + output.write(String.format("(%s, %s, %s, %s, %s)", + escape(m.contestJid), + escape(m.userJid), + escape(m.createdBy), + escape(m.createdAt), + escape(m.updatedAt))); + } + output.write(";\n"); + } } diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestModuleHibernateDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestModuleHibernateDao.java index 1feccde93..3f81d9ec0 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestModuleHibernateDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestModuleHibernateDao.java @@ -1,7 +1,11 @@ package judgels.uriel.hibernate; +import java.io.PrintWriter; +import java.util.List; import java.util.Optional; import javax.inject.Inject; +import judgels.persistence.Model_; +import judgels.persistence.api.OrderDir; import judgels.persistence.hibernate.HibernateDao; import judgels.persistence.hibernate.HibernateDaoData; import judgels.persistence.hibernate.HibernateQueryBuilder; @@ -37,6 +41,33 @@ public Optional selectEnabledByContestJidAndType(String cont .unique(); } + @Override + public void dump(PrintWriter output, String contestJid) { + List results = selectByContestJid(contestJid).orderBy(Model_.ID, OrderDir.ASC).all(); + if (results.isEmpty()) { + return; + } + + output.write("INSERT IGNORE INTO uriel_contest_module (contestJid, name, config, enabled, createdBy, createdAt, updatedBy, updatedAt) VALUES\n"); + + for (int i = 0; i < results.size(); i++) { + ContestModuleModel m = results.get(i); + if (i > 0) { + output.write(",\n"); + } + output.write(String.format("(%s, %s, %s, %s, %s, %s, %s, %s)", + escape(m.contestJid), + escape(m.name), + escape(m.config), + escape(m.enabled), + escape(m.createdBy), + escape(m.createdAt), + escape(m.updatedBy), + escape(m.updatedAt))); + } + output.write(";\n"); + } + private static class ContestModuleHibernateQueryBuilder extends HibernateQueryBuilder implements ContestModuleQueryBuilder { ContestModuleHibernateQueryBuilder(Session currentSession, String contestJid) { super(currentSession, ContestModuleModel.class); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestProblemHibernateDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestProblemHibernateDao.java index 889443e93..173b62e22 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestProblemHibernateDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestProblemHibernateDao.java @@ -4,8 +4,11 @@ import static judgels.uriel.api.contest.problem.ContestProblemStatus.OPEN; import com.google.common.collect.ImmutableSet; +import java.io.PrintWriter; +import java.util.List; import java.util.Optional; import javax.inject.Inject; +import judgels.persistence.Model_; import judgels.persistence.api.OrderDir; import judgels.persistence.hibernate.HibernateDao; import judgels.persistence.hibernate.HibernateDaoData; @@ -40,6 +43,35 @@ public Optional selectByContestJidAndProblemAlias(String co .unique(); } + @Override + public void dump(PrintWriter output, String contestJid) { + List results = selectByContestJid(contestJid).orderBy(Model_.ID, OrderDir.ASC).all(); + if (results.isEmpty()) { + return; + } + + output.write("INSERT IGNORE INTO uriel_contest_problem (contestJid, problemJid, alias, status, submissionsLimit, points, createdBy, createdAt, updatedBy, updatedAt) VALUES\n"); + + for (int i = 0; i < results.size(); i++) { + ContestProblemModel m = results.get(i); + if (i > 0) { + output.write(",\n"); + } + output.write(String.format("(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", + escape(m.contestJid), + escape(m.problemJid), + escape(m.alias), + escape(m.status), + escape(m.submissionsLimit), + escape(m.points), + escape(m.createdBy), + escape(m.createdAt), + escape(m.updatedBy), + escape(m.updatedAt))); + } + output.write(";\n"); + } + private static class ContestProblemHibernateQueryBuilder extends HibernateQueryBuilder implements ContestProblemQueryBuilder { ContestProblemHibernateQueryBuilder(Session currentSession, String contestJid) { super(currentSession, ContestProblemModel.class); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestScoreboardHibernateDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestScoreboardHibernateDao.java index 7cbe21b24..cad4f0cd7 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestScoreboardHibernateDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestScoreboardHibernateDao.java @@ -1,7 +1,12 @@ package judgels.uriel.hibernate; +import java.io.PrintWriter; +import java.util.List; import java.util.Optional; import javax.inject.Inject; +import judgels.persistence.Model_; +import judgels.persistence.QueryBuilder; +import judgels.persistence.api.OrderDir; import judgels.persistence.hibernate.HibernateDao; import judgels.persistence.hibernate.HibernateDaoData; import judgels.uriel.api.contest.scoreboard.ContestScoreboardType; @@ -15,6 +20,12 @@ public ContestScoreboardHibernateDao(HibernateDaoData data) { super(data); } + @Override + public QueryBuilder selectByContestJid(String contestJid) { + return select() + .where(columnEq(ContestScoreboardModel_.contestJid, contestJid)); + } + @Override public Optional selectByContestJidAndType(String contestJid, ContestScoreboardType type) { return select() @@ -22,4 +33,30 @@ public Optional selectByContestJidAndType(String contest .where(columnEq(ContestScoreboardModel_.type, type.name())) .unique(); } + + @Override + public void dump(PrintWriter output, String contestJid) { + List results = selectByContestJid(contestJid).orderBy(Model_.ID, OrderDir.ASC).all(); + if (results.isEmpty()) { + return; + } + + output.write("INSERT IGNORE INTO uriel_contest_scoreboard (contestJid, type, scoreboard, createdBy, createdAt, updatedBy, updatedAt) VALUES\n"); + + for (int i = 0; i < results.size(); i++) { + ContestScoreboardModel m = results.get(i); + if (i > 0) { + output.write(",\n"); + } + output.write(String.format("(%s, %s, %s, %s, %s, %s, %s)", + escape(m.contestJid), + escape(m.type), + escape(m.scoreboard), + escape(m.createdBy), + escape(m.createdAt), + escape(m.updatedBy), + escape(m.updatedAt))); + } + output.write(";\n"); + } } diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestSupervisorHibernateDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestSupervisorHibernateDao.java index 41ab0ff37..1fc23dc9f 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestSupervisorHibernateDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/hibernate/ContestSupervisorHibernateDao.java @@ -1,8 +1,12 @@ package judgels.uriel.hibernate; +import java.io.PrintWriter; +import java.util.List; import java.util.Optional; import javax.inject.Inject; +import judgels.persistence.Model_; import judgels.persistence.QueryBuilder; +import judgels.persistence.api.OrderDir; import judgels.persistence.hibernate.HibernateDao; import judgels.persistence.hibernate.HibernateDaoData; import judgels.persistence.hibernate.HibernateQueryBuilder; @@ -29,4 +33,30 @@ public Optional selectByContestJidAndUserJid(String cont .where(columnEq(ContestSupervisorModel_.userJid, userJid)) .unique(); } + + @Override + public void dump(PrintWriter output, String contestJid) { + List results = selectByContestJid(contestJid).orderBy(Model_.ID, OrderDir.ASC).all(); + if (results.isEmpty()) { + return; + } + + output.write("INSERT IGNORE INTO uriel_contest_supervisor (contestJid, userJid, permission, createdBy, createdAt, updatedBy, updatedAt) VALUES\n"); + + for (int i = 0; i < results.size(); i++) { + ContestSupervisorModel m = results.get(i); + if (i > 0) { + output.write(",\n"); + } + output.write(String.format("(%s, %s, %s, %s, %s, %s, %s)", + escape(m.contestJid), + escape(m.userJid), + escape(m.permission), + escape(m.createdBy), + escape(m.createdAt), + escape(m.updatedBy), + escape(m.updatedAt))); + } + output.write(";\n"); + } } diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestAnnouncementDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestAnnouncementDao.java index 0838ff5c6..aeb6f8ca8 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestAnnouncementDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestAnnouncementDao.java @@ -1,10 +1,12 @@ package judgels.uriel.persistence; +import java.io.PrintWriter; import judgels.persistence.JudgelsDao; import judgels.persistence.QueryBuilder; public interface ContestAnnouncementDao extends JudgelsDao { ContestAnnouncementQueryBuilder selectByContestJid(String contestJid); + void dump(PrintWriter output, String contestJid); interface ContestAnnouncementQueryBuilder extends QueryBuilder { ContestAnnouncementQueryBuilder whereStatusIs(String status); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestClarificationDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestClarificationDao.java index 870556108..6f34099d0 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestClarificationDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestClarificationDao.java @@ -1,5 +1,6 @@ package judgels.uriel.persistence; +import java.io.PrintWriter; import java.util.Optional; import judgels.persistence.JudgelsDao; import judgels.persistence.QueryBuilder; @@ -7,6 +8,7 @@ public interface ContestClarificationDao extends JudgelsDao { ContestClarificationQueryBuilder selectByContestJid(String contestJid); Optional selectByContestJidAndClarificationJid(String contestJid, String clarificationJid); + void dump(PrintWriter output, String contestJid); interface ContestClarificationQueryBuilder extends QueryBuilder { ContestClarificationQueryBuilder whereUserIsAsker(String userJid); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestContestantDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestContestantDao.java index 23fe02dcd..9067aece4 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestContestantDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestContestantDao.java @@ -1,5 +1,6 @@ package judgels.uriel.persistence; +import java.io.PrintWriter; import java.util.Optional; import judgels.persistence.Dao; import judgels.persistence.QueryBuilder; @@ -8,6 +9,7 @@ public interface ContestContestantDao extends Dao { ContestContestantQueryBuilder select(); ContestContestantQueryBuilder selectByContestJid(String contestJid); Optional selectByContestJidAndUserJid(String contestJid, String userJid); + void dump(PrintWriter output, String contestJid); interface ContestContestantQueryBuilder extends QueryBuilder { ContestContestantQueryBuilder whereUserParticipated(String userJid); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestDao.java index 0f95b27d1..da2af04aa 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestDao.java @@ -1,5 +1,6 @@ package judgels.uriel.persistence; +import java.io.PrintWriter; import java.time.Instant; import java.util.Collection; import java.util.List; @@ -11,6 +12,7 @@ public interface ContestDao extends JudgelsDao { ContestQueryBuilder select(); Optional selectBySlug(String contestSlug); List selectAllBySlugs(Collection contestSlugs); + void dump(PrintWriter output, String contestJid); interface ContestQueryBuilder extends QueryBuilder { ContestQueryBuilder wherePublic(); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestLogDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestLogDao.java index cbca561b2..4ce77b459 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestLogDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestLogDao.java @@ -1,10 +1,12 @@ package judgels.uriel.persistence; +import java.io.PrintWriter; import judgels.persistence.QueryBuilder; import judgels.persistence.UnmodifiableDao; public interface ContestLogDao extends UnmodifiableDao { ContestLogQueryBuilder selectByContestJid(String contestJid); + void dump(PrintWriter output, String contestJid); interface ContestLogQueryBuilder extends QueryBuilder { ContestLogQueryBuilder whereUserIs(String userJid); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestManagerDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestManagerDao.java index 442611cdb..3a4b7bc09 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestManagerDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestManagerDao.java @@ -1,5 +1,6 @@ package judgels.uriel.persistence; +import java.io.PrintWriter; import java.util.Optional; import judgels.persistence.Dao; import judgels.persistence.QueryBuilder; @@ -7,4 +8,5 @@ public interface ContestManagerDao extends Dao { QueryBuilder selectByContestJid(String contestJid); Optional selectByContestJidAndUserJid(String contestJid, String userJid); + void dump(PrintWriter output, String contestJid); } diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestModuleDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestModuleDao.java index 8db1fdf04..cd59e80e3 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestModuleDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestModuleDao.java @@ -1,5 +1,6 @@ package judgels.uriel.persistence; +import java.io.PrintWriter; import java.util.Optional; import judgels.persistence.Dao; import judgels.persistence.QueryBuilder; @@ -9,6 +10,7 @@ public interface ContestModuleDao extends Dao { ContestModuleQueryBuilder selectByContestJid(String contestJid); Optional selectByContestJidAndType(String contestJid, ContestModuleType type); Optional selectEnabledByContestJidAndType(String contestJid, ContestModuleType type); + void dump(PrintWriter output, String contestJid); interface ContestModuleQueryBuilder extends QueryBuilder { ContestModuleQueryBuilder whereEnabled(); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestProblemDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestProblemDao.java index 83fbcebc8..fbe20e342 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestProblemDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestProblemDao.java @@ -1,5 +1,6 @@ package judgels.uriel.persistence; +import java.io.PrintWriter; import java.util.Optional; import judgels.persistence.Dao; import judgels.persistence.QueryBuilder; @@ -9,6 +10,7 @@ public interface ContestProblemDao extends Dao { ContestProblemQueryBuilder selectByContestJid(String contestJid); Optional selectByContestJidAndProblemJid(String contestJid, String problemJid); Optional selectByContestJidAndProblemAlias(String contestJid, String problemAlias); + void dump(PrintWriter output, String contestJid); interface ContestProblemQueryBuilder extends QueryBuilder { ContestProblemQueryBuilder orderBy(String column, OrderDir dir); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestScoreboardDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestScoreboardDao.java index 4dc6a7158..8c32679d5 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestScoreboardDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestScoreboardDao.java @@ -1,9 +1,13 @@ package judgels.uriel.persistence; +import java.io.PrintWriter; import java.util.Optional; import judgels.persistence.Dao; +import judgels.persistence.QueryBuilder; import judgels.uriel.api.contest.scoreboard.ContestScoreboardType; public interface ContestScoreboardDao extends Dao { + QueryBuilder selectByContestJid(String contestJid); Optional selectByContestJidAndType(String contestJid, ContestScoreboardType type); + void dump(PrintWriter output, String contestJid); } diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestSupervisorDao.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestSupervisorDao.java index bad18764a..5d4a33d7d 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestSupervisorDao.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/persistence/ContestSupervisorDao.java @@ -1,5 +1,6 @@ package judgels.uriel.persistence; +import java.io.PrintWriter; import java.util.Optional; import judgels.persistence.Dao; import judgels.persistence.QueryBuilder; @@ -7,4 +8,5 @@ public interface ContestSupervisorDao extends Dao { QueryBuilder selectByContestJid(String contestJid); Optional selectByContestJidAndUserJid(String contestJid, String userJid); + void dump(PrintWriter output, String contestJid); }