Search in sources :

Example 6 with DateRenderer

use of com.vaadin.ui.renderers.DateRenderer in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationGrid method initColumns.

private void initColumns() {
    setColumns(ImmunizationIndexDto.UUID, ImmunizationIndexDto.PERSON_UUID, ImmunizationIndexDto.PERSON_FIRST_NAME, ImmunizationIndexDto.PERSON_LAST_NAME, ImmunizationIndexDto.DISEASE, ImmunizationIndexDto.AGE_AND_BIRTH_DATE, ImmunizationIndexDto.SEX, ImmunizationIndexDto.DISTRICT, ImmunizationIndexDto.MEANS_OF_IMMUNIZATION, ImmunizationIndexDto.MANAGEMENT_STATUS, ImmunizationIndexDto.IMMUNIZATION_STATUS, ImmunizationIndexDto.START_DATE, ImmunizationIndexDto.END_DATE, ImmunizationIndexDto.LAST_VACCINE_TYPE, ImmunizationIndexDto.RECOVERY_DATE);
    ((Column<ImmunizationIndexDto, String>) getColumn(ImmunizationIndexDto.UUID)).setRenderer(new UuidRenderer());
    ((Column<ImmunizationIndexDto, String>) getColumn(ImmunizationIndexDto.PERSON_UUID)).setRenderer(new UuidRenderer());
    ((Column<ImmunizationIndexDto, AgeAndBirthDateDto>) getColumn(ImmunizationIndexDto.AGE_AND_BIRTH_DATE)).setRenderer(value -> value == null ? "" : PersonHelper.getAgeAndBirthdateString(value.getAge(), value.getAgeType(), value.getDateOfBirthDD(), value.getDateOfBirthMM(), value.getDateOfBirthYYYY()), new TextRenderer());
    ((Column<ImmunizationIndexDto, Date>) getColumn(ImmunizationIndexDto.START_DATE)).setRenderer(new DateRenderer(DateFormatHelper.getDateFormat()));
    ((Column<ImmunizationIndexDto, Date>) getColumn(ImmunizationIndexDto.END_DATE)).setRenderer(new DateRenderer(DateFormatHelper.getDateFormat()));
    ((Column<ImmunizationIndexDto, Date>) getColumn(ImmunizationIndexDto.RECOVERY_DATE)).setRenderer(new DateRenderer(DateFormatHelper.getDateFormat()));
    for (Column<ImmunizationIndexDto, ?> column : getColumns()) {
        column.setCaption(I18nProperties.findPrefixCaptionWithDefault(column.getId(), column.getCaption(), ImmunizationIndexDto.I18N_PREFIX, PersonDto.I18N_PREFIX));
        column.setStyleGenerator(FieldAccessColumnStyleGenerator.getDefault(getBeanType(), column.getId()));
    }
}
Also used : ImmunizationIndexDto(de.symeda.sormas.api.immunization.ImmunizationIndexDto) UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) DateRenderer(com.vaadin.ui.renderers.DateRenderer) TextRenderer(com.vaadin.ui.renderers.TextRenderer)

Example 7 with DateRenderer

use of com.vaadin.ui.renderers.DateRenderer in project SORMAS-Project by hzi-braunschweig.

the class AbstractCaseGrid method initColumns.

