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));
}
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;
}
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);
}
}
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);
}
}
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);
}
}
Aggregations