use of de.symeda.sormas.backend.event.EventParticipantFacadeEjb.EventParticipantFacadeEjbLocal in project SORMAS-Project by hzi-braunschweig.
the class EventParticipantImporterTest method testImportEventParticipantSimilarityPick.
@Test
public void testImportEventParticipantSimilarityPick() throws IOException, InvalidColumnException, InterruptedException, CsvValidationException, URISyntaxException {
EventParticipantFacadeEjbLocal eventParticipantFacade = getBean(EventParticipantFacadeEjbLocal.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);
EventDto event = creator.createEvent(EventStatus.SIGNAL, "Title", "Description", "First", "Name", "12345", TypeOfPlace.PUBLIC_PLACE, DateHelper.subtractDays(new Date(), 2), new Date(), user.toReference(), user.toReference(), Disease.EVD);
EventReferenceDto eventRef = event.toReference();
PersonDto person = creator.createPerson("Günther", "Heinz");
creator.createCase(user.toReference(), person.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
// Person Similarity: pick
List<SimilarPersonDto> persons = FacadeProvider.getPersonFacade().getSimilarPersonDtos(new PersonSimilarityCriteria());
File csvFile = new File(getClass().getClassLoader().getResource("sormas_eventparticipant_import_test_similarities.csv").toURI());
EventParticipantImporterExtension eventParticipantImporter = new EventParticipantImporterExtension(csvFile, user, event) {
@Override
protected <T extends PersonImportSimilarityResult> void handlePersonSimilarity(PersonDto newPerson, Consumer<T> resultConsumer, BiFunction<SimilarPersonDto, ImportSimilarityResultOption, T> createSimilarityResult, String infoText, UI currentUI) {
List<SimilarPersonDto> entries = new ArrayList<>();
for (SimilarPersonDto person : persons) {
if (PersonHelper.areNamesSimilar(newPerson.getFirstName(), newPerson.getLastName(), person.getFirstName(), person.getLastName(), null)) {
entries.add(person);
}
}
resultConsumer.accept((T) new PersonImportSimilarityResult(entries.get(0), ImportSimilarityResultOption.PICK));
}
};
ImportResultStatus importResult = eventParticipantImporter.runImport();
EventParticipantIndexDto importedEventParticipant = eventParticipantFacade.getIndexList(new EventParticipantCriteria().withEvent(eventRef), null, null, null).get(0);
PersonDto importedPerson = getPersonFacade().getPersonByUuid(importedEventParticipant.getPersonUuid());
assertEquals(ImportResultStatus.COMPLETED, importResult);
assertEquals(1, eventParticipantFacade.count(new EventParticipantCriteria().withEvent(eventRef)));
assertEquals(person.getUuid(), importedEventParticipant.getPersonUuid());
assertEquals(person.getFirstName(), importedPerson.getFirstName());
assertEquals(person.getLastName(), importedPerson.getLastName());
assertEquals(1, getPersonFacade().getAllUuids().size());
}
use of de.symeda.sormas.backend.event.EventParticipantFacadeEjb.EventParticipantFacadeEjbLocal in project SORMAS-Project by hzi-braunschweig.
the class EventParticipantImporterTest method testImportEventParticipantSimilarityCreate.
@Test
public void testImportEventParticipantSimilarityCreate() throws IOException, InvalidColumnException, InterruptedException, CsvValidationException, URISyntaxException {
EventParticipantFacadeEjbLocal eventParticipantFacade = getBean(EventParticipantFacadeEjbLocal.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);
EventDto event = creator.createEvent(EventStatus.SIGNAL, "Title", "Description", "First", "Name", "12345", TypeOfPlace.PUBLIC_PLACE, DateHelper.subtractDays(new Date(), 2), new Date(), user.toReference(), user.toReference(), Disease.EVD);
EventReferenceDto eventRef = event.toReference();
PersonDto person = creator.createPerson("Günther", "Heinze");
creator.createCase(user.toReference(), person.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
// Person Similarity: create
File csvFile = new File(getClass().getClassLoader().getResource("sormas_eventparticipant_import_test_similarities.csv").toURI());
EventParticipantImporterExtension eventParticipantImporter = new EventParticipantImporterExtension(csvFile, user, event);
ImportResultStatus importResult = eventParticipantImporter.runImport();
EventParticipantIndexDto importedEventParticipant = eventParticipantFacade.getIndexList(new EventParticipantCriteria().withEvent(eventRef), null, null, null).get(0);
assertEquals(ImportResultStatus.COMPLETED, importResult);
assertEquals(1, eventParticipantFacade.count(new EventParticipantCriteria().withEvent(eventRef)));
assertNotEquals(person.getUuid(), importedEventParticipant.getPersonUuid());
assertEquals(2, getPersonFacade().getAllUuids().size());
}
use of de.symeda.sormas.backend.event.EventParticipantFacadeEjb.EventParticipantFacadeEjbLocal in project SORMAS-Project by hzi-braunschweig.
the class EventParticipantImporterTest method testImportEventParticipantDifferentAddressTypes.
@Test
public void testImportEventParticipantDifferentAddressTypes() throws IOException, InvalidColumnException, InterruptedException, CsvValidationException, URISyntaxException {
EventParticipantFacadeEjbLocal eventParticipantFacade = getBean(EventParticipantFacadeEjbLocal.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);
EventDto event = creator.createEvent(EventStatus.SIGNAL, "Title", "Description", "First", "Name", "12345", TypeOfPlace.PUBLIC_PLACE, DateHelper.subtractDays(new Date(), 2), new Date(), user.toReference(), user.toReference(), Disease.EVD);
EventReferenceDto eventRef = event.toReference();
// import of 3 event participants with different address types
File csvFile = new File(getClass().getClassLoader().getResource("sormas_eventparticipant_import_test_address_types.csv").toURI());
EventParticipantImporterExtension eventParticipantImporter = new EventParticipantImporterExtension(csvFile, user, event);
ImportResultStatus importResult = eventParticipantImporter.runImport();
List<EventParticipantDto> eventParticipants = getEventParticipantFacade().getByEventUuids(Collections.singletonList(eventRef.getUuid()));
assertEquals(3, eventParticipants.size());
boolean foundOtto = false;
boolean foundOskar = false;
boolean foundOona = false;
for (EventParticipantDto eventParticipant : eventParticipants) {
PersonDto person = eventParticipant.getPerson();
if ("Otto".equals(person.getFirstName())) {
foundOtto = true;
assertTrue(CollectionUtils.isEmpty(person.getAddresses()));
assertEquals("131", person.getAddress().getHouseNumber());
}
if ("Oskar".equals(person.getFirstName())) {
foundOskar = true;
assertTrue(CollectionUtils.isEmpty(person.getAddresses()));
assertEquals("132", person.getAddress().getHouseNumber());
}
if ("Oona".equals(person.getFirstName())) {
foundOona = true;
assertTrue(person.getAddress().checkIsEmptyLocation());
assertEquals(1, person.getAddresses().size());
assertEquals("133", person.getAddresses().get(0).getHouseNumber());
}
}
assertTrue("Not all eventparticipants found.", foundOtto && foundOskar && foundOona);
}
use of de.symeda.sormas.backend.event.EventParticipantFacadeEjb.EventParticipantFacadeEjbLocal in project SORMAS-Project by hzi-braunschweig.
the class EventParticipantImporterTest method testImportEventParticipantSimilarityPickEventParticipant.
@Test
public void testImportEventParticipantSimilarityPickEventParticipant() throws IOException, InvalidColumnException, InterruptedException, CsvValidationException, URISyntaxException {
EventParticipantFacadeEjbLocal eventParticipantFacade = getBean(EventParticipantFacadeEjbLocal.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);
EventDto event = creator.createEvent(EventStatus.SIGNAL, "Title", "Description", "First", "Name", "12345", TypeOfPlace.PUBLIC_PLACE, DateHelper.subtractDays(new Date(), 2), new Date(), user.toReference(), user.toReference(), Disease.EVD);
EventReferenceDto eventRef = event.toReference();
PersonDto person = creator.createPerson("Günther", "Heinz");
EventParticipantDto eventParticipant = creator.createEventParticipant(eventRef, person, "old desc", user.toReference());
// Person Similarity: pick event participant
List<SimilarPersonDto> persons = FacadeProvider.getPersonFacade().getSimilarPersonDtos(new PersonSimilarityCriteria());
File csvFile = new File(getClass().getClassLoader().getResource("sormas_eventparticipant_import_test_similarities.csv").toURI());
EventParticipantImporterExtension eventParticipantImporter = new EventParticipantImporterExtension(csvFile, user, event) {
@Override
protected <T extends PersonImportSimilarityResult> void handlePersonSimilarity(PersonDto newPerson, Consumer<T> resultConsumer, BiFunction<SimilarPersonDto, ImportSimilarityResultOption, T> createSimilarityResult, String infoText, UI currentUI) {
List<SimilarPersonDto> entries = new ArrayList<>();
for (SimilarPersonDto person : persons) {
if (PersonHelper.areNamesSimilar(newPerson.getFirstName(), newPerson.getLastName(), person.getFirstName(), person.getLastName(), null)) {
entries.add(person);
}
}
resultConsumer.accept((T) new PersonImportSimilarityResult(entries.get(0), ImportSimilarityResultOption.PICK));
}
};
ImportResultStatus importResult = eventParticipantImporter.runImport();
EventParticipantIndexDto importedEventParticipant = eventParticipantFacade.getIndexList(new EventParticipantCriteria().withEvent(eventRef), null, null, null).get(0);
assertEquals(ImportResultStatus.COMPLETED, importResult);
assertEquals(1, eventParticipantFacade.count(new EventParticipantCriteria().withEvent(eventRef)));
assertEquals(person.getUuid(), importedEventParticipant.getPersonUuid());
assertEquals(eventParticipant.getUuid(), importedEventParticipant.getUuid());
assertEquals("description 1", importedEventParticipant.getInvolvementDescription());
assertEquals(1, getPersonFacade().getAllUuids().size());
}
use of de.symeda.sormas.backend.event.EventParticipantFacadeEjb.EventParticipantFacadeEjbLocal in project SORMAS-Project by hzi-braunschweig.
the class EventParticipantImporterTest method testImportEventParticipantSimilaritySkip.
@Test
public void testImportEventParticipantSimilaritySkip() throws IOException, InvalidColumnException, InterruptedException, CsvValidationException, URISyntaxException {
EventParticipantFacadeEjbLocal eventParticipantFacade = getBean(EventParticipantFacadeEjbLocal.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);
EventDto event = creator.createEvent(EventStatus.SIGNAL, "Title", "Description", "First", "Name", "12345", TypeOfPlace.PUBLIC_PLACE, DateHelper.subtractDays(new Date(), 2), new Date(), user.toReference(), user.toReference(), Disease.EVD);
EventReferenceDto eventRef = event.toReference();
// Person Similarity: create
File csvFile = new File(getClass().getClassLoader().getResource("sormas_eventparticipant_import_test_similarities.csv").toURI());
EventParticipantImporterExtension eventParticipantImporter = new EventParticipantImporterExtension(csvFile, user, event) {
@Override
protected <T extends PersonImportSimilarityResult> void handlePersonSimilarity(PersonDto newPerson, Consumer<T> resultConsumer, BiFunction<SimilarPersonDto, ImportSimilarityResultOption, T> createSimilarityResult, String infoText, UI currentUI) {
resultConsumer.accept((T) new PersonImportSimilarityResult(null, ImportSimilarityResultOption.SKIP));
}
};
ImportResultStatus importResult = eventParticipantImporter.runImport();
assertEquals(ImportResultStatus.COMPLETED, importResult);
assertEquals(0, eventParticipantFacade.count(new EventParticipantCriteria().withEvent(eventRef)));
assertEquals(0, getPersonFacade().getAllUuids().size());
}
Aggregations