<commit_before>package com.percero.agents.sync.jobs;

import com.esotericsoftware.yamlbeans.YamlException;
import com.esotericsoftware.yamlbeans.YamlReader;
import edu.emory.mathcs.backport.java.util.Collections;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.beans.PropertyVetoException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author <NAME>
 *
 */
@Component
public class UpdateTableRegistry {

    private static Logger logger = Logger.getLogger(UpdateTableRegistry.class);

    private static UpdateTableRegistry instance;

    @SuppressWarnings("unchecked")
	private List<UpdateTableConnectionFactory> connectionFactories = Collections.synchronizedList(new ArrayList<UpdateTableConnectionFactory>());
    public List<UpdateTableConnectionFactory> getConnectionFactories() {
    	return connectionFactories;
    }

    private Map<String, UpdateTableMapping> tableMap = new HashMap<>();
    public UpdateTableMapping getTableMapping(String tableName){
        return tableMap.get(tableName);
    }

    public UpdateTableRegistry(){
        instance = this;
    }

    public static UpdateTableRegistry getInstance(){
        return instance;
    }
   
    @PostConstruct
    public void init() throws YamlException {
        loadConnectionFactories();
		loadTableMappings();
    }

    private void loadTableMappings() throws YamlException{
        try{
            URL ymlUrl = UpdateTableRegistry.class.getClassLoader().getResource("updateTableMap.yml");
            if (ymlUrl == null) {
                logger.warn("No configuration found for UpdateTableMapping (updateTableMap.yml), skipping UpdateTables");
                return;
            }
            File configFile = new File(ymlUrl.getFile());
            YamlReader reader = new YamlReader(new FileReader(configFile));
            while (true) {
                UpdateTableMapping updateTableMapping = reader.read(UpdateTableMapping.class);
                if (updateTableMapping == null) {
                    break;
                }

                updateTableMapping.init();
                tableMap.put(updateTableMapping.tableName, updateTableMapping);
            }
        }catch (FileNotFoundException e) {
            logger.warn("No configuration found for UpdateTables (updateTables.yml), skipping UpdateTables");
        }
    }

    private void loadConnectionFactories() throws YamlException{
        try {
            URL ymlUrl = UpdateTableRegistry.class.getClassLoader().getResource("updateTables.yml");
            if (ymlUrl == null) {
                logger.warn("No configuration found for UpdateTables (updateTables.yml), skipping UpdateTables");
                return;
            }
            File configFile = new File(ymlUrl.getFile());
            YamlReader reader = new YamlReader(new FileReader(configFile));
            while (true) {
                UpdateTableConnectionFactory updateTableConnectionFactory = reader.read(UpdateTableConnectionFactory.class);
                if (updateTableConnectionFactory == null) {
                    break;
                }

                try {
                    updateTableConnectionFactory.init();
                    connectionFactories.add(updateTableConnectionFactory);
                } catch (PropertyVetoException e) {
                    logger.warn("Unable to initialize Update Table Connection Factory", e);
                }

            }
        }
        catch (FileNotFoundException e) {
            logger.warn("No configuration found for UpdateTables (updateTables.yml), skipping UpdateTables");
        }

    }
}
<commit_msg>Made the yml file configurable<commit_after>package com.percero.agents.sync.jobs;

import com.esotericsoftware.yamlbeans.YamlException;
import com.esotericsoftware.yamlbeans.YamlReader;
import com.google.api.client.util.Value;
import edu.emory.mathcs.backport.java.util.Collections;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.beans.PropertyVetoException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author <NAME>
 *
 */
@Component
public class UpdateTableRegistry {

    private static Logger logger = Logger.getLogger(UpdateTableRegistry.class);

    private static UpdateTableRegistry instance;

    @SuppressWarnings("unchecked")
	private List<UpdateTableConnectionFactory> connectionFactories = Collections.synchronizedList(new ArrayList<UpdateTableConnectionFactory>());
    public List<UpdateTableConnectionFactory> getConnectionFactories() {
    	return connectionFactories;
    }

    private Map<String, UpdateTableMapping> tableMap = new HashMap<>();
    public UpdateTableMapping getTableMapping(String tableName){
        return tableMap.get(tableName);
    }

    public UpdateTableRegistry(){
        instance = this;
    }

    public static UpdateTableRegistry getInstance(){
        return instance;
    }

    @Autowired(required=false) @Qualifier("updateTableMapFile")
    private String updateTableMapFile = "updateTableMap.yml";

    @Autowired(required=false) @Qualifier("updateTableConfigFile")
    private String updateTableConfigFile = "updateTables.yml";
   
    @PostConstruct
    public void init() throws YamlException {
        loadConnectionFactories();
		loadTableMappings();
    }

    private void loadTableMappings() throws YamlException{
        try{
            URL ymlUrl = UpdateTableRegistry.class.getClassLoader().getResource(updateTableMapFile);
            if (ymlUrl == null) {
                logger.warn("No configuration found for UpdateTableMapping (updateTableMap.yml), skipping UpdateTables");
                return;
            }
            File configFile = new File(ymlUrl.getFile());
            YamlReader reader = new YamlReader(new FileReader(configFile));
            while (true) {
                UpdateTableMapping updateTableMapping = reader.read(UpdateTableMapping.class);
                if (updateTableMapping == null) {
                    break;
                }

                updateTableMapping.init();
                tableMap.put(updateTableMapping.tableName, updateTableMapping);
            }
        }catch (FileNotFoundException e) {
            logger.warn("No configuration found for UpdateTables (updateTables.yml), skipping UpdateTables");
        }
    }

    private void loadConnectionFactories() throws YamlException{
        try {
            URL ymlUrl = UpdateTableRegistry.class.getClassLoader().getResource(updateTableConfigFile);
            if (ymlUrl == null) {
                logger.warn("No configuration found for UpdateTables (updateTables.yml), skipping UpdateTables");
                return;
            }
            File configFile = new File(ymlUrl.getFile());
            YamlReader reader = new YamlReader(new FileReader(configFile));
            while (true) {
                UpdateTableConnectionFactory updateTableConnectionFactory = reader.read(UpdateTableConnectionFactory.class);
                if (updateTableConnectionFactory == null) {
                    break;
                }

                try {
                    updateTableConnectionFactory.init();
                    connectionFactories.add(updateTableConnectionFactory);
                } catch (PropertyVetoException e) {
                    logger.warn("Unable to initialize Update Table Connection Factory", e);
                }

            }
        }
        catch (FileNotFoundException e) {
            logger.warn("No configuration found for UpdateTables (updateTables.yml), skipping UpdateTables");
        }

    }
}

{'fraction_non_alphanumeric': 0.0862850839563672, 'fraction_numerical': 0.00024512807942149775, 'mean_word_length': 2.746556473829201, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '3523282', 'n_tokens_mistral': 2049, 'n_tokens_neox': 1959, 'n_words': 432}