|
20 | 20 | import java.util.ArrayList; |
21 | 21 | import java.util.Collection; |
22 | 22 | import java.util.List; |
23 | | - |
24 | | -import org.apache.commons.text.StringEscapeUtils; |
25 | | - |
| 23 | +import com.vaadin.data.provider.DataProvider; |
| 24 | +import com.vaadin.data.provider.ListDataProvider; |
26 | 25 | import com.vaadin.navigator.Navigator; |
27 | 26 | import com.vaadin.server.Page; |
28 | 27 | import com.vaadin.server.Sizeable; |
|
44 | 43 | import de.symeda.sormas.api.event.EventCriteria; |
45 | 44 | import de.symeda.sormas.api.event.EventDto; |
46 | 45 | import de.symeda.sormas.api.event.EventIndexDto; |
| 46 | +import de.symeda.sormas.api.event.EventParticipantCriteria; |
47 | 47 | import de.symeda.sormas.api.event.EventParticipantDto; |
| 48 | +import de.symeda.sormas.api.event.EventParticipantFacade; |
| 49 | +import de.symeda.sormas.api.event.EventParticipantIndexDto; |
| 50 | +import de.symeda.sormas.api.event.EventParticipantReferenceDto; |
48 | 51 | import de.symeda.sormas.api.event.EventReferenceDto; |
49 | 52 | import de.symeda.sormas.api.i18n.Captions; |
50 | 53 | import de.symeda.sormas.api.i18n.I18nProperties; |
|
60 | 63 | import de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent.CommitListener; |
61 | 64 | import de.symeda.sormas.ui.utils.VaadinUiUtil; |
62 | 65 |
|
| 66 | +import org.apache.commons.text.StringEscapeUtils; |
| 67 | + |
63 | 68 | public class EventController { |
64 | 69 |
|
65 | 70 | public void registerViews(Navigator navigator) { |
@@ -105,7 +110,7 @@ public void onCommit() { |
105 | 110 |
|
106 | 111 | EventReferenceDto eventReferenceDto = new EventReferenceDto(selectedEvent.getUuid()); |
107 | 112 | if (!eventIndexDto.contains(selectedEvent)) { |
108 | | - createEventParticipantWithCase(eventReferenceDto, caseDataDto, caseRef); |
| 113 | + linkCaseToEvent(eventReferenceDto, caseDataDto, caseRef); |
109 | 114 | } |
110 | 115 | } else { |
111 | 116 | create(caseRef); |
@@ -153,7 +158,19 @@ public void selectOrCreateEvent(ContactDto contact) { |
153 | 158 | VaadinUiUtil.showModalPopupWindow(component, I18nProperties.getString(Strings.headingPickOrCreateEvent)); |
154 | 159 | } |
155 | 160 |
|
156 | | - public void createEventParticipantWithCase(EventReferenceDto eventReferenceDto, CaseDataDto caseDataDto, CaseReferenceDto caseRef) { |
| 161 | + public void linkCaseToEvent(EventReferenceDto eventReferenceDto, CaseDataDto caseDataDto, CaseReferenceDto caseRef) { |
| 162 | + // Check whether Person is already enlisted as EventParticipant in this Event |
| 163 | + EventParticipantReferenceDto eventParticipantRef = |
| 164 | + FacadeProvider.getEventParticipantFacade().getReferenceByEventAndPerson(eventReferenceDto.getUuid(), caseDataDto.getPerson().getUuid()); |
| 165 | + if (eventParticipantRef != null) { |
| 166 | + EventParticipantDto eventParticipant = |
| 167 | + FacadeProvider.getEventParticipantFacade().getEventParticipantByUuid(eventParticipantRef.getUuid()); |
| 168 | + eventParticipant.setResultingCase(caseRef); |
| 169 | + FacadeProvider.getEventParticipantFacade().saveEventParticipant(eventParticipant); |
| 170 | + return; |
| 171 | + } |
| 172 | + |
| 173 | + // Create new EventParticipant for this Person |
157 | 174 | PersonDto personDto = FacadeProvider.getPersonFacade().getPersonByUuid(caseDataDto.getPerson().getUuid()); |
158 | 175 | EventParticipantDto eventParticipantDto; |
159 | 176 | eventParticipantDto = |
@@ -242,7 +259,7 @@ public void onCommit() { |
242 | 259 | if (caseRef != null) { |
243 | 260 | EventReferenceDto createdEvent = new EventReferenceDto(dto.getUuid()); |
244 | 261 |
|
245 | | - createEventParticipantWithCase(createdEvent, finalCaseDataDto, caseRef); |
| 262 | + linkCaseToEvent(createdEvent, finalCaseDataDto, caseRef); |
246 | 263 | SormasUI.refreshView(); |
247 | 264 | } else { |
248 | 265 | navigateToParticipants(dto.getUuid()); |
|
0 commit comments