Search in sources :

Example 26 with DAOException

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);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) HibernateException(org.hibernate.HibernateException)

Example 27 with DAOException

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);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) HibernateException(org.hibernate.HibernateException)

Example 28 with DAOException

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);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) HibernateException(org.hibernate.HibernateException) Permission(org.jbei.ice.storage.model.Permission) RemoteAccessModel(org.jbei.ice.storage.model.RemoteAccessModel)

Example 29 with DAOException

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);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) HibernateException(org.hibernate.HibernateException) RemoteClientModel(org.jbei.ice.storage.model.RemoteClientModel)

Example 30 with DAOException

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);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) HibernateException(org.hibernate.HibernateException) Request(org.jbei.ice.storage.model.Request) SampleRequest(org.jbei.ice.lib.dto.sample.SampleRequest)

Aggregations

DAOException (org.jbei.ice.storage.DAOException)150 HibernateException (org.hibernate.HibernateException)144 ArrayList (java.util.ArrayList)26 Group (org.jbei.ice.storage.model.Group)14 Account (org.jbei.ice.storage.model.Account)8 Request (org.jbei.ice.storage.model.Request)8 Predicate (javax.persistence.criteria.Predicate)7 SampleRequest (org.jbei.ice.lib.dto.sample.SampleRequest)6 Entry (org.jbei.ice.storage.model.Entry)6 Session (org.hibernate.Session)5 ApiKey (org.jbei.ice.storage.model.ApiKey)5 BulkUpload (org.jbei.ice.storage.model.BulkUpload)5 NativeQuery (org.hibernate.query.NativeQuery)4 Feature (org.jbei.ice.storage.model.Feature)4 Preference (org.jbei.ice.storage.model.Preference)4 Sample (org.jbei.ice.storage.model.Sample)4 Attachment (org.jbei.ice.storage.model.Attachment)3 Audit (org.jbei.ice.storage.model.Audit)3 RemoteClientModel (org.jbei.ice.storage.model.RemoteClientModel)3 ShotgunSequence (org.jbei.ice.storage.model.ShotgunSequence)3