use of org.jbei.ice.storage.DAOException in project ice by JBEI.
the class GroupDAO method getGroupsBy.
/**
* Retrieves groups by type and <code>autoJoin</code> value
*
* @param type type of groups to retrieve
* @param isAutoJoin auto join status
* @return list of groups found that match the parameters
* @throws DAOException on HibernateException retrieving groups
*/
public List<Group> getGroupsBy(GroupType type, boolean isAutoJoin) {
try {
CriteriaQuery<Group> query = getBuilder().createQuery(Group.class).distinct(true);
Root<Group> from = query.from(Group.class);
query.where(getBuilder().equal(from.get("type"), type), getBuilder().equal((from.get("autoJoin")), isAutoJoin));
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 GroupDAO method getGroupsByType.
public List<Group> getGroupsByType(GroupType type, int offset, int limit) {
try {
CriteriaQuery<Group> query = getBuilder().createQuery(Group.class).distinct(true);
Root<Group> from = query.from(Group.class);
query.where(getBuilder().equal(from.get("type"), type));
return currentSession().createQuery(query).setFirstResult(offset).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 EntryDAO method ownerEntryCount.
// does not check permissions (includes pending entries)
public long ownerEntryCount(String ownerEmail) {
try {
CriteriaQuery<Long> query = getBuilder().createQuery(Long.class);
Root<Entry> from = query.from(Entry.class);
ArrayList<Predicate> predicates = new ArrayList<>();
predicates.add(getBuilder().equal(from.get("ownerEmail"), ownerEmail));
predicates.add(getBuilder().or(getBuilder().equal(from.get("visibility"), Visibility.OK.getValue()), getBuilder().equal(from.get("visibility"), Visibility.PENDING.getValue())));
query.select(getBuilder().countDistinct(from.get("id"))).where(predicates.toArray(new Predicate[predicates.size()]));
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 setEntryVisibility.
public int setEntryVisibility(List<Long> list, Visibility ok) {
try {
CriteriaUpdate<Entry> update = getBuilder().createCriteriaUpdate(Entry.class);
Root<Entry> from = update.from(Entry.class);
update.set(from.get("visibility"), ok.getValue());
update.where(from.get("id").in(list));
return currentSession().createQuery(update).executeUpdate();
} catch (HibernateException e) {
Logger.error(e);
throw new DAOException(e);
}
}
use of org.jbei.ice.storage.DAOException in project ice by JBEI.
the class FolderDAO method addFolderContents.
public Folder addFolderContents(Folder folder, List<Entry> entrys) {
Session session = currentSession();
try {
folder = session.get(Folder.class, folder.getId());
folder.getContents().addAll(entrys);
folder.setModificationTime(new Date());
session.saveOrUpdate(folder);
return folder;
} catch (HibernateException e) {
Logger.error(e);
throw new DAOException(e);
}
}
Aggregations