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)));
}
}
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"));
}
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()));
}
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()));
}
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()));
}
Aggregations