Search in sources :

Example 11 with Group

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

the class VisibleEntries method getEntries.

public List<PartData> getEntries(ColumnField field, boolean asc, int start, int limit, String filter) {
    List<Entry> results;
    if (isAdmin) {
        // no filters
        results = dao.retrieveAllEntries(field, asc, start, limit, filter);
    } else {
        // retrieve groups for account and filter by permission
        Set<Group> accountGroups = new HashSet<>(account.getGroups());
        accountGroups.add(everybodyGroup);
        results = dao.retrieveVisibleEntries(account, accountGroups, field, asc, start, limit, filter);
    }
    ArrayList<PartData> data = new ArrayList<>();
    for (Entry entry : results) {
        PartData info = ModelToInfoFactory.createTableViewData(account.getEmail(), entry, false);
        data.add(info);
    }
    return data;
}
Also used : Group(org.jbei.ice.storage.model.Group) Entry(org.jbei.ice.storage.model.Entry) ArrayList(java.util.ArrayList) PartData(org.jbei.ice.lib.dto.entry.PartData) HashSet(java.util.HashSet)

Example 12 with Group

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

the class OwnerEntries method retrieveOwnerEntries.

public List<PartData> retrieveOwnerEntries(ColumnField sort, boolean asc, int start, int limit, String filter) {
    List<Entry> entries;
    if (this.isAdmin || this.isSelf) {
        entries = entryDAO.retrieveOwnerEntries(this.ownerAccount.getEmail(), sort, asc, start, limit, filter);
    } else {
        Set<Group> accountGroups = new HashSet<>(account.getGroups());
        GroupController controller = new GroupController();
        Group everybodyGroup = controller.createOrRetrievePublicGroup();
        accountGroups.add(everybodyGroup);
        // retrieve entries for user that can be read by others
        entries = entryDAO.retrieveUserEntries(account, this.ownerAccount.getEmail(), accountGroups, sort, asc, start, limit, filter);
    }
    ArrayList<PartData> data = new ArrayList<>();
    for (Entry entry : entries) {
        PartData info = ModelToInfoFactory.createTableViewData(account.getEmail(), entry, false);
        data.add(info);
    }
    return data;
}
Also used : Group(org.jbei.ice.storage.model.Group) Entry(org.jbei.ice.storage.model.Entry) GroupController(org.jbei.ice.lib.group.GroupController) ArrayList(java.util.ArrayList) PartData(org.jbei.ice.lib.dto.entry.PartData) HashSet(java.util.HashSet)

Example 13 with Group

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

the class SharedEntries method getEntries.

public List<PartData> getEntries(ColumnField field, boolean asc, int start, int limit, String filter) {
    GroupController groupController = new GroupController();
    Group publicGroup = groupController.createOrRetrievePublicGroup();
    Set<Group> accountGroups = account.getGroups();
    accountGroups.remove(publicGroup);
    List<Entry> entries = this.entryDAO.sharedWithUserEntries(account, accountGroups, field, asc, start, limit, filter);
    ArrayList<PartData> data = new ArrayList<>();
    for (Entry entry : entries) {
        PartData info = ModelToInfoFactory.createTableViewData(account.getEmail(), entry, false);
        data.add(info);
    }
    return data;
}
Also used : Group(org.jbei.ice.storage.model.Group) Entry(org.jbei.ice.storage.model.Entry) GroupController(org.jbei.ice.lib.group.GroupController) ArrayList(java.util.ArrayList) PartData(org.jbei.ice.lib.dto.entry.PartData)

Example 14 with Group

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

the class Groups method getMatchingGroups.

public List<UserGroup> getMatchingGroups(String token, int limit) {
    Account account = accountDAO.getByEmail(this.userId);
    List<Group> groups = dao.getMatchingGroups(account, token, limit);
    List<UserGroup> results = new ArrayList<>(groups.size());
    for (Group group : groups) {
        results.add(group.toDataTransferObject());
    }
    return results;
}
Also used : Account(org.jbei.ice.storage.model.Account) Group(org.jbei.ice.storage.model.Group) UserGroup(org.jbei.ice.lib.dto.group.UserGroup) UserGroup(org.jbei.ice.lib.dto.group.UserGroup)

Example 15 with Group

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

the class GroupController method deleteGroup.

public boolean deleteGroup(String userIdStr, long groupId) {
    Account account = DAOFactory.getAccountDAO().getByEmail(userIdStr);
    Group group = dao.get(groupId);
    if (group == null)
        return false;
    if (group.getType() == GroupType.PUBLIC && account.getType() != AccountType.ADMIN) {
        String errMsg = "Non admin " + account.getEmail() + " attempting to delete public group";
        Logger.error(errMsg);
        throw new PermissionException(errMsg);
    }
    if (group.getMembers() != null) {
        for (Account member : group.getMembers()) {
            accountController.removeMemberFromGroup(group.getId(), member.getEmail());
        }
    }
    DAOFactory.getPermissionDAO().clearPermissions(group);
    dao.delete(group);
    return true;
}
Also used : PermissionException(org.jbei.ice.lib.access.PermissionException) Account(org.jbei.ice.storage.model.Account) Group(org.jbei.ice.storage.model.Group) UserGroup(org.jbei.ice.lib.dto.group.UserGroup)

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