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 Movie[] getMovieData(String movies_detail) { final String RESULTS = "results"; final String TITLE = "original_title"; final String OVER_VIEW = "overview"; final String POSTER_PATH = "poster_path"; final String RELEASE_DATE = "release_date"; final String RATINGS = "vote_average"; Movie[] movies = null; try { JSONObject movie_json = new JSONObject(movies_detail); JSONArray movieArray = movie_json.getJSONArray(RESULTS); movies = new Movie[movieArray.length()]; for (int i = 0; i < movieArray.length(); i++) { JSONObject movieObject = movieArray.getJSONObject(i); Movie temp_movie = new Movie(); temp_movie.setTitle(movieObject.getString(TITLE)); temp_movie.setImage_base_url(movieObject.getString(POSTER_PATH)); temp_movie.setOverview(movieObject.getString(OVER_VIEW)); temp_movie.setRatings(movieObject.getDouble(RATINGS)); temp_movie.setRelease_date(movieObject.getString(RELEASE_DATE)); movies[i] = temp_movie; } } catch (Exception e) { Log.e("main", e.getMessage()); } return movies; }
@SuppressWarnings("unused") private Movie stubMovie(final String mlId) { Movie stub = new Movie(); stub.setMlId(mlId); stub.setTitle("Interesting...the wrong title. Sssshhhh!"); return stub; }
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(); } }
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; }
@Test public void testCategoryAndMovieIntegration() { Movie movie = new Movie(); movie.setTitle("The Iron Man"); movie.setBirthplace("EUA"); movie.setReleaseYear(2014); movie.setSinopse("Very cool!!"); movie.setStockQuantity(20); movie.setCoverPicture(""); Category category = new Category(); category.setName("Category test"); category.addMovie(movie); Assert.assertNotNull(category.getMovieByTitle(movie.getTitle())); }
public void addMovie(Integer id, String director, String title, String synopsis) { Movie movie = new Movie(); movie.setId(id); movie.setDirector(director); movie.setTitle(title); movie.setSynopsis(synopsis); Session session = sf.getCurrentSession(); session.beginTransaction(); session.save(movie); session.getTransaction().commit(); }
private static Movie buildMovieInfo( String category, String title, String description, String studio, String videoUrl, String cardImageUrl, String bgImageUrl) { Movie movie = new Movie(); movie.setId(Movie.getCount()); Movie.incCount(); movie.setTitle(title); movie.setDescription(description); movie.setStudio(studio); movie.setCategory(category); movie.setCardImageUrl(cardImageUrl); movie.setBackgroundImageUrl(bgImageUrl); movie.setVideoUrl(videoUrl); return movie; }
private void extractMovieFromJSON(String jsonStr) { try { JSONObject jo = new JSONObject(jsonStr); Movie tempMovie = new Movie(); 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(); } }
public static Movie parseMovie(Document doc) { LOGGER.info("Parsing movie"); Movie movie = new Movie(); Element root = doc.getDocumentElement(); movie.setTitle(getTagValue("title", root)); movie.setCountry(getTagValue("country", root)); movie.setGenre(getTagValue("genre", root)); movie.setSummary(getTagValue("summary", root)); movie.setYear(getTagValue("year", root)); NodeList nList = doc.getElementsByTagName("director"); for (int i = 0; i < nList.getLength(); i++) { Node node = nList.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element directorElement = (Element) node; Person director = parsePerson(directorElement); movie.setDirector(director); } } nList = doc.getElementsByTagName("actor"); for (int i = 0; i < nList.getLength(); i++) { Node node = nList.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element actorElement = (Element) node; Person actor = parsePerson(actorElement); String role = getTagValue("role", actorElement); movie.addActor(actor, role); } } return movie; }
public ArrayList<Movie> loadMovies() { ArrayList<Movie> movies = new ArrayList<Movie>(); Cursor movieCursor = mContext .getContentResolver() .query(MovieContract.MovieEntry.CONTENT_URI, null, null, null, null); movieCursor.moveToFirst(); do { Integer movieId = movieCursor.getInt(movieCursor.getColumnIndex(MovieContract.MovieEntry.COLUMN_MOVIE_ID)); String title = movieCursor.getString(movieCursor.getColumnIndex(MovieContract.MovieEntry.COLUMN_TITLE)); boolean adult = movieCursor.getInt(movieCursor.getColumnIndex(MovieContract.MovieEntry.COLUMN_ADULT)) != 0 ? true : false; String backDropPath = movieCursor.getString( movieCursor.getColumnIndex(MovieContract.MovieEntry.COLUMN_BACKDROP_PATH)); String genreIdsString = movieCursor.getString( movieCursor.getColumnIndex(MovieContract.MovieEntry.COLUMN_GENRE_IDS)); String[] genreStrings = genreIdsString.split(","); ArrayList<Integer> genreIds = new ArrayList<Integer>(); for (String s : genreStrings) { genreIds.add(Integer.parseInt(s)); } String orgLanguage = movieCursor.getString( movieCursor.getColumnIndex(MovieContract.MovieEntry.COLUMN_ORIGINAL_LANGUAGE)); String orgTitle = movieCursor.getString( movieCursor.getColumnIndex(MovieContract.MovieEntry.COLUMN_ORIGINAL_TITLE)); String overview = movieCursor.getString( movieCursor.getColumnIndex(MovieContract.MovieEntry.COLUMN_OVERVIEW)); String releasString = movieCursor.getString( movieCursor.getColumnIndex(MovieContract.MovieEntry.COLUMN_RELEASE_DATE)); SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", new Locale("us")); Date releaseDate = new Date(); try { releaseDate = sdf.parse(releasString); } catch (ParseException e) { e.printStackTrace(); } String posterPath = movieCursor.getString( movieCursor.getColumnIndex(MovieContract.MovieEntry.COLUMN_POSTER_PATH)); Double popularity = movieCursor.getDouble( movieCursor.getColumnIndex(MovieContract.MovieEntry.COLUMN_POPULARITY)); boolean isVideo = movieCursor.getInt(movieCursor.getColumnIndex(MovieContract.MovieEntry.COLUMN_VIDEO)) != 0 ? true : false; Double voteAverage = movieCursor.getDouble( movieCursor.getColumnIndex(MovieContract.MovieEntry.COLUMN_VOTE_AVERAGE)); Integer voteCount = movieCursor.getInt( movieCursor.getColumnIndex(MovieContract.MovieEntry.COLUMN_VOTE_COUNT)); Movie movie = new Movie(); movie.setId(movieId); movie.setTitle(title); movie.setAdult(adult); movie.setBackdrop_path(backDropPath); movie.setOriginal_language(orgLanguage); movie.setOriginal_title(orgTitle); movie.setOverview(overview); movie.setRelease_date(releaseDate); movie.setPoster_path(posterPath); movie.setPopularity(popularity); movie.setVideo(isVideo); movie.setVote_average(voteAverage); movie.setVote_count(voteCount); movies.add(movie); } while (movieCursor.moveToNext()); return movies; }
public void run1() { long testStartTime = System.nanoTime(); marktime = System.nanoTime(); try { timelog("Beginning graph2 test..."); DElementStore crewStore = new DElementStore(); crewStore.setStoreKey(crewPath); crewStore.addType(Crew.class); DElementStore movieStore = new DElementStore(); movieStore.setStoreKey(moviePath); movieStore.addType(Movie.class); DElementStore characterStore = new DElementStore(); characterStore.setStoreKey(charactersPath); characterStore.addType(Character.class); DElementStore edgeStore = new DElementStore(); edgeStore.setStoreKey(edgePath); // DElementStore usersStore = new DElementStore(); // usersStore.setStoreKey(NoteCoordinate.Utils.getLongFromReplid(nabId)); // usersStore.setProxyStoreKey(NoteCoordinate.Utils.getLongFromReplid(usersId)); // usersStore.addType(User.class); DConfiguration config = new DConfiguration(); graph = new DGraph(config); config.addElementStore(crewStore); config.addElementStore(movieStore); config.addElementStore(characterStore); config.addElementStore(edgeStore); // config.addElementStore(usersStore); config.setDefaultElementStore(edgeStore.getStoreKey()); DGraph graph = new DGraph(config); DFramedGraphFactory factory = new DFramedGraphFactory(config); FramedTransactionalGraph<DGraph> framedGraph = factory.create(graph); resetDbs(); // User ntfUser = framedGraph.getVertex(nabId + ntfUnid, User.class); Movie newhopeMovie = framedGraph.addVertex("Star Wars", Movie.class); newhopeMovie.setTitle("Star Wars"); // Likes ntfLikesNH = ntfUser.addLikes(newhopeMovie); // ntfLikesNH.setRating(4); Movie empireMovie = framedGraph.addVertex("The Empire Strikes Back", Movie.class); empireMovie.setTitle("The Empire Strikes Back"); // Likes ntfLikesESB = ntfUser.addLikes(empireMovie); // ntfLikesESB.setRating(5); Movie jediMovie = framedGraph.addVertex("Return of the Jedi", Movie.class); jediMovie.setTitle("Return of the Jedi"); // Likes ntfLikesRoJ = ntfUser.addLikes(jediMovie); // ntfLikesRoJ.setRating(5); Movie phantomMovie = framedGraph.addVertex("The Phantom Menace", Movie.class); phantomMovie.setTitle("The Phantom Menace"); Movie clonesMovie = framedGraph.addVertex("Attack of the Clones", Movie.class); clonesMovie.setTitle("Attack of the Clones"); Movie revengeMovie = framedGraph.addVertex("Revenge of the Sith", Movie.class); revengeMovie.setTitle("Revenge of the Sith"); Crew lucasCrew = framedGraph.addVertex("George Lucas", Crew.class); lucasCrew.setFullName("George Lucas"); Crew kershnerCrew = framedGraph.addVertex("Irvin Kershner", Crew.class); kershnerCrew.setFullName("Irvin Kershner"); Crew marquandCrew = framedGraph.addVertex("Richard Marquand", Crew.class); marquandCrew.setFullName("Richard Marquand"); DirectedBy nhDirector = newhopeMovie.addDirectedBy(lucasCrew); nhDirector.setRating(4); DirectedBy esbDirector = empireMovie.addDirectedBy(kershnerCrew); esbDirector.setRating(5); DirectedBy rojDirector = jediMovie.addDirectedBy(marquandCrew); rojDirector.setRating(4); DirectedBy pmDirector = phantomMovie.addDirectedBy(lucasCrew); pmDirector.setRating(3); DirectedBy aocDirector = clonesMovie.addDirectedBy(lucasCrew); aocDirector.setRating(2); DirectedBy rosDirector = revengeMovie.addDirectedBy(lucasCrew); rosDirector.setRating(1); Character luke = framedGraph.addVertex("Luke Skywalker", Character.class); luke.setName("Luke Skywalker"); luke.addAppearsIn(newhopeMovie); luke.addAppearsIn(empireMovie); luke.addAppearsIn(jediMovie); Character leia = framedGraph.addVertex("Leia Organa", Character.class); leia.setName("Leia Organa"); leia.addAppearsIn(newhopeMovie); leia.addAppearsIn(empireMovie); leia.addAppearsIn(jediMovie); Character han = framedGraph.addVertex("Han Solo", Character.class); han.setName("Han Solo"); han.addAppearsIn(newhopeMovie); han.addAppearsIn(empireMovie); han.addAppearsIn(jediMovie); Character chewy = framedGraph.addVertex("Chewbacca", Character.class); chewy.setName("Chewbacca"); chewy.addAppearsIn(newhopeMovie); chewy.addAppearsIn(empireMovie); chewy.addAppearsIn(jediMovie); chewy.addAppearsIn(revengeMovie); Character threepio = framedGraph.addVertex("C-3PO", Character.class); threepio.setName("C-3PO"); threepio.addAppearsIn(newhopeMovie); threepio.addAppearsIn(empireMovie); threepio.addAppearsIn(jediMovie); threepio.addAppearsIn(phantomMovie); threepio.addAppearsIn(clonesMovie); threepio.addAppearsIn(revengeMovie); Character artoo = framedGraph.addVertex("R2D2", Character.class); artoo.setName("R2D2"); artoo.addAppearsIn(newhopeMovie); artoo.addAppearsIn(empireMovie); artoo.addAppearsIn(jediMovie); artoo.addAppearsIn(phantomMovie); artoo.addAppearsIn(clonesMovie); artoo.addAppearsIn(revengeMovie); Character lando = framedGraph.addVertex("Lando Calrissian", Character.class); lando.setName("Lando Calrissian"); lando.addAppearsIn(empireMovie); lando.addAppearsIn(jediMovie); Character anakin = framedGraph.addVertex("Anakin Skywalker", Character.class); anakin.setName("Anakin Skywalker"); anakin.addAppearsIn(newhopeMovie); anakin.addAppearsIn(empireMovie); anakin.addAppearsIn(jediMovie); anakin.addAppearsIn(phantomMovie); anakin.addAppearsIn(clonesMovie); anakin.addAppearsIn(revengeMovie); Character palpatine = framedGraph.addVertex("Darth Sidious", Character.class); palpatine.setName("Darth Sidious"); palpatine.addAppearsIn(empireMovie); palpatine.addAppearsIn(jediMovie); palpatine.addAppearsIn(phantomMovie); palpatine.addAppearsIn(clonesMovie); palpatine.addAppearsIn(revengeMovie); Character obiwan = framedGraph.addVertex("Obi-Wan Kenobi", Character.class); obiwan.setName("Obi-Wan Kenobi"); obiwan.addAppearsIn(newhopeMovie); obiwan.addAppearsIn(empireMovie); obiwan.addAppearsIn(jediMovie); obiwan.addAppearsIn(phantomMovie); obiwan.addAppearsIn(clonesMovie); obiwan.addAppearsIn(revengeMovie); Character quigon = framedGraph.addVertex("Qui-Gon Jinn", Character.class); quigon.setName("Qui-Gon Jinn"); quigon.addAppearsIn(phantomMovie); Character yoda = framedGraph.addVertex("Yoda", Character.class); yoda.setName("Yoda"); yoda.addAppearsIn(empireMovie); yoda.addAppearsIn(jediMovie); yoda.addAppearsIn(phantomMovie); yoda.addAppearsIn(clonesMovie); yoda.addAppearsIn(revengeMovie); Character jango = framedGraph.addVertex("Jango Fett", Character.class); jango.setName("Jango Fett"); jango.addAppearsIn(clonesMovie); Character boba = framedGraph.addVertex("Boba Fett", Character.class); boba.setName("Boba Fett"); boba.addAppearsIn(empireMovie); boba.addAppearsIn(jediMovie); boba.addAppearsIn(clonesMovie); Character padme = framedGraph.addVertex("Padme", Character.class); padme.setName("Padme"); padme.addAppearsIn(phantomMovie); padme.addAppearsIn(clonesMovie); padme.addAppearsIn(revengeMovie); Character shmi = framedGraph.addVertex("Shmi Skywalker", Character.class); shmi.setName("Shmi Skywalker"); shmi.addAppearsIn(phantomMovie); shmi.addAppearsIn(clonesMovie); Character tyranus = framedGraph.addVertex("Darth Tyranus", Character.class); tyranus.setName("Darth Tyranus"); tyranus.addAppearsIn(clonesMovie); tyranus.addAppearsIn(revengeMovie); Character maul = framedGraph.addVertex("Darth Maul", Character.class); maul.setName("Darth Maul"); maul.addAppearsIn(phantomMovie); maul.addAppearsIn(clonesMovie); Character tarkin = framedGraph.addVertex("Grand Moff Tarkin", Character.class); tarkin.setName("Grand Moff Tarkin"); tarkin.addAppearsIn(newhopeMovie); Character windu = framedGraph.addVertex("Mace Windu", Character.class); windu.setName("Mace Windu"); windu.addAppearsIn(phantomMovie); windu.addAppearsIn(clonesMovie); windu.addAppearsIn(revengeMovie); Character greedo = framedGraph.addVertex("Greedo", Character.class); greedo.setName("Greedo"); greedo.addAppearsIn(newhopeMovie); Character wedge = framedGraph.addVertex("Wedge Antilles", Character.class); wedge.setName("Wedge Antilles"); wedge.addAppearsIn(newhopeMovie); wedge.addAppearsIn(empireMovie); wedge.addAppearsIn(jediMovie); Crew ford = framedGraph.addVertex("Harrison Ford", Crew.class); ford.setFullName("Harrison Ford"); ford.addStarsInMovie(newhopeMovie); ford.addStarsInMovie(empireMovie); ford.addStarsInMovie(jediMovie); han.addPortrayedBy(ford); Crew fischer = framedGraph.addVertex("Carrie Fischer", Crew.class); fischer.setFullName("Carrie Fischer"); fischer.addStarsInMovie(newhopeMovie); fischer.addStarsInMovie(empireMovie); fischer.addStarsInMovie(jediMovie); fischer.addPortrayals(leia); Crew hammill = framedGraph.addVertex("Mark Hammill", Crew.class); hammill.setFullName("Mark Hammill"); hammill.addStarsInMovie(newhopeMovie); hammill.addStarsInMovie(empireMovie); hammill.addStarsInMovie(jediMovie); hammill.addPortrayals(luke); Crew daniels = framedGraph.addVertex("Anthony Daniels", Crew.class); daniels.setFullName("Anthony Daniels"); daniels.addStarsInMovie(newhopeMovie); daniels.addStarsInMovie(empireMovie); daniels.addStarsInMovie(jediMovie); daniels.addStarsInMovie(phantomMovie); daniels.addStarsInMovie(clonesMovie); daniels.addStarsInMovie(revengeMovie); daniels.addPortrayals(threepio); Crew baker = framedGraph.addVertex("Kenny Baker", Crew.class); baker.setFullName("Kenny Baker"); baker.addStarsInMovie(newhopeMovie); baker.addStarsInMovie(empireMovie); baker.addStarsInMovie(jediMovie); baker.addStarsInMovie(phantomMovie); baker.addStarsInMovie(clonesMovie); baker.addStarsInMovie(revengeMovie); baker.addPortrayals(artoo); Crew prowse = framedGraph.addVertex("David Prowse", Crew.class); prowse.setFullName("David Prowse"); prowse.addStarsInMovie(newhopeMovie); prowse.addStarsInMovie(empireMovie); prowse.addStarsInMovie(jediMovie); prowse.addPortrayals(anakin); Crew williams = framedGraph.addVertex("Billy Dee Williams", Crew.class); williams.setFullName("Billy Dee Williams"); williams.addStarsInMovie(empireMovie); williams.addStarsInMovie(jediMovie); williams.addPortrayals(lando); Crew guinness = framedGraph.addVertex("Alec Guinness", Crew.class); guinness.setFullName("Alec Guinness"); guinness.addStarsInMovie(newhopeMovie); guinness.addStarsInMovie(empireMovie); guinness.addStarsInMovie(jediMovie); guinness.addPortrayals(obiwan); Crew ewan = framedGraph.addVertex("Ewan McGregor", Crew.class); ewan.setFullName("Ewan McGregor"); ewan.addStarsInMovie(phantomMovie); ewan.addStarsInMovie(clonesMovie); ewan.addStarsInMovie(revengeMovie); ewan.addPortrayals(obiwan); Crew cushing = framedGraph.addVertex("Peter Cushing", Crew.class); cushing.setFullName("Peter Cushing"); cushing.addStarsInMovie(newhopeMovie); cushing.addPortrayals(tarkin); Crew mayhew = framedGraph.addVertex("Peter Mayhew", Crew.class); mayhew.setFullName("Peter Mayhew"); mayhew.addStarsInMovie(newhopeMovie); mayhew.addStarsInMovie(empireMovie); mayhew.addStarsInMovie(jediMovie); mayhew.addStarsInMovie(revengeMovie); mayhew.addPortrayals(chewy); Crew oz = framedGraph.addVertex("Frank Oz", Crew.class); oz.setFullName("Frank Oz"); oz.addStarsInMovie(empireMovie); oz.addStarsInMovie(jediMovie); oz.addStarsInMovie(phantomMovie); oz.addStarsInMovie(clonesMovie); oz.addStarsInMovie(revengeMovie); oz.addPortrayals(yoda); Crew bulloch = framedGraph.addVertex("Jeremy Bulloch", Crew.class); bulloch.setFullName("Jeremy Bulloch"); bulloch.addStarsInMovie(empireMovie); bulloch.addStarsInMovie(jediMovie); bulloch.addPortrayals(boba); Crew revill = framedGraph.addVertex("Clive Revill", Crew.class); revill.setFullName("Clive Revill"); revill.addStarsInMovie(empireMovie); revill.addPortrayals(palpatine); Crew ian = framedGraph.addVertex("Ian McDiarmid", Crew.class); ian.setFullName("Ian McDiarmid"); ian.addStarsInMovie(jediMovie); ian.addStarsInMovie(phantomMovie); ian.addStarsInMovie(clonesMovie); ian.addStarsInMovie(revengeMovie); ian.addPortrayals(palpatine); Crew shaw = framedGraph.addVertex("Sebastian Shaw", Crew.class); shaw.setFullName("Sebastian Shaw"); shaw.addStarsInMovie(jediMovie); shaw.addPortrayals(anakin); Crew liam = framedGraph.addVertex("Liam Neeson", Crew.class); liam.setFullName("Liam Neeson"); liam.addStarsInMovie(phantomMovie); liam.addPortrayals(quigon); Crew portman = framedGraph.addVertex("Natalie Portman", Crew.class); portman.setFullName("Natalie Portman"); portman.addStarsInMovie(phantomMovie); portman.addStarsInMovie(clonesMovie); portman.addStarsInMovie(revengeMovie); portman.addPortrayals(padme); Crew lloyd = framedGraph.addVertex("Jake Lloyd", Crew.class); lloyd.setFullName("Jake Lloyd"); lloyd.addStarsInMovie(phantomMovie); lloyd.addPortrayals(anakin); Crew hayden = framedGraph.addVertex("Hayden Christensen", Crew.class); hayden.setFullName("Hayden Christensen"); hayden.addStarsInMovie(clonesMovie); hayden.addStarsInMovie(revengeMovie); hayden.addPortrayals(anakin); Crew august = framedGraph.addVertex("Pernill August", Crew.class); august.setFullName("Pernill August"); august.addStarsInMovie(phantomMovie); august.addStarsInMovie(clonesMovie); august.addPortrayals(shmi); Crew park = framedGraph.addVertex("Ray Park", Crew.class); park.setFullName("Ray Park"); park.addStarsInMovie(phantomMovie); park.addPortrayals(maul); Crew samuel = framedGraph.addVertex("Samuel L. Jackson", Crew.class); samuel.setFullName("Samuel L. Jackson"); samuel.addStarsInMovie(phantomMovie); samuel.addStarsInMovie(clonesMovie); samuel.addStarsInMovie(revengeMovie); samuel.addPortrayals(windu); Crew lee = framedGraph.addVertex("Christopher Lee", Crew.class); lee.setFullName("Christopher Lee"); lee.addStarsInMovie(clonesMovie); lee.addStarsInMovie(revengeMovie); lee.addPortrayals(tyranus); Crew morrison = framedGraph.addVertex("Temuera Morrison", Crew.class); morrison.setFullName("Temuera Morrison"); morrison.addStarsInMovie(clonesMovie); morrison.addPortrayals(jango); Crew logan = framedGraph.addVertex("Daniel Logan", Crew.class); logan.setFullName("Daniel Logan"); logan.addStarsInMovie(clonesMovie); logan.addPortrayals(boba); Crew blake = framedGraph.addVertex("Paul Blake", Crew.class); blake.setFullName("Paul Blake"); blake.addStarsInMovie(newhopeMovie); blake.addPortrayals(greedo); Crew lawson = framedGraph.addVertex("Denis Lawson", Crew.class); lawson.setFullName("Denis Lawson"); lawson.addStarsInMovie(newhopeMovie); lawson.addStarsInMovie(empireMovie); lawson.addStarsInMovie(jediMovie); lawson.addPortrayals(wedge); Kills curKills = null; curKills = anakin.addKills(obiwan); curKills.setFilm(newhopeMovie.asVertex().getId().toString()); curKills = luke.addKills(tarkin); curKills.setFilm(newhopeMovie.asVertex().getId().toString()); curKills = windu.addKills(jango); curKills.setFilm(clonesMovie.asVertex().getId().toString()); curKills = palpatine.addKills(windu); curKills.setFilm(revengeMovie.asVertex().getId().toString()); curKills = wedge.addKills(anakin); curKills.setFilm(jediMovie.asVertex().getId().toString()); curKills = lando.addKills(anakin); curKills.setFilm(jediMovie.asVertex().getId().toString()); curKills = anakin.addKills(palpatine); curKills.setFilm(jediMovie.asVertex().getId().toString()); curKills = maul.addKills(quigon); curKills.setFilm(phantomMovie.asVertex().getId().toString()); curKills = obiwan.addKills(maul); curKills.setFilm(phantomMovie.asVertex().getId().toString()); curKills = han.addKills(greedo); curKills.setFilm(newhopeMovie.asVertex().getId().toString()); curKills = han.addKills(boba); curKills.setFilm(jediMovie.asVertex().getId().toString()); curKills = anakin.addKills(tyranus); curKills.setFilm(revengeMovie.asVertex().getId().toString()); anakin.addSpawns(threepio); anakin.addSpawns(luke); anakin.addSpawns(leia); padme.addSpawns(luke); padme.addSpawns(leia); shmi.addSpawns(anakin); jango.addSpawns(boba); graph.commit(); } catch (Throwable t) { t.printStackTrace(); } long testEndTime = System.nanoTime(); System.out.println( "Completed " + getClass().getSimpleName() + " run in " + ((testEndTime - testStartTime) / 1000000) + " ms"); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); setHasOptionsMenu(true); /** ******************** new code***************** */ mGridView = (GridView) rootView.findViewById(R.id.gridView); mProgressBar = (ProgressBar) rootView.findViewById(R.id.progressBar); // Initialize with empty data mGridData = new ArrayList<>(); mGridAdapter = new ImageAdapter(getActivity(), R.layout.grid_item_layout, mGridData); mGridView.setAdapter(mGridAdapter); // Grid view click event mGridView.setOnItemClickListener( new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { // Get item at position Movie item = (Movie) parent.getItemAtPosition(position); Intent intent = new Intent(getActivity(), detailMovie.class); // Pass the movie details DetailsActivity intent .putExtra("title", item.getTitle()) .putExtra("overview", item.getOverview()) .putExtra("rating", item.getRating()) .putExtra("rDate", item.getReleaseDate()) .putExtra("id", item.getMovieID()) .putExtra("pURL", item.getPosterURL()) .putExtra("pURL", item.getPosterURL()); mPosition = position; mListener.OnItemClicked(item); // Start details activity startActivity(intent); } }); // -------------------- if (savedInstanceState == null || !savedInstanceState.containsKey(SELECTED_KEY)) { mProgressBar.setVisibility(View.VISIBLE); // getting the setting value String Sort_By = getPreferredSort(getActivity()); // favourite String Fav = getString(R.string.pref_sort_favourite); String pop = getString(R.string.pref_sort_popular); String rate = getString(R.string.pref_sort_rate); Toast.makeText(getActivity(), "hey_there " + Sort_By, Toast.LENGTH_SHORT).show(); if (Sort_By.contentEquals(Fav)) { SharedPreferences pref = getActivity() .getSharedPreferences(getString(R.string.pref_movie_name), Context.MODE_PRIVATE); SharedPreferences.Editor editor = pref.edit(); Log.d("Entered", "favourtie"); String fM = pref.getString(getString(R.string.pref_movie_key), ""); // Log.d("Getting Movie ",fM ); String fMovies[]; if (fM != null) { fMovies = fM.split("#"); mGridData.clear(); String rMovies[], vMovies[]; reviews = new ArrayList<>(); videos = new ArrayList<>(); String[] movieDetails; String[] reviewDetail; String[] videoDetail; Movie movieObj; Review review; Video video; for (int i = 0; i < fMovies.length; i++) { movieDetails = fMovies[i].split("|"); movieObj = new Movie(); movieObj.setMovieID(movieDetails[0]); movieObj.setPosterURL(movieDetails[1]); movieObj.setBackgroundUrl(movieDetails[2]); movieObj.setTitle(movieDetails[3]); movieObj.setOverview(movieDetails[4]); movieObj.setReleaseDate(movieDetails[5]); movieObj.setRating(movieDetails[6]); // Log.d("Movie From Prefrence", // " --- "+movieDetails[0] + // " --- "+movieDetails[1] + // " ---"+movieDetails[2] + // " ---- "+movieDetails[3] + // " --- "+movieDetails[4] + // " --- "+movieDetails[5] + // " --- "+movieDetails[6] ); rMovies = pref.getString(getString(R.string.pref_movie_name), null).split("#"); for (int j = 0; j < rMovies.length; j++) { reviewDetail = rMovies[i].split("|"); review = new Review(); // Log.d("Review", "Author "+reviewDetail[0] // + "Content "+reviewDetail[1]); review.setAuthor(reviewDetail[0]); review.setContent(reviewDetail[1]); reviews.add(review); } vMovies = pref.getString(getString(R.string.pref_movie_name), null).split("#"); for (int j = 0; j < vMovies.length; j++) { videoDetail = vMovies[i].split("|"); video = new Video(); // Log.d("Videos", "Title "+videoDetail[0] // + "URL "+videoDetail[1]); video.setName(videoDetail[0]); video.setUrl(videoDetail[1]); videos.add(video); } mGridData.add(movieObj); } // for(int q=0 ; q<mGridData.size() ; q++){ // // Log.d("Favorite "+ q, "Backgorund // "+mGridData.get(q).getBackgroundUrl() // + "Date " +mGridData.get(q).getReleaseDate() // + "Movie ID :" +mGridData.get(q).getMovieID() // + "Rting: "+mGridData.get(q).getRating() // +"Title" + mGridData.get(q).getTitle() // ); // } mGridAdapter.setGridData(mGridData); // Log.d("Favorite", mGridData.toString()); Toast.makeText(getActivity(), "Here are your Movies", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getActivity(), "You Don't have any Favourite", Toast.LENGTH_SHORT).show(); } } else if (Sort_By.contentEquals(pop) || Sort_By.contentEquals(rate)) { Toast.makeText(getActivity(), "hey_there " + Sort_By, Toast.LENGTH_SHORT).show(); Log.d("Sort BY", Sort_By); mGridData.clear(); new FetchMoviesTask().execute(Sort_By); } else { mGridData.clear(); new FetchMoviesTask().execute(pop); } } else { Toast.makeText(getActivity(), "hey Else ", Toast.LENGTH_SHORT).show(); mGridData = savedInstanceState.getParcelableArrayList(SELECTED_KEY); mGridAdapter = new ImageAdapter(getActivity(), R.layout.grid_item_layout, mGridData); mGridView.setAdapter(mGridAdapter); Log.d("Main Grid", mGridData.toString()); // set } // ---------------- /** ********************************************** */ return rootView; }
/** * Take the String representing the complete forecast in JSON Format and pull out the data we * need to construct the Strings needed for the wireframes. * * <p>Fortunately parsing is easy: constructor takes the JSON string and converts it into an * Object hierarchy for us. */ private String[] getMovieDataFromJson(String MovieJsonStr) throws JSONException { final String Results_ID = "results"; final String Movie_ID = "id"; final String Title_ID = "original_title"; final String Poster_URL_ID = "poster_path"; final String Background_URL_ID = "backdrop_path"; final String OverView_ID = "overview"; final String Rating_ID = "vote_average"; final String release_Date_ID = "release_date"; final String baseImageUrl = "http://image.tmdb.org/t/p/"; final String imageSizeForUrl = "w185/"; JSONObject MovieJson = new JSONObject(MovieJsonStr); JSONArray moviesArray = MovieJson.getJSONArray(Results_ID); String[] resultStrs = new String[moviesArray.length()]; String title, posterURL, overview, rating, releaseDate, backgroundURL, movieID; Movie movieObj; Movie item = new Movie(); for (int i = 0; i < moviesArray.length(); i++) { // Get the JSON object representing the day JSONObject MovieDetails = moviesArray.getJSONObject(i); title = MovieDetails.getString(Title_ID); posterURL = MovieDetails.getString(Poster_URL_ID); overview = MovieDetails.getString(OverView_ID); rating = MovieDetails.getString(Rating_ID); releaseDate = MovieDetails.getString(release_Date_ID); backgroundURL = MovieDetails.getString(Background_URL_ID); movieID = MovieDetails.getString(Movie_ID); posterURL = baseImageUrl + imageSizeForUrl + posterURL; backgroundURL = baseImageUrl + imageSizeForUrl + backgroundURL; String details = posterURL + "|" + backgroundURL + "|" + title + "|" + overview + "|" + rating + "|" + releaseDate + "|" + movieID; movieObj = new Movie(); movieObj.setTitle(title); movieObj.setOverview(overview); movieObj.setRating(rating); movieObj.setReleaseDate(releaseDate); movieObj.setBackgroundUrl(backgroundURL); movieObj.setPosterURL(posterURL); movieObj.setMovieID(movieID); Log.v(LOG_TAG, "Movie string: " + details); resultStrs[i] = details; mGridData.add(movieObj); } return resultStrs; }