Package entity

Examples of entity.Enrollment


       
        String comment;
        comment = String.valueOf(request.getParameter("comment"));
       
        EnrollmentJpaController enrollentJPAController = new EnrollmentJpaController();
        Enrollment enrollment = enrollentJPAController.findEnrollment(userID, courseID);

        boolean success = false;
       
        if (enrollment != null) {
            Comments comments = new Comments();
View Full Code Here


       
        Integer rating;
        rating = Integer.valueOf(request.getParameter("rating"));
       
        EnrollmentJpaController enrollentJPAController = new EnrollmentJpaController();
        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();
View Full Code Here

        //********************************
       
        // Second generate a list of courseIDs
        List<Integer> courseIDList = new ArrayList<Integer>();
        for (Iterator<Enrollment> it = enrollmentList.iterator(); it.hasNext();) {
            Enrollment enrollment = it.next();
            courseIDList.add(enrollment.getCourseId().getCourseId());
        }
       
        //********************************
       
        // Third generate a array list with maps containing courseIDs and their descriptions
View Full Code Here

       
        //********************************
       
        // Second get user related details
        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();) {
View Full Code Here

       
        Integer courseID;
        courseID = Integer.valueOf(request.getParameter("courseID"));
        Courses course = new Courses(courseID);
       
        Enrollment enrollment = new Enrollment();
        enrollment.setUserId(user);
        enrollment.setCourseId(course);
        enrollment.setSysdate(new Date());
       
        EnrollmentJpaController jpaController = new EnrollmentJpaController();
        jpaController.create(enrollment);
               
        try {
View Full Code Here

        // First get all comments of the course
        EnrollmentJpaController enrollmentJpaController = new EnrollmentJpaController();
        List<Enrollment> enrollmentList = enrollmentJpaController.findEnrollmentEntitiesWithCourseID(courseID);
        List<Comments> commentsList = new ArrayList<Comments>();
        for (Iterator<Enrollment> it = enrollmentList.iterator(); it.hasNext();) {
            Enrollment tempEnrollment = it.next();
            if (tempEnrollment.getCommentsList() != null) {
                commentsList.addAll(tempEnrollment.getCommentsList());
            }
        }

        //********************************
       
View Full Code Here

        return "courseDetail";
    }
   
    public void enrollCourse()
    {
        Enrollment enrollment = new Enrollment();
        enrollment.setUserId(user);
        enrollment.setCourseId(course);
        enrollment.setSysdate(new Date());
       
        try {    
       
        EnrollmentJpaController jpaController = new EnrollmentJpaController();
        jpaController.create(enrollment);
View Full Code Here

         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);
         Enrollment tempEnroll = new Enrollment();
         tempEnroll.setCourseId(tempCourse);
         tempEnroll.setSysdate(new SimpleDateFormat("MM/dd/yy").parse("01/10/02"));
         tempEnroll.setUserId(tempUser);
         // add to list of user's enrollment list
         enrollList.add(tempEnroll);        
         tempUser.setEnrollmentList(enrollList);
        
         em.getTransaction().begin();
View Full Code Here

        return emf.createEntityManager();
    }

    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.");
            }
        }
        if (illegalOrphanMessages != null) {
            throw new IllegalOrphanException(illegalOrphanMessages);
        }
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Enrollment enrollment = courserates.getEnrollment();
            if (enrollment != null) {
                enrollment = em.getReference(enrollment.getClass(), enrollment.getId());
                courserates.setEnrollment(enrollment);
            }
            em.persist(courserates);
            if (enrollment != null) {
                enrollment.setCourserates(courserates);
                enrollment = em.merge(enrollment);
            }
            em.getTransaction().commit();
        } catch (Exception ex) {
            if (findCourserates(courserates.getId()) != null) {
View Full Code Here

        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.");
                }
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            if (enrollmentNew != null) {
                enrollmentNew = em.getReference(enrollmentNew.getClass(), enrollmentNew.getId());
                courserates.setEnrollment(enrollmentNew);
            }
            courserates = em.merge(courserates);
            if (enrollmentOld != null && !enrollmentOld.equals(enrollmentNew)) {
                enrollmentOld.setCourserates(null);
                enrollmentOld = em.merge(enrollmentOld);
            }
            if (enrollmentNew != null && !enrollmentNew.equals(enrollmentOld)) {
                enrollmentNew.setCourserates(courserates);
                enrollmentNew = em.merge(enrollmentNew);
            }
            em.getTransaction().commit();
        } catch (Exception ex) {
            String msg = ex.getLocalizedMessage();
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.