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;
}
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);
});
}
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());
});
}
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);
}
Aggregations