use of de.symeda.sormas.api.event.EventReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjbTest method testMergeCase.
@Test
public void testMergeCase() throws IOException {
useNationalUserLogin();
// 1. Create
// Create leadCase
UserDto leadUser = creator.createUser("", "", "", "First", "User");
UserReferenceDto leadUserReference = new UserReferenceDto(leadUser.getUuid());
PersonDto leadPerson = creator.createPerson("Alex", "Miller");
PersonReferenceDto leadPersonReference = new PersonReferenceDto(leadPerson.getUuid());
RDCF leadRdcf = creator.createRDCF();
CaseDataDto leadCase = creator.createCase(leadUserReference, leadPersonReference, Disease.DENGUE, CaseClassification.SUSPECT, InvestigationStatus.PENDING, new Date(), leadRdcf, (c) -> {
c.setAdditionalDetails("Test additional details");
c.setFollowUpComment("Test followup comment");
});
leadCase.setClinicianEmail("mail");
leadCase.getEpiData().setActivityAsCaseDetailsKnown(YesNoUnknown.NO);
getCaseFacade().save(leadCase);
VisitDto leadVisit = creator.createVisit(leadCase.getDisease(), leadCase.getPerson(), leadCase.getReportDate());
leadVisit.getSymptoms().setAnorexiaAppetiteLoss(SymptomState.YES);
getVisitFacade().saveVisit(leadVisit);
// Create otherCase
UserDto otherUser = creator.createUser("", "", "", "Second", "User");
UserReferenceDto otherUserReference = new UserReferenceDto(otherUser.getUuid());
PersonDto otherPerson = creator.createPerson("Max", "Smith");
otherPerson.setBirthWeight(2);
getPersonFacade().savePerson(otherPerson);
PersonReferenceDto otherPersonReference = new PersonReferenceDto(otherPerson.getUuid());
RDCF otherRdcf = creator.createRDCF("Reg2", "Dis2", "Comm2", "Fac2", "Poe2");
CaseDataDto otherCase = creator.createCase(otherUserReference, otherPersonReference, Disease.CHOLERA, CaseClassification.SUSPECT, InvestigationStatus.PENDING, new Date(), otherRdcf, (c) -> {
c.setAdditionalDetails("Test other additional details");
c.setFollowUpComment("Test other followup comment");
});
otherCase.setClinicianName("name");
CaseReferenceDto otherCaseReference = getCaseFacade().getReferenceByUuid(otherCase.getUuid());
ContactDto contact = creator.createContact(otherUserReference, otherUserReference, otherPersonReference, otherCase, new Date(), new Date(), null);
Region region = creator.createRegion("");
District district = creator.createDistrict("", region);
SampleDto sample = creator.createSample(otherCaseReference, otherUserReference, creator.createFacility("", region, district, creator.createCommunity("", district)));
TaskDto task = creator.createTask(TaskContext.CASE, TaskType.CASE_INVESTIGATION, TaskStatus.PENDING, otherCaseReference, new ContactReferenceDto(), new EventReferenceDto(), new Date(), otherUserReference);
TreatmentDto treatment = creator.createTreatment(otherCase);
PrescriptionDto prescription = creator.createPrescription(otherCase);
ClinicalVisitDto visit = creator.createClinicalVisit(otherCase);
otherCase.getEpiData().setActivityAsCaseDetailsKnown(YesNoUnknown.YES);
final ArrayList<ActivityAsCaseDto> otherActivitiesAsCase = new ArrayList<>();
ActivityAsCaseDto activityAsCaseDto = new ActivityAsCaseDto();
activityAsCaseDto.setActivityAsCaseType(ActivityAsCaseType.GATHERING);
otherActivitiesAsCase.add(activityAsCaseDto);
otherCase.getEpiData().setActivitiesAsCase(otherActivitiesAsCase);
getCaseFacade().save(otherCase);
VisitDto otherVisit = creator.createVisit(otherCase.getDisease(), otherCase.getPerson(), otherCase.getReportDate());
otherVisit.getSymptoms().setAbdominalPain(SymptomState.YES);
getVisitFacade().saveVisit(otherVisit);
EventDto event = creator.createEvent(otherUserReference);
event.setDisease(otherCase.getDisease());
getEventFacade().save(event);
EventParticipantDto otherCaseEventParticipant = creator.createEventParticipant(event.toReference(), otherPerson, otherUserReference);
otherCaseEventParticipant.setResultingCase(otherCaseReference);
getEventParticipantFacade().saveEventParticipant(otherCaseEventParticipant);
creator.createSurveillanceReport(otherUserReference, otherCaseReference);
TravelEntryDto travelEntry = creator.createTravelEntry(otherPersonReference, otherUserReference, otherCase.getDisease(), otherRdcf.region, otherRdcf.district, otherRdcf.pointOfEntry);
travelEntry.setResultingCase(otherCaseReference);
travelEntry = getTravelEntryFacade().save(travelEntry);
DocumentDto document = creator.createDocument(leadUserReference, "document.pdf", "application/pdf", 42L, DocumentRelatedEntityType.CASE, leadCase.getUuid(), "content".getBytes(StandardCharsets.UTF_8));
DocumentDto otherDocument = creator.createDocument(leadUserReference, "other_document.pdf", "application/pdf", 42L, DocumentRelatedEntityType.CASE, otherCase.getUuid(), "other content".getBytes(StandardCharsets.UTF_8));
// 2. Merge
getCaseFacade().mergeCase(leadCase.getUuid(), otherCase.getUuid());
// 3. Test
CaseDataDto mergedCase = getCaseFacade().getCaseDataByUuid(leadCase.getUuid());
// Check no values
assertNull(mergedCase.getClassificationComment());
// Check 'lead and other have different values'
assertEquals(leadCase.getDisease(), mergedCase.getDisease());
// Check 'lead has value, other has not'
assertEquals(leadCase.getClinicianEmail(), mergedCase.getClinicianEmail());
// Check 'lead has no value, other has'
assertEquals(otherCase.getClinicianName(), mergedCase.getClinicianName());
PersonDto mergedPerson = getPersonFacade().getPersonByUuid(mergedCase.getPerson().getUuid());
// Check no values
assertNull(mergedPerson.getBirthdateDD());
// Check 'lead and other have different values'
assertEquals(leadCase.getPerson().getFirstName(), mergedPerson.getFirstName());
// Check 'lead has value, other has not'
assertEquals(leadCase.getPerson().getLastName(), mergedPerson.getLastName());
// Check 'lead has no value, other has'
assertEquals(otherPerson.getBirthWeight(), mergedPerson.getBirthWeight());
// Check merge comments
assertEquals("Test additional details Test other additional details", mergedCase.getAdditionalDetails());
assertEquals("Test followup comment Test other followup comment", mergedCase.getFollowUpComment());
// 4. Test Reference Changes
// 4.1 Contacts
List<String> contactUuids = new ArrayList<>();
contactUuids.add(contact.getUuid());
assertEquals(leadCase.getUuid(), getContactFacade().getByUuids(contactUuids).get(0).getCaze().getUuid());
// 4.2 Samples
List<String> sampleUuids = new ArrayList<>();
sampleUuids.add(sample.getUuid());
assertEquals(leadCase.getUuid(), getSampleFacade().getByUuids(sampleUuids).get(0).getAssociatedCase().getUuid());
// 4.3 Tasks
List<String> taskUuids = new ArrayList<>();
taskUuids.add(task.getUuid());
assertEquals(leadCase.getUuid(), getTaskFacade().getByUuids(taskUuids).get(0).getCaze().getUuid());
// 4.4 Treatments
List<String> treatmentUuids = new ArrayList<>();
treatmentUuids.add(treatment.getUuid());
assertEquals(leadCase.getTherapy().getUuid(), getTreatmentFacade().getByUuids(treatmentUuids).get(0).getTherapy().getUuid());
// 4.5 Prescriptions
List<String> prescriptionUuids = new ArrayList<>();
prescriptionUuids.add(prescription.getUuid());
assertEquals(leadCase.getTherapy().getUuid(), getPrescriptionFacade().getByUuids(prescriptionUuids).get(0).getTherapy().getUuid());
// 4.6 Clinical Visits
List<String> visitUuids = new ArrayList<>();
visitUuids.add(visit.getUuid());
assertEquals(leadCase.getClinicalCourse().getUuid(), getClinicalVisitFacade().getByUuids(visitUuids).get(0).getClinicalCourse().getUuid());
// 4.7 Visits;
List<String> mergedVisits = getVisitFacade().getIndexList(new VisitCriteria().caze(mergedCase.toReference()), null, null, null).stream().map(VisitIndexDto::getUuid).collect(Collectors.toList());
assertEquals(2, mergedVisits.size());
assertTrue(mergedVisits.contains(leadVisit.getUuid()));
assertTrue(mergedVisits.contains(otherVisit.getUuid()));
// and symptoms
assertEquals(SymptomState.YES, mergedCase.getSymptoms().getAbdominalPain());
assertEquals(SymptomState.YES, mergedCase.getSymptoms().getAnorexiaAppetiteLoss());
assertTrue(mergedCase.getSymptoms().getSymptomatic());
// 4.8 Linked Events
assertEquals(1, getEventFacade().count(new EventCriteria().caze(mergedCase.toReference())));
// 4.8 Linked Surveillance Reports
List<SurveillanceReportDto> surveillanceReportList = getSurveillanceReportFacade().getByCaseUuids(Collections.singletonList(mergedCase.getUuid()));
MatcherAssert.assertThat(surveillanceReportList, hasSize(1));
// 5 Documents
List<DocumentDto> mergedDocuments = getDocumentFacade().getDocumentsRelatedToEntity(DocumentRelatedEntityType.CASE, leadCase.getUuid());
assertEquals(2, mergedDocuments.size());
List<String> documentUuids = mergedDocuments.stream().map(DocumentDto::getUuid).collect(Collectors.toList());
assertTrue(documentUuids.contains(document.getUuid()));
assertTrue(documentUuids.contains(otherDocument.getUuid()));
// 10 Activities as case
final EpiDataDto epiData = mergedCase.getEpiData();
assertEquals(YesNoUnknown.YES, epiData.getActivityAsCaseDetailsKnown());
final List<ActivityAsCaseDto> activitiesAsCase = epiData.getActivitiesAsCase();
assertEquals(1, activitiesAsCase.size());
assertEquals(ActivityAsCaseType.GATHERING, activitiesAsCase.get(0).getActivityAsCaseType());
// Travel entry
travelEntry = getTravelEntryFacade().getByUuid(travelEntry.getUuid());
assertEquals(mergedCase.toReference(), travelEntry.getResultingCase());
}
use of de.symeda.sormas.api.event.EventReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class ContactFacadeEjbTest method testGetIndexDetailedList.
@Test
public void testGetIndexDetailedList() {
ContactCriteria contactCriteria = new ContactCriteria();
contactCriteria.setIncludeContactsFromOtherJurisdictions(true);
List<SortProperty> sortProperties = Collections.emptyList();
List<ContactIndexDetailedDto> result;
// 0. No data: empty list
result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
assertThat(result, is(empty()));
// Create needed structural data
RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility");
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
PersonDto cazePerson = creator.createPerson("Case", "Person");
CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
UserReferenceDto reportingUser = new UserReferenceDto(user.getUuid());
EventDto event1 = creator.createEvent(reportingUser, DateHelper.subtractDays(new Date(), 1));
EventDto event2 = creator.createEvent(reportingUser, new Date());
PersonDto contactPerson = creator.createPerson("Contact", "Person");
ContactDto contact1 = creator.createContact(user.toReference(), user.toReference(), contactPerson.toReference(), caze, new Date(), new Date(), null);
// 1a. one Contact without Event
result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
assertThat(result, hasSize(1));
{
ContactIndexDetailedDto dto = result.get(0);
assertThat(dto.getUuid(), equalTo(contact1.getUuid()));
assertThat(dto.getEventCount(), equalTo(0L));
assertNull(dto.getLatestEventId());
assertNull(dto.getLatestEventTitle());
assertThat(dto.getVisitCount(), equalTo(0));
}
// 1b. one Contact with one Event
creator.createEventParticipant(new EventReferenceDto(event1.getUuid()), contactPerson, reportingUser);
result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
assertThat(result, hasSize(1));
{
ContactIndexDetailedDto dto = result.get(0);
assertThat(dto.getUuid(), equalTo(contact1.getUuid()));
assertThat(dto.getEventCount(), equalTo(1L));
assertThat(dto.getLatestEventId(), equalTo(event1.getUuid()));
assertThat(dto.getLatestEventTitle(), equalTo(event1.getEventTitle()));
assertThat(dto.getVisitCount(), equalTo(0));
}
// 1c. one Contact with two Events, second is leading
creator.createEventParticipant(new EventReferenceDto(event2.getUuid()), contactPerson, reportingUser);
result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
assertThat(result, hasSize(1));
{
ContactIndexDetailedDto dto = result.get(0);
assertThat(dto.getUuid(), equalTo(contact1.getUuid()));
assertThat(dto.getEventCount(), equalTo(2L));
assertThat(dto.getLatestEventId(), equalTo(event2.getUuid()));
assertThat(dto.getLatestEventTitle(), equalTo(event2.getEventTitle()));
assertThat(dto.getVisitCount(), equalTo(0));
}
// 1d. one Contact with two Events and one visit
creator.createVisit(new PersonReferenceDto(contactPerson.getUuid()));
result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
assertThat(result, hasSize(1));
{
ContactIndexDetailedDto dto = result.get(0);
assertThat(dto.getUuid(), equalTo(contact1.getUuid()));
assertThat(dto.getEventCount(), equalTo(2L));
assertThat(dto.getLatestEventId(), equalTo(event2.getUuid()));
assertThat(dto.getLatestEventTitle(), equalTo(event2.getEventTitle()));
assertThat(dto.getVisitCount(), equalTo(1));
}
// 1e. one Contact with two Events and three visits
creator.createVisit(new PersonReferenceDto(contactPerson.getUuid()));
creator.createVisit(new PersonReferenceDto(contactPerson.getUuid()));
result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
assertThat(result, hasSize(1));
{
ContactIndexDetailedDto dto = result.get(0);
assertThat(dto.getUuid(), equalTo(contact1.getUuid()));
assertThat(dto.getEventCount(), equalTo(2L));
assertThat(dto.getLatestEventId(), equalTo(event2.getUuid()));
assertThat(dto.getLatestEventTitle(), equalTo(event2.getEventTitle()));
assertThat(dto.getVisitCount(), equalTo(3));
}
}
use of de.symeda.sormas.api.event.EventReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class SampleController method getDiseaseOf.
public Disease getDiseaseOf(SampleDto sample) {
CaseReferenceDto cazeRef = sample.getAssociatedCase();
if (cazeRef != null) {
return FacadeProvider.getCaseFacade().getByUuid(cazeRef.getUuid()).getDisease();
}
ContactReferenceDto contactRef = sample.getAssociatedContact();
if (contactRef != null) {
return FacadeProvider.getContactFacade().getByUuid(contactRef.getUuid()).getDisease();
}
EventParticipantReferenceDto eventPartRef = sample.getAssociatedEventParticipant();
if (eventPartRef != null) {
EventReferenceDto eventRef = FacadeProvider.getEventParticipantFacade().getByUuid(eventPartRef.getUuid()).getEvent();
if (eventRef != null) {
return FacadeProvider.getEventFacade().getEventByUuid(eventRef.getUuid(), false).getDisease();
}
}
return null;
}
use of de.symeda.sormas.api.event.EventReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class EventsView method createStatusFilterBar.
public HorizontalLayout createStatusFilterBar() {
HorizontalLayout statusFilterLayout = new HorizontalLayout();
statusFilterLayout.setSpacing(true);
statusFilterLayout.setMargin(false);
statusFilterLayout.setWidth(100, Unit.PERCENTAGE);
statusFilterLayout.addStyleName(CssStyles.VSPACE_3);
statusButtons = new HashMap<>();
if (isDefaultViewType()) {
Button statusAll = ButtonHelper.createButton(Captions.all, e -> {
eventCriteria.setEventStatus(null);
navigateTo(eventCriteria);
}, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
statusAll.setCaptionAsHtml(true);
statusFilterLayout.addComponent(statusAll);
statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all));
activeStatusButton = statusAll;
for (EventStatus status : EventStatus.values()) {
Button statusButton = ButtonHelper.createButton("status-" + status, status.toString(), e -> {
eventCriteria.setEventStatus(status);
navigateTo(eventCriteria);
}, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT);
statusButton.setCaptionAsHtml(true);
statusButton.setData(status);
statusFilterLayout.addComponent(statusButton);
statusButtons.put(statusButton, status.toString());
}
} else if (isActionViewType()) {
Button statusAll = ButtonHelper.createButton(Captions.all, e -> {
eventCriteria.setActionStatus(null);
navigateTo(eventCriteria);
}, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
statusAll.setCaptionAsHtml(true);
statusFilterLayout.addComponent(statusAll);
statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all));
activeStatusButton = statusAll;
for (ActionStatus status : ActionStatus.values()) {
Button statusButton = ButtonHelper.createButton("status-" + status, status.toString(), e -> {
eventCriteria.actionStatus(status);
navigateTo(eventCriteria);
}, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT);
statusButton.setCaptionAsHtml(true);
statusButton.setData(status);
statusFilterLayout.addComponent(statusButton);
statusButtons.put(statusButton, status.toString());
}
}
HorizontalLayout actionButtonsLayout = new HorizontalLayout();
actionButtonsLayout.setSpacing(true);
{
// Show active/archived/all dropdown
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_VIEW)) {
if (isGroupViewType()) {
groupRelevanceStatusFilter = buildRelevanceStatus(Captions.eventActiveGroups, Captions.eventArchivedGroups, Captions.eventAllGroups);
groupRelevanceStatusFilter.addValueChangeListener(e -> {
eventGroupCriteria.relevanceStatus((EntityRelevanceStatus) e.getProperty().getValue());
navigateTo(eventGroupCriteria);
});
actionButtonsLayout.addComponent(groupRelevanceStatusFilter);
} else {
int daysAfterEventGetsArchived = FacadeProvider.getConfigFacade().getDaysAfterEventGetsArchived();
if (daysAfterEventGetsArchived > 0) {
relevanceStatusInfoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " " + String.format(I18nProperties.getString(Strings.infoArchivedEvents), daysAfterEventGetsArchived), ContentMode.HTML);
relevanceStatusInfoLabel.setVisible(false);
relevanceStatusInfoLabel.addStyleName(CssStyles.LABEL_VERTICAL_ALIGN_SUPER);
actionButtonsLayout.addComponent(relevanceStatusInfoLabel);
actionButtonsLayout.setComponentAlignment(relevanceStatusInfoLabel, Alignment.MIDDLE_RIGHT);
}
eventRelevanceStatusFilter = buildRelevanceStatus(Captions.eventActiveEvents, Captions.eventArchivedEvents, Captions.eventAllEvents);
eventRelevanceStatusFilter.addValueChangeListener(e -> {
relevanceStatusInfoLabel.setVisible(EntityRelevanceStatus.ARCHIVED.equals(e.getProperty().getValue()));
eventCriteria.relevanceStatus((EntityRelevanceStatus) e.getProperty().getValue());
navigateTo(eventCriteria);
});
actionButtonsLayout.addComponent(eventRelevanceStatusFilter);
}
}
// Bulk operation dropdown
if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS_EVENT) && isDefaultViewType()) {
EventGrid eventGrid = (EventGrid) grid;
List<MenuBarHelper.MenuBarItem> bulkActions = new ArrayList<>();
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_EDIT)) {
bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H, mi -> grid.bulkActionHandler(items -> ControllerProvider.getEventController().showBulkEventDataEditComponent(items))));
}
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_DELETE)) {
bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, mi -> grid.bulkActionHandler(items -> ControllerProvider.getEventController().deleteAllSelectedItems(items, () -> navigateTo(eventCriteria)), true)));
}
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_ARCHIVE)) {
bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionArchive), VaadinIcons.ARCHIVE, mi -> grid.bulkActionHandler(items -> ControllerProvider.getEventController().archiveAllSelectedItems(items, () -> navigateTo(eventCriteria, true)), true), EntityRelevanceStatus.ACTIVE.equals(eventCriteria.getRelevanceStatus())));
bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionDearchive), VaadinIcons.ARCHIVE, mi -> grid.bulkActionHandler(items -> ControllerProvider.getEventController().dearchiveAllSelectedItems(eventGrid.asMultiSelect().getSelectedItems(), () -> navigateTo(eventCriteria, true)), true), EntityRelevanceStatus.ARCHIVED.equals(eventCriteria.getRelevanceStatus())));
}
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENTGROUP_CREATE) && UserProvider.getCurrent().hasUserRight(UserRight.EVENTGROUP_LINK)) {
bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionGroupEvent), VaadinIcons.FILE_TREE, mi -> grid.bulkActionHandler(items -> ControllerProvider.getEventGroupController().linkAllToGroup(eventGrid.asMultiSelect().getSelectedItems(), () -> navigateTo(eventCriteria)))));
}
bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.ExternalSurveillanceToolGateway_send), VaadinIcons.SHARE, mi -> grid.bulkActionHandler(items -> ControllerProvider.getEventController().sendAllSelectedToExternalSurveillanceTool(eventGrid.asMultiSelect().getSelectedItems(), () -> navigateTo(eventCriteria))), FacadeProvider.getExternalSurveillanceToolFacade().isFeatureEnabled()));
if (isDocGenerationAllowed()) {
bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkActionCreatDocuments), VaadinIcons.FILE_TEXT, mi -> {
grid.bulkActionHandler(items -> {
EventGrid eventGrid1 = (EventGrid) this.grid;
List<EventReferenceDto> references = eventGrid1.asMultiSelect().getSelectedItems().stream().map(EventIndexDto::toReference).collect(Collectors.toList());
if (references.size() == 0) {
new Notification(I18nProperties.getString(Strings.headingNoEventsSelected), I18nProperties.getString(Strings.headingNoEventsSelected), Notification.Type.WARNING_MESSAGE, false).show(Page.getCurrent());
return;
}
ControllerProvider.getDocGenerationController().showEventDocumentDialog(references);
});
}));
}
bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, bulkActions);
bulkOperationsDropdown.setVisible(viewConfiguration.isInEagerMode());
bulkOperationsDropdown.setCaption("");
actionButtonsLayout.addComponent(bulkOperationsDropdown);
}
if (isDefaultViewType()) {
// Contact Count Method Dropdown
contactCountMethod = ComboBoxHelper.createComboBoxV7();
contactCountMethod.setCaption(I18nProperties.getCaption(Captions.Event_contactCountMethod));
contactCountMethod.addItem(EventContactCountMethod.ALL);
contactCountMethod.addItem(EventContactCountMethod.SOURCE_CASE_IN_EVENT);
contactCountMethod.addItem(EventContactCountMethod.BOTH_METHODS);
contactCountMethod.setItemCaption(EventContactCountMethod.ALL, I18nProperties.getEnumCaption(EventContactCountMethod.ALL));
contactCountMethod.setItemCaption(EventContactCountMethod.SOURCE_CASE_IN_EVENT, I18nProperties.getEnumCaption(EventContactCountMethod.SOURCE_CASE_IN_EVENT));
contactCountMethod.setItemCaption(EventContactCountMethod.BOTH_METHODS, I18nProperties.getEnumCaption(EventContactCountMethod.BOTH_METHODS));
contactCountMethod.setValue(EventContactCountMethod.ALL);
contactCountMethod.setTextInputAllowed(false);
contactCountMethod.setNullSelectionAllowed(false);
contactCountMethod.addValueChangeListener(event -> {
((EventGrid) grid).setContactCountMethod((EventContactCountMethod) event.getProperty().getValue());
((EventGrid) grid).reload();
});
actionButtonsLayout.addComponent(contactCountMethod);
}
}
statusFilterLayout.addComponent(actionButtonsLayout);
statusFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT);
statusFilterLayout.setExpandRatio(actionButtonsLayout, 1);
return statusFilterLayout;
}
use of de.symeda.sormas.api.event.EventReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class EventController method selectOrCreateEvent.
public void selectOrCreateEvent(CaseReferenceDto caseRef) {
CaseDataDto caseDataDto = FacadeProvider.getCaseFacade().getCaseDataByUuid(caseRef.getUuid());
EventSelectionField eventSelect = new EventSelectionField(caseDataDto.getDisease(), I18nProperties.getString(Strings.infoPickOrCreateEventForCase), null);
eventSelect.setWidth(1100, Sizeable.Unit.PIXELS);
final CommitDiscardWrapperComponent<EventSelectionField> component = new CommitDiscardWrapperComponent<>(eventSelect);
component.addCommitListener(() -> {
EventIndexDto selectedEvent = eventSelect.getValue();
if (selectedEvent != null) {
EventCriteria eventCriteria = new EventCriteria();
eventCriteria.caze(caseRef);
eventCriteria.setUserFilterIncluded(false);
List<EventIndexDto> eventIndexDto = FacadeProvider.getEventFacade().getIndexList(eventCriteria, null, null, null);
EventReferenceDto eventReferenceDto = new EventReferenceDto(selectedEvent.getUuid());
if (!eventIndexDto.contains(selectedEvent)) {
linkCaseToEvent(eventReferenceDto, caseDataDto, caseRef);
SormasUI.refreshView();
} else {
SormasUI.refreshView();
Notification notification = new Notification(I18nProperties.getString(Strings.messagePersonAlreadyCaseInEvent), "", Type.HUMANIZED_MESSAGE);
notification.setDelayMsec(10000);
notification.show(Page.getCurrent());
}
} else {
create(caseRef);
SormasUI.refreshView();
}
});
eventSelect.setSelectionChangeCallback((commitAllowed) -> {
component.getCommitButton().setEnabled(commitAllowed);
});
VaadinUiUtil.showModalPopupWindow(component, I18nProperties.getString(Strings.headingPickOrCreateEvent));
}
Aggregations