use of cn.edu.zju.acm.onlinejudge.bean.Problemset in project zoj by licheng.
the class ContestForm method populate.
public void populate(AbstractContest contest) {
this.id = String.valueOf(contest.getId());
this.name = contest.getTitle();
this.description = contest.getDescription();
this.forumId = String.valueOf(contest.getForumId());
if (contest instanceof Contest) {
this.contestType = 0;
} else if (contest instanceof Problemset) {
this.contestType = 1;
} else {
this.contestType = 2;
}
if (contest.getStartTime() != null) {
this.startTime = Utility.toTimestamp(contest.getStartTime());
this.contestLength = contest.getHours() + ":" + contest.getMinutes() + ":" + contest.getSeconds();
} else {
this.startTime = "";
this.contestLength = "";
}
this.checkIp = contest.isCheckIp();
Limit limit = contest.getLimit();
this.useGlobalDefault = limit.getId() == Limit.DEFAULT_LIMIT_ID;
this.timeLimit = String.valueOf(limit.getTimeLimit());
this.memoryLimit = String.valueOf(limit.getMemoryLimit());
this.submissionLimit = String.valueOf(limit.getSubmissionLimit());
this.outputLimit = String.valueOf(limit.getOutputLimit());
this.languageIds = new String[contest.getLanguages().size()];
for (int i = 0; i < this.languageIds.length; ++i) {
this.languageIds[i] = String.valueOf(contest.getLanguages().get(i).getId());
}
}
use of cn.edu.zju.acm.onlinejudge.bean.Problemset in project zoj by licheng.
the class ContestPersistenceImpl method populateContest.
/**
* Populates an AbstractContest with given ResultSet.
*
* @param rs
* @return an AbstractContest instance
* @throws SQLException
*/
private AbstractContest populateContest(ResultSet rs) throws SQLException {
AbstractContest contest = null;
int contestType = rs.getInt(DatabaseConstants.CONTEST_PROBLEMSET);
if (contestType == 1) {
contest = new Problemset();
} else if (contestType == 0) {
contest = new Contest();
} else {
contest = new Course();
}
if (rs.getTimestamp(DatabaseConstants.CONTEST_START_TIME) != null) {
contest.setStartTime(new Date(rs.getTimestamp(DatabaseConstants.CONTEST_START_TIME).getTime()));
}
if (rs.getTimestamp(DatabaseConstants.CONTEST_END_TIME) != null) {
contest.setEndTime(new Date(rs.getTimestamp(DatabaseConstants.CONTEST_END_TIME).getTime()));
}
contest.setId(rs.getLong(DatabaseConstants.CONTEST_CONTEST_ID));
contest.setTitle(rs.getString(DatabaseConstants.CONTEST_TITLE));
contest.setDescription(rs.getString(DatabaseConstants.CONTEST_DESCRIPTION));
contest.setForumId(rs.getLong(DatabaseConstants.CONTEST_FORUM_ID));
contest.setCheckIp(rs.getBoolean(DatabaseConstants.CONTEST_CHECK_IP));
Limit limit = new Limit();
limit.setId(rs.getLong(DatabaseConstants.LIMITS_LIMITS_ID));
limit.setTimeLimit(rs.getInt(DatabaseConstants.LIMITS_TIME_LIMIT));
limit.setMemoryLimit(rs.getInt(DatabaseConstants.LIMITS_MEMORY_LIMIT));
limit.setSubmissionLimit(rs.getInt(DatabaseConstants.LIMITS_SUBMISSION_LIMIT));
limit.setOutputLimit(rs.getInt(DatabaseConstants.LIMITS_OUTPUT_LIMIT));
contest.setLimit(limit);
return contest;
}
use of cn.edu.zju.acm.onlinejudge.bean.Problemset in project zoj by licheng.
the class ContestPersistenceImplTest method testGetContest4.
/**
* Tests getContest method
* @throws Exception to JUnit
*/
public void testGetContest4() throws Exception {
Problemset contest = (Problemset) persistence.getContest(problemset2.getId());
checkAbstractContest(problemset2, contest);
}
use of cn.edu.zju.acm.onlinejudge.bean.Problemset in project zoj by licheng.
the class ContestPersistenceImplTest method testGetContest3.
/**
* Tests getContest method
* @throws Exception to JUnit
*/
public void testGetContest3() throws Exception {
Problemset contest = (Problemset) persistence.getContest(problemset1.getId());
checkAbstractContest(problemset1, contest);
}
use of cn.edu.zju.acm.onlinejudge.bean.Problemset in project zoj by licheng.
the class ContestPersistenceImplTest method testUpdateContest4.
/**
* Tests updateContest method
* @throws Exception to JUnit
*/
public void testUpdateContest4() throws Exception {
problemset2.setDescription("new");
problemset2.setTitle("new");
problemset2.setLanguages(Arrays.asList(new Object[] { language1, language2, language3 }));
problemset2.setLimit(limit2);
problemset2.setForumId(forum1.getId());
persistence.updateContest(problemset2, 11);
Problemset contest = (Problemset) persistence.getContest(problemset2.getId());
checkAbstractContest(problemset2, contest);
}
Aggregations