Search in sources :

Example 81 with DAOException

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

the class ApiKeyDAO method getApiKeysForUser.

public List<ApiKey> getApiKeysForUser(String userId, String sort, int limit, int start, boolean asc) {
    try {
        CriteriaQuery<ApiKey> query = getBuilder().createQuery(ApiKey.class);
        Root<ApiKey> from = query.from(ApiKey.class);
        query.where(getBuilder().equal(from.get("ownerEmail"), userId)).orderBy(asc ? getBuilder().asc(from.get(sort)) : getBuilder().desc(from.get(sort))).distinct(true);
        return currentSession().createQuery(query).setFirstResult(start).setMaxResults(limit).list();
    } catch (HibernateException he) {
        Logger.error(he);
        throw new DAOException(he);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) ApiKey(org.jbei.ice.storage.model.ApiKey) HibernateException(org.hibernate.HibernateException)

Example 82 with DAOException

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

the class RemoteClientModelDAO method getClientsForGroup.

/**
     * Retrieves clients belonging to specified group
     *
     * @param group group whose members are to be retrieved
     * @return remote clients that have been added to the specified group
     */
public List<RemoteClientModel> getClientsForGroup(Group group) {
    try {
        CriteriaQuery<RemoteClientModel> query = getBuilder().createQuery(RemoteClientModel.class);
        Root<RemoteClientModel> from = query.from(RemoteClientModel.class);
        Join<RemoteClientModel, Group> groups = from.join("groups");
        query.where(getBuilder().equal(groups.get("id"), group.getId()), getBuilder().isNotNull(from.get("email")));
        return currentSession().createQuery(query).list();
    } catch (HibernateException he) {
        Logger.error(he);
        throw new DAOException(he);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) Group(org.jbei.ice.storage.model.Group) HibernateException(org.hibernate.HibernateException) RemoteClientModel(org.jbei.ice.storage.model.RemoteClientModel)

Example 83 with DAOException

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

the class RemotePartnerDAO method getRegistryPartners.

public List<RemotePartner> getRegistryPartners() {
    try {
        CriteriaQuery<RemotePartner> query = getBuilder().createQuery(RemotePartner.class);
        query.from(RemotePartner.class);
        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) RemotePartner(org.jbei.ice.storage.model.RemotePartner)

Example 84 with DAOException

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

the class RemotePartnerDAO method getByUrl.

/**
     * Retrieves remote partners by url. the url is also a unique identifier
     * for a partner
     *
     * @param url partner url to retrieve by
     * @return partner is found, null otherwise
     */
public RemotePartner getByUrl(String url) {
    try {
        CriteriaQuery<RemotePartner> query = getBuilder().createQuery(RemotePartner.class);
        Root<RemotePartner> from = query.from(RemotePartner.class);
        query.where(getBuilder().equal(from.get("url"), url));
        Optional<RemotePartner> result = currentSession().createQuery(query).uniqueResultOptional();
        if (result.isPresent())
            return result.get();
        return null;
    } catch (HibernateException he) {
        Logger.error(he);
        throw new DAOException(he);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) HibernateException(org.hibernate.HibernateException) RemotePartner(org.jbei.ice.storage.model.RemotePartner)

Example 85 with DAOException

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

the class RemoteShareModelDAO method get.

public RemoteShareModel get(String userId, RemotePartner remotePartner, Folder folder) {
    try {
        CriteriaQuery<RemoteShareModel> query = getBuilder().createQuery(RemoteShareModel.class);
        Root<RemoteShareModel> from = query.from(RemoteShareModel.class);
        Join<RemoteShareModel, Permission> permission = from.join("permission");
        Join<RemoteShareModel, RemoteClientModel> client = from.join("client");
        query.where(getBuilder().equal(permission.get("folder"), folder), getBuilder().equal(client.get("remotePartner"), remotePartner), getBuilder().equal(client.get("email"), userId));
        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)

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