use of cn.edu.zju.acm.onlinejudge.persistence.ProblemPersistence in project zoj by licheng.
the class DeleteProblemAction method execute.
/**
* Register.
*
* @param mapping
* action mapping
* @param form
* action form
* @param request
* http servlet request
* @param response
* http servlet response
*
* @return action forward instance
*
* @throws Exception
* any errors happened
*/
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, ContextAdapter context) throws Exception {
// check problem
boolean isProblemset = context.getRequest().getRequestURI().endsWith("deleteProblem.do");
ActionForward forward = this.checkProblemAdminPermission(mapping, context, isProblemset);
if (forward != null) {
return forward;
}
Problem problem = context.getProblem();
ActionMessages messages = new ActionMessages();
ProblemPersistence problemPersistence = PersistenceManager.getInstance().getProblemPersistence();
problemPersistence.deleteProblem(problem.getId(), context.getUserProfile().getId());
messages.add("message", new ActionMessage("onlinejudge.deleteProblem.success"));
this.saveErrors(context.getRequest(), messages);
String back = isProblemset ? "showProblems" : "showContestProblems";
context.setAttribute("back", back + ".do?contestId=" + context.getContest().getId());
ContestManager.getInstance().refreshContest(context.getContest().getId());
return this.handleSuccess(mapping, context, "success");
}
use of cn.edu.zju.acm.onlinejudge.persistence.ProblemPersistence in project zoj by licheng.
the class ContestManager method getProblemsCount.
public int getProblemsCount(long contestId) throws PersistenceException {
Object key = new Long(contestId);
synchronized (this.problemCountCache) {
Integer count = this.problemCountCache.get(key);
if (count == null) {
ProblemPersistence problemPersistence = PersistenceManager.getInstance().getProblemPersistence();
int ret = problemPersistence.getProblemsCount(contestId);
this.problemCountCache.put(key, ret);
return ret;
}
return count.intValue();
}
}
use of cn.edu.zju.acm.onlinejudge.persistence.ProblemPersistence in project zoj by licheng.
the class ContestManager method searchProblems.
public List<Problem> searchProblems(ProblemCriteria criteria, int offset, int count) throws PersistenceException {
List<Object> key = new ArrayList<Object>();
key.add(criteria);
key.add(new Integer(offset));
key.add(new Integer(count));
synchronized (this.contestProblemsCache) {
List<Problem> problems = this.contestProblemsCache.get(key);
if (problems == null) {
ProblemPersistence problemPersistence = PersistenceManager.getInstance().getProblemPersistence();
problems = problemPersistence.searchProblems(criteria, offset, count);
this.contestProblemsCache.put(key, problems);
}
return problems;
}
}
Aggregations