theMap.put("user_id", hasUser ? StringUtils.format("%d", user.getId()) : ""); theMap.put("screen_name", hasUser ? user.getScreenName() : ""); theMap.put("location", hasUser ? user.getLocation() : ""); theMap.put("verified", hasUser ? user.isVerified() : "");
private Record extractRecord(String idPrefix, Schema avroSchema, Status status) { User user = status.getUser(); Record doc = new Record(avroSchema); doc.put("id", idPrefix + status.getId()); doc.put("created_at", formatterTo.format(status.getCreatedAt())); doc.put("retweet_count", status.getRetweetCount()); doc.put("retweeted", status.isRetweet()); doc.put("in_reply_to_user_id", status.getInReplyToUserId()); doc.put("in_reply_to_status_id", status.getInReplyToStatusId()); addString(doc, "source", status.getSource()); addString(doc, "text", status.getText()); MediaEntity[] mediaEntities = status.getMediaEntities(); if (mediaEntities.length > 0) { addString(doc, "media_url_https", mediaEntities[0].getMediaURLHttps()); addString(doc, "expanded_url", mediaEntities[0].getExpandedURL()); } doc.put("user_friends_count", user.getFriendsCount()); doc.put("user_statuses_count", user.getStatusesCount()); doc.put("user_followers_count", user.getFollowersCount()); addString(doc, "user_location", user.getLocation()); addString(doc, "user_description", user.getDescription()); addString(doc, "user_screen_name", user.getScreenName()); addString(doc, "user_name", user.getName()); return doc; }
@Override public String getValue() { return status.getUser().getLocation(); } },
/** * Retrieves the State from User Object of the Tweet. * * @param status -- Status Object. * @param state -- Current State. * @return State of tweet. */ private final String getStateFromTweetUserObject(final Status status, String state) { String stateFromUserObject = status.getUser().getLocation(); if(null == state && null != stateFromUserObject && 1 < stateFromUserObject.length()) { String stateUser = stateFromUserObject.substring(stateFromUserObject.length() - 2).toUpperCase(); LOGGER.debug("State from User:{}", stateFromUserObject); //Retry to get the State of the User if the last 2 chars are US for the User's Location object. //This is just a pro-active check. //This assumes the format: NY, US if("US".equalsIgnoreCase(stateUser) && 5 < stateFromUserObject.length()){ stateUser = stateFromUserObject.substring(stateFromUserObject.length() - 6, stateFromUserObject.length() - 4); LOGGER.debug("State from User again:{}", stateFromUserObject); } state = (2 == stateUser.length())? stateUser.toUpperCase(): null; } return state; }
theMap.put("user_id", hasUser ? StringUtils.format("%d", user.getId()) : ""); theMap.put("screen_name", hasUser ? user.getScreenName() : ""); theMap.put("location", hasUser ? user.getLocation() : ""); theMap.put("verified", hasUser ? user.isVerified() : "");
String userLocation = user.getLocation();
final String userLocationText = user.getLocation(); if (userLocationText != null) { userLocation.setText(userLocationText);
status.user.description = user.getDescription(); status.user.id = user.getId(); status.user.location = user.getLocation(); status.user.language = user.getLang(); status.user.postings = user.getStatusesCount();
status.user.description = user.getDescription(); status.user.id = user.getId(); status.user.location = user.getLocation(); status.user.language = user.getLang(); status.user.postings = user.getStatusesCount();
private Record extractRecord(String idPrefix, Schema avroSchema, Status status) { User user = status.getUser(); Record doc = new Record(avroSchema); doc.put("id", idPrefix + status.getId()); doc.put("created_at", formatterTo.format(status.getCreatedAt())); doc.put("retweet_count", status.getRetweetCount()); doc.put("retweeted", status.isRetweet()); doc.put("in_reply_to_user_id", status.getInReplyToUserId()); doc.put("in_reply_to_status_id", status.getInReplyToStatusId()); addString(doc, "source", status.getSource()); addString(doc, "text", status.getText()); MediaEntity[] mediaEntities = status.getMediaEntities(); if (mediaEntities.length > 0) { addString(doc, "media_url_https", mediaEntities[0].getMediaURLHttps()); addString(doc, "expanded_url", mediaEntities[0].getExpandedURL()); } doc.put("user_friends_count", user.getFriendsCount()); doc.put("user_statuses_count", user.getStatusesCount()); doc.put("user_followers_count", user.getFollowersCount()); addString(doc, "user_location", user.getLocation()); addString(doc, "user_description", user.getDescription()); addString(doc, "user_screen_name", user.getScreenName()); addString(doc, "user_name", user.getName()); return doc; }
.put("Name", user.getName()) .put("ScreenName", user.getScreenName()) .put("Location", user.getLocation()) .put("Description", user.getDescription()) .put("ContributorsEnabled", user.isContributorsEnabled())