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; }
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; }