<commit_before>package org.intermine.api.tracker;

/*
 * Copyright (C) 2002-2011 FlyMine
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  See the LICENSE file for more
 * information or http://www.gnu.org/copyleft/lesser.html.
 *
 */
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

import org.apache.log4j.Logger;

/**
 * Runnable object providing insertion into the database. TrackerLogger is created
 * for a specific connection and table.
 * @author dbutano
 *
 */
public class TrackerLogger implements Runnable
{
    private static final Logger LOG = Logger.getLogger(TrackerLogger.class);
    private Connection connection;
    private String tableName;
    private String[] colNames;
    private Object[] values;

    /**
     * Construct a TrackerLogger for a specific connection and table
     * @param connection the connection to the database
     * @param tableName the name of the table where the value will be saved
     * @param colNames the names of the columns
     * @param values the values to be saved
     */
    public TrackerLogger(Connection connection, String tableName, String[] colNames,
                         Object[] values) {
        this.connection = connection;
        this.tableName = tableName;
        this.colNames = colNames;
        this.values = values;
    }

    /**
     * Set the values to insert into the database.
     * The values have to be in the same order as colNames
     * @param values an array of Objects to be saved into the database
     */
    public synchronized void setValues(Object[] values) {
        this.values = values;
    }

    public void run() {
        Statement stm = null;
        StringBuffer colNamesBuffer = new StringBuffer();
        StringBuffer valuesBuffer = new StringBuffer();
        for (int index = 0; index < colNames.length; index++) {
            colNamesBuffer = colNamesBuffer.append(colNames[index] + ",");
            valuesBuffer = valuesBuffer.append("'" + values[index] + "',");
        }
        colNamesBuffer = colNamesBuffer.deleteCharAt(colNamesBuffer.length() - 1);
        valuesBuffer = valuesBuffer.deleteCharAt(valuesBuffer.length() - 1);
        String sql = "";
        try {
            stm = connection.createStatement();
            sql = "INSERT INTO " + tableName
                        + " (" + colNamesBuffer + ") "
                        + " VALUES ( " + valuesBuffer + ")";
            stm.executeUpdate(sql);
        } catch (SQLException sqe) {
            LOG.error("Problem executing the statement: " + sql, sqe);
            LOG.error("The template execution has not been tracked.");
            if (stm != null) {
                try {
                    stm.close();<commit_msg>Removed a method not used anymore<commit_after>package org.intermine.api.tracker;

/*
 * Copyright (C) 2002-2011 FlyMine
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  See the LICENSE file for more
 * information or http://www.gnu.org/copyleft/lesser.html.
 *
 */
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

import org.apache.log4j.Logger;

/**
 * Runnable object providing insertion into the database. TrackerLogger is created
 * for a specific connection and table.
 * @author dbutano
 *
 */
public class TrackerLogger implements Runnable
{
    private static final Logger LOG = Logger.getLogger(TrackerLogger.class);
    private Connection connection;
    private String tableName;
    private String[] colNames;
    private Object[] values;

    /**
     * Construct a TrackerLogger for a specific connection and table
     * @param connection the connection to the database
     * @param tableName the name of the table where the value will be saved
     * @param colNames the names of the columns
     * @param values the values to be saved
     */
    public TrackerLogger(Connection connection, String tableName, String[] colNames,
                         Object[] values) {
        this.connection = connection;
        this.tableName = tableName;
        this.colNames = colNames;
        this.values = values;
    }

    public void run() {
        Statement stm = null;
        StringBuffer colNamesBuffer = new StringBuffer();
        StringBuffer valuesBuffer = new StringBuffer();
        for (int index = 0; index < colNames.length; index++) {
            colNamesBuffer = colNamesBuffer.append(colNames[index] + ",");
            valuesBuffer = valuesBuffer.append("'" + values[index] + "',");
        }
        colNamesBuffer = colNamesBuffer.deleteCharAt(colNamesBuffer.length() - 1);
        valuesBuffer = valuesBuffer.deleteCharAt(valuesBuffer.length() - 1);
        String sql = "";
        try {
            stm = connection.createStatement();
            sql = "INSERT INTO " + tableName
                        + " (" + colNamesBuffer + ") "
                        + " VALUES ( " + valuesBuffer + ")";
            stm.executeUpdate(sql);
        } catch (SQLException sqe) {
            LOG.error("Problem executing the statement: " + sql, sqe);
            LOG.error("The template execution has not been tracked.");
            if (stm != null) {
                try {
                    stm.close();
{'fraction_non_alphanumeric': 0.0934287812041116, 'fraction_numerical': 0.004405286343612335, 'mean_word_length': 2.429200755191945, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '5527803', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1371, 'n_words': 472}