List of usage examples for twitter4j Status isTruncated
boolean isTruncated();
From source file:au.net.moon.tUtils.twitterFields.java
License:Open Source License
/** * Get a <CODE>HashMap</CODE> of tweet fields by parsing a twitter4j Status * //from w w w . j a va 2 s. c om * @param status * the twitter4j Status object * @return the tweet fields as name, value pairs in a <CODE>HashMap</CODE>. */ public static HashMap<String, String> parseStatusObj(Status status) { HashMap<String, String> splitFields = new HashMap<String, String>(); splitFields.put("createdAt", status.getCreatedAt().toString()); splitFields.put("id", Long.toString(status.getId())); splitFields.put("text", status.getText()); splitFields.put("source", status.getSource()); splitFields.put("isTruncated", status.isTruncated() ? "1" : "0"); splitFields.put("inReplyToStatusId", Long.toString(status.getInReplyToStatusId())); splitFields.put("inReplyToUserId", Long.toString(status.getInReplyToUserId())); splitFields.put("isFavorited", status.isFavorited() ? "1" : "0"); splitFields.put("inReplyToScreenName", status.getInReplyToScreenName()); if (status.getGeoLocation() != null) { splitFields.put("geoLocation", status.getGeoLocation().toString()); } else { splitFields.put("geoLocation", ""); } if (status.getPlace() != null) { splitFields.put("place", status.getPlace().toString()); } else { splitFields.put("place", ""); } splitFields.put("retweetCount", Long.toString(status.getRetweetCount())); splitFields.put("wasRetweetedByMe", status.isRetweetedByMe() ? "1" : "0"); String contributors = ""; if (status.getContributors() != null) { long[] tempContributors = status.getContributors(); for (int i = 0; i < tempContributors.length; i++) { contributors += Long.toString(tempContributors[i]); if (i != tempContributors.length - 1) { contributors += ", "; } } } splitFields.put("contributors", contributors); splitFields.put("annotations", ""); if (status.getRetweetedStatus() != null) { splitFields.put("retweetedStatus", "1"); } else { splitFields.put("retweetedStatus", "0"); } splitFields.put("userMentionEntities", status.getUserMentionEntities().toString()); splitFields.put("urlEntities", status.getURLEntities().toString()); splitFields.put("hashtagEntities", status.getHashtagEntities().toString()); splitFields.put("user", status.getUser().toString()); return splitFields; }
From source file:br.com.porcelli.hornetq.integration.twitter.support.TweetMessageConverterSupport.java
License:Apache License
public static ServerMessage buildMessage(final String queueName, final Status status) { final ServerMessage msg = new ServerMessageImpl(status.getId(), InternalTwitterConstants.INITIAL_MESSAGE_BUFFER_SIZE); msg.setAddress(new SimpleString(queueName)); msg.setDurable(true);//from ww w.j a va 2s .c om msg.putStringProperty(TwitterConstants.KEY_MSG_TYPE, MessageType.TWEET.toString()); msg.putStringProperty(TwitterConstants.KEY_CREATED_AT, read(status.getCreatedAt())); msg.putStringProperty(TwitterConstants.KEY_ID, read(status.getId())); msg.putStringProperty(TwitterConstants.KEY_TEXT, read(status.getText())); msg.putStringProperty(TwitterConstants.KEY_SOURCE, read(status.getSource())); msg.putStringProperty(TwitterConstants.KEY_TRUNCATED, read(status.isTruncated())); msg.putStringProperty(TwitterConstants.KEY_IN_REPLY_TO_STATUS_ID, read(status.getInReplyToStatusId())); msg.putStringProperty(TwitterConstants.KEY_IN_REPLY_TO_USER_ID, read(status.getInReplyToUserId())); msg.putStringProperty(TwitterConstants.KEY_IN_REPLY_TO_SCREEN_NAME, read(status.getInReplyToScreenName())); msg.putStringProperty(TwitterConstants.KEY_RETWEET, read(status.isRetweet())); msg.putStringProperty(TwitterConstants.KEY_FAVORITED, read(status.isFavorited())); msg.putStringProperty(TwitterConstants.KEY_ENTITIES_URLS_JSON, read(status.getURLEntities())); msg.putStringProperty(TwitterConstants.KEY_ENTITIES_HASHTAGS_JSON, read(status.getHashtagEntities())); msg.putStringProperty(TwitterConstants.KEY_ENTITIES_MENTIONS_JSON, read(status.getUserMentionEntities())); msg.putStringProperty(TwitterConstants.KEY_CONTRIBUTORS_JSON, read(status.getContributors())); if (status.getUser() != null) { buildUserData("", status.getUser(), msg); } GeoLocation gl; if ((gl = status.getGeoLocation()) != null) { msg.putStringProperty(TwitterConstants.KEY_GEO_LATITUDE, read(gl.getLatitude())); msg.putStringProperty(TwitterConstants.KEY_GEO_LONGITUDE, read(gl.getLongitude())); } Place place; if ((place = status.getPlace()) != null) { msg.putStringProperty(TwitterConstants.KEY_PLACE_ID, read(place.getId())); msg.putStringProperty(TwitterConstants.KEY_PLACE_URL, read(place.getURL())); msg.putStringProperty(TwitterConstants.KEY_PLACE_NAME, read(place.getName())); msg.putStringProperty(TwitterConstants.KEY_PLACE_FULL_NAME, read(place.getFullName())); msg.putStringProperty(TwitterConstants.KEY_PLACE_COUNTRY_CODE, read(place.getCountryCode())); msg.putStringProperty(TwitterConstants.KEY_PLACE_COUNTRY, read(place.getCountry())); msg.putStringProperty(TwitterConstants.KEY_PLACE_STREET_ADDRESS, read(place.getStreetAddress())); msg.putStringProperty(TwitterConstants.KEY_PLACE_TYPE, read(place.getPlaceType())); msg.putStringProperty(TwitterConstants.KEY_PLACE_GEO_TYPE, read(place.getGeometryType())); msg.putStringProperty(TwitterConstants.KEY_PLACE_BOUNDING_BOX_TYPE, read(place.getBoundingBoxType())); msg.putStringProperty(TwitterConstants.KEY_PLACE_BOUNDING_BOX_COORDINATES_JSON, read(place.getBoundingBoxCoordinates().toString())); msg.putStringProperty(TwitterConstants.KEY_PLACE_BOUNDING_BOX_GEOMETRY_COORDINATES_JSON, read(place.getGeometryCoordinates().toString())); } msg.putStringProperty(TwitterConstants.KEY_RAW_JSON, status.toString()); return msg; }
From source file:com.github.jcustenborder.kafka.connect.twitter.StatusConverter.java
License:Apache License
public static void convert(Status status, Struct struct) { struct.put("CreatedAt", status.getCreatedAt()).put("Id", status.getId()).put("Text", status.getText()) .put("Source", status.getSource()).put("Truncated", status.isTruncated()) .put("InReplyToStatusId", status.getInReplyToStatusId()) .put("InReplyToUserId", status.getInReplyToUserId()) .put("InReplyToScreenName", status.getInReplyToScreenName()).put("Favorited", status.isFavorited()) .put("Retweeted", status.isRetweeted()).put("FavoriteCount", status.getFavoriteCount()) .put("Retweet", status.isRetweet()).put("RetweetCount", status.getRetweetCount()) .put("RetweetedByMe", status.isRetweetedByMe()) .put("CurrentUserRetweetId", status.getCurrentUserRetweetId()) .put("PossiblySensitive", status.isPossiblySensitive()).put("Lang", status.getLang()); Struct userStruct;/*w ww. j av a2 s . c om*/ if (null != status.getUser()) { userStruct = new Struct(USER_SCHEMA); convert(status.getUser(), userStruct); } else { userStruct = null; } struct.put("User", userStruct); Struct placeStruct; if (null != status.getPlace()) { placeStruct = new Struct(PLACE_SCHEMA); convert(status.getPlace(), placeStruct); } else { placeStruct = null; } struct.put("Place", placeStruct); Struct geoLocationStruct; if (null != status.getGeoLocation()) { geoLocationStruct = new Struct(GEO_LOCATION_SCHEMA); convert(status.getGeoLocation(), geoLocationStruct); } else { geoLocationStruct = null; } struct.put("GeoLocation", geoLocationStruct); List<Long> contributers = new ArrayList<>(); if (null != status.getContributors()) { for (Long l : status.getContributors()) { contributers.add(l); } } struct.put("Contributors", contributers); List<String> withheldInCountries = new ArrayList<>(); if (null != status.getWithheldInCountries()) { for (String s : status.getWithheldInCountries()) { withheldInCountries.add(s); } } struct.put("WithheldInCountries", withheldInCountries); struct.put("HashtagEntities", convert(status.getHashtagEntities())); struct.put("UserMentionEntities", convert(status.getUserMentionEntities())); struct.put("MediaEntities", convert(status.getMediaEntities())); struct.put("SymbolEntities", convert(status.getSymbolEntities())); struct.put("URLEntities", convert(status.getURLEntities())); }
From source file:com.raythos.sentilexo.twitter.domain.QueryResultItemMapper.java
License:Apache License
public static Map getFieldsMapFromStatus(String queryOwner, String queryName, String queryString, Status status) { if (queryName != null) queryName = queryName.toLowerCase(); if (queryOwner != null) queryOwner = queryOwner.toLowerCase(); Map m = StatusArraysHelper.getUserMentionMap(status); Map newMap = new HashMap(); for (Object key : m.keySet()) { newMap.put(key.toString(), (Long) m.get(key)); }/* w ww.j a v a 2s . c o m*/ Double longitude = null; Double lattitude = null; if (status.getGeoLocation() != null) { longitude = status.getGeoLocation().getLongitude(); lattitude = status.getGeoLocation().getLatitude(); } String place = null; if (status.getPlace() != null) { place = status.getPlace().getFullName(); } boolean isRetweet = status.getRetweetedStatus() != null; Long retweetedId = null; String retweetedText = null; if (isRetweet) { retweetedId = status.getRetweetedStatus().getId(); retweetedText = status.getRetweetedStatus().getText(); } Map<String, Object> result = new HashMap<>(); result.put(QueryResultItemFieldNames.STATUS_ID, status.getId()); result.put(QueryResultItemFieldNames.CREATED_AT, status.getCreatedAt()); result.put(QueryResultItemFieldNames.CURRENT_USER_RETWEET_ID, status.getCurrentUserRetweetId()); result.put(QueryResultItemFieldNames.FAVOURITE_COUNT, status.getFavoriteCount()); result.put(QueryResultItemFieldNames.FAVOURITED, status.isFavorited()); result.put(QueryResultItemFieldNames.HASHTAGS, StatusArraysHelper.getHashTagsList(status)); result.put(QueryResultItemFieldNames.IN_REPLY_TO_SCREEN_NAME, (status.getInReplyToScreenName())); result.put(QueryResultItemFieldNames.IN_REPLY_TO_STATUS_ID, status.getInReplyToStatusId()); result.put(QueryResultItemFieldNames.IN_REPLY_TO_USER_ID, status.getInReplyToUserId()); result.put(QueryResultItemFieldNames.LATITUDE, lattitude); result.put(QueryResultItemFieldNames.LONGITUDE, longitude); result.put(QueryResultItemFieldNames.MENTIONS, newMap); result.put(QueryResultItemFieldNames.LANGUAGE, status.getLang()); result.put(QueryResultItemFieldNames.PLACE, place); result.put(QueryResultItemFieldNames.POSSIBLY_SENSITIVE, status.isPossiblySensitive()); result.put(QueryResultItemFieldNames.QUERY_NAME, queryName); result.put(QueryResultItemFieldNames.QUERY_OWNER, queryOwner); result.put(QueryResultItemFieldNames.QUERY, queryString); result.put(QueryResultItemFieldNames.RELEVANT_QUERY_TERMS, TwitterUtils.relevantQueryTermsFromStatus(queryString, status)); result.put(QueryResultItemFieldNames.RETWEET, isRetweet); result.put(QueryResultItemFieldNames.RETWEET_COUNT, status.getRetweetCount()); result.put(QueryResultItemFieldNames.RETWEETED, status.isRetweeted()); result.put(QueryResultItemFieldNames.RETWEETED_BY_ME, status.isRetweetedByMe()); result.put(QueryResultItemFieldNames.RETWEET_STATUS_ID, retweetedId); result.put(QueryResultItemFieldNames.RETWEETED_TEXT, retweetedText); result.put(QueryResultItemFieldNames.SCOPES, StatusArraysHelper.getScopesList(status)); result.put(QueryResultItemFieldNames.SCREEN_NAME, status.getUser().getScreenName()); result.put(QueryResultItemFieldNames.SOURCE, (status.getSource())); result.put(QueryResultItemFieldNames.TEXT, (status.getText())); result.put(QueryResultItemFieldNames.TRUNCATED, status.isTruncated()); result.put(QueryResultItemFieldNames.URLS, StatusArraysHelper.getUrlsList(status)); result.put(QueryResultItemFieldNames.USER_ID, status.getUser().getId()); result.put(QueryResultItemFieldNames.USER_NAME, (status.getUser().getName())); result.put(QueryResultItemFieldNames.USER_DESCRIPTION, (status.getUser().getDescription())); result.put(QueryResultItemFieldNames.USER_LOCATION, (status.getUser().getLocation())); result.put(QueryResultItemFieldNames.USER_URL, (status.getUser().getURL())); result.put(QueryResultItemFieldNames.USER_IS_PROTECTED, status.getUser().isProtected()); result.put(QueryResultItemFieldNames.USER_FOLLOWERS_COUNT, status.getUser().getFollowersCount()); result.put(QueryResultItemFieldNames.USER_CREATED_AT, status.getUser().getCreatedAt()); result.put(QueryResultItemFieldNames.USER_FRIENDS_COUNT, status.getUser().getFriendsCount()); result.put(QueryResultItemFieldNames.USER_LISTED_COUNT, status.getUser().getListedCount()); result.put(QueryResultItemFieldNames.USER_STATUSES_COUNT, status.getUser().getStatusesCount()); result.put(QueryResultItemFieldNames.USER_FAVOURITES_COUNT, status.getUser().getFavouritesCount()); return result; }
From source file:com.raythos.sentilexo.twitter.domain.QueryResultItemMapper.java
License:Apache License
public static TwitterQueryResultItemAvro mapItem(String queryOwner, String queryName, String queryString, Status status) { TwitterQueryResultItemAvro result = new TwitterQueryResultItemAvro(); if (queryName != null) queryName = queryName.toLowerCase(); if (queryOwner != null) queryOwner = queryOwner.toLowerCase(); result.setQueryName(queryName);//from www .j a v a 2 s . co m result.setQueryOwner(queryOwner); result.setQuery(queryString); result.setStatusId(status.getId()); result.setText(status.getText()); result.setRelevantQueryTerms(TwitterUtils.relevantQueryTermsFromStatus(queryString, status)); result.setLang(status.getLang()); result.setCreatedAt(status.getCreatedAt().getTime()); User user = status.getUser(); result.setUserId(user.getId()); result.setScreenName(user.getScreenName()); result.setUserLocation(user.getLocation()); result.setUserName(user.getName()); result.setUserDescription(user.getDescription()); result.setUserIsProtected(user.isProtected()); result.setUserFollowersCount(user.getFollowersCount()); result.setUserCreatedAt(user.getCreatedAt().getTime()); result.setUserCreatedAtAsString(DateTimeUtils.getDateAsText(user.getCreatedAt())); result.setCreatedAtAsString(DateTimeUtils.getDateAsText(status.getCreatedAt())); result.setUserFriendsCount(user.getFriendsCount()); result.setUserListedCount(user.getListedCount()); result.setUserStatusesCount(user.getStatusesCount()); result.setUserFavoritesCount(user.getFavouritesCount()); result.setCurrentUserRetweetId(status.getCurrentUserRetweetId()); result.setInReplyToScreenName(status.getInReplyToScreenName()); result.setInReplyToStatusId(status.getInReplyToStatusId()); result.setInReplyToUserId(status.getInReplyToUserId()); if (status.getGeoLocation() != null) { result.setLatitude(status.getGeoLocation().getLatitude()); result.setLongitude(status.getGeoLocation().getLongitude()); } result.setSource(status.getSource()); result.setTrucated(status.isTruncated()); result.setPossiblySensitive(status.isPossiblySensitive()); result.setRetweet(status.getRetweetedStatus() != null); if (result.getRetweet()) { result.setRetweetStatusId(status.getRetweetedStatus().getId()); result.setRetweetedText(status.getRetweetedStatus().getText()); } result.setRetweeted(status.isRetweeted()); result.setRetweetCount(status.getRetweetCount()); result.setRetweetedByMe(status.isRetweetedByMe()); result.setFavoriteCount(status.getFavoriteCount()); result.setFavourited(status.isFavorited()); if (status.getPlace() != null) { result.setPlace(status.getPlace().getFullName()); } Scopes scopesObj = status.getScopes(); if (scopesObj != null) { List scopes = Arrays.asList(scopesObj.getPlaceIds()); result.setScopes(scopes); } return result; }
From source file:info.maslowis.twitterripper.util.Util.java
License:Open Source License
/** * Returns a representation the status (tweet) as string * * @return a representation the status as string in format <em>Status{id=, text='', lang='', createdAt=, geoLocation=, isFavorited=, isRetweeted=, retweetCount=, isTruncated=}</em> */// w w w .ja v a 2 s. c om public static String toString(final Status status) { return "Status{id=" + status.getId() + ", text='" + status.getText() + "', lang='" + status.getLang() + "', createdAt=" + status.getCreatedAt() + ", geoLocation=" + status.getGeoLocation() + ", isFavorited=" + status.isFavorited() + ", isRetweeted=" + status.isRetweeted() + ", retweetCount=" + status.getRetweetCount() + ", isTruncated=" + status.isTruncated() + "}"; }
From source file:nl.isaac.dotcms.twitter.pojo.CustomStatus.java
License:Creative Commons License
public CustomStatus(Status status) { this.createdAt = status.getCreatedAt(); this.id = status.getId(); this.id_str = String.valueOf(status.getId()); this.text = status.getText(); this.source = status.getSource(); this.isTruncated = status.isTruncated(); this.inReplyToStatusId = status.getInReplyToStatusId(); this.inReplyToUserId = status.getInReplyToUserId(); this.isFavorited = status.isFavorited(); this.inReplyToScreenName = status.getInReplyToScreenName(); this.geoLocation = status.getGeoLocation(); this.place = status.getPlace(); this.retweetCount = status.getRetweetCount(); this.isPossiblySensitive = status.isPossiblySensitive(); this.contributorsIDs = status.getContributors(); this.retweetedStatus = status.getRetweetedStatus(); this.userMentionEntities = status.getUserMentionEntities(); this.urlEntities = status.getURLEntities(); this.hashtagEntities = status.getHashtagEntities(); this.mediaEntities = status.getMediaEntities(); this.currentUserRetweetId = status.getCurrentUserRetweetId(); this.isRetweet = status.isRetweet(); this.isRetweetedByMe = status.isRetweetedByMe(); this.rateLimitStatus = status.getRateLimitStatus(); this.accessLevel = status.getAccessLevel(); this.user = status.getUser(); }
From source file:org.bireme.interop.toJson.Twitter2Json.java
License:Open Source License
private JSONObject getDocument(final Status status) { assert status != null; final JSONObject obj = new JSONObject(); final GeoLocation geo = status.getGeoLocation(); final Place place = status.getPlace(); final User user = status.getUser(); obj.put("createdAt", status.getCreatedAt()).put("id", status.getId()).put("lang", status.getLang()); if (geo != null) { obj.put("location_latitude", geo.getLatitude()).put("location_longitude", geo.getLongitude()); }/* w w w . j av a2s . c o m*/ if (place != null) { obj.put("place_country", place.getCountry()).put("place_fullName", place.getFullName()) .put("place_id", place.getId()).put("place_name", place.getName()) .put("place_type", place.getPlaceType()).put("place_streetAddress", place.getStreetAddress()) .put("place_url", place.getURL()); } obj.put("source", status.getSource()).put("text", status.getText()); if (user != null) { obj.put("user_description", user.getDescription()).put("user_id", user.getId()) .put("user_lang", user.getLang()).put("user_location", user.getLocation()) .put("user_name", user.getName()).put("user_url", user.getURL()); } obj.put("isTruncated", status.isTruncated()).put("isRetweet", status.isRetweet()); return obj; }
From source file:org.hornetq.integration.twitter.impl.IncomingTweetsHandler.java
License:Apache License
private void putTweetIntoMessage(final Status status, final ServerMessage msg) { msg.getBodyBuffer().writeString(status.getText()); msg.putLongProperty(TwitterConstants.KEY_ID, status.getId()); msg.putStringProperty(TwitterConstants.KEY_SOURCE, status.getSource()); msg.putLongProperty(TwitterConstants.KEY_CREATED_AT, status.getCreatedAt().getTime()); msg.putBooleanProperty(TwitterConstants.KEY_IS_TRUNCATED, status.isTruncated()); msg.putLongProperty(TwitterConstants.KEY_IN_REPLY_TO_STATUS_ID, status.getInReplyToStatusId()); msg.putIntProperty(TwitterConstants.KEY_IN_REPLY_TO_USER_ID, status.getInReplyToUserId()); msg.putBooleanProperty(TwitterConstants.KEY_IS_FAVORITED, status.isFavorited()); msg.putBooleanProperty(TwitterConstants.KEY_IS_RETWEET, status.isRetweet()); msg.putObjectProperty(TwitterConstants.KEY_CONTRIBUTORS, status.getContributors()); GeoLocation gl;//from w w w. j a va 2 s. c om if ((gl = status.getGeoLocation()) != null) { msg.putDoubleProperty(TwitterConstants.KEY_GEO_LOCATION_LATITUDE, gl.getLatitude()); msg.putDoubleProperty(TwitterConstants.KEY_GEO_LOCATION_LONGITUDE, gl.getLongitude()); } Place place; if ((place = status.getPlace()) != null) { msg.putStringProperty(TwitterConstants.KEY_PLACE_ID, place.getId()); } }
From source file:org.kuali.mobility.conference.controllers.ConferenceController.java
License:Open Source License
@RequestMapping(value = "twitter-search", method = RequestMethod.GET) public ResponseEntity<String> twitterSearch(@RequestParam(value = "term", required = true) String searchParam, @RequestParam(value = "since", required = false) String sinceParam, HttpServletRequest request) { Twitter twitter = TwitterFactory.getSingleton(); Query query = new Query(searchParam.isEmpty() ? "#kualidays" : searchParam); QueryResult result = null;/*from w ww. j a v a2 s . c om*/ query.setSince(!sinceParam.isEmpty() ? sinceParam : "2014-01-01"); query.setCount(100); query.setResultType(Query.MIXED); String json = ""; List<String> tweetList = new ArrayList<String>(); try { result = twitter.search(query); } catch (TwitterException e) { System.err.println("Caught 'twitterSearch' IOException: " + e.getMessage()); } String tweetInfo = ""; for (Status status : result.getTweets()) { tweetInfo = "{"; tweetInfo += "\"id\" : \"" + status.getId() + "\", "; tweetInfo += "\"avatar\" : \"" + status.getUser().getProfileImageURL() + "\", "; tweetInfo += "\"tweetedOn\" : \"" + status.getCreatedAt() + "\", "; tweetInfo += "\"tweetedOnParsed\" : \"" + status.getCreatedAt().getTime() + "\", "; tweetInfo += "\"screenname\" : \"" + status.getUser().getScreenName() + "\", "; tweetInfo += "\"status\" : \"" + StringEscapeUtils.escapeHtml(status.getText().replaceAll("(\\r|\\n)", "")) + "\", "; tweetInfo += "\"truncated\" : \"" + (status.isTruncated() ? "true" : "false") + "\","; tweetInfo += "\"retweeted\" : \"" + (status.isRetweet() ? "true" : "false") + "\""; tweetInfo += "}"; tweetList.add(tweetInfo); } json = "[" + StringUtils.arrayToDelimitedString(tweetList.toArray(), ",") + "]"; return new ResponseEntity<String>(json, HttpStatus.OK); }