Package entity

Examples of entity.User


    public User getUser() {
        if(user == null) {
            user = (User)JsfUtil.getObjectFromRequestParameter("jsfcrud.currentUser", converter, null);
        }
        if(user == null) {
            user = new User();
        }
        return user;
    }
View Full Code Here


    public String getAsString(FacesContext context, UIComponent component, Object value) {
        if (value == null) {
            return null;
        }
        if (value instanceof User) {
            User o = (User) value;
            return o.getId() == null ? "" : o.getId().toString();
        } else {
            throw new IllegalArgumentException("object " + value + " is of type " + value.getClass().getName() + "; expected type: entity.User");
        }
    }   
View Full Code Here

    private static final String PERSISTENCEUNITNAME = "EducationXPU";
    private EntityManagerFactory emf;
    private EntityManager em;
   
    public UserTest() throws ParseException {
        this.s1 = new User("anakin", "anakin@skywalker.net", "24ewRTtr", 'S', 500, new SimpleDateFormat("MM/dd/yy").parse("05/18/05"));
        this.s2 = new User("luke", "luke@skywalker.net", "42eeRTew", 'S', 250, new SimpleDateFormat("MM/dd/yy").parse("05/18/05"));
    }
View Full Code Here

   
    @Test
    public void testDeleteUsersWithPrimaryKey(){
        em.getTransaction().begin();        
        // primary key
        User s1 = em.find(User.class, 11);    
        em.remove(s1);       
        em.getTransaction().commit();               
    }
View Full Code Here

        Assert.assertTrue(cnt > 0);
    }
   
    @Test
    public void testUserPasswordInvalidLength() {
        User user = new User();
        user.setPassword("xxaa1");
        Assert.fail("User password must be at least 6 characters in length");
    }
