<?xml version="1.0" encoding="ISO-8859-1"?>
<persistence-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="../../../../defs/config-metier/Persistence.xsd">
    <layer name="mysql" persistence-model="xemelios-sql">
        <document id="ref-collec-spl" repository-import-xslt-file="">
            <table base-name="REF_COLL_SPL_LIST_BC" type="list-bc" version="1">
                CREATE TABLE IF NOT EXISTS ${base-name} ( 
                    COLLECTIVITE VARCHAR(15) NOT NULL, 
                    BUDGET VARCHAR(24) NOT NULL, 
                    BUDGET_LIB VARCHAR(200), 
                    COLLECTIVITE_LIB VARCHAR(200), 
                    INITIAL_DOC_NAME VARCHAR(100) NOT NULL, 
                    INDEX IX_${base-name}_BC (COLLECTIVITE,BUDGET) 
                ) TYPE MYISAM 
            </table>
            <etat id="Referentiel" import-xslt-file="ref-collec-spl/ref-collec-spl-import-mysql.xsl">
                
                <table type="document" base-name="REF_COLL_SPL_DOCUMENTS" version="1">
                    CREATE TABLE IF NOT EXISTS ${base-name} ( 
                    COLLECTIVITE VARCHAR(15) NOT NULL, 
                    BUDGET VARCHAR(24) NOT NULL, 
                    INITIAL_DOC_NAME VARCHAR(100) NOT NULL, 
                    DOC_ID VARCHAR(100) NOT NULL, 
                    DOC LONGBLOB, 
                    ENCODING VARCHAR(20), 
                    INDEX IX_${base-name}_BC (COLLECTIVITE,BUDGET,DOC_ID) 
                    ) TYPE MYISAM
                </table>
                <table type="index" id="REFERENTIEL_COLLECTIVITESSPL_COLLECTIVITE_IX" base-name="REF_COLL_SPL_COLLECTIVITESSPL_COLL_IX" version="3" main="true">
                    CREATE TABLE IF NOT EXISTS ${base-name} ( 
                    COLLECTIVITE VARCHAR(15) NOT NULL, 
                    BUDGET VARCHAR(24) NOT NULL, 
                    DOC_ID VARCHAR(100) NOT NULL, 
                    EXERCICE INT NOT NULL,
                    BUDGET_PRINC VARCHAR(255) ,
                    CODCOLL VARCHAR(255) ,
                    IDCOLL VARCHAR(255) ,
                    CODBUDG VARCHAR(255) ,
                    CODIC VARCHAR(255) ,
                    LIBELLE VARCHAR(255) ,
                    LIBELLE_POSTE VARCHAR(255) ,
                    CODEINSEE VARCHAR(255) ,
                    JURI_FINAN VARCHAR(150) ,
                    GROUPE VARCHAR(150) ,
                    NOMENCL VARCHAR(150) ,
                    ARCHIVE CHAR(3) ,
                    INDEX IX_${base-name}_BC (COLLECTIVITE,BUDGET,DOC_ID), 
                    INDEX IX_${base-name}_DC (DOC_ID) 
                    ) TYPE MYISAM
                    <patch from-version="1">
                        <sql failonerror="false">ALTER TABLE ${base-name} ADD JURI_FINAN VARCHAR(150), ADD GROUPE VARCHAR(150), ADD NOMENCL VARCHAR(150)</sql>
                        <sql failonerror="false">ALTER TABLE ${base-name} ADD ARCHIVE CHAR(3)</sql>
                    </patch>
                    <patch from-version="2">
                        <sql failonerror="false">ALTER TABLE ${base-name} ADD ARCHIVE CHAR(3)</sql>
                    </patch>
                    
                </table>
                
                
                <!-- CRITERIA /Referentiel/CollectivitesSPL/Collectivite -->
                <criteria id="CRI_REFERENTIEL_COLLECTIVITE_BUDGET-PRINC" type="1" sql-index-id="SQI_REFERENTIEL_COLLECTIVITE_BUDGET-PRINC">
                    <where-clause>fn:string-compare(${table}.${column},budget-princ)</where-clause>
                </criteria>
                <criteria id="CRI_REFERENTIEL_COLLECTIVITE_CODCOLL" type="1" sql-index-id="SQI_REFERENTIEL_COLLECTIVITE_CODCOLL">
                    <where-clause>fn:string-compare(${table}.${column},codColl)</where-clause>
                </criteria>
                <criteria id="CRI_REFERENTIEL_COLLECTIVITE_IDCOLL" type="1" sql-index-id="SQI_REFERENTIEL_COLLECTIVITE_IDCOLL">
                    <where-clause>fn:string-compare(${table}.${column},idColl)</where-clause>
                </criteria>
                <criteria id="CRI_REFERENTIEL_COLLECTIVITE_CODBUDG" type="1" sql-index-id="SQI_REFERENTIEL_COLLECTIVITE_CODBUDG">
                    <where-clause>fn:string-compare(${table}.${column},codBudg)</where-clause>
                </criteria>
                <criteria id="CRI_REFERENTIEL_COLLECTIVITE_CODIC" type="1" sql-index-id="SQI_REFERENTIEL_COLLECTIVITE_CODIC">
                    <where-clause>fn:string-compare(${table}.${column},codic)</where-clause>
                </criteria>
                <criteria id="CRI_REFERENTIEL_COLLECTIVITE_LIBELLE" type="1" sql-index-id="SQI_REFERENTIEL_COLLECTIVITE_LIBELLE">
                    <where-clause>fn:string-compare(${table}.${column},libelle)</where-clause>
                </criteria>
                <criteria id="CRI_REFERENTIEL_COLLECTIVITE_LIBELLE-POSTE" type="1" sql-index-id="SQI_REFERENTIEL_COLLECTIVITE_LIBELLE-POSTE">
                    <where-clause>fn:string-compare(${table}.${column},libelle-poste)</where-clause>
                </criteria>
                <criteria id="CRI_REFERENTIEL_COLLECTIVITE_CODEINSEE" type="1" sql-index-id="SQI_REFERENTIEL_COLLECTIVITE_CODEINSEE">
                    <where-clause>fn:string-compare(${table}.${column},codeInsee)</where-clause>
                </criteria>
                <criteria id="CRI_EXERCICE" sql-index-id="SQI_REFERENTIEL_REFERENTIEL_EXERCICE">
                    <where-clause>${table}.${column}##OPERATEUR:exercice####VALEUR:exercice##</where-clause>
                </criteria>
                <criteria id="juriFi" sql-index-id="SQI_JURI_FI">
                    <where-clause>fn:string-compare(${table}.${column},juriFi)</where-clause>
                </criteria>
                <criteria id="groupe" sql-index-id="SQI_GROUPE">
                    <where-clause>fn:string-compare(${table}.${column},groupe)</where-clause>
                </criteria>
                <criteria id="nomencl" sql-index-id="SQI_NOMENCL">
                    <where-clause>fn:string-compare(${table}.${column},nomencl)</where-clause>
                </criteria>
                <criteria id="archive" sql-index-id="SQI_ARCHIVE">
                    <where-clause>${table}.${column}='##VALEUR:archive##'</where-clause>
                </criteria>
                
                
                
                <!-- SQL-INDEX /Referentiel -->
                <sql-index id="SQI_REFERENTIEL_REFERENTIEL_EXERCICE" path="/n:Referentiel/n:Exercice/text()" datatype="integer" column="EXERCICE" table="REFERENTIEL_COLLECTIVITESSPL_COLLECTIVITE_IX"/>
                
                <!-- SQL-INDEX /Referentiel/CollectivitesSPL/Collectivite -->
                <sql-index id="SQI_REFERENTIEL_COLLECTIVITE_BUDGET-PRINC" path="/n:Referentiel/n:CollectivitesSPL/n:Collectivite/@budget-princ" datatype="string" column="BUDGET_PRINC" table="REFERENTIEL_COLLECTIVITESSPL_COLLECTIVITE_IX" format="uppercase" />
                <sql-index id="SQI_REFERENTIEL_COLLECTIVITE_CODCOLL" path="/n:Referentiel/n:CollectivitesSPL/n:Collectivite/@codColl" datatype="string" column="CODCOLL" table="REFERENTIEL_COLLECTIVITESSPL_COLLECTIVITE_IX" format="uppercase" />
                <sql-index id="SQI_REFERENTIEL_COLLECTIVITE_IDCOLL" path="/n:Referentiel/n:CollectivitesSPL/n:Collectivite/@idColl" datatype="string" column="IDCOLL" table="REFERENTIEL_COLLECTIVITESSPL_COLLECTIVITE_IX" format="uppercase" />
                <sql-index id="SQI_REFERENTIEL_COLLECTIVITE_CODBUDG" path="/n:Referentiel/n:CollectivitesSPL/n:Collectivite/@codBudg" datatype="string" column="CODBUDG" table="REFERENTIEL_COLLECTIVITESSPL_COLLECTIVITE_IX" format="uppercase" />
                <sql-index id="SQI_REFERENTIEL_COLLECTIVITE_CODIC" path="/n:Referentiel/n:CollectivitesSPL/n:Collectivite/@codic" datatype="string" column="CODIC" table="REFERENTIEL_COLLECTIVITESSPL_COLLECTIVITE_IX" format="uppercase" />
                <sql-index id="SQI_REFERENTIEL_COLLECTIVITE_LIBELLE" path="/n:Referentiel/n:CollectivitesSPL/n:Collectivite/@libelle" datatype="string" column="LIBELLE" table="REFERENTIEL_COLLECTIVITESSPL_COLLECTIVITE_IX" format="uppercase" />
                <sql-index id="SQI_REFERENTIEL_COLLECTIVITE_LIBELLE-POSTE" path="/n:Referentiel/n:CollectivitesSPL/n:Collectivite/@libelle-poste" datatype="string" column="LIBELLE_POSTE" table="REFERENTIEL_COLLECTIVITESSPL_COLLECTIVITE_IX" format="uppercase" />
                <sql-index id="SQI_REFERENTIEL_COLLECTIVITE_CODEINSEE" path="/n:Referentiel/n:CollectivitesSPL/n:Collectivite/@codeInsee" datatype="string" column="CODEINSEE" table="REFERENTIEL_COLLECTIVITESSPL_COLLECTIVITE_IX" format="uppercase" />
                <sql-index id="SQI_JURI_FI" path="/n:Referentiel/n:CollectivitesSPL/n:Collectivite/@juri-finan" datatype="string" column="JURI_FINAN" table="REFERENTIEL_COLLECTIVITESSPL_COLLECTIVITE_IX" format="uppercase"/>
                <sql-index id="SQI_GROUPE" path="/n:Referentiel/n:CollectivitesSPL/n:Collectivite/@groupe" datatype="string" column="GROUPE" table="REFERENTIEL_COLLECTIVITESSPL_COLLECTIVITE_IX" format="uppercase"/>
                <sql-index id="SQI_NOMENCL" path="/n:Referentiel/n:CollectivitesSPL/n:Collectivite/@nomencl" datatype="string" column="NOMENCL" table="REFERENTIEL_COLLECTIVITESSPL_COLLECTIVITE_IX" format="uppercase"/>
                <sql-index id="SQI_ARCHIVE" table="REFERENTIEL_COLLECTIVITESSPL_COLLECTIVITE_IX" column="ARCHIVE" path="/n:Referentiel/n:CollectivitesSPL/n:Collectivite/@archive" datatype="string"/>
            </etat>
        </document>
        
    </layer>
</persistence-config>
