Search in sources :

Example 11 with UserQueryParams

use of org.hisp.dhis.user.UserQueryParams in project dhis2-core by dhis2.

the class FindUserAction method execute.

@Override
public String execute() throws Exception {
    updateRecipients(recipientCheckBox);
    if (keyword != null) {
        int index = keyword.indexOf(' ');
        if (index != -1 && index == keyword.lastIndexOf(' ')) {
            String[] keys = keyword.split(" ");
            keyword = keys[0] + "  " + keys[1];
        }
    }
    UserQueryParams params = new UserQueryParams();
    params.setQuery(keyword);
    users = userService.getUsers(params);
    if (users.size() == 1) {
        User user = users.iterator().next();
        userId = user.getId();
        return REDIRECT;
    }
    foundUsers = users.size();
    return SUCCESS;
}
Also used : User(org.hisp.dhis.user.User) UserQueryParams(org.hisp.dhis.user.UserQueryParams)

Example 12 with UserQueryParams

use of org.hisp.dhis.user.UserQueryParams in project dhis2-core by dhis2.

the class TwoFAPopulator method execute.

@Override
public void execute() throws Exception {
    UserQueryParams userQueryParams = new UserQueryParams(currentUserService.getCurrentUser());
    userQueryParams.setNot2FA(true);
    userService.getUsers(userQueryParams).forEach(user -> {
        user.setSecret(null);
        userService.updateUser(user);
    });
}
Also used : UserQueryParams(org.hisp.dhis.user.UserQueryParams)

Example 13 with UserQueryParams

use of org.hisp.dhis.user.UserQueryParams in project dhis2-core by dhis2.

the class MetadataOrgUnitSplitHandler method splitUsers.

public void splitUsers(OrgUnitSplitRequest request) {
    Set<OrganisationUnit> source = Sets.newHashSet(request.getSource());
    List<User> dataCaptureUsers = userService.getUsers(new UserQueryParams().setCanSeeOwnUserAuthorityGroups(true).setOrganisationUnits(source));
    dataCaptureUsers.forEach(u -> {
        u.addOrganisationUnits(request.getTargets());
        u.removeOrganisationUnit(request.getSource());
    });
    List<User> dataViewUsers = userService.getUsers(new UserQueryParams().setCanSeeOwnUserAuthorityGroups(true).setDataViewOrganisationUnits(source));
    dataViewUsers.forEach(u -> {
        u.getDataViewOrganisationUnits().addAll(request.getTargets());
        u.getDataViewOrganisationUnits().remove(request.getSource());
    });
    List<User> teiSearchOrgUnits = userService.getUsers(new UserQueryParams().setCanSeeOwnUserAuthorityGroups(true).setTeiSearchOrganisationUnits(source));
    teiSearchOrgUnits.forEach(u -> {
        u.getTeiSearchOrganisationUnits().addAll(request.getTargets());
        u.getTeiSearchOrganisationUnits().remove(request.getSource());
    });
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) User(org.hisp.dhis.user.User) UserQueryParams(org.hisp.dhis.user.UserQueryParams)

Example 14 with UserQueryParams

use of org.hisp.dhis.user.UserQueryParams 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)14 User (org.hisp.dhis.user.User)5 Date (java.util.Date)2 HashMap (java.util.HashMap)2 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)2 UserLookup (org.hisp.dhis.webapi.webdomain.user.UserLookup)2 UserLookups (org.hisp.dhis.webapi.webdomain.user.UserLookups)2 DateTime (org.joda.time.DateTime)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 IllegalQueryException (org.hisp.dhis.common.IllegalQueryException)1 Objects (org.hisp.dhis.common.Objects)1 DataSummary (org.hisp.dhis.datasummary.DataSummary)1 ErrorMessage (org.hisp.dhis.feedback.ErrorMessage)1 Query (org.hisp.dhis.query.Query)1 IncomingSms (org.hisp.dhis.sms.incoming.IncomingSms)1 SmsMessageStatus (org.hisp.dhis.sms.incoming.SmsMessageStatus)1 UserGroup (org.hisp.dhis.user.UserGroup)1