public void updateMovie() { Movie m = em.find(Movie.class, 3, LockModeType.PESSIMISTIC_WRITE); em.lock(m, LockModeType.PESSIMISTIC_WRITE); m.setName("INCEPTION"); em.merge(m); em.flush(); }
private static void testGetMovieInformation() { String[][] m = getMovieListInformation(parseMoviesHTML(formatString("harry potter"))); ArrayList<Movie> ar = getMovieInformation(m); for (Movie t : ar) { System.out.println(t.toString()); } }
public static void main(String[] args) { String host = args[0]; int port = Integer.parseInt(args[1]); long id = Long.parseLong(args[2]); String character = args[3]; long actorId = Long.parseLong(args[4]); // Install an RMISecurityManager, if there is not a // SecurityManager already installed if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } String name = "rmi://" + host + ":" + port + "/MovieDatabase"; try { MovieDatabase db = (MovieDatabase) Naming.lookup(name); db.noteCharacter(id, character, actorId); Movie movie = db.getMovie(id); out.println(movie.getTitle()); for (Map.Entry entry : movie.getCharacters().entrySet()) { out.println(" " + entry.getKey() + "\t" + entry.getValue()); } } catch (RemoteException | NotBoundException | MalformedURLException ex) { ex.printStackTrace(System.err); } }
private void updateMetadata(final Movie movie) { final MediaMetadata.Builder metadataBuilder = new MediaMetadata.Builder(); String title = movie.getTitle().replace("_", " -"); metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_TITLE, title); metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_SUBTITLE, movie.getDescription()); metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_ICON_URI, movie.getCardImageUrl()); // And at minimum the title and artist for legacy support metadataBuilder.putString(MediaMetadata.METADATA_KEY_TITLE, title); metadataBuilder.putString(MediaMetadata.METADATA_KEY_ARTIST, movie.getStudio()); Glide.with(this) .load(Uri.parse(movie.getCardImageUrl())) .asBitmap() .into( new SimpleTarget<Bitmap>(500, 500) { @Override public void onResourceReady(Bitmap bitmap, GlideAnimation anim) { metadataBuilder.putBitmap(MediaMetadata.METADATA_KEY_ART, bitmap); mSession.setMetadata(metadataBuilder.build()); } }); }
private static void loadMovies(String filename) { FirstRatings fr = new FirstRatings(); ArrayList<Movie> list = fr.loadMovies(filename); for (Movie m : list) { ourMovies.put(m.getID(), m); } }
public Movie createMovie(final String title, final int year) { final Movie movie = new Movie().persist(); movie.setTitle(title); movie.setYear(year); searchEngine.indexMovie(movie); return movie; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_movie_screen); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); Intent intent = getIntent(); int moviePosition = intent.getIntExtra(MovieListAdapter.MOVIE_POSITION, 0); currentMovie = LocalStore.getMovies().get(moviePosition); TextView movieTitle = (TextView) findViewById(R.id.movieTitle); TextView movieGenre = (TextView) findViewById(R.id.movieGenre); TextView movieDescr = (TextView) findViewById(R.id.movieDescription); movieTitle.setText(currentMovie.getTitle()); // movieGenre.setText(currentMovie.get); movieDescr.setText(((Integer) currentMovie.getYear()).toString()); // implement viewList of reviews Button addRating = (Button) findViewById(R.id.addRatingButton); addRating.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { review(currentMovie.getId()); } }); }
public void addMovieTx(Integer id, String director, String title, String synopsis) { Movie movie = new Movie(); movie.setId(id); movie.setDirector(director); movie.setTitle(title); movie.setSynopsis(synopsis); Movie movie0 = new Movie(); movie0.setId(101); movie0.setDirector("d"); movie0.setTitle("t"); movie0.setSynopsis("s"); Session session = sf.getCurrentSession(); org.hibernate.Transaction tx = session.beginTransaction(); try { session.save(movie0); session.save(movie); tx.commit(); } catch (HibernateException e) { System.out.println("Caught an hibernate exception."); if (tx != null) { System.out.println("Rolling back the transaction."); tx.rollback(); } } }
private static String getTrailer(Movie movie) { String trailerLink = ""; if (Integer.valueOf(movie.getMovieYear()) < 1990) { trailerLink = "null"; } else { trailerLink += "http://www.youtube.com"; String link = formatYoutubeString(movie.getMovieName()); try { Document d = Jsoup.connect("http://www.youtube.com/" + link).get(); Element e = d.body(); String html = e.toString(); String linkDiv = ""; int max = html.indexOf("class=\"yt-lockup-title \"><a href=\"") + 100; for (int i = html.indexOf("class=\"yt-lockup-title \"><a href=\""); i < max; i++) { linkDiv += html.charAt(i); } for (int i = linkDiv.indexOf("<a href=\"") + 9; i < linkDiv.indexOf("class=\"yt-uix-sessionlink") - 2; i++) { trailerLink += linkDiv.charAt(i); } } catch (Exception e) { System.out.println(e.toString()); } } return trailerLink; }
@SuppressWarnings("unused") private Movie stubMovie(final String mlId) { Movie stub = new Movie(); stub.setMlId(mlId); stub.setTitle("Interesting...the wrong title. Sssshhhh!"); return stub; }
@Override public void onStart() { super.onStart(); if (mMovie != null) { new FetchTrailersTask().execute(Integer.toString(mMovie.getId())); new FetchReviewsTask().execute(Integer.toString(mMovie.getId())); } }
public Movie getMovieById(String imdb_id) { for (Movie movie : movies) { if (movie.getIMDBCode().equals(imdb_id)) { return movie; } } return null; }
public Movie getMovieByTitle(String title) { for (Movie movie : movies) { if (movie.getTitle().equals(title)) { return movie; } } return null; }
@Override public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; ImageHolder holder = null; // מחזיק שורה if (row == null) { // מקשרים לתצוגה LayoutInflater inflater = ((Activity) context).getLayoutInflater(); // קישור לשורה בקמל row = inflater.inflate(R.layout.row_movie_search, parent, false); // המחזיק אליו פונים לשני המקומות holder = new ImageHolder(); // בשביל הטקסט holder.ObjectName = (TextView) row.findViewById(R.id.textViewnamemovie); holder.ObjectId = (TextView) row.findViewById(R.id.textViewidmovie); // בשביל הפונוט Typeface font = Typeface.createFromAsset(getContext().getAssets(), "fonts/CinzelDecorative-Regular.ttf"); holder.ObjectName.setTypeface(font); // Objectliner בשביל צבע שורה holder.Objectliner = (LinearLayout) row.findViewById(R.id.LinearLayoutrow); // כל שורה זוגית נצבע בלבן if (position % 2 == 0) { holder.Objectliner.setBackgroundColor(0xffffffff); } // בשביל התמונה holder.Objectimage = (ImageView) row.findViewById(R.id.imageViewpic); row.setTag(holder); } else { holder = (ImageHolder) row.getTag(); } // לתמונה מהקלאס ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).build(); ImageLoader.getInstance().init(config); DisplayImageOptions option = new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisc(true).build(); // קישור לתוכן Movie movie = ListObject.get(position); holder.ObjectName.setText(movie.getSubject()); holder.ObjectId.setText(movie.getMovieid()); // בשביל התמונה ImageLoader.getInstance().displayImage(movie.getUrlImage(), holder.Objectimage, option); // לאנמציה Animation animation = AnimationUtils.loadAnimation(context, R.anim.push_left_in); row.startAnimation(animation); return row; }
@Override protected void onBindDescription(ViewHolder viewHolder, Object item) { Movie movie = (Movie) item; if (movie != null) { viewHolder.getTitle().setText(movie.getTitle()); viewHolder.getSubtitle().setText(movie.getStudio()); viewHolder.getBody().setText(movie.getDescription()); } }
public Copy getSpecificCopy(String title, String format) { Movie movie = movieSystem.getMovie(title); Copy onecopy = null; for (Copy copy : movie.getCopies()) { if (copy.getFormat().equals(format) && copy.getStatus().equals(Copy.UNRENT)) { onecopy = copy; } } return onecopy; }
private void extractListFromJSON(String jsonStr) { try { moviesList.clear(); JSONObject moviesJson = new JSONObject(jsonStr); JSONArray moviesArray = moviesJson.getJSONArray("results"); for (int i = 0; i < moviesArray.length(); i++) { Movie tempMovie = new Movie(); JSONObject jo = moviesArray.getJSONObject(i); tempMovie.setTitle(jo.getString(getString(R.string.ORIGIONAL_TITLE_PARAM))); tempMovie.setId(jo.getString(getString(R.string.ID))); tempMovie.setPoster_Location(jo.getString(getString(R.string.POSTER_PATH_PARAM))); tempMovie.setBackdrop_path(jo.getString(getString(R.string.BACKDROP_PATH_PARAM))); tempMovie.setOverview(jo.getString(getString(R.string.OVERVIEW_PARAM))); tempMovie.setRelease_Date(jo.getString(getString(R.string.RELEASE_DATE_PARAM))); tempMovie.setRating(jo.getString(getString(R.string.RATING_PARAM))); tempMovie.setPopularity(jo.getString(getString(R.string.POPULARITY_PARAM))); moviesList.add(tempMovie); } } catch (JSONException e) { e.printStackTrace(); } }
@Test public void testParcelable() { Parcel parcel = Parcel.obtain(); movie.writeToParcel(parcel, movie.describeContents()); parcel.setDataPosition(0); Movie movieFromParcel = Movie.CREATOR.createFromParcel(parcel); assertEquals(movie, movieFromParcel); }
/** Create a string, holding all movie records. */ private String buildFileContents() { String NEW_LINE = System.getProperty("line.separator"); StringBuilder result = new StringBuilder(); for (Movie movie : fTable.values()) { appendTo(result, movie.getTitle(), DELIMITER); appendTo(result, movie.getDateViewed(), DELIMITER); appendTo(result, movie.getRating(), DELIMITER); appendTo(result, movie.getComment(), NEW_LINE); } return result.toString(); }
public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); Movie movie = null; while (true) { String movieType = reader.readLine(); movie = MovieFactory.getMovie(movieType); if (movie == null) break; System.out.println(movie.getClass().getSimpleName()); } reader.close(); }
@Test public void shouldDisplayMovideDetails() { Movie movie = new Movie("The Boy in the Striped pyjamas", "Mark Herman", 2008, 7.8f); movie.displayMovie(); assertEquals( String.format( "%-40s%-25s%-25s%-25s", "THE BOY IN THE STRIPED PYJAMAS", "MARK HERMAN", 2008, 7.8) + "\n", outputContent.toString()); }
public void collectMovie(String title, String format, String memberNum) { for (int i = 0; i < rentings.size(); i++) { Renting renting = rentings.get(i); if (renting.getMemberNum().equals(memberNum)) { Copy copy = renting.getCopy(); Movie movie = movieSystem.getMovieByCopy(copy.getId()); if (movie.getTitle().equals(title) && copy.getFormat().equals(format)) { rentings.remove(i); } } } }
@Override public Movie update(Movie movie) { // TODO Auto-generated method stub for (Movie mov : movielist) { if (mov.getId().equals(movie.getId())) { Collections.replaceAll(movielist, mov, movie); } else throw new IllegalArgumentException("This movie is not present in the list"); } if (movielist.contains(movie)) return movie; else return null; }
@Override @Test public void checkAnExtendedWidget() { assertTrue(rottenTomatoes.getExtendeddMovieCount() >= 1); Movie movie = rottenTomatoes.getAnExtendedMovie(0); assertTrue(!StringUtils.isBlank(movie.title())); assertTrue(!StringUtils.isBlank(movie.score())); assertNotNull(movie.getPoster()); movie.goToReview(); rottenTomatoes.checkExtendedReview(); }
@Test @Override public void checkACommonWidget() { assertTrue(rottenTomatoes.getSimpleMovieCount() >= 1); Movie movie = rottenTomatoes.getASimpleMovie(0); assertTrue(!StringUtils.isBlank(movie.title())); assertTrue(!StringUtils.isBlank(movie.score())); assertNotNull(movie.getPoster()); movie.goToReview(); rottenTomatoes.checkSimpleReview(); }
@Override public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) { Movie movie = (Movie) item; ((ViewHolder) viewHolder).setMovie(movie); Log.d(TAG, "onBindViewHolder"); if (movie.getCardImageUrl() != null) { ((ViewHolder) viewHolder).mCardView.setTitleText(movie.getTitle()); ((ViewHolder) viewHolder).mCardView.setContentText(movie.getStudio()); ((ViewHolder) viewHolder).mCardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT); ((ViewHolder) viewHolder).updateCardViewImage(movie.getCardImageURI()); } }
@Test public void testGetters() throws Exception { assertEquals(ID, movie.getId()); assertEquals(TITLE, movie.getTitle()); assertEquals(OVERVIEW, movie.getOverview()); assertEquals(RELEASE_DATE, movie.getReleaseDate()); assertEquals(POSTER_PATH, movie.getPosterPath()); assertEquals(POPULARITY, movie.getPopularity(), 1e-5); assertEquals(ORIGINAL_TITLE, movie.getOriginalTitle()); assertEquals(AVERAGE_VOTE, movie.getAverageVote(), 1e-5); assertEquals(VOTE_COUNT, movie.getVoteCount()); assertEquals(BACKDROP_PATH, movie.getBackdropPath()); }
@Override public void run() { moviesController.deleteMovie(movieId); // Remove movie from local list for (int i = 0; i < movies.size(); i++) { Movie m = movies.get(i); if (m.getId() == movieId) { movies.remove(m); break; } } }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_movie_details, container, false); ButterKnife.bind(this, view); Movie movie = getActivity().getIntent().getParcelableExtra(MovieDetailsActivity.EXTRA_MOVIE); try { releaseDate.setText("" + movie.getReleaseDateYear()); } catch (Exception e) { releaseDate.setVisibility(View.GONE); } ratings.setText("" + movie.getRatings() + "/10.0"); String posterUrl = SpotifyStreamerConstants.getMoviePosterUrl( movie.getPoster(), SpotifyStreamerConstants.MoviePosterSize.W342); Picasso.with(getActivity()).load(posterUrl).into(poster); if (!TextUtils.isEmpty(movie.getSynopsis())) { synopsis.setText(movie.getSynopsis()); } String trailerVideosUrl = SpotifyStreamerConstants.getMovieTrailerVideos(movie.getId()); if (!TextUtils.isEmpty(trailerVideosUrl)) { FetchMovieTrailorAsyncTask fetchMovieTrailorAsyncTask = new FetchMovieTrailorAsyncTask(this); fetchMovieTrailorAsyncTask.execute(trailerVideosUrl); } String reviewUrl = SpotifyStreamerConstants.getMovieReview(movie.getId()); if (!TextUtils.isEmpty(trailerVideosUrl)) { FetchMovieReviewsAsyncTask fetchMovieReviewAsyncTask = new FetchMovieReviewsAsyncTask(this); fetchMovieReviewAsyncTask.execute(reviewUrl); } return view; }
@Override public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; LayoutInflater inflater = ((Activity) context).getLayoutInflater(); row = inflater.inflate(R.layout.grid_item_layout, parent, false); final ImageView imageView = (ImageView) row.findViewById(R.id.gridItemImageView); final Movie movie = getItem(position); if (movie != null) { Picasso.with(context).load(movie.getmImageUrl()).into(imageView); } return row; }