use of org.hisp.dhis.user.UserCredentials in project dhis2-core by dhis2.
the class FormUtilsImpl method getDataSetsForCurrentUser.
@Override
public List<DataSet> getDataSetsForCurrentUser(Integer organisationUnitId) {
Validate.notNull(organisationUnitId);
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(organisationUnitId);
List<DataSet> dataSets = new ArrayList<>(organisationUnit.getDataSets());
UserCredentials userCredentials = currentUserService.getCurrentUser().getUserCredentials();
if (!userCredentials.isSuper()) {
dataSets.retainAll(userCredentials.getAllDataSets());
}
return dataSets;
}
use of org.hisp.dhis.user.UserCredentials in project dhis2-core by dhis2.
the class GetDataSetsAction method getDataSetsForCurrentUser.
private List<DataSet> getDataSetsForCurrentUser(String ids) {
Set<DataSet> dataSets = new HashSet<>();
if (ids.length() == 0) {
return new ArrayList<>();
}
for (String id : ids.split(",")) {
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(id);
if (organisationUnit == null) {
continue;
}
if (organisationUnit.getDataSets() != null) {
dataSets.addAll(organisationUnit.getDataSets());
}
}
UserCredentials userCredentials = currentUserService.getCurrentUser().getUserCredentials();
if (!userCredentials.isSuper()) {
dataSets.retainAll(userCredentials.getAllDataSets());
}
return new ArrayList<>(dataSets);
}
use of org.hisp.dhis.user.UserCredentials in project dhis2-core by dhis2.
the class GetLockExceptionFormAction method getDataSetsForCurrentUser.
private List<DataSet> getDataSetsForCurrentUser(int id) {
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(id);
if (organisationUnit == null) {
return new ArrayList<>();
}
List<DataSet> dataSets = new ArrayList<>();
if (organisationUnit.getDataSets() != null) {
dataSets.addAll(organisationUnit.getDataSets());
}
UserCredentials userCredentials = currentUserService.getCurrentUser().getUserCredentials();
if (!userCredentials.isSuper()) {
dataSets.retainAll(userCredentials.getAllDataSets());
}
return dataSets;
}
use of org.hisp.dhis.user.UserCredentials in project dhis2-core by dhis2.
the class DhisConvenienceTest method createUser.
public static User createUser(char uniqueCharacter) {
UserCredentials credentials = new UserCredentials();
User user = new User();
user.setUid(BASE_USER_UID + uniqueCharacter);
credentials.setUserInfo(user);
user.setUserCredentials(credentials);
credentials.setUsername("username" + uniqueCharacter);
credentials.setPassword("password" + uniqueCharacter);
user.setFirstName("FirstName" + uniqueCharacter);
user.setSurname("Surname" + uniqueCharacter);
user.setEmail("Email" + uniqueCharacter);
user.setPhoneNumber("PhoneNumber" + uniqueCharacter);
user.setCode("UserCode" + uniqueCharacter);
user.setAutoFields();
return user;
}
Aggregations