<commit_before><commit_msg>added SettingsWrapper class for .xhtml to only call db once for settings<commit_after>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.harvard.iq.dataverse;

import edu.harvard.iq.dataverse.settings.Setting;
import edu.harvard.iq.dataverse.settings.SettingsServiceBean;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import javax.ejb.EJB;
import javax.faces.view.ViewScoped;
import javax.inject.Named;

/**
 *
 * @author gdurand
 */
@ViewScoped
@Named
public class SettingsWrapper implements java.io.Serializable {

    @EJB
    SettingsServiceBean settingService;

    private Map<String, String> settingsMap;

    public String get(String settingKey) {
        if (settingsMap == null) {
            // initialize settings map
            settingsMap = new HashMap<>();
            for (Setting setting : settingService.listAll()) {
                settingsMap.put(setting.getName(),setting.getContent());
            }
        }
        
        
        return settingsMap.get(settingKey);
    }



}


{'fraction_non_alphanumeric': 0.09551495016611296, 'fraction_numerical': 0.0, 'mean_word_length': 3.0436241610738257, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5626939', 'n_tokens_mistral': 339, 'n_tokens_neox': 329, 'n_words': 92}