Search in sources :

Example 1 with Problemset

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());
    }
}
Also used : 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)

Example 2 with Problemset

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

Example 3 with Problemset

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

Example 4 with Problemset

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

Example 5 with Problemset

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

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