View Full Code Here

        }
    } 

    @Test
    public void testUserEnrollment() throws ParseException {
         tempUser = new User("anakin", "anakin@skywalker.net", "24ewRTtr", 'S', 500, new SimpleDateFormat("MM/dd/yy").parse("05/18/05"));
         List<Enrollment> enrollList = new ArrayList<Enrollment>();
        
         // create courses and add to enroll list of temp user;                      
         Courses tempCourse = new Courses("testClass with john lennon", 'A', "How to play guitar without pick", new SimpleDateFormat("MM/dd/yy").parse("05/18/05"));      
         tempCourse.setCreaterUserId(tempUser);
View Full Code Here

    // tempUser's primaryId will be needed to delete user and it's associative entities; enrollment and courses entities.       
    private void removeTestData() {
        primaryId = Integer.parseInt(emf.getPersistenceUnitUtil().getIdentifier(tempUser).toString());            
        em.getTransaction().begin();    
        User user = em.find(User.class, primaryId);
        if (user != null) {
            em.remove(user);
        }
        em.getTransaction().commit();
    }
View Full Code Here

            Courserates courserates = enrollment.getCourserates();
            if (courserates != null) {
                courserates = em.getReference(courserates.getClass(), courserates.getId());
                enrollment.setCourserates(courserates);
            }
            User userId = enrollment.getUserId();
            if (userId != null) {
                userId = em.getReference(userId.getClass(), userId.getId());
                enrollment.setUserId(userId);
            }
            Courses courseId = enrollment.getCourseId();
            if (courseId != null) {
                courseId = em.getReference(courseId.getClass(), courseId.getCourseId());
                enrollment.setCourseId(courseId);
            }
            List<Comments> attachedCommentsList = new ArrayList<Comments>();
            for (Comments commentsListCommentsToAttach : enrollment.getCommentsList()) {
                commentsListCommentsToAttach = em.getReference(commentsListCommentsToAttach.getClass(), commentsListCommentsToAttach.getId());
                attachedCommentsList.add(commentsListCommentsToAttach);
            }
            enrollment.setCommentsList(attachedCommentsList);
            em.persist(enrollment);
            if (courserates != null) {
                Enrollment oldEnrollmentOfCourserates = courserates.getEnrollment();
                if (oldEnrollmentOfCourserates != null) {
                    oldEnrollmentOfCourserates.setCourserates(null);
                    oldEnrollmentOfCourserates = em.merge(oldEnrollmentOfCourserates);
                }
                courserates.setEnrollment(enrollment);
                courserates = em.merge(courserates);
            }
            if (userId != null) {
                userId.getEnrollmentList().add(enrollment);
                userId = em.merge(userId);
            }
            if (courseId != null) {
                courseId.getEnrollmentList().add(enrollment);
                courseId = em.merge(courseId);
View Full Code Here

            em = getEntityManager();
            em.getTransaction().begin();
            Enrollment persistentEnrollment = em.find(Enrollment.class, enrollment.getId());
            Courserates courseratesOld = persistentEnrollment.getCourserates();
            Courserates courseratesNew = enrollment.getCourserates();
            User userIdOld = persistentEnrollment.getUserId();
            User userIdNew = enrollment.getUserId();
            Courses courseIdOld = persistentEnrollment.getCourseId();
            Courses courseIdNew = enrollment.getCourseId();
            List<Comments> commentsListOld = persistentEnrollment.getCommentsList();
            List<Comments> commentsListNew = enrollment.getCommentsList();
            List<String> illegalOrphanMessages = null;
            if (courseratesOld != null && !courseratesOld.equals(courseratesNew)) {
                if (illegalOrphanMessages == null) {
                    illegalOrphanMessages = new ArrayList<String>();
                }
                illegalOrphanMessages.add("You must retain Courserates " + courseratesOld + " since its enrollment field is not nullable.");
            }
            for (Comments commentsListOldComments : commentsListOld) {
                if (!commentsListNew.contains(commentsListOldComments)) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("You must retain Comments " + commentsListOldComments + " since its enrollmentId field is not nullable.");
                }
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            if (courseratesNew != null) {
                courseratesNew = em.getReference(courseratesNew.getClass(), courseratesNew.getId());
                enrollment.setCourserates(courseratesNew);
            }
            if (userIdNew != null) {
                userIdNew = em.getReference(userIdNew.getClass(), userIdNew.getId());
                enrollment.setUserId(userIdNew);
            }
            if (courseIdNew != null) {
                courseIdNew = em.getReference(courseIdNew.getClass(), courseIdNew.getCourseId());
                enrollment.setCourseId(courseIdNew);
            }
            List<Comments> attachedCommentsListNew = new ArrayList<Comments>();
            for (Comments commentsListNewCommentsToAttach : commentsListNew) {
                commentsListNewCommentsToAttach = em.getReference(commentsListNewCommentsToAttach.getClass(), commentsListNewCommentsToAttach.getId());
                attachedCommentsListNew.add(commentsListNewCommentsToAttach);
            }
            commentsListNew = attachedCommentsListNew;
            enrollment.setCommentsList(commentsListNew);
            enrollment = em.merge(enrollment);
            if (courseratesNew != null && !courseratesNew.equals(courseratesOld)) {
                Enrollment oldEnrollmentOfCourserates = courseratesNew.getEnrollment();
                if (oldEnrollmentOfCourserates != null) {
                    oldEnrollmentOfCourserates.setCourserates(null);
                    oldEnrollmentOfCourserates = em.merge(oldEnrollmentOfCourserates);
                }
                courseratesNew.setEnrollment(enrollment);
                courseratesNew = em.merge(courseratesNew);
            }
            if (userIdOld != null && !userIdOld.equals(userIdNew)) {
                userIdOld.getEnrollmentList().remove(enrollment);
                userIdOld = em.merge(userIdOld);
            }
            if (userIdNew != null && !userIdNew.equals(userIdOld)) {
                userIdNew.getEnrollmentList().add(enrollment);
                userIdNew = em.merge(userIdNew);
            }
            if (courseIdOld != null && !courseIdOld.equals(courseIdNew)) {
                courseIdOld.getEnrollmentList().remove(enrollment);
                courseIdOld = em.merge(courseIdOld);
View Full Code Here

                illegalOrphanMessages.add("This Enrollment (" + enrollment + ") cannot be destroyed since the Comments " + commentsListOrphanCheckComments + " in its commentsList field has a non-nullable enrollmentId field.");
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            User userId = enrollment.getUserId();
            if (userId != null) {
                userId.getEnrollmentList().remove(enrollment);
                userId = em.merge(userId);
            }
            Courses courseId = enrollment.getCourseId();
            if (courseId != null) {
                courseId.getEnrollmentList().remove(enrollment);
View Full Code Here

TOP

Related Classes of entity.User

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.