List of usage examples for twitter4j GeoLocation getLongitude
public double getLongitude()
From source file:io.rakam.datasource.twitter.TweetProcessor.java
License:Apache License
@Override public void onStatus(Status status) { Map<String, Object> map = new HashMap<>(); GeoLocation geoLocation = status.getGeoLocation(); if (geoLocation != null) { map.put("latitude", geoLocation.getLatitude()); map.put("longitude", geoLocation.getLongitude()); }/* w w w .j a va 2 s . c o m*/ map.put("_time", status.getCreatedAt().getTime()); Place place = status.getPlace(); if (place != null) { map.put("country_code", place.getCountryCode()); map.put("place", place.getName()); map.put("place_type", place.getPlaceType()); map.put("place_id", place.getId()); } User user = status.getUser(); map.put("_user", user.getId()); map.put("user_lang", user.getLang()); map.put("user_created", user.getCreatedAt()); map.put("user_followers", user.getFollowersCount()); map.put("user_status_count", user.getStatusesCount()); map.put("user_verified", user.isVerified()); map.put("id", status.getId()); map.put("is_reply", status.getInReplyToUserId() > -1); map.put("is_retweet", status.isRetweet()); map.put("has_media", status.getMediaEntities().length > 0); map.put("urls", Arrays.stream(status.getURLEntities()).map(URLEntity::getText).collect(Collectors.toList())); map.put("hashtags", Arrays.stream(status.getHashtagEntities()).map(HashtagEntity::getText) .collect(Collectors.toList())); map.put("user_mentions", Arrays.stream(status.getUserMentionEntities()).map(UserMentionEntity::getText) .collect(Collectors.toList())); map.put("language", "und".equals(status.getLang()) ? null : status.getLang()); map.put("is_positive", classifier.isPositive(status.getText())); Event event = new Event().properties(map).collection(collection); buffer.add(event); commitIfNecessary(); }
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()); }/*from ww w . ja v a 2s. 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.codice.ddf.catalog.twitter.source.TwitterSource.java
License:Open Source License
private Metacard getMetacard(Status status) { MetacardImpl metacard = new MetacardImpl(); metacard.setSourceId(id);//from ww w . ja v a 2 s . c o m metacard.setId(String.valueOf(status.getId())); metacard.setTitle(status.getText()); metacard.setMetadata("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<Resource>" + "<name>" + status.getText() + "</name>" + "</Resource>"); metacard.setCreatedDate(status.getCreatedAt()); metacard.setModifiedDate(status.getCreatedAt()); metacard.setEffectiveDate(status.getCreatedAt()); metacard.setPointOfContact(status.getUser().getName()); if (status.getURLEntities() != null && status.getURLEntities().length > 0) { try { metacard.setResourceURI(new URI(status.getURLEntities()[0].getExpandedURL())); } catch (URISyntaxException e) { LOGGER.error("Unable to set resource URI.", e); } } else if (status.getMediaEntities() != null && status.getMediaEntities().length > 0) { try { metacard.setResourceURI(new URI(status.getMediaEntities()[0].getExpandedURL())); } catch (URISyntaxException e) { LOGGER.error("Unable to set resource URI.", e); } } else if (status.getExtendedMediaEntities() != null && status.getExtendedMediaEntities().length > 0) { try { metacard.setResourceURI(new URI(status.getExtendedMediaEntities()[0].getExpandedURL())); } catch (URISyntaxException e) { LOGGER.error("Unable to set resource URI.", e); } } GeoLocation geoLocation = status.getGeoLocation(); if (geoLocation != null) { metacard.setLocation("POINT (" + geoLocation.getLongitude() + " " + geoLocation.getLatitude() + ")"); } return metacard; }
From source file:org.gabrielebaldassarre.twitter.stream.tweet.TalendRowTweetBehaviour.java
License:Open Source License
public void visit(TalendFlow target) { ResourceBundle rb = ResourceBundle.getBundle("tTwitterStreamInput", Locale.getDefault()); valid = false;/* www . j av a 2 s . c om*/ if (status != null) { TalendRowFactory rowFactory = target.getModel().getRowFactory(); Status tweet = status; status = null; TalendRow current = rowFactory.newRow(target); Iterator<Entry<TalendColumn, TweetField>> col = associations.entrySet().iterator(); while (col.hasNext()) { List<String> h; List<Long> l; Map.Entry<TalendColumn, TweetField> row = (Map.Entry<TalendColumn, TweetField>) col.next(); if (target != null && !row.getKey().getFlow().equals(target)) { throw new IllegalArgumentException(String.format(rb.getString("exception.columnNotInFlow"), row.getKey().getName(), target.getName())); } switch (row.getValue()) { case CREATION_DATE: String literalDate = (new StringBuilder( TalendRowTweetBehaviour.DATEFORMAT.format(tweet.getCreatedAt()))).toString(); switch (row.getKey().getType()) { case BIGDECIMAL: current.setValue(row.getKey(), new BigDecimal(literalDate)); case LONG: current.setValue(row.getKey(), Long.parseLong(literalDate)); case DOUBLE: current.setValue(row.getKey(), Double.parseDouble(literalDate)); case FLOAT: current.setValue(row.getKey(), Float.parseFloat(literalDate)); case INTEGER: current.setValue(row.getKey(), Integer.parseInt(literalDate)); case DATE: current.setValue(row.getKey(), tweet.getCreatedAt()); break; case STRING: current.setValue(row.getKey(), literalDate); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case FROM_NAME: switch (row.getKey().getType()) { case STRING: current.setValue(row.getKey(), tweet.getUser().getName()); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case FROM_USERID: switch (row.getKey().getType()) { case BIGDECIMAL: current.setValue(row.getKey(), new BigDecimal(tweet.getUser().getId())); break; case DOUBLE: current.setValue(row.getKey(), new Double(tweet.getUser().getId())); break; case FLOAT: current.setValue(row.getKey(), new Float(tweet.getUser().getId())); break; case LONG: current.setValue(row.getKey(), new Long(tweet.getUser().getId())); break; case STRING: current.setValue(row.getKey(), String.valueOf((tweet.getUser().getId()))); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case FROM_SCREEN_NAME: switch (row.getKey().getType()) { case STRING: current.setValue(row.getKey(), tweet.getUser().getScreenName()); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case HASHTAGS: List<HashtagEntity> hashtags = Arrays.asList(tweet.getHashtagEntities()); h = new ArrayList<String>(hashtags.size()); for (HashtagEntity hashtag : hashtags) { h.add((includeHash() ? "#" : "") + hashtag.getText()); } switch (row.getKey().getType()) { case STRING: case LIST: current.setValue(row.getKey(), !TalendType.STRING.equals(row.getKey().getType()) ? h : Joiner.on(getEntitiesSeparator()).join(h)); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case IS_FAVORITED: switch (row.getKey().getType()) { case BIGDECIMAL: current.setValue(row.getKey(), new BigDecimal(tweet.isFavorited() ? 1 : 0)); break; case BOOLEAN: current.setValue(row.getKey(), tweet.isFavorited()); break; case BYTE: current.setValue(row.getKey(), (byte) (tweet.isFavorited() ? 1 : 0)); break; case CHARACTER: current.setValue(row.getKey(), (tweet.isFavorited() ? '1' : '0')); break; case DOUBLE: current.setValue(row.getKey(), (double) (tweet.isFavorited() ? 1d : 0d)); break; case FLOAT: current.setValue(row.getKey(), (float) (tweet.isFavorited() ? 1f : 0f)); break; case INTEGER: current.setValue(row.getKey(), (tweet.isFavorited() ? 1 : 0)); break; case LONG: current.setValue(row.getKey(), (long) (tweet.isFavorited() ? 1l : 0l)); break; case SHORT: current.setValue(row.getKey(), (short) (tweet.isFavorited() ? (short) 1 : (short) 0)); break; case STRING: current.setValue(row.getKey(), (tweet.isFavorited() ? "1" : "0")); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case IS_POSSIBLY_SENSITIVE: switch (row.getKey().getType()) { case BIGDECIMAL: current.setValue(row.getKey(), new BigDecimal(tweet.isPossiblySensitive() ? 1 : 0)); break; case BOOLEAN: current.setValue(row.getKey(), tweet.isPossiblySensitive()); break; case BYTE: current.setValue(row.getKey(), (byte) (tweet.isPossiblySensitive() ? 1 : 0)); break; case CHARACTER: current.setValue(row.getKey(), (tweet.isPossiblySensitive() ? '1' : '0')); break; case DOUBLE: current.setValue(row.getKey(), (double) (tweet.isPossiblySensitive() ? 1d : 0d)); break; case FLOAT: current.setValue(row.getKey(), (float) (tweet.isPossiblySensitive() ? 1f : 0f)); break; case INTEGER: current.setValue(row.getKey(), (tweet.isPossiblySensitive() ? 1 : 0)); break; case LONG: current.setValue(row.getKey(), (long) (tweet.isPossiblySensitive() ? 1l : 0l)); break; case SHORT: current.setValue(row.getKey(), (short) (tweet.isPossiblySensitive() ? (short) 1 : (short) 0)); break; case STRING: current.setValue(row.getKey(), (tweet.isPossiblySensitive() ? "1" : "0")); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case IS_RETWEET: switch (row.getKey().getType()) { case BIGDECIMAL: current.setValue(row.getKey(), new BigDecimal(tweet.isRetweet() ? 1 : 0)); break; case BOOLEAN: current.setValue(row.getKey(), tweet.isRetweet()); break; case BYTE: current.setValue(row.getKey(), (byte) (tweet.isRetweet() ? 1 : 0)); break; case CHARACTER: current.setValue(row.getKey(), (tweet.isRetweet() ? '1' : '0')); break; case DOUBLE: current.setValue(row.getKey(), (double) (tweet.isRetweet() ? 1d : 0d)); break; case FLOAT: current.setValue(row.getKey(), (float) (tweet.isRetweet() ? 1f : 0f)); break; case INTEGER: current.setValue(row.getKey(), (tweet.isRetweet() ? 1 : 0)); break; case LONG: current.setValue(row.getKey(), (long) (tweet.isRetweet() ? 1l : 0l)); break; case SHORT: current.setValue(row.getKey(), (short) (tweet.isRetweet() ? (short) 1 : (short) 0)); break; case STRING: current.setValue(row.getKey(), (tweet.isRetweet() ? "1" : "0")); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } current.setValue(row.getKey(), tweet.isRetweet()); break; case LOCATION: GeoLocation g = tweet.getGeoLocation(); switch (row.getKey().getType()) { case STRING: current.setValue(row.getKey(), g != null ? String.valueOf(g.getLatitude()) + getEntitiesSeparator() + String.valueOf(g.getLongitude()) : null); break; case OBJECT: current.setValue(row.getKey(), g); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case REPLYTO_SCREEN_NAME: switch (row.getKey().getType()) { case STRING: current.setValue(row.getKey(), tweet.getInReplyToScreenName()); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case REPLYTO_STATUSID: switch (row.getKey().getType()) { case BIGDECIMAL: current.setValue(row.getKey(), new BigDecimal(tweet.getInReplyToStatusId())); break; case DOUBLE: current.setValue(row.getKey(), new Double(tweet.getInReplyToStatusId())); break; case FLOAT: current.setValue(row.getKey(), new Float(tweet.getInReplyToStatusId())); break; case LONG: current.setValue(row.getKey(), new Long(tweet.getInReplyToStatusId())); break; case STRING: current.setValue(row.getKey(), String.valueOf((tweet.getInReplyToStatusId()))); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case REPLYTO_USERID: switch (row.getKey().getType()) { case BIGDECIMAL: current.setValue(row.getKey(), new BigDecimal(tweet.getInReplyToUserId())); break; case DOUBLE: current.setValue(row.getKey(), new Double(tweet.getInReplyToUserId())); break; case FLOAT: current.setValue(row.getKey(), new Float(tweet.getInReplyToUserId())); break; case LONG: current.setValue(row.getKey(), new Long(tweet.getInReplyToUserId())); break; case STRING: current.setValue(row.getKey(), String.valueOf((tweet.getInReplyToUserId()))); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case RETWEET_COUNT: switch (row.getKey().getType()) { case BIGDECIMAL: current.setValue(row.getKey(), new BigDecimal(tweet.getRetweetCount())); break; case DOUBLE: current.setValue(row.getKey(), new Double(tweet.getRetweetCount())); break; case FLOAT: current.setValue(row.getKey(), new Float(tweet.getRetweetCount())); break; case LONG: current.setValue(row.getKey(), new Long(tweet.getRetweetCount())); break; case STRING: current.setValue(row.getKey(), String.valueOf((tweet.getRetweetCount()))); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case SOURCE: switch (row.getKey().getType()) { case STRING: current.setValue(row.getKey(), tweet.getSource()); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case STATUS_ID: switch (row.getKey().getType()) { case BIGDECIMAL: current.setValue(row.getKey(), new BigDecimal(tweet.getId())); break; case DOUBLE: current.setValue(row.getKey(), new Double(tweet.getId())); break; case FLOAT: current.setValue(row.getKey(), new Float(tweet.getId())); break; case LONG: current.setValue(row.getKey(), new Long(tweet.getId())); break; case STRING: current.setValue(row.getKey(), String.valueOf((tweet.getId()))); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case TEXT: switch (row.getKey().getType()) { case STRING: current.setValue(row.getKey(), tweet.getText()); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case URL_ENTITIES: case URL_ENTITIES_STRING: List<URLEntity> urlEntities = Arrays.asList(tweet.getURLEntities()); h = new ArrayList<String>(urlEntities.size()); for (URLEntity urlEntity : urlEntities) { h.add(urlEntity.getExpandedURL()); } switch (row.getKey().getType()) { case STRING: case LIST: current.setValue(row.getKey(), !TalendType.STRING.equals(row.getKey().getType()) ? h : Joiner.on(getEntitiesSeparator()).join(h)); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case USER_MENTIONS: List<UserMentionEntity> userMentionsEntities = Arrays.asList(tweet.getUserMentionEntities()); l = new ArrayList<Long>(userMentionsEntities.size()); for (UserMentionEntity userMention : userMentionsEntities) { l.add(userMention.getId()); } switch (row.getKey().getType()) { case STRING: case LIST: current.setValue(row.getKey(), !TalendType.STRING.equals(row.getKey().getType()) ? l : Joiner.on(getEntitiesSeparator()).join(l)); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case USER_MENTIONS_SCREEN_NAME: List<UserMentionEntity> userMentionsScreen = Arrays.asList(tweet.getUserMentionEntities()); h = new ArrayList<String>(userMentionsScreen.size()); for (UserMentionEntity userMention : userMentionsScreen) { h.add((includeHash() ? "@" : "") + userMention.getScreenName()); } switch (row.getKey().getType()) { case STRING: case LIST: current.setValue(row.getKey(), !TalendType.STRING.equals(row.getKey().getType()) ? h : Joiner.on(getEntitiesSeparator()).join(h)); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; default: throw new IllegalArgumentException( String.format(rb.getString("exception.unparseableColumn"), row.getKey().getName())); } } } valid = true; }
From source file:org.gabrielebaldassarre.twitter.tweet.TalendFlowTweetBehaviour.java
License:Open Source License
/** * Visit a target {@link TalendFlow} for parsed or raw json output. * // ww w . j av a2 s .c o m * @param target the data flow to fill */ public void visit(TalendFlow target) { ResourceBundle rb = ResourceBundle.getBundle("tTwitterInput", Locale.getDefault()); TalendRowFactory rowFactory = target.getModel().getRowFactory(); valid = false; @SuppressWarnings("unchecked") List<Status> tweets = (List<Status>) resultSet.getValue(); for (int i = 0; i < tweets.size(); i++) { Status tweet = tweets.get(i); TalendRow current = rowFactory.newRow(target); Iterator<Entry<TalendColumn, TweetField>> col = associations.entrySet().iterator(); while (col.hasNext()) { List<String> h; List<Long> l; Map.Entry<TalendColumn, TweetField> row = (Map.Entry<TalendColumn, TweetField>) col.next(); if (target != null && !row.getKey().getFlow().equals(target)) { throw new IllegalArgumentException(String.format(rb.getString("exception.columnNotInFlow"), row.getKey().getName(), target.getName())); } switch (row.getValue()) { case CREATION_DATE: String literalDate = (new StringBuilder( TalendFlowTweetBehaviour.DATEFORMAT.format(tweet.getCreatedAt()))).toString(); switch (row.getKey().getType()) { case BIGDECIMAL: current.setValue(row.getKey(), new BigDecimal(literalDate)); case LONG: current.setValue(row.getKey(), Long.parseLong(literalDate)); case DOUBLE: current.setValue(row.getKey(), Double.parseDouble(literalDate)); case FLOAT: current.setValue(row.getKey(), Float.parseFloat(literalDate)); case INTEGER: current.setValue(row.getKey(), Integer.parseInt(literalDate)); case DATE: current.setValue(row.getKey(), tweet.getCreatedAt()); break; case STRING: current.setValue(row.getKey(), literalDate); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case FROM_NAME: switch (row.getKey().getType()) { case STRING: current.setValue(row.getKey(), tweet.getUser().getName()); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case FROM_USERID: switch (row.getKey().getType()) { case BIGDECIMAL: current.setValue(row.getKey(), new BigDecimal(tweet.getUser().getId())); break; case DOUBLE: current.setValue(row.getKey(), new Double(tweet.getUser().getId())); break; case FLOAT: current.setValue(row.getKey(), new Float(tweet.getUser().getId())); break; case LONG: current.setValue(row.getKey(), new Long(tweet.getUser().getId())); break; case STRING: current.setValue(row.getKey(), String.valueOf((tweet.getUser().getId()))); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case FROM_SCREEN_NAME: switch (row.getKey().getType()) { case STRING: current.setValue(row.getKey(), tweet.getUser().getScreenName()); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case HASHTAGS: List<HashtagEntity> hashtags = Arrays.asList(tweet.getHashtagEntities()); h = new ArrayList<String>(hashtags.size()); for (HashtagEntity hashtag : hashtags) { h.add((includeHash() ? "#" : "") + hashtag.getText()); } switch (row.getKey().getType()) { case STRING: case LIST: current.setValue(row.getKey(), !TalendType.STRING.equals(row.getKey().getType()) ? h : Joiner.on(getEntitiesSeparator()).join(h)); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case IS_FAVORITED: switch (row.getKey().getType()) { case BIGDECIMAL: current.setValue(row.getKey(), new BigDecimal(tweet.isFavorited() ? 1 : 0)); break; case BOOLEAN: current.setValue(row.getKey(), tweet.isFavorited()); break; case BYTE: current.setValue(row.getKey(), (byte) (tweet.isFavorited() ? 1 : 0)); break; case CHARACTER: current.setValue(row.getKey(), (tweet.isFavorited() ? '1' : '0')); break; case DOUBLE: current.setValue(row.getKey(), (double) (tweet.isFavorited() ? 1d : 0d)); break; case FLOAT: current.setValue(row.getKey(), (float) (tweet.isFavorited() ? 1f : 0f)); break; case INTEGER: current.setValue(row.getKey(), (tweet.isFavorited() ? 1 : 0)); break; case LONG: current.setValue(row.getKey(), (long) (tweet.isFavorited() ? 1l : 0l)); break; case SHORT: current.setValue(row.getKey(), (short) (tweet.isFavorited() ? (short) 1 : (short) 0)); break; case STRING: current.setValue(row.getKey(), (tweet.isFavorited() ? "1" : "0")); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case IS_POSSIBLY_SENSITIVE: switch (row.getKey().getType()) { case BIGDECIMAL: current.setValue(row.getKey(), new BigDecimal(tweet.isPossiblySensitive() ? 1 : 0)); break; case BOOLEAN: current.setValue(row.getKey(), tweet.isPossiblySensitive()); break; case BYTE: current.setValue(row.getKey(), (byte) (tweet.isPossiblySensitive() ? 1 : 0)); break; case CHARACTER: current.setValue(row.getKey(), (tweet.isPossiblySensitive() ? '1' : '0')); break; case DOUBLE: current.setValue(row.getKey(), (double) (tweet.isPossiblySensitive() ? 1d : 0d)); break; case FLOAT: current.setValue(row.getKey(), (float) (tweet.isPossiblySensitive() ? 1f : 0f)); break; case INTEGER: current.setValue(row.getKey(), (tweet.isPossiblySensitive() ? 1 : 0)); break; case LONG: current.setValue(row.getKey(), (long) (tweet.isPossiblySensitive() ? 1l : 0l)); break; case SHORT: current.setValue(row.getKey(), (short) (tweet.isPossiblySensitive() ? (short) 1 : (short) 0)); break; case STRING: current.setValue(row.getKey(), (tweet.isPossiblySensitive() ? "1" : "0")); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case IS_RETWEET: switch (row.getKey().getType()) { case BIGDECIMAL: current.setValue(row.getKey(), new BigDecimal(tweet.isRetweet() ? 1 : 0)); break; case BOOLEAN: current.setValue(row.getKey(), tweet.isRetweet()); break; case BYTE: current.setValue(row.getKey(), (byte) (tweet.isRetweet() ? 1 : 0)); break; case CHARACTER: current.setValue(row.getKey(), (tweet.isRetweet() ? '1' : '0')); break; case DOUBLE: current.setValue(row.getKey(), (double) (tweet.isRetweet() ? 1d : 0d)); break; case FLOAT: current.setValue(row.getKey(), (float) (tweet.isRetweet() ? 1f : 0f)); break; case INTEGER: current.setValue(row.getKey(), (tweet.isRetweet() ? 1 : 0)); break; case LONG: current.setValue(row.getKey(), (long) (tweet.isRetweet() ? 1l : 0l)); break; case SHORT: current.setValue(row.getKey(), (short) (tweet.isRetweet() ? (short) 1 : (short) 0)); break; case STRING: current.setValue(row.getKey(), (tweet.isRetweet() ? "1" : "0")); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } current.setValue(row.getKey(), tweet.isRetweet()); break; case LOCATION: GeoLocation g = tweet.getGeoLocation(); switch (row.getKey().getType()) { case STRING: current.setValue(row.getKey(), g != null ? String.valueOf(g.getLatitude()) + getEntitiesSeparator() + String.valueOf(g.getLongitude()) : null); break; case OBJECT: current.setValue(row.getKey(), g); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case REPLYTO_SCREEN_NAME: switch (row.getKey().getType()) { case STRING: current.setValue(row.getKey(), tweet.getInReplyToScreenName()); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case REPLYTO_STATUSID: switch (row.getKey().getType()) { case BIGDECIMAL: current.setValue(row.getKey(), new BigDecimal(tweet.getInReplyToStatusId())); break; case DOUBLE: current.setValue(row.getKey(), new Double(tweet.getInReplyToStatusId())); break; case FLOAT: current.setValue(row.getKey(), new Float(tweet.getInReplyToStatusId())); break; case LONG: current.setValue(row.getKey(), new Long(tweet.getInReplyToStatusId())); break; case STRING: current.setValue(row.getKey(), String.valueOf((tweet.getInReplyToStatusId()))); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case REPLYTO_USERID: switch (row.getKey().getType()) { case BIGDECIMAL: current.setValue(row.getKey(), new BigDecimal(tweet.getInReplyToUserId())); break; case DOUBLE: current.setValue(row.getKey(), new Double(tweet.getInReplyToUserId())); break; case FLOAT: current.setValue(row.getKey(), new Float(tweet.getInReplyToUserId())); break; case LONG: current.setValue(row.getKey(), new Long(tweet.getInReplyToUserId())); break; case STRING: current.setValue(row.getKey(), String.valueOf((tweet.getInReplyToUserId()))); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case RETWEET_COUNT: switch (row.getKey().getType()) { case BIGDECIMAL: current.setValue(row.getKey(), new BigDecimal(tweet.getRetweetCount())); break; case DOUBLE: current.setValue(row.getKey(), new Double(tweet.getRetweetCount())); break; case FLOAT: current.setValue(row.getKey(), new Float(tweet.getRetweetCount())); break; case LONG: current.setValue(row.getKey(), new Long(tweet.getRetweetCount())); break; case STRING: current.setValue(row.getKey(), String.valueOf((tweet.getRetweetCount()))); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case SOURCE: switch (row.getKey().getType()) { case STRING: current.setValue(row.getKey(), tweet.getSource()); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case STATUS_ID: switch (row.getKey().getType()) { case BIGDECIMAL: current.setValue(row.getKey(), new BigDecimal(tweet.getId())); break; case DOUBLE: current.setValue(row.getKey(), new Double(tweet.getId())); break; case FLOAT: current.setValue(row.getKey(), new Float(tweet.getId())); break; case LONG: current.setValue(row.getKey(), new Long(tweet.getId())); break; case STRING: current.setValue(row.getKey(), String.valueOf((tweet.getId()))); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case TEXT: switch (row.getKey().getType()) { case STRING: current.setValue(row.getKey(), tweet.getText()); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case URL_ENTITIES: case URL_ENTITIES_STRING: List<URLEntity> urlEntities = Arrays.asList(tweet.getURLEntities()); h = new ArrayList<String>(urlEntities.size()); for (URLEntity urlEntity : urlEntities) { h.add(urlEntity.getExpandedURL()); } switch (row.getKey().getType()) { case STRING: case LIST: current.setValue(row.getKey(), !TalendType.STRING.equals(row.getKey().getType()) ? h : Joiner.on(getEntitiesSeparator()).join(h)); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case USER_MENTIONS: List<UserMentionEntity> userMentionsEntities = Arrays.asList(tweet.getUserMentionEntities()); l = new ArrayList<Long>(userMentionsEntities.size()); for (UserMentionEntity userMention : userMentionsEntities) { l.add(userMention.getId()); } switch (row.getKey().getType()) { case STRING: case LIST: current.setValue(row.getKey(), !TalendType.STRING.equals(row.getKey().getType()) ? l : Joiner.on(getEntitiesSeparator()).join(l)); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case USER_MENTIONS_SCREEN_NAME: List<UserMentionEntity> userMentionsScreen = Arrays.asList(tweet.getUserMentionEntities()); h = new ArrayList<String>(userMentionsScreen.size()); for (UserMentionEntity userMention : userMentionsScreen) { h.add((includeHash() ? "@" : "") + userMention.getScreenName()); } switch (row.getKey().getType()) { case STRING: case LIST: current.setValue(row.getKey(), !TalendType.STRING.equals(row.getKey().getType()) ? h : Joiner.on(getEntitiesSeparator()).join(h)); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; case JSON: switch (row.getKey().getType()) { case STRING: current.setValue(row.getKey(), DataObjectFactory.getRawJSON(tweet)); break; default: throw new IllegalArgumentException(String.format(rb.getString("exception.uncastableColumn"), row.getKey().getType().getTypeString(), row.getKey().getName())); } break; default: throw new IllegalArgumentException( String.format(rb.getString("exception.unparseableColumn"), row.getKey().getName())); } } } valid = true; }
From source file:org.getlantern.firetweet.model.ParcelableLocation.java
License:Open Source License
public ParcelableLocation(@Nullable final GeoLocation location) { latitude = location != null ? location.getLatitude() : Double.NaN; longitude = location != null ? location.getLongitude() : Double.NaN; }
From source file:org.getlantern.firetweet.util.ContentValuesCreator.java
License:Open Source License
public static ContentValues createStatus(final Status orig, final long accountId) { if (orig == null || orig.getId() <= 0) return null; final ContentValues values = new ContentValues(); values.put(Statuses.ACCOUNT_ID, accountId); values.put(Statuses.STATUS_ID, orig.getId()); values.put(Statuses.STATUS_TIMESTAMP, orig.getCreatedAt().getTime()); final Status status; if (orig.isRetweet()) { final Status retweetedStatus = orig.getRetweetedStatus(); final User retweetUser = orig.getUser(); final long retweetedById = retweetUser.getId(); values.put(Statuses.RETWEET_ID, retweetedStatus.getId()); values.put(Statuses.RETWEET_TIMESTAMP, retweetedStatus.getCreatedAt().getTime()); values.put(Statuses.RETWEETED_BY_USER_ID, retweetedById); values.put(Statuses.RETWEETED_BY_USER_NAME, retweetUser.getName()); values.put(Statuses.RETWEETED_BY_USER_SCREEN_NAME, retweetUser.getScreenName()); values.put(Statuses.RETWEETED_BY_USER_PROFILE_IMAGE, (retweetUser.getProfileImageUrlHttps())); values.put(Statuses.IS_RETWEET, true); if (retweetedById == accountId) { values.put(Statuses.MY_RETWEET_ID, orig.getId()); } else {//from w ww . j av a 2 s. c o m values.put(Statuses.MY_RETWEET_ID, orig.getCurrentUserRetweet()); } status = retweetedStatus; } else if (orig.isQuote()) { final Status quotedStatus = orig.getQuotedStatus(); final User quoteUser = orig.getUser(); final long quotedById = quoteUser.getId(); values.put(Statuses.QUOTE_ID, quotedStatus.getId()); final String textHtml = TwitterContentUtils.formatStatusText(orig); values.put(Statuses.QUOTE_TEXT_HTML, textHtml); values.put(Statuses.QUOTE_TEXT_PLAIN, orig.getText()); values.put(Statuses.QUOTE_TEXT_UNESCAPED, toPlainText(textHtml)); values.put(Statuses.QUOTE_TIMESTAMP, orig.getCreatedAt().getTime()); values.put(Statuses.QUOTE_SOURCE, orig.getSource()); values.put(Statuses.QUOTED_BY_USER_ID, quotedById); values.put(Statuses.QUOTED_BY_USER_NAME, quoteUser.getName()); values.put(Statuses.QUOTED_BY_USER_SCREEN_NAME, quoteUser.getScreenName()); values.put(Statuses.QUOTED_BY_USER_PROFILE_IMAGE, quoteUser.getProfileImageUrlHttps()); values.put(Statuses.QUOTED_BY_USER_IS_VERIFIED, quoteUser.isVerified()); values.put(Statuses.QUOTED_BY_USER_IS_PROTECTED, quoteUser.isProtected()); values.put(Statuses.IS_QUOTE, true); if (quotedById == accountId) { values.put(Statuses.MY_QUOTE_ID, orig.getId()); // } else { // values.put(Statuses.MY_QUOTE_ID, orig.getCurrentUserRetweet()); } status = quotedStatus; } else { values.put(Statuses.MY_RETWEET_ID, orig.getCurrentUserRetweet()); status = orig; } final User user = status.getUser(); final long userId = user.getId(); final String profileImageUrl = (user.getProfileImageUrlHttps()); final String name = user.getName(), screenName = user.getScreenName(); values.put(Statuses.USER_ID, userId); values.put(Statuses.USER_NAME, name); values.put(Statuses.USER_SCREEN_NAME, screenName); values.put(Statuses.IS_PROTECTED, user.isProtected()); values.put(Statuses.IS_VERIFIED, user.isVerified()); values.put(Statuses.USER_PROFILE_IMAGE_URL, profileImageUrl); values.put(CachedUsers.IS_FOLLOWING, user.isFollowing()); final String textHtml = TwitterContentUtils.formatStatusText(status); values.put(Statuses.TEXT_HTML, textHtml); values.put(Statuses.TEXT_PLAIN, status.getText()); values.put(Statuses.TEXT_UNESCAPED, toPlainText(textHtml)); values.put(Statuses.RETWEET_COUNT, status.getRetweetCount()); values.put(Statuses.REPLY_COUNT, status.getReplyCount()); values.put(Statuses.FAVORITE_COUNT, status.getFavoriteCount()); values.put(Statuses.DESCENDENT_REPLY_COUNT, status.getDescendentReplyCount()); values.put(Statuses.IN_REPLY_TO_STATUS_ID, status.getInReplyToStatusId()); values.put(Statuses.IN_REPLY_TO_USER_ID, status.getInReplyToUserId()); values.put(Statuses.IN_REPLY_TO_USER_NAME, TwitterContentUtils.getInReplyToName(status)); values.put(Statuses.IN_REPLY_TO_USER_SCREEN_NAME, status.getInReplyToScreenName()); values.put(Statuses.SOURCE, status.getSource()); values.put(Statuses.IS_POSSIBLY_SENSITIVE, status.isPossiblySensitive()); final GeoLocation location = status.getGeoLocation(); if (location != null) { values.put(Statuses.LOCATION, ParcelableLocation.toString(location.getLatitude(), location.getLongitude())); } final Place place = status.getPlace(); if (place != null) { values.put(Statuses.PLACE_FULL_NAME, place.getFullName()); } values.put(Statuses.IS_FAVORITE, status.isFavorited()); final ParcelableMedia[] media = ParcelableMedia.fromEntities(status); if (media != null) { values.put(Statuses.MEDIA_LIST, SimpleValueSerializer.toSerializedString(media)); } final ParcelableUserMention[] mentions = ParcelableUserMention.fromStatus(status); if (mentions != null) { values.put(Statuses.MENTIONS_LIST, SimpleValueSerializer.toSerializedString(mentions)); } final ParcelableCardEntity card = ParcelableCardEntity.fromCardEntity(status.getCard(), accountId); if (card != null) { values.put(Statuses.CARD_NAME, card.name); values.put(Statuses.CARD, JSONSerializer.toJSONObjectString(card)); } return values; }
From source file:org.graylog2.inputs.twitter.TwitterCodec.java
License:Open Source License
private Message createMessageFromStatus(final Status status) { final Message message = new Message(status.getText(), "twitter.com", new DateTime(status.getCreatedAt())); message.addField("facility", "Tweets"); message.addField("level", 6); message.addField("tweet_id", status.getId()); message.addField("tweet_is_retweet", Boolean.toString(status.isRetweet())); message.addField("tweet_favorite_count", status.getFavoriteCount()); message.addField("tweet_retweet_count", status.getRetweetCount()); message.addField("tweet_language", status.getLang()); final GeoLocation geoLocation = status.getGeoLocation(); if (geoLocation != null) { message.addField("tweet_geo_long", geoLocation.getLongitude()); message.addField("tweet_geo_lat", geoLocation.getLatitude()); }//from ww w . j a v a 2s.c o m final User user = status.getUser(); if (user != null) { message.addField("tweet_url", "https://twitter.com/" + user.getScreenName() + "/status/" + status.getId()); message.addField("user_id", user.getId()); message.addField("user_name", user.getScreenName()); message.addField("user_description", user.getDescription()); message.addField("user_timezone", user.getTimeZone()); message.addField("user_utc_offset", user.getUtcOffset()); message.addField("user_location", user.getLocation()); message.addField("user_language", user.getLang()); message.addField("user_url", user.getURL()); message.addField("user_followers", user.getFollowersCount()); message.addField("user_tweets", user.getStatusesCount()); message.addField("user_favorites", user.getFavouritesCount()); } return message; }
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; if ((gl = status.getGeoLocation()) != null) { msg.putDoubleProperty(TwitterConstants.KEY_GEO_LOCATION_LATITUDE, gl.getLatitude()); msg.putDoubleProperty(TwitterConstants.KEY_GEO_LOCATION_LONGITUDE, gl.getLongitude()); }//w ww . j a va2s. co m Place place; if ((place = status.getPlace()) != null) { msg.putStringProperty(TwitterConstants.KEY_PLACE_ID, place.getId()); } }
From source file:org.mariotaku.twidere.util.ContentValuesCreator.java
License:Open Source License
@NonNull public static ContentValues createStatus(final Status orig, final long accountId) { if (orig == null) throw new NullPointerException(); final ContentValues values = new ContentValues(); values.put(Statuses.ACCOUNT_ID, accountId); values.put(Statuses.STATUS_ID, orig.getId()); values.put(Statuses.STATUS_TIMESTAMP, orig.getCreatedAt().getTime()); final Status status; if (orig.isRetweet()) { final Status retweetedStatus = orig.getRetweetedStatus(); final User retweetUser = orig.getUser(); final long retweetedById = retweetUser.getId(); values.put(Statuses.RETWEET_ID, retweetedStatus.getId()); values.put(Statuses.RETWEET_TIMESTAMP, retweetedStatus.getCreatedAt().getTime()); values.put(Statuses.RETWEETED_BY_USER_ID, retweetedById); values.put(Statuses.RETWEETED_BY_USER_NAME, retweetUser.getName()); values.put(Statuses.RETWEETED_BY_USER_SCREEN_NAME, retweetUser.getScreenName()); values.put(Statuses.RETWEETED_BY_USER_PROFILE_IMAGE, (retweetUser.getProfileImageUrlHttps())); values.put(Statuses.IS_RETWEET, true); if (retweetedById == accountId) { values.put(Statuses.MY_RETWEET_ID, orig.getId()); } else {//from w w w. j av a 2s . c om values.put(Statuses.MY_RETWEET_ID, orig.getCurrentUserRetweet()); } status = retweetedStatus; } else if (orig.isQuote()) { final Status quotedStatus = orig.getQuotedStatus(); final User quoteUser = orig.getUser(); final long quotedById = quoteUser.getId(); values.put(Statuses.QUOTE_ID, quotedStatus.getId()); final String textHtml = TwitterContentUtils.formatStatusText(orig); values.put(Statuses.QUOTE_TEXT_HTML, textHtml); values.put(Statuses.QUOTE_TEXT_PLAIN, orig.getText()); values.put(Statuses.QUOTE_TEXT_UNESCAPED, toPlainText(textHtml)); values.put(Statuses.QUOTE_TIMESTAMP, orig.getCreatedAt().getTime()); values.put(Statuses.QUOTE_SOURCE, orig.getSource()); final ParcelableMedia[] quoteMedia = ParcelableMedia.fromStatus(orig); if (quoteMedia != null && quoteMedia.length > 0) { try { values.put(Statuses.QUOTE_MEDIA_JSON, LoganSquare.serialize(Arrays.asList(quoteMedia), ParcelableMedia.class)); } catch (IOException ignored) { } } values.put(Statuses.QUOTED_BY_USER_ID, quotedById); values.put(Statuses.QUOTED_BY_USER_NAME, quoteUser.getName()); values.put(Statuses.QUOTED_BY_USER_SCREEN_NAME, quoteUser.getScreenName()); values.put(Statuses.QUOTED_BY_USER_PROFILE_IMAGE, quoteUser.getProfileImageUrlHttps()); values.put(Statuses.QUOTED_BY_USER_IS_VERIFIED, quoteUser.isVerified()); values.put(Statuses.QUOTED_BY_USER_IS_PROTECTED, quoteUser.isProtected()); values.put(Statuses.IS_QUOTE, true); status = quotedStatus; } else { values.put(Statuses.MY_RETWEET_ID, orig.getCurrentUserRetweet()); status = orig; } if (orig.isRetweet()) { values.put(Statuses.IN_REPLY_TO_STATUS_ID, status.getInReplyToStatusId()); values.put(Statuses.IN_REPLY_TO_USER_ID, status.getInReplyToUserId()); values.put(Statuses.IN_REPLY_TO_USER_NAME, TwitterContentUtils.getInReplyToName(status)); values.put(Statuses.IN_REPLY_TO_USER_SCREEN_NAME, status.getInReplyToScreenName()); } else { values.put(Statuses.IN_REPLY_TO_STATUS_ID, orig.getInReplyToStatusId()); values.put(Statuses.IN_REPLY_TO_USER_ID, orig.getInReplyToUserId()); values.put(Statuses.IN_REPLY_TO_USER_NAME, TwitterContentUtils.getInReplyToName(orig)); values.put(Statuses.IN_REPLY_TO_USER_SCREEN_NAME, orig.getInReplyToScreenName()); } final User user = status.getUser(); final long userId = user.getId(); final String profileImageUrl = (user.getProfileImageUrlHttps()); final String name = user.getName(), screenName = user.getScreenName(); values.put(Statuses.USER_ID, userId); values.put(Statuses.USER_NAME, name); values.put(Statuses.USER_SCREEN_NAME, screenName); values.put(Statuses.IS_PROTECTED, user.isProtected()); values.put(Statuses.IS_VERIFIED, user.isVerified()); values.put(Statuses.USER_PROFILE_IMAGE_URL, profileImageUrl); values.put(CachedUsers.IS_FOLLOWING, user.isFollowing()); final String textHtml = TwitterContentUtils.formatStatusText(status); values.put(Statuses.TEXT_HTML, textHtml); values.put(Statuses.TEXT_PLAIN, status.getText()); values.put(Statuses.TEXT_UNESCAPED, toPlainText(textHtml)); values.put(Statuses.RETWEET_COUNT, status.getRetweetCount()); values.put(Statuses.REPLY_COUNT, status.getReplyCount()); values.put(Statuses.FAVORITE_COUNT, status.getFavoriteCount()); values.put(Statuses.DESCENDENT_REPLY_COUNT, status.getDescendentReplyCount()); values.put(Statuses.SOURCE, status.getSource()); values.put(Statuses.IS_POSSIBLY_SENSITIVE, status.isPossiblySensitive()); final GeoLocation location = status.getGeoLocation(); if (location != null) { values.put(Statuses.LOCATION, ParcelableLocation.toString(location.getLatitude(), location.getLongitude())); } final Place place = status.getPlace(); if (place != null) { values.put(Statuses.PLACE_FULL_NAME, place.getFullName()); } values.put(Statuses.IS_FAVORITE, status.isFavorited()); final ParcelableMedia[] media = ParcelableMedia.fromStatus(status); if (media != null && media.length > 0) { try { values.put(Statuses.MEDIA_JSON, LoganSquare.serialize(Arrays.asList(media), ParcelableMedia.class)); } catch (IOException ignored) { } } final ParcelableUserMention[] mentions = ParcelableUserMention.fromStatus(status); if (mentions != null && mentions.length > 0) { try { values.put(Statuses.MENTIONS_JSON, LoganSquare.serialize(Arrays.asList(mentions), ParcelableUserMention.class)); } catch (IOException ignored) { } } final ParcelableCardEntity card = ParcelableCardEntity.fromCardEntity(status.getCard(), accountId); if (card != null) { try { values.put(Statuses.CARD, LoganSquare.serialize(card)); values.put(Statuses.CARD_NAME, card.name); } catch (IOException ignored) { } } return values; }