Search in sources :

Example 11 with UserGroup

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);
}
Also used : Account(org.jbei.ice.storage.model.Account) UserGroup(org.jbei.ice.lib.dto.group.UserGroup)

Example 12 with UserGroup

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);
}
Also used : Account(org.jbei.ice.storage.model.Account) UserGroup(org.jbei.ice.lib.dto.group.UserGroup)

Example 13 with 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);
}
Also used : Account(org.jbei.ice.storage.model.Account) UserGroup(org.jbei.ice.lib.dto.group.UserGroup)

Example 14 with UserGroup

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);
}
Also used : UserGroup(org.jbei.ice.lib.dto.group.UserGroup)

Example 15 with UserGroup

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;
}
Also used : Account(org.jbei.ice.storage.model.Account) Group(org.jbei.ice.storage.model.Group) UserGroup(org.jbei.ice.lib.dto.group.UserGroup) Results(org.jbei.ice.lib.dto.common.Results) AccountController(org.jbei.ice.lib.account.AccountController) UserGroup(org.jbei.ice.lib.dto.group.UserGroup)

Aggregations

UserGroup (org.jbei.ice.lib.dto.group.UserGroup)17 Account (org.jbei.ice.storage.model.Account)13 Group (org.jbei.ice.storage.model.Group)9 AccountTransfer (org.jbei.ice.lib.account.AccountTransfer)5 PermissionException (org.jbei.ice.lib.access.PermissionException)3 RemoteUser (org.jbei.ice.lib.dto.web.RemoteUser)3 RemotePartner (org.jbei.ice.storage.model.RemotePartner)3 Results (org.jbei.ice.lib.dto.common.Results)2 RemoteClientModel (org.jbei.ice.storage.model.RemoteClientModel)2 Test (org.junit.Test)2 Date (java.util.Date)1 AccountController (org.jbei.ice.lib.account.AccountController)1 RegistryPartner (org.jbei.ice.lib.dto.web.RegistryPartner)1 Message (org.jbei.ice.storage.model.Message)1