<commit_before>package org.dukecon.server.conference

import org.apache.commons.lang3.text.StrSubstitutor
import org.dukecon.server.adapter.DefaultRawDataResource
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.context.annotation.Configuration
import org.yaml.snakeyaml.Yaml

import javax.validation.Valid
import javax.validation.constraints.NotNull
import java.time.LocalDate

@ConfigurationProperties(locations = "classpath:conferences.yml")
@Configuration
class ConferencesConfiguration {

    static ConferencesConfiguration fromFile(String classpathName, Map<String, Object> allProperties) {
        new ConferencesConfiguration(conferences: new Yaml(new YamlDateTimeConstructor()).load(getClass().getResourceAsStream("/${classpathName}")).collect {
            new Conference(substitutePlaceHolder(it, allProperties))
        })
    }

    private static Map substitutePlaceHolder(Map properties, Map allConfigProperties) {
        def substitutor = new StrSubstitutor(properties + allConfigProperties)
        properties.each {k, v ->
            if (v instanceof String) {
                properties[k] = substitutor.replace(v)
            }
            if (v instanceof Map) {
                def substitutor2 = new StrSubstitutor(properties + allConfigProperties)
                v.each {k1, v1 ->
                    v[k1] = substitutor.replace(v1)
                }<commit_msg>fixed loading conferences.yml from jar execution<commit_after>package org.dukecon.server.conference

import org.apache.commons.lang3.text.StrSubstitutor
import org.dukecon.server.adapter.DefaultRawDataResource
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.context.annotation.Configuration
import org.yaml.snakeyaml.Yaml

import javax.validation.Valid
import javax.validation.constraints.NotNull
import java.time.LocalDate

@ConfigurationProperties(locations = "classpath:conferences.yml")
@Configuration
class ConferencesConfiguration {

    static ConferencesConfiguration fromFile(String classpathName, Map<String, Object> allProperties) {
        new ConferencesConfiguration(conferences: new Yaml(new YamlDateTimeConstructor()).load(new org.springframework.core.io.ClassPathResource(classpathName).inputStream).collect {
            new Conference(substitutePlaceHolder(it, allProperties))
        })
    }

    private static Map substitutePlaceHolder(Map properties, Map allConfigProperties) {
        def substitutor = new StrSubstitutor(properties + allConfigProperties)
        properties.each {k, v ->
            if (v instanceof String) {
                properties[k] = substitutor.replace(v)
            }
            if (v instanceof Map) {
                def substitutor2 = new StrSubstitutor(properties + allConfigProperties)
                v.each {k1, v1 ->
                    v[k1] = substitutor.replace(v1)
                }
{'fraction_non_alphanumeric': 0.0824847250509165, 'fraction_numerical': 0.004073319755600814, 'mean_word_length': 3.61189358372457, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '6723676', 'n_tokens_mistral': 761, 'n_tokens_neox': 725, 'n_words': 152}