Search in sources :

Example 1 with PseudonymizableDto

use of de.symeda.sormas.api.utils.pseudonymization.PseudonymizableDto in project SORMAS-Project by hzi-braunschweig.

the class PreviewGridHelper method createPersonColumns.

public static <T> List<String> createPersonColumns(Grid<T> grid, Function<T, SormasToSormasPersonPreview> getPerson) {
    ((Grid.Column<PseudonymizableDto, ?>) grid.addComponentColumn(previewData -> {
        SormasToSormasPersonPreview person = getPerson.apply(previewData);
        if (person.isPseudonymized()) {
            return new Label(I18nProperties.getCaption(Captions.inaccessibleValue));
        }
        return new Label(person.getFirstName() + " " + person.getLastName());
    })).setId(PERSON_NAME).setStyleGenerator(item -> {
        if (item.isPseudonymized()) {
            return CssStyles.INACCESSIBLE_COLUMN;
        }
        return "";
    });
    grid.addComponentColumn(previewData -> new Label(DateFormatHelper.formatDate(getPerson.apply(previewData).getBirthdateDD(), getPerson.apply(previewData).getBirthdateMM(), getPerson.apply(previewData).getBirthdateYYYY()))).setId(BIRTH_DATE);
    grid.addComponentColumn(previewData -> new Label(getPerson.apply(previewData).getSex().toString())).setId(SormasToSormasPersonPreview.SEX);
    grid.addComponentColumn(previewData -> new Label(LocationHelper.buildLocationString(getPerson.apply(previewData).getAddress()))).setId(SormasToSormasPersonPreview.ADDRESS);
    return Arrays.asList(PERSON_NAME, BIRTH_DATE, SormasToSormasPersonPreview.SEX, SormasToSormasPersonPreview.ADDRESS);
}
Also used : Arrays(java.util.Arrays) List(java.util.List) CssStyles(de.symeda.sormas.ui.utils.CssStyles) SormasToSormasPersonPreview(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasPersonPreview) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) Label(com.vaadin.ui.Label) DateFormatHelper(de.symeda.sormas.api.utils.DateFormatHelper) LocationHelper(de.symeda.sormas.api.utils.LocationHelper) PseudonymizableDto(de.symeda.sormas.api.utils.pseudonymization.PseudonymizableDto) Function(java.util.function.Function) Captions(de.symeda.sormas.api.i18n.Captions) Grid(com.vaadin.ui.Grid) Grid(com.vaadin.ui.Grid) PseudonymizableDto(de.symeda.sormas.api.utils.pseudonymization.PseudonymizableDto) Label(com.vaadin.ui.Label) SormasToSormasPersonPreview(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasPersonPreview)

Aggregations

Grid (com.vaadin.ui.Grid)1 Label (com.vaadin.ui.Label)1 Captions (de.symeda.sormas.api.i18n.Captions)1 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)1 SormasToSormasPersonPreview (de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasPersonPreview)1 DateFormatHelper (de.symeda.sormas.api.utils.DateFormatHelper)1 LocationHelper (de.symeda.sormas.api.utils.LocationHelper)1 PseudonymizableDto (de.symeda.sormas.api.utils.pseudonymization.PseudonymizableDto)1 CssStyles (de.symeda.sormas.ui.utils.CssStyles)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Function (java.util.function.Function)1