use of de.symeda.sormas.ui.person.PersonSelectionField in project SORMAS-Project by hzi-braunschweig.
the class EventImporter method handlePersonSimilarity.
/**
* Presents a popup window to the user that allows them to deal with detected potentially duplicate persons.
* By passing the desired result to the resultConsumer, the importer decided how to proceed with the import process.
*/
protected void handlePersonSimilarity(PersonDto newPerson, Consumer<PersonImportSimilarityResult> resultConsumer) {
currentUI.accessSynchronously(() -> {
PersonSelectionField personSelect = new PersonSelectionField(newPerson, I18nProperties.getString(Strings.infoSelectOrCreatePersonForImport));
personSelect.setWidth(1024, Unit.PIXELS);
if (personSelect.hasMatches()) {
final CommitDiscardWrapperComponent<PersonSelectionField> component = new CommitDiscardWrapperComponent<>(personSelect);
component.addCommitListener(() -> {
SimilarPersonDto person = personSelect.getValue();
if (person == null) {
resultConsumer.accept(new PersonImportSimilarityResult(null, ImportSimilarityResultOption.CREATE));
} else {
resultConsumer.accept(new PersonImportSimilarityResult(person, ImportSimilarityResultOption.PICK));
}
});
component.addDiscardListener(() -> resultConsumer.accept(new PersonImportSimilarityResult(null, ImportSimilarityResultOption.SKIP)));
personSelect.setSelectionChangeCallback((commitAllowed) -> component.getCommitButton().setEnabled(commitAllowed));
Window window = VaadinUiUtil.showModalPopupWindow(component, I18nProperties.getString(Strings.headingPickOrCreatePerson));
window.addCloseListener(event -> resultConsumer.accept(new PersonImportSimilarityResult(null, ImportSimilarityResultOption.SKIP)));
personSelect.selectBestMatch();
} else {
resultConsumer.accept(new PersonImportSimilarityResult(null, ImportSimilarityResultOption.CREATE));
}
});
}
use of de.symeda.sormas.ui.person.PersonSelectionField in project SORMAS-Project by hzi-braunschweig.
the class DataImporter method handlePersonSimilarity.
/**
* Presents a popup window to the user that allows them to deal with detected potentially duplicate persons.
* By passing the desired result to the resultConsumer, the importer decided how to proceed with the import process.
*/
protected <T extends PersonImportSimilarityResult> void handlePersonSimilarity(PersonDto newPerson, Consumer<T> resultConsumer, BiFunction<SimilarPersonDto, ImportSimilarityResultOption, T> createSimilarityResult, String infoText, UI currentUI) {
currentUI.accessSynchronously(() -> {
PersonSelectionField personSelect = new PersonSelectionField(newPerson, I18nProperties.getString(infoText));
personSelect.setWidth(1024, Unit.PIXELS);
if (personSelect.hasMatches()) {
final CommitDiscardWrapperComponent<PersonSelectionField> component = new CommitDiscardWrapperComponent<>(personSelect);
component.addCommitListener(() -> {
SimilarPersonDto person = personSelect.getValue();
if (person == null) {
resultConsumer.accept(createSimilarityResult.apply(null, ImportSimilarityResultOption.CREATE));
} else {
resultConsumer.accept(createSimilarityResult.apply(person, ImportSimilarityResultOption.PICK));
}
});
component.addDiscardListener(() -> resultConsumer.accept(createSimilarityResult.apply(null, ImportSimilarityResultOption.SKIP)));
personSelect.setSelectionChangeCallback((commitAllowed) -> {
component.getCommitButton().setEnabled(commitAllowed);
});
VaadinUiUtil.showModalPopupWindow(component, I18nProperties.getString(Strings.headingPickOrCreatePerson));
personSelect.selectBestMatch();
} else {
resultConsumer.accept(createSimilarityResult.apply(null, ImportSimilarityResultOption.CREATE));
}
});
}
Aggregations