Skip to content

Commit

Permalink
[GITFLOW]merging 'hotfix-1.70.2' into 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
MateStrysewske committed Apr 11, 2022
2 parents 8f1c48b + c637b36 commit 8db7b70
Show file tree
Hide file tree
Showing 26 changed files with 287 additions and 80 deletions.
2 changes: 1 addition & 1 deletion sormas-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<parent>
<groupId>de.symeda.sormas</groupId>
<artifactId>sormas-base</artifactId>
<version>1.70.1</version>
<version>1.70.2</version>
<relativePath>../sormas-base</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
28 changes: 26 additions & 2 deletions sormas-api/src/main/java/de/symeda/sormas/api/user/UserFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ public interface UserFacade {

UserDto getByUserName(String userName);

/**
*
* @param regionRef
* reference of the region to be filtered for. When this region is null, it is not filtered in this regard.
* NOTE: some users don't have a region (often users with NATIONAL_USER role, for example). They will
* not be included when a region is specified, but otherwise they will.
* @param limitedDisease
* can be used to remove users from the return value that are limited to diseases other that limitedDisease.
* @param userRights
* user rights to be filtered for.
* @return
*/
List<UserReferenceDto> getUsersByRegionAndRights(RegionReferenceDto regionRef, Disease limitedDisease, UserRight... userRights);

List<UserReferenceDto> getUsersWithSuperiorJurisdiction(UserDto user);
Expand All @@ -62,17 +74,29 @@ public interface UserFacade {
long count(UserCriteria userCriteria);

/**
*
* @param district
* reference of the district to be filtered for. When this district is null, it is not filtered in this regard.
* NOTE: some users don't have a district (often users with NATIONAL_USER role, for example). They will
* not be included when a district is specified, but otherwise they will.
* @param limitedDisease
* can be used to remove users from the return value that are limited to diseases other that limitedDisease.
* @param userRights
* rights of the users by district
* user rights to be filtered for.
* @return
*/
List<UserReferenceDto> getUserRefsByDistrict(DistrictReferenceDto district, Disease limitedDisease, UserRight... userRights);

/**
*
* @param district
* reference of the district to be filtered for. When this district is null, it is not filtered in this regard.
* NOTE: some users don't have a district (often users with NATIONAL_USER role, for example). They will
* * not be included when a district is specified, but otherwise they will.
* @param excludeLimitedDiseaseUsers
* if true, all users limited to diseases are excluded from the return value.
* @param userRights
* rights of the users by district
* user rights to be filtered for.
* @return
*/
List<UserReferenceDto> getUserRefsByDistrict(DistrictReferenceDto district, boolean excludeLimitedDiseaseUsers, UserRight... userRights);
Expand Down
2 changes: 1 addition & 1 deletion sormas-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sormas-base</artifactId>
<groupId>de.symeda.sormas</groupId>
<version>1.70.1</version>
<version>1.70.2</version>
<relativePath>../sormas-base</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sormas-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sormas-base</artifactId>
<groupId>de.symeda.sormas</groupId>
<version>1.70.1</version>
<version>1.70.2</version>
<relativePath>../sormas-base</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* SORMAS® - Surveillance Outbreak Response Management & Analysis System
* Copyright © 2016-2018 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
* Copyright © 2016-2022 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -46,6 +46,7 @@
import java.util.stream.Collectors;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
Expand Down Expand Up @@ -1849,6 +1850,7 @@ private void updateTasksOnCaseChanged(Case newCase, CaseDataDto existingCase) {
}
}

@PermitAll
public void onCaseSampleChanged(Case associatedCase) {
// Update case classification if the feature is enabled
if (configFacade.isFeatureAutomaticCaseClassification()) {
Expand Down Expand Up @@ -1881,13 +1883,12 @@ public void onCaseSampleChanged(Case associatedCase) {
* Handles potential changes, processes and backend logic that needs to be done
* after a case has been created/saved
*/
@PermitAll
public void onCaseChanged(CaseDataDto existingCase, Case newCase) {
onCaseChanged(existingCase, newCase, true);
}

@RolesAllowed({
UserRight._CASE_EDIT,
UserRight._EXTERNAL_VISITS })
@PermitAll
public void onCaseChanged(CaseDataDto existingCase, Case newCase, boolean syncShares) {

// If its a new case and the case is new and the geo coordinates of the case's
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* SORMAS® - Surveillance Outbreak Response Management & Analysis System
* Copyright © 2016-2018 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
* Copyright © 2016-2022 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -42,6 +42,7 @@
import java.util.stream.Collectors;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
Expand Down Expand Up @@ -398,15 +399,14 @@ public ContactDto save(ContactDto dto, boolean handleChanges, boolean handleCase
return toDto(entity);
}

@RolesAllowed({
UserRight._CONTACT_EDIT,
UserRight._EXTERNAL_VISITS })
@PermitAll
public void onContactChanged(ContactDto contact, boolean syncShares) {
if (syncShares && sormasToSormasFacade.isFeatureConfigured()) {
syncSharesAsync(new ShareTreeCriteria(contact.getUuid()));
}
}

@PermitAll
public void onContactChanged(ContactDto existingContact, Contact contact, boolean syncShares) {

if (existingContact == null) {
Expand Down Expand Up @@ -2151,7 +2151,7 @@ private void doSave(Contact contact, boolean handleChanges) {
* Handles potential changes, processes and backend logic that needs to be done
* after a contact has been created/saved
*/
public void onCaseChanged(Contact newContact) {
private void onCaseChanged(Contact newContact) {
// Update completeness value
newContact.setCompleteness(calculateCompleteness(newContact));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* SORMAS® - Surveillance Outbreak Response Management & Analysis System
* Copyright © 2016-2021 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
* Copyright © 2016-2022 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -36,6 +36,7 @@
import java.util.stream.Collectors;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
Expand Down Expand Up @@ -266,6 +267,7 @@ public EventDto save(@NotNull EventDto dto, boolean checkChangeDate, boolean int
return convertToDto(event, pseudonymizer);
}

@PermitAll
public void onEventChange(EventDto event, boolean syncShares) {
if (syncShares && sormasToSormasFacade.isFeatureConfigured()) {
syncSharesAsync(new ShareTreeCriteria(event.getUuid()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import de.symeda.sormas.backend.infrastructure.community.Community;
import de.symeda.sormas.backend.infrastructure.district.District;
import de.symeda.sormas.backend.infrastructure.region.Region;
import de.symeda.sormas.backend.location.Location;
import de.symeda.sormas.backend.user.User;
import de.symeda.sormas.backend.util.PredicateJurisdictionValidator;
import de.symeda.sormas.utils.EventJoins;
Expand Down Expand Up @@ -58,17 +59,18 @@ protected Predicate isInJurisdiction() {

@Override
protected Predicate isInJurisdictionOrOwned() {

final Predicate reportedByCurrentUser = cb.and(
cb.isNotNull(joins.getReportingUser()),
cb.isNotNull(joins.getRoot().get(Event.REPORTING_USER)),
user != null
? cb.equal(joins.getReportingUser().get(User.ID), user.getId())
: cb.equal(joins.getReportingUser().get(User.ID), userPath.get(User.ID)));
? cb.equal(joins.getRoot().get(Event.REPORTING_USER).get(User.ID), user.getId())
: cb.equal(joins.getRoot().get(Event.REPORTING_USER).get(User.ID), userPath.get(User.ID)));

final Predicate currentUserResponsible = cb.and(
cb.isNotNull(joins.getResponsibleUser()),
cb.isNotNull(joins.getRoot().get(Event.RESPONSIBLE_USER)),
user != null
? cb.equal(joins.getResponsibleUser().get(User.ID), user.getId())
: cb.equal(joins.getResponsibleUser().get(User.ID), userPath.get(User.ID)));
? cb.equal(joins.getRoot().get(Event.RESPONSIBLE_USER).get(User.ID), user.getId())
: cb.equal(joins.getRoot().get(Event.RESPONSIBLE_USER).get(User.ID), userPath.get(User.ID)));

return cb.or(reportedByCurrentUser, currentUserResponsible, isInJurisdiction());
}
Expand All @@ -86,22 +88,22 @@ protected Predicate whenNationalLevel() {
@Override
protected Predicate whenRegionalLevel() {
return user != null
? cb.equal(joins.getRegion().get(Region.ID), user.getRegion().getId())
: cb.equal(joins.getRegion().get(Region.ID), userPath.get(User.REGION).get(Region.ID));
? cb.equal(joins.getLocation().get(Location.REGION).get(Region.ID), user.getRegion().getId())
: cb.equal(joins.getLocation().get(Location.REGION).get(Region.ID), userPath.get(User.REGION).get(Region.ID));
}

@Override
protected Predicate whenDistrictLevel() {
return user != null
? cb.equal(joins.getDistrict().get(District.ID), user.getDistrict().getId())
: cb.equal(joins.getDistrict().get(District.ID), userPath.get(User.DISTRICT).get(District.ID));
? cb.equal(joins.getLocation().get(Location.DISTRICT).get(District.ID), user.getDistrict().getId())
: cb.equal(joins.getLocation().get(Location.DISTRICT).get(District.ID), userPath.get(User.DISTRICT).get(District.ID));
}

@Override
protected Predicate whenCommunityLevel() {
return user != null
? cb.equal(joins.getCommunity().get(Community.ID), user.getCommunity().getId())
: cb.equal(joins.getCommunity().get(Community.ID), userPath.get(User.COMMUNITY).get(Community.ID));
? cb.equal(joins.getLocation().get(Location.COMMUNITY).get(Community.ID), user.getCommunity().getId())
: cb.equal(joins.getLocation().get(Location.COMMUNITY).get(Community.ID), userPath.get(User.COMMUNITY).get(Community.ID));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* SORMAS® - Surveillance Outbreak Response Management & Analysis System
* Copyright © 2016-2021 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
* Copyright © 2016-2022 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
Expand Down Expand Up @@ -31,6 +31,7 @@
import java.util.function.Function;
import java.util.stream.Collectors;

import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
Expand Down Expand Up @@ -352,6 +353,7 @@ public EventParticipantDto saveEventParticipant(@Valid EventParticipantDto dto,
return convertToDto(entity, pseudonymizer);
}

@PermitAll
public void onEventParticipantChanged(
EventDto event,
EventParticipantDto existingEventParticipant,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ public Predicate createUserFilter(
default:
}

Predicate filterResponsible = cb.equal(eventJoins.getReportingUser(), currentUser);
filterResponsible = cb.or(filterResponsible, cb.equal(eventJoins.getResponsibleUser(), currentUser));
Predicate filterResponsible = cb.equal(eventJoins.getRoot().get(Event.REPORTING_USER), currentUser);
filterResponsible = cb.or(filterResponsible, cb.equal(eventJoins.getRoot().get(Event.RESPONSIBLE_USER), currentUser));

if (eventUserFilterCriteria != null && eventUserFilterCriteria.isIncludeUserCaseAndEventParticipantFilter()) {
filter = CriteriaBuilderHelper.or(cb, filter, createCaseAndEventParticipantFilter(cb, cq, eventParticipantJoin));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* SORMAS® - Surveillance Outbreak Response Management & Analysis System
* Copyright © 2016-2021 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
* Copyright © 2016-2022 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
Expand Down Expand Up @@ -32,6 +32,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
Expand Down Expand Up @@ -1083,10 +1084,12 @@ private void cleanup(Person person) {
}
}

@PermitAll
public void onPersonChanged(PersonDto existingPerson, Person newPerson) {
onPersonChanged(existingPerson, newPerson, true);
}

@PermitAll
public void onPersonChanged(PersonDto existingPerson, Person newPerson, boolean syncShares) {

List<Case> personCases = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public List<ExternalShareInfoCountAndLatestDate> getShareCountAndLatestDate(List
countSubQuery.groupBy(countAssociatedObject);

cq.multiselect(associatedObjectUuid, countSubQuery, creationDate, root.get(ExternalShareInfo.STATUS));
cq.distinct(true);
cq.where(
cb.function(ExtendedPostgreSQL94Dialect.CONCAT_FUNCTION, String.class, associatedObjectId, creationDate).in(latestShareInfoSubQuery),
associatedObjectId.in(ids));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ public long count(TaskCriteria taskCriteria) {

Predicate filter = null;
if (taskCriteria == null || !taskCriteria.hasContextCriteria()) {
filter = taskService.createUserFilter(cb, cq, task);
filter = taskService.createUserFilterForJoin(new TaskQueryContext<>(cb, cq, task));
} else {
filter = CriteriaBuilderHelper.and(cb, filter, taskService.createAssigneeFilter(cb, joins.getAssignee()));
}
Expand Down Expand Up @@ -546,7 +546,7 @@ public List<TaskIndexDto> getIndexList(TaskCriteria taskCriteria, Integer first,

Predicate filter = null;
if (taskCriteria == null || !taskCriteria.hasContextCriteria()) {
filter = taskService.createUserFilter(cb, cq, task);
filter = taskService.createUserFilterForJoin(taskQueryContext);
} else {
filter = CriteriaBuilderHelper.and(cb, filter, taskService.createAssigneeFilter(cb, joins.getAssignee()));
}
Expand Down Expand Up @@ -710,7 +710,7 @@ public List<TaskExportDto> getExportList(TaskCriteria criteria, Collection<Strin
//@formatter:on
Predicate filter = null;
if (criteria == null || !criteria.hasContextCriteria()) {
filter = taskService.createUserFilter(cb, cq, task);
filter = taskService.createUserFilterForJoin(new TaskQueryContext<>(cb, cq, task));
} else {
filter = CriteriaBuilderHelper.and(cb, filter, taskService.createAssigneeFilter(cb, joins.getAssignee()));
}
Expand Down
Loading

0 comments on commit 8db7b70

Please sign in to comment.