use of org.jbei.ice.storage.DAOException in project ice by JBEI.
the class BulkUploadDAO method retrieveSavedDraftCount.
public int retrieveSavedDraftCount(long draftId) {
try {
CriteriaQuery<Long> query = getBuilder().createQuery(Long.class);
Root<BulkUpload> from = query.from(BulkUpload.class);
Join<BulkUpload, Entry> contents = from.join("contents");
query.select(getBuilder().countDistinct(contents.get("id"))).where(getBuilder().equal(from.get("id"), draftId));
return currentSession().createQuery(query).uniqueResult().intValue();
} catch (HibernateException he) {
Logger.error(he);
throw new DAOException(he);
}
}
use of org.jbei.ice.storage.DAOException in project ice by JBEI.
the class BulkUploadDAO method retrieveByAccount.
public List<BulkUpload> retrieveByAccount(Account account) {
try {
CriteriaQuery<BulkUpload> query = getBuilder().createQuery(BulkUpload.class);
Root<BulkUpload> from = query.from(BulkUpload.class);
query.where(getBuilder().equal(from.get("account"), account), getBuilder().notEqual(from.get("status"), BulkUploadStatus.PENDING_APPROVAL));
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 EntryDAO method getOwnerEntryIds.
/**
* Retrieves list of entry ids whose owner email column matches the specified ownerEmail parameter,
* with a visibility of <pre>OK</pre> or <pre>PENDING</pre> and if not null, matches the type
*
* @param ownerEmail value of owner email column that desired entries must match
* @param type option entry type parameter
* @return list of ids for all matching entries
*/
public List<Long> getOwnerEntryIds(String ownerEmail, EntryType type) {
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())));
if (type != null)
predicates.add(getBuilder().equal(from.get("recordType"), type.getName()));
query.select(getBuilder().countDistinct(from.get("id"))).where(predicates.toArray(new Predicate[predicates.size()]));
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 EntryDAO method getMatchingEntryPartNumbers.
public List<String> getMatchingEntryPartNumbers(String token, int limit, Set<String> include) {
try {
CriteriaQuery<String> query = getBuilder().createQuery(String.class);
Root<Entry> from = query.from(Entry.class);
ArrayList<Predicate> predicates = new ArrayList<>();
predicates.add(getBuilder().like(getBuilder().lower(from.get("partNumber")), "%" + token.toLowerCase() + "%"));
if (include != null && !include.isEmpty()) {
predicates.add(from.get("recordType").in(include));
}
query.select(from.get("partNumber")).distinct(true).where(predicates.toArray(new Predicate[predicates.size()]));
return currentSession().createQuery(query).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 CommentDAO method getCommentCount.
public int getCommentCount(Entry entry) {
try {
CriteriaQuery<Long> query = getBuilder().createQuery(Long.class);
Root<Comment> from = query.from(Comment.class);
query.select(getBuilder().countDistinct(from.get("id"))).where(getBuilder().equal(from.get("entry"), entry));
return currentSession().createQuery(query).uniqueResult().intValue();
} catch (HibernateException he) {
Logger.error(he);
throw new DAOException(he);
}
}
Aggregations