Search in sources :

Example 1 with ProblemCriteria

use of cn.edu.zju.acm.onlinejudge.bean.request.ProblemCriteria in project zoj by licheng.

the class ContestManager method getContestProblems.

public List<Problem> getContestProblems(long contestId) throws PersistenceException {
    ProblemCriteria criteria = new ProblemCriteria();
    criteria.setContestId(new Long(contestId));
    return this.searchProblems(criteria, 0, Integer.MAX_VALUE);
}
Also used : ProblemCriteria(cn.edu.zju.acm.onlinejudge.bean.request.ProblemCriteria)

Example 2 with ProblemCriteria

use of cn.edu.zju.acm.onlinejudge.bean.request.ProblemCriteria in project zoj by licheng.

the class ContestManager method refreshContest.

public void refreshContest(long contestId) {
    synchronized (this.contestProblemsCache) {
        for (Object key : this.contestProblemsCache.getKeys()) {
            ProblemCriteria criteria = ((List<ProblemCriteria>) key).iterator().next();
            if (criteria.getContestId() == contestId) {
                this.contestProblemsCache.remove(key);
            }
        }
    }
    this.contestCache.remove(contestId);
    this.problemCountCache.remove(contestId);
    this.contestsCache.remove(true);
    this.contestsCache.remove(false);
}
Also used : ProblemCriteria(cn.edu.zju.acm.onlinejudge.bean.request.ProblemCriteria)

Example 3 with ProblemCriteria

use of cn.edu.zju.acm.onlinejudge.bean.request.ProblemCriteria in project zoj by licheng.

the class ContestManager method getContestProblems.

public List<Problem> getContestProblems(long contestId, int offset, int count) throws PersistenceException {
    ProblemCriteria criteria = new ProblemCriteria();
    criteria.setContestId(new Long(contestId));
    return this.searchProblems(criteria, offset, count);
}
Also used : ProblemCriteria(cn.edu.zju.acm.onlinejudge.bean.request.ProblemCriteria)

Example 4 with ProblemCriteria

use of cn.edu.zju.acm.onlinejudge.bean.request.ProblemCriteria in project zoj by licheng.

the class ContextAdapter method getProblem.

public Problem getProblem() throws PersistenceException {
    if (this.getAttribute("problem") instanceof Problem) {
        return (Problem) this.getAttribute("problem");
    }
    long problemId = -1;
    String stringCode = this.request.getParameter("problemCode");
    String stringId = this.request.getParameter("problemId");
    if (stringCode != null) {
        ProblemCriteria pc = new ProblemCriteria();
        pc.setContestId(new Long(ConfigManager.getDefaultProblemSetId()));
        pc.setCode(stringCode);
        ProblemPersistence problemPersistence = PersistenceManager.getInstance().getProblemPersistence();
        List problems = problemPersistence.searchProblems(pc, 0, 1);
        if (problems.size() != 0) {
            problemId = ((Problem) (problems.get(0))).getId();
            stringId = "" + problemId;
        }
    }
    this.setAttribute("problemId", stringId);
    if (stringId != null) {
        try {
            problemId = Long.parseLong(stringId);
        } catch (NumberFormatException e) {
        }
    }
    if (problemId < 0) {
        return null;
    }
    Problem problem = ContestManager.getInstance().getProblem(problemId);
    this.setAttribute("problem", problem);
    return problem;
}
Also used : Problem(cn.edu.zju.acm.onlinejudge.bean.Problem) ArrayList(java.util.ArrayList) List(java.util.List) ProblemCriteria(cn.edu.zju.acm.onlinejudge.bean.request.ProblemCriteria) ProblemPersistence(cn.edu.zju.acm.onlinejudge.persistence.ProblemPersistence)

Aggregations

ProblemCriteria (cn.edu.zju.acm.onlinejudge.bean.request.ProblemCriteria)4 Problem (cn.edu.zju.acm.onlinejudge.bean.Problem)1 ProblemPersistence (cn.edu.zju.acm.onlinejudge.persistence.ProblemPersistence)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1