Package entity

Examples of entity.Enrollment


                courserates = em.getReference(Courserates.class, id);
                courserates.getId();
            } catch (EntityNotFoundException enfe) {
                throw new NonexistentEntityException("The courserates with id " + id + " no longer exists.", enfe);
            }
            Enrollment enrollment = courserates.getEnrollment();
            if (enrollment != null) {
                enrollment.setCourserates(null);
                enrollment = em.merge(enrollment);
            }
            em.remove(courserates);
            em.getTransaction().commit();
        } finally {
View Full Code Here


            Commentrates commentrates = comments.getCommentrates();
            if (commentrates != null) {
                commentrates = em.getReference(commentrates.getClass(), commentrates.getId());
                comments.setCommentrates(commentrates);
            }
            Enrollment enrollmentId = comments.getEnrollmentId();
            if (enrollmentId != null) {
                enrollmentId = em.getReference(enrollmentId.getClass(), enrollmentId.getId());
                comments.setEnrollmentId(enrollmentId);
            }
            em.persist(comments);
            if (commentrates != null) {
                Comments oldCommentsOfCommentrates = commentrates.getComments();
                if (oldCommentsOfCommentrates != null) {
                    oldCommentsOfCommentrates.setCommentrates(null);
                    oldCommentsOfCommentrates = em.merge(oldCommentsOfCommentrates);
                }
                commentrates.setComments(comments);
                commentrates = em.merge(commentrates);
            }
            if (enrollmentId != null) {
                enrollmentId.getCommentsList().add(comments);
                enrollmentId = em.merge(enrollmentId);
            }
            em.getTransaction().commit();
        } finally {
            if (em != null) {
View Full Code Here

            em = getEntityManager();
            em.getTransaction().begin();
            Comments persistentComments = em.find(Comments.class, comments.getId());
            Commentrates commentratesOld = persistentComments.getCommentrates();
            Commentrates commentratesNew = comments.getCommentrates();
            Enrollment enrollmentIdOld = persistentComments.getEnrollmentId();
            Enrollment enrollmentIdNew = comments.getEnrollmentId();
            List<String> illegalOrphanMessages = null;
            if (commentratesOld != null && !commentratesOld.equals(commentratesNew)) {
                if (illegalOrphanMessages == null) {
                    illegalOrphanMessages = new ArrayList<String>();
                }
                illegalOrphanMessages.add("You must retain Commentrates " + commentratesOld + " since its comments field is not nullable.");
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            if (commentratesNew != null) {
                commentratesNew = em.getReference(commentratesNew.getClass(), commentratesNew.getId());
                comments.setCommentrates(commentratesNew);
            }
            if (enrollmentIdNew != null) {
                enrollmentIdNew = em.getReference(enrollmentIdNew.getClass(), enrollmentIdNew.getId());
                comments.setEnrollmentId(enrollmentIdNew);
            }
            comments = em.merge(comments);
            if (commentratesNew != null && !commentratesNew.equals(commentratesOld)) {
                Comments oldCommentsOfCommentrates = commentratesNew.getComments();
                if (oldCommentsOfCommentrates != null) {
                    oldCommentsOfCommentrates.setCommentrates(null);
                    oldCommentsOfCommentrates = em.merge(oldCommentsOfCommentrates);
                }
                commentratesNew.setComments(comments);
                commentratesNew = em.merge(commentratesNew);
            }
            if (enrollmentIdOld != null && !enrollmentIdOld.equals(enrollmentIdNew)) {
                enrollmentIdOld.getCommentsList().remove(comments);
                enrollmentIdOld = em.merge(enrollmentIdOld);
            }
            if (enrollmentIdNew != null && !enrollmentIdNew.equals(enrollmentIdOld)) {
                enrollmentIdNew.getCommentsList().add(comments);
                enrollmentIdNew = em.merge(enrollmentIdNew);
            }
            em.getTransaction().commit();
        } catch (Exception ex) {
            String msg = ex.getLocalizedMessage();
View Full Code Here

                illegalOrphanMessages.add("This Comments (" + comments + ") cannot be destroyed since the Commentrates " + commentratesOrphanCheck + " in its commentrates field has a non-nullable comments field.");
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            Enrollment enrollmentId = comments.getEnrollmentId();
            if (enrollmentId != null) {
                enrollmentId.getCommentsList().remove(comments);
                enrollmentId = em.merge(enrollmentId);
            }
            em.remove(comments);
            em.getTransaction().commit();
        } finally {
View Full Code Here

                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);
            }
            for (Comments commentsListComments : enrollment.getCommentsList()) {
                Enrollment oldEnrollmentIdOfCommentsListComments = commentsListComments.getEnrollmentId();
                commentsListComments.setEnrollmentId(enrollment);
                commentsListComments = em.merge(commentsListComments);
                if (oldEnrollmentIdOfCommentsListComments != null) {
                    oldEnrollmentIdOfCommentsListComments.getCommentsList().remove(commentsListComments);
                    oldEnrollmentIdOfCommentsListComments = em.merge(oldEnrollmentIdOfCommentsListComments);
                }
            }
            em.getTransaction().commit();
        } finally {
View Full Code Here

    public void edit(Enrollment enrollment) throws IllegalOrphanException, NonexistentEntityException, Exception {
        EntityManager em = null;
        try {
            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);
            }
            if (courseIdNew != null && !courseIdNew.equals(courseIdOld)) {
                courseIdNew.getEnrollmentList().add(enrollment);
                courseIdNew = em.merge(courseIdNew);
            }
            for (Comments commentsListNewComments : commentsListNew) {
                if (!commentsListOld.contains(commentsListNewComments)) {
                    Enrollment oldEnrollmentIdOfCommentsListNewComments = commentsListNewComments.getEnrollmentId();
                    commentsListNewComments.setEnrollmentId(enrollment);
                    commentsListNewComments = em.merge(commentsListNewComments);
                    if (oldEnrollmentIdOfCommentsListNewComments != null && !oldEnrollmentIdOfCommentsListNewComments.equals(enrollment)) {
                        oldEnrollmentIdOfCommentsListNewComments.getCommentsList().remove(commentsListNewComments);
                        oldEnrollmentIdOfCommentsListNewComments = em.merge(oldEnrollmentIdOfCommentsListNewComments);
                    }
                }
            }
           
View Full Code Here

    public void destroy(Integer id) throws IllegalOrphanException, NonexistentEntityException {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Enrollment enrollment;
            try {
                enrollment = em.getReference(Enrollment.class, id);
                enrollment.getId();
            } catch (EntityNotFoundException enfe) {
                throw new NonexistentEntityException("The enrollment with id " + id + " no longer exists.", enfe);
            }
            List<String> illegalOrphanMessages = null;
            Courserates courseratesOrphanCheck = enrollment.getCourserates();
            if (courseratesOrphanCheck != null) {
                if (illegalOrphanMessages == null) {
                    illegalOrphanMessages = new ArrayList<String>();
                }
                illegalOrphanMessages.add("This Enrollment (" + enrollment + ") cannot be destroyed since the Courserates " + courseratesOrphanCheck + " in its courserates field has a non-nullable enrollment field.");
            }
            List<Comments> commentsListOrphanCheck = enrollment.getCommentsList();
            for (Comments commentsListOrphanCheckComments : commentsListOrphanCheck) {
                if (illegalOrphanMessages == null) {
                    illegalOrphanMessages = new ArrayList<String>();
                }
                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);
                courseId = em.merge(courseId);
            }
            em.remove(enrollment);
View Full Code Here

    public List<Enrollment> findEnrollmentEntitiesWithUserID(Integer userID) {
        List<Enrollment> enrollmentList = findEnrollmentEntities();
        List<Enrollment> resultList = new ArrayList<Enrollment>();
       
        for (Iterator<Enrollment> it = enrollmentList.iterator(); it.hasNext();) {
            Enrollment enrollment = it.next();
            if (enrollment.getUserId().getId().equals(userID)) {
                resultList.add(enrollment);
            }
        }
        return resultList;
    }
View Full Code Here

        public List<Enrollment> findEnrollmentEntitiesWithCourseID(Integer courseID) {
        List<Enrollment> enrollmentList = findEnrollmentEntities();
        List<Enrollment> resultList = new ArrayList<Enrollment>();
       
        for (Iterator<Enrollment> it = enrollmentList.iterator(); it.hasNext();) {
            Enrollment enrollment = it.next();
            if (enrollment.getCourseId().getCourseId().equals(courseID)) {
                resultList.add(enrollment);
            }
        }
        return resultList;
    }
View Full Code Here

    }
   
    public Enrollment findEnrollment(Integer userID, Integer courseID) {
        List<Enrollment> enrollmentList = findEnrollmentEntities();
        for (Iterator<Enrollment> it = enrollmentList.iterator(); it.hasNext();) {
            Enrollment enrollment = it.next();
            if (enrollment.getUserId().getId().equals(userID) && enrollment.getCourseId().getCourseId().equals(courseID)) {
                return enrollment;
            }
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of entity.Enrollment

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.