@SuppressWarnings("unchecked")
protected void initColumns() {
    Column<IndexDto, String> diseaseShortColumn = addColumn(caze -> DiseaseHelper.toString(caze.getDisease(), caze.getDiseaseDetails()));
    diseaseShortColumn.setId(DISEASE_SHORT);
    diseaseShortColumn.setSortProperty(CaseIndexDto.DISEASE);
    Column<IndexDto, String> visitsColumn = addColumn(entry -> {
        if (FacadeProvider.getDiseaseConfigurationFacade().hasFollowUp(entry.getDisease())) {
            int numberOfVisits = entry.getVisitCount();
            int numberOfRequiredVisits = FollowUpLogic.getNumberOfRequiredVisitsSoFar(entry.getReportDate(), entry.getFollowUpUntil());
            int numberOfMissedVisits = numberOfRequiredVisits - numberOfVisits;
            // Set number of missed visits to 0 when more visits than expected have been done
            if (numberOfMissedVisits < 0) {
                numberOfMissedVisits = 0;
            }
            return String.format(I18nProperties.getCaption(Captions.formatNumberOfVisitsFormat), numberOfVisits, numberOfMissedVisits);
        } else {
            return "-";
        }
    });
    visitsColumn.setId(NUMBER_OF_VISITS);
    visitsColumn.setSortable(false);
    addComponentColumn(indexDto -> {
        Label label = new Label(indexDto.getCompleteness() != null ? new DecimalFormat("#").format(indexDto.getCompleteness() * 100) + " %" : "-");
        if (indexDto.getCompleteness() != null) {
            if (indexDto.getCompleteness() < 0.25f) {
                CssStyles.style(label, CssStyles.LABEL_CRITICAL);
            } else if (indexDto.getCompleteness() < 0.5f) {
                CssStyles.style(label, CssStyles.LABEL_IMPORTANT);
            } else if (indexDto.getCompleteness() < 0.75f) {
                CssStyles.style(label, CssStyles.LABEL_RELEVANT);
            } else {
                CssStyles.style(label, CssStyles.LABEL_POSITIVE);
            }
        }
        return label;
    }).setId(COLUMN_COMPLETENESS);
    setColumns(getGridColumns().toArray(String[]::new));
    if (FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_GERMANY) || FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_SWITZERLAND)) {
        getColumn(CaseIndexDto.EPID_NUMBER).setHidden(true);
    } else {
        getColumn(CaseIndexDto.EXTERNAL_ID).setHidden(true);
        getColumn(CaseIndexDto.EXTERNAL_TOKEN).setHidden(true);
    }
    getColumn(COLUMN_COMPLETENESS).setCaption(I18nProperties.getPrefixCaption(CaseIndexDto.I18N_PREFIX, CaseIndexDto.COMPLETENESS));
    getColumn(COLUMN_COMPLETENESS).setSortable(false);
    Language userLanguage = I18nProperties.getUserLanguage();
    ((Column<CaseIndexDto, String>) getColumn(CaseIndexDto.UUID)).setRenderer(new UuidRenderer());
    ((Column<CaseIndexDto, String>) getColumn(CaseIndexDto.PERSON_UUID)).setRenderer(new UuidRenderer());
    ((Column<CaseIndexDto, Date>) getColumn(CaseIndexDto.REPORT_DATE)).setRenderer(new DateRenderer(DateHelper.getLocalDateTimeFormat(userLanguage)));
    if (externalSurveillanceToolShareEnabled) {
        Column<CaseIndexDto, Date> shareDateColumn = ((Column<CaseIndexDto, Date>) getColumn(CaseIndexDto.SURVEILLANCE_TOOL_LAST_SHARE_DATE));
        shareDateColumn.setSortable(false);
        shareDateColumn.setRenderer(new DateRenderer(DateHelper.getLocalDateTimeFormat(userLanguage)));
        getColumn(CaseIndexDto.SURVEILLANCE_TOOL_SHARE_COUNT).setSortable(false);
        getColumn(CaseIndexDto.SURVEILLANCE_TOOL_STATUS).setSortable(false);
        getColumn(CaseIndexDto.SURVEILLANCE_TOOL_LAST_SHARE_DATE).setSortable(false);
    }
    ((Column<CaseIndexDto, Date>) getColumn(CaseIndexDto.QUARANTINE_TO)).setRenderer(new DateRenderer(DateHelper.getLocalDateTimeFormat(userLanguage)));
    if (caseFollowUpEnabled) {
        ((Column<CaseIndexDto, Date>) getColumn(CaseIndexDto.FOLLOW_UP_UNTIL)).setRenderer(new DateRenderer(DateHelper.getLocalDateFormat(userLanguage)));
    }
    if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_IMPORT)) {
        ((Column<CaseIndexDto, Date>) getColumn(CaseIndexDto.CREATION_DATE)).setRenderer(new DateRenderer(DateHelper.getLocalDateTimeFormat(userLanguage)));
    } else {
        removeColumn(CaseIndexDto.CREATION_DATE);
    }
    for (Column<IndexDto, ?> column : getColumns()) {
        column.setCaption(I18nProperties.findPrefixCaptionWithDefault(column.getId(), column.getCaption(), CaseIndexDto.I18N_PREFIX, PersonDto.I18N_PREFIX, LocationDto.I18N_PREFIX));
        column.setStyleGenerator(FieldAccessColumnStyleGenerator.getDefault(getBeanType(), column.getId()));
    }
}
Also used : FollowUpStatus(de.symeda.sormas.api.contact.FollowUpStatus) FeatureType(de.symeda.sormas.api.feature.FeatureType) DataProviderListener(com.vaadin.data.provider.DataProviderListener) UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) Date(java.util.Date) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) DateHelper(de.symeda.sormas.api.utils.DateHelper) SortDirection(com.vaadin.shared.data.sort.SortDirection) Function(java.util.function.Function) PersonDto(de.symeda.sormas.api.person.PersonDto) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) ViewConfiguration(de.symeda.sormas.ui.utils.ViewConfiguration) ViewModelProviders(de.symeda.sormas.ui.ViewModelProviders) CssStyles(de.symeda.sormas.ui.utils.CssStyles) ContactIndexDto(de.symeda.sormas.api.contact.ContactIndexDto) FieldAccessColumnStyleGenerator(de.symeda.sormas.ui.utils.FieldAccessColumnStyleGenerator) Label(com.vaadin.ui.Label) CountryHelper(de.symeda.sormas.api.CountryHelper) UserRole(de.symeda.sormas.api.user.UserRole) DataProvider(com.vaadin.data.provider.DataProvider) UserProvider(de.symeda.sormas.ui.UserProvider) DateRenderer(com.vaadin.ui.renderers.DateRenderer) LocationDto(de.symeda.sormas.api.location.LocationDto) ListDataProvider(com.vaadin.data.provider.ListDataProvider) FilteredGrid(de.symeda.sormas.ui.utils.FilteredGrid) DiseaseHelper(de.symeda.sormas.api.DiseaseHelper) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) DecimalFormat(java.text.DecimalFormat) CaseOrigin(de.symeda.sormas.api.caze.CaseOrigin) SortProperty(de.symeda.sormas.api.utils.SortProperty) Collectors(java.util.stream.Collectors) Language(de.symeda.sormas.api.Language) Captions(de.symeda.sormas.api.i18n.Captions) CaseIndexDto(de.symeda.sormas.api.caze.CaseIndexDto) UserRight(de.symeda.sormas.api.user.UserRight) ShowDetailsListener(de.symeda.sormas.ui.utils.ShowDetailsListener) List(java.util.List) Stream(java.util.stream.Stream) FollowUpLogic(de.symeda.sormas.api.followup.FollowUpLogic) ContactIndexDto(de.symeda.sormas.api.contact.ContactIndexDto) CaseIndexDto(de.symeda.sormas.api.caze.CaseIndexDto) UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) DecimalFormat(java.text.DecimalFormat) Label(com.vaadin.ui.Label) DateRenderer(com.vaadin.ui.renderers.DateRenderer) Date(java.util.Date) CaseIndexDto(de.symeda.sormas.api.caze.CaseIndexDto) Language(de.symeda.sormas.api.Language)

