Search in sources :

Example 36 with Group

use of org.jbei.ice.storage.model.Group in project ice by JBEI.

the class GroupControllerTest method testSave.

@Test
public void testSave() throws Exception {
    Account account = AccountCreator.createTestAccount("testSave", false);
    Group group = new Group();
    group.setOwner(account);
    group.setLabel("group label");
    group.setDescription("group description");
    Assert.assertNotNull(controller.save(group));
}
Also used : Account(org.jbei.ice.storage.model.Account) Group(org.jbei.ice.storage.model.Group) UserGroup(org.jbei.ice.lib.dto.group.UserGroup)

Example 37 with Group

use of org.jbei.ice.storage.model.Group in project ice by JBEI.

the class FolderController method getPublicFolders.

/**
     * Retrieves folders that are shared shared publicly. Note that this is different from
     * featured folders that have a type of PUBLIC
     *
     * @return list of public folders on this site
     */
public ArrayList<FolderDetails> getPublicFolders() {
    Group publicGroup = groupController.createOrRetrievePublicGroup();
    List<Folder> folders = permissionDAO.getFolders(publicGroup);
    ArrayList<FolderDetails> list = new ArrayList<>();
    for (Folder folder : folders) {
        FolderDetails details = folder.toDataTransferObject();
        long folderSize = dao.getFolderSize(folder.getId(), null, true);
        details.setCount(folderSize);
        list.add(details);
    }
    Collections.sort(list);
    return list;
}
Also used : Group(org.jbei.ice.storage.model.Group) FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails) Folder(org.jbei.ice.storage.model.Folder)

Example 38 with Group

use of org.jbei.ice.storage.model.Group in project ice by JBEI.

the class GroupDAO method get.

/**
     * Retrieve {@link Group} object from the database by its uuid.
     *
     * @param uuid universally unique identifier for group
     * @return Group object.
     * @throws DAOException
     */
public Group get(String uuid) {
    try {
        CriteriaQuery<Group> query = getBuilder().createQuery(Group.class);
        Root<Group> from = query.from(Group.class);
        query.where(getBuilder().equal(from.get("uuid"), uuid));
        return currentSession().createQuery(query).uniqueResult();
    } catch (HibernateException e) {
        Logger.error(e);
        throw new DAOException(e);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) Group(org.jbei.ice.storage.model.Group) HibernateException(org.hibernate.HibernateException)

Example 39 with Group

use of org.jbei.ice.storage.model.Group in project ice by JBEI.

the class GroupDAO method getMemberGroupUUIDs.

/**
     * Retrieves all UUIDs that the specified account either owns or is a member of
     *
     * @param account account
     * @return list of UUIDs matching the query
     * @throws DAOException on hibernate exception
     */
public List<String> getMemberGroupUUIDs(Account account) {
    try {
        CriteriaQuery<String> query = getBuilder().createQuery(String.class).distinct(true);
        Root<Group> from = query.from(Group.class);
        Join<Group, Account> members = from.join("members", JoinType.LEFT);
        query.select(from.get("uuid")).where(getBuilder().or(getBuilder().equal(from.get("owner"), account), getBuilder().equal(members.get("email"), account.getEmail())));
        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) Account(org.jbei.ice.storage.model.Account) HibernateException(org.hibernate.HibernateException)

Example 40 with Group

use of org.jbei.ice.storage.model.Group in project ice by JBEI.

the class GroupDAO method getGroupsByTypeCount.

public long getGroupsByTypeCount(GroupType type) {
    try {
        CriteriaQuery<Long> query = getBuilder().createQuery(Long.class).distinct(true);
        Root<Group> from = query.from(Group.class);
        query.select(getBuilder().countDistinct(from.get("id")));
        query.where(getBuilder().equal(from.get("type"), type));
        return currentSession().createQuery(query).uniqueResult();
    } 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)

Aggregations

Group (org.jbei.ice.storage.model.Group)50 Account (org.jbei.ice.storage.model.Account)24 UserGroup (org.jbei.ice.lib.dto.group.UserGroup)16 HibernateException (org.hibernate.HibernateException)14 DAOException (org.jbei.ice.storage.DAOException)14 GroupController (org.jbei.ice.lib.group.GroupController)10 ArrayList (java.util.ArrayList)7 Entry (org.jbei.ice.storage.model.Entry)7 HashSet (java.util.HashSet)6 PermissionException (org.jbei.ice.lib.access.PermissionException)6 PartData (org.jbei.ice.lib.dto.entry.PartData)4 Folder (org.jbei.ice.storage.model.Folder)4 RemoteClientModel (org.jbei.ice.storage.model.RemoteClientModel)4 NativeQuery (org.hibernate.query.NativeQuery)3 AccountTransfer (org.jbei.ice.lib.account.AccountTransfer)3 AccessPermission (org.jbei.ice.lib.dto.access.AccessPermission)3 Results (org.jbei.ice.lib.dto.common.Results)3 FolderDetails (org.jbei.ice.lib.dto.folder.FolderDetails)3 Message (org.jbei.ice.storage.model.Message)3 AccountController (org.jbei.ice.lib.account.AccountController)2