private void mapMovie(int movieId, JSONObject movieJson, Context context) throws ParseException {
String title = movieJson.getString("title");
String vertexId = TheMovieDbOntology.getMovieVertexId(movieId);
String sourceUrl = "http://www.themoviedb.org/movie/" + movieId;
VertexBuilder m = prepareVertex(vertexId, visibility);
LumifyProperties.CONCEPT_TYPE.addPropertyValue(m, MULTI_VALUE_KEY, TheMovieDbOntology.CONCEPT_TYPE_MOVIE, visibility);
LumifyProperties.SOURCE.addPropertyValue(m, MULTI_VALUE_KEY, SOURCE, visibility);
LumifyProperties.SOURCE_URL.addPropertyValue(m, MULTI_VALUE_KEY, sourceUrl, visibility);
StreamingPropertyValue rawValue = new StreamingPropertyValue(new ByteArrayInputStream(movieJson.toString().getBytes()), byte[].class);
rawValue.store(true);
rawValue.searchIndex(false);
LumifyProperties.RAW.addPropertyValue(m, MULTI_VALUE_KEY, rawValue, visibility);
LumifyProperties.TITLE.addPropertyValue(m, MULTI_VALUE_KEY, title, visibility);
String releaseDateString = movieJson.optString("release_date");
if (releaseDateString != null && releaseDateString.length() > 0) {
Date releaseDate = parseDate(releaseDateString);
TheMovieDbOntology.RELEASE_DATE.addPropertyValue(m, MULTI_VALUE_KEY, releaseDate, visibility);
}
JSONArray genres = movieJson.optJSONArray("genres");
if (genres != null) {
for (int i = 0; i < genres.length(); i++) {
JSONObject genre = genres.getJSONObject(i);
String genreName = genre.getString("name");
TheMovieDbOntology.GENRE.addPropertyValue(m, MULTI_VALUE_KEY + "_" + genreName, genreName, visibility);
}
}
double runtime = movieJson.optDouble("runtime", -1);
if (runtime > 0) {
runtime = runtime * 60;
TheMovieDbOntology.RUNTIME.addPropertyValue(m, MULTI_VALUE_KEY, runtime, visibility);
}
int revenue = movieJson.optInt("revenue", -1);
if (revenue > 0) {
TheMovieDbOntology.REVENUE.addPropertyValue(m, MULTI_VALUE_KEY, revenue, visibility);
}
int budget = movieJson.optInt("budget", -1);
if (budget > 0) {
TheMovieDbOntology.BUDGET.addPropertyValue(m, MULTI_VALUE_KEY, budget, visibility);
}
String overview = movieJson.optString("overview");
if (overview != null && overview.length() > 0) {
Map<String, Object> metadata = new HashMap<String, Object>();
metadata.put(LumifyProperties.META_DATA_TEXT_DESCRIPTION, "Overview");
metadata.put(LumifyProperties.META_DATA_MIME_TYPE, "text/plain");
StreamingPropertyValue value = new StreamingPropertyValue(new ByteArrayInputStream(overview.getBytes()), String.class);
LumifyProperties.TEXT.addPropertyValue(m, MULTI_VALUE_KEY, value, metadata, visibility);
}
String tagLine = movieJson.optString("tagline");
if (tagLine != null && tagLine.length() > 0) {
TheMovieDbOntology.TAG_LINE.addPropertyValue(m, MULTI_VALUE_KEY, tagLine, visibility);
}
Vertex movieVertex = m.save(authorizations);
processMovieCredits(movieId, movieJson, movieVertex);
processMovieProductionCompanies(movieId, movieJson, movieVertex);
context.getCounter(TheMovieDbImportCounters.MOVIES_PROCESSED).increment(1);