use of org.jbei.ice.storage.DAOException in project ice by JBEI.
the class EntryDAO method getByVisibilityCount.
public long getByVisibilityCount(Visibility visibility) {
try {
CriteriaQuery<Long> query = getBuilder().createQuery(Long.class);
Root<Entry> from = query.from(Entry.class);
query.select(getBuilder().countDistinct(from.get("id"))).where(getBuilder().equal(from.get("visibility"), visibility.getValue()));
return currentSession().createQuery(query).uniqueResult();
} catch (HibernateException he) {
Logger.error(he);
throw new DAOException(he);
}
}
use of org.jbei.ice.storage.DAOException in project ice by JBEI.
the class EntryDAO method getEntryByField.
protected Entry getEntryByField(String field, String fieldValue) {
try {
CriteriaQuery<Entry> query = getBuilder().createQuery(Entry.class);
Root<Entry> from = query.from(Entry.class);
query.where(getBuilder().equal(getBuilder().lower(from.get(field)), fieldValue.toLowerCase()));
return currentSession().createQuery(query).uniqueResult();
} catch (HibernateException e) {
Logger.error(e);
throw new DAOException("Failed to retrieve entry by: " + fieldValue, e);
}
}
use of org.jbei.ice.storage.DAOException in project ice by JBEI.
the class RemoteAccessModelDAO method getByFolder.
public RemoteAccessModel getByFolder(Account account, Folder folder) {
try {
CriteriaQuery<RemoteAccessModel> query = getBuilder().createQuery(RemoteAccessModel.class);
Root<RemoteAccessModel> from = query.from(RemoteAccessModel.class);
Join<RemoteAccessModel, Permission> permission = from.join("permission");
query.where(getBuilder().equal(permission.get("folder"), folder), getBuilder().equal(permission.get("account"), account));
List<RemoteAccessModel> result = currentSession().createQuery(query).list();
if (result.size() > 1) {
Logger.warn("Found " + result.size() + " access models for folder " + folder.getId());
return result.get(0);
}
return null;
} catch (HibernateException he) {
Logger.error(he);
throw new DAOException(he);
}
}
use of org.jbei.ice.storage.DAOException in project ice by JBEI.
the class RemoteClientModelDAO method getModel.
public RemoteClientModel getModel(String email, RemotePartner remotePartner) {
try {
CriteriaQuery<RemoteClientModel> query = getBuilder().createQuery(RemoteClientModel.class);
Root<RemoteClientModel> from = query.from(RemoteClientModel.class);
query.where(getBuilder().equal(from.get("email"), email), getBuilder().equal(from.get("remotePartner"), remotePartner));
return currentSession().createQuery(query).uniqueResult();
} catch (HibernateException he) {
Logger.error(he);
throw new DAOException(he);
}
}
use of org.jbei.ice.storage.DAOException in project ice by JBEI.
the class RequestDAO method getCount.
public int getCount(Account account) {
try {
CriteriaQuery<Long> query = getBuilder().createQuery(Long.class);
Root<Request> from = query.from(Request.class);
query.select(getBuilder().countDistinct(from.get("id")));
if (account != null)
query.where(getBuilder().equal(from.get("account"), account));
return currentSession().createQuery(query).uniqueResult().intValue();
} catch (HibernateException he) {
Logger.error(he);
throw new DAOException(he);
}
}
Aggregations