45 lines
1.6 KiB
Java
45 lines
1.6 KiB
Java
package org.mercury_im.messenger.persistence.room.dao;
|
|
|
|
import androidx.lifecycle.LiveData;
|
|
import androidx.room.Dao;
|
|
import androidx.room.Query;
|
|
import androidx.room.TypeConverters;
|
|
|
|
import org.jxmpp.jid.EntityBareJid;
|
|
import org.mercury_im.messenger.persistence.room.model.RoomContactModel;
|
|
import org.mercury_im.messenger.persistence.room.type_converter.EntityBareJidConverter;
|
|
|
|
import java.util.List;
|
|
|
|
@Dao
|
|
@TypeConverters(EntityBareJidConverter.class)
|
|
public interface ContactDao extends BaseDao<RoomContactModel> {
|
|
|
|
@Query("SELECT * FROM contacts WHERE id = :id")
|
|
LiveData<RoomContactModel> getContact(long id);
|
|
|
|
@Query("SELECT * FROM contacts WHERE id = :id")
|
|
RoomContactModel syncGetContact(long id);
|
|
|
|
@Query("SELECT * FROM contacts WHERE entityId = :entityId")
|
|
LiveData<RoomContactModel> getContactForEntityId(long entityId);
|
|
|
|
@Query("SELECT * FROM contacts WHERE entityId = :entityId")
|
|
RoomContactModel syncGetContactForEntityId(long entityId);
|
|
|
|
/**
|
|
* Return a {@link LiveData} wrapping a {@link List} of all {@link RoomContactModel RosterEntries}
|
|
* which are currently found in the database.
|
|
*
|
|
* @return
|
|
*/
|
|
@Query("SELECT * FROM contacts")
|
|
LiveData<List<RoomContactModel>> getAllContacts();
|
|
|
|
@Query("SELECT contacts.* FROM contacts JOIN entities WHERE contacts.accountId = :accountId AND jid = :jid")
|
|
RoomContactModel getContactByJid(long accountId, EntityBareJid jid);
|
|
|
|
@Query("SELECT * FROM contacts WHERE accountId = :accountId")
|
|
LiveData<List<RoomContactModel>> getContactsForAccount(long accountId);
|
|
}
|