Package org.neo4j.cineasts.domain

Examples of org.neo4j.cineasts.domain.User


    @Autowired
    private UserRepository userRepository;

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


        return null;
    }

    @Transactional
    public User register(String login, String name, String password) {
        User found = findUser(login);
        if (found!=null) throw new RuntimeException("Login already taken: "+login);
        if (name==null || name.isEmpty()) throw new RuntimeException("No name provided.");
        if (password==null || password.isEmpty()) throw new RuntimeException("No password provided.");
        User user=userRepository.save(new User(login,name,password,User.Roles.ROLE_USER));
        setUserInSession(user);
        return user;
    }
View Full Code Here

    }

    @Transactional
    public void addFriend(String login) {
        User friend = findUser(login);
        User user = getUserFromSession();
        if (!user.equals(friend)) {
            user.addFriend(friend);
        }
    }
View Full Code Here

    @Autowired
    private UserRepository userRepository;

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

        return null;
    }

    @Transactional
    public User register(String login, String name, String password) {
        User found = findUser(login);
        if (found!=null) throw new RuntimeException("Login already taken: "+login);
        if (name==null || name.isEmpty()) throw new RuntimeException("No name provided.");
        if (password==null || password.isEmpty()) throw new RuntimeException("No password provided.");
        User user=userRepository.save(new User(login,name,password,User.Roles.ROLE_USER));
        setUserInSession(user);
        return user;
    }
View Full Code Here

    }

    @Transactional
    public void addFriend(String login) {
        User friend = findUser(login);
        User user = getUserFromSession();
        if (!user.equals(friend)) {
            user.addFriend(friend);
        }
    }
View Full Code Here

    }


    @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 = movieRepository.findById(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 = movieRepository.findById(movieId);
        User user = userDetailsService.getUserFromSession();
        userDetailsService.rate(user, movie, stars, comment);
        return singleMovieView(model,movieId);
    }
View Full Code Here

        Iterable result = user.findAllPathsByTraversal(traversal);
        Iterable<EntityPath<User,User>> friends = (Iterable<EntityPath<User,User>>)result;
        for (EntityPath<User,User> path : friends) {
            int weight = ratingDistance - path.length();
            User friend = path.endEntity();
            aggregateRatings(friend,weight);
        }
        for (Rating rating : user.getRatings()) {
            ratings.remove(rating.getMovie());
        }
View Full Code Here

        userDetailsService.rate(user, movie, stars, comment);
        return singleMovieView(model,movieId);
    }

    private User addUser(Model model) {
        User user = userDetailsService.getUserFromSession();
        model.addAttribute("user", user);
        return 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.