Search in sources :

Example 1 with DatarouterSettingTag

use of io.datarouter.storage.setting.DatarouterSettingTag in project datarouter by hotpads.

the class ClusterSettingsHandler method customSettings.

@Handler
public Mav customSettings(OptionalString prefix) {
    Mav mav = new Mav(files.jsp.admin.datarouter.setting.editSettingsJsp);
    mav.put("serverTypeOptions", serverTypes.getHtmlSelectOptionsVarNames());
    mav.put("validities", buildLegend());
    clusterSettingService.scanClusterSettingAndValidityWithPrefix(prefix.orElse(null)).flush(settings -> mav.put("rows", settings));
    boolean mightBeDevelopment = datarouterServerTypeDetector.mightBeDevelopment();
    mav.put("mightBeDevelopment", mightBeDevelopment);
    if (mightBeDevelopment) {
        mav.put("settingTagFilePath", CachedClusterSettingTags.getConfigFilePath());
        List<DatarouterSettingTag> tags = cachedClusterSettingTags.get();
        mav.put("settingTagValues", tags.stream().map(DatarouterSettingTag::getPersistentString).collect(Collectors.joining(",")));
    }
    return mav;
}
Also used : Mav(io.datarouter.web.handler.mav.Mav) DatarouterSettingTag(io.datarouter.storage.setting.DatarouterSettingTag) BaseHandler(io.datarouter.web.handler.BaseHandler)

Example 2 with DatarouterSettingTag

use of io.datarouter.storage.setting.DatarouterSettingTag in project datarouter by hotpads.

the class ClusterSettingService method getSettingValueForWebappInstance.

public <T> T getSettingValueForWebappInstance(CachedSetting<T> memorySetting, WebappInstance webappInstance) {
    // try database first
    List<ClusterSetting> settingsWithName = clusterSettingFinder.getAllSettingsWithName(memorySetting.getName());
    Optional<ClusterSetting> mostSpecificSetting = ClusterSettingComparisonTool.getMostSpecificSettingForWebappInstance(settingsWithName, webappInstance);
    if (mostSpecificSetting.isPresent()) {
        return ClusterSettingComparisonTool.getTypedValueOrUseDefaultFrom(mostSpecificSetting, memorySetting);
    }
    // use default
    var environmentType = environmentTypeSupplier.getDatarouterEnvironmentType();
    DefaultSettingValue<T> defaultSettingValue = memorySetting.getDefaultSettingValue();
    ServerType serverType = serverTypes.fromPersistentString(webappInstance.getServerType());
    List<DatarouterSettingTag> settingTags = cachedClusterSettingTags.get();
    return defaultSettingValue.getValue(environmentType, environmentName.get(), serverType, serverName.get(), settingTags);
}
Also used : ServerType(io.datarouter.storage.servertype.ServerType) ClusterSetting(io.datarouter.clustersetting.storage.clustersetting.ClusterSetting) DatarouterSettingTag(io.datarouter.storage.setting.DatarouterSettingTag)

Aggregations

DatarouterSettingTag (io.datarouter.storage.setting.DatarouterSettingTag)2 ClusterSetting (io.datarouter.clustersetting.storage.clustersetting.ClusterSetting)1 ServerType (io.datarouter.storage.servertype.ServerType)1 BaseHandler (io.datarouter.web.handler.BaseHandler)1 Mav (io.datarouter.web.handler.mav.Mav)1