Package org.ops4j.pax.exam.sample2.movieimport

Examples of org.ops4j.pax.exam.sample2.movieimport.MovieDbLocalStorage


        Collection<Map<String, ?>> cast = (Collection<Map<String, ?>>) data.get("cast");
        for (Map<String, ?> entry : cast) {
            Integer id = (Integer) entry.get("id");
            String jobName = (String) entry.get("job");
            if ("Actor".equals(jobName)) {
                Actor actor = new Actor();
                actor.setId(id);
                doImportPerson(actor);
                Role role = new Role();
                role.setActor(actor);
                role.setMovie(movie);
                role.setName((String) entry.get("character"));
View Full Code Here


    @PersistenceContext
    private EntityManager em;

    public Actor findById(int id) {
        Actor actor = em.find(Actor.class, id);
        actor.getRoles();
        return actor;
    }
View Full Code Here

                role.setName((String) entry.get("character"));
                em.persist(role);
                movie.getRoles().add(role);
            }
            else if ("Director".equals(jobName)) {
                Director director = new Director();
                director.setId(id);
                director.getMovies().add(movie);
                doImportPerson(director);
                movie.setDirector(director);
            }
            else {
                logger.info("Could not add person with job {} {}", jobName, entry);
View Full Code Here

    @PersistenceContext
    private EntityManager em;

    public Movie findById(int id) {
        Movie movie = em.find(Movie.class, id);
        movie.getActors();
        movie.getRoles();
        movie.getRatings();
        return movie;
    }
View Full Code Here

        List<Movie> result = new ArrayList<Movie>(ids.size());
        for (Integer id : ids) {
            result.add(importService.importMovie(id));
        }

        final Movie movie = movieService.findById(603);
        userService.rate(micha, movie, 5, "Best of the series");
        return result;
    }
View Full Code Here

        return movies;
    }

    private String importMovieFailsafe(Integer id) {
        try {
            Movie movie = doImportMovie(id);
            return movie.getTitle();
        }
        // CHECKSTYLE:SKIP : catch all wanted
        catch (Exception e) {
            return e.getMessage();
        }
View Full Code Here

    }

    private Movie doImportMovie(Integer movieId) {
        logger.info("Importing movie " + movieId);

        Movie movie = new Movie();
        movie.setId(movieId);

        Map<String, ?> data = loadMovieData(movieId);
        if (data.containsKey("not_found")) {
            throw new RuntimeException("Data for Movie " + movieId + " not found.");
        }
View Full Code Here

        Map<String, ?> data = loadPersonData(personId);
        if (data.containsKey("not_found")) {
            throw new RuntimeException("Data for Person " + personId + " not found.");
        }
        movieDbJsonMapper.mapToPerson(data, person);
        Person persistentPerson = em.find(Person.class, person.getId());
        if (persistentPerson == null) {
            em.persist(person);
        }
    }
View Full Code Here

        em.persist(user);
        return user;
    }

    public Rating rate(User user, Movie movie, int stars, String comment) {
        Rating rating = new Rating();
        rating.setUser(user);
        rating.setMovie(movie);
        rating.setStars(stars);
        rating.setComment(comment);
        em.persist(rating);
        return rating;
    }
View Full Code Here

            String jobName = (String) entry.get("job");
            if ("Actor".equals(jobName)) {
                Actor actor = new Actor();
                actor.setId(id);
                doImportPerson(actor);
                Role role = new Role();
                role.setActor(actor);
                role.setMovie(movie);
                role.setName((String) entry.get("character"));
                em.persist(role);
                movie.getRoles().add(role);
            }
            else if ("Director".equals(jobName)) {
                Director director = new Director();
View Full Code Here

TOP

Related Classes of org.ops4j.pax.exam.sample2.movieimport.MovieDbLocalStorage

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.