Add a view to show user recommendations.
This commit is contained in:
parent
3afd36cb06
commit
fb23a16374
@ -92,4 +92,36 @@ public class MainController {
|
|||||||
|
|
||||||
return "redirect:/movieratings?user_id=" + rating.getUserId();
|
return "redirect:/movieratings?user_id=" + rating.getUserId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/recommendations", method = RequestMethod.GET)
|
||||||
|
public ModelAndView ProcessRecommendations(
|
||||||
|
@RequestParam(value = "user_id", required = true) Integer userId,
|
||||||
|
@RequestParam(value = "processing_mode", required = false, defaultValue = "0") Integer processingMode){
|
||||||
|
System.out.println("GET /movieratings for user " + userId);
|
||||||
|
|
||||||
|
// TODO: process recommendations for specified user exploiting other users ratings
|
||||||
|
// use different methods depending on processingMode parameter
|
||||||
|
Genre genre0 = new Genre(0, "genre0");
|
||||||
|
Genre genre1 = new Genre(1, "genre1");
|
||||||
|
Genre genre2 = new Genre(2, "genre2");
|
||||||
|
List<Rating> recommendations = new LinkedList<Rating>();
|
||||||
|
String titlePrefix;
|
||||||
|
if (processingMode.equals(0))
|
||||||
|
titlePrefix = "0_";
|
||||||
|
else if (processingMode.equals(1))
|
||||||
|
titlePrefix = "1_";
|
||||||
|
else if (processingMode.equals(2))
|
||||||
|
titlePrefix = "2_";
|
||||||
|
else
|
||||||
|
titlePrefix = "default_";
|
||||||
|
recommendations.add(new Rating(new Movie(0, titlePrefix + "Titre 0", Arrays.asList(new Genre[] {genre0, genre1})), userId, 5));
|
||||||
|
recommendations.add(new Rating(new Movie(1, titlePrefix + "Titre 1", Arrays.asList(new Genre[] {genre0, genre2})), userId, 5));
|
||||||
|
recommendations.add(new Rating(new Movie(2, titlePrefix + "Titre 2", Arrays.asList(new Genre[] {genre1})), userId, 4));
|
||||||
|
recommendations.add(new Rating(new Movie(3, titlePrefix + "Titre 3", Arrays.asList(new Genre[] {genre0, genre1, genre2})), userId, 3));
|
||||||
|
|
||||||
|
ModelAndView mv = new ModelAndView("recommendations");
|
||||||
|
mv.addObject("recommendations", recommendations);
|
||||||
|
|
||||||
|
return mv;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
23
src/main/webapp/WEB-INF/views/recommendations.jsp
Normal file
23
src/main/webapp/WEB-INF/views/recommendations.jsp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
|
||||||
|
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
|
||||||
|
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
|
<title>Recommandations</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1>
|
||||||
|
Vos recommandations
|
||||||
|
</h1>
|
||||||
|
<ul>
|
||||||
|
<c:forEach items="${recommendations}" var="recommendation">
|
||||||
|
<li>
|
||||||
|
${recommendation.getMovie().title}
|
||||||
|
</li>
|
||||||
|
</c:forEach>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Reference in New Issue
Block a user