Search in sources :

Example 1 with UserLookup

use of org.hisp.dhis.webapi.webdomain.user.UserLookup in project dhis2-core by dhis2.

the class UserLookupController method lookUpFeedbackRecipients.

@GetMapping(value = "/feedbackRecipients")
public UserLookups lookUpFeedbackRecipients(@RequestParam String query) {
    UserGroup feedbackRecipients = config.getConfiguration().getFeedbackRecipients();
    if (feedbackRecipients == null) {
        throw new IllegalQueryException(new ErrorMessage(ErrorCode.E6200));
    }
    UserQueryParams params = new UserQueryParams().setQuery(query).setUserGroups(Sets.newHashSet(feedbackRecipients)).setCanSeeOwnUserAuthorityGroups(true).setMax(25);
    List<UserLookup> users = userService.getUsers(params).stream().map(UserLookup::fromUser).collect(Collectors.toList());
    return new UserLookups(users);
}
Also used : IllegalQueryException(org.hisp.dhis.common.IllegalQueryException) UserLookup(org.hisp.dhis.webapi.webdomain.user.UserLookup) UserLookups(org.hisp.dhis.webapi.webdomain.user.UserLookups) ErrorMessage(org.hisp.dhis.feedback.ErrorMessage) UserQueryParams(org.hisp.dhis.user.UserQueryParams) UserGroup(org.hisp.dhis.user.UserGroup) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with UserLookup

use of org.hisp.dhis.webapi.webdomain.user.UserLookup in project dhis2-core by dhis2.

the class UserLookupController method lookUpUsers.

@GetMapping
public UserLookups lookUpUsers(@RequestParam String query) {
    UserQueryParams params = new UserQueryParams().setQuery(query).setCanSeeOwnUserAuthorityGroups(true).setMax(25);
    List<UserLookup> users = userService.getUsers(params).stream().map(UserLookup::fromUser).collect(Collectors.toList());
    return new UserLookups(users);
}
Also used : UserLookup(org.hisp.dhis.webapi.webdomain.user.UserLookup) UserLookups(org.hisp.dhis.webapi.webdomain.user.UserLookups) UserQueryParams(org.hisp.dhis.user.UserQueryParams) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

UserQueryParams (org.hisp.dhis.user.UserQueryParams)2 UserLookup (org.hisp.dhis.webapi.webdomain.user.UserLookup)2 UserLookups (org.hisp.dhis.webapi.webdomain.user.UserLookups)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 IllegalQueryException (org.hisp.dhis.common.IllegalQueryException)1 ErrorMessage (org.hisp.dhis.feedback.ErrorMessage)1 UserGroup (org.hisp.dhis.user.UserGroup)1