use of org.jbei.ice.storage.DAOException in project ice by JBEI.
the class ApiKeyDAO method getApiKeysForUser.
public List<ApiKey> getApiKeysForUser(String userId, String sort, int limit, int start, boolean asc) {
try {
CriteriaQuery<ApiKey> query = getBuilder().createQuery(ApiKey.class);
Root<ApiKey> from = query.from(ApiKey.class);
query.where(getBuilder().equal(from.get("ownerEmail"), userId)).orderBy(asc ? getBuilder().asc(from.get(sort)) : getBuilder().desc(from.get(sort))).distinct(true);
return currentSession().createQuery(query).setFirstResult(start).setMaxResults(limit).list();
} 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 getClientsForGroup.
/**
* Retrieves clients belonging to specified group
*
* @param group group whose members are to be retrieved
* @return remote clients that have been added to the specified group
*/
public List<RemoteClientModel> getClientsForGroup(Group group) {
try {
CriteriaQuery<RemoteClientModel> query = getBuilder().createQuery(RemoteClientModel.class);
Root<RemoteClientModel> from = query.from(RemoteClientModel.class);
Join<RemoteClientModel, Group> groups = from.join("groups");
query.where(getBuilder().equal(groups.get("id"), group.getId()), getBuilder().isNotNull(from.get("email")));
return currentSession().createQuery(query).list();
} catch (HibernateException he) {
Logger.error(he);
throw new DAOException(he);
}
}
use of org.jbei.ice.storage.DAOException in project ice by JBEI.
the class RemotePartnerDAO method getRegistryPartners.
public List<RemotePartner> getRegistryPartners() {
try {
CriteriaQuery<RemotePartner> query = getBuilder().createQuery(RemotePartner.class);
query.from(RemotePartner.class);
return currentSession().createQuery(query).list();
} catch (HibernateException he) {
Logger.error(he);
throw new DAOException(he);
}
}
use of org.jbei.ice.storage.DAOException in project ice by JBEI.
the class RemotePartnerDAO method getByUrl.
/**
* Retrieves remote partners by url. the url is also a unique identifier
* for a partner
*
* @param url partner url to retrieve by
* @return partner is found, null otherwise
*/
public RemotePartner getByUrl(String url) {
try {
CriteriaQuery<RemotePartner> query = getBuilder().createQuery(RemotePartner.class);
Root<RemotePartner> from = query.from(RemotePartner.class);
query.where(getBuilder().equal(from.get("url"), url));
Optional<RemotePartner> result = currentSession().createQuery(query).uniqueResultOptional();
if (result.isPresent())
return result.get();
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 RemoteShareModelDAO method get.
public RemoteShareModel get(String userId, RemotePartner remotePartner, Folder folder) {
try {
CriteriaQuery<RemoteShareModel> query = getBuilder().createQuery(RemoteShareModel.class);
Root<RemoteShareModel> from = query.from(RemoteShareModel.class);
Join<RemoteShareModel, Permission> permission = from.join("permission");
Join<RemoteShareModel, RemoteClientModel> client = from.join("client");
query.where(getBuilder().equal(permission.get("folder"), folder), getBuilder().equal(client.get("remotePartner"), remotePartner), getBuilder().equal(client.get("email"), userId));
return currentSession().createQuery(query).uniqueResult();
} catch (HibernateException he) {
Logger.error(he);
throw new DAOException(he);
}
}
Aggregations