placeHelper.flush();
}
boolean hasAnnotations = 0 < tweet.getAnnotations().size();
MicroblogPost currentMicroblogPost = persistenceContext.persist(tweet, hasAnnotations);
if (null != tweet.getUser()) {
persistenceContext.persist(tweet.getUser());
} else {
LOGGER.fine("null user for tweet: " + tweet);
}
if (null != tweet.getGeo()) {
Point p = persistenceContext.persist(tweet.getGeo());
Set<SpatialThing> s = currentMicroblogPost.getLocation();
s.add(p);
currentMicroblogPost.setLocation(s);
}
if (null != tweet.getPlace()) {
Feature f = persistenceContext.persist(tweet.getPlace());
if (null != placeHelper) {
try {
placeHelper.submit(tweet.getPlace(), f);
} catch (TwitterClientException e) {
throw new HandlerException(e);
}
}
Set<SpatialThing> s = currentMicroblogPost.getLocation();
s.add(f);
currentMicroblogPost.setLocation(s);
}
// end Elmo operations
try {
storeConnection.commit();
} catch (TweetStoreException e) {
throw new HandlerException(e);
}
// Note: we assume that Twitter and any other services which supply these posts will not allow a cycle
// of replies and/or retweets.
// Note: these tweets are persisted in their own transactions.
if (null != tweet.getInReplyToTweet()) {
this.handle(tweet.getInReplyToTweet());
}
if (null != tweet.getRetweetOf()) {
this.handle(tweet.getRetweetOf());
}
//System.out.println(" ...ending transaction");
// Note: these Sail operations are performed outside of the Elmo transaction. If they were to be
// carried out inside the transaction, apparently Sesame would kill the thread without throwing
// an exception or logging an error.
if (hasAnnotations) {
for (Triple triple : tweet.getAnnotations()) {
System.out.println("\t (" + triple.getWeight() + ")\t" + triple);
Statement st;
try {
st = toRDF(triple, uriOf(currentMicroblogPost.getEmbedsKnowledge()));
} catch (TwitterClientException e) {
throw new HandlerException(e);
}
if (null != st) {