use of cn.edu.zju.acm.onlinejudge.persistence.LanguagePersistence in project zoj by licheng.
the class SubmissionSearchForm method toSubmissionCriteria.
public SubmissionCriteria toSubmissionCriteria() throws ParseException, NumberFormatException, PersistenceException {
SubmissionCriteria criteria = new SubmissionCriteria();
if (this.contestId != null && this.contestId.trim().length() > 0) {
criteria.setContestId(Long.valueOf(this.contestId.trim()));
}
if (this.problemCode != null && this.problemCode.trim().length() > 0) {
criteria.setProblemCode(this.problemCode);
}
if (this.handle != null && this.handle.trim().length() > 0) {
criteria.setHandle(this.handle);
}
if (this.idStart != null && this.idStart.trim().length() > 0) {
criteria.setIdStart(Long.valueOf(this.idStart.trim()));
}
if (this.idEnd != null && this.idEnd.trim().length() > 0) {
criteria.setIdEnd(Long.valueOf(this.idEnd.trim()));
}
if (this.timeStart != null && this.timeStart.trim().length() > 0) {
criteria.setTimeStart(Utility.parseTimestamp(this.timeStart));
}
if (this.timeEnd != null && this.timeEnd.trim().length() > 0) {
criteria.setTimeEnd(Utility.parseTimestamp(this.timeEnd));
}
if (this.languageIds != null && this.languageIds.length > 0) {
LanguagePersistence persistence = PersistenceManager.getInstance().getLanguagePersistence();
List<Language> languages = new ArrayList<Language>();
for (int i = 0; i < this.languageIds.length; ++i) {
languages.add(persistence.getLanguage(Long.parseLong(this.languageIds[i])));
}
criteria.setLanguages(languages);
}
if (this.judgeReplyIds != null && this.judgeReplyIds.length > 0) {
List<JudgeReply> judgeReplies = new ArrayList<JudgeReply>();
for (int i = 0; i < this.judgeReplyIds.length; ++i) {
judgeReplies.add(JudgeReply.findById(Long.parseLong(this.judgeReplyIds[i])));
}
criteria.setJudgeReplies(judgeReplies);
}
return criteria;
}
use of cn.edu.zju.acm.onlinejudge.persistence.LanguagePersistence 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