Search in sources :

Example 11 with ContactIndexDto

use of de.symeda.sormas.api.contact.ContactIndexDto in project SORMAS-Project by hzi-braunschweig.

the class SourceContactList method reload.

@Override
public void reload() {
    List<ContactIndexDto> contacts = FacadeProvider.getContactFacade().getIndexList(criteria, 0, maxDisplayedEntries * 20, null);
    setEntries(contacts);
    if (!contacts.isEmpty()) {
        showPage(1);
    } else {
        updatePaginationLayout();
        listLayout.addComponent(new Label(I18nProperties.getCaption(Captions.epiDataNoSourceContacts)));
    }
}
Also used : Label(com.vaadin.ui.Label) ContactIndexDto(de.symeda.sormas.api.contact.ContactIndexDto)

Example 12 with ContactIndexDto

use of de.symeda.sormas.api.contact.ContactIndexDto in project SORMAS-Project by hzi-braunschweig.

the class ContactFacadeEjbPseudonymizationTest method testPseudonymizeIndexData.

@Test
public void testPseudonymizeIndexData() {
    CaseDataDto caze = createCase(user1, rdcf1);
    ContactDto contact1 = createContact(user2, caze, rdcf2);
    // contact of case on other jurisdiction --> should be pseudonymized
    ContactDto contact2 = creator.createContact(user1.toReference(), null, createPerson().toReference(), caze, new Date(), new Date(), Disease.CORONAVIRUS, rdcf2);
    ContactCriteria contactCriteria = new ContactCriteria();
    contactCriteria.setIncludeContactsFromOtherJurisdictions(true);
    List<ContactIndexDto> indexList = getContactFacade().getIndexList(contactCriteria, null, null, Collections.emptyList());
    ContactIndexDto index1 = indexList.stream().filter(c -> c.getUuid().equals(contact1.getUuid())).findFirst().get();
    assertThat(index1.getFirstName(), is("James"));
    assertThat(index1.getLastName(), is("Smith"));
    assertThat(index1.getCaze().getFirstName(), is("Confidential"));
    assertThat(index1.getCaze().getLastName(), is("Confidential"));
    ContactIndexDto index2 = indexList.stream().filter(c -> c.getUuid().equals(contact2.getUuid())).findFirst().get();
    assertThat(index2.getFirstName(), is("Confidential"));
    assertThat(index2.getLastName(), is("Confidential"));
    assertThat(index2.getCaze().getFirstName(), is("Confidential"));
    assertThat(index2.getCaze().getLastName(), is("Confidential"));
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) SimilarContactDto(de.symeda.sormas.api.contact.SimilarContactDto) ContactCriteria(de.symeda.sormas.api.contact.ContactCriteria) Date(java.util.Date) ContactIndexDto(de.symeda.sormas.api.contact.ContactIndexDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 13 with ContactIndexDto

use of de.symeda.sormas.api.contact.ContactIndexDto in project SORMAS-Project by hzi-braunschweig.

the class ContactFacadeEjbTest method testSearchContactsWithExtendedQuarantine.

@Test
public void testSearchContactsWithExtendedQuarantine() {
    RDCF rdcf = creator.createRDCF();
    ContactDto contact = creator.createContact(creator.createUser(rdcf, UserRole.SURVEILLANCE_OFFICER).toReference(), creator.createPerson().toReference());
    contact.setQuarantineExtended(true);
    getContactFacade().save(contact);
    List<ContactIndexDto> indexList = getContactFacade().getIndexList(new ContactCriteria(), 0, 100, Collections.emptyList());
    assertThat(indexList.get(0).getUuid(), is(contact.getUuid()));
    ContactCriteria contactCriteria = new ContactCriteria();
    contactCriteria.setWithExtendedQuarantine(true);
    List<ContactIndexDto> indexListFiltered = getContactFacade().getIndexList(contactCriteria, 0, 100, Collections.emptyList());
    assertThat(indexListFiltered.get(0).getUuid(), is(contact.getUuid()));
}
Also used : RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) SimilarContactDto(de.symeda.sormas.api.contact.SimilarContactDto) MapContactDto(de.symeda.sormas.api.contact.MapContactDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) ContactCriteria(de.symeda.sormas.api.contact.ContactCriteria) ContactIndexDto(de.symeda.sormas.api.contact.ContactIndexDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 14 with ContactIndexDto

use of de.symeda.sormas.api.contact.ContactIndexDto in project SORMAS-Project by hzi-braunschweig.

the class ContactFacadeEjbTest method testIncludeContactsFromOtherJurisdictionsFilter.

@Test
public void testIncludeContactsFromOtherJurisdictionsFilter() {
    RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility");
    RegionReferenceDto regionReferenceDto = getRegionFacade().getReferencesByName("Region", false).get(0);
    DistrictReferenceDto districtReferenceDto = getDistrictFacade().getByName("District", regionReferenceDto, false).get(0);
    RDCFEntities rdcf2 = creator.createRDCFEntities("NewRegion", "NewDistrict", "Community2", "Facility2");
    RegionReferenceDto region2ReferenceDto = getRegionFacade().getReferencesByName("NewRegion", false).get(0);
    DistrictReferenceDto district2ReferenceDto = getDistrictFacade().getByName("NewDistrict", region2ReferenceDto, false).get(0);
    // "mainUser" is the user which executes the grid query
    UserDto mainUser = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
    loginWith(mainUser);
    PersonDto cazePerson = creator.createPerson("Case", "Person");
    CaseDataDto caze = creator.createCase(mainUser.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
    // 1) contact created by main user, jurisdiction same with main user, no case linked
    PersonDto contactPersonSameJurisdictionMainUserCreatorNoCase = creator.createPerson("contactSameJurisdictionMainUserCreatorNoCase", "Person1");
    ContactDto contactSameJurisdictionMainUserCreatorNoCase = creator.createContact(mainUser.toReference(), mainUser.toReference(), contactPersonSameJurisdictionMainUserCreatorNoCase.toReference(), null, new Date(), new Date(), null);
    updateContactJurisdictionAndCase(contactSameJurisdictionMainUserCreatorNoCase.getUuid(), regionReferenceDto, districtReferenceDto, null);
    // 2) contact created by main user, jurisdiction different from main user, no case linked
    PersonDto contactPersonDiffJurisMainUserCreatorNoCase = creator.createPerson("contactDiffJurisdictionMainUserCreatorNoCase", "Person2");
    ContactDto contactDiffJurisdictionMainUserCreatorNoCase = creator.createContact(mainUser.toReference(), mainUser.toReference(), contactPersonDiffJurisMainUserCreatorNoCase.toReference(), null, new Date(), new Date(), null);
    updateContactJurisdictionAndCase(contactDiffJurisdictionMainUserCreatorNoCase.getUuid(), region2ReferenceDto, district2ReferenceDto, null);
    // 3) contact created by main user, jurisdiction null, linked to case from main user's jurisdiction
    PersonDto contactPersonJurisdictionNullMainUserCreatorCaseSameJurisdiction = creator.createPerson("contactJurisdictionNullMainUserCreatorCaseSameJurisdiction", "Person3");
    ContactDto contactJurisdictionNullMainUserCreatorCaseSameJurisdiction = creator.createContact(mainUser.toReference(), mainUser.toReference(), contactPersonJurisdictionNullMainUserCreatorCaseSameJurisdiction.toReference(), caze, new Date(), new Date(), null);
    updateContactJurisdictionAndCase(contactJurisdictionNullMainUserCreatorCaseSameJurisdiction.getUuid(), null, null, new CaseReferenceDto(caze.getUuid()));
    UserDto user2 = creator.createUser(rdcf2.region.getUuid(), rdcf2.district.getUuid(), rdcf2.facility.getUuid(), "Surv2", "Sup2", UserRole.SURVEILLANCE_SUPERVISOR);
    loginWith(user2);
    // 4) contact created by different user, jurisdiction same with main user, no case linked
    PersonDto contactPersonSameJurisdictionDiffUserNoCase = creator.createPerson("contactSameJurisdictionDiffUserNoCase", "Person4");
    ContactDto contactSameJurisdictionDiffUserNoCase = creator.createContact(user2.toReference(), user2.toReference(), contactPersonSameJurisdictionDiffUserNoCase.toReference(), null, new Date(), new Date(), null, null, c -> {
        c.setRegion(regionReferenceDto);
        c.setDistrict(districtReferenceDto);
    });
    // 5) contact created by different user, jurisdiction different from main user, no case linked
    PersonDto contactPersonDiffJurisdictionDiffUserNoCase = creator.createPerson("contactDiffJurisdictionDiffUserNoCase", "Person5");
    ContactDto contactDiffJurisdictionDiffUserNoCase = creator.createContact(user2.toReference(), user2.toReference(), contactPersonDiffJurisdictionDiffUserNoCase.toReference(), null, new Date(), new Date(), null);
    // 6) contact created by different user, jurisdiction null, linked to case from main user's jurisdiction
    PersonDto contactPersonDiffJurisdictionDiffUserCaseSameJurisdiction = creator.createPerson("contactDiffJurisdictionDiffUserCaseSameJurisdiction", "Person6");
    ContactDto contactDiffJurisdictionDiffUserCaseSameJurisdiction = creator.createContact(user2.toReference(), user2.toReference(), contactPersonDiffJurisdictionDiffUserCaseSameJurisdiction.toReference(), null, new Date(), new Date(), null, null, c -> {
        c.setCaze(new CaseReferenceDto(caze.getUuid()));
    });
    // includeContactsFromOtherJurisdictionsFilter = false - return 1, 3, 4, 6
    // includeContactsFromOtherJurisdictionsFilter = true - return 1, 2, 3, 4, 6
    loginWith(mainUser);
    ContactCriteria gridContactCriteria = new ContactCriteria();
    List<ContactIndexDto> contactList = getContactFacade().getIndexList(gridContactCriteria, 0, 100, null);
    List<String> contactListUuids = new ArrayList<>();
    contactList.stream().forEach(contactIndexDto -> contactListUuids.add(contactIndexDto.getUuid()));
    assertEquals(4, getContactFacade().getIndexList(gridContactCriteria, 0, 100, null).size());
    assertFalse(contactListUuids.contains(contactDiffJurisdictionMainUserCreatorNoCase.getUuid()));
    assertFalse(contactListUuids.contains(contactDiffJurisdictionDiffUserNoCase.getUuid()));
    gridContactCriteria.setIncludeContactsFromOtherJurisdictions(true);
    contactListUuids.clear();
    List<ContactIndexDto> newContactList = getContactFacade().getIndexList(gridContactCriteria, 0, 100, null);
    newContactList.stream().forEach(contactIndexDto -> contactListUuids.add(contactIndexDto.getUuid()));
    assertEquals(5, getContactFacade().getIndexList(gridContactCriteria, 0, 100, null).size());
    assertFalse(contactListUuids.contains(contactDiffJurisdictionDiffUserNoCase.getUuid()));
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) ArrayList(java.util.ArrayList) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) Date(java.util.Date) LocalDate(java.time.LocalDate) ContactIndexDto(de.symeda.sormas.api.contact.ContactIndexDto) RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) SimilarContactDto(de.symeda.sormas.api.contact.SimilarContactDto) MapContactDto(de.symeda.sormas.api.contact.MapContactDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) ContactCriteria(de.symeda.sormas.api.contact.ContactCriteria) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 15 with ContactIndexDto

