Package org.neo4j.cineasts.domain

Examples of org.neo4j.cineasts.domain.User



    @Override
    @Transactional
    public User register(String login, String name, String password) {
        User found = findByLogin(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=template.save(new User(login,name,password,User.Roles.ROLE_USER));
        setUserInSession(user);
        return user;
    }
View Full Code Here


    }

    @Override
    @Transactional
    public void addFriend(String friendLogin, final User user) {
        User friend = findByLogin(friendLogin);
        if (!user.equals(friend)) {
            user.addFriend(friend);
            template.save(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 = userRepository.getUserFromSession();
        model.addAttribute("user", user);
        if (user!=null) {
            model.addAttribute("recommendations", movieRepository.getRecommendations(user));
        }
        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 = userRepository.findByLogin(login);
        User user = userRepository.getUserFromSession();

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

    MovieDbImportService importService;
    private final static Logger log = LoggerFactory.getLogger(DatabasePopulator.class);

    @Transactional
    public List<Movie> populateDatabase() {
        User me = userRepository.save(new User("micha", "Micha", "password", User.Roles.ROLE_ADMIN,User.Roles.ROLE_USER));
        User ollie = new User("ollie", "Olliver", "password",User.Roles.ROLE_USER);
        me.addFriend(ollie);
        userRepository.save(me);
        List<Integer> ids = asList(19995 , 194, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 13, 20526, 11, 1893, 1892, 1894, 168, 193, 200, 157, 152, 201, 154, 12155, 58, 285, 118, 22, 392, 5255, 568, 9800, 497, 101, 120, 121, 122);
        List<Movie> result=new ArrayList<Movie>(ids.size());
        for (Integer id : ids) {
View Full Code Here

        return cineastsRepository.getMovie(id);
    }

    @RequestMapping(value = "/movies/{movieId}", method = RequestMethod.GET, headers = "Accept=text/html")
    public String singleMovieView(final Model model, @PathVariable String movieId) {
        User user = addUser(model);
        MovieRepository.MovieData movieData = cineastsRepository.getMovieData( movieId );
        model.addAttribute("id", movieId);
        if (movieData != null) {
            Movie movie = movieData.getMovie();
            model.addAttribute("movie", movie);
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 = cineastsRepository.getMovie(movieId);
        User user = userDetailsService.getUserFromSession();
        cineastsRepository.rateMovie(movie,user, stars==null ? -1 : stars,comment!=null ? comment.trim() : null);
        return singleMovieView(model,movieId);
    }
View Full Code Here

        cineastsRepository.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));
        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

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.