use of org.jbei.ice.lib.dto.group.UserGroup in project ice by JBEI.
the class GroupControllerTest method testRetrieveGroupMembers.
@Test
public void testRetrieveGroupMembers() throws Exception {
Account a1 = AccountCreator.createTestAccount("testRetrieveGroupMembers1", false);
AccountCreator.createTestAccount("testRetrieveGroupMembers2", false);
AccountCreator.createTestAccount("testRetrieveGroupMembers3", false);
UserGroup user = new UserGroup();
user.setDescription("desc");
user.setLabel("label");
user.setType(GroupType.PRIVATE);
// create group
user = controller.createGroup(a1.getEmail(), user);
Assert.assertNotNull(user);
}
use of org.jbei.ice.lib.dto.group.UserGroup in project ice by JBEI.
the class GroupControllerTest method testCreate.
@Test
public void testCreate() throws Exception {
Account account = AccountCreator.createTestAccount("testCreate", false);
UserGroup userGroup = new UserGroup();
userGroup.setLabel("test Group");
userGroup.setDescription("test");
userGroup = controller.createGroup(account.getEmail(), userGroup);
Assert.assertNotNull(userGroup);
}
use of org.jbei.ice.lib.dto.group.UserGroup in project ice by JBEI.
the class GroupControllerTest method testSetGroupMembers.
@Test
public void testSetGroupMembers() throws Exception {
Account a1 = AccountCreator.createTestAccount("testSetGroupMembers1", false);
AccountCreator.createTestAccount("testSetGroupMembers2", false);
AccountCreator.createTestAccount("testSetGroupMembers3", false);
UserGroup user = new UserGroup();
user.setDescription("desc");
user.setLabel("label");
user.setType(GroupType.PRIVATE);
// create group
user = controller.createGroup(a1.getEmail(), user);
Assert.assertNotNull(user);
}
use of org.jbei.ice.lib.dto.group.UserGroup in project ice by JBEI.
the class GroupResource method getGroup.
/**
* Retrieve specified group
*
* @param id unique identifier for group to be retrieved
* @return found group
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}")
public Response getGroup(@PathParam("id") long id) {
String userId = requireUserId();
UserGroup group = groupController.getGroupById(userId, id);
return respond(group);
}
use of org.jbei.ice.lib.dto.group.UserGroup in project ice by JBEI.
the class Groups method get.
/**
* Retrieves groups that user is either a member of. Users are implicit members of the groups
* that they create so call also returns those groups
*
* @param userId id of account whose groups are being requested
* @return list of groups that user is a member of
*/
public Results<UserGroup> get(long userId) {
AccountController accountController = new AccountController();
Account userIdAccount = accountDAO.get(userId);
Account account = accountDAO.getByEmail(this.userId);
// TODO : account authorization
if (!accountController.isAdministrator(account.getEmail()) && account.getId() != userIdAccount.getId())
return null;
List<Group> result = dao.retrieveMemberGroups(account);
Results<UserGroup> groupResults = new Results<>();
for (Group group : result) {
UserGroup user = group.toDataTransferObject();
long count = dao.getMemberCount(group.getUuid());
// get clients
count += DAOFactory.getRemoteClientModelDAO().getClientCount(group);
user.setMemberCount(count);
groupResults.getData().add(user);
}
return groupResults;
}
Aggregations