} finally {
Database.dispose(ps);
}
// update the limit
Limit limit = contest.getLimit();
if (limit.getId() != ContestPersistenceImpl.DEFAULT_LIMIT_ID) {
try {
ps = conn.prepareStatement(ContestPersistenceImpl.INSERT_LIMIT);
ps.setInt(1, limit.getTimeLimit());
ps.setInt(2, limit.getMemoryLimit());
ps.setInt(3, limit.getOutputLimit());
ps.setInt(4, limit.getSubmissionLimit());
ps.executeUpdate();
} finally {
Database.dispose(ps);
}
limit.setId(Database.getLastId(conn));
}
if (contestLimitId != limit.getId()) {
// TODO(xuchuan) I don't understand what's that.
try {
ps = conn.prepareStatement(ContestPersistenceImpl.UPDATE_PROBLEM_LIMIT);
ps.setLong(1, limit.getId());
ps.setLong(2, contest.getId());
ps.setLong(3, contestLimitId);
ps.executeUpdate();
} finally {
Database.dispose(ps);
}
}
try {
// update the contest
ps = conn.prepareStatement(ContestPersistenceImpl.UPDATE_CONTEST);
ps.setString(1, contest.getTitle());
ps.setString(2, contest.getDescription());
if (contest.getStartTime() != null) {
ps.setTimestamp(3, new Timestamp(contest.getStartTime().getTime()));
} else {
ps.setTimestamp(3, null);
}
if (contest.getEndTime() != null) {
ps.setTimestamp(4, new Timestamp(contest.getEndTime().getTime()));
} else {
ps.setTimestamp(4, null);
}
ps.setLong(5, contest.getForumId());
if (limit == null || limit.getId() == ContestPersistenceImpl.DEFAULT_LIMIT_ID) {
ps.setLong(6, ContestPersistenceImpl.DEFAULT_LIMIT_ID);
} else {
ps.setLong(6, limit.getId());
}
ps.setBoolean(7, contest instanceof Problemset);
ps.setLong(8, user);
ps.setTimestamp(9, new Timestamp(new Date().getTime()));
ps.setBoolean(10, contest.isCheckIp());