Package entity

Examples of entity.Courserates


        Enrollment enrollment = enrollentJPAController.findEnrollment(userID, courseID);
       
        boolean success = false;
       
        if (enrollment != null) {
            Courserates courseRates = new Courserates();
            courseRates.setId(enrollment.getId());
            courseRates.setPoints(rating);
            courseRates.setSysdate(new Date());
            courseRates.setEnrollment(enrollment);
           
            CourseratesJpaController courseratesJPAController = new CourseratesJpaController();
            try {
                courseratesJPAController.create(courseRates);
                success = true;
View Full Code Here


        EnrollmentJpaController enrollmentJpaController = new EnrollmentJpaController();
        Enrollment enrollment = enrollmentJpaController.findEnrollment(userID, courseID);
       
        if (enrollment != null) {
            courseDetailMap.put("userEnrolled", Boolean.TRUE);
            Courserates courseRate = enrollment.getCourserates();
           
            if (courseRate != null) {
                courseDetailMap.put("userRated", Boolean.TRUE);
                courseDetailMap.put("userRatePoint", new Integer(courseRate.getPoints()));
            } else {
                courseDetailMap.put("userRated", Boolean.FALSE);
                courseDetailMap.put("userRatePoint", new Integer(-1));
            }
           
        } else {
            courseDetailMap.put("userEnrolled", Boolean.FALSE);
            courseDetailMap.put("userRated", Boolean.FALSE);
            courseDetailMap.put("userRatePoint", new Integer(-1));
        }
       
        //********************************
       
        // Third get basic course details
        CoursesJpaController coursesJpaController = new CoursesJpaController();
        Courses course = coursesJpaController.findCourses(courseID);
       
        courseDetailMap.put("courseID", new Integer(courseID));
        courseDetailMap.put("courseName", new String(course.getName()));
        courseDetailMap.put("courseDescription", new String(course.getDescription()));
        courseDetailMap.put("courseCreatorName", new String(course.getCreaterUserId().getName()));
       
        //********************************
       
        // Forth get rating
        List<Enrollment> enrollmentList = enrollmentJpaController.findEnrollmentEntitiesWithCourseID(courseID);
        List<Courserates> courseRatesList = new ArrayList<Courserates>();
        for (Iterator<Enrollment> it = enrollmentList.iterator(); it.hasNext();) {
            Enrollment tempEnrollment = it.next();
            if (tempEnrollment.getCourserates() != null) {
                courseRatesList.add(tempEnrollment.getCourserates());
            }
        }
       
        Float totalRating = 0.f;
        for (Iterator<Courserates> it = courseRatesList.iterator(); it.hasNext();) {
            Courserates tempCourseRate = it.next();
            totalRating += tempCourseRate.getPoints().floatValue();
        }
        if (!courseRatesList.isEmpty()) {
            totalRating /= courseRatesList.size();
        }
       
View Full Code Here

    public void create(Courserates courserates) throws IllegalOrphanException, PreexistingEntityException, Exception {
        List<String> illegalOrphanMessages = null;
        Enrollment enrollmentOrphanCheck = courserates.getEnrollment();
        if (enrollmentOrphanCheck != null) {
            Courserates oldCourseratesOfEnrollment = enrollmentOrphanCheck.getCourserates();
            if (oldCourseratesOfEnrollment != null) {
                if (illegalOrphanMessages == null) {
                    illegalOrphanMessages = new ArrayList<String>();
                }
                illegalOrphanMessages.add("The Enrollment " + enrollmentOrphanCheck + " already has an item of type Courserates whose enrollment column cannot be null. Please make another selection for the enrollment field.");
View Full Code Here

    public void edit(Courserates courserates) throws IllegalOrphanException, NonexistentEntityException, Exception {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Courserates persistentCourserates = em.find(Courserates.class, courserates.getId());
            Enrollment enrollmentOld = persistentCourserates.getEnrollment();
            Enrollment enrollmentNew = courserates.getEnrollment();
            List<String> illegalOrphanMessages = null;
            if (enrollmentNew != null && !enrollmentNew.equals(enrollmentOld)) {
                Courserates oldCourseratesOfEnrollment = enrollmentNew.getCourserates();
                if (oldCourseratesOfEnrollment != null) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("The Enrollment " + enrollmentNew + " already has an item of type Courserates whose enrollment column cannot be null. Please make another selection for the enrollment field.");
View Full Code Here

    public void destroy(Integer id) throws NonexistentEntityException {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Courserates courserates;
            try {
                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);
View Full Code Here

        }
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            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);
View Full Code Here

        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);
View Full Code Here

                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.");
View Full Code Here

TOP

Related Classes of entity.Courserates

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.