<commit_before><project name="Lutece - Database Initialisation" default="specific" basedir=".">
    
    <macrodef name="runsql">
        <attribute name="sql.driver" />
        <attribute name="sql.url" />
        <attribute name="sql.userid" />
        <attribute name="sql.password" />
        <attribute name="sql.connector.path" />
        <attribute name="sql.fileset.refid"/>
        <sequential>
            <!--echo message="sql.driver : @{sql.driver}" />
            <echo message="sql.url : @{sql.url}" />
            <echo message="sql.userid : @{sql.userid}" />
            <echo message="sql.password : @{sql.password}" />
            <echo message="sql.connector.path : @{sql.connector.path}" /-->
            <!-- Concatenate all sql files into one -->
            <echo message="Translating SQL files to fit ${dbms} requirements"/>
            <tempfile property="temp.sql" prefix="tmp_" />
            <concat destfile="${temp.sql}" fixlastline="true">
            	<fileset file="init_db/init_session_${dbms}.sql" />
                <fileset refid="@{sql.fileset.refid}"/>
            </concat>
            <propertycopy name="regexp.list" from="regexp.${dbms}.list" override="true"/>
            <for list="${regexp.list}" delimiter="," param="index">
                <sequential>
                    <propertycopy name="regexp.index" from="regexp.${dbms}.@{index}" override="true"/>
                    <propertycopy name="replace.index" from="replace.${dbms}.@{index}" override="true"/>
                    <echo message=" ====== Applying rule @{index} ${regexp.index} => ${replace.index}" />
                    <replaceregexp file="${temp.sql}" match="${regexp.index}"
                                   replace="${replace.index}" byline="true" flags="gi" />
                </sequential>
            </for>
            <sql driver="@{sql.driver}"
                 url="@{sql.url}"
                 userid="@{sql.userid}" 
                 password="<PASSWORD>}"
                 classpath="@{sql.connector.path}"
                 onerror="${on_sql_error}"
                 encoding="${db.encoding}"
            >
                <fileset file="${temp.sql}"/>
            </sql>
            <delete file="${temp.sql}" verbose="true" />
        </sequential>
    </macrodef>
    
    <macrodef name="getdbms">
        <attribute name="dbms.url"/>
        <attribute name="property"/>
        <sequential>
        <propertyregex property="@{property}"
                       input="@{dbms.url}"
                       regexp="jdbc:(.*?):.*"
                       select="\1"
                       casesensitive="false" />
        </sequential>
    </macrodef>
    <regexp id="regexp.mysql.url" pattern="(.*)/(.*)\?(.*)" />
    <regexp id="regexp.hsqldb.url" pattern=".*(:|/)(.*)" />
    
    <target name="init" description="Prepare the database by creating it and inserting data">
        <echo message="Preparing the database(s) by creating it and inserting data" />
        
        <!-- Property file -->
        <property file="build.properties" />
        <property name="db.properties.path" value="../conf/db.properties"/>
        
        <!-- Webapp database pool configuration file -->
        <property file="${db.properties.path}" />
        <getdbms dbms.url="${portal.url}" property="dbms" />
        <!--propertyregex property="dbms"
                       input="${portal.url}"
                       regexp="jdbc:(.*?):.*"
                       select="\1"
                       casesensitive="false" /-->
        <switch value="${dbms}">
            <case value="hsqldb">
                <property name="hsqldb" value="hsqldb" />
            </case>
            <default>
                <property name="mysql" value="mysql" />
            </default>
        </switch>
        
    </target>
    <commit_msg>TOOLS-71 : Add support of "shutdown=true" for HSQL (regex)<commit_after><project name="Lutece - Database Initialisation" default="specific" basedir=".">
    
    <macrodef name="runsql">
        <attribute name="sql.driver" />
        <attribute name="sql.url" />
        <attribute name="sql.userid" />
        <attribute name="sql.password" />
        <attribute name="sql.connector.path" />
        <attribute name="sql.fileset.refid"/>
        <sequential>
            <!--echo message="sql.driver : @{sql.driver}" />
            <echo message="sql.url : @{sql.url}" />
            <echo message="sql.userid : @{sql.userid}" />
            <echo message="sql.password : @{sql.password}" />
            <echo message="sql.connector.path : @{sql.connector.path}" /-->
            <!-- Concatenate all sql files into one -->
            <echo message="Translating SQL files to fit ${dbms} requirements"/>
            <tempfile property="temp.sql" prefix="tmp_" />
            <concat destfile="${temp.sql}" fixlastline="true">
            	<fileset file="init_db/init_session_${dbms}.sql" />
                <fileset refid="@{sql.fileset.refid}"/>
            </concat>
            <propertycopy name="regexp.list" from="regexp.${dbms}.list" override="true"/>
            <for list="${regexp.list}" delimiter="," param="index">
                <sequential>
                    <propertycopy name="regexp.index" from="regexp.${dbms}.@{index}" override="true"/>
                    <propertycopy name="replace.index" from="replace.${dbms}.@{index}" override="true"/>
                    <echo message=" ====== Applying rule @{index} ${regexp.index} => ${replace.index}" />
                    <replaceregexp file="${temp.sql}" match="${regexp.index}"
                                   replace="${replace.index}" byline="true" flags="gi" />
                </sequential>
            </for>
            <sql driver="@{sql.driver}"
                 url="@{sql.url}"
                 userid="@{sql.userid}" 
                 password="@{<PASSWORD>}"
                 classpath="@{sql.connector.path}"
                 onerror="${on_sql_error}"
                 encoding="${db.encoding}"
            >
                <fileset file="${temp.sql}"/>
            </sql>
            <delete file="${temp.sql}" verbose="true" />
        </sequential>
    </macrodef>
    
    <macrodef name="getdbms">
        <attribute name="dbms.url"/>
        <attribute name="property"/>
        <sequential>
        <propertyregex property="@{property}"
                       input="@{dbms.url}"
                       regexp="jdbc:(.*?):.*"
                       select="\1"
                       casesensitive="false" />
        </sequential>
    </macrodef>
    <regexp id="regexp.mysql.url" pattern="(.*)/(.*)\?(.*)" />
    <regexp id="regexp.hsqldb.url" pattern=".*(:|/)(.*);" />
    
    <target name="init" description="Prepare the database by creating it and inserting data">
        <echo message="Preparing the database(s) by creating it and inserting data" />
        
        <!-- Property file -->
        <property file="build.properties" />
        <property name="db.properties.path" value="../conf/db.properties"/>
        
        <!-- Webapp database pool configuration file -->
        <property file="${db.properties.path}" />
        <getdbms dbms.url="${portal.url}" property="dbms" />
        <!--propertyregex property="dbms"
                       input="${portal.url}"
                       regexp="jdbc:(.*?):.*"
                       select="\1"
                       casesensitive="false" /-->
        <switch value="${dbms}">
            <case value="hsqldb">
                <property name="hsqldb" value="hsqldb" />
            </case>
            <default>
                <property name="mysql" value="mysql" />
            </default>
        </switch>
        
    </target>
    
{'fraction_non_alphanumeric': 0.1785345717234262, 'fraction_numerical': 0.0007739938080495357, 'mean_word_length': 1.749290780141844, 'pattern_counts': {'":': 0, '<': 131, '<?xml version=': 0, '>': 133, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '2594695', 'n_tokens_mistral': 2159, 'n_tokens_neox': 2079, 'n_words': 385}