<commit_before>package edacc.experiment;

import edacc.model.DatabaseConnector;
import javax.swing.table.AbstractTableModel;
import java.util.ArrayList;
import edacc.model.Solver;
import edacc.model.SolverDAO;
import java.util.HashMap;

/**
 *
 * @author daniel
 */
public class SolverTableModel extends AbstractTableModel {

    private static final String[] columns_noCompetition = {"Name", "binary name", "md5", "description", "Selected"};
    private static final String[] columns_competition = {"Name", "binary name", "md5", "description", "categories", "Selected"};
    private String[] columns = columns_competition;
    private String[] categories;
    private boolean isCompetition;
    private ArrayList<Solver> solvers;
    private Boolean[] selected;

    public SolverTableModel() {
        this.solvers = new ArrayList<Solver>();
    }

    public void setSolvers(ArrayList<Solver> solvers) {
        this.solvers = solvers;
        this.selected = new Boolean[solvers.size()];
        for (int i = 0; i < solvers.size(); i++) {
            selected[i] = false;
        }
        try {
            isCompetition = DatabaseConnector.getInstance().isCompetitionDB();
        } catch (Exception e) {
            isCompetition = false;
        }
        categories = null;
        if (isCompetition) {
            columns = columns_competition;
            if (solvers != null) {
                categories = new String[solvers.size()];
                try {
                    HashMap<Integer, ArrayList<String>> cats = SolverDAO.getCompetitionCategories();
                    for (int i = 0; i < solvers.size(); i++) {
                        String tmp = "";
                        ArrayList<String> catlist = cats.get(solvers.get(i).getId());
                        if (catlist != null) {
                            for (int k = 0; k < catlist.size(); k++) {
                                tmp += catlist.get(k);
                                if (k != catlist.size() - 1) {
                                    tmp += ", ";
                                }
                            }
                        }
                        categories[i] = tmp;
                    }
                } catch (Exception e) {
                }
            }
        } else {
            columns = columns_noCompetition;
        }
        this.fireTableStructureChanged();
    }

    @Override
    public int getRowCount() {
        return solvers.size();
    }

    @Override
    public int getColumnCount() {
        return columns.length;
    }

    @Override
    public String getColumnName(int col) {
        return columns[col];
    }

    @Override
    public Class getColumnClass(int col) {
        return getValueAt(0, col).getClass();
    }

    @Override
    public boolean isCellEditable(int row, int col) {
        if (isCompetition) {
            col--;
        }
        if (col == 4) {
            return true;
        }
        return false;
    }

    @Override
    public void setValueAt(Object value, int row, int col) {
        if (isCompetition) {
            col--;
        }
        if (col == 4) {
            selected[row] = (Boolean) value;
        }
        fireTableCellUpdated(row, col);
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch (columnIndex) {
            case 0:
                return solvers.get(rowIndex).getName();
            case 1:
                return solvers.get(rowIndex).getBinaryName();
            case 2:
                return solvers.get(rowIndex).getMd5();
            case 3:
                return solvers.get(rowIndex).getDescription();
            case 4:
                if (isCompetition) {
                    return categories[rowIndex] == null ? "" : categories[rowIndex];
                } else {
                    return selected[rowIndex];
                }
            case 5:
                return selected[rowIndex];
            default:
                return "";
        }
    }

    public void setSolverSelected(int solverId, boolean value) {
        for (int i = 0; i < solvers.size(); i++) {
            if (solvers.get(i).getId() == solverId) {
                selected[i] = value;
                this.fireTableCellUpdated(i, 4);
                break;
            }
        }
    }

    public Solver getSolver(int row) {
        return solvers.get(row);
    }

    public boolean isSelected(int row) {
        return selected[row];
    }

    public void setSelected(int row, boolean sel) {
        selected[row] = sel;
        fireTableRowsUpdated(row, row);
    }
}
<commit_msg>Added column  to solver tables<commit_after>package edacc.experiment;

import edacc.model.DatabaseConnector;
import javax.swing.table.AbstractTableModel;
import java.util.ArrayList;
import edacc.model.Solver;
import edacc.model.SolverDAO;
import java.util.HashMap;

