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

Commit b3cc224

Browse files
SORMAS-Foundation#2902 - extend event participant jurisdiction calculation - added logic for warning on change jurisdiction on save
1 parent 45c49f1 commit b3cc224

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

sormas-backend/src/main/java/de/symeda/sormas/backend/event/EventParticipantFacadeEjb.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ public EventParticipantDto saveEventParticipant(EventParticipantDto dto) {
193193
Event event = eventService.getByUuid(eventReferenceDto.getUuid());
194194

195195
if (!eventJurisdictionChecker.isInJurisdiction(event) && (dto.getRegion() == null || dto.getDistrict() == null)) {
196-
dto.setRegion(new RegionReferenceDto(user.getRegion() != null ? user.getRegion().getUuid() : null));
197-
dto.setDistrict(new DistrictReferenceDto(user.getDistrict() != null ? user.getDistrict().getUuid() : null));
196+
dto.setRegion(user.getRegion() != null ? new RegionReferenceDto(user.getRegion().getUuid()) : null);
197+
dto.setDistrict(user.getDistrict() != null ? new DistrictReferenceDto(user.getDistrict().getUuid()) : null);
198198
}
199199

200200
Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight);

sormas-ui/src/main/java/de/symeda/sormas/ui/events/EventParticipantsController.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,24 +220,28 @@ private CommitDiscardWrapperComponent<EventParticipantEditForm> createEventParti
220220
RegionReferenceDto epEventRegion = eventDto.getEventLocation().getRegion();
221221
DistrictReferenceDto epEventDistrict = eventDto.getEventLocation().getDistrict();
222222

223+
//Responsible region of the event participant is filled and differs from user Region - warning about loosing full access rights to the event participant should be triggered
223224
Boolean responsibleRegionDiffersFromUserRegion =
224225
(userRegion != null && epResponsibleRegion != null && !userRegion.equals(epResponsibleRegion));
225226

227+
//Responsible district of the event participant is filled and differs from user District - warning about loosing full access rights to the event participant should be triggered
226228
Boolean responsibleDistrictDiffersFromUserDistrict =
227229
(userDistrict != null && epResponsibleDistrict != null && !userDistrict.equals(epResponsibleDistrict));
228230

229-
Boolean responsibleEmptyFallBackToEvent = (epResponsibleRegion == null
231+
//both responsible region and district of the event participant are empty and the fall back towards event location:
232+
// event region or event district is different from user's region or district - warning about loosing full access rights to the event participant should be triggered
233+
Boolean responsibleFieldsEmptyAndEventOutsideJurisdiction = (epResponsibleRegion == null
230234
&& epResponsibleDistrict == null
231235
&& (userRegion != null && !userRegion.equals(epEventRegion) || userDistrict != null && !userDistrict.equals(epEventDistrict)));
232236

233-
Boolean onResponsibleDistrictNullCheckBothRegionAndDistrictAgainstUser =
234-
((epResponsibleRegion != null && epResponsibleDistrict == null)
235-
&& (userRegion != null && !userRegion.equals(epResponsibleRegion) || userDistrict != null));
237+
//if only district is not filled and either responsible region or district are different from user region or district - warning about loosing full access rights to the event participant should be triggered
238+
Boolean responsibleDistrictIsEmpty = ((epResponsibleRegion != null && epResponsibleDistrict == null)
239+
&& (userRegion != null && !userRegion.equals(epResponsibleRegion) || userDistrict != null));
236240

237241
if (responsibleRegionDiffersFromUserRegion
238242
|| responsibleDistrictDiffersFromUserDistrict
239-
|| responsibleEmptyFallBackToEvent
240-
|| onResponsibleDistrictNullCheckBothRegionAndDistrictAgainstUser) {
243+
|| responsibleFieldsEmptyAndEventOutsideJurisdiction
244+
|| responsibleDistrictIsEmpty) {
241245
VaadinUiUtil.showConfirmationPopup(
242246
I18nProperties.getString(Strings.headingEventParticipantResponsibleJurisdictionUpdated),
243247
new Label(I18nProperties.getString(Strings.messageEventParticipantResponsibleJurisdictionUpdated)),

0 commit comments

Comments
 (0)