Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit 9765aa1

Browse files
Only take into account case jurisdiction when contact jurisdiction is empty, extended unit test
1 parent 17d3411 commit 9765aa1

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

sormas-backend/src/main/java/de/symeda/sormas/backend/contact/ContactService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ private Predicate buildQuarantineDateFilter(CriteriaBuilder cb, Root<Contact> co
12731273
cb.greaterThanOrEqualTo(contact.get(Contact.QUARANTINE_TO), to)));
12741274
}
12751275

1276-
public Predicate isInJurisdictionOrOwned(CriteriaBuilder cb, CriteriaQuery<Long> cq, ContactJoins joins) {
1276+
public Predicate isInJurisdictionOrOwned(CriteriaBuilder cb, CriteriaQuery<Long> cq, Root<Contact> contactRoot, ContactJoins joins) {
12771277
final User currentUser = this.getCurrentUser();
12781278

12791279
final Subquery<Long> contactCaseJurisdictionSubQuery = cq.subquery(Long.class);
@@ -1310,7 +1310,7 @@ public Predicate isInJurisdictionOrOwned(CriteriaBuilder cb, CriteriaQuery<Long>
13101310
default:
13111311
jurisdictionPredicate = cb.disjunction();
13121312
}
1313-
return cb.or(reportedByCurrentUser, contactCaseInJurisdiction, jurisdictionPredicate);
1313+
return cb.or(reportedByCurrentUser, jurisdictionPredicate, cb.and(cb.isNull(contactRoot.get(Contact.REGION)), contactCaseInJurisdiction));
13141314
}
13151315

13161316
public boolean isContactEditAllowed(Contact contact) {

sormas-backend/src/main/java/de/symeda/sormas/backend/person/PersonService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ private Predicate getJurisdictionPredicate(CriteriaBuilder cb, CriteriaQuery<Lon
267267
contactJurisdictionSubQuery.where(
268268
cb.and(
269269
cb.equal(contactRoot.get(Contact.PERSON).get(Person.ID), personId),
270-
contactService.isInJurisdictionOrOwned(cb, cq, new ContactJoins(contactRoot))));
270+
contactService.isInJurisdictionOrOwned(cb, cq, contactRoot, new ContactJoins(contactRoot))));
271271
final Predicate isContactInJurisdiction = cb.exists(contactJurisdictionSubQuery);
272272

273273
final Subquery<Long> eventParticipantJurisdictionSubQuery = cq.subquery(Long.class);

sormas-backend/src/test/java/de/symeda/sormas/backend/person/PersonFacadeEjbPseudonymizationTest.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
import de.symeda.sormas.api.Disease;
3939
import de.symeda.sormas.api.caze.CaseDataDto;
40+
import de.symeda.sormas.api.contact.ContactDto;
4041
import de.symeda.sormas.api.event.EventDto;
4142
import de.symeda.sormas.api.location.AreaType;
4243
import de.symeda.sormas.api.location.LocationDto;
@@ -126,8 +127,24 @@ public void testGetContactPersonInSameJurisdiction() {
126127
@Test
127128
public void testGetContactPersonOutsideJurisdiction() {
128129

129-
creator.createContact(user1.toReference(), null, person.toReference(), null, new Date(), null, Disease.CORONAVIRUS, rdcf1);
130+
ContactDto contact =
131+
creator.createContact(user1.toReference(), null, person.toReference(), null, new Date(), null, Disease.CORONAVIRUS, rdcf1);
132+
assertPseudonymised(getPersonFacade().getPersonByUuid(person.getUuid()));
133+
134+
CaseDataDto caze = creator.createCase(user1.toReference(), creator.createPerson().toReference(), rdcf2);
135+
contact.setCaze(caze.toReference());
136+
contact = getContactFacade().saveContact(contact);
130137
assertPseudonymised(getPersonFacade().getPersonByUuid(person.getUuid()));
138+
139+
contact.setRegion(rdcf2.region);
140+
contact.setDistrict(rdcf2.district);
141+
contact = getContactFacade().saveContact(contact);
142+
assertNotPseudonymized(getPersonFacade().getPersonByUuid(person.getUuid()));
143+
144+
contact.setRegion(null);
145+
contact.setDistrict(null);
146+
contact = getContactFacade().saveContact(contact);
147+
assertNotPseudonymized(getPersonFacade().getPersonByUuid(person.getUuid()));
131148
}
132149

133150
@Test

0 commit comments

Comments
 (0)