Example 8 with DateRenderer

use of com.vaadin.ui.renderers.DateRenderer in project SORMAS-Project by hzi-braunschweig.

the class CaseGridDetailed method initColumns.

@SuppressWarnings("unchecked")
@Override
protected void initColumns() {
    addColumn(caze -> {
        if (caze.getLatestSampleDateTime() != null) {
            return DateFormatHelper.formatLocalDateTime(caze.getLatestSampleDateTime()) + " [" + caze.getSampleCount() + "]";
        } else {
            return null;
        }
    }).setCaption(I18nProperties.getPrefixCaption(CaseIndexDetailedDto.I18N_PREFIX, CaseIndexDetailedDto.LATEST_SAMPLE_DATE_TIME)).setId(LATEST_SAMPLE_DATE_TIME_AND_SAMPLE_COUNT).setSortable(false).setWidth(150);
    super.initColumns();
    if (!FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_GERMANY)) {
        getColumn(CaseIndexDetailedDto.RE_INFECTION).setHidden(true);
    }
    getColumn(CaseIndexDetailedDto.SEX).setWidth(80);
    getColumn(CaseIndexDetailedDto.AGE_AND_BIRTH_DATE).setWidth(100);
    getColumn(CaseIndexDetailedDto.POSTAL_CODE).setWidth(100);
    getColumn(CaseIndexDetailedDto.CITY).setWidth(150);
    getColumn(CaseIndexDetailedDto.STREET).setWidth(150);
    getColumn(CaseIndexDetailedDto.HOUSE_NUMBER).setWidth(50);
    getColumn(CaseIndexDetailedDto.ADDITIONAL_INFORMATION).setWidth(200);
    getColumn(CaseIndexDetailedDto.PHONE).setWidth(100);
    getColumn(CaseIndexDetailedDto.EVENT_COUNT).setWidth(80).setSortable(false);
    getColumn(CaseIndexDetailedDto.LATEST_EVENT_ID).setWidth(80).setSortable(false);
    getColumn(CaseIndexDetailedDto.LATEST_EVENT_STATUS).setWidth(80).setSortable(false);
    getColumn(CaseIndexDetailedDto.LATEST_EVENT_TITLE).setWidth(150).setSortable(false);
    ((Column<CaseIndexDetailedDto, String>) getColumn(CaseIndexDetailedDto.LATEST_EVENT_ID)).setRenderer(new UuidRenderer());
    addItemClickListener(new ShowDetailsListener<>(CaseIndexDetailedDto.LATEST_EVENT_ID, c -> ControllerProvider.getEventController().navigateToData(c.getLatestEventId())));
    ((Column<CaseIndexDetailedDto, AgeAndBirthDateDto>) getColumn(CaseIndexDetailedDto.AGE_AND_BIRTH_DATE)).setRenderer(value -> value == null ? "" : PersonHelper.getAgeAndBirthdateString(value.getAge(), value.getAgeType(), value.getDateOfBirthDD(), value.getDateOfBirthMM(), value.getDateOfBirthYYYY()), new TextRenderer());
    ((Column<CaseIndexDetailedDto, Date>) getColumn(CaseIndexDetailedDto.SYMPTOM_ONSET_DATE)).setRenderer(new DateRenderer(DateFormatHelper.getDateFormat())).setCaption(I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, SymptomsDto.ONSET_DATE)).setWidth(80);
}
Also used : TextRenderer(com.vaadin.ui.renderers.TextRenderer) UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) Date(java.util.Date) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) DateFormatHelper(de.symeda.sormas.ui.utils.DateFormatHelper) PersonHelper(de.symeda.sormas.api.person.PersonHelper) AgeAndBirthDateDto(de.symeda.sormas.api.caze.AgeAndBirthDateDto) CaseIndexDetailedDto(de.symeda.sormas.api.caze.CaseIndexDetailedDto) SortProperty(de.symeda.sormas.api.utils.SortProperty) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) CaseIndexDto(de.symeda.sormas.api.caze.CaseIndexDto) ShowDetailsListener(de.symeda.sormas.ui.utils.ShowDetailsListener) List(java.util.List) Stream(java.util.stream.Stream) CountryHelper(de.symeda.sormas.api.CountryHelper) SymptomsDto(de.symeda.sormas.api.symptoms.SymptomsDto) DateRenderer(com.vaadin.ui.renderers.DateRenderer) UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) DateRenderer(com.vaadin.ui.renderers.DateRenderer) TextRenderer(com.vaadin.ui.renderers.TextRenderer)

