use of de.symeda.sormas.api.contact.ContactFacade in project SORMAS-Project by hzi-braunschweig.
the class ContactController method showBulkContactDataEditComponent.
public void showBulkContactDataEditComponent(Collection<? extends ContactIndexDto> selectedContacts, String caseUuid) {
if (selectedContacts.size() == 0) {
new Notification(I18nProperties.getString(Strings.headingNoContactsSelected), I18nProperties.getString(Strings.messageNoContactsSelected), Type.WARNING_MESSAGE, false).show(Page.getCurrent());
return;
}
// Check if cases with multiple districts have been selected
String districtUuid = null;
for (ContactIndexDto selectedContact : selectedContacts) {
String selectedDistrictUuid = selectedContact.getDistrictUuid();
if (districtUuid == null) {
districtUuid = selectedDistrictUuid;
} else if (!districtUuid.equals(selectedDistrictUuid)) {
districtUuid = null;
break;
}
}
DistrictReferenceDto district = districtUuid != null ? FacadeProvider.getDistrictFacade().getReferenceByUuid(districtUuid) : null;
// Create a temporary contact in order to use the CommitDiscardWrapperComponent
ContactBulkEditData bulkEditData = new ContactBulkEditData();
BulkContactDataForm form = new BulkContactDataForm(district, selectedContacts);
form.setValue(bulkEditData);
final CommitDiscardWrapperComponent<BulkContactDataForm> editView = new CommitDiscardWrapperComponent<BulkContactDataForm>(form, form.getFieldGroup());
Window popupWindow = VaadinUiUtil.showModalPopupWindow(editView, I18nProperties.getString(Strings.headingEditContacts));
editView.addCommitListener(() -> {
ContactBulkEditData updatedBulkEditData = form.getValue();
ContactFacade contactFacade = FacadeProvider.getContactFacade();
boolean classificationChange = form.getClassificationCheckBox().getValue();
boolean contactOfficerChange = district != null ? form.getContactOfficerCheckBox().getValue() : false;
int changedContacts = bulkEdit(selectedContacts, updatedBulkEditData, contactFacade, classificationChange, contactOfficerChange);
popupWindow.close();
if (caseUuid == null) {
overview();
} else {
caseContactsOverview(caseUuid);
}
if (changedContacts == selectedContacts.size()) {
Notification.show(I18nProperties.getString(Strings.messageContactsEdited), Type.HUMANIZED_MESSAGE);
} else {
NotificationHelper.showNotification(String.format(I18nProperties.getString(Strings.messageContactsEditedExceptArchived), changedContacts), Type.HUMANIZED_MESSAGE, -1);
}
});
editView.addDiscardListener(() -> popupWindow.close());
}
use of de.symeda.sormas.api.contact.ContactFacade in project SORMAS-Project by hzi-braunschweig.
the class ContactFacadeEjbTest method testGetNonSourceCaseCountForDashboard.
@Test
public void testGetNonSourceCaseCountForDashboard() {
ContactFacade cut = getBean(ContactFacadeEjbLocal.class);
RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
PersonDto person = creator.createPerson("Case", "Person");
Disease disease = Disease.OTHER;
// 1. A case not resulted of a contact: 0
CaseDataDto caseWithoutContact = creator.createCase(user.toReference(), person.toReference(), disease, CaseClassification.CONFIRMED, InvestigationStatus.PENDING, new Date(), rdcf);
assertThat(cut.getNonSourceCaseCountForDashboard(Collections.singletonList(caseWithoutContact.getUuid())), equalTo(0));
// 2. Another case, but created from a contact: 1
ContactDto contact = creator.createContact(user.toReference(), person.toReference(), disease);
CaseDataDto caseWithContact = creator.createCase(user.toReference(), person.toReference(), disease, CaseClassification.CONFIRMED, InvestigationStatus.PENDING, new Date(), rdcf);
contact.setResultingCase(caseWithContact.toReference());
contact = getContactFacade().save(contact);
assertThat(cut.getNonSourceCaseCountForDashboard(Arrays.asList(caseWithoutContact.getUuid(), caseWithContact.getUuid())), equalTo(1));
// 3. Some more cases
{
CaseDataDto caseWithoutContact2 = creator.createCase(user.toReference(), person.toReference(), disease, CaseClassification.CONFIRMED, InvestigationStatus.PENDING, new Date(), rdcf);
ContactDto contact2 = creator.createContact(user.toReference(), person.toReference(), disease);
CaseDataDto caseWithContact2 = creator.createCase(user.toReference(), person.toReference(), disease, CaseClassification.CONFIRMED, InvestigationStatus.PENDING, new Date(), rdcf);
contact2.setResultingCase(caseWithContact2.toReference());
contact2 = getContactFacade().save(contact2);
ContactDto contact3 = creator.createContact(user.toReference(), person.toReference(), disease);
CaseDataDto caseWithContact3 = creator.createCase(user.toReference(), person.toReference(), disease, CaseClassification.CONFIRMED, InvestigationStatus.PENDING, new Date(), rdcf);
contact3.setResultingCase(caseWithContact3.toReference());
contact3 = getContactFacade().save(contact3);
assertThat(cut.getNonSourceCaseCountForDashboard(Arrays.asList(caseWithoutContact.getUuid(), caseWithContact.getUuid(), caseWithoutContact2.getUuid(), caseWithContact2.getUuid(), caseWithContact3.getUuid())), equalTo(3));
}
}
use of de.symeda.sormas.api.contact.ContactFacade in project SORMAS-Project by hzi-braunschweig.
the class ContactFacadeEjbTest method testGetNonSourceCaseCountForDashboardVariousInClauseCount.
@Test
public void testGetNonSourceCaseCountForDashboardVariousInClauseCount() {
ContactFacade cut = getBean(ContactFacadeEjbLocal.class);
// 0. Works for 0 cases
assertThat(cut.getNonSourceCaseCountForDashboard(Collections.emptyList()), equalTo(0));
assertThat(cut.getNonSourceCaseCountForDashboard(null), equalTo(0));
// 1a. Works for 1 case
assertThat(cut.getNonSourceCaseCountForDashboard(Collections.singletonList(DataHelper.createUuid())), equalTo(0));
// 1b. Works for 2 cases
assertThat(cut.getNonSourceCaseCountForDashboard(Arrays.asList(DataHelper.createUuid(), DataHelper.createUuid())), equalTo(0));
// 1c. Works for 3 cases
assertThat(cut.getNonSourceCaseCountForDashboard(Arrays.asList(DataHelper.createUuid(), DataHelper.createUuid(), DataHelper.createUuid())), equalTo(0));
// 2a. Works for 1_000 cases
assertThat(cut.getNonSourceCaseCountForDashboard(TestDataCreator.createValuesList(1_000, i -> DataHelper.createUuid())), equalTo(0));
// 2b. Works for 100_000 cases
assertThat(cut.getNonSourceCaseCountForDashboard(TestDataCreator.createValuesList(100_000, i -> DataHelper.createUuid())), equalTo(0));
}
Aggregations