use of cn.edu.zju.acm.onlinejudge.bean.Problem 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.bean.Problem in project zoj by licheng.
the class ShowProblemAction method execute.
/**
* ShowProblemAction.
*
* @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 contest
boolean isProblemset = context.getRequest().getRequestURI().endsWith("showProblem.do");
ActionForward forward = this.checkProblemViewPermission(mapping, context, isProblemset);
if (forward != null) {
return forward;
}
Problem problem = context.getProblem();
byte[] text = ContestManager.getInstance().getDescription(problem.getId());
// StringBuffer sb = new StringBuffer();
context.setAttribute("text", text);
return this.handleSuccess(mapping, context, "success");
}
use of cn.edu.zju.acm.onlinejudge.bean.Problem in project zoj by licheng.
the class ProblemPersistenceImplTest method testGetProblem2.
/**
* Tests getProblem method
* @throws Exception to JUnit
*/
public void testGetProblem2() throws Exception {
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 testUpdateProblem1.
/**
* Tests updateProblem method
* @throws Exception to JUnit
*/
public void testUpdateProblem1() throws Exception {
long id = problem1.getId();
problem1.setContestId(problemset.getId());
problem1.setCode("new" + id);
problem1.setAuthor("new author" + id);
problem1.setChecker(id % 2 != 1);
problem1.setContest("new contest" + id);
problem1.setLimit(null);
problem1.setRevision((int) id * 100);
problem1.setSource("new source" + id);
problem1.setTitle("new title" + id);
persistence.updateProblem(problem1, 11);
Problem problem = (Problem) persistence.getProblem(problem1.getId());
checkProblem(problem1, problem);
}
use of cn.edu.zju.acm.onlinejudge.bean.Problem in project zoj by licheng.
the class ProblemPersistenceImplTest method testGetProblem4.
/**
* Tests getProblem method
* @throws Exception to JUnit
*/
public void testGetProblem4() throws Exception {
Problem problem = persistence.getProblem(1234567890l);
assertNull("no such problem", problem);
}
Aggregations