Example 9 with DateRenderer

use of com.vaadin.ui.renderers.DateRenderer in project SORMAS-Project by hzi-braunschweig.

the class MergeCasesGrid method buildColumns.

@Override
protected void buildColumns() {
    Column<CaseIndexDto, String> diseaseColumn = addColumn(caze -> DiseaseHelper.toString(caze.getDisease(), caze.getDiseaseDetails()));
    diseaseColumn.setId(COLUMN_DISEASE);
    setColumns(COLUMN_UUID, COLUMN_DISEASE, CaseIndexDto.CASE_CLASSIFICATION, CaseIndexDto.PERSON_FIRST_NAME, CaseIndexDto.PERSON_LAST_NAME, CaseIndexDto.AGE_AND_BIRTH_DATE, CaseIndexDto.SEX, CaseIndexDto.RESPONSIBLE_DISTRICT_NAME, CaseIndexDto.HEALTH_FACILITY_NAME, CaseIndexDto.REPORT_DATE, CaseIndexDto.CREATION_DATE, COLUMN_COMPLETENESS, COLUMN_ACTIONS);
    getColumn(COLUMN_ACTIONS).setMinimumWidth(280);
    Language userLanguage = I18nProperties.getUserLanguage();
    ((Column<CaseIndexDto, Date>) getColumn(CaseIndexDto.REPORT_DATE)).setRenderer(new DateRenderer(DateHelper.getLocalDateTimeFormat(userLanguage)));
    ((Column<CaseIndexDto, Date>) getColumn(CaseIndexDto.CREATION_DATE)).setRenderer(new DateRenderer(DateHelper.getLocalDateTimeFormat(userLanguage)));
    ((Column<CaseIndexDto, AgeAndBirthDateDto>) getColumn(CaseIndexDto.AGE_AND_BIRTH_DATE)).setRenderer(value -> value == null ? "" : PersonHelper.getAgeAndBirthdateString(value.getAge(), value.getAgeType(), value.getDateOfBirthDD(), value.getDateOfBirthMM(), value.getDateOfBirthYYYY()), new TextRenderer());
}
Also used : Language(de.symeda.sormas.api.Language) DateRenderer(com.vaadin.ui.renderers.DateRenderer) CaseIndexDto(de.symeda.sormas.api.caze.CaseIndexDto) TextRenderer(com.vaadin.ui.renderers.TextRenderer)

