use of de.symeda.sormas.api.user.UserRole in project SORMAS-Project by hzi-braunschweig.
the class CampaignFacadeEjb method deleteCampaign.
@Override
public void deleteCampaign(String campaignUuid) {
User user = userService.getCurrentUser();
if (!userRoleConfigFacade.getEffectiveUserRights(user.getUserRoles().toArray(new UserRole[user.getUserRoles().size()])).contains(UserRight.CAMPAIGN_DELETE)) {
throw new UnsupportedOperationException(I18nProperties.getString(Strings.entityUser) + " " + user.getUuid() + " is not allowed to delete " + I18nProperties.getString(Strings.entityCampaigns).toLowerCase() + ".");
}
service.delete(service.getByUuid(campaignUuid));
}
use of de.symeda.sormas.api.user.UserRole in project SORMAS-Project by hzi-braunschweig.
the class PathogenTestFacadeEjb method deletePathogenTest.
@Override
public void deletePathogenTest(String pathogenTestUuid) {
User user = userService.getCurrentUser();
if (!userRoleConfigFacade.getEffectiveUserRights(user.getUserRoles().toArray(new UserRole[user.getUserRoles().size()])).contains(UserRight.PATHOGEN_TEST_DELETE)) {
throw new UnsupportedOperationException("User " + user.getUuid() + " is not allowed to delete pathogen " + "tests.");
}
PathogenTest pathogenTest = pathogenTestService.getByUuid(pathogenTestUuid);
pathogenTestService.delete(pathogenTest);
handleAssotiatedObjectChanges(pathogenTest, true);
}
use of de.symeda.sormas.api.user.UserRole in project SORMAS-Project by hzi-braunschweig.
the class SampleFacadeEjb method deleteSample.
@Override
public void deleteSample(SampleReferenceDto sampleRef) {
User user = userService.getCurrentUser();
if (!userRoleConfigFacade.getEffectiveUserRights(user.getUserRoles().toArray(new UserRole[user.getUserRoles().size()])).contains(UserRight.SAMPLE_DELETE)) {
throw new UnsupportedOperationException("User " + user.getUuid() + " is not allowed to delete samples.");
}
Sample sample = sampleService.getByReferenceDto(sampleRef);
sampleService.delete(sample);
handleAssotiatedObjectChanges(sample, true);
}
use of de.symeda.sormas.api.user.UserRole in project SORMAS-Project by hzi-braunschweig.
the class SampleFacadeEjb method deleteAllSamples.
@Override
public void deleteAllSamples(List<String> sampleUuids) {
User user = userService.getCurrentUser();
if (!userRoleConfigFacade.getEffectiveUserRights(user.getUserRoles().toArray(new UserRole[user.getUserRoles().size()])).contains(UserRight.SAMPLE_DELETE)) {
throw new UnsupportedOperationException("User " + user.getUuid() + " is not allowed to delete samples.");
}
long startTime = DateHelper.startTime();
IterableHelper.executeBatched(sampleUuids, DELETED_BATCH_SIZE, batchedSampleUuids -> sampleService.deleteAll(batchedSampleUuids));
logger.debug("deleteAllSamples(sampleUuids) finished. samplesCount = {}, {}ms", sampleUuids.size(), DateHelper.durationMillies(startTime));
}
use of de.symeda.sormas.api.user.UserRole in project SORMAS-Project by hzi-braunschweig.
the class UserService method getLabUsersOfLab.
public List<User> getLabUsersOfLab(Facility facility) {
if (facility == null || facility.getType() != FacilityType.LABORATORY) {
throw new IllegalArgumentException("Facility needs to be a laboratory");
}
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<User> cq = cb.createQuery(getElementClass());
Root<User> from = cq.from(getElementClass());
Join<User, UserRole> joinRoles = from.join(User.USER_ROLES, JoinType.LEFT);
Predicate filter = cb.and(createDefaultFilter(cb, from), cb.equal(from.get(User.LABORATORY), facility), joinRoles.in(Arrays.asList(UserRole.LAB_USER, UserRole.EXTERNAL_LAB_USER)));
cq.where(filter).distinct(true);
return em.createQuery(cq).getResultList();
}
Aggregations