Add a view to show user movie ratings and add/update ratings.

This commit is contained in:
Camille31
2016-11-27 11:10:31 +01:00
parent 5284966d4a
commit 3afd36cb06
4 changed files with 169 additions and 1 deletions

View File

@ -14,7 +14,7 @@ public class Movie {
this.genres = genres;
}
public long getId() {
public int getId() {
return this.id;
}

View File

@ -0,0 +1,67 @@
package com.camillepradel.movierecommender.model;
import java.util.Arrays;
public class Rating {
private Movie movie;
private int userId;
private int score;
public Rating() {
this.movie = null;
this.userId = 0;
this.score = 0;
}
public Rating(Movie movie, int userId, int score) {
this.movie = movie;
this.userId = userId;
this.score = score;
}
public Rating(Movie movie, int userId) {
this.movie = movie;
this.userId = userId;
this.score = 0;
}
public Movie getMovie() {
return this.movie;
}
public void setMovie(Movie movie) {
this.movie = movie;
}
// pseudo getter and setter for movie id
// (in order to automatically serialize Rating object on form submission)
public int getMovieId() {
return this.movie.getId();
}
public void setMovieId(int movieId) {
// TODO: get movie with id movieId from database
String title = "Titre";
Genre genre0 = new Genre(0, "genre0");
Genre genre1 = new Genre(1, "genre1");
this.movie = new Movie(movieId, title, Arrays.asList(new Genre[] {genre0, genre1}));
}
public int getUserId() {
return this.userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public int getScore() {
return this.score;
}
public void setScore(int score) {
this.score = score;
}
}