Package cn.edu.zju.acm.onlinejudge.form

Examples of cn.edu.zju.acm.onlinejudge.form.ProblemForm


        ActionForward forward = this.checkContestAdminPermission(mapping, context, isProblemset, false);
        if (forward != null) {
            return forward;
        }

        ProblemForm problemForm = (ProblemForm) form;
        if (problemForm == null || problemForm.getProblemId() == null) {
            return this.handleSuccess(mapping, context);
        }

        // check title and code
        ActionMessages errors = this.validate(problemForm, context);
        if (errors.size() > 0) {
            return this.handleFailure(mapping, context, errors);
        }

        ProblemPersistence problemPersistence = PersistenceManager.getInstance().getProblemPersistence();
        AbstractContest contest = context.getContest();

        Problem problem = problemForm.toProblem();
        if (problemForm.isUseContestDefault()) {
            problem.getLimit().setId(contest.getLimit().getId());
        }

        long userId = context.getUserSecurity().getId();
        // create problem
        problemPersistence.createProblem(problem, userId);

        // cprete problem reference, i.e. text, input, output, checker, judge solution, checker source
        this.createReference(ReferenceType.DESCRIPTION, problemForm.getDescription(), problem.getId(), userId);
        this.createReference(ReferenceType.INPUT, problemForm.getInputData(), problem.getId(), userId);
        this.createReference(ReferenceType.OUTPUT, problemForm.getOutputData(), problem.getId(), userId);
        this.createReference(ReferenceType.HEADER, problemForm.getChecker(), problem.getId(), userId);
        this.createReference(ReferenceType.CHECKER_SOURCE, problemForm.getCheckerSource(), problem.getId(), userId);
        this.createReference(ReferenceType.JUDGE_SOLUTION, problemForm.getJudgeSolution(), problem.getId(), userId);

        ContestManager.getInstance().refreshContest(problem.getContestId());

        return this.handleSuccess(mapping, context, "success", "?contestId=" + contest.getId());
    }
View Full Code Here


        ActionForward forward = this.checkProblemAdminPermission(mapping, context, isProblemset);
        if (forward != null) {
            return forward;
        }

        ProblemForm problemForm = (ProblemForm) form;
        if (problemForm == null || problemForm.getName() == null) {
            Problem problem = context.getProblem();
            problemForm.populate(problem, context.getContest());
            this.setReference("DescriptionRef", ReferenceType.DESCRIPTION, problem.getId(), context);
            this.setReference("InputRef", ReferenceType.INPUT, problem.getId(), context);
            this.setReference("OutputRef", ReferenceType.OUTPUT, problem.getId(), context);
            this.setReference("JudgeSolutionRef", ReferenceType.JUDGE_SOLUTION, problem.getId(), context);
            this.setReference("HeaderRef", ReferenceType.HEADER, problem.getId(), context);
            this.setReference("CheckerSourceRef", ReferenceType.CHECKER_SOURCE, problem.getId(), context);
            return this.handleSuccess(mapping, context, "failure");
        }

        // check title and code
        ActionMessages errors = this.validate(problemForm, context);
        if (errors.size() > 0) {
            return this.handleFailure(mapping, context, errors);
        }

        ProblemPersistence problemPersistence = PersistenceManager.getInstance().getProblemPersistence();
        AbstractContest contest = context.getContest();

        Problem problem = problemForm.toProblem();
        if (problemForm.isUseContestDefault()) {
            problem.getLimit().setId(contest.getLimit().getId());
        }

        long userId = context.getUserSecurity().getId();
        // create problem
        problemPersistence.updateProblem(problem, userId);

        // cprete problem reference, i.e. text, input, output, checker, judge solution, checker source
        this.updateReference(ReferenceType.DESCRIPTION, problemForm.getDescription(), problem.getId(), userId);
        this.updateReference(ReferenceType.INPUT, problemForm.getInputData(), problem.getId(), userId);
        this.updateReference(ReferenceType.OUTPUT, problemForm.getOutputData(), problem.getId(), userId);
        this.updateReference(ReferenceType.HEADER, problemForm.getChecker(), problem.getId(), userId);
        this.updateReference(ReferenceType.CHECKER_SOURCE, problemForm.getCheckerSource(), problem.getId(), userId);
        this.updateReference(ReferenceType.JUDGE_SOLUTION, problemForm.getJudgeSolution(), problem.getId(), userId);

        ContestManager.getInstance().refreshProblem(problem);

        return this.handleSuccess(mapping, context, "success", "?contestId=" + contest.getId());
    }
View Full Code Here

TOP

Related Classes of cn.edu.zju.acm.onlinejudge.form.ProblemForm

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.