Search in sources :

Example 1 with SearchResult

use of org.apache.openmeetings.db.dto.basic.SearchResult 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)

Aggregations

GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 SearchResult (org.apache.openmeetings.db.dto.basic.SearchResult)1 UserSearchResult (org.apache.openmeetings.db.dto.user.UserSearchResult)1 GroupUser (org.apache.openmeetings.db.entity.user.GroupUser)1 User (org.apache.openmeetings.db.entity.user.User)1