Search in sources :

Example 86 with DAOException

use of org.jbei.ice.storage.DAOException in project ice by JBEI.

the class RemoteShareModelDAO method getByFolder.

public List<RemoteShareModel> getByFolder(Folder folder) {
    try {
        CriteriaQuery<RemoteShareModel> query = getBuilder().createQuery(RemoteShareModel.class);
        Root<RemoteShareModel> from = query.from(RemoteShareModel.class);
        Join<RemoteShareModel, Permission> permission = from.join("permission");
        query.where(getBuilder().equal(permission.get("folder"), folder));
        return currentSession().createQuery(query).list();
    } catch (HibernateException he) {
        Logger.error(he);
        throw new DAOException(he);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) HibernateException(org.hibernate.HibernateException)

Example 87 with DAOException

use of org.jbei.ice.storage.DAOException in project ice by JBEI.

the class RequestDAO method getCount.

public int getCount(SampleRequestStatus status, String filter) {
    try {
        CriteriaQuery<Long> query = getBuilder().createQuery(Long.class);
        Root<Request> from = query.from(Request.class);
        query.select(getBuilder().countDistinct(from.get("id")));
        List<Predicate> predicates = createPredicates(from, filter, status);
        if (!predicates.isEmpty())
            query.where(predicates.toArray(new Predicate[predicates.size()]));
        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) Predicate(javax.persistence.criteria.Predicate)

Example 88 with DAOException

use of org.jbei.ice.storage.DAOException in project ice by JBEI.

the class SampleDAO method getSamplesByEntry.

public List<Sample> getSamplesByEntry(Entry entry) {
    try {
        CriteriaQuery<Sample> query = getBuilder().createQuery(Sample.class);
        Root<Sample> from = query.from(Sample.class);
        query.where(getBuilder().equal(from.get("entry"), entry));
        return currentSession().createQuery(query).list();
    } catch (HibernateException e) {
        Logger.error(e);
        throw new DAOException(e);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) HibernateException(org.hibernate.HibernateException) Sample(org.jbei.ice.storage.model.Sample)

Example 89 with DAOException

use of org.jbei.ice.storage.DAOException in project ice by JBEI.

the class SampleDAO method hasSample.

public boolean hasSample(Entry entry) {
    try {
        CriteriaQuery<Long> query = getBuilder().createQuery(Long.class);
        Root<Sample> from = query.from(Sample.class);
        query.select(getBuilder().countDistinct(from.get("id")));
        query.where(getBuilder().equal(from.get("entry"), entry));
        return currentSession().createQuery(query).setMaxResults(1).uniqueResult() > 0;
    } catch (HibernateException e) {
        Logger.error(e);
        throw new DAOException(e);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) HibernateException(org.hibernate.HibernateException) Sample(org.jbei.ice.storage.model.Sample)

Example 90 with DAOException

use of org.jbei.ice.storage.DAOException in project ice by JBEI.

the class SequenceDAO method getSequenceString.

public Optional<String> getSequenceString(Entry entry) {
    try {
        CriteriaQuery<String> query = getBuilder().createQuery(String.class);
        Root<Sequence> from = query.from(Sequence.class);
        query.select(from.get("sequence")).where(getBuilder().equal(from.get("entry"), entry));
        return currentSession().createQuery(query).uniqueResultOptional();
    } catch (HibernateException he) {
        Logger.error(he);
        throw new DAOException(he);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) HibernateException(org.hibernate.HibernateException)

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