Map courseDetailMap = new HashMap();
//********************************
// 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());