use of cn.edu.zju.acm.onlinejudge.bean.Problemset in project zoj by licheng.
the class ProblemPersistenceImplTest method newProblemset.
/**
* Creates a new problemset.
* @param id the id
* @param forumId the forum id
* @param limit the limit
* @param languages a list of languages
* @return a new problemset instance
*/
private Problemset newProblemset(long id, long forumId, Limit limit, List languages) {
Problemset problem = new Problemset();
problem.setId(id);
problem.setDescription("desc" + id);
problem.setLimit(limit);
problem.setLanguages(languages);
problem.setTitle("title" + id);
problem.setForumId(forumId);
return problem;
}
use of cn.edu.zju.acm.onlinejudge.bean.Problemset in project zoj by licheng.
the class ContestPersistenceImplTest method testGetAllProblemsets.
/**
* Tests getAllProblemsets method
* @throws Exception to JUnit
*/
public void testGetAllProblemsets() throws Exception {
List contests = persistence.getAllProblemsets();
assertEquals("wrong size", 2, contests.size());
Problemset contest = (Problemset) contests.get(0);
checkAbstractContest(problemset1, contest);
contest = (Problemset) contests.get(1);
checkAbstractContest(problemset2, contest);
}
use of cn.edu.zju.acm.onlinejudge.bean.Problemset in project zoj by licheng.
the class ContestPersistenceImplTest method newProblemset.
/**
* Creates a new problemset.
* @param id the id
* @param forumId the forum id
* @param limit the limit
* @param languages a list of languages
* @return a new problemset instance
*/
private Problemset newProblemset(long id, long forumId, Limit limit, List languages) {
Problemset contest = new Problemset();
contest.setId(id);
contest.setDescription("desc" + id);
contest.setLimit(limit);
contest.setLanguages(languages);
contest.setTitle("title" + id);
contest.setForumId(forumId);
return contest;
}
use of cn.edu.zju.acm.onlinejudge.bean.Problemset in project zoj by licheng.
the class ContestPersistenceImplTest method testUpdateContest3.
/**
* Tests updateContest method
* @throws Exception to JUnit
*/
public void testUpdateContest3() throws Exception {
problemset1.setDescription("new");
problemset1.setTitle("new");
problemset1.setLanguages(null);
problemset1.setLimit(null);
problemset1.setForumId(forum2.getId());
persistence.updateContest(problemset1, 11);
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 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