38 lines
1.3 KiB
Java
38 lines
1.3 KiB
Java
package de.vanitasvitae.fasel.db.dao.impl;
|
|
|
|
import java.sql.SQLException;
|
|
import java.util.List;
|
|
|
|
import com.j256.ormlite.dao.BaseDaoImpl;
|
|
import com.j256.ormlite.dao.DaoManager;
|
|
import com.j256.ormlite.support.ConnectionSource;
|
|
import de.vanitasvitae.fasel.db.dao.ContactDao;
|
|
import de.vanitasvitae.fasel.db.entity.Account;
|
|
import de.vanitasvitae.fasel.db.entity.Contact;
|
|
import de.vanitasvitae.fasel.db.entity.XmppEntity;
|
|
|
|
public class ContactDaoImpl extends BaseDaoImpl<Contact, Long> implements ContactDao {
|
|
|
|
public ContactDaoImpl(ConnectionSource connectionSource)
|
|
throws SQLException {
|
|
super(connectionSource, Contact.class);
|
|
}
|
|
|
|
// TODO: Test
|
|
public List<Contact> getContactsOf(Account account) throws SQLException {
|
|
return queryForEq(Contact.ACCOUNT, account.getAccountId());
|
|
}
|
|
|
|
public List<Contact> getContactsByJid(String jid) throws SQLException {
|
|
XmppEntityDaoImpl entityDao = DaoManager.createDao(getConnectionSource(), XmppEntity.class);
|
|
List<Contact> contacts = queryBuilder()
|
|
.join(Contact.ENTITY, XmppEntity.ENTITY_ID, entityDao.queryBuilder())
|
|
.where().eq(XmppEntity.JID, jid).query();
|
|
return contacts;
|
|
}
|
|
|
|
public List<Contact> getAllContacts() throws SQLException {
|
|
return queryForAll();
|
|
}
|
|
}
|