Example usage for twitter4j UserMentionEntity getId

List of usage examples for twitter4j UserMentionEntity getId

Introduction

In this page you can find the example usage for twitter4j UserMentionEntity getId.

Prototype

long getId();

Source Link

Document

Returns the user id mentioned in the status.

Usage

From source file:com.daemon.database.Transactor.java

License:Open Source License

/**
 * Adds the user mentions for a given tweet to the SQL Batch saved
 * to the DB by saveAllTweetsTransactionSave.
 * /*ww w  .  j  ava  2  s  .  c  o m*/
 * @param tweet   The tweet which contains mentions of users 
 * @throws SQLException
 */
private void saveUserMentions(Status tweet) throws SQLException {
    // Save tweet id in prepared statements
    prepStatementMentions.setLong(1, tweet.getId());

    // 1. Get User Mentions in given tweet
    UserMentionEntity[] userMentionEntities = tweet.getUserMentionEntities();

    // 2. Create for each user Mention an db entry, if necessary
    for (UserMentionEntity userMentionEntity : userMentionEntities) {
        prepStatementMentions.setLong(2, userMentionEntity.getId());
        prepStatementMentions.addBatch();
    }
}

From source file:com.freshdigitable.udonroad.module.realm.StatusCacheRealm.java

License:Apache License

private UserMentionEntity[] splitUserMentionEntity(Collection<Status> updates) {
    final Map<Long, UserMentionEntity> res = new LinkedHashMap<>();
    for (Status s : updates) {
        for (UserMentionEntity ume : s.getUserMentionEntities()) {
            res.put(ume.getId(), ume);
        }//from   w  ww .  j  ava2s. co  m
    }
    final Collection<UserMentionEntity> values = res.values();
    return values.toArray(new UserMentionEntity[values.size()]);
}

From source file:com.freshdigitable.udonroad.module.realm.UserCacheRealm.java

License:Apache License

void upsert(UserMentionEntity[] mentionEntity) {
    if (mentionEntity == null || mentionEntity.length < 1) {
        return;//from  www . j  a  v a  2  s .  co m
    }
    final List<UserRealm> upserts = new ArrayList<>(mentionEntity.length);
    for (UserMentionEntity ume : mentionEntity) {
        final User user = find(ume.getId());
        if (user == null) {
            upserts.add(new UserRealm(ume));
        }
    }
    if (!upserts.isEmpty()) {
        cache.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                realm.insertOrUpdate(upserts);
            }
        });
    }
}

From source file:com.freshdigitable.udonroad.module.realm.UserMentionEntityRealm.java

License:Apache License

UserMentionEntityRealm(UserMentionEntity u) {
    this.id = u.getId();
    this.screenName = u.getScreenName();
    this.name = u.getName();
}

From source file:com.freshdigitable.udonroad.module.realm.UserRealm.java

License:Apache License

UserRealm(UserMentionEntity mentionEntity) {
    this.id = mentionEntity.getId();
    this.name = mentionEntity.getName();
    this.screenName = mentionEntity.getScreenName();
}

From source file:com.freshdigitable.udonroad.SpannableStringUtil.java

License:Apache License

private static List<SpanningInfo> createUserSpanningInfo(Status bindingStatus) {
    final String text = bindingStatus.getText();
    final UserMentionEntity[] userMentionEntities = bindingStatus.getUserMentionEntities();
    final List<SpanningInfo> info = new ArrayList<>();
    for (UserMentionEntity u : userMentionEntities) {
        final int start = text.indexOf("@" + u.getScreenName());
        final int end = start + u.getScreenName().length() + 1;
        if (isInvalidRange(text, start, end)) {
            continue;
        }/*from w  w w.j av  a 2 s.  c  o  m*/
        final long id = u.getId();
        info.add(new SpanningInfo(new ClickableSpan() {
            @Override
            public void onClick(View view) {
                UserInfoActivity.start(view.getContext(), id);
            }
        }, start, end, null));
    }
    return info;
}

From source file:com.github.jcustenborder.kafka.connect.twitter.StatusConverter.java

License:Apache License

static Struct convertUserMentionEntity(UserMentionEntity userMentionEntity) {
    return new Struct(SCHEMA_USER_MENTION_ENTITY).put("Name", userMentionEntity.getName())
            .put("Id", userMentionEntity.getId()).put("Text", userMentionEntity.getText())
            .put("ScreenName", userMentionEntity.getScreenName()).put("Start", userMentionEntity.getStart())
            .put("End", userMentionEntity.getEnd());
}

From source file:com.mothsoft.alexis.engine.retrieval.TwitterRetrievalTaskImpl.java

License:Apache License

private List<TweetMention> readMentions(Status status) {
    final List<TweetMention> mentions = new ArrayList<TweetMention>();

    if (status.getUserMentionEntities() != null) {
        for (final UserMentionEntity entity : status.getUserMentionEntities()) {

            final Long userId = entity.getId();
            final String name = entity.getName();
            final String screenName = entity.getScreenName();

            final TweetMention mention = new TweetMention((short) entity.getStart(), (short) entity.getEnd(),
                    userId, name, screenName);
            mentions.add(mention);//  w  ww . j  a va  2  s.  c  o m
        }
    }

    return mentions;
}

From source file:com.narvis.frontend.twitter.input.Input.java

License:Open Source License

private boolean isMentionnedIn(UserMentionEntity[] mentions) throws TwitterException {
    if (mentions != null) {
        for (UserMentionEntity mention : mentions) {
            if (mention.getId() == this.stream.getId()) {
                return true;
            }/*from   ww w  .j a  v a  2 s .  c o m*/
        }
    }
    return false;
}

From source file:com.raythos.sentilexo.twitter.utils.StatusArraysHelper.java

public static Map<String, Long> getUserMentionMap(Status status) {
    @SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
    Map<String, Long> result = new HashMap<>();
    for (UserMentionEntity um : status.getUserMentionEntities()) {
        result.put(um.getScreenName(), um.getId());
    }// w w  w  .j  a v  a2s. c o m
    return result;
}