Search in sources :

Example 26 with Problem

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");
}
Also used : ActionMessages(org.apache.struts.action.ActionMessages) ActionMessage(org.apache.struts.action.ActionMessage) Problem(cn.edu.zju.acm.onlinejudge.bean.Problem) ActionForward(org.apache.struts.action.ActionForward) ProblemPersistence(cn.edu.zju.acm.onlinejudge.persistence.ProblemPersistence)

Example 27 with Problem

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");
}
Also used : Problem(cn.edu.zju.acm.onlinejudge.bean.Problem) ActionForward(org.apache.struts.action.ActionForward)

Example 28 with Problem

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

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

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

Aggregations

Problem (cn.edu.zju.acm.onlinejudge.bean.Problem)44 ActionForward (org.apache.struts.action.ActionForward)11 AbstractContest (cn.edu.zju.acm.onlinejudge.bean.AbstractContest)10 ArrayList (java.util.ArrayList)9 Limit (cn.edu.zju.acm.onlinejudge.bean.Limit)8 ActionMessage (org.apache.struts.action.ActionMessage)7 ProblemPersistence (cn.edu.zju.acm.onlinejudge.persistence.ProblemPersistence)6 ActionMessages (org.apache.struts.action.ActionMessages)6 Reference (cn.edu.zju.acm.onlinejudge.bean.Reference)5 PersistenceException (cn.edu.zju.acm.onlinejudge.persistence.PersistenceException)5 Connection (java.sql.Connection)5 PreparedStatement (java.sql.PreparedStatement)5 ResultSet (java.sql.ResultSet)5 SQLException (java.sql.SQLException)5 UserProfile (cn.edu.zju.acm.onlinejudge.bean.UserProfile)4 Submission (cn.edu.zju.acm.onlinejudge.bean.Submission)3 RankListEntry (cn.edu.zju.acm.onlinejudge.util.RankListEntry)3 List (java.util.List)3 Language (cn.edu.zju.acm.onlinejudge.bean.enumeration.Language)2 ProblemForm (cn.edu.zju.acm.onlinejudge.form.ProblemForm)2