Search in sources :

Example 1 with ConversionException

use of com.vaadin.v7.data.util.converter.Converter.ConversionException in project SORMAS-Project by hzi-braunschweig.

the class CaseDataForm method setValue.

@Override
public void setValue(CaseDataDto newFieldValue) throws ReadOnlyException, ConversionException {
    for (ReinfectionDetailGroup group : reinfectionTrees.keySet()) {
        if (newFieldValue.getReinfectionDetails() != null) {
            reinfectionTrees.get(group).setValues(newFieldValue.getReinfectionDetails().entrySet().stream().filter(e -> e.getKey().getGroup() == group).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
        } else {
            reinfectionTrees.get(group).setValues(null);
        }
    }
    super.setValue(newFieldValue);
    ComboBox caseConfirmationBasisCombo = getField(CASE_CONFIRMATION_BASIS);
    if (caseConfirmationBasisCombo != null) {
        if (newFieldValue.getClinicalConfirmation() == YesNoUnknown.YES) {
            caseConfirmationBasisCombo.setValue(CaseConfirmationBasis.CLINICAL_CONFIRMATION);
        } else if (newFieldValue.getEpidemiologicalConfirmation() == YesNoUnknown.YES) {
            caseConfirmationBasisCombo.setValue(CaseConfirmationBasis.EPIDEMIOLOGICAL_CONFIRMATION);
        } else if (newFieldValue.getLaboratoryDiagnosticConfirmation() == YesNoUnknown.YES) {
            caseConfirmationBasisCombo.setValue(CaseConfirmationBasis.LABORATORY_DIAGNOSTIC_CONFIRMATION);
        }
    }
    if (caseFollowUpEnabled) {
        FollowUpPeriodDto followUpPeriodDto = FacadeProvider.getCaseFacade().calculateFollowUpUntilDate(newFieldValue, true);
        tfExpectedFollowUpUntilDate.setValue(DateHelper.formatLocalDate(followUpPeriodDto.getFollowUpEndDate(), I18nProperties.getUserLanguage()));
        tfExpectedFollowUpUntilDate.setReadOnly(true);
        tfExpectedFollowUpUntilDate.setDescription(String.format(I18nProperties.getString(Strings.infoExpectedFollowUpUntilDateCase), followUpPeriodDto.getFollowUpStartDateType(), DateHelper.formatLocalDate(followUpPeriodDto.getFollowUpStartDate(), I18nProperties.getUserLanguage())));
    }
    updateVisibilityDifferentPlaceOfStayJurisdiction(newFieldValue);
    // HACK: Binding to the fields will call field listeners that may clear/modify the values of other fields.
    // this hopefully resets everything to its correct value
    discard();
}
Also used : ComboBox(com.vaadin.v7.ui.ComboBox) FollowUpPeriodDto(de.symeda.sormas.api.followup.FollowUpPeriodDto) ReinfectionDetailGroup(de.symeda.sormas.api.caze.ReinfectionDetailGroup)

Aggregations

ComboBox (com.vaadin.v7.ui.ComboBox)1 ReinfectionDetailGroup (de.symeda.sormas.api.caze.ReinfectionDetailGroup)1 FollowUpPeriodDto (de.symeda.sormas.api.followup.FollowUpPeriodDto)1