<commit_before>package org.ovirt.engine.ui.uicommonweb.models.vms;

import org.ovirt.engine.core.common.TimeZoneType;
import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;



public class TimeZoneModel {
    private static final Map<TimeZoneType, Iterable<TimeZoneModel>> cachedTimeZoneModels = new HashMap<TimeZoneType, Iterable<TimeZoneModel>>();

    public static Iterable<TimeZoneModel> getTimeZones(TimeZoneType timeZoneType) {
        return cachedTimeZoneModels.get(timeZoneType);
    }

    static {
        for (TimeZoneType timeZoneType : TimeZoneType.values()) {
            mapListModels(timeZoneType, timeZoneType.getTimeZoneList());
        }
    }

    private static void mapListModels(TimeZoneType timeZoneType, Map<String, String> timeZones) {
        List<TimeZoneModel> models = new ArrayList<TimeZoneModel>();
        models.add(new TimeZoneModel(null, timeZoneType)); // add empty field representing default engine TZ
        for (Map.Entry<String, String> entry : timeZones.entrySet()) {
            models.add(new TimeZoneModel(entry.getKey(), timeZoneType));
        }
        cachedTimeZoneModels.put(timeZoneType, models);
    }

    private String timeZoneKey = null;
    private TimeZoneType timeZoneType = TimeZoneType.GENERAL_TIMEZONE;

    public TimeZoneModel(String timeZoneKey, TimeZoneType timeZoneType) {
        this.timeZoneKey = timeZoneKey;
        this.timeZoneType = timeZoneType;

    }

    public String getTimeZoneKey() {
        return timeZoneKey;
    }

    public boolean isDefault() {
        return timeZoneKey == null;
    }

    public String getDisplayValue() {
        if (isDefault()) {
            final String defaultTimeZoneKey = (String) AsyncDataProvider.getConfigValuePreConverted(timeZoneType.getDefaultTimeZoneConfigurationKey());
            // check if default timezone is correct
            if (!timeZoneType.getTimeZoneList().containsKey(defaultTimeZoneKey)) {
                // if not show GMT
                timeZoneKey = timeZoneType.getUltimateFallback();
            }
            return timeZoneType.getTimeZoneList().get(defaultTimeZoneKey);
        } else {
            return timeZoneType.getTimeZoneList().get(timeZoneKey);
        }
    }
}
<commit_msg>frontend: Correct default time-zone rendering<commit_after>package org.ovirt.engine.ui.uicommonweb.models.vms;

import org.ovirt.engine.core.common.TimeZoneType;
import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;



public class TimeZoneModel {
    private static final Map<TimeZoneType, Iterable<TimeZoneModel>> cachedTimeZoneModels = new HashMap<TimeZoneType, Iterable<TimeZoneModel>>();

    public static Iterable<TimeZoneModel> getTimeZones(TimeZoneType timeZoneType) {
        return cachedTimeZoneModels.get(timeZoneType);
    }

    static {
        for (TimeZoneType timeZoneType : TimeZoneType.values()) {
            mapListModels(timeZoneType, timeZoneType.getTimeZoneList());
        }
    }

    private static void mapListModels(TimeZoneType timeZoneType, Map<String, String> timeZones) {
        List<TimeZoneModel> models = new ArrayList<TimeZoneModel>();
        models.add(new TimeZoneModel(null, timeZoneType)); // add empty field representing default engine TZ
        for (Map.Entry<String, String> entry : timeZones.entrySet()) {
            models.add(new TimeZoneModel(entry.getKey(), timeZoneType));
        }
        cachedTimeZoneModels.put(timeZoneType, models);
    }

    private final String timeZoneKey;
    private final TimeZoneType timeZoneType;

    public TimeZoneModel(String timeZoneKey, TimeZoneType timeZoneType) {
        this.timeZoneKey = timeZoneKey;
        this.timeZoneType = timeZoneType;

    }

    public String getTimeZoneKey() {
        return timeZoneKey;
    }

    public boolean isDefault() {
        return timeZoneKey == null;
    }

    public String getDisplayValue() {
        if (isDefault()) {
            String defaultTimeZoneKey = (String) AsyncDataProvider.getConfigValuePreConverted(timeZoneType.getDefaultTimeZoneConfigurationKey());
            // check if default timezone is correct
            if (!timeZoneType.getTimeZoneList().containsKey(defaultTimeZoneKey)) {
                // if not show GMT
                defaultTimeZoneKey = timeZoneType.getUltimateFallback();
            }
            return timeZoneType.getTimeZoneList().get(defaultTimeZoneKey);
        } else {
            return timeZoneType.getTimeZoneList().get(timeZoneKey);
        }
    }
}

{'fraction_non_alphanumeric': 0.09054283290924513, 'fraction_numerical': 0.0, 'mean_word_length': 3.272644927536232, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2022094', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1301, 'n_words': 261}