use of cn.edu.zju.acm.onlinejudge.bean.Problem in project zoj by licheng.
the class JudgeClientInstanceUnitTest method init.
@BeforeClass
public static void init() throws Exception {
ReflectionUtil.setFieldValue(DAOFactory.class, "languageDAO", new MockLanguageDAO());
ReflectionUtil.setFieldValue(DAOFactory.class, "problemDAO", new MockProblemDAO());
ReflectionUtil.setFieldValue(DAOFactory.class, "submissionDAO", new MockSubmissionDAO());
ReflectionUtil.setFieldValue(DAOFactory.class, "referenceDAO", new MockReferenceDAO());
Problem problem = new Problem();
problem.setId(0);
problem.setRevision(0);
Limit limit = new Limit();
limit.setTimeLimit(1);
limit.setMemoryLimit(1024);
limit.setOutputLimit(1);
problem.setLimit(limit);
Reference reference = new Reference();
reference.setReferenceType(ReferenceType.INPUT);
reference.setContent("0 0\n1 2\n2 3\n".getBytes("ASCII"));
DAOFactory.getReferenceDAO().save(reference, 0);
DAOFactory.getReferenceDAO().save(reference, 1);
reference = new Reference();
reference.setReferenceType(ReferenceType.OUTPUT);
reference.setContent("0\n3\n5\n".getBytes("ASCII"));
DAOFactory.getReferenceDAO().save(reference, 0);
DAOFactory.getReferenceDAO().save(reference, 1);
DAOFactory.getProblemDAO().update(problem);
}
use of cn.edu.zju.acm.onlinejudge.bean.Problem in project zoj by licheng.
the class ContestManager method getProblem.
public Problem getProblem(long problemId) throws PersistenceException {
Object key = new Long(problemId);
synchronized (this.problemCache) {
Problem problem = this.problemCache.get(key);
if (problem == null) {
ProblemPersistence problemPersistence = PersistenceManager.getInstance().getProblemPersistence();
problem = problemPersistence.getProblem(problemId);
this.problemCache.put(key, problem);
}
return problem;
}
}
use of cn.edu.zju.acm.onlinejudge.bean.Problem in project zoj by licheng.
the class StatisticsManager method getRankList.
public RankList getRankList(long contestId, long roleId) throws PersistenceException {
List<Long> key = new ArrayList<Long>();
key.add(contestId);
key.add(roleId);
synchronized (this.ranklistCache) {
RankList ranklist = this.ranklistCache.get(key);
if (ranklist == null) {
ranklist = new RankList();
List<RoleSecurity> roles = PersistenceManager.getInstance().getAuthorizationPersistence().getContestRoles(contestId);
ranklist.setRoles(roles);
for (RoleSecurity role : roles) {
if (role.getId() == roleId) {
ranklist.setRole(role);
break;
}
}
if (roleId < 0 || ranklist.getRole() != null) {
AbstractContest contest = ContestManager.getInstance().getContest(contestId);
List<Problem> problems = ContestManager.getInstance().getContestProblems(contestId);
List<RankListEntry> entries = PersistenceManager.getInstance().getSubmissionPersistence().getRankList(problems, contest.getStartTime().getTime(), roleId);
for (RankListEntry entry : entries) {
entry.setUserProfile(UserManager.getInstance().getUserProfile(entry.getUserProfile().getId()));
}
ranklist.setEntries(entries);
}
this.ranklistCache.put(key, ranklist);
}
return ranklist;
}
}
use of cn.edu.zju.acm.onlinejudge.bean.Problem in project zoj by licheng.
the class ProblemPersistenceImplTest method testUpdateProblem2.
/**
* Tests updateProblem method
* @throws Exception to JUnit
*/
public void testUpdateProblem2() throws Exception {
long id = problem2.getId();
problem2.setContestId(problemset.getId());
problem2.setCode("new" + id);
problem2.setAuthor("new author" + id);
problem2.setChecker(id % 2 != 1);
problem2.setContest("new contest" + id);
problem2.setLimit(limit2);
problem2.setRevision((int) id * 200);
problem2.setSource("new source" + id);
problem2.setTitle("new title" + id);
persistence.updateProblem(problem2, 11);
Problem problem = (Problem) persistence.getProblem(problem2.getId());
checkProblem(problem2, problem);
}
use of cn.edu.zju.acm.onlinejudge.bean.Problem in project zoj by licheng.
the class ProblemPersistenceImplTest method testGetProblem1.
/**
* Tests getProblem method
* @throws Exception to JUnit
*/
public void testGetProblem1() throws Exception {
Problem problem = persistence.getProblem(problem1.getId());
checkProblem(problem1, problem);
}
Aggregations