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

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


        String ip = context.getRequest().getRemoteHost();
        long contestId = context.getContest().getId();
        String ipSessionKey = "last_submit_ip" + contestId;
        String lastIp = (String) context.getSessionAttribute(ipSessionKey);
        if (lastIp == null) {
            ContestPersistence contestPersistence = PersistenceManager.getInstance().getContestPersistence();
            long userId = context.getUserProfile().getId();
            lastIp = contestPersistence.getLastSubmitIP(userId, contestId);
            if (lastIp == null) {
                // first submit
                contestPersistence.setLastSubmitIP(userId, contestId, ip);
                context.setSessionAttribute(ipSessionKey, lastIp);
                return null;
            }
            context.setSessionAttribute(ipSessionKey, lastIp);
        }
View Full Code Here


        if (contestForm.getId() == null) {
            AbstractContest contest = context.getContest();
            contestForm.populate(contest);
            return this.handleSuccess(mapping, context);
        } else {
            ContestPersistence persistence = PersistenceManager.getInstance().getContestPersistence();
            AbstractContest contest = contestForm.toContest();
            persistence.updateContest(contest, context.getUserSecurity().getId());
            ContestManager.getInstance().refreshContest(contest.getId());

            ActionMessages messages = new ActionMessages();
            messages.add("message", new ActionMessage("onlinejudge.editContest.success"));
            this.saveErrors(context.getRequest(), messages);
View Full Code Here

        if (forward != null) {
            return forward;
        }

        AbstractContest contest = context.getContest();
        ContestPersistence contestPersistence = PersistenceManager.getInstance().getContestPersistence();
        contestPersistence.deleteContest(contest.getId(), context.getUserSecurity().getId());

        ContestManager.getInstance().refreshContest(contest.getId());

        ActionMessages messages = new ActionMessages();
        if (isProblemset) {
View Full Code Here

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

        ContestPersistence contestPersistence = PersistenceManager.getInstance().getContestPersistence();
        ContestForm contestForm = (ContestForm) form;
        if (contestForm == null || contestForm.getId() == null) {
            return this.handleSuccess(mapping, context, "failure");
        }

        context.setAttribute("ContestForm", contestForm);

        // create user profile
        AbstractContest contest = contestForm.toContest();

        contestPersistence.createContest(contest, context.getUserProfile().getId());
        ContestManager.getInstance().refreshContest(contest.getId());

        ActionMessages messages = new ActionMessages();
        messages.add("message", new ActionMessage("onlinejudge.createContest.success"));
        this.saveErrors(context.getRequest(), messages);
View Full Code Here

    public List<AbstractContest> getContests(int contestType) throws PersistenceException {
        Object key = new Integer(contestType);
        synchronized (this.contestsCache) {
            List<AbstractContest> contests = this.contestsCache.get(key);
            if (contests == null) {
                ContestPersistence contestPersistence = PersistenceManager.getInstance().getContestPersistence();
                if (contestType==1) {
                    contests = contestPersistence.getAllProblemsets();
                } else if (contestType==0) {
                    contests = contestPersistence.getAllContests();
                } else {
                    contests = contestPersistence.getAllCourses();
                }
                this.contestsCache.put(key, contests);
            }
            return contests;
        }
View Full Code Here

    public AbstractContest getContest(long contestId) throws PersistenceException {
        Object key = new Long(contestId);
        synchronized (this.contestCache) {
            AbstractContest contest = this.contestCache.get(key);
            if (contest == null) {
                ContestPersistence contestPersistence = PersistenceManager.getInstance().getContestPersistence();
                contest = contestPersistence.getContest(contestId);
                this.contestCache.put(key, contest);
            }
            return contest;
        }
    }
View Full Code Here

TOP

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

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.