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