Package cn.edu.zju.acm.onlinejudge.bean

Examples of cn.edu.zju.acm.onlinejudge.bean.UserPreference


                ps = conn.prepareStatement(UserPersistenceImpl.GET_USER_PREFERENCE);
                ps.setLong(1, id);
                ResultSet rs = ps.executeQuery();

                if (rs.next()) {
                    UserPreference preference = new UserPreference();
                    preference.setId(rs.getLong(DatabaseConstants.USER_PREFERENCE_USER_PROFILE_ID));
                    preference.setPlan(rs.getString(DatabaseConstants.USER_PREFERENCE_PLAN));
                    preference.setPostPaging(rs.getInt(DatabaseConstants.USER_PREFERENCE_POST_PAGING));
                    preference.setProblemPaging(rs.getInt(DatabaseConstants.USER_PREFERENCE_PROBLEM_PAGING));
                    preference.setStatusPaging(rs.getInt(DatabaseConstants.USER_PREFERENCE_STATUS_PAGING));
                    preference.setSubmissionPaging(rs.getInt(DatabaseConstants.USER_PREFERENCE_SUBMISSION_PAGING));
                    preference.setThreadPaging(rs.getInt(DatabaseConstants.USER_PREFERENCE_THREAD_PAGING));
                    preference.setUserPaging(rs.getInt(DatabaseConstants.USER_PREFERENCE_USER_PAGING));
                    return preference;
                } else {
                    return null;
                }
            } finally {
View Full Code Here


        // create user profile
        UserProfile profile = profileForm.toUserProfile();
        userPersistence.createUserProfile(profile, 0);

        // create user perference
        UserPreference perference = profileForm.toUserPreference();
        perference.setId(profile.getId());
        userPersistence.createUserPreference(perference, 0);

        AuthorizationPersistence authorizationPersistence =
                PersistenceManager.getInstance().getAuthorizationPersistence();
        authorizationPersistence.addUserRole(profile.getId(), 2);
View Full Code Here

                contest = null;
            }
        }

        UserStatistics statistics = null;
        UserPreference pref = null;
        if (contest != null && user != null) {
          // TODO cache?
          pref = PersistenceManager.getInstance().getUserPersistence().getUserPreference(user.getId());
            statistics = StatisticsManager.getInstance().getUserStatistics(contest.getId(), user.getId());
        }
View Full Code Here

            return this.handleSuccess(mapping, context, "login");
        }
        UserPersistence userPersistence = PersistenceManager.getInstance().getUserPersistence();
        ProfileForm profileForm = (ProfileForm) form;
        UserProfile profile = context.getUserProfile();
        UserPreference perference = userPersistence.getUserPreference(profile.getId());
        if (profileForm.getHandle() == null) {
            profileForm.populate(profile, perference);
            context.setAttribute("ProfileForm", profileForm);
            return this.handleSuccess(mapping, context, "failure");
        }

        if (userPersistence.login(profileForm.getHandle(), profileForm.getPassword()) == null) {
            return this.handleFailure(mapping, context, "password", "ProfileForm.password.invalid");
        }

        UserProfile newProfile = profileForm.toUserProfile();
        newProfile.setId(profile.getId());
        newProfile.setRegDate(profile.getRegDate());

        if (!profile.getHandle().equals(newProfile.getHandle())) {
            return this.handleFailure(mapping, context, "handle", "ProfileForm.handle.changed");
        }

        if (!profile.getEmail().equals(newProfile.getEmail())) {
            UserProfile temp = userPersistence.getUserProfileByEmail(newProfile.getEmail());
            if (temp != null && temp.getId() != profile.getId()) {
                return this.handleFailure(mapping, context, "email", "ProfileForm.email.used");
            }
        }

        userPersistence.updateUserProfile(newProfile, profile.getId());
        UserPreference newPerference = profileForm.toUserPreference();
        newPerference.setId(profile.getId());
        userPersistence.updateUserPreference(newPerference, profile.getId());
        context.setUserProfile(newProfile);
        context.getRequest().setAttribute("Countries",
                                          PersistenceManager.getInstance().getUserPersistence().getAllCountries());
View Full Code Here

  public void testCreateUserPreference() throws Exception
    persistence.createUserProfile(profile, 1)
    perference.setId(profile.getId());
    persistence.createUserPreference(perference, 1);
   
    UserPreference perference1 = persistence.getUserPreference(perference.getId());
    checkUserPreference(perference, perference1);   
       
  }
View Full Code Here

    perference.setThreadPaging(55);
    perference.setUserPaging(66);
   
    persistence.updateUserPreference(perference, 1);
   
    UserPreference perference1 = persistence.getUserPreference(perference.getId());
    checkUserPreference(perference, perference1);   
       
  }
View Full Code Here

  public void testGetUserPreference() throws Exception
    persistence.createUserProfile(profile, 1)
    perference.setId(profile.getId());
    persistence.createUserPreference(perference, 1);
   
    UserPreference perference1 = persistence.getUserPreference(perference.getId());
    checkUserPreference(perference, perference1);   
       
  }
View Full Code Here

        // get UserSecurity
        UserSecurity security = authorizationPersistence.getUserSecurity(profile.getId());

        // get UserPreference
        UserPreference perference = userPersistence.getUserPreference(profile.getId());

        context.setUserProfile(profile);
        context.setUserSecurity(security);
        if(context.getAllCourses().size()!=0) {
          security.setHasCourses(true);
View Full Code Here

        profile.setPassword(this.newPassword);
        return profile;
    }

    public UserPreference toUserPreference() throws PersistenceException {
        UserPreference preference= new UserPreference();
        preference.setPlan(this.plan);
        preference.setPostPaging(20); // TODO...
        preference.setProblemPaging(100);
        preference.setStatusPaging(20);
        preference.setThreadPaging(20);
        preference.setUserPaging(20);
        return preference;
    }
View Full Code Here

                        AuthorizationPersistence authorizationPersistence =
                                PersistenceManager.getInstance().getAuthorizationPersistence();
                        // get UserSecurity
                        UserSecurity security = authorizationPersistence.getUserSecurity(profile.getId());
                        // get UserPreference
                        UserPreference perference = userPersistence.getUserPreference(profile.getId());
                        r.getSession().setAttribute(ContextAdapter.USER_PROFILE_SESSION_KEY, profile);
                        r.getSession().setAttribute(ContextAdapter.SECURITY_SESSION_KEY, security);
                        r.getSession().setAttribute(ContextAdapter.PREFERENCE_SESSION_KEY, perference);
                    } else {
                        Cookie ch = new Cookie("oj_handle", "");
View Full Code Here

TOP

Related Classes of cn.edu.zju.acm.onlinejudge.bean.UserPreference

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.