private void startTag(String aPrefix, String aName, XmlPullParser aParser) throws Exception {
   if ("entry".equals(aName)) {
     tweets.addTweet(currentTweet = new Tweet());
   } else if ("published".equals(aName)) {
     aParser.next();
     currentTweet.setPublished(dateFormat.parse(aParser.getText()));
   } else if (("title".equals(aName)) && (currentTweet != null)) {
     aParser.next();
     currentTweet.setTitle(aParser.getText());
   } else if ("content".equals(aName)) {
     Content _c = new Content();
     _c.setType(aParser.getAttributeValue(null, "type"));
     aParser.next();
     _c.setValue(aParser.getText());
     currentTweet.setContent(_c);
   } else if ("lang".equals(aName)) {
     aParser.next();
     currentTweet.setLanguage(aParser.getText());
   } else if ("author".equals(aName)) {
     currentTweet.setAuthor(currentAuthor = new Author());
   } else if ("name".equals(aName)) {
     aParser.next();
     currentAuthor.setName(aParser.getText());
   } else if ("uri".equals(aName)) {
     aParser.next();
     currentAuthor.setUri(aParser.getText());
   }
 }
Exemple #2
0
 public void onStatus(twitter4j.Status status) {
   Logger.info(status.getUser().getName() + " : " + status.getText());
   Tweet tweet = new Tweet(status);
   tweet.conformsToTerms = checkMatch(status);
   tweet.save();
   if (tweet.conformsToTerms && esClient != null) {
     String json = DataObjectFactory.getRawJSON(status);
     json =
         json.replaceAll(
             "(\"geo\":\\{\"type\":\"Point\",\"coordinates\":)\\[([-0-9.,]*)\\]", "$1\"$2\"");
     // Logger.debug("geo mangled json");
     // Logger.debug(json);
     IndexResponse response =
         esClient.prepareIndex("twitter", "tweet").setSource(json).execute().actionGet();
   }
 }
Exemple #3
0
 public static Result list(int page, int pageSize) {
   Page<Tweet> currentPage = Tweet.page(page - 1, pageSize);
   // List<Tweet> tweets = Tweet.find.where().eq("conformsToTerms",true).orderBy("date
   // desc").findList();
   StreamConfig config = getConfig();
   String terms = config.listTermsAsString();
   return ok(stream_result_list.render(currentPage, page, pageSize, terms));
 }