Commit 8321995e authored by kpandey's avatar kpandey

Updated courseService by adding trending courses in getCourse method and...

Updated courseService by adding trending courses in getCourse method and change in service path instead of course/all path will be course

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@199952 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c3ba8d6f
......@@ -153,7 +153,7 @@ public class CourseAPIService
//For getting All Course Details
@GET
@Path("/course/all")
@Path("/course")
@Produces(MediaType.APPLICATION_JSON)
public Response getAllCourses(@QueryParam("USER_INFO") String userInfoStr) throws Exception
{
......@@ -190,6 +190,8 @@ public class CourseAPIService
courseMap.put(course.getCourseCode() ,course);
}
JSONArray courseArray = courseDao.getUserCourseData(courseMap, courseCodeList);
JSONArray trendingCourseArray = courseDao.getCourseTrendingData(courseCodeList);
respJsonObject.put("trending-courses", trendingCourseArray );
respJsonObject.put("courses", courseArray );
respJsonObject.put("result", getResponseMessage("Data Loaded Successfully ! ","Success") );
}
......@@ -347,6 +349,74 @@ public class CourseAPIService
return srvUserInfoObj.toString();
}
//For getting All Trending Course Details
@GET
@Path("/course/trendings")
@Produces(MediaType.APPLICATION_JSON)
public Response getTrendingCourses(@QueryParam("USER_INFO") String userInfoStr) throws Exception
{
BaseLogger.log("3",null,null,"Inside getTrendingCourses of CourseApiService");
System.out.println("Inside getTrendingCourses of CourseApiService");
JSONObject respJsonObject = new JSONObject();
try
{
System.out.println("Inside Try of getTrendingCourses of CourseApiService");
UserInfoBean userInfo = null;
if(userInfoStr != null)
{
BaseLogger.log("3",null,null,"userInfoStr :: "+userInfoStr);
userInfo = new UserInfoBean(userInfoStr);
}
else
{
userInfo = getUserInfo();
}
if( userInfo != null )
{
System.out.println("Inside if when userInfo is not null of getTrendingCourses of CourseApiService");
CourseDAO courseDao = new CourseDAO();
courseDao.setUserInfo(userInfo);
List<Course> courseList = courseDao.getCourses();
BaseLogger.log("3",null,null,"courseList :: "+courseList);
if( courseList != null && !courseList.isEmpty() )
{
System.out.println("Inside if when courseList is not null of getTrendingCourses of CourseApiService");
List<String> courseCodeList = new ArrayList<String>();
for(Course course : courseList)
{
courseCodeList.add(course.getCourseCode());
}
JSONArray courseArray = courseDao.getCourseTrendingData(courseCodeList);
respJsonObject.put("courses", courseArray );
respJsonObject.put("result", getResponseMessage("Data Loaded Successfully ! ","Success") );
}
else
{
respJsonObject.put("courses", new JSONArray() );
respJsonObject.put("result", getResponseMessage("No Data Found ! ","Success") );
}
}
else
{
respJsonObject.put("result", getResponseMessage("Unauthorised Access Denied ! ","Failure"));
}
}
catch (JSONException e)
{
e.printStackTrace();
}
catch (BaseException e)
{
e.printStackTrace();
}
return Response.status(200).entity(respJsonObject.toString()).build();
}
/*
//Unused
//For getting Single Course Details
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment