Search in sources :

Example 1 with TagDao

use of nodomain.freeyourgadget.gadgetbridge.entities.TagDao in project Gadgetbridge by Freeyourgadget.

the class DBHelper method getTag.

@NonNull
public static Tag getTag(@NonNull User user, @NonNull String name, @NonNull DaoSession session) {
    TagDao tagDao = session.getTagDao();
    QueryBuilder<Tag> qb = tagDao.queryBuilder();
    Query<Tag> query = qb.where(TagDao.Properties.UserId.eq(user.getId()), TagDao.Properties.Name.eq(name)).build();
    List<Tag> tags = query.list();
    if (tags.size() > 0) {
        return tags.get(0);
    }
    return createTag(user, name, null, session);
}
Also used : TagDao(nodomain.freeyourgadget.gadgetbridge.entities.TagDao) Tag(nodomain.freeyourgadget.gadgetbridge.entities.Tag) NonNull(android.support.annotation.NonNull)

Aggregations

NonNull (android.support.annotation.NonNull)1 Tag (nodomain.freeyourgadget.gadgetbridge.entities.Tag)1 TagDao (nodomain.freeyourgadget.gadgetbridge.entities.TagDao)1