@Override public void store(Item item) throws IOException { String userId = item.getUserId(); String tweetId = item.getId(); long timestamp = item.getPublicationTime(); // String title = item.getTitle(); Vertex source = getOrCreateVertex(userId, vertexUserId); // handle mentions String[] mentions = item.getMentions(); for (String userMention : mentions) { Edge edge; // handle retweets if (!item.isOriginal()) { String userRetweets = item.getReferencedUserId(); Vertex destination = getOrCreateVertex(userRetweets, vertexUserId); edge = titanGraph.addEdge(null, source, destination, edgeReTweets); // edge.setProperty("title", title); } else { Vertex destination = getOrCreateVertex(userMention, vertexUserId); edge = titanGraph.addEdge(null, source, destination, edgeMentions); // edge.setProperty("title", title); } edge.setProperty(edgePropertyTweedId, tweetId); edge.setProperty(edgePropertyTimestamp, timestamp); } titanGraph.commit(); }
/** * Stores an item to all available databases * * @param item * @throws IOException */ private void process(Item item) throws IOException { if (store != null) { for (ItemFilter filter : filters) { if (!filter.accept(item)) { return; } } for (Processor processor : processors) { processor.process(item); } if (item.getOperation() == Operation.NEW) { store.store(item); } else if (item.getOperation() == Operation.UPDATE) { store.update(item); } else if (item.getOperation() == Operation.DELETED) { store.delete(item.getId()); } else { System.out.println(item.getOperation() + ": Not supported operation"); } } }