/**
 *
 * @author daniel
 */
public class SolverTableModel extends AbstractTableModel {

    private static final String[] columns_noCompetition = {"Name", "Version", "binary name", "md5", "description", "Selected"};
    private static final String[] columns_competition = {"Name", "Version", "binary name", "md5", "description", "categories", "Selected"};
    private String[] columns = columns_competition;
    private String[] categories;
    private boolean isCompetition;
    private ArrayList<Solver> solvers;
    private Boolean[] selected;

    public SolverTableModel() {
        this.solvers = new ArrayList<Solver>();
    }

    public void setSolvers(ArrayList<Solver> solvers) {
        this.solvers = solvers;
        this.selected = new Boolean[solvers.size()];
        for (int i = 0; i < solvers.size(); i++) {
            selected[i] = false;
        }
        try {
            isCompetition = DatabaseConnector.getInstance().isCompetitionDB();
        } catch (Exception e) {
            isCompetition = false;
        }
        categories = null;
        if (isCompetition) {
            columns = columns_competition;
            if (solvers != null) {
                categories = new String[solvers.size()];
                try {
                    HashMap<Integer, ArrayList<String>> cats = SolverDAO.getCompetitionCategories();
                    for (int i = 0; i < solvers.size(); i++) {
                        String tmp = "";
                        ArrayList<String> catlist = cats.get(solvers.get(i).getId());
                        if (catlist != null) {
                            for (int k = 0; k < catlist.size(); k++) {
                                tmp += catlist.get(k);
                                if (k != catlist.size() - 1) {
                                    tmp += ", ";
                                }
                            }
                        }
                        categories[i] = tmp;
                    }
                } catch (Exception e) {
                }
            }
        } else {
            columns = columns_noCompetition;
        }
        this.fireTableStructureChanged();
    }

    @Override
    public int getRowCount() {
        return solvers.size();
    }

    @Override
    public int getColumnCount() {
        return columns.length;
    }

    @Override
    public String getColumnName(int col) {
        return columns[col];
    }

    @Override
    public Class getColumnClass(int col) {
        return getValueAt(0, col).getClass();
    }

    @Override
    public boolean isCellEditable(int row, int col) {
        if (isCompetition) {
            col--;
        }
        if (col == 4) {
            return true;
        }
        return false;
    }

    @Override
    public void setValueAt(Object value, int row, int col) {
        if (isCompetition) {
            col--;
        }
        if (col == 4) {
            selected[row] = (Boolean) value;
        }
        fireTableCellUpdated(row, col);
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch (columnIndex) {
            case 0:
                return solvers.get(rowIndex).getName();
            case 1:
                return solvers.get(rowIndex).getVersion();
            case 2:
                return solvers.get(rowIndex).getBinaryName();
            case 3:
                return solvers.get(rowIndex).getMd5();
            case 4:
                return solvers.get(rowIndex).getDescription();
            case 5:
                if (isCompetition) {
                    return categories[rowIndex] == null ? "" : categories[rowIndex];
                } else {
                    return selected[rowIndex];
                }
            case 6:
                return selected[rowIndex];
            default:
                return "";
        }
    }

    public void setSolverSelected(int solverId, boolean value) {
        for (int i = 0; i < solvers.size(); i++) {
            if (solvers.get(i).getId() == solverId) {
                selected[i] = value;
                this.fireTableCellUpdated(i, 4);
                break;
            }
        }
    }

    public Solver getSolver(int row) {
        return solvers.get(row);
    }

    public boolean isSelected(int row) {
        return selected[row];
    }

    public void setSelected(int row, boolean sel) {
        selected[row] = sel;
        fireTableRowsUpdated(row, row);
    }
}

{'fraction_non_alphanumeric': 0.10767590618336886, 'fraction_numerical': 0.00394456289978678, 'mean_word_length': 1.5326673866090712, 'pattern_counts': {'":': 0, '<': 23, '<?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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5439758', 'n_tokens_mistral': 2582, 'n_tokens_neox': 2442, 'n_words': 600}