use of de.symeda.sormas.backend.user.User in project SORMAS-Project by hzi-braunschweig.
the class ContactFacadeEjb method getIndexDetailedList.
@Override
public List<ContactIndexDetailedDto> getIndexDetailedList(ContactCriteria contactCriteria, Integer first, Integer max, List<SortProperty> sortProperties) {
CriteriaQuery<ContactIndexDetailedDto> query = listCriteriaBuilder.buildIndexDetailedCriteria(contactCriteria, sortProperties);
List<ContactIndexDetailedDto> dtos = QueryHelper.getResultList(em, query, first, max);
// Load event count and latest events info per contact
Map<String, List<ContactEventSummaryDetails>> eventSummaries = eventService.getEventSummaryDetailsByContacts(dtos.stream().map(ContactIndexDetailedDto::getUuid).collect(Collectors.toList())).stream().collect(Collectors.groupingBy(ContactEventSummaryDetails::getContactUuid, Collectors.toList()));
for (ContactIndexDetailedDto contact : dtos) {
List<ContactEventSummaryDetails> contactEvents = eventSummaries.getOrDefault(contact.getUuid(), Collections.emptyList());
contact.setEventCount((long) contactEvents.size());
contactEvents.stream().max(Comparator.comparing(ContactEventSummaryDetails::getEventDate)).ifPresent(eventSummary -> {
contact.setLatestEventId(eventSummary.getEventUuid());
contact.setLatestEventTitle(eventSummary.getEventTitle());
});
}
Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight, I18nProperties.getCaption(Captions.inaccessibleValue));
User currentUser = userService.getCurrentUser();
pseudonymizer.pseudonymizeDtoCollection(ContactIndexDetailedDto.class, dtos, c -> c.getInJurisdiction(), (c, isInJurisdiction) -> {
pseudonymizer.pseudonymizeUser(userService.getByUuid(c.getReportingUser().getUuid()), currentUser, c::setReportingUser);
if (c.getCaze() != null) {
pseudonymizer.pseudonymizeDto(CaseReferenceDto.class, c.getCaze(), c.getCaseInJurisdiction(), null);
}
});
return dtos;
}
use of de.symeda.sormas.backend.user.User in project SORMAS-Project by hzi-braunschweig.
the class StartupShutdownService method createAndPersistDefaultUser.
private User createAndPersistDefaultUser(UserRole userRole, String firstName, String lastName, DataHelper.Pair<String, String> usernameAndPassword, Consumer<User> userModificator) {
User user = MockDataGenerator.createUser(userRole, firstName, lastName, usernameAndPassword.getElement1());
user.setUserName(usernameAndPassword.getElement0());
userModificator.accept(user);
userService.persist(user);
userUpdateEvent.fire(new UserUpdateEvent(user));
return user;
}
use of de.symeda.sormas.backend.user.User in project SORMAS-Project by hzi-braunschweig.
the class StartupShutdownService method syncUsers.
/**
* Synchronizes all active users with the external Authentication Provider if User Sync at startup is enabled and supported.
*
* @see AuthProvider#isUserSyncSupported()
* @see AuthProvider#isUserSyncAtStartupEnabled()
*/
private void syncUsers() {
AuthProvider authProvider = AuthProvider.getProvider(configFacade);
if (!authProvider.isUserSyncSupported()) {
logger.info("Active Authentication Provider {} doesn't support user sync", authProvider.getName());
return;
}
if (!authProvider.isUserSyncAtStartupEnabled()) {
logger.info("User sync at startup is disabled. Enable this in SORMAS properties if the active Authentication Provider supports it");
return;
}
List<User> users = userService.getAllActive();
for (User user : users) {
syncUser(user);
}
logger.info("User synchronization finalized");
}
use of de.symeda.sormas.backend.user.User in project SORMAS-Project by hzi-braunschweig.
the class StartupShutdownService method createOrUpdateDefaultUser.
private void createOrUpdateDefaultUser(Set<UserRole> userRoles, String username, String password, String firstName, String lastName) {
if (StringUtils.isAnyBlank(username, password)) {
logger.debug("Invalid user details. Will not create/update default user");
return;
}
User existingUser = userService.getByUserName(username);
if (existingUser == null) {
if (!DataHelper.isNullOrEmpty(password)) {
User newUser = MockDataGenerator.createUser(userRoles, firstName, lastName, password);
newUser.setUserName(username);
userService.persist(newUser);
userUpdateEvent.fire(new UserUpdateEvent(newUser));
}
} else if (!DataHelper.equal(existingUser.getPassword(), PasswordHelper.encodePassword(password, existingUser.getSeed()))) {
existingUser.setSeed(PasswordHelper.createPass(16));
existingUser.setPassword(PasswordHelper.encodePassword(password, existingUser.getSeed()));
userService.persist(existingUser);
passwordResetEvent.fire(new PasswordResetEvent(existingUser));
}
}
use of de.symeda.sormas.backend.user.User in project SORMAS-Project by hzi-braunschweig.
the class PersonFacadeEjb method getDeathsBetween.
@Override
public List<PersonDto> getDeathsBetween(Date fromDate, Date toDate, DistrictReferenceDto districtRef, Disease disease) {
final User user = userService.getCurrentUser();
if (user == null) {
return Collections.emptyList();
}
final District district = districtService.getByReferenceDto(districtRef);
return toPseudonymizedDtos(personService.getDeathsBetween(fromDate, toDate, district, disease, user));
}
Aggregations