<commit_before>package de.uni_potsdam.hpi.bpt.bp2014.database;


import java.util.LinkedList;


/**
 * ********************************************************************************
 * <p/>
 * _________ _______  _        _______ _________ _        _______
 * \__    _/(  ____ \( (    /|(  ____ \\__   __/( (    /|(  ____ \
 * )  (  | (    \/|  \  ( || (    \/   ) (   |  \  ( || (    \/
 * |  |  | (__    |   \ | || |         | |   |   \ | || (__
 * |  |  |  __)   | (\ \) || | ____    | |   | (\ \) ||  __)
 * |  |  | (      | | \   || | \_  )   | |   | | \   || (
 * |\_)  )  | (____/\| )  \  || (___) |___) (___| )  \  || (____/\
 * (____/   (_______/|/    )_)(_______)\_______/|/    )_)(_______/
 * <p/>
 * ******************************************************************
 * <p/>
 * Copyright © All Rights Reserved 2014 - 2015
 * <p/>
 * Please be aware of the License. You may found it in the root directory.
 * <p/>
 * **********************************************************************************
 */

/**
 * This class administrates the scenario instances in the databases and provides check methods to make sure the database is correct.
 * Moreover it is possible to mark a scenario instance as terminated.
 */
public class DbScenarioInstance extends DbObject {
    /**
     * Checks if a scenario instance belongs to the right scenario.
     *
     * @param scenario_id         This is the database ID of a scenario.
     * @param scenarioInstance_id This is the database ID of a scenario instance.
     * @return if the check was positive(true) or not(false).
     */
    public Boolean existScenario(int scenario_id, int scenarioInstance_id) {
        String sql = "SELECT id FROM scenarioinstance WHERE scenario_id = " + scenario_id + " AND id = " + scenarioInstance_id;
        return this.executeExistStatement(sql);
    }

    /**
     * Checks if a given scenario instance ID is present in the database.
     *
     * @param scenarioInstance_id This is the database ID of a scenario instance.
     * @return if the check was positive(true) or not(false).
     */
    public Boolean existScenario(int scenarioInstance_id) {
        String sql = "SELECT id FROM scenarioinstance WHERE id = " + scenarioInstance_id;
        return this.executeExistStatement(sql);
    }

    /**
     * Creates a new scenario instance from a scenario.
     *
     * @param id This is the database Id of a scenario.
     * @return -1 if something went wrong else it returns the database ID of the newly created scenario instance.
     */
    public int createNewScenarioInstance(int id) {
        String sql = "INSERT INTO scenarioinstance (scenario_id) VALUES (" + id + ")";
        return this.executeInsertStatement(sql);
    }

    /**
     * Returns the highest ID of all scenario instances of a scenario.
     *
     * @param scenario_id This is the database ID of a scenario.
     * @return -1 if something went wrong else it returns the database ID of the latest scenario instance.
     */
    public int getScenarioInstanceID(int scenario_id) {
        String sql = "SELECT id FROM scenarioinstance WHERE scenario_id = " + scenario_id + " ORDER BY id DESC";
        return this.executeStatementReturnsInt(sql, "id");
    }
<commit_msg>added default name for scenario instances<commit_after>package de.uni_potsdam.hpi.bpt.bp2014.database;


import java.util.LinkedList;


/**
 * ********************************************************************************
 * <p/>
 * _________ _______  _        _______ _________ _        _______
 * \__    _/(  ____ \( (    /|(  ____ \\__   __/( (    /|(  ____ \
 * )  (  | (    \/|  \  ( || (    \/   ) (   |  \  ( || (    \/
 * |  |  | (__    |   \ | || |         | |   |   \ | || (__
 * |  |  |  __)   | (\ \) || | ____    | |   | (\ \) ||  __)
 * |  |  | (      | | \   || | \_  )   | |   | | \   || (
 * |\_)  )  | (____/\| )  \  || (___) |___) (___| )  \  || (____/\
 * (____/   (_______/|/    )_)(_______)\_______/|/    )_)(_______/
 * <p/>
 * ******************************************************************
 * <p/>
 * Copyright © All Rights Reserved 2014 - 2015
 * <p/>
 * Please be aware of the License. You may found it in the root directory.
 * <p/>
 * **********************************************************************************
 */

/**
 * This class administrates the scenario instances in the databases and provides check methods to make sure the database is correct.
 * Moreover it is possible to mark a scenario instance as terminated.
 */
public class DbScenarioInstance extends DbObject {
    /**
     * Checks if a scenario instance belongs to the right scenario.
     *
     * @param scenario_id         This is the database ID of a scenario.
     * @param scenarioInstance_id This is the database ID of a scenario instance.
     * @return if the check was positive(true) or not(false).
     */
    public Boolean existScenario(int scenario_id, int scenarioInstance_id) {
        String sql = "SELECT id FROM scenarioinstance WHERE scenario_id = " + scenario_id + " AND id = " + scenarioInstance_id;
        return this.executeExistStatement(sql);
    }

    /**
     * Checks if a given scenario instance ID is present in the database.
     *
     * @param scenarioInstance_id This is the database ID of a scenario instance.
     * @return if the check was positive(true) or not(false).
     */
    public Boolean existScenario(int scenarioInstance_id) {
        String sql = "SELECT id FROM scenarioinstance WHERE id = " + scenarioInstance_id;
        return this.executeExistStatement(sql);
    }

    /**
     * Creates a new scenario instance from a scenario.
     *
     * @param id This is the database Id of a scenario.
     * @return -1 if something went wrong else it returns the database ID of the newly created scenario instance.
     */
    public int createNewScenarioInstance(int id) {
        String sql = "INSERT INTO scenarioinstance (scenario_id, name) VALUES (" + id + ", (SELECT name FROM scenario WHERE id = " + id + "))";
        return this.executeInsertStatement(sql);
    }

    /**
     * Returns the highest ID of all scenario instances of a scenario.
     *
     * @param scenario_id This is the database ID of a scenario.
     * @return -1 if something went wrong else it returns the database ID of the latest scenario instance.
     */
    public int getScenarioInstanceID(int scenario_id) {
        String sql = "SELECT id FROM scenarioinstance WHERE scenario_id = " + scenario_id + " ORDER BY id DESC";
        return this.executeStatementReturnsInt(sql, "id");
    }

{'fraction_non_alphanumeric': 0.17793648381704907, 'fraction_numerical': 0.004254672542166844, 'mean_word_length': 2.5292225201072385, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 18, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2018131', 'n_tokens_mistral': 1896, 'n_tokens_neox': 1799, 'n_words': 571}