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

Commit 743ec3d

Browse files
Merge pull request SORMAS-Foundation#2741 from john1496/feature-link-event-to-case-#2684
solved Linking a case to an event breaks when there is no event in the db issue SORMAS-Foundation#2684
2 parents 84d6795 + 8fed454 commit 743ec3d

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,7 @@ public Contact fromDto(@NotNull ContactDto source) {
927927
target.setCreationDate(new Timestamp(source.getCreationDate().getTime()));
928928
}
929929
}
930+
930931
DtoHelper.validateDto(source, target);
931932

932933
target.setCaze(caseService.getByReferenceDto(source.getCaze()));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public List<EventParticipantDto> getAllEventParticipantsByEventAfter(Date date,
115115
}
116116

117117
@Override
118-
public List<String> getAllActiveUuids() {
118+
public List<String> getAllActiveUuids() {
119119
User user = userService.getCurrentUser();
120120

121121
if (user == null) {

sormas-ui/src/main/java/de/symeda/sormas/ui/caze/eventLink/EventListComponent.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
import com.vaadin.ui.VerticalLayout;
2929
import com.vaadin.ui.themes.ValoTheme;
3030

31+
import de.symeda.sormas.api.FacadeProvider;
3132
import de.symeda.sormas.api.caze.CaseReferenceDto;
33+
import de.symeda.sormas.api.event.EventCriteria;
3234
import de.symeda.sormas.api.i18n.Captions;
3335
import de.symeda.sormas.api.i18n.I18nProperties;
3436
import de.symeda.sormas.api.i18n.Strings;
@@ -44,7 +46,19 @@ public class EventListComponent extends VerticalLayout {
4446

4547
public EventListComponent(CaseReferenceDto caseRef) {
4648

47-
createEventListComponent(new EventList(caseRef), e -> ControllerProvider.getEventController().selectOrCreateEvent(caseRef));
49+
createEventListComponent(new EventList(caseRef), e -> {
50+
51+
EventCriteria eventCriteria = new EventCriteria();
52+
53+
//check if there are active events in the database
54+
long events = FacadeProvider.getEventFacade().count(eventCriteria);
55+
if (events > 0) {
56+
ControllerProvider.getEventController().selectOrCreateEvent(caseRef);
57+
} else {
58+
ControllerProvider.getEventController().create(caseRef);
59+
}
60+
});
61+
4862
}
4963

5064
private void createEventListComponent(EventList eventList, Button.ClickListener clickListener) {

0 commit comments

Comments
 (0)