<commit_before>/**
 * FPempresa Copyright (C) 2014 <NAME>
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package es.logongas.ix3.web.database;

import es.logongas.ix3.core.database.DatabaseMigration;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class DatabaseMigrateContextListener implements ServletContextListener {

    @Autowired
    DatabaseMigration databaseMigration;
    
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        List<String> locations = new ArrayList<String>();
        locations.add(servletContextEvent.getServletContext().getInitParameter("databasemigration.location"));

        WebApplicationContext webApplicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContextEvent.getServletContext());
        AutowireCapableBeanFactory autowireCapableBeanFactory=webApplicationContext.getAutowireCapableBeanFactory();
        autowireCapableBeanFactory.autowireBean(this);
        
        databaseMigration.migrate(locations);
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {

    }

}<commit_msg>Permitir mas de un path de la migracion de base de datos<commit_after>/**
 * FPempresa Copyright (C) 2014 <NAME>
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package es.logongas.ix3.web.database;

import es.logongas.ix3.core.database.DatabaseMigration;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class DatabaseMigrateContextListener implements ServletContextListener {

    @Autowired
    DatabaseMigration databaseMigration;
    
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        WebApplicationContext webApplicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContextEvent.getServletContext());
        AutowireCapableBeanFactory autowireCapableBeanFactory=webApplicationContext.getAutowireCapableBeanFactory();
        autowireCapableBeanFactory.autowireBean(this);
        
        //Permitirmos varias "locations" en el parámetro separados por "\n"
        String[] rawLocations = (servletContextEvent.getServletContext().getInitParameter("databasemigration.location")+"").split("\\n");
        List<String> locations = new ArrayList<String>();
        for(String location : rawLocations) {
            if ((location!=null) && (location.trim().isEmpty()==false)) {
                locations.add(location);
            }
        }

        databaseMigration.migrate(locations);
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {

    }

}
{'fraction_non_alphanumeric': 0.07752632758234372, 'fraction_numerical': 0.003136903428187318, 'mean_word_length': 4.504315659679408, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '261083', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1121, 'n_words': 341}