Search in sources :

Example 6 with Problemset

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;
}
Also used : Problemset(cn.edu.zju.acm.onlinejudge.bean.Problemset)

Example 7 with Problemset

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);
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) Problemset(cn.edu.zju.acm.onlinejudge.bean.Problemset)

Example 8 with Problemset

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;
}
Also used : Problemset(cn.edu.zju.acm.onlinejudge.bean.Problemset)

Example 9 with Problemset

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);
}
Also used : Problemset(cn.edu.zju.acm.onlinejudge.bean.Problemset)

Example 10 with Problemset

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;
}
Also used : AbstractContest(cn.edu.zju.acm.onlinejudge.bean.AbstractContest) Language(cn.edu.zju.acm.onlinejudge.bean.enumeration.Language) ArrayList(java.util.ArrayList) AbstractContest(cn.edu.zju.acm.onlinejudge.bean.AbstractContest) Contest(cn.edu.zju.acm.onlinejudge.bean.Contest) Limit(cn.edu.zju.acm.onlinejudge.bean.Limit) Problemset(cn.edu.zju.acm.onlinejudge.bean.Problemset) Course(cn.edu.zju.acm.onlinejudge.bean.Course) Date(java.util.Date) LanguagePersistence(cn.edu.zju.acm.onlinejudge.persistence.LanguagePersistence)

Aggregations

Problemset (cn.edu.zju.acm.onlinejudge.bean.Problemset)12 Limit (cn.edu.zju.acm.onlinejudge.bean.Limit)5 Date (java.util.Date)4 AbstractContest (cn.edu.zju.acm.onlinejudge.bean.AbstractContest)3 Contest (cn.edu.zju.acm.onlinejudge.bean.Contest)3 Course (cn.edu.zju.acm.onlinejudge.bean.Course)3 Language (cn.edu.zju.acm.onlinejudge.bean.enumeration.Language)3 PersistenceException (cn.edu.zju.acm.onlinejudge.persistence.PersistenceException)2 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 SQLException (java.sql.SQLException)2 Timestamp (java.sql.Timestamp)2 ArrayList (java.util.ArrayList)2 LanguagePersistence (cn.edu.zju.acm.onlinejudge.persistence.LanguagePersistence)1 ResultSet (java.sql.ResultSet)1 List (java.util.List)1