Example 10 with DateRenderer

use of com.vaadin.ui.renderers.DateRenderer in project SORMAS-Project by hzi-braunschweig.

the class TravelEntryGrid method initColumns.

private void initColumns() {
    setColumns(TravelEntryIndexDto.UUID, TravelEntryIndexDto.EXTERNAL_ID, TravelEntryIndexDto.PERSON_FIRST_NAME, TravelEntryIndexDto.PERSON_LAST_NAME, TravelEntryIndexDto.HOME_DISTRICT_NAME, TravelEntryIndexDto.POINT_OF_ENTRY_NAME, TravelEntryIndexDto.RECOVERED, TravelEntryIndexDto.VACCINATED, TravelEntryIndexDto.TESTED_NEGATIVE, TravelEntryIndexDto.QUARANTINE_TO);
    ((Column<TravelEntryIndexDto, String>) getColumn(TravelEntryIndexDto.UUID)).setRenderer(new UuidRenderer());
    ((Column<TravelEntryIndexDto, Boolean>) getColumn(TravelEntryIndexDto.RECOVERED)).setRenderer(new BooleanRenderer());
    ((Column<TravelEntryIndexDto, Boolean>) getColumn(TravelEntryIndexDto.VACCINATED)).setRenderer(new BooleanRenderer());
    ((Column<TravelEntryIndexDto, Boolean>) getColumn(TravelEntryIndexDto.TESTED_NEGATIVE)).setRenderer(new BooleanRenderer());
    ((Column<TravelEntryIndexDto, Date>) getColumn(TravelEntryIndexDto.QUARANTINE_TO)).setRenderer(new DateRenderer(DateFormatHelper.getDateFormat()));
    for (Column<TravelEntryIndexDto, ?> column : getColumns()) {
        column.setCaption(I18nProperties.findPrefixCaptionWithDefault(column.getId(), column.getCaption(), TravelEntryIndexDto.I18N_PREFIX, PersonDto.I18N_PREFIX));
        column.setStyleGenerator(FieldAccessColumnStyleGenerator.getDefault(getBeanType(), column.getId()));
    }
}
Also used : BooleanRenderer(de.symeda.sormas.ui.utils.BooleanRenderer) UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) TravelEntryIndexDto(de.symeda.sormas.api.travelentry.TravelEntryIndexDto) DateRenderer(com.vaadin.ui.renderers.DateRenderer)

Aggregations

DateRenderer (com.vaadin.ui.renderers.DateRenderer)15 UuidRenderer (de.symeda.sormas.ui.utils.UuidRenderer)9 Language (de.symeda.sormas.api.Language)7 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)7 Date (java.util.Date)7 List (java.util.List)6 Label (com.vaadin.ui.Label)5 DateHelper (de.symeda.sormas.api.utils.DateHelper)5 TextRenderer (com.vaadin.ui.renderers.TextRenderer)4 FacadeProvider (de.symeda.sormas.api.FacadeProvider)4 CaseIndexDto (de.symeda.sormas.api.caze.CaseIndexDto)4 SortProperty (de.symeda.sormas.api.utils.SortProperty)4 ControllerProvider (de.symeda.sormas.ui.ControllerProvider)4 ShowDetailsListener (de.symeda.sormas.ui.utils.ShowDetailsListener)4 DataProvider (com.vaadin.data.provider.DataProvider)3 ListDataProvider (com.vaadin.data.provider.ListDataProvider)3 SortDirection (com.vaadin.shared.data.sort.SortDirection)3 HeightMode (com.vaadin.shared.ui.grid.HeightMode)3 Grid (com.vaadin.ui.Grid)3 CountryHelper (de.symeda.sormas.api.CountryHelper)3