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

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


     * @return the UserProfile instance
     * @throws SQLException
     *             if any error occurs
     */
    private UserProfile populateUserProfile(ResultSet rs) throws SQLException {
        UserProfile profile = new UserProfile();

        profile.setId(rs.getLong(DatabaseConstants.USER_PROFILE_USER_PROFILE_ID));
        profile.setHandle(rs.getString(DatabaseConstants.USER_PROFILE_HANDLE));
        profile.setPassword(rs.getString(DatabaseConstants.USER_PROFILE_PASSWORD));
        profile.setEmail(rs.getString(DatabaseConstants.USER_PROFILE_EMAIL_ADDRESS));
        profile.setRegDate(rs.getTimestamp(DatabaseConstants.USER_PROFILE_REG_DATE));
        profile.setFirstName(rs.getString(DatabaseConstants.USER_PROFILE_FIRST_NAME));
        profile.setLastName(rs.getString(DatabaseConstants.USER_PROFILE_LAST_NAME));
        profile.setAddressLine1(rs.getString(DatabaseConstants.USER_PROFILE_ADDRESS_LINE1));
        profile.setAddressLine2(rs.getString(DatabaseConstants.USER_PROFILE_ADDRESS_LINE2));
        profile.setCity(rs.getString(DatabaseConstants.USER_PROFILE_CITY));
        profile.setState(rs.getString(DatabaseConstants.USER_PROFILE_STATE));
        profile.setCountry(new Country(rs.getLong(DatabaseConstants.USER_PROFILE_COUNTRY_ID), "foo"));
        profile.setZipCode(rs.getString(DatabaseConstants.USER_PROFILE_ZIP_CODE));
        profile.setPhoneNumber(rs.getString(DatabaseConstants.USER_PROFILE_PHONE_NUMBER));
        profile.setBirthDate(rs.getDate(DatabaseConstants.USER_PROFILE_BIRTH_DATE));
        String gender = rs.getString(DatabaseConstants.USER_PROFILE_GENDER);
        profile.setGender(gender == null || gender.length() == 0 ? ' ' : gender.charAt(0));
        profile.setSchool(rs.getString(DatabaseConstants.USER_PROFILE_SCHOOL));
        profile.setMajor(rs.getString(DatabaseConstants.USER_PROFILE_MAJOR));
        profile.setGraduateStudent(rs.getBoolean(DatabaseConstants.USER_PROFILE_GRADUATE_STUDENT));
        profile.setGraduationYear(rs.getInt(DatabaseConstants.USER_PROFILE_GRADUATION_YEAR));
        profile.setStudentNumber(rs.getString(DatabaseConstants.USER_PROFILE_STUDENT_NUMBER));
        profile.setConfirmed(rs.getBoolean(DatabaseConstants.USER_PROFILE_CONFIRMED));
        profile.setActive(rs.getBoolean(DatabaseConstants.USER_PROFILE_ACTIVE));
        profile.setNickName(rs.getString("nickname"));
        profile.setOldEmail(rs.getString("old_email"));
        return profile;
    }
View Full Code Here


     *
     */
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                                 HttpServletResponse response) {
        UserProfile user = (UserProfile) request.getSession().getAttribute(ContextAdapter.USER_PROFILE_SESSION_KEY);
        long actionId = PerformanceManager.getInstance().actionStart(this, request, user);

        ContextAdapter context = null;
        ActionForward forward = null;
        try {
View Full Code Here

                    long userId = rs.getLong(1);
                    RankListEntry entry = (RankListEntry) entries.get(new Long(userId));
                    if (entry == null) {
                        entry = new RankListEntry(problems.size());
                        entries.put(new Long(userId), entry);
                        UserProfile profile = new UserProfile();
                        profile.setId(userId);
                        entry.setUserProfile(profile);
                    }
                    long problemId = rs.getLong(2);
                    long judgeReplyId = rs.getLong(3);
                    int time = (int) ((rs.getTimestamp(4).getTime() - contestStartDate) / 1000 / 60);
View Full Code Here

            try {
                ps = conn.prepareStatement(sql);
                ps.setLong(1, contestId);
                ResultSet rs = ps.executeQuery();
                while (rs.next()) {
                    UserProfile user = new UserProfile();
                    user.setId(rs.getLong(1));
                    user.setHandle(rs.getString(2));
                    user.setNickName(rs.getString(3));
                    user.setDeclaration(rs.getString(4));
                    users.add(user);
                    solved.add(rs.getInt(5));
                    total.add(rs.getInt(6));
                }
            } finally {
View Full Code Here

        String email = context.getRequest().getParameter("email");
        if ((handle == null || handle.trim().length() == 0) && (email == null || email.trim().length() == 0)) {
          return this.handleSuccess(mapping, context, "success");
        }
        UserPersistence userPersistence = PersistenceManager.getInstance().getUserPersistence();
        UserProfile user = null;
       
       
        if (handle != null && handle.trim().length() > 0) {
          user = userPersistence.getUserProfileByHandle(handle);
        }
View Full Code Here

        if (errors.size() > 0) {
            return this.handleFailure(mapping, context, errors);
        }
        // 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);

        context.getRequest().setAttribute("Countries",
                                          PersistenceManager.getInstance().getUserPersistence().getAllCountries());

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

        context.setUserProfile(profile);
        context.setUserSecurity(security);
        context.setUserPreference(perference);
View Full Code Here

     * Get operator.
     *
     * @return the operator.
     */
    public String getOperator() {
        UserProfile user = this.getUserProfile();
        if (user == null) {
            return "anoymouse";
        } else {
            return user.getHandle();
        }
    }
View Full Code Here

            return forward;
        }

        long userId = Utility.parseLong(String.valueOf(context.getRequest().getParameter("userId")));
        long roleId = Utility.parseLong(String.valueOf(context.getRequest().getParameter("roleId")));
        UserProfile user = UserManager.getInstance().getUserProfile(userId);
        if (user == null) {
            return this.handleSuccess(mapping, context, "failure");
        }

        PersistenceManager.getInstance().getAuthorizationPersistence().deleteUserRole(userId, roleId);
View Full Code Here

    }

    public UserProfile getUserProfile(long userId) throws PersistenceException {
        Object key = new Long(userId);
        synchronized (this.userCache) {
            UserProfile user = this.userCache.get(key);
            if (user == null) {
                UserPersistence userPersistence = PersistenceManager.getInstance().getUserPersistence();
                user = userPersistence.getUserProfile(userId);
                this.userCache.put(key, user);
            }
View Full Code Here

        ResetPasswordForm passwordForm = (ResetPasswordForm) form;
        String code = passwordForm.getCode();

        UserPersistence userPersistence = PersistenceManager.getInstance().getUserPersistence();
        UserProfile user = null;
        if (code != null && code.trim().length() > 0) {
            user = userPersistence.getUserProfileByCode(code);
        }

        if (user == null) {
            ActionMessages messages = new ActionMessages();
            messages.add("message", new ActionMessage("onlinejudge.resetPassword.invalidCode"));
            this.saveErrors(context.getRequest(), messages);
            return this.handleSuccess(mapping, context, "message");

        }

        if (passwordForm.getPassword() == null) {
            return this.handleSuccess(mapping, context, "failure");
        }

        user.setPassword(passwordForm.getPassword());
        userPersistence.updateUserProfile(user, user.getId());
        userPersistence.deleteConfirmCode(user.getId(), user.getId());

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

TOP

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

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.