use of cn.edu.zju.acm.onlinejudge.bean.Contest in project zoj by licheng.
the class ContestPersistenceImplTest method testGetContest2.
/**
* Tests getContest method
* @throws Exception to JUnit
*/
public void testGetContest2() throws Exception {
Contest contest = (Contest) persistence.getContest(contest2.getId());
checkAbstractContest(contest2, contest);
assertEquals("wrong start time", contest.getStartTime(), contest2.getStartTime());
assertEquals("wrong end time", contest.getEndTime(), contest2.getEndTime());
}
use of cn.edu.zju.acm.onlinejudge.bean.Contest in project zoj by licheng.
the class ContestPersistenceImplTest method testUpdateContest2.
/**
* Tests updateContest method
* @throws Exception to JUnit
*/
public void testUpdateContest2() throws Exception {
contest2.setDescription("new");
contest2.setTitle("new");
contest2.setLanguages(Arrays.asList(new Object[] { language1, language2, language3 }));
contest2.setLimit(limit2);
contest2.setForumId(forum1.getId());
contest2.setStartTime(new Date(50000));
contest2.setEndTime(new Date(60000));
persistence.updateContest(contest2, 11);
Contest contest = (Contest) persistence.getContest(contest2.getId());
checkAbstractContest(contest2, contest);
assertEquals("wrong start time", contest.getStartTime(), contest2.getStartTime());
assertEquals("wrong end time", contest.getEndTime(), contest2.getEndTime());
}
use of cn.edu.zju.acm.onlinejudge.bean.Contest in project zoj by licheng.
the class ContestForm method toContest.
public AbstractContest toContest() throws ParseException, NumberFormatException, PersistenceException {
AbstractContest contest = null;
if (this.contestType == 1) {
contest = new Problemset();
} else if (this.contestType == 0) {
contest = new Contest();
} else {
contest = new Course();
}
if (this.startTime != null && this.startTime.trim().length() > 0) {
contest.setStartTime(Utility.parseTimestamp(this.startTime));
contest.setEndTime(new Date(Utility.parseTimestamp(this.startTime).getTime() + Utility.parseTime(this.contestLength) * 1000));
}
try {
if (this.id != null) {
contest.setId(Long.parseLong(this.id));
}
} catch (NumberFormatException e) {
}
contest.setTitle(this.name);
contest.setDescription(this.description);
contest.setCheckIp(this.checkIp);
Limit limit = new Limit();
if (this.useGlobalDefault) {
limit.setId(1);
} else {
limit.setTimeLimit(Integer.parseInt(this.timeLimit));
limit.setMemoryLimit(Integer.parseInt(this.memoryLimit));
limit.setSubmissionLimit(Integer.parseInt(this.submissionLimit));
limit.setOutputLimit(Integer.parseInt(this.outputLimit));
}
contest.setLimit(limit);
contest.setForumId(Long.parseLong(this.forumId));
List<Language> languages = new ArrayList<Language>();
LanguagePersistence languagePersistence = PersistenceManager.getInstance().getLanguagePersistence();
if (this.languageIds != null) {
for (int i = 0; i < this.languageIds.length; ++i) {
Language language = languagePersistence.getLanguage(Long.parseLong(this.languageIds[i]));
if (language != null) {
languages.add(language);
}
}
}
contest.setLanguages(languages);
return contest;
}
Aggregations