Search in sources :

Example 26 with GroupUser

use of org.apache.openmeetings.db.entity.user.GroupUser in project openmeetings by apache.

the class GroupWebService method getUsers.

/**
 * Search users and return them
 *
 * @param sid
 *            The SID from getSession
 * @param id
 *            the group id
 * @param start
 *            first record
 * @param max
 *            max records
 * @param orderby
 *            orderby clause
 * @param asc
 *            asc or desc
 * @return - users found
 */
@GET
@Path("/users/{id}")
public UserSearchResult getUsers(@QueryParam("sid") @WebParam(name = "sid") String sid, @PathParam("id") @WebParam(name = "id") long id, @QueryParam("start") @WebParam(name = "start") int start, @QueryParam("max") @WebParam(name = "max") int max, @QueryParam("orderby") @WebParam(name = "orderby") String orderby, @QueryParam("asc") @WebParam(name = "asc") boolean asc) {
    return performCall(sid, User.Right.Soap, sd -> {
        SearchResult<User> result = new SearchResult<>();
        result.setObjectName(User.class.getName());
        result.setRecords(groupUserDao.count(id));
        result.setResult(new ArrayList<User>());
        String order = isAlphanumeric(orderby) ? orderby : "id";
        for (GroupUser ou : groupUserDao.get(id, null, start, max, order + " " + (asc ? "ASC" : "DESC"))) {
            result.getResult().add(ou.getUser());
        }
        return new UserSearchResult(result);
    });
}
Also used : User(org.apache.openmeetings.db.entity.user.User) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) UserSearchResult(org.apache.openmeetings.db.dto.user.UserSearchResult) SearchResult(org.apache.openmeetings.db.dto.basic.SearchResult) UserSearchResult(org.apache.openmeetings.db.dto.user.UserSearchResult) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 27 with GroupUser

use of org.apache.openmeetings.db.entity.user.GroupUser in project openmeetings by apache.

the class TestUserGroup method add10kUsers.

@Test
@Category(HeavyTests.class)
public void add10kUsers() throws Exception {
    List<Group> groups = groupDao.get(GROUP_NAME, 0, 1, null);
    Group g = null;
    if (groups == null || groups.isEmpty()) {
        g = new Group();
        g.setName(GROUP_NAME);
        g = groupDao.update(g, null);
    } else {
        g = groups.get(0);
    }
    for (int i = 0; i < 10000; ++i) {
        User u = createUser();
        u.getGroupUsers().add(new GroupUser(g, u));
        userDao.update(u, null);
    }
}
Also used : Group(org.apache.openmeetings.db.entity.user.Group) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) User(org.apache.openmeetings.db.entity.user.User) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 28 with GroupUser

use of org.apache.openmeetings.db.entity.user.GroupUser in project openmeetings by apache.

the class TestUserGroup method addGroup.

@Test
public void addGroup() {
    Group g = new Group();
    g.setName(GROUP_NAME);
    // inserted by not checked
    Long groupId = groupDao.update(g, null).getId();
    assertNotNull("New Group have valid id", groupId);
    List<GroupUser> ul = groupUserDao.get(groupId, 0, 9999);
    assertTrue("New Group should contain NO users: " + ul.size(), ul.size() == 0);
}
Also used : Group(org.apache.openmeetings.db.entity.user.Group) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) Test(org.junit.Test)

Aggregations

GroupUser (org.apache.openmeetings.db.entity.user.GroupUser)28 User (org.apache.openmeetings.db.entity.user.User)19 Group (org.apache.openmeetings.db.entity.user.Group)9 Test (org.junit.Test)7 ServiceResult (org.apache.openmeetings.db.dto.basic.ServiceResult)5 Date (java.util.Date)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 Path (javax.ws.rs.Path)3 AbstractJUnitDefaults.createUser (org.apache.openmeetings.AbstractJUnitDefaults.createUser)3 AbstractJUnitDefaults.getUser (org.apache.openmeetings.AbstractJUnitDefaults.getUser)3 GroupDao (org.apache.openmeetings.db.dao.user.GroupDao)3 Appointment (org.apache.openmeetings.db.entity.calendar.Appointment)3 RoomGroup (org.apache.openmeetings.db.entity.room.RoomGroup)3 JSONObject (com.github.openjson.JSONObject)2 AppointmentDTO (org.apache.openmeetings.db.dto.calendar.AppointmentDTO)2 OAuthUser (org.apache.openmeetings.db.dto.user.OAuthUser)2 MeetingMember (org.apache.openmeetings.db.entity.calendar.MeetingMember)2 BaseFileItem (org.apache.openmeetings.db.entity.file.BaseFileItem)2 JSONArray (com.github.openjson.JSONArray)1