Package cn.edu.zju.acm.onlinejudge.persistence

Examples of cn.edu.zju.acm.onlinejudge.persistence.ProblemPersistence


        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);
View Full Code Here


        {
      ProblemCriteria pc=new ProblemCriteria();
      pc.setContestId(new Long(ConfigManager.getDefaultProblemSetId()));
      pc.setCode(stringCode);
           
      ProblemPersistence problemPersistence = PersistenceManager.getInstance().getProblemPersistence();
            List problems = problemPersistence.searchProblems(pc, 0,1);
      if(problems.size()!=0)
      {
        problemId = ((Problem)(problems.get(0))).getId();
        stringId=""+problemId;
      }
View Full Code Here

            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";
View Full Code Here

    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();
        }
View Full Code Here

        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;
        }
    }
View Full Code Here

    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;
        }
    }
View Full Code Here

        return this.handleSuccess(mapping, context, "success");

    }

    private static void createProblems(ProblemPackage pack, long cid) throws Exception {
        ProblemPersistence problemPersistence = PersistenceManager.getInstance().getProblemPersistence();

        ProblemEntry[] problems = pack.getProblemEntries();
        for (int i = 0; i < problems.length; ++i) {
            // info
            problems[i].getProblem().setContestId(cid);
            problemPersistence.createProblem(problems[i].getProblem(), 0);

            long problemId = problems[i].getProblem().getId();
            ProblemImportAction.createReference(ReferenceType.DESCRIPTION, problems[i].getText(), problemId, 0,
                                                ProblemManager.PROBLEM_TEXT_FILE, null);
            ProblemImportAction.createReference(ReferenceType.INPUT, problems[i].getInput(), problemId, 0,
View Full Code Here

        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);
View Full Code Here

TOP

Related Classes of cn.edu.zju.acm.onlinejudge.persistence.ProblemPersistence

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.