use of org.jbei.ice.storage.DAOException in project ice by JBEI.
the class RequestDAO method getAccountRequests.
public List<Request> getAccountRequests(Account account, SampleRequestStatus status, int start, int limit, String sort, boolean asc) {
try {
CriteriaQuery<Request> query = getBuilder().createQuery(Request.class);
Root<Request> from = query.from(Request.class);
if (status != null) {
query.where(getBuilder().equal(from.get("account"), account), getBuilder().equal(from.get("status"), status));
} else {
query.where(getBuilder().equal(from.get("account"), account));
}
query.orderBy(asc ? getBuilder().asc(from.get(sort)) : getBuilder().desc(from.get(sort)));
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 RequestDAO method getSampleRequestByStatus.
public List<Request> getSampleRequestByStatus(Account account, Entry entry, SampleRequestStatus status) {
try {
CriteriaQuery<Request> query = getBuilder().createQuery(Request.class);
Root<Request> from = query.from(Request.class);
query.where(getBuilder().and(getBuilder().equal(from.get("status"), status), getBuilder().equal(from.get("entry"), entry), getBuilder().equal(from.get("account"), account)));
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 RequestDAO method get.
public List<Request> get(int start, int limit, String sort, boolean asc, SampleRequestStatus status, String filter) {
try {
CriteriaQuery<Request> query = getBuilder().createQuery(Request.class).distinct(true);
Root<Request> from = query.from(Request.class);
List<Predicate> predicates = createPredicates(from, filter, status);
if (!predicates.isEmpty())
query.where(predicates.toArray(new Predicate[predicates.size()]));
query.orderBy(asc ? getBuilder().asc(from.get(sort)) : getBuilder().desc(from.get(sort)));
return currentSession().createQuery(query).setMaxResults(limit).setFirstResult(start).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 PreferencesDAO method getPreference.
public Preference getPreference(Account account, String key) {
try {
CriteriaQuery<Preference> query = getBuilder().createQuery(Preference.class);
Root<Preference> from = query.from(Preference.class);
query.where(getBuilder().equal(from.get("account"), account), getBuilder().equal(from.get("key"), key.toUpperCase()));
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 PreferencesDAO method retrievePreferenceValues.
public HashMap<String, String> retrievePreferenceValues(Account account, HashSet<String> keys) {
try {
CriteriaQuery<Preference> query = getBuilder().createQuery(Preference.class);
Root<Preference> from = query.from(Preference.class);
query.where(getBuilder().equal(from.get("account"), account), from.get("key").in(keys));
List<Preference> result = currentSession().createQuery(query).list();
Iterator iterator = result.iterator();
HashMap<String, String> results = new HashMap<>();
while (iterator.hasNext()) {
Preference preference = (Preference) iterator.next();
if (keys.contains(preference.getKey().toUpperCase())) {
results.put(preference.getKey().toUpperCase().trim(), preference.getValue().trim());
}
}
return results;
} catch (HibernateException he) {
Logger.error(he);
throw new DAOException(he);
}
}
Aggregations