use of de.symeda.sormas.api.contact.ContactIndexDto in project SORMAS-Project by hzi-braunschweig.

the class ContactFacadeEjbTest method testSearchContactsWithReducedQuarantine.

@Test
public void testSearchContactsWithReducedQuarantine() {
    RDCF rdcf = creator.createRDCF();
    ContactDto contact = creator.createContact(creator.createUser(rdcf, UserRole.SURVEILLANCE_OFFICER).toReference(), creator.createPerson().toReference());
    contact.setQuarantineReduced(true);
    getContactFacade().save(contact);
    List<ContactIndexDto> indexList = getContactFacade().getIndexList(new ContactCriteria(), 0, 100, Collections.emptyList());
    assertThat(indexList.get(0).getUuid(), is(contact.getUuid()));
    ContactCriteria contactCriteria = new ContactCriteria();
    contactCriteria.setWithReducedQuarantine(true);
    List<ContactIndexDto> indexListFiltered = getContactFacade().getIndexList(contactCriteria, 0, 100, Collections.emptyList());
    assertThat(indexListFiltered.get(0).getUuid(), is(contact.getUuid()));
}
Also used : RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) SimilarContactDto(de.symeda.sormas.api.contact.SimilarContactDto) MapContactDto(de.symeda.sormas.api.contact.MapContactDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) ContactCriteria(de.symeda.sormas.api.contact.ContactCriteria) ContactIndexDto(de.symeda.sormas.api.contact.ContactIndexDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Aggregations

ContactIndexDto (de.symeda.sormas.api.contact.ContactIndexDto)16 Label (com.vaadin.ui.Label)8 ContactCriteria (de.symeda.sormas.api.contact.ContactCriteria)8 ContactDto (de.symeda.sormas.api.contact.ContactDto)6 SimilarContactDto (de.symeda.sormas.api.contact.SimilarContactDto)6 Notification (com.vaadin.ui.Notification)5 Test (org.junit.Test)5 FacadeProvider (de.symeda.sormas.api.FacadeProvider)4 Captions (de.symeda.sormas.api.i18n.Captions)4 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)4 UserRight (de.symeda.sormas.api.user.UserRight)4 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)4 ControllerProvider (de.symeda.sormas.ui.ControllerProvider)4 UserProvider (de.symeda.sormas.ui.UserProvider)4 Date (java.util.Date)4 List (java.util.List)4 MapContactDto (de.symeda.sormas.api.contact.MapContactDto)3 Collectors (java.util.stream.Collectors)3 ClickListener (com.vaadin.ui.Button.ClickListener)2 Window (com.vaadin.ui.Window)2