Package org.neo4j.cineasts.domain

Examples of org.neo4j.cineasts.domain.User


    }


    @RequestMapping(value = "/movies/{movieId}", method = RequestMethod.GET, headers = "Accept=text/html")
    public String singleMovieView(final Model model, @PathVariable String movieId) {
        User user = addUser(model);
        Movie movie = moviesRepository.getMovie(movieId);
        model.addAttribute("id", movieId);
        if (movie != null) {
            model.addAttribute("movie", movie);
            final int stars = movie.getStars();
View Full Code Here


    }

    @RequestMapping(value = "/movies/{movieId}", method = RequestMethod.POST, headers = "Accept=text/html")
    public String updateMovie(Model model, @PathVariable String movieId, @RequestParam(value = "rated",required = false) Integer stars, @RequestParam(value = "comment",required = false) String comment) {
        Movie movie = moviesRepository.getMovie(movieId);
        User user = userDetailsService.getUserFromSession();
        moviesRepository.rateMovie(movie,user, stars==null ? -1 : stars,comment!=null ? comment.trim() : null);
        return singleMovieView(model,movieId);
    }
View Full Code Here

        moviesRepository.rateMovie(movie,user, stars==null ? -1 : stars,comment!=null ? comment.trim() : null);
        return singleMovieView(model,movieId);
    }

    private User addUser(Model model) {
        User user = userDetailsService.getUserFromSession();
        model.addAttribute("user", user);
        return user;
    }
View Full Code Here

    private final static Logger logger = LoggerFactory.getLogger(UserController.class);

    @RequestMapping(value = "/user", method = RequestMethod.GET)
    public String profile(Model model) {
        final User user = userDetailsService.getUserFromSession();
        model.addAttribute("user", user);
        model.addAttribute("recommendations", repository.recommendMovies(user, 3));
        return "/user/index";
    }
View Full Code Here

    return "forward:/user/"+login;
    }

    @RequestMapping(value = "/user/{login}")
    public String publicProfile(Model model, @PathVariable("login") String login) {
        User profiled = userDetailsService.findUser(login);
        User user = userDetailsService.getUserFromSession();

        return publicProfile(model, profiled, user);
    }
View Full Code Here

    }
    @Test
    public void testGetMovieRecommendations() throws Exception {
        Movie movie = new Movie("1", "Test-Movie").persist();
        Movie movie2 = new Movie("2", "Test-Movie2").persist();
        User user=new User("me","me","me").persist();
        user.rate(movie,3,"me");
        User friend=new User("friend","friend","friend").persist();
        friend.rate(movie,5,"friend");
        friend.rate(movie2,3,"friend2");
        assertEquals(2,movieRepository.count());
        final List<MovieRecommendation> recommendations = movieRepository.getRecommendations(user);
        assertEquals("one recommendation", 1, recommendations.size());
        assertEquals("one recommendation", movie2, recommendations.get(0).getMovie());
        assertEquals("one recommendation", 3, recommendations.get(0).getRating());
View Full Code Here

        assertEquals("one recommendation", 3, recommendations.get(0).getRating());
    }
    @Test
    public void testRateMovie() throws Exception {
        Movie movie = new Movie("1", "Test-Movie").persist();
        User user=new User("me","me","me").persist();
        user.rate(movie, 5, "comment");
        final Rating rating = IteratorUtil.first(movie.getRatings());
        assertEquals("rating stars", 5, rating.getStars());
        assertEquals("rating comment", "comment", rating.getComment());
        assertEquals("rating user", user, rating.getUser());
        assertEquals("rating movie", movie, rating.getMovie());
View Full Code Here

    MovieRepository movieRepository;

    @Test
    @Ignore
    public void testBefriendUsers() {
        final User me = userRepository.save(new User("me", "me", "me"));
        final User you = userRepository.save(new User("you", "you", "you"));
        userRepository.addFriend("you", userRepository.getUserFromSession());
        final User loaded = userRepository.findOne(me.getId());
        assertEquals(1,loaded.getFriends().size());
    }
View Full Code Here

        assertEquals(1,loaded.getFriends().size());
    }

    @Test
    public void testRateMovie() {
        final User me = userRepository.save(new User("me", "me", "me"));
        final Movie movie = movieRepository.save(new Movie("1","Movie"));
        userRepository.rate(movie, me, 5, "cool");
        final User loaded = userRepository.findOne(me.getId());
        assertEquals(1,loaded.getRatings().size());
    }
View Full Code Here

    @Autowired
    private Neo4jOperations template;

    @Override
    public CineastsUserDetails loadUserByUsername(String login) throws UsernameNotFoundException, DataAccessException {
        final User user = findByLogin(login);
        if (user==null) throw new UsernameNotFoundException("Username not found: "+login);
        return new CineastsUserDetails(user);
    }
View Full Code Here

TOP

Related Classes of org.neo4j.cineasts.domain.User

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.