OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 180 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
132 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
182 ilm 4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
132 ilm 5
 *
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 package org.openconcerto.erp.config;
15
 
156 ilm 16
import org.openconcerto.erp.config.DsnBrutCode.DsnTypeCodeBrut;
132 ilm 17
import org.openconcerto.sql.model.DBRoot;
18
import org.openconcerto.sql.model.SQLBase;
142 ilm 19
import org.openconcerto.sql.model.SQLName;
132 ilm 20
import org.openconcerto.sql.model.SQLRow;
21
import org.openconcerto.sql.model.SQLRowListRSH;
22
import org.openconcerto.sql.model.SQLRowValues;
23
import org.openconcerto.sql.model.SQLSelect;
24
import org.openconcerto.sql.model.SQLSyntax;
25
import org.openconcerto.sql.model.SQLTable;
26
import org.openconcerto.sql.model.Where;
27
import org.openconcerto.sql.request.Inserter;
28
import org.openconcerto.sql.request.Inserter.Insertion;
142 ilm 29
import org.openconcerto.sql.request.UpdateBuilder;
132 ilm 30
import org.openconcerto.sql.utils.AlterTable;
31
import org.openconcerto.sql.utils.ReOrder;
32
import org.openconcerto.sql.utils.SQLCreateTable;
33
import org.openconcerto.utils.Tuple2;
156 ilm 34
import org.openconcerto.utils.Tuple3;
132 ilm 35
 
36
import java.sql.SQLException;
37
import java.util.ArrayList;
38
import java.util.Arrays;
142 ilm 39
import java.util.HashMap;
132 ilm 40
import java.util.List;
142 ilm 41
import java.util.Map;
132 ilm 42
 
43
public class DSNInstallationUtils {
44
 
45
    private void insertUndef(final SQLCreateTable ct) throws SQLException {
46
        // check that we can use insertReturnFirstField()
47
        if (ct.getPrimaryKey().size() != 1)
48
            throw new IllegalStateException("Not one and only one field in the PK : " + ct.getPrimaryKey());
49
        final Insertion<?> insertion = new Inserter(ct).insertReturnFirstField("(" + SQLBase.quoteIdentifier(SQLSyntax.ORDER_NAME) + ") VALUES(" + ReOrder.MIN_ORDER + ")", false);
50
        assert insertion.getCount() == 1;
51
        if (insertion.getRows().size() != 1)
52
            throw new IllegalStateException("Missing ID " + insertion.getRows());
53
        SQLTable.setUndefID(ct.getRoot().getSchema(), ct.getName(), ((Number) insertion.getRows().get(0)).intValue());
54
    }
55
 
56
    private void insertValues(List<Tuple2<String, String>> values, SQLTable table) throws SQLException {
142 ilm 57
        SQLSelect sel = new SQLSelect();
58
        sel.addSelect(table.getField("CODE"));
182 ilm 59
        List<String> codes = (List<String>) table.getDBSystemRoot().getDataSource().executeCol(sel.asString());
132 ilm 60
        for (Tuple2<String, String> tuple2 : values) {
142 ilm 61
            if (!codes.contains(tuple2.get0())) {
62
                SQLRowValues rowVals = new SQLRowValues(table);
63
                rowVals.put("CODE", tuple2.get0());
64
                rowVals.put("NOM", tuple2.get1());
65
                rowVals.commit();
66
            }
132 ilm 67
        }
68
    }
69
 
70
    public void updateDSNCommonTable(final DBRoot root) throws SQLException {
71
 
72
        SQLTable societeCommonT = root.getTable("SOCIETE_COMMON");
73
        if (!societeCommonT.contains("IBAN")) {
74
            AlterTable t = new AlterTable(societeCommonT);
75
            t.addVarCharColumn("IBAN", 256);
76
            t.addVarCharColumn("BIC", 256);
77
            root.getBase().getDataSource().execute(t.asString());
78
            root.refetchTable("SOCIETE_COMMON");
79
            root.getSchema().updateVersion();
80
        }
81
        if (!societeCommonT.contains("ORG_PROTECTION_SOCIAL_ID")) {
82
            AlterTable t = new AlterTable(societeCommonT);
83
            t.addVarCharColumn("ORG_PROTECTION_SOCIAL_ID", 256);
84
            root.getBase().getDataSource().execute(t.asString());
85
            root.refetchTable("SOCIETE_COMMON");
86
            root.getSchema().updateVersion();
87
        }
88
 
182 ilm 89
        if (!societeCommonT.contains("ORG_PROTECTION_SOCIAL_ID")) {
90
            AlterTable t = new AlterTable(societeCommonT);
91
            t.addVarCharColumn("ORG_PROTECTION_SOCIAL_ID", 256);
92
            root.getBase().getDataSource().execute(t.asString());
93
            root.refetchTable("SOCIETE_COMMON");
94
            root.getSchema().updateVersion();
95
        }
96
 
132 ilm 97
        SQLTable tableRubCot = root.getTable("RUBRIQUE_COTISATION");
98
        if (!tableRubCot.contains("ASSIETTE_PLAFONNEE")) {
99
            AlterTable tableRub = new AlterTable(tableRubCot);
100
            tableRub.addBooleanColumn("ASSIETTE_PLAFONNEE", false, false);
101
            root.getBase().getDataSource().execute(tableRub.asString());
102
            root.refetchTable("RUBRIQUE_COTISATION");
103
            root.getSchema().updateVersion();
104
        }
105
 
144 ilm 106
        if (!tableRubCot.contains("TAXABLE_CM")) {
107
            AlterTable tableRub = new AlterTable(tableRubCot);
108
            tableRub.addBooleanColumn("TAXABLE_CM", Boolean.FALSE, false);
109
            root.getBase().getDataSource().execute(tableRub.asString());
110
            root.refetchTable("RUBRIQUE_COTISATION");
111
            root.getSchema().updateVersion();
112
        }
113
 
132 ilm 114
        if (!root.contains("CODE_CAISSE_TYPE_RUBRIQUE")) {
115
            final SQLCreateTable createTableCode = new SQLCreateTable(root, "CODE_CAISSE_TYPE_RUBRIQUE");
116
            createTableCode.addVarCharColumn("CODE", 25);
117
            createTableCode.addVarCharColumn("NOM", 512);
118
            createTableCode.addVarCharColumn("CAISSE_COTISATION", 512);
119
 
120
            try {
121
                root.getBase().getDataSource().execute(createTableCode.asString());
122
                insertUndef(createTableCode);
123
                root.refetchTable("CODE_CAISSE_TYPE_RUBRIQUE");
124
 
125
                final SQLTable table = root.getTable("CODE_CAISSE_TYPE_RUBRIQUE");
126
 
127
                DsnUrssafCode codeUrssaf = new DsnUrssafCode();
128
                codeUrssaf.insertCode(table);
129
 
130
                List<String> tableRubName = Arrays.asList("RUBRIQUE_BRUT", "RUBRIQUE_COTISATION", "RUBRIQUE_NET");
131
                for (String t : tableRubName) {
132
                    AlterTable tableRub = new AlterTable(root.getTable(t));
133
                    tableRub.addForeignColumn("ID_CODE_CAISSE_TYPE_RUBRIQUE", table);
134
                    root.getBase().getDataSource().execute(tableRub.asString());
135
                    root.refetchTable(t);
136
                }
137
                root.getSchema().updateVersion();
138
 
139
            } catch (SQLException ex) {
140
                throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_CAISSE_TYPE_RUBRIQUE", ex);
141
            }
142
        }
143
 
144
        if (!root.contains("MOTIF_ARRET_TRAVAIL")) {
145
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "MOTIF_ARRET_TRAVAIL");
146
            createTableMotif.addVarCharColumn("CODE", 25);
147
            createTableMotif.addVarCharColumn("NOM", 512);
148
 
149
            try {
150
                root.getBase().getDataSource().execute(createTableMotif.asString());
151
                insertUndef(createTableMotif);
152
                root.refetchTable("MOTIF_ARRET_TRAVAIL");
153
                root.getSchema().updateVersion();
154
 
155
                final SQLTable table = root.getTable("MOTIF_ARRET_TRAVAIL");
156
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
157
                v.add(Tuple2.create("01", "maladie"));
158
                v.add(Tuple2.create("02", "maternité /adoption"));
159
                v.add(Tuple2.create("03", "paternité / accueil de l’enfant"));
160
                v.add(Tuple2.create("04", "congé suite à un accident de trajet"));
161
                v.add(Tuple2.create("05", "congé suite à maladie professionnelle"));
162
                v.add(Tuple2.create("06", "congé suite à accident de travail ou de service"));
163
                v.add(Tuple2.create("07", "femme enceinte dispensée de travail"));
164
                v.add(Tuple2.create("99", "annulation"));
165
 
166
                insertValues(v, table);
167
            } catch (SQLException ex) {
168
                throw new IllegalStateException("Erreur lors de la création de la table " + "MOTIF_ARRET_TRAVAIL", ex);
169
            }
170
        }
182 ilm 171
 
180 ilm 172
        if (!root.contains("DIPLOME_PREPARE")) {
173
            final SQLCreateTable createTableDiplome = new SQLCreateTable(root, "DIPLOME_PREPARE");
174
            createTableDiplome.addVarCharColumn("CODE", 25);
175
            createTableDiplome.addVarCharColumn("NOM", 512);
132 ilm 176
 
180 ilm 177
            try {
178
                root.getBase().getDataSource().execute(createTableDiplome.asString());
179
                insertUndef(createTableDiplome);
180
                root.refetchTable("DIPLOME_PREPARE");
181
                root.getSchema().updateVersion();
182
 
183
                final SQLTable table = root.getTable("DIPLOME_PREPARE");
184
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
185
                v.add(Tuple2.create("03", "Niveau de formation équivalent au CAP (certificat d'aptitude professionnelle) ou au BEP (brevet d'études professionnelles)"));
186
                v.add(Tuple2.create("04", "Formation de niveau du bac (général, technologique ou professionnel), du brevet de technicien (BT) ou du brevet professionnel"));
187
                v.add(Tuple2.create("05", "Formation de niveau bac+2 : licence 2, BTS (brevet de technicien supérieur), DUT (diplôme universitaire de technologie), etc."));
188
                v.add(Tuple2.create("06", "Formation de niveau bac+3 et bac+4 : licence 3, licence professionnelle, master 1, etc."));
189
                v.add(Tuple2.create("07", "Formation de niveau bac+5 : master 2, diplôme d'études approfondies, diplôme d'études supérieures spécialisées, diplôme d'ingénieur, etc."));
190
                v.add(Tuple2.create("08", "Formation de niveau bac+8 : doctorat, habilitation à diriger des recherches, etc. "));
191
 
192
                insertValues(v, table);
193
            } catch (SQLException ex) {
194
                throw new IllegalStateException("Erreur lors de la création de la table " + "DIPLOME_PREPARE", ex);
195
            }
196
        }
197
 
142 ilm 198
        if (!root.contains("TYPE_PREAVIS")) {
199
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "TYPE_PREAVIS");
200
            createTableMotif.addVarCharColumn("CODE", 25);
201
            createTableMotif.addVarCharColumn("NOM", 512);
202
 
203
            try {
204
                root.getBase().getDataSource().execute(createTableMotif.asString());
205
                insertUndef(createTableMotif);
206
                root.refetchTable("TYPE_PREAVIS");
207
                root.getSchema().updateVersion();
208
 
209
                final SQLTable table = root.getTable("TYPE_PREAVIS");
210
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
211
                v.add(Tuple2.create("01", "préavis effectué et payé"));
212
                v.add(Tuple2.create("02", "préavis non effectué et payé"));
213
                v.add(Tuple2.create("03", "préavis non effectué et non payé"));
214
                v.add(Tuple2.create("10", "préavis non effectué non payé dans le cadre d’un contrat de sécurisation professionnelle (CSP)"));
215
                v.add(Tuple2.create("50", "préavis non effectué et payé dans le cadre d’un congé de reclassement"));
216
                v.add(Tuple2.create("51", "préavis non effectué et payé dans le cadre d’un congé de mobilité"));
217
                v.add(Tuple2.create("60", "Délai de prévenance"));
218
                v.add(Tuple2.create("90", "pas de clause de préavis applicable"));
219
 
220
                insertValues(v, table);
221
            } catch (SQLException ex) {
222
                throw new IllegalStateException("Erreur lors de la création de la table " + "TYPE_PREAVIS", ex);
223
            }
224
        }
225
 
132 ilm 226
        if (!root.contains("CODE_BASE_ASSUJETTIE")) {
227
            final SQLCreateTable createTableCodeBase = new SQLCreateTable(root, "CODE_BASE_ASSUJETTIE");
228
            createTableCodeBase.addVarCharColumn("CODE", 25);
229
            createTableCodeBase.addVarCharColumn("NOM", 512);
230
 
231
            try {
232
                root.getBase().getDataSource().execute(createTableCodeBase.asString());
233
                insertUndef(createTableCodeBase);
234
                root.refetchTable("CODE_BASE_ASSUJETTIE");
235
                root.getSchema().updateVersion();
236
 
237
                final SQLTable table = root.getTable("CODE_BASE_ASSUJETTIE");
238
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
239
 
240
                v.add(Tuple2.create("02", "Assiette brute plafonnée"));
241
                v.add(Tuple2.create("03", "Assiette brute déplafonnée"));
242
                v.add(Tuple2.create("04", "Assiette de la contribution sociale généralisée"));
243
                v.add(Tuple2.create("07", "Assiette des contributions d'Assurance Chômage"));
244
                v.add(Tuple2.create("08", "Assiette retraite CPRP SNCF"));
245
                v.add(Tuple2.create("09", "Assiette de compensation bilatérale maladie CPRP SNCF"));
246
                v.add(Tuple2.create("10", "Base brute fiscale"));
247
                v.add(Tuple2.create("11", "Base forfaitaire soumise aux cotisations de Sécurité Sociale"));
248
                v.add(Tuple2.create("12", "Assiette du crédit d'impôt compétitivité-emploi"));
249
                v.add(Tuple2.create("13", "Assiette du forfait social à 8%"));
250
                v.add(Tuple2.create("14", "Assiette du forfait social à 20%"));
251
 
252
                insertValues(v, table);
253
            } catch (SQLException ex) {
254
                throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_BASE_ASSUJETTIE", ex);
255
            }
256
        }
257
        if (!tableRubCot.contains("ID_CODE_BASE_ASSUJETTIE")) {
258
            AlterTable alterTableCot = new AlterTable(tableRubCot);
259
            alterTableCot.addForeignColumn("ID_CODE_BASE_ASSUJETTIE", root.getTable("CODE_BASE_ASSUJETTIE"));
260
            root.getBase().getDataSource().execute(alterTableCot.asString());
261
            root.refetchTable("RUBRIQUE_COTISATION");
262
            root.getSchema().updateVersion();
263
        }
264
 
265
        if (!root.contains("CODE_TYPE_RUBRIQUE_BRUT")) {
266
            final SQLCreateTable createTableCodeBase = new SQLCreateTable(root, "CODE_TYPE_RUBRIQUE_BRUT");
267
            createTableCodeBase.addVarCharColumn("CODE", 25);
268
            createTableCodeBase.addVarCharColumn("NOM", 512);
269
            createTableCodeBase.addVarCharColumn("TYPE", 512);
270
 
271
            try {
272
                root.getBase().getDataSource().execute(createTableCodeBase.asString());
273
                insertUndef(createTableCodeBase);
274
                root.refetchTable("CODE_TYPE_RUBRIQUE_BRUT");
275
                root.getSchema().updateVersion();
276
 
277
                DsnBrutCode brutCode = new DsnBrutCode();
278
                brutCode.insertCode(root.getTable("CODE_TYPE_RUBRIQUE_BRUT"));
279
            } catch (SQLException ex) {
280
                throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_BASE_ASSUJETTIE", ex);
281
            }
282
        }
283
 
284
        SQLTable tableRubBrut = root.getTable("RUBRIQUE_BRUT");
285
        if (!tableRubBrut.contains("ID_CODE_TYPE_RUBRIQUE_BRUT")) {
286
            AlterTable alterTableBrut = new AlterTable(tableRubBrut);
287
            alterTableBrut.addForeignColumn("ID_CODE_TYPE_RUBRIQUE_BRUT", root.getTable("CODE_TYPE_RUBRIQUE_BRUT"));
288
            root.getBase().getDataSource().execute(alterTableBrut.asString());
289
            root.refetchTable("RUBRIQUE_BRUT");
290
            root.getSchema().updateVersion();
291
        }
292
 
144 ilm 293
        if (!tableRubBrut.contains("COTISABLE")) {
294
            AlterTable alterTableBrut = new AlterTable(tableRubBrut);
295
            alterTableBrut.addBooleanColumn("COTISABLE", Boolean.TRUE, false);
296
            root.getBase().getDataSource().execute(alterTableBrut.asString());
297
            root.refetchTable("RUBRIQUE_BRUT");
298
            root.getSchema().updateVersion();
299
        }
300
 
301
        if (!tableRubBrut.contains("TAXABLE_CM")) {
302
            AlterTable alterTableBrut = new AlterTable(tableRubBrut);
303
            alterTableBrut.addBooleanColumn("TAXABLE_CM", Boolean.TRUE, false);
304
            root.getBase().getDataSource().execute(alterTableBrut.asString());
305
            root.refetchTable("RUBRIQUE_BRUT");
306
            root.getSchema().updateVersion();
307
        }
308
 
177 ilm 309
        if (!tableRubBrut.contains("CSG_NORMAL")) {
310
            AlterTable alterTableBrut = new AlterTable(tableRubBrut);
311
            alterTableBrut.addBooleanColumn("CSG_NORMAL", Boolean.TRUE, false);
312
            root.getBase().getDataSource().execute(alterTableBrut.asString());
313
            root.refetchTable("RUBRIQUE_BRUT");
314
            root.getSchema().updateVersion();
315
        }
316
        if (!tableRubBrut.contains("CSG_REDUIT")) {
317
            AlterTable alterTableBrut = new AlterTable(tableRubBrut);
318
            alterTableBrut.addBooleanColumn("CSG_REDUIT", Boolean.FALSE, false);
319
            root.getBase().getDataSource().execute(alterTableBrut.asString());
320
            root.refetchTable("RUBRIQUE_BRUT");
321
            root.getSchema().updateVersion();
322
        }
323
 
142 ilm 324
        SQLTable tableRubNet = root.getTable("RUBRIQUE_NET");
325
        if (!tableRubNet.contains("ID_CODE_TYPE_RUBRIQUE_BRUT")) {
326
 
327
            AlterTable alterTableNet = new AlterTable(tableRubNet);
328
            alterTableNet.addForeignColumn("ID_CODE_TYPE_RUBRIQUE_BRUT", root.getTable("CODE_TYPE_RUBRIQUE_BRUT"));
329
            root.getBase().getDataSource().execute(alterTableNet.asString());
330
            root.refetchTable("RUBRIQUE_NET");
331
            root.getSchema().updateVersion();
332
        }
333
 
132 ilm 334
        if (!root.contains("DSN_REGIME_LOCAL")) {
335
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "DSN_REGIME_LOCAL");
336
            createTableMotif.addVarCharColumn("CODE", 25);
337
            createTableMotif.addVarCharColumn("NOM", 512);
338
 
339
            try {
340
                root.getBase().getDataSource().execute(createTableMotif.asString());
341
                insertUndef(createTableMotif);
342
                root.refetchTable("DSN_REGIME_LOCAL");
343
                root.getSchema().updateVersion();
344
 
345
                final SQLTable table = root.getTable("DSN_REGIME_LOCAL");
346
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
347
                v.add(Tuple2.create("99", "non applicable"));
348
                v.add(Tuple2.create("01", "régime local Alsace Moselle"));
349
                insertValues(v, table);
350
            } catch (SQLException ex) {
351
                throw new IllegalStateException("Erreur lors de la création de la table " + "DSN_REGIME_LOCAL", ex);
352
            }
353
        }
354
 
355
        if (!root.contains("CONTRAT_MODALITE_TEMPS")) {
356
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CONTRAT_MODALITE_TEMPS");
357
            createTableMotif.addVarCharColumn("CODE", 25);
358
            createTableMotif.addVarCharColumn("NOM", 512);
359
 
360
            try {
361
                root.getBase().getDataSource().execute(createTableMotif.asString());
362
                insertUndef(createTableMotif);
363
                root.refetchTable("CONTRAT_MODALITE_TEMPS");
364
                root.getSchema().updateVersion();
365
 
366
                final SQLTable table = root.getTable("CONTRAT_MODALITE_TEMPS");
367
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
368
                v.add(Tuple2.create("10", "temps plein"));
369
                v.add(Tuple2.create("20", "temps partiel"));
370
                v.add(Tuple2.create("21", "temps partiel thérapeutique"));
371
                v.add(Tuple2.create("99", "salarié non concerné"));
372
                insertValues(v, table);
373
            } catch (SQLException ex) {
374
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_MODALITE_TEMPS", ex);
375
            }
376
        }
377
 
378
        if (!root.contains("CONTRAT_REGIME_MALADIE")) {
379
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CONTRAT_REGIME_MALADIE");
380
            createTableMotif.addVarCharColumn("CODE", 25);
381
            createTableMotif.addVarCharColumn("NOM", 512);
382
 
383
            try {
384
                root.getBase().getDataSource().execute(createTableMotif.asString());
385
                insertUndef(createTableMotif);
386
                root.refetchTable("CONTRAT_REGIME_MALADIE");
387
                root.getSchema().updateVersion();
388
 
389
                final SQLTable table = root.getTable("CONTRAT_REGIME_MALADIE");
390
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
391
                v.add(Tuple2.create("134", "régime spécial de la SNCF"));
392
                v.add(Tuple2.create("135", "régime spécial de la RATP"));
393
                v.add(Tuple2.create("136", "établissement des invalides de la marine (ENIM)"));
394
                v.add(Tuple2.create("137", "mineurs ou assimilés (CANMSS)"));
395
                v.add(Tuple2.create("138", "militaires de carrière (CNMSS)"));
396
                v.add(Tuple2.create("140", "clercs et employés de notaires (CRPCEN)"));
397
                v.add(Tuple2.create("141", "chambre de commerce et d'industrie de Paris"));
398
                v.add(Tuple2.create("144", "Assemblée Nationale"));
399
                v.add(Tuple2.create("145", "Sénat"));
400
                v.add(Tuple2.create("146", "port autonome de Bordeaux"));
401
                v.add(Tuple2.create("147", "industries électriques et gazières (CAMIEG)"));
402
                v.add(Tuple2.create("149", "régimes des cultes (CAVIMAC)"));
403
                v.add(Tuple2.create("200", "régime général (CNAM)"));
404
                v.add(Tuple2.create("300", "régime agricole (MSA)"));
405
                v.add(Tuple2.create("400", "régime spécial Banque de France"));
406
                v.add(Tuple2.create("900", "autre régime (réservé Polynésie Française, Nouvelle Calédonie)"));
407
                v.add(Tuple2.create("999", "autre"));
408
 
409
                insertValues(v, table);
410
            } catch (SQLException ex) {
411
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_REGIME_MALADIE", ex);
412
            }
413
        }
414
 
415
        if (!root.contains("CONTRAT_REGIME_VIEILLESSE")) {
416
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CONTRAT_REGIME_VIEILLESSE");
417
            createTableMotif.addVarCharColumn("CODE", 25);
418
            createTableMotif.addVarCharColumn("NOM", 512);
419
 
420
            try {
421
                root.getBase().getDataSource().execute(createTableMotif.asString());
422
                insertUndef(createTableMotif);
423
                root.refetchTable("CONTRAT_REGIME_VIEILLESSE");
424
                root.getSchema().updateVersion();
425
 
426
                final SQLTable table = root.getTable("CONTRAT_REGIME_VIEILLESSE");
427
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
428
                v.add(Tuple2.create("120", "retraite des agents des collectivités locales (CNRACL)"));
429
                v.add(Tuple2.create("121", "pensions des ouvriers des établissements industriels de l'Etat (FSPOEIE)"));
430
                v.add(Tuple2.create("122", "pensions civiles et militaires de retraite de l'Etat (SRE)"));
431
                v.add(Tuple2.create("134", "régime spécial de la SNCF"));
432
                v.add(Tuple2.create("135", "régime spécial de la RATP"));
433
                v.add(Tuple2.create("136", "établissement des invalides de la marine (ENIM)"));
434
                v.add(Tuple2.create("137", "mineurs ou assimilés (fonds Caisse des Dépôts)"));
435
                v.add(Tuple2.create("139", "Banque de France"));
436
                v.add(Tuple2.create("140", "clercs et employés de notaires (CRPCEN)"));
437
                v.add(Tuple2.create("141", "chambre de commerce et d'industrie de Paris"));
438
                v.add(Tuple2.create("144", "Assemblée Nationale"));
439
                v.add(Tuple2.create("145", "Sénat"));
440
                v.add(Tuple2.create("147", "industries électriques et gazières (CNIEG)"));
441
                v.add(Tuple2.create("149", "régime des cultes (CAVIMAC)"));
442
                v.add(Tuple2.create("157", "régime de retraite des avocats (CNBF)"));
443
                v.add(Tuple2.create("158", "SEITA"));
444
                v.add(Tuple2.create("159", "Comédie Française"));
445
                v.add(Tuple2.create("160", "Opéra de Paris"));
446
                v.add(Tuple2.create("200", "régime général (CNAV)"));
447
                v.add(Tuple2.create("300", "régime agricole (MSA)"));
448
                v.add(Tuple2.create("900", "autre régime (réservé Polynésie Française, Nouvelle Calédonie, Principauté de Monaco)"));
449
                v.add(Tuple2.create("903", "salariés étrangers exemptés d'affiliation pour le risque vieillesse"));
450
                v.add(Tuple2.create("999", "cas particuliers d'affiliation"));
451
 
452
                insertValues(v, table);
453
            } catch (SQLException ex) {
454
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_REGIME_VIEILLESSE", ex);
455
            }
456
        }
457
 
458
        if (!root.contains("CONTRAT_MOTIF_RECOURS")) {
459
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CONTRAT_MOTIF_RECOURS");
460
            createTableMotif.addVarCharColumn("CODE", 25);
461
            createTableMotif.addVarCharColumn("NOM", 512);
462
 
463
            try {
464
                root.getBase().getDataSource().execute(createTableMotif.asString());
465
                insertUndef(createTableMotif);
466
                root.refetchTable("CONTRAT_MOTIF_RECOURS");
467
                root.getSchema().updateVersion();
468
 
469
                final SQLTable table = root.getTable("CONTRAT_MOTIF_RECOURS");
470
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
471
                v.add(Tuple2.create("01", "Remplacement d'un salarié"));
472
                v.add(Tuple2.create("02", "Accroissement temporaire de l'activité de l'entreprise"));
473
                v.add(Tuple2.create("03", "Emplois à caractère saisonnier"));
474
                v.add(Tuple2.create("04", "Contrat vendanges"));
475
                v.add(Tuple2.create("05", "Contrat à durée déterminée d’usage"));
476
                v.add(Tuple2.create("06", "Contrat à durée déterminée à objet défini"));
477
                v.add(Tuple2.create("07", "Remplacement d'un chef d'entreprise"));
478
                v.add(Tuple2.create("08", "Remplacement du chef d'une exploitation agricole"));
479
                v.add(Tuple2.create("09", "Recrutement de personnes sans emploi rencontrant des difficultés sociales et professionnelles particulières"));
480
                v.add(Tuple2.create("10", "Complément de formation professionnelle au salarié"));
481
                v.add(Tuple2.create("11",
482
                        "Formation professionnelle au salarié par la voie de l'apprentissage, en vue de l'obtention d'une qualification professionnelle sanctionnée par un diplôme ou un titre à finalité professionnelle enregistré au répertoire national des certifications professionnelles"));
483
                v.add(Tuple2.create("12", "Remplacement d’un salarié passé provisoirement à temps partiel"));
484
                v.add(Tuple2.create("13", "Attente de la suppression définitive du poste du salarié ayant quitté définitivement l’entreprise"));
485
                insertValues(v, table);
486
            } catch (SQLException ex) {
487
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_MOTIF_RECOURS", ex);
488
            }
489
        }
490
 
491
        if (!root.contains("CONTRAT_DETACHE_EXPATRIE")) {
492
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CONTRAT_DETACHE_EXPATRIE");
493
            createTableMotif.addVarCharColumn("CODE", 25);
494
            createTableMotif.addVarCharColumn("NOM", 512);
495
 
496
            try {
497
                root.getBase().getDataSource().execute(createTableMotif.asString());
498
                insertUndef(createTableMotif);
499
                root.refetchTable("CONTRAT_DETACHE_EXPATRIE");
500
                root.getSchema().updateVersion();
501
 
502
                final SQLTable table = root.getTable("CONTRAT_DETACHE_EXPATRIE");
503
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
504
                v.add(Tuple2.create("01", "Détaché"));
505
                v.add(Tuple2.create("02", "Expatrié"));
506
                v.add(Tuple2.create("03", "Frontalier"));
507
                v.add(Tuple2.create("99", "Salarié non concerné"));
508
                insertValues(v, table);
509
            } catch (SQLException ex) {
510
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_DETACHE_EXPATRIE", ex);
511
            }
512
        }
513
 
514
        if (!root.contains("DSN_NATURE")) {
515
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "DSN_NATURE");
516
            createTableMotif.addVarCharColumn("CODE", 25);
517
            createTableMotif.addVarCharColumn("NOM", 512);
518
 
519
            try {
520
                root.getBase().getDataSource().execute(createTableMotif.asString());
521
                insertUndef(createTableMotif);
522
                root.refetchTable("DSN_NATURE");
523
                root.getSchema().updateVersion();
524
 
525
                final SQLTable table = root.getTable("DSN_NATURE");
526
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
527
                v.add(Tuple2.create("01", "DSN Mensuelle"));
528
                v.add(Tuple2.create("02", "Signalement Fin du contrat de travail"));
529
                v.add(Tuple2.create("04", "Signalement Arrêt de travail"));
530
                v.add(Tuple2.create("05", "Signalement Reprise suite à arrêt de travail"));
531
                v.add(Tuple2.create("06", "DSN reprise d'historique"));
532
                insertValues(v, table);
533
            } catch (SQLException ex) {
534
                throw new IllegalStateException("Erreur lors de la création de la table " + "DSN_NATURE", ex);
535
            }
536
        }
537
 
538
        if (!root.contains("DSN_TYPE")) {
539
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "DSN_TYPE");
540
            createTableMotif.addVarCharColumn("CODE", 25);
541
            createTableMotif.addVarCharColumn("NOM", 512);
542
 
543
            try {
544
                root.getBase().getDataSource().execute(createTableMotif.asString());
545
                insertUndef(createTableMotif);
546
                root.refetchTable("DSN_TYPE");
547
                root.getSchema().updateVersion();
548
 
549
                final SQLTable table = root.getTable("DSN_TYPE");
550
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
551
                v.add(Tuple2.create("01", "déclaration normale"));
552
                v.add(Tuple2.create("02", "déclaration normale néant"));
553
                v.add(Tuple2.create("03", "déclaration annule et remplace intégral"));
554
                v.add(Tuple2.create("04", "déclaration annule"));
555
                v.add(Tuple2.create("05", "annule et remplace néant"));
556
                insertValues(v, table);
557
            } catch (SQLException ex) {
558
                throw new IllegalStateException("Erreur lors de la création de la table " + "DSN_TYPE", ex);
559
            }
560
        }
561
 
562
        if (!root.contains("CONTRAT_DISPOSITIF_POLITIQUE")) {
563
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CONTRAT_DISPOSITIF_POLITIQUE");
564
            createTableMotif.addVarCharColumn("CODE", 25);
565
            createTableMotif.addVarCharColumn("NOM", 512);
566
 
567
            try {
568
                root.getBase().getDataSource().execute(createTableMotif.asString());
569
                insertUndef(createTableMotif);
570
                root.refetchTable("CONTRAT_DISPOSITIF_POLITIQUE");
571
                root.getSchema().updateVersion();
572
 
573
                final SQLTable table = root.getTable("CONTRAT_DISPOSITIF_POLITIQUE");
574
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
575
                v.add(Tuple2.create("21", "CUI - Contrat Initiative Emploi"));
576
                v.add(Tuple2.create("41", "CUI - Contrat d'Accompagnement dans l'Emploi"));
577
                v.add(Tuple2.create("42", "CUI - Contrat d'accès à l'emploi - DOM"));
578
                v.add(Tuple2.create("50", "Emploi d'avenir secteur marchand"));
579
                v.add(Tuple2.create("51", "Emploi d'avenir secteur non marchand"));
580
                v.add(Tuple2.create("61", "Contrat de Professionnalisation"));
581
                v.add(Tuple2.create("64", "Contrat d'apprentissage entreprises artisanales ou de moins de 11 salariés (loi du 3 janvier 1979)"));
582
                v.add(Tuple2.create("65", "Contrat d’apprentissage entreprises non inscrites au répertoire des métiers d’au moins 11 salariés (loi de 1987)"));
583
                v.add(Tuple2.create("70", "Contrat à durée déterminée pour les séniors"));
584
                v.add(Tuple2.create("71", "Contrat à durée déterminée d’insertion"));
585
                v.add(Tuple2.create("80", "Contrat de génération"));
586
                v.add(Tuple2.create("81", "Contrat d'apprentissage secteur public (Loi de 1992)"));
587
                v.add(Tuple2.create("82", "Contrat à durée indéterminée intérimaire"));
588
                v.add(Tuple2.create("99", "Non concerné"));
589
                insertValues(v, table);
590
            } catch (SQLException ex) {
591
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_DISPOSITIF_POLITIQUE", ex);
592
            }
593
        }
594
 
177 ilm 595
        if (!root.contains("CODE_AMENAGEMENT_PARTIEL")) {
596
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CODE_AMENAGEMENT_PARTIEL");
597
            createTableMotif.addVarCharColumn("CODE", 25);
598
            createTableMotif.addVarCharColumn("NOM", 512);
599
 
600
            try {
601
                root.getBase().getDataSource().execute(createTableMotif.asString());
602
                insertUndef(createTableMotif);
603
                root.refetchTable("CODE_AMENAGEMENT_PARTIEL");
604
                root.getSchema().updateVersion();
605
 
606
                final SQLTable table = root.getTable("CODE_AMENAGEMENT_PARTIEL");
607
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
608
 
609
                v.add(Tuple2.create("01", "Forfait hebdomadaire"));
610
                v.add(Tuple2.create("02", "Autre temps de travail hebdomadaire"));
611
                v.add(Tuple2.create("03", "Equivalent à 35h - 39h (Mayotte)"));
612
                v.add(Tuple2.create("04", "Forfait mensuel"));
613
                v.add(Tuple2.create("05", "Forfait annuel en jour"));
614
                v.add(Tuple2.create("06", "Forfait annuel en heures"));
615
                v.add(Tuple2.create("07", "Cycle"));
616
                v.add(Tuple2.create("08", "Modulation"));
617
                v.add(Tuple2.create("09", "Aménagement du temps de travail (Loi du 20 août 2008)"));
618
                v.add(Tuple2.create("10", "Personnel navigant ou autres"));
619
 
620
                insertValues(v, table);
621
            } catch (SQLException ex) {
622
                throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_AMENAGEMENT_PARTIEL", ex);
623
            }
624
        }
625
 
626
        if (!root.contains("CODE_SUSPENSION")) {
627
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CODE_SUSPENSION");
628
            createTableMotif.addVarCharColumn("CODE", 25);
629
            createTableMotif.addVarCharColumn("NOM", 512);
630
 
631
            try {
632
                root.getBase().getDataSource().execute(createTableMotif.asString());
633
                insertUndef(createTableMotif);
634
                root.refetchTable("CODE_SUSPENSION");
635
                root.getSchema().updateVersion();
636
 
637
                final SQLTable table = root.getTable("CODE_SUSPENSION");
638
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
639
 
640
                v.add(Tuple2.create("112", "Invalidité catégorie 1"));
641
                v.add(Tuple2.create("114", "Invalidité catégorie 2"));
642
                v.add(Tuple2.create("116", "Invalidité catégorie 3"));
643
                v.add(Tuple2.create("200", "COP (Congés payés)"));
644
                v.add(Tuple2.create("301", "Congé de Formation Professionnelle"));
645
                v.add(Tuple2.create("501", "Congé divers non rémunéré"));
646
                v.add(Tuple2.create("507", "Chômage intempéries"));
647
                v.add(Tuple2.create("601", "Mobilité volontaire sécurisée"));
648
                v.add(Tuple2.create("602", "Chômage sans rupture de contrat"));
649
                v.add(Tuple2.create("603", "Détention provisoire"));
650
                v.add(Tuple2.create("604", "Journée de perception de l'allocation journalière de présence parentale"));
651
                v.add(Tuple2.create("605", "Congé statutaire"));
652
                v.add(Tuple2.create("606", "Détachement d'un salarié IEG en France"));
653
                v.add(Tuple2.create("607", "Congé de présence parentale"));
654
                v.add(Tuple2.create("608", "CASA"));
655
                v.add(Tuple2.create("609", "CIF (Congé Individuel de Formation)"));
656
                v.add(Tuple2.create("611", "Congé de bilan de compétences"));
657
                v.add(Tuple2.create("612", "Congé de candidat parlementaire ou élu à un mandat local"));
658
                v.add(Tuple2.create("615", "Congé de formation de cadres et d'animateurs pour la jeunesse"));
659
                v.add(Tuple2.create("617", "Congé de formation pour les salariés de moins de 25 ans"));
660
                v.add(Tuple2.create("618", "Congé de formation économique, sociale et syndicale"));
661
                v.add(Tuple2.create("620", "Congé de mobilité"));
662
                v.add(Tuple2.create("621", "Congé de participation aux instances d'emploi ou de formation professionnelle"));
663
                v.add(Tuple2.create("625", "Congé de reclassement"));
664
                v.add(Tuple2.create("626", "Congé de représentation"));
665
                v.add(Tuple2.create("627", "Congé de solidarité familiale"));
666
                v.add(Tuple2.create("628", "Congé de solidarité internationale"));
667
                v.add(Tuple2.create("630", "Congé d'enseignement ou de recherche"));
668
                v.add(Tuple2.create("631", "Congé mutualiste de formation"));
669
                v.add(Tuple2.create("632", "Congé parental d'éducation"));
670
                v.add(Tuple2.create("633", "Congé pour acquisition de la nationalité"));
671
                v.add(Tuple2.create("634", "Congé pour catastrophe naturelle"));
672
                v.add(Tuple2.create("635", "Congé pour création ou reprise d'entreprise"));
673
                v.add(Tuple2.create("636", "Congé pour enfant malade"));
674
                v.add(Tuple2.create("637", "Congé pour évènement familial"));
675
                v.add(Tuple2.create("638", "Congé pour validation des acquis de l'expérience"));
676
                v.add(Tuple2.create("639", "Congé sabbatique"));
677
                v.add(Tuple2.create("642", "Convention FNE d'aide au passage à temps partiel"));
678
                v.add(Tuple2.create("643", "Congé de conversion avec prise en charge par l'Etat"));
679
                v.add(Tuple2.create("644", "Congé de conversion sans prise en charge par l'Etat"));
680
                v.add(Tuple2.create("645", "Préretraite progressive"));
681
                v.add(Tuple2.create("646", "Préretraite d'entreprise sans rupture de contrat de travail"));
682
                v.add(Tuple2.create("647", "Réduction temps d'emploi"));
683
                v.add(Tuple2.create("648", "Conventions d'Allocations Spéciales du FNE (ASFNE)"));
684
                v.add(Tuple2.create("650", "Congé de proche aidant"));
685
                v.add(Tuple2.create("651", "Congé pour mandat parlementaire"));
686
                v.add(Tuple2.create("652", "Inaptitude temporaire liée à la grossesse"));
687
                v.add(Tuple2.create("653", "Maintien de salaire – personnel navigant de l’aéronautique civile"));
688
                v.add(Tuple2.create("654", "Inactivité temps alterné – personnel navigant de l’aéronautique civile"));
689
                v.add(Tuple2.create("655", "[FP] Détachement conduisant à pension (ECP)"));
690
                v.add(Tuple2.create("656", "[FP] Congé pour cessation anticipée d’activité du fait d’une maladie professionnelle provoquée par l’amiante"));
691
                v.add(Tuple2.create("657", "[FP] Absence concertée de travail"));
692
                v.add(Tuple2.create("658", "[FP] Congé spécial"));
693
                v.add(Tuple2.create("659", "[FP] Période d'instruction militaire ou réserve opérationnelle"));
694
                v.add(Tuple2.create("660", "[FP] Congé avec traitement période d'instruction militaire obligatoire"));
695
                v.add(Tuple2.create("661", "[FP] Congé organisations de jeunesse"));
696
                v.add(Tuple2.create("662", "[FP] Congé pour siéger auprès d’une association, d’une mutuelle, d’une instance de l’Etat ou d’une collectivité territoriale"));
697
                v.add(Tuple2.create("663", "[FP] Congé non rémunéré de 18 jours pour mandats municipaux ou départementaux ou régionaux"));
698
                v.add(Tuple2.create("664", "[FP] Congé avec traitement pour période d'activité dans la réserve de sécurité civile"));
699
                v.add(Tuple2.create("665", "[FP] Congé pour période d'activité dans la réserve sanitaire"));
700
                v.add(Tuple2.create("666", "[FP] Congé pour recherches ou conversions thématiques"));
701
                v.add(Tuple2.create("667", "[FP] Congé pour raisons opérationnelles et activités privées des sapeurs"));
702
                v.add(Tuple2.create("668", "[FP] Congé pour raisons opérationnelles cotisé des sapeurs"));
703
                v.add(Tuple2.create("669", "[FP] Congé pour difficultés opérationnelles des sapeurs"));
704
                v.add(Tuple2.create("670", "[FP] Congé pour période d'activité dans la réserve civile de la police"));
705
                v.add(Tuple2.create("671", "[FP] Exclusion temporaire de fonctions"));
706
                v.add(Tuple2.create("672", "[FP] Suspension"));
707
                v.add(Tuple2.create("673", "[FP] Absences irrégulières (service non fait)"));
708
                v.add(Tuple2.create("674", "[FP] Détachement ne conduisant pas à pension (ENCP)"));
709
                v.add(Tuple2.create("675", "[FP] Disponibilité"));
710
                v.add(Tuple2.create("676", "[FP] Disponibilité pour maladie"));
711
                v.add(Tuple2.create("677", "[FP] Disponibilité pour élever un enfant âgé de moins de 8 ans"));
712
                v.add(Tuple2.create("678", "[FP] Position hors cadres"));
713
                v.add(Tuple2.create("680", "Congé sans solde cotisés"));
714
                v.add(Tuple2.create("681", "Détachement hors IEG"));
715
                v.add(Tuple2.create("998", "Annulation"));
716
 
717
                insertValues(v, table);
718
            } catch (SQLException ex) {
719
                throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_SUSPENSION", ex);
720
            }
721
        }
722
 
132 ilm 723
        if (!root.contains("MOTIF_REPRISE_ARRET_TRAVAIL")) {
724
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "MOTIF_REPRISE_ARRET_TRAVAIL");
725
            createTableMotif.addVarCharColumn("CODE", 25);
726
            createTableMotif.addVarCharColumn("NOM", 512);
727
 
728
            try {
729
                root.getBase().getDataSource().execute(createTableMotif.asString());
730
                insertUndef(createTableMotif);
731
                root.refetchTable("MOTIF_REPRISE_ARRET_TRAVAIL");
732
                root.getSchema().updateVersion();
733
 
734
                final SQLTable table = root.getTable("MOTIF_REPRISE_ARRET_TRAVAIL");
735
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
736
                v.add(Tuple2.create("01", "reprise normale"));
737
                v.add(Tuple2.create("02", "reprise temps partiel thérapeutique"));
738
                v.add(Tuple2.create("03", "reprise temps partiel raison personnelle"));
739
                insertValues(v, table);
740
            } catch (SQLException ex) {
741
                throw new IllegalStateException("Erreur lors de la création de la table " + "MOTIF_REPRISE_ARRET_TRAVAIL", ex);
742
            }
743
        }
744
 
745
        if (!root.contains("MOTIF_FIN_CONTRAT")) {
746
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "MOTIF_FIN_CONTRAT");
747
            createTableMotif.addVarCharColumn("CODE", 25);
748
            createTableMotif.addVarCharColumn("NOM", 512);
749
 
750
            try {
751
                root.getBase().getDataSource().execute(createTableMotif.asString());
752
                insertUndef(createTableMotif);
753
                root.refetchTable("MOTIF_FIN_CONTRAT");
754
                root.getSchema().updateVersion();
755
 
756
                final SQLTable table = root.getTable("MOTIF_FIN_CONTRAT");
757
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
758
                v.add(Tuple2.create("011", "licenciement suite à liquidation judiciaire ou à redressement judiciaire"));
759
                v.add(Tuple2.create("012", "licenciement suite à fermeture définitive de l'établissement"));
760
                v.add(Tuple2.create("014", "licenciement pour motif économique"));
761
                v.add(Tuple2.create("015", "licenciement pour fin de chantier"));
762
                v.add(Tuple2.create("020", "licenciement pour autre motif"));
763
                v.add(Tuple2.create("025", "autre fin de contrat pour motif économique"));
764
                v.add(Tuple2.create("026", "rupture pour motif économique dans le cadre d’un contrat de sécurisation professionnelle CSP"));
765
                v.add(Tuple2.create("031", "fin de contrat à durée déterminée ou fin d'accueil occasionnel"));
766
                v.add(Tuple2.create("032", "fin de mission d'intérim"));
767
                v.add(Tuple2.create("033", "rupture anticipée d’un CDD ou d’un contrat de mission en cas d’inaptitude physique constatée par le médecin du travail"));
768
                v.add(Tuple2.create("034", "fin de période d'essai à l'initiative de l'employeur"));
769
                v.add(Tuple2.create("035", "fin de période d'essai à l'initiative du salarié"));
770
                v.add(Tuple2.create("036", " rupture anticipée d'un CDD, d'un contrat d'apprentissage ou d’un contrat de mission à l'initiative de l'employeur"));
771
                v.add(Tuple2.create("037", "rupture anticipée d'un CDD, d'un contrat d'apprentissage ou d’un contrat de mission à l'initiative du salarié"));
772
                v.add(Tuple2.create("038", "mise à la retraite par l'employeur"));
773
                v.add(Tuple2.create("039", "départ à la retraite à l'initiative du salarié"));
774
                v.add(Tuple2.create("043", "rupture conventionnelle"));
775
                v.add(Tuple2.create("058", "prise d'acte de la rupture de contrat de travail"));
776
                v.add(Tuple2.create("059", "démission"));
777
                v.add(Tuple2.create("065", "décès de l'employeur ou internement / conduit à un licenciement autre motif"));
778
                v.add(Tuple2.create("066", "décès du salarié / rupture force majeure"));
779
                v.add(Tuple2.create("081", "fin de contrat d'apprentissage"));
780
                v.add(Tuple2.create("082", "résiliation judiciaire du contrat de travail"));
781
                v.add(Tuple2.create("083", "rupture de contrat de travail ou d’un contrat de mission pour force majeure"));
782
                v.add(Tuple2.create("084", "rupture d'un commun accord du CDD, du contrat d'apprentissage ou d’un contrat de mission"));
783
                v.add(Tuple2.create("085", "fin de mandat"));
784
                v.add(Tuple2.create("086", "licenciement convention CATS"));
785
                v.add(Tuple2.create("087", "licenciement pour faute grave"));
786
                v.add(Tuple2.create("088", "licenciement pour faute lourde"));
787
                v.add(Tuple2.create("089", "licenciement pour force majeure"));
788
                v.add(Tuple2.create("091", "licenciement pour inaptitude physique d'origine non professionnelle"));
789
                v.add(Tuple2.create("092", "licenciement pour inaptitude physique d'origine professionnelle"));
790
                v.add(Tuple2.create("093", "licenciement suite à décision d'une autorité administrative"));
791
                v.add(Tuple2.create("094", "rupture anticipée du contrat de travail pour arrêt de tournage"));
792
                v.add(Tuple2.create("095", "rupture anticipée du contrat de travail ou d’un contrat de mission pour faute grave"));
793
                v.add(Tuple2.create("096", "rupture anticipée du contrat de travail ou d’un contrat de mission pour faute lourde"));
794
                v.add(Tuple2.create("097", "rupture anticipée d’un contrat de travail ou d’un contrat de mission suite à fermeture de l'établissement"));
795
                v.add(Tuple2.create("098", "retrait d'enfant"));
796
                v.add(Tuple2.create("998", "transfert du contrat de travail sans rupture du contrat vers un autre établissement n'effectuant pas encore de DSN"));
797
                v.add(Tuple2.create("999", "fin de relation avec l’employeur (autres que contrat de travail) pour les cas ne portant aucun impact sur l’Assurance chômage"));
798
                insertValues(v, table);
799
            } catch (SQLException ex) {
800
                throw new IllegalStateException("Erreur lors de la création de la table " + "MOTIF_FIN_CONTRAT", ex);
801
            }
802
        }
803
 
804
        DSNUpdateRubrique dsnUpdateRubrique = new DSNUpdateRubrique(root);
805
        dsnUpdateRubrique.updateRubriqueCotisation();
142 ilm 806
 
807
        // PHASE 3
156 ilm 808
        final SQLTable caisseCot = root.getTable("CAISSE_COTISATION");
142 ilm 809
        {
810
            SQLTable tableCaisseCotisation = root.findTable("CAISSE_COTISATION");
811
            if (!tableCaisseCotisation.contains("ORG_PROTECTION_SOCIALE")) {
812
                final AlterTable alterCaisse = new AlterTable(tableCaisseCotisation);
813
                alterCaisse.addBooleanColumn("ORG_PROTECTION_SOCIALE", Boolean.FALSE, false);
814
                alterCaisse.addBooleanColumn("URSSAF", Boolean.FALSE, false);
815
 
816
                root.getBase().getDataSource().execute(alterCaisse.asString());
817
                root.refetchTable("CAISSE_COTISATION");
818
                root.getSchema().updateVersion();
819
 
820
                {
821
                    UpdateBuilder upCaisse = new UpdateBuilder(tableCaisseCotisation);
822
                    upCaisse.setObject("ORG_PROTECTION_SOCIALE", Boolean.TRUE);
823
                    upCaisse.setWhere(new Where(tableCaisseCotisation.getField("NOM"), Arrays.asList("URSSAF", "AGIRC", "ARRCO")));
824
                    root.getBase().getDataSource().execute(upCaisse.asString());
825
                }
826
                {
827
                    UpdateBuilder upCaisse = new UpdateBuilder(tableCaisseCotisation);
828
                    upCaisse.setObject("URSSAF", Boolean.TRUE);
829
                    upCaisse.setWhere(new Where(tableCaisseCotisation.getField("NOM"), Arrays.asList("URSSAF")));
830
                    root.getBase().getDataSource().execute(upCaisse.asString());
831
                }
832
            }
833
            if (!root.contains("CAISSE_MODE_PAIEMENT")) {
834
                final SQLCreateTable createCaisseMode = new SQLCreateTable(root, "CAISSE_MODE_PAIEMENT");
835
                createCaisseMode.addVarCharColumn("CODE", 25);
836
                createCaisseMode.addVarCharColumn("NOM", 512);
837
 
838
                try {
839
                    root.getBase().getDataSource().execute(createCaisseMode.asString());
840
                    insertUndef(createCaisseMode);
841
                    root.refetchTable("CAISSE_MODE_PAIEMENT");
842
                    root.getSchema().updateVersion();
843
 
844
                    final SQLTable table = root.getTable("CAISSE_MODE_PAIEMENT");
845
                    List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
846
                    v.add(Tuple2.create("01", "chèque"));
847
                    v.add(Tuple2.create("02", "virement"));
848
                    v.add(Tuple2.create("03", "prélèvement"));
849
                    v.add(Tuple2.create("04", "titre inter-bancaire de paiement"));
850
                    v.add(Tuple2.create("05", "prélèvement SEPA"));
851
                    v.add(Tuple2.create("06", "versement réalisé par un autre établissement"));
852
 
853
                    insertValues(v, table);
854
                } catch (SQLException ex) {
855
                    throw new IllegalStateException("Erreur lors de la création de la table " + "CAISSE_MODE_PAIEMENT", ex);
856
                }
857
 
858
                final SQLCreateTable createCaisseREnseignement = new SQLCreateTable(root, "CAISSE_COTISATION_RENSEIGNEMENT");
859
                createCaisseREnseignement.addVarCharColumn("IDENTIFIANT", 256);
860
                createCaisseREnseignement.addVarCharColumn("SIRET", 256);
861
                createCaisseREnseignement.addVarCharColumn("BIC", 256);
862
                createCaisseREnseignement.addVarCharColumn("IBAN", 256);
863
                createCaisseREnseignement.addVarCharColumn("ENTITE_AFFECTATION", 256);
864
                createCaisseREnseignement.addBooleanColumn("ORGANISME_COMPLEMENTAIRE", Boolean.FALSE, false);
865
                createCaisseREnseignement.addBooleanColumn("PAIEMENT_TRIMESTRIEL", Boolean.FALSE, false);
866
                createCaisseREnseignement.addVarCharColumn("CODE_DELEGATAIRE", 256);
867
                createCaisseREnseignement.addForeignColumn("ID_CAISSE_MODE_PAIEMENT", root.getTable("CAISSE_MODE_PAIEMENT"));
156 ilm 868
                createCaisseREnseignement.addForeignColumn("ID_CAISSE_COTISATION", caisseCot);
142 ilm 869
                createCaisseREnseignement.addForeignColumn("ID_SOCIETE_COMMON", root.getTable("SOCIETE_COMMON"));
870
                root.getBase().getDataSource().execute(createCaisseREnseignement.asString());
871
                insertUndef(createCaisseREnseignement);
872
                root.refetchTable("CAISSE_COTISATION_RENSEIGNEMENT");
873
                root.getSchema().updateVersion();
874
            }
875
            SQLTable tableCR = root.getTable("CAISSE_COTISATION_RENSEIGNEMENT");
876
            if (!tableCR.contains("PAIEMENT_TRIMESTRIEL")) {
877
                AlterTable alter = new AlterTable(tableCR);
878
                alter.addBooleanColumn("PAIEMENT_TRIMESTRIEL", Boolean.FALSE, false);
879
                root.getBase().getDataSource().execute(alter.asString());
880
                root.refetchTable("CAISSE_COTISATION_RENSEIGNEMENT");
881
                root.getSchema().updateVersion();
882
            }
144 ilm 883
 
884
            if (!tableCR.contains("JOUR_PAIEMENT")) {
885
                AlterTable alter = new AlterTable(tableCR);
886
                alter.addIntegerColumn("JOUR_PAIEMENT", 0);
887
                root.getBase().getDataSource().execute(alter.asString());
888
                root.refetchTable("CAISSE_COTISATION_RENSEIGNEMENT");
889
                root.getSchema().updateVersion();
890
            }
142 ilm 891
        }
892
 
893
        if (!root.contains("TYPE_COMPOSANT_BASE_ASSUJETTIE")) {
894
            final SQLCreateTable createTableTypeComposant = new SQLCreateTable(root, "TYPE_COMPOSANT_BASE_ASSUJETTIE");
895
            createTableTypeComposant.addVarCharColumn("CODE", 25);
896
            createTableTypeComposant.addVarCharColumn("NOM", 512);
897
 
898
            try {
899
                root.getBase().getDataSource().execute(createTableTypeComposant.asString());
900
                insertUndef(createTableTypeComposant);
901
                root.refetchTable("TYPE_COMPOSANT_BASE_ASSUJETTIE");
902
                root.getSchema().updateVersion();
903
 
904
                final SQLTable table = root.getTable("TYPE_COMPOSANT_BASE_ASSUJETTIE");
905
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
906
 
907
                v.add(Tuple2.create("01", "Montant du SMIC retenu pour le calcul de la Réduction générale des cotisations patronales de sécurité sociale"));
908
                v.add(Tuple2.create("02", "Montant du SMIC retenu pour le calcul du crédit d'impôt compétitivité-emploi"));
909
                v.add(Tuple2.create("03", "Contributions patronales à des régimes complémentaires de retraite"));
910
                v.add(Tuple2.create("04", "Contributions patronales destinées au financement des prestations de prévoyance complémentaire"));
911
                v.add(Tuple2.create("05", "Contributions patronales destinées au financement des prestations de retraite supplémentaire"));
912
                v.add(Tuple2.create("06", "Plafond calculé pour salarié poly-employeurs"));
913
                v.add(Tuple2.create("10", "Salaire brut Prévoyance"));
914
                v.add(Tuple2.create("11", "Tranche A Prévoyance"));
915
                v.add(Tuple2.create("12", "Tranche 2 Prévoyance"));
916
                v.add(Tuple2.create("13", "Tranche B Prévoyance"));
917
                v.add(Tuple2.create("14", "Tranche C Prévoyance"));
918
                v.add(Tuple2.create("15", "Tranche D Prévoyance"));
919
                v.add(Tuple2.create("16", "Tranche D1 Prévoyance"));
920
                v.add(Tuple2.create("17", "Base spécifique Prévoyance"));
921
                v.add(Tuple2.create("18", "Base forfaitaire Prévoyance"));
922
                v.add(Tuple2.create("19", "Base fictive Prévoyance reconstituée"));
923
                v.add(Tuple2.create("20", "Montant forfaitaire Prévoyance"));
924
                v.add(Tuple2.create("21", "Montant Prévoyance libre ou exceptionnel"));
925
                v.add(Tuple2.create("22", "Montant des indemnités journalières CRPCEN"));
926
                v.add(Tuple2.create("90", "Retenue sur salaire"));
927
                v.add(Tuple2.create("91", "Base de taxe sur les salaires au taux normal"));
928
 
929
                insertValues(v, table);
930
 
931
                AlterTable tableRubCotis = new AlterTable(tableRubCot);
932
                tableRubCotis.addForeignColumn("ID_TYPE_COMPOSANT_BASE_ASSUJETTIE", root.getTable("TYPE_COMPOSANT_BASE_ASSUJETTIE"));
933
                root.getBase().getDataSource().execute(tableRubCotis.asString());
934
                root.refetchTable(tableRubCot.getName());
935
                root.getSchema().updateVersion();
936
            } catch (SQLException ex) {
937
                throw new IllegalStateException("Erreur lors de la création de la table " + "TYPE_COMPOSANT_BASE_ASSUJETTIE", ex);
938
            }
939
        }
940
        if (!root.contains("CODE_COTISATION_INDIVIDUELLE")) {
941
            final SQLCreateTable createTableTypeComposant = new SQLCreateTable(root, "CODE_COTISATION_INDIVIDUELLE");
942
            createTableTypeComposant.addVarCharColumn("CODE", 25);
943
            createTableTypeComposant.addVarCharColumn("NOM", 512);
944
 
945
            try {
946
                root.getBase().getDataSource().execute(createTableTypeComposant.asString());
947
                insertUndef(createTableTypeComposant);
948
                root.refetchTable("CODE_COTISATION_INDIVIDUELLE");
949
                root.getSchema().updateVersion();
950
 
951
                final SQLTable table = root.getTable("CODE_COTISATION_INDIVIDUELLE");
952
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
953
 
954
                v.add(Tuple2.create("001", "Exonération de cotisations au titre de l'emploi d'un apprenti (loi de 1979)"));
955
                v.add(Tuple2.create("002", "Exonération de cotisations au titre de l'emploi d'un apprenti (loi de 1987)"));
956
                v.add(Tuple2.create("003", "Exonération de cotisations au titre de l'emploi d'un apprenti (loi de 1992)"));
957
                v.add(Tuple2.create("004", "Exonération de cotisations au titre de l'emploi d'un salarié en contrat d'accès à l'emploi"));
958
                v.add(Tuple2.create("006", "Exonération de cotisations au titre de l'emploi d'un salarié en contrat d'accompagnement dans l'emploi"));
959
                v.add(Tuple2.create("008", "Exonération de cotisations au titre de l'emploi d'un salarié en contrat de professionnalisation"));
960
                v.add(Tuple2.create("009", "Exonération de cotisations applicable aux associations intermédiaires"));
961
                v.add(Tuple2.create("010", "Exonération de cotisations applicable aux entreprises des bassins d'emploi à redynamiser"));
962
                v.add(Tuple2.create("011", "Exonération de cotisations applicable au créateur ou repreneur d'entreprise"));
963
                v.add(Tuple2.create("012", "Exonération de cotisations applicable dans les DOM"));
964
                v.add(Tuple2.create("013", "Exonération de cotisations applicable aux entreprises et associations d'aide à domicile"));
965
                v.add(Tuple2.create("014", "Exonérations de cotisations applicable aux entreprises innovantes ou universitaires"));
966
                v.add(Tuple2.create("015", "Exonération de cotisations applicable aux entreprises en zones franches urbaines"));
967
                v.add(Tuple2.create("016", "Exonération de cotisations applicable aux organismes d'intérêt général en zones de revitalisation rurale"));
968
                v.add(Tuple2.create("017", "Exonération de cotisations applicable aux structures agréées de l'aide sociale"));
969
                v.add(Tuple2.create("018", "Réduction générale des cotisations patronales de sécurité sociale"));
970
                v.add(Tuple2.create("019", "Réduction de cotisations applicable aux entreprises des zones de restructuration de la défense"));
971
                v.add(Tuple2.create("020", "Réduction de cotisations au titre de l'embauche du 1er au 50ème salarié en zones de revitalisation rurale"));
972
                v.add(Tuple2.create("021", "Déduction patronale au titre des heures supplémentaires"));
973
                v.add(Tuple2.create("022", "Exonération de cotisations applicable à une gratification de stage"));
974
                v.add(Tuple2.create("023", "Exonération de cotisation des sommes provenant d'un CET et réaffectées à un PERCO ou à un régime de retraite supplémentaire"));
975
                v.add(Tuple2.create("025", "Exonération de cotisations au titre de l’emploi d’un salarié en chantier et atelier d'insertion"));
976
                v.add(Tuple2.create("027", "Exonération Personnel technique CUMA, hors ateliers"));
977
                v.add(Tuple2.create("028", "Réduction Travailleur Occasionnel"));
978
                v.add(Tuple2.create("029", "CNIEG Réduction employeurs petit pool"));
979
                v.add(Tuple2.create("030", "Camieg Cotisation employeurs Régime spécial Complémentaire"));
980
                v.add(Tuple2.create("031", "Camieg Cotisation salariés Régime spécial Complémentaire"));
981
                v.add(Tuple2.create("032", "Camieg Cotisation salariés Régime spécial Solidarité"));
982
                v.add(Tuple2.create("033", "CNIEG Cotisation employeurs complément d'invalidité"));
983
                v.add(Tuple2.create("034", "CNIEG Cotisation employeurs régime de droit commun (population adossée)"));
984
                v.add(Tuple2.create("035", "CNIEG Cotisation employeurs Régime spécial (population adossée)"));
985
                v.add(Tuple2.create("036", "CNIEG Cotisation employeurs régime spécial (population non adossée)"));
986
                v.add(Tuple2.create("037", "CNIEG Cotisation salariés régime de droit commun (population adossée)"));
987
                v.add(Tuple2.create("038", "CNIEG Cotisation salariés régime spécial (population non adossée)"));
988
                v.add(Tuple2.create("039", "CNIEG Cotisations employeurs petit pool"));
989
                v.add(Tuple2.create("040", "Cotisation AC : assurance chômage sur rémunérations brutes après déduction, limitées à 4 fois le plafond de la SS"));
990
                v.add(Tuple2.create("041", "Cotisation AC majorée 1 : application d’une majoration AC + 0,5% sur les contrats d’usage inférieurs ou égaux à 3 mois"));
991
                v.add(Tuple2.create("042", "Cotisation AC majorée 2 : application d’une majoration AC + 3% sur les contrats d’accroissement temporaire d’activité inférieurs ou égaux à 1 mois"));
992
                v.add(Tuple2.create("043",
993
                        "Cotisation AC majorée 3 : application d’une majoration AC + 1,5% sur les contrats d’accroissement temporaire d’activité supérieurs à 1 mois mais inférieurs ou égaux à 3 mois"));
994
                v.add(Tuple2.create("044", "Exonération de cotisation chômage pour les moins de 26 ans"));
995
                v.add(Tuple2.create("045", "Cotisation Accident du travail"));
996
                v.add(Tuple2.create("046", "Cotisation AEF Bourse de l'emploi"));
997
                v.add(Tuple2.create("047", "Cotisation AEF CESA"));
998
                v.add(Tuple2.create("048", "Cotisation AGS : assurance garantie des salaires sur rémunérations brutes après déduction, limitées à 4 fois le plafond de la sécurité sociale"));
999
                v.add(Tuple2.create("049", "Cotisation Allocation de logement (FNAL)"));
1000
                v.add(Tuple2.create("051", "Cotisation Formation professionnelle ADEFA"));
1001
                v.add(Tuple2.create("052", "Cotisation AFNCA, ANEFA, PROVEA, ASCPA"));
1002
                v.add(Tuple2.create("053", "Cotisation Formation professionnelle additionnelle FAFSEA"));
1003
                v.add(Tuple2.create("054", "Cotisation Formation professionnelle AREFA"));
1004
                v.add(Tuple2.create("055", "Cotisation Formation professionnelle CEREFAR"));
1005
                v.add(Tuple2.create("056", "Cotisation Formation professionnelle FAFSEA"));
1006
                v.add(Tuple2.create("057", "Cotisation Formation professionnelle FAFSEA CDD"));
1007
                v.add(Tuple2.create("058", "Cotisation Formation professionnelle FAFSEA des communes forestières"));
1008
                v.add(Tuple2.create("059", "Cotisation individuelle Prévoyance-Assurance-Mutuelle pour la période et l'affiliation concernées"));
1009
                v.add(Tuple2.create("060", "Cotisation IRCANTEC Tranche A"));
1010
                v.add(Tuple2.create("061", "Cotisation IRCANTEC Tranche B"));
1011
                v.add(Tuple2.create("063", "RETA Montant de cotisation Arrco"));
1012
                v.add(Tuple2.create("064", "RETC Montant de cotisation Agirc"));
1013
                v.add(Tuple2.create("065", "Cotisation CRPCEN"));
1014
                v.add(Tuple2.create("066", "Cotisation caisse de congés spectacles"));
1015
                v.add(Tuple2.create("068", "Contribution solidarité autonomie"));
1016
                v.add(Tuple2.create("069", "Contribution sur avantage de pré-retraite entreprise à dater du 11/10/2007 (CAPE)"));
1017
                v.add(Tuple2.create("070", "Contribution sur avantage de pré-retraite entreprise aux taux normal (CAPE)"));
1018
                v.add(Tuple2.create("071", "Contribution forfait social"));
1019
                v.add(Tuple2.create("072", "Contribution sociale généralisée/salaires partiellement déductibles"));
1020
                v.add(Tuple2.create("073", "CSG/CRDS sur participation intéressement épargne salariale"));
1021
                v.add(Tuple2.create("074", "Cotisation Allocation familiale taux normal  "));
1022
                v.add(Tuple2.create("075", "Cotisation Assurance Maladie"));
1023
                v.add(Tuple2.create("076", "Cotisation Assurance Vieillesse"));
1024
                v.add(Tuple2.create("077", "Montant de la retenue à la source effectuée sur les salaires versés aux personnes domiciliées hors de France"));
1025
                v.add(Tuple2.create("078", "Pénalité de 1% emploi sénior"));
1026
                v.add(Tuple2.create("079", "Remboursement de la dette sociale"));
1027
                v.add(Tuple2.create("081", "Versement transport"));
1028
                v.add(Tuple2.create("082", "Versement transport additionnel"));
1029
                v.add(Tuple2.create("086", "Cotisation pénibilité mono exposition"));
1030
                v.add(Tuple2.create("087", "Cotisation pénibilité multi exposition"));
1031
                v.add(Tuple2.create("088", "Exonération versement transport"));
1032
                v.add(Tuple2.create("089", "Exonération Contrat Initiative Emploi"));
1033
                v.add(Tuple2.create("090", "Exonération accueillants familiaux"));
1034
                v.add(Tuple2.create("091", "Cotisation Service de santé au travail"));
1035
                v.add(Tuple2.create("092", "Cotisation Association pour l'emploi des cadres ingénieurs et techniciens de l'agriculture (APECITA)"));
1036
                v.add(Tuple2.create("093", "Contribution sur indemnités de mise à la retraite"));
1037
                v.add(Tuple2.create("094", "Exonération cotisations Allocations familiales (SICAE)"));
1038
                v.add(Tuple2.create("096", "Cotisation CRPNPAC au fonds de retraite"));
1039
                v.add(Tuple2.create("097", "Cotisation CRPNPAC au fonds d'assurance"));
1040
                v.add(Tuple2.create("098", "Cotisation CRPNPAC au fonds de majoration"));
1041
                v.add(Tuple2.create("099", "Contribution stock options"));
1042
                v.add(Tuple2.create("100", "Contribution pour le financement des organisations syndicales de salariés et organisations professionnelles d'employeurs"));
1043
                v.add(Tuple2.create("101", "Association Mutualisation du Coût Inaptitude"));
1044
                v.add(Tuple2.create("102", "Cotisation Allocation Familiale - taux réduit"));
1045
                v.add(Tuple2.create("103", "Contribution actions gratuites"));
1046
                v.add(Tuple2.create("226", "Assiette du Versement Transport"));
182 ilm 1047
 
142 ilm 1048
                v.add(Tuple2.create("901", "Cotisation épargne retraite"));
1049
 
1050
                insertValues(v, table);
1051
 
1052
                List<Tuple2<String, String>> vCodeBase = new ArrayList<Tuple2<String, String>>();
1053
                vCodeBase.add(Tuple2.create("15", "CNIEG-Assiette brute du régime spécial"));
1054
                vCodeBase.add(Tuple2.create("16", "CNIEG-Assiette brute du complément invalidité"));
1055
                vCodeBase.add(Tuple2.create("17", "CNIEG - Assiette brute du petit pool"));
1056
                vCodeBase.add(Tuple2.create("18", "Camieg - assiette brute plafonnée"));
1057
                vCodeBase.add(Tuple2.create("19", "Assiette CRPCEN"));
1058
                vCodeBase.add(Tuple2.create("20", "CIBTP - Base brute de cotisations congés payés"));
1059
                vCodeBase.add(Tuple2.create("21", "CIBTP - Base brute de cotisations OPPBTP permanents"));
1060
                vCodeBase.add(Tuple2.create("22", "Base brute spécifique"));
1061
                vCodeBase.add(Tuple2.create("23", "Base exceptionnelle (Agirc Arrco)"));
1062
                vCodeBase.add(Tuple2.create("24", "Base plafonnée spécifique"));
1063
                vCodeBase.add(Tuple2.create("25", "Assiette de contribution libératoire"));
1064
                vCodeBase.add(Tuple2.create("27", "Assiette Caisse de congés spectacles"));
1065
                vCodeBase.add(Tuple2.create("28", "Base IRCANTEC cotisée"));
1066
                vCodeBase.add(Tuple2.create("29", "Base IRCANTEC non cotisée (arrêt de travail)"));
1067
                vCodeBase.add(Tuple2.create("31", "Eléments de cotisation Prévoyance, Santé, retraite supplémentaire"));
1068
                vCodeBase.add(Tuple2.create("33", "Assiette Contribution sur les avantages de préretraite entreprise"));
1069
                vCodeBase.add(Tuple2.create("34", "CIBTP -Base plafonnée de cotisations intempéries gros oeuvre travaux publics"));
1070
                vCodeBase.add(Tuple2.create("35", "CIBTP -Base plafonnée de cotisations intempéries second oeuvre"));
1071
                vCodeBase.add(Tuple2.create("36", "CIBTP -Base \"A\" de cotisations organisme professionnel BTP"));
1072
                vCodeBase.add(Tuple2.create("37", "Assiette de pénibilité"));
1073
                vCodeBase.add(Tuple2.create("38", "Rémunération pour le calcul de la réduction Travailleur Occasionnel"));
1074
                vCodeBase.add(Tuple2.create("39", "CIBTP -Base \"B\" de cotisations organisme professionnel BTP"));
1075
                vCodeBase.add(Tuple2.create("40", "CIBTP -Base \"C\" de cotisations organisme professionnel BTP"));
1076
                vCodeBase.add(Tuple2.create("41", "CRPNPAC-Assiette soumise au taux normal (non-plafonnée)"));
1077
                vCodeBase.add(Tuple2.create("42", "CRPNPAC-Assiette soumise au taux majoré (non-plafonnée)"));
1078
                vCodeBase.add(Tuple2.create("43", "Base plafonnée exceptionnelle Agirc Arrco"));
1079
                vCodeBase.add(Tuple2.create("44", "Assiette du forfait social à 16%"));
1080
                vCodeBase.add(Tuple2.create("45", "Base plafonnée ICP Agirc-Arrco"));
1081
                vCodeBase.add(Tuple2.create("90", "Autre revenu net imposable"));
1082
                insertValues(vCodeBase, root.getTable("CODE_BASE_ASSUJETTIE"));
1083
 
1084
                AlterTable tableRubCotis = new AlterTable(tableRubCot);
1085
                tableRubCotis.addForeignColumn("ID_CODE_COTISATION_INDIVIDUELLE", root.getTable("CODE_COTISATION_INDIVIDUELLE"));
1086
                root.getBase().getDataSource().execute(tableRubCotis.asString());
1087
                root.refetchTable(tableRubCot.getName());
1088
                root.getSchema().updateVersion();
1089
            } catch (SQLException ex) {
1090
                throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_COTISATION_INDIVIDUELLE", ex);
1091
            }
1092
            {
1093
                final SQLTable tableCodeBase = root.getTable("CODE_BASE_ASSUJETTIE");
1094
                SQLSelect selCodeBase = new SQLSelect();
1095
                selCodeBase.addSelectStar(tableCodeBase);
1096
                List<SQLRow> rowsCodeBase = SQLRowListRSH.execute(selCodeBase);
1097
                Map<String, SQLRow> mapCodeBase = new HashMap<String, SQLRow>();
1098
                for (SQLRow sqlRow : rowsCodeBase) {
1099
 
1100
                    final String string = sqlRow.getString("CODE");
1101
                    mapCodeBase.put(string, sqlRow);
1102
                }
1103
                final SQLTable tableCodeTypeComp = root.getTable("TYPE_COMPOSANT_BASE_ASSUJETTIE");
1104
                SQLSelect selCodeTypeComp = new SQLSelect();
1105
                selCodeTypeComp.addSelectStar(tableCodeTypeComp);
1106
                List<SQLRow> rowsTypeComp = SQLRowListRSH.execute(selCodeTypeComp);
1107
                Map<String, SQLRow> mapTypeComp = new HashMap<String, SQLRow>();
1108
                for (SQLRow sqlRow : rowsTypeComp) {
1109
                    final String string = sqlRow.getString("CODE");
1110
                    mapTypeComp.put(string, sqlRow);
1111
                }
1112
                final SQLTable tableCodeCotInd = root.getTable("CODE_COTISATION_INDIVIDUELLE");
1113
                SQLSelect selCodeCodeInd = new SQLSelect();
1114
                selCodeCodeInd.addSelectStar(tableCodeCotInd);
1115
                List<SQLRow> rowsCodeInd = SQLRowListRSH.execute(selCodeCodeInd);
1116
                Map<String, SQLRow> mapCodeInd = new HashMap<String, SQLRow>();
1117
                for (SQLRow sqlRow : rowsCodeInd) {
1118
                    final String string = sqlRow.getString("CODE");
1119
                    mapCodeInd.put(string, sqlRow);
1120
                }
156 ilm 1121
                final SQLTable tableCaisse = caisseCot;
142 ilm 1122
                SQLSelect selCodeCodeCaisse = new SQLSelect();
1123
                selCodeCodeCaisse.addSelectStar(tableCaisse);
1124
                List<SQLRow> rowsCodeCaisse = SQLRowListRSH.execute(selCodeCodeCaisse);
1125
                Map<String, SQLRow> mapCodeCaisse = new HashMap<String, SQLRow>();
1126
                for (SQLRow sqlRow : rowsCodeCaisse) {
1127
                    final String string = sqlRow.getString("NOM");
1128
                    mapCodeCaisse.put(string, sqlRow);
1129
                }
1130
                if (mapCodeCaisse.containsKey("ARRCO")) {
1131
                    UpdateBuilder updaterRubCot = new UpdateBuilder(tableRubCot);
1132
                    updaterRubCot.setObject("ID_CODE_BASE_ASSUJETTIE", mapCodeBase.get("02").getID());
1133
                    updaterRubCot.setObject("ID_CODE_COTISATION_INDIVIDUELLE", mapCodeInd.get("063").getID());
1134
                    // updaterRubCot.setObject("ID_TYPE_COMPOSANT_BASE_ASSUJETTIE",
1135
                    // mapTypeComp.get("03").getID());
1136
                    updaterRubCot.setWhere(new Where(tableRubCot.getField("ID_CAISSE_COTISATION"), "=", mapCodeCaisse.get("ARRCO").getID()));
1137
                    root.getBase().getDataSource().execute(updaterRubCot.asString());
1138
                }
1139
                if (mapCodeCaisse.containsKey("AGIRC")) {
1140
                    UpdateBuilder updaterRubCot = new UpdateBuilder(tableRubCot);
1141
                    updaterRubCot.setObject("ID_CODE_BASE_ASSUJETTIE", mapCodeBase.get("03").getID());
1142
                    updaterRubCot.setObject("ID_CODE_COTISATION_INDIVIDUELLE", mapCodeInd.get("064").getID());
1143
                    // updaterRubCot.setObject("ID_TYPE_COMPOSANT_BASE_ASSUJETTIE",
1144
                    // mapTypeComp.get("03").getID());
1145
                    updaterRubCot.setWhere(new Where(tableRubCot.getField("ID_CAISSE_COTISATION"), "=", mapCodeCaisse.get("AGIRC").getID()));
1146
                    root.getBase().getDataSource().execute(updaterRubCot.asString());
1147
                }
1148
            }
1149
        }
1150
 
1151
        if (!tableRubNet.contains("ID_CODE_COTISATION_INDIVIDUELLE")) {
1152
            AlterTable alterRubNet = new AlterTable(tableRubNet);
1153
            alterRubNet.addForeignColumn("ID_CODE_COTISATION_INDIVIDUELLE", root.getTable("CODE_COTISATION_INDIVIDUELLE"));
1154
            root.getBase().getDataSource().execute(alterRubNet.asString());
1155
            root.refetchTable(tableRubNet.getName());
1156
            root.getSchema().updateVersion();
1157
        }
1158
        if (!tableRubNet.contains("ID_TYPE_COMPOSANT_BASE_ASSUJETTIE")) {
1159
            AlterTable alterRubNet = new AlterTable(tableRubNet);
1160
            alterRubNet.addForeignColumn("ID_TYPE_COMPOSANT_BASE_ASSUJETTIE", root.getTable("TYPE_COMPOSANT_BASE_ASSUJETTIE"));
1161
            root.getBase().getDataSource().execute(alterRubNet.asString());
1162
            root.refetchTable(tableRubNet.getName());
1163
            root.getSchema().updateVersion();
1164
        }
1165
        if (!tableRubNet.contains("ID_CODE_BASE_ASSUJETTIE")) {
1166
            AlterTable alterRubNet = new AlterTable(tableRubNet);
1167
            alterRubNet.addForeignColumn("ID_CODE_BASE_ASSUJETTIE", root.getTable("CODE_BASE_ASSUJETTIE"));
1168
            root.getBase().getDataSource().execute(alterRubNet.asString());
1169
            root.refetchTable(tableRubNet.getName());
1170
            root.getSchema().updateVersion();
1171
        }
1172
 
1173
        if (!tableRubNet.contains("ID_CAISSE_COTISATION")) {
1174
            AlterTable alterRubNet = new AlterTable(tableRubNet);
156 ilm 1175
            alterRubNet.addForeignColumn("ID_CAISSE_COTISATION", caisseCot);
142 ilm 1176
            root.getBase().getDataSource().execute(alterRubNet.asString());
1177
            root.refetchTable(tableRubNet.getName());
1178
            root.getSchema().updateVersion();
1179
        }
1180
 
1181
        if (!root.contains("CODE_COTISATION_ETABLISSEMENT")) {
1182
            final SQLCreateTable createTableTypeComposant = new SQLCreateTable(root, "CODE_COTISATION_ETABLISSEMENT");
1183
            createTableTypeComposant.addVarCharColumn("CODE", 25);
1184
            createTableTypeComposant.addVarCharColumn("NOM", 512);
1185
 
1186
            try {
1187
                root.getBase().getDataSource().execute(createTableTypeComposant.asString());
1188
                insertUndef(createTableTypeComposant);
1189
                root.refetchTable("CODE_COTISATION_ETABLISSEMENT");
1190
                root.getSchema().updateVersion();
1191
 
1192
                final SQLTable table = root.getTable("CODE_COTISATION_ETABLISSEMENT");
1193
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
1194
 
1195
                v.add(Tuple2.create("001", "Cotisation ADPFA (Association pour le Développement du Paritarisme des Fleuristes et Animaliers)"));
1196
                v.add(Tuple2.create("002", "Cotisation APNAB (Association Paritaire Nationale pour le développement de la négociation collective dans l'Artisanat du Bâtiment)"));
1197
                v.add(Tuple2.create("003 ", "Cotisation sur assiette avec congés payés CCCA-BTP (Comité de Concertation et de Coordination de l'apprentissage du Bâtiment et des Travaux Publics)"));
1198
                v.add(Tuple2.create("004 ", "Cotisation CPPNTT (Commission Paritaire Professionnelle Nationale du Travail Temporaire)"));
1199
                v.add(Tuple2.create("005 ", "Cotisation Développement du paritarisme"));
1200
                v.add(Tuple2.create("006 ", "Cotisation Dialogue social"));
1201
                v.add(Tuple2.create("007 ", "Cotisation FAF (Fonds d'Assurance formation)"));
1202
                v.add(Tuple2.create("009 ", "Cotisation FAPS (Fonds d'action professionnelle et sociale)"));
1203
                v.add(Tuple2.create("010 ", "Cotisation FASTT (Fonds d'Action Sociale du Travail Temporaire)"));
1204
                v.add(Tuple2.create("011 ", "Cotisation Fonds de péréquation"));
1205
                v.add(Tuple2.create("012 ", "Cotisation IFC (Indemnités de fin de carrière)"));
1206
                v.add(Tuple2.create("017 ", "Cotisation ORGA (Organisations Syndicales  du Travail Temporaire)"));
1207
                v.add(Tuple2.create("018 ", "Cotisation Promotion et recrutement"));
1208
                v.add(Tuple2.create("019 ", "Cotisations attachées à une population de non salariés ayants"));
1209
                v.add(Tuple2.create("020 ", "Cotisations attachées à une population de non salariés retraités"));
1210
                v.add(Tuple2.create("021 ", "Cotisations FMSE (Fond national agricole de mutualisation des risques sanitaires et environnementaux)"));
1211
                v.add(Tuple2.create("022 ", "Cotisations VAL'HOR (association française pour la valorisation des produits et métiers de l'horticulture et du paysage)"));
1212
                v.add(Tuple2.create("023 ", "Chiffre d'affaire"));
1213
                v.add(Tuple2.create("024 ", "Nombre d'heures d'intérim"));
1214
                v.add(Tuple2.create("025 ", "Contribution aux régimes supplémentaires de retraite à prestations définies - Rente"));
1215
                v.add(Tuple2.create("026 ", "Contribution aux régimes supplémentaires de retraite à prestations définies - Prime"));
1216
                v.add(Tuple2.create("027 ", "Contribution aux régimes supplémentaires de retraite à prestations définies - Dotations"));
1217
                v.add(Tuple2.create("028 ", "Contribution additionnelle sur les rentes liquidées"));
1218
                v.add(Tuple2.create("029 ", "Contribution aux régimes supplémentaires de retraite à prestations définies. Rente à taux 7%"));
1219
                v.add(Tuple2.create("030 ", "Contribution aux régimes supplémentaires de retraite à prestations définies. Rente à taux 14%"));
1220
                v.add(Tuple2.create("031 ", "Contribution additionnelle de solidarité pour l'autonomie"));
1221
                v.add(Tuple2.create("032 ", "Contribution Sociale généralisée au taux de 3,80% + RDS sur revenu de remplacement "));
1222
                v.add(Tuple2.create("033 ", "Contribution Sociale généralisée au taux de 6,20% + RDS sur revenu de remplacement "));
1223
                v.add(Tuple2.create("034 ", "Contribution Sociale généralisée au taux de 6,60% + RDS sur revenu de remplacement "));
1224
                v.add(Tuple2.create("035 ", "Contribution Sociale généralisée au taux de 7,50% + RDS sur revenu de remplacement "));
1225
                v.add(Tuple2.create("036 ", "Cotisation TTC sur assiette CDD avec congés payés pour le secteur du BTP (Constructys Organisme Paritaire Collecteur Agréé pour le BTP)"));
1226
                v.add(Tuple2.create("037 ", "Cotisation TTC sur assiette avec congés payés pour le secteur du BTP (Constructys Organisme Paritaire Collecteur Agréé pour le BTP)"));
1227
                v.add(Tuple2.create("038 ", "Cotisation TTC  sur assiette sans  congés payés (Constructys Organisme Paritaire Collecteur Agréé pour le BTP)"));
1228
                v.add(Tuple2.create("039 ",
1229
                        "Cotisation TTC  sur assiette avec congés payés pour les salariés non soumis à la cotisation CCCA-BTP (Constructys Organisme Paritaire Collecteur Agréé pour le BTP)"));
1230
                v.add(Tuple2.create("040 ",
1231
                        "Cotisation TTC  sur assiette hors congés payés pour les salariés non soumis à la cotisation CCCA-BTP (Constructys Organisme Paritaire Collecteur Agréé pour le BTP)"));
1232
                v.add(Tuple2.create("041 ", "Cotisation maladie sur les avantages de préretraite"));
1233
                v.add(Tuple2.create("042 ", "Cotisation maladie sur les avantages de retraite"));
1234
                v.add(Tuple2.create("043 ", "Cotisation maladie Alsace-Moselle sur les avantages de retraite"));
1235
                v.add(Tuple2.create("044 ", "Cotisation forfait social à 8%"));
1236
                v.add(Tuple2.create("045 ", "Cotisation forfait social à 20%"));
1237
                v.add(Tuple2.create("090 ", "Cotisation spécifique Prévoyance"));
1238
 
1239
                insertValues(v, table);
1240
 
1241
                AlterTable tableRubCotis = new AlterTable(tableRubCot);
1242
                tableRubCotis.addForeignColumn("ID_CODE_COTISATION_ETABLISSEMENT", root.getTable("CODE_COTISATION_ETABLISSEMENT"));
1243
                root.getBase().getDataSource().execute(tableRubCotis.asString());
1244
                root.refetchTable(tableRubCot.getName());
1245
                root.getSchema().updateVersion();
1246
            } catch (SQLException ex) {
1247
                throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_COTISATION_ETABLISSEMENT", ex);
1248
            }
1249
        }
1250
 
1251
        if (!root.contains("CODE_PENIBILITE")) {
1252
            final SQLCreateTable createTableTypeComposant = new SQLCreateTable(root, "CODE_PENIBILITE");
1253
            createTableTypeComposant.addVarCharColumn("CODE", 25);
1254
            createTableTypeComposant.addVarCharColumn("NOM", 512);
1255
 
1256
            try {
1257
                root.getBase().getDataSource().execute(createTableTypeComposant.asString());
1258
                insertUndef(createTableTypeComposant);
1259
                root.refetchTable("CODE_PENIBILITE");
1260
                root.getSchema().updateVersion();
1261
 
1262
                final SQLTable table = root.getTable("CODE_PENIBILITE");
1263
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
1264
 
1265
                v.add(Tuple2.create("01", "les manutentions manuelles de charges"));
1266
                v.add(Tuple2.create("02", "les postures pénibles (positions forcées des articulations)"));
1267
                v.add(Tuple2.create("03", "les vibrations mécaniques"));
1268
                v.add(Tuple2.create("04", "les agents chimiques dangereux"));
1269
                v.add(Tuple2.create("05", "les activités exercées en milieu hyperbare"));
1270
                v.add(Tuple2.create("06", "les températures extrêmes"));
1271
                v.add(Tuple2.create("07", "le bruit"));
1272
                v.add(Tuple2.create("08", "le travail de nuit"));
1273
                v.add(Tuple2.create("09", "le travail en équipes successives alternantes"));
1274
                v.add(Tuple2.create("10", "le travail répétitif (répétition d'un même geste, à une cadence contrainte avec un temps de cycle défini)"));
1275
                v.add(Tuple2.create("99", "annulation"));
1276
 
1277
                insertValues(v, table);
1278
 
1279
            } catch (SQLException ex) {
1280
                throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_PENIBILITE", ex);
1281
            }
1282
        }
1283
 
1284
        if (!root.contains("AYANT_DROIT_TYPE")) {
1285
            final SQLCreateTable createTableTypeAyantDroit = new SQLCreateTable(root, "AYANT_DROIT_TYPE");
1286
            createTableTypeAyantDroit.addVarCharColumn("CODE", 25);
1287
            createTableTypeAyantDroit.addVarCharColumn("NOM", 512);
1288
 
1289
            try {
1290
                root.getBase().getDataSource().execute(createTableTypeAyantDroit.asString());
1291
                insertUndef(createTableTypeAyantDroit);
1292
                root.refetchTable("AYANT_DROIT_TYPE");
1293
                root.getSchema().updateVersion();
1294
 
1295
                final SQLTable table = root.getTable("AYANT_DROIT_TYPE");
1296
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
1297
 
1298
                v.add(Tuple2.create("01", "Adultes (conjoint, concubin, pacs)"));
1299
                v.add(Tuple2.create("02", "Enfant"));
1300
                v.add(Tuple2.create("03", "Autre (ascendant, collatéraux, ...)"));
1301
 
1302
                insertValues(v, table);
1303
 
1304
            } catch (SQLException ex) {
1305
                throw new IllegalStateException("Erreur lors de la création de la table " + "AYANT_DROIT_TYPE", ex);
1306
            }
1307
        }
1308
 
156 ilm 1309
        if (!root.contains("TYPE_TAUX_PAS")) {
1310
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "TYPE_TAUX_PAS");
1311
            createTableMotif.addVarCharColumn("CODE", 25);
1312
            createTableMotif.addVarCharColumn("NOM", 512);
1313
 
1314
            try {
1315
                root.getBase().getDataSource().execute(createTableMotif.asString());
1316
                insertUndef(createTableMotif);
1317
                root.refetchTable("TYPE_TAUX_PAS");
1318
                root.getSchema().updateVersion();
1319
 
1320
                final SQLTable table = root.getTable("TYPE_TAUX_PAS");
1321
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
1322
                v.add(Tuple2.create("01", " Taux transmis par la DGFIP"));
1323
                v.add(Tuple2.create("10", " Barème horaire métropole"));
1324
                v.add(Tuple2.create("11", " Barème quotidien métropole"));
1325
                v.add(Tuple2.create("12", " Barème hebdomadaire métropole"));
1326
                v.add(Tuple2.create("13", " Barème mensuel métropole"));
1327
                v.add(Tuple2.create("14", " Barème trimestriel métropole"));
1328
                v.add(Tuple2.create("15", " Barème semestriel métropole"));
1329
                v.add(Tuple2.create("16", " Barème annuel métropole"));
1330
                v.add(Tuple2.create("17", " Barème mathématique sur base mensuelle métropole"));
1331
                v.add(Tuple2.create("18", " Barème mathématique sur base annuelle métropole"));
1332
                v.add(Tuple2.create("20", " Barème horaire Guadeloupe, Réunion et Martinique"));
1333
                v.add(Tuple2.create("21", " Barème quotidien Guadeloupe, Réunion et Martinique"));
1334
                v.add(Tuple2.create("22", " Barème hebdomadaire Guadeloupe, Réunion et Martinique"));
1335
                v.add(Tuple2.create("23", " Barème mensuel Guadeloupe, Réunion et Martinique"));
1336
                v.add(Tuple2.create("24", " Barème trimestriel Guadeloupe, Réunion et Martinique"));
1337
                v.add(Tuple2.create("25", " Barème semestriel Guadeloupe, Réunion et Martinique"));
1338
                v.add(Tuple2.create("26", " Barème annuel Guadeloupe, Réunion et Martinique"));
1339
                v.add(Tuple2.create("27", " Barème mathématique sur base mensuelle Guadeloupe, Réunion et Martinique"));
1340
                v.add(Tuple2.create("28", " Barème mathématique sur base annuelle Guadeloupe, Réunion et Martinique"));
1341
                v.add(Tuple2.create("30", " Barème horaire Guyane et Mayotte"));
1342
                v.add(Tuple2.create("31", " Barème quotidien Guyane et Mayotte"));
1343
                v.add(Tuple2.create("32", " Barème hebdomadaire Guyane et Mayotte"));
1344
                v.add(Tuple2.create("33", " Barème mensuel Guyane et Mayotte"));
1345
                v.add(Tuple2.create("34", " Barème trimestriel Guyane et Mayotte"));
1346
                v.add(Tuple2.create("35", " Barème semestriel Guyane et Mayotte"));
1347
                v.add(Tuple2.create("36", " Barème annuel Guyane et Mayotte"));
1348
                v.add(Tuple2.create("37", " Barème mathématique sur base mensuelle Guyane et Mayotte"));
1349
                v.add(Tuple2.create("38", " Barème mathématique sur base annuelle Guyane et Mayotte"));
1350
                v.add(Tuple2.create("99", " Indu relatif à un exercice antérieur – pas de taux de PAS"));
1351
 
1352
                insertValues(v, table);
1353
            } catch (SQLException ex) {
1354
                throw new IllegalStateException("Erreur lors de la création de la table " + "TYPE_TAUX_PAS", ex);
1355
            }
1356
        }
1357
 
1358
        // P19V01.2
1359
        final SQLTable tableCotInd = root.getTable("CODE_COTISATION_INDIVIDUELLE");
1360
        List<Tuple2<String, String>> vCodeIndiv = new ArrayList<>();
182 ilm 1361
        vCodeIndiv.add(Tuple2.create("104", " Pénibilité Cotisation de base"));
1362
        vCodeIndiv.add(Tuple2.create("105", " Montant de cotisation Régime Unifié Agirc Arrco, y compris Apec"));
1363
        vCodeIndiv.add(Tuple2.create("106", " Réduction générale des cotisations patronales de retraite complémentaire"));
1364
        vCodeIndiv.add(Tuple2.create("107", " Forfait marin"));
1365
        vCodeIndiv.add(Tuple2.create("108", " Demi rôle marin"));
1366
        vCodeIndiv.add(Tuple2.create("109", " Exonération de cotisations salariales de retraite complémentaire au titre de l'emploi d'un apprenti"));
1367
        vCodeIndiv.add(Tuple2.create("110", " Exonération de cotisations patronales de retraite complémentaire applicable dans les DOM (LODEOM) SMIC 130% à 220%"));
1368
        vCodeIndiv.add(Tuple2.create("111", " Exonération de cotisations de retraite complémentaire applicable aux entreprises et associations d'aide à domicile"));
1369
        vCodeIndiv.add(Tuple2.create("112", " Exonération de cotisations patronales de retraite complémentaire applicable dans les DOM (LODEOM) SMIC 170% à 270%"));
1370
        vCodeIndiv.add(Tuple2.create("113", " Exonération de cotisations patronales de retraite complémentaire applicable dans les DOM (LODEOM) SMIC 170% à 350%"));
1371
        vCodeIndiv.add(Tuple2.create("114", " Montant de réduction des heures supplémentaires/complémentaires"));
1372
        vCodeIndiv.add(Tuple2.create("115", " Cotisation Assurance Maladie pour le Régime Local Alsace Moselle"));
1373
        vCodeIndiv.add(Tuple2.create("116", " Cotisation absente de la norme en cas de régularisation prud'homale"));
1374
        vCodeIndiv.add(Tuple2.create("128", " Contribution à la formation professionnelle (CFP)"));
1375
        vCodeIndiv.add(Tuple2.create("129", " Contribution dédiée au financement du Compte Professionnel de Formation pour les titulaires de CDD (CPFCDD)"));
1376
        vCodeIndiv.add(Tuple2.create("130", " Part principale de la taxe d'apprentissage"));
1377
        vCodeIndiv.add(Tuple2.create("131", " Cotisation régime unifié Agirc Arrco"));
1378
        vCodeIndiv.add(Tuple2.create("132", " Cotisation Apec"));
1379
        vCodeIndiv.add(Tuple2.create("133", " Contribution maladie spécifique Mayotte"));
1380
        vCodeIndiv.add(Tuple2.create("902", " Contribution à la formation professionnelle des Artisans assimilés salariés"));
1381
        vCodeIndiv.add(Tuple2.create("903", " Cotisation AFNCA"));
1382
        vCodeIndiv.add(Tuple2.create("904", " Cotisation ANEFA"));
1383
        vCodeIndiv.add(Tuple2.create("905", " Cotisation ASCPA"));
1384
        vCodeIndiv.add(Tuple2.create("906", " Cotisation PROVEA"));
1385
        vCodeIndiv.add(Tuple2.create("907", " Complément de cotisation Assurance Maladie"));
1386
        vCodeIndiv.add(Tuple2.create("908", " Taxe forfaitaire CDDU Assurance Chômage"));
1387
        vCodeIndiv.add(Tuple2.create("909", " Cotisation au titre du financement des régimes de retraites supplémentaires à prestation définies"));
1388
        vCodeIndiv.add(Tuple2.create("910", " Exonération de cotisations patronales pour les entreprises affectées par la crise sanitaire"));
1389
        vCodeIndiv.add(Tuple2.create("911", " Réduction de cotisations patronales pour les entreprises du secteur de la vigne affectées par la crise sanitaire"));
1390
        vCodeIndiv.add(Tuple2.create("912", " Exonération du forfait social à 10%"));
1391
        vCodeIndiv.add(Tuple2.create("913", " Potentielle nouvelle cotisation C"));
1392
        vCodeIndiv.add(Tuple2.create("914", " Potentielle nouvelle cotisation A"));
1393
        vCodeIndiv.add(Tuple2.create("915", " Potentielle nouvelle cotisation B"));
1394
 
156 ilm 1395
        insertValues(vCodeIndiv, tableCotInd);
1396
 
1397
        final SQLTable tableCTP = root.getTable("CODE_CAISSE_TYPE_RUBRIQUE");
1398
        List<Tuple2<String, String>> vCTP = new ArrayList<>();
1399
        vCTP.add(Tuple2.create("003", "Réduction cotisations salariale heures supplémentaires"));
1400
        vCTP.add(Tuple2.create("510", "Prime exceptionnelle de pouvoir d’achat"));
177 ilm 1401
        vCTP.add(Tuple2.create("060", "RR Chômage CSG-CRDS taux plein"));
182 ilm 1402
        vCTP.add(Tuple2.create("917", "MOBILITE ADD JOURNALISTE TX MINO 20%"));
1403
        vCTP.add(Tuple2.create("920", "EMPL AGRIC (1500 TONNES CANNE) RMI OM"));
1404
        vCTP.add(Tuple2.create("921", "MOBILITE ARTISTES TX MINORE 30%"));
1405
        vCTP.add(Tuple2.create("922", "ENTR.DE PRODUCTION D ELECTRICITE"));
1406
        vCTP.add(Tuple2.create("922", "ENTR.DE PRODUCTION D ELECTRICITE"));
1407
        vCTP.add(Tuple2.create("926", "AT SEULEMENT - GESTION TOTALE"));
1408
        vCTP.add(Tuple2.create("927", "MOBILITE ADD ARTISTES TX MINO 30%"));
1409
        vCTP.add(Tuple2.create("936", "CNIEG PRESTATION COMPL. INVALIDITE"));
1410
        vCTP.add(Tuple2.create("937", "COTISATIONS AGS CAS GENERAL U2"));
1411
        vCTP.add(Tuple2.create("938", "CONTRATS AIDES ATELIER INSERTION"));
1412
        vCTP.add(Tuple2.create("939", "ATELIER INSERTION MAYOTTE"));
1413
        vCTP.add(Tuple2.create("939", "ATELIER INSERTION MAYOTTE"));
1414
        vCTP.add(Tuple2.create("940", "CNIEG DROITS SPE. PASSES NON REGULES"));
1415
        vCTP.add(Tuple2.create("948", "CONTRAT EMPLOI SOLIDARITE"));
1416
        vCTP.add(Tuple2.create("950", "CONTRAT EMPLOI SOLIDARITE CAS PART"));
1417
        vCTP.add(Tuple2.create("951", "CONTRATS EMPLOI SOLIDARITE CAS PART"));
1418
        vCTP.add(Tuple2.create("952", "CONTRAT EMPLOI CONSOLIDE CAS GENERAL"));
1419
        vCTP.add(Tuple2.create("954", "CONTRAT EMPLOI CONSOLIDE CAS PART"));
1420
        vCTP.add(Tuple2.create("955", "CNIEG PETIT POOL"));
1421
        vCTP.add(Tuple2.create("959", "CFP ENTREPRISE < 11 SALARIES"));
1422
        vCTP.add(Tuple2.create("967", "CONTR.ROYALTIES ART.ET MANNEQUINS"));
1423
        vCTP.add(Tuple2.create("969", "COT.MAL.ROYALTIES ART.ETRANGER"));
1424
        vCTP.add(Tuple2.create("971", "CFP ENTREPRISE >= 11 SALARIES"));
1425
        vCTP.add(Tuple2.create("983", "CFP INTERMITTENTS DU SPECTACLE"));
1426
        vCTP.add(Tuple2.create("985", "PENALITE PENIBILITE"));
1427
        vCTP.add(Tuple2.create("987", "CONTRIBUTION CPF CDD "));
1428
        vCTP.add(Tuple2.create("992", "TA PRINCIPALE HORS ALSACE MOSELLE"));
1429
        vCTP.add(Tuple2.create("993", "TA ALSACE MOSELLE"));
1430
        vCTP.add(Tuple2.create("994", "TA DEDUCTION CFA ET OFFRE NOUVELLE"));
1431
        vCTP.add(Tuple2.create("995", "TA - SOLDE VERSEMENT LIBERATOIRE"));
1432
        vCTP.add(Tuple2.create("995", "TA - SOLDE VERSEMENT LIBERATOIRE"));
1433
        vCTP.add(Tuple2.create("996", "TA - DEDUCTION AU SOLDE CFA"));
1434
        vCTP.add(Tuple2.create("997", "TA - DEDUCTION SOLDE CREANCE ALTERN"));
1435
        vCTP.add(Tuple2.create("998", "CSA CONTRIBUTION ANNUELLE"));
156 ilm 1436
        insertValues(vCTP, tableCTP);
1437
 
1438
        final SQLTable tableTypeBrut = root.getTable("CODE_TYPE_RUBRIQUE_BRUT");
1439
        List<Tuple3<String, String, String>> vbrutType = new ArrayList<>();
1440
        vbrutType.add(Tuple3.create("016", "[FP] Heures affectées à un travail d’aide à domicile", DsnTypeCodeBrut.REMUNERATION.getName()));
1441
        vbrutType.add(Tuple3.create("017", "Heures supplémentaires ou complémentaires aléatoires", DsnTypeCodeBrut.REMUNERATION.getName()));
1442
        vbrutType.add(Tuple3.create("018", "Heures supplémentaires structurelles", DsnTypeCodeBrut.REMUNERATION.getName()));
177 ilm 1443
        vbrutType.add(Tuple3.create("019", "Heures d'activité partielle", DsnTypeCodeBrut.REMUNERATION.getName()));
1444
        vbrutType.add(Tuple3.create("020", "Heures affectées à un travail d’aide à domicile de publics fragiles", DsnTypeCodeBrut.REMUNERATION.getName()));
182 ilm 1445
 
1446
        vbrutType.add(Tuple3.create("021", "[FP] Taux de rémunération de la situation administrative", DsnTypeCodeBrut.REMUNERATION.getName()));
1447
        vbrutType.add(Tuple3.create("022", "Potentiel nouveau type de rémunération B", DsnTypeCodeBrut.REMUNERATION.getName()));
1448
        vbrutType.add(Tuple3.create("023", "Potentiel nouveau type de rémunération C", DsnTypeCodeBrut.REMUNERATION.getName()));
1449
        vbrutType.add(Tuple3.create("025", "Heures correspondant à du chômage intempéries", DsnTypeCodeBrut.REMUNERATION.getName()));
1450
        vbrutType.add(Tuple3.create("026", "Heures supplémentaires exonérées", DsnTypeCodeBrut.REMUNERATION.getName()));
1451
        vbrutType.add(Tuple3.create("027", "Potentiel nouveau type de rémunération A", DsnTypeCodeBrut.REMUNERATION.getName()));
1452
 
156 ilm 1453
        DsnBrutCode dsnBurCode = new DsnBrutCode();
1454
        dsnBurCode.updateTable(vbrutType, tableTypeBrut);
1455
 
182 ilm 1456
        // P21
1457
        final SQLTable tableArret = root.getTable("MOTIF_ARRET_TRAVAIL");
1458
        List<Tuple2<String, String>> vArret = new ArrayList<Tuple2<String, String>>();
1459
        vArret.add(Tuple2.create("09", "adoption"));
1460
        vArret.add(Tuple2.create("15", "temps partiel thérapeutique (risque maladie)"));
1461
        vArret.add(Tuple2.create("16", "temps partiel thérapeutique (risque accident de travail)"));
1462
        vArret.add(Tuple2.create("17", "temps partiel thérapeutique (risque accident de trajet)"));
1463
        vArret.add(Tuple2.create("18", "temps partiel thérapeutique (risque maladie professionnelle)"));
1464
        insertValues(vArret, tableArret);
1465
 
1466
        if (!root.contains("CODE_CAISSE_CONGES_PAYES")) {
1467
            final SQLCreateTable createTableCode = new SQLCreateTable(root, "CODE_CAISSE_CONGES_PAYES");
1468
            createTableCode.addVarCharColumn("CODE", 25);
1469
            createTableCode.addVarCharColumn("NOM", 512);
1470
 
1471
            try {
1472
                root.getBase().getDataSource().execute(createTableCode.asString());
1473
                insertUndef(createTableCode);
1474
                root.refetchTable("CODE_CAISSE_CONGES_PAYES");
1475
                root.getSchema().updateVersion();
1476
 
1477
            } catch (SQLException ex) {
1478
                throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_CAISSE_CONGES_PAYES", ex);
1479
            }
1480
        }
1481
 
1482
        if (!root.contains("MOTIF_NON_ASSUJETIS_TA")) {
1483
            final SQLCreateTable createTableCode = new SQLCreateTable(root, "MOTIF_NON_ASSUJETIS_TA");
1484
            createTableCode.addVarCharColumn("CODE", 25);
1485
            createTableCode.addVarCharColumn("NOM", 512);
1486
 
1487
            try {
1488
                root.getBase().getDataSource().execute(createTableCode.asString());
1489
                insertUndef(createTableCode);
1490
                root.refetchTable("MOTIF_NON_ASSUJETIS_TA");
1491
                root.getSchema().updateVersion();
1492
 
1493
                final SQLTable tableMotif = root.getTable("MOTIF_NON_ASSUJETIS_TA");
1494
                List<Tuple2<String, String>> vMotif = new ArrayList<Tuple2<String, String>>();
1495
                vMotif.add(Tuple2.create("001", "Non assujetti par choix du régime fiscal (option IR en catégorie BNC)"));
1496
                vMotif.add(Tuple2.create("002", "Collectivités publiques"));
1497
                vMotif.add(Tuple2.create("003", "Etablissements publics de recherche et les établissements publics d'enseignement supérieurs"));
1498
                vMotif.add(Tuple2.create("004", "Personnes morales créées pour la gestion d'un pôle de recherche et d'enseignement supérieur ou d'un réseau thématique de recherche avancée"));
1499
                vMotif.add(Tuple2.create("005", "Fondations reconnues d'utilité public du secteur de la recherche"));
1500
                vMotif.add(Tuple2.create("006", "Sociétés et personnes morales ayant pour objet exclusif l'enseignement"));
1501
                vMotif.add(Tuple2.create("007", "Associations sans but lucratif"));
1502
                vMotif.add(Tuple2.create("008", "Syndicats professionnels"));
1503
                vMotif.add(Tuple2.create("009", "Entreprises sans établissement en France (ESEF)"));
1504
                vMotif.add(Tuple2.create("010", "Sociétés civiles de moyens (SCM) non commerciale"));
1505
                vMotif.add(Tuple2.create("011", "Personnes physiques ou morales assujetties aux BNC ou BA"));
1506
                vMotif.add(Tuple2.create("012", "Les coopératives agricoles"));
1507
                vMotif.add(Tuple2.create("013", "Les coopératives artisanales, transport (y compris fluvial et maritime) et leurs unions"));
1508
                vMotif.add(Tuple2.create("014", "Les groupements d'employeurs dont agricoles"));
1509
                vMotif.add(Tuple2.create("015", "Les sociétés civiles agricoles"));
1510
                vMotif.add(Tuple2.create("016", "Les mutuelles et organismes mutualistes"));
1511
                vMotif.add(Tuple2.create("017",
1512
                        "Les organismes HLM, SA de crédit immobilier (I et au II de l'article L. 422-4 du code de la construction et de l'habitation ) et unions d'économie sociale"));
1513
                vMotif.add(Tuple2.create("018", "Les sociétés coopératives de construction désignées à l'article L. 432-2 du code de la construction et de l'habitation."));
1514
                vMotif.add(Tuple2.create("019", "Organismes chargés de l'organisation en France d'une compétition sportive internationale en France (Article L6131-1 du code du travail)"));
1515
 
1516
                insertValues(vMotif, tableMotif);
1517
            } catch (SQLException ex) {
1518
                throw new IllegalStateException("Erreur lors de la création de la table " + "MOTIF_NON_ASSUJETIS_TA", ex);
1519
            }
1520
        }
1521
        if (!societeCommonT.contains("ASSUJETTISSEMENT_TA")) {
1522
            AlterTable alterSoc = new AlterTable(societeCommonT);
1523
            alterSoc.addBooleanColumn("ASSUJETTISSEMENT_TA", Boolean.TRUE, false);
1524
            alterSoc.addBooleanColumn("ASSUJETTISSEMENT_CFP", Boolean.TRUE, false);
1525
            alterSoc.addBooleanColumn("ASSUJETTISSEMENT_CFP_CDD", Boolean.TRUE, false);
1526
            alterSoc.addForeignColumn("ID_MOTIF_NON_ASSUJETIS_TA", root.findTable("MOTIF_NON_ASSUJETIS_TA"));
1527
 
1528
            root.getBase().getDataSource().execute(alterSoc.asString());
1529
            root.getSchema().updateVersion();
1530
        }
132 ilm 1531
    }
1532
 
1533
    public void updateDSN(final DBRoot root) throws SQLException {
1534
        final SQLTable tableCodeStatutCat = root.getTable("CODE_STATUT_CATEGORIEL");
1535
        SQLRow rowNonCadre = tableCodeStatutCat.getRow(4);
1536
        if (rowNonCadre != null) {
1537
            rowNonCadre.createEmptyUpdateRow().put("CODE", "04").commit();
1538
        }
1539
        SQLRow rowSansStatut = tableCodeStatutCat.getRow(4);
1540
        if (rowSansStatut != null) {
1541
            rowSansStatut.createEmptyUpdateRow().put("CODE", "99").commit();
1542
        }
142 ilm 1543
        // 04 non cadre
1544
        UpdateBuilder up04 = new UpdateBuilder(tableCodeStatutCat);
1545
        up04.setObject("NOM", "Non cadre");
1546
        up04.setWhere(new Where(tableCodeStatutCat.getField("CODE"), "=", "04"));
1547
        root.getBase().getDataSource().execute(up04.asString());
132 ilm 1548
 
142 ilm 1549
        // 99 - pas de retraite complémentaire
1550
        UpdateBuilder up99 = new UpdateBuilder(tableCodeStatutCat);
1551
        up99.setObject("NOM", "Pas de retraite complémentaire");
1552
        up99.setWhere(new Where(tableCodeStatutCat.getField("CODE"), "=", "99"));
1553
        root.getBase().getDataSource().execute(up99.asString());
1554
 
132 ilm 1555
        if (!root.contains("ARRET_TRAVAIL")) {
1556
 
1557
            final SQLCreateTable createTable = new SQLCreateTable(root, "ARRET_TRAVAIL");
1558
            createTable.addForeignColumn("SALARIE");
1559
            createTable.addDateAndTimeColumn("DATE_DERNIER_JOUR_TRAV");
1560
            createTable.addDateAndTimeColumn("DATE_FIN_PREV");
1561
            createTable.addBooleanColumn("SUBROGATION", Boolean.FALSE, false);
1562
            createTable.addDateAndTimeColumn("DATE_DEBUT_SUBROGATION");
1563
            createTable.addDateAndTimeColumn("DATE_FIN_SUBROGATION");
1564
            createTable.addForeignColumn("ID_MOTIF_ARRET_TRAVAIL", root.findTable("MOTIF_ARRET_TRAVAIL"));
1565
            createTable.addForeignColumn("ID_MOTIF_REPRISE_ARRET_TRAVAIL", root.findTable("MOTIF_REPRISE_ARRET_TRAVAIL"));
1566
            createTable.addDateAndTimeColumn("DATE_REPRISE");
1567
            createTable.addDateAndTimeColumn("DATE_ACCIDENT");
1568
 
1569
            try {
1570
                root.getBase().getDataSource().execute(createTable.asString());
1571
                insertUndef(createTable);
1572
                root.refetchTable("ARRET_TRAVAIL");
1573
                root.getSchema().updateVersion();
1574
            } catch (SQLException ex) {
1575
                throw new IllegalStateException("Erreur lors de la création de la table " + "ARRET_TRAVAIL", ex);
1576
            }
1577
        }
1578
 
142 ilm 1579
        if (!root.contains("FIN_CONTRAT")) {
1580
 
1581
            final SQLCreateTable createTable = new SQLCreateTable(root, "FIN_CONTRAT");
1582
            createTable.addForeignColumn("FICHE_PAYE");
1583
            createTable.addForeignColumn("ID_MOTIF_FIN_CONTRAT", root.findTable("MOTIF_FIN_CONTRAT"));
1584
            createTable.addDateAndTimeColumn("DATE_FIN");
1585
            createTable.addDateAndTimeColumn("DATE_NOTIFICATION");
1586
            createTable.addDateAndTimeColumn("DATE_SIGNATURE_CONVENTION");
1587
            createTable.addDateAndTimeColumn("DATE_ENGAGEMENT_PROCEDURE");
1588
            createTable.addDateAndTimeColumn("DERNIER_JOUR_TRAV_PAYE");
1589
            createTable.addBooleanColumn("TRANSACTION_EN_COURS", Boolean.FALSE, false);
1590
            createTable.addBooleanColumn("PORTABILITE_PREVOYANCE", Boolean.FALSE, false);
1591
            createTable.addIntegerColumn("NB_DIF_RESTANT", null, true);
1592
            createTable.addIntegerColumn("NB_MOIS_CSP", null, true);
1593
            createTable.addDecimalColumn("SALAIRE_NET_HORAIRE", 16, 8, null, true);
1594
            createTable.addDecimalColumn("INDEMNITE_VERSE", 16, 8, null, true);
1595
            createTable.addForeignColumn("ID_TYPE_PREAVIS", root.findTable("TYPE_PREAVIS"));
1596
            createTable.addDateAndTimeColumn("DATE_DEBUT_PREAVIS");
1597
            createTable.addDateAndTimeColumn("DATE_FIN_PREAVIS");
1598
            createTable.addVarCharColumn("INFOS", 2048);
1599
 
1600
            try {
1601
                root.getBase().getDataSource().execute(createTable.asString());
1602
                insertUndef(createTable);
1603
                root.refetchTable("FIN_CONTRAT");
1604
                root.getSchema().updateVersion();
1605
            } catch (SQLException ex) {
1606
                throw new IllegalStateException("Erreur lors de la création de la table " + "FIN_CONTRAT", ex);
1607
            }
1608
        }
1609
 
132 ilm 1610
        if (!root.contains("REPRISE_TRAVAIL")) {
1611
 
1612
            final SQLCreateTable createTable = new SQLCreateTable(root, "REPRISE_TRAVAIL");
1613
            createTable.addForeignColumn("SALARIE");
1614
            createTable.addDateAndTimeColumn("DATE_DERNIER_JOUR_TRAV");
1615
            createTable.addDateAndTimeColumn("DATE_FIN_PREV");
1616
            createTable.addBooleanColumn("SUBROGATION", Boolean.FALSE, false);
1617
            createTable.addDateAndTimeColumn("DATE_DEBUT_SUBROGATION");
1618
            createTable.addDateAndTimeColumn("DATE_FIN_SUBROGATION");
1619
            createTable.addForeignColumn("ID_MOTIF_ARRET_TRAVAIL", root.findTable("MOTIF_ARRET_TRAVAIL"));
1620
            createTable.addForeignColumn("ID_MOTIF_REPRISE_ARRET_TRAVAIL", root.findTable("MOTIF_REPRISE_ARRET_TRAVAIL"));
1621
            createTable.addDateAndTimeColumn("DATE_REPRISE");
1622
            createTable.addDateAndTimeColumn("DATE_ACCIDENT");
1623
            createTable.addDateAndTimeColumn("DATE");
1624
            createTable.addVarCharColumn("COMMENTAIRES", 2048);
1625
 
1626
            try {
1627
                root.getBase().getDataSource().execute(createTable.asString());
1628
                insertUndef(createTable);
1629
                root.refetchTable("REPRISE_TRAVAIL");
1630
                root.getSchema().updateVersion();
1631
            } catch (SQLException ex) {
1632
                throw new IllegalStateException("Erreur lors de la création de la table " + "REPRISE_TRAVAIL", ex);
1633
            }
1634
        }
1635
 
1636
        if (!root.contains("DECLARATION_DSN")) {
1637
 
1638
            final SQLCreateTable createTable = new SQLCreateTable(root, "DECLARATION_DSN");
1639
            createTable.addForeignColumn("ID_DSN_NATURE", root.findTable("DSN_NATURE"));
1640
 
1641
            createTable.addDateAndTimeColumn("DATE");
1642
            createTable.addDateAndTimeColumn("DATE_ENVOI");
1643
            createTable.addBooleanColumn("TEST", Boolean.FALSE, false);
1644
            createTable.addBooleanColumn("ENVOYE", Boolean.FALSE, false);
1645
            createTable.addVarCharColumn("COMMENTAIRE", 1024);
1646
            createTable.addVarCharColumn("DSN_FILE", 75000);
1647
            createTable.addIntegerColumn("NUMERO", 1);
1648
            createTable.addIntegerColumn("ANNEE", 2016);
1649
            createTable.addForeignColumn("MOIS");
1650
 
1651
            try {
1652
                root.getBase().getDataSource().execute(createTable.asString());
1653
                insertUndef(createTable);
1654
                root.refetchTable("DECLARATION_DSN");
1655
                root.getSchema().updateVersion();
1656
            } catch (SQLException ex) {
1657
                throw new IllegalStateException("Erreur lors de la création de la table " + "DECLARATION_DSN", ex);
1658
            }
1659
        }
1660
 
1661
        SQLTable tableArret = root.getTable("ARRET_TRAVAIL");
1662
        if (!tableArret.contains("DATE")) {
1663
            AlterTable alter = new AlterTable(tableArret);
1664
            alter.addDateAndTimeColumn("DATE");
1665
            alter.addVarCharColumn("COMMENTAIRES", 2048);
1666
            root.getBase().getDataSource().execute(alter.asString());
1667
            root.refetchTable("ARRET_TRAVAIL");
1668
            root.getSchema().updateVersion();
1669
        }
1670
 
1671
        SQLTable tableDsn = root.getTable("DECLARATION_DSN");
1672
        if (!tableDsn.contains("ID_ARRET_TRAVAIL")) {
1673
            AlterTable alter = new AlterTable(tableDsn);
1674
            alter.addForeignColumn("ID_ARRET_TRAVAIL", root.findTable("ARRET_TRAVAIL"));
1675
            root.getBase().getDataSource().execute(alter.asString());
1676
            root.getSchema().updateVersion();
1677
        }
142 ilm 1678
        if (!tableDsn.contains("ID_FIN_CONTRAT")) {
1679
            AlterTable alter = new AlterTable(tableDsn);
1680
            alter.addForeignColumn("ID_FIN_CONTRAT", root.findTable("FIN_CONTRAT"));
1681
            root.getBase().getDataSource().execute(alter.asString());
1682
            root.getSchema().updateVersion();
1683
        }
1684
 
132 ilm 1685
        if (!tableDsn.contains("ID_REPRISE_TRAVAIL")) {
1686
            AlterTable alter = new AlterTable(tableDsn);
1687
            alter.addForeignColumn("ID_REPRISE_TRAVAIL", root.findTable("REPRISE_TRAVAIL"));
1688
            root.getBase().getDataSource().execute(alter.asString());
1689
            root.getSchema().updateVersion();
1690
        }
1691
        if (!tableDsn.contains("ID_MOIS_REGUL")) {
1692
            AlterTable alter = new AlterTable(tableDsn);
1693
            alter.addForeignColumn("ID_MOIS_REGUL", root.findTable("MOIS"));
1694
            root.getBase().getDataSource().execute(alter.asString());
1695
            root.getSchema().updateVersion();
1696
        }
1697
 
1698
        if (!tableDsn.contains("ANNULE_REMPLACE")) {
1699
            AlterTable alter = new AlterTable(tableDsn);
1700
            alter.addBooleanColumn("ANNULE_REMPLACE", Boolean.FALSE, false);
1701
            root.getBase().getDataSource().execute(alter.asString());
1702
            root.getSchema().updateVersion();
1703
        }
142 ilm 1704
        if (!tableDsn.contains("NUMERO_REFERENCE")) {
1705
            AlterTable alter = new AlterTable(tableDsn);
1706
            alter.addVarCharColumn("NUMERO_REFERENCE", 256);
1707
            root.getBase().getDataSource().execute(alter.asString());
1708
            root.getSchema().updateVersion();
1709
        }
1710
        if (!tableDsn.contains("ID_DECLARATION_DSN_ANNULATION")) {
1711
            AlterTable alter = new AlterTable(tableDsn);
1712
            alter.addForeignColumn("ID_DECLARATION_DSN_ANNULATION", tableDsn);
1713
            root.getBase().getDataSource().execute(alter.asString());
1714
            root.getSchema().updateVersion();
1715
        }
1716
        if (!tableDsn.contains("EFFECTIF_CVAE")) {
1717
            AlterTable alter = new AlterTable(tableDsn);
1718
            alter.addIntegerColumn("EFFECTIF_CVAE", null, true);
1719
            alter.addVarCharColumn("CODE_INSEE_CVAE", 32);
1720
            root.getBase().getDataSource().execute(alter.asString());
1721
            root.getSchema().updateVersion();
1722
            root.refetchTable(tableDsn.getName());
1723
        }
132 ilm 1724
 
142 ilm 1725
        if (!tableDsn.contains("PERIODE_CVAE_DEBUT")) {
1726
            AlterTable alter = new AlterTable(tableDsn);
1727
            alter.addColumn("PERIODE_CVAE_DEBUT", "date");
1728
            alter.addColumn("PERIODE_CVAE_FIN", "date");
1729
            root.getBase().getDataSource().execute(alter.asString());
1730
            root.getSchema().updateVersion();
1731
        }
1732
 
132 ilm 1733
        // if (!root.contains("FIN_CONTRAT")) {
1734
        //
1735
        // final SQLCreateTable createTable = new SQLCreateTable(root, "FIN_CONTRAT");
1736
        // createTable.addForeignColumn("SALARIE");
1737
        // createTable.addDateAndTimeColumn("DATE_FIN");
1738
        // createTable.addDateAndTimeColumn("DATE_FIN_PREV");
1739
        // createTable.addBooleanColumn("SUBROGATION", Boolean.FALSE, false);
1740
        // createTable.addDateAndTimeColumn("DATE_DEBUT_SUBROGATION");
1741
        // createTable.addDateAndTimeColumn("DATE_FIN_SUBROGATION");
1742
        // createTable.addForeignColumn("ID_MOTIF_ARRET_TRAVAIL",
1743
        // root.findTable("MOTIF_ARRET_TRAVAIL"));
1744
        // createTable.addForeignColumn("ID_MOTIF_REPRISE_ARRET_TRAVAIL",
1745
        // root.findTable("MOTIF_REPRISE_ARRET_TRAVAIL"));
1746
        // createTable.addDateAndTimeColumn("DATE_REPRISE");
1747
        // createTable.addDateAndTimeColumn("DATE_ACCIDENT");
1748
        //
1749
        // try {
1750
        // root.getBase().getDataSource().execute(createTable.asString());
1751
        // insertUndef(createTable);
1752
        // root.refetchTable("FIN_CONTRAT");
1753
        // root.getSchema().updateVersion();
1754
        // } catch (SQLException ex) {
1755
        // throw new IllegalStateException("Erreur lors de la création de la table " +
1756
        // "FIN_CONTRAT", ex);
1757
        // }
1758
        // }
1759
 
1760
        SQLTable tableContrat = root.getTable("CONTRAT_SALARIE");
1761
        if (!tableContrat.contains("NUMERO")) {
1762
            AlterTable alter = new AlterTable(tableContrat);
1763
            alter.addColumn("NUMERO", "varchar(" + 128 + ") default '00000' NOT NULL");
1764
            root.getBase().getDataSource().execute(alter.asString());
1765
            root.getSchema().updateVersion();
1766
        }
1767
 
1768
        if (!tableContrat.contains("CODE_REGIME_RETRAITE_DSN")) {
1769
            AlterTable alter = new AlterTable(tableContrat);
1770
            alter.addColumn("CODE_REGIME_RETRAITE_DSN", "varchar(" + 128 + ") default '00000' NOT NULL");
1771
            root.getBase().getDataSource().execute(alter.asString());
1772
            root.getSchema().updateVersion();
1773
        }
1774
 
1775
        if (!tableContrat.contains("DATE_PREV_FIN")) {
1776
            AlterTable alter = new AlterTable(tableContrat);
1777
            alter.addDateAndTimeColumn("DATE_PREV_FIN");
1778
            root.getBase().getDataSource().execute(alter.asString());
1779
            root.getSchema().updateVersion();
1780
        }
1781
 
1782
        boolean updateContrat = false;
1783
        if (!tableContrat.contains("ID_CONTRAT_MODALITE_TEMPS")) {
1784
            updateContrat = true;
1785
            AlterTable alter = new AlterTable(tableContrat);
1786
            alter.addForeignColumn("ID_CONTRAT_MODALITE_TEMPS", root.findTable("CONTRAT_MODALITE_TEMPS"));
1787
            root.getBase().getDataSource().execute(alter.asString());
1788
            root.getSchema().updateVersion();
1789
        }
1790
        if (!tableContrat.contains("ID_CONTRAT_REGIME_MALADIE")) {
1791
            AlterTable alter = new AlterTable(tableContrat);
1792
            alter.addForeignColumn("ID_CONTRAT_REGIME_MALADIE", root.findTable("CONTRAT_REGIME_MALADIE"));
1793
            root.getBase().getDataSource().execute(alter.asString());
1794
            root.getSchema().updateVersion();
1795
        }
1796
        if (!tableContrat.contains("ID_CONTRAT_REGIME_VIEILLESSE")) {
1797
            AlterTable alter = new AlterTable(tableContrat);
1798
            alter.addForeignColumn("ID_CONTRAT_REGIME_VIEILLESSE", root.findTable("CONTRAT_REGIME_VIEILLESSE"));
1799
            root.getBase().getDataSource().execute(alter.asString());
1800
            root.getSchema().updateVersion();
1801
        }
1802
        if (!tableContrat.contains("ID_CONTRAT_MOTIF_RECOURS")) {
1803
            AlterTable alter = new AlterTable(tableContrat);
1804
            alter.addForeignColumn("ID_CONTRAT_MOTIF_RECOURS", root.findTable("CONTRAT_MOTIF_RECOURS"));
1805
            root.getBase().getDataSource().execute(alter.asString());
1806
            root.getSchema().updateVersion();
1807
        }
1808
        if (!tableContrat.contains("ID_CONTRAT_DETACHE_EXPATRIE")) {
1809
            AlterTable alter = new AlterTable(tableContrat);
1810
            alter.addForeignColumn("ID_CONTRAT_DETACHE_EXPATRIE", root.findTable("CONTRAT_DETACHE_EXPATRIE"));
1811
            root.getBase().getDataSource().execute(alter.asString());
1812
            root.getSchema().updateVersion();
1813
        }
1814
        if (!tableContrat.contains("ID_CONTRAT_DISPOSITIF_POLITIQUE")) {
1815
            AlterTable alter = new AlterTable(tableContrat);
1816
            alter.addForeignColumn("ID_CONTRAT_DISPOSITIF_POLITIQUE", root.findTable("CONTRAT_DISPOSITIF_POLITIQUE"));
1817
            root.getBase().getDataSource().execute(alter.asString());
1818
            root.getSchema().updateVersion();
1819
        }
177 ilm 1820
        if (!tableContrat.contains("ID_CODE_AMENAGEMENT_PARTIEL")) {
1821
            updateContrat = true;
1822
            AlterTable alter = new AlterTable(tableContrat);
1823
            alter.addForeignColumn("ID_CODE_AMENAGEMENT_PARTIEL", root.findTable("CODE_AMENAGEMENT_PARTIEL"));
1824
            alter.addColumn("DATE_DEBUT_SUSPENSION", "date");
1825
            alter.addColumn("DATE_FIN_SUSPENSION", "date");
1826
            root.getBase().getDataSource().execute(alter.asString());
1827
            root.getSchema().updateVersion();
1828
        }
132 ilm 1829
 
177 ilm 1830
        if (!tableContrat.contains("ID_CODE_SUSPENSION")) {
1831
            updateContrat = true;
1832
            AlterTable alter = new AlterTable(tableContrat);
1833
            alter.addForeignColumn("ID_CODE_SUSPENSION", root.findTable("CODE_SUSPENSION"));
1834
            root.getBase().getDataSource().execute(alter.asString());
1835
            root.getSchema().updateVersion();
1836
        }
182 ilm 1837
 
180 ilm 1838
        if (!tableContrat.contains("ID_DIPLOME_PREPARE")) {
1839
            updateContrat = true;
1840
            AlterTable alter = new AlterTable(tableContrat);
1841
            alter.addForeignColumn("ID_DIPLOME_PREPARE", root.findTable("DIPLOME_PREPARE"));
1842
            root.getBase().getDataSource().execute(alter.asString());
1843
            root.getSchema().updateVersion();
1844
        }
177 ilm 1845
 
132 ilm 1846
        if (updateContrat) {
1847
            root.refetchTable("CONTRAT_SALARIE");
1848
            tableContrat = root.findTable("CONTRAT_SALARIE");
1849
            SQLSelect sel = new SQLSelect();
1850
            sel.addSelectStar(tableContrat);
1851
            List<SQLRow> contrats = SQLRowListRSH.execute(sel);
1852
 
1853
            SQLSelect selModal = new SQLSelect();
1854
            final SQLTable tableModaliteTemps = root.findTable("CONTRAT_MODALITE_TEMPS");
1855
            selModal.addSelectStar(tableModaliteTemps);
1856
            selModal.setWhere(new Where(tableModaliteTemps.getField("CODE"), "=", "10"));
1857
            SQLRow contratModalite = SQLRowListRSH.execute(selModal).get(0);
1858
 
1859
            SQLSelect selMaladie = new SQLSelect();
1860
            final SQLTable tableMaladie = root.findTable("CONTRAT_REGIME_MALADIE");
1861
            selMaladie.addSelectStar(tableMaladie);
1862
            selMaladie.setWhere(new Where(tableMaladie.getField("CODE"), "=", "200"));
1863
            SQLRow contratMaladie = SQLRowListRSH.execute(selMaladie).get(0);
1864
 
1865
            SQLSelect selViel = new SQLSelect();
1866
            final SQLTable tableViel = root.findTable("CONTRAT_REGIME_VIEILLESSE");
1867
            selViel.addSelectStar(tableViel);
1868
            selViel.setWhere(new Where(tableViel.getField("CODE"), "=", "200"));
1869
            SQLRow contratViel = SQLRowListRSH.execute(selViel).get(0);
1870
 
1871
            SQLSelect selDetacheExp = new SQLSelect();
1872
            final SQLTable tableDetacheExp = root.findTable("CONTRAT_DETACHE_EXPATRIE");
1873
            selDetacheExp.addSelectStar(tableDetacheExp);
1874
            selDetacheExp.setWhere(new Where(tableDetacheExp.getField("CODE"), "=", "99"));
1875
            SQLRow contratDetacheExp = SQLRowListRSH.execute(selDetacheExp).get(0);
1876
 
1877
            SQLSelect selDispoPolitique = new SQLSelect();
1878
            final SQLTable tableDispoPol = root.findTable("CONTRAT_DISPOSITIF_POLITIQUE");
1879
            selDispoPolitique.addSelectStar(tableDispoPol);
1880
            selDispoPolitique.setWhere(new Where(tableDispoPol.getField("CODE"), "=", "99"));
1881
            SQLRow contratDispoPol = SQLRowListRSH.execute(selDispoPolitique).get(0);
1882
 
1883
            for (SQLRow contrat : contrats) {
1884
 
1885
                final SQLRowValues createEmptyUpdateRow = contrat.createEmptyUpdateRow();
1886
                createEmptyUpdateRow.put("ID_CONTRAT_MODALITE_TEMPS", contratModalite.getID());
1887
                createEmptyUpdateRow.put("ID_CONTRAT_REGIME_MALADIE", contratMaladie.getID());
1888
                createEmptyUpdateRow.put("ID_CONTRAT_REGIME_VIEILLESSE", contratViel.getID());
1889
                createEmptyUpdateRow.put("ID_CONTRAT_DETACHE_EXPATRIE", contratDetacheExp.getID());
1890
                createEmptyUpdateRow.put("ID_CONTRAT_DISPOSITIF_POLITIQUE", contratDispoPol.getID());
1891
                createEmptyUpdateRow.commit();
1892
            }
1893
        }
142 ilm 1894
        if (!root.contains("CONTRAT_PREVOYANCE")) {
132 ilm 1895
 
142 ilm 1896
            final SQLCreateTable createTable = new SQLCreateTable(root, "CONTRAT_PREVOYANCE");
1897
            createTable.addVarCharColumn("REFERENCE", 256);
1898
            createTable.addDateAndTimeColumn("DATE_DEBUT");
1899
            createTable.addDateAndTimeColumn("DATE_FIN");
1900
            createTable.addVarCharColumn("CODE_ORGANISME", 256);
1901
            createTable.addVarCharColumn("CODE_DELEGATAIRE", 256);
1902
            createTable.addVarCharColumn("CODE_UNIQUE", 256);
1903
            createTable.addVarCharColumn("NOM", 256);
1904
            try {
1905
                root.getBase().getDataSource().execute(createTable.asString());
1906
                insertUndef(createTable);
1907
                root.refetchTable("CONTRAT_PREVOYANCE");
1908
                root.getSchema().updateVersion();
1909
            } catch (SQLException ex) {
1910
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_PREVOYANCE", ex);
1911
            }
1912
        }
1913
        if (!root.getTable("CONTRAT_PREVOYANCE").contains("COTISATION_ETABLISSEMENT")) {
1914
            AlterTable tableContratP = new AlterTable(root.getTable("CONTRAT_PREVOYANCE"));
1915
            tableContratP.addBooleanColumn("COTISATION_ETABLISSEMENT", Boolean.FALSE, false);
1916
            root.getBase().getDataSource().execute(tableContratP.asString());
1917
            root.refetchTable("CONTRAT_PREVOYANCE");
1918
            root.getSchema().updateVersion();
1919
        }
1920
 
1921
        if (!root.contains("CONTRAT_PREVOYANCE_CONTRAT_SALARIE")) {
1922
 
1923
            final SQLCreateTable createTableSal = new SQLCreateTable(root, "CONTRAT_PREVOYANCE_CONTRAT_SALARIE");
1924
            final SQLTable tableInfosSalarie = root.getTable("INFOS_SALARIE_PAYE");
1925
            createTableSal.addForeignColumn("ID_INFOS_SALARIE_PAYE", tableInfosSalarie);
1926
            createTableSal.addForeignColumn("ID_CONTRAT_PREVOYANCE", root.getTable("CONTRAT_PREVOYANCE"));
1927
            createTableSal.addVarCharColumn("CODE_OPTION", 256);
1928
            createTableSal.addVarCharColumn("CODE_POPULATION", 256);
1929
            createTableSal.addIntegerColumn("NB_ENFANT_CHARGE", null, true);
1930
            createTableSal.addIntegerColumn("NB_ADULTE_AYANT_DROIT", null, true);
1931
            createTableSal.addIntegerColumn("NB_AYANT_DROIT", null, true);
1932
            createTableSal.addIntegerColumn("NB_AYANT_DROIT_AUTRE", null, true);
1933
            createTableSal.addIntegerColumn("NB_ENFANT_AYANT_DROIT", null, true);
1934
 
1935
            try {
1936
                root.getBase().getDataSource().execute(createTableSal.asString());
1937
                insertUndef(createTableSal);
1938
                root.refetchTable("CONTRAT_PREVOYANCE_CONTRAT_SALARIE");
1939
                root.getSchema().updateVersion();
1940
 
1941
                String up = "UPDATE " + new SQLName(root.getName(), tableInfosSalarie.getName()).quote() + " i SET \"ID_SALARIE\" = (SELECT s.\"ID\" FROM "
1942
                        + new SQLName(root.getName(), tableInfosSalarie.getForeignTable("ID_SALARIE").getName()).quote() + " s WHERE s.\"ID_INFOS_SALARIE_PAYE\"=i.\"ID\" and s.\"ARCHIVE\"=0)"
1943
                        + " WHERE i.\"ID\" IN (SELECT i2.\"ID_INFOS_SALARIE_PAYE\" FROM " + new SQLName(root.getName(), tableInfosSalarie.getForeignTable("ID_SALARIE").getName()).quote();
1944
                up += " i2 WHERE i2.\"ARCHIVE\"=0)";
1945
 
1946
                root.getBase().getDataSource().execute(up);
1947
 
1948
            } catch (SQLException ex) {
1949
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_PREVOYANCE_SALARIE", ex);
1950
            }
1951
        }
1952
        if (!root.contains("CONTRAT_PREVOYANCE_RUBRIQUE"))
1953
 
1954
        {
1955
 
1956
            final SQLCreateTable createTableRub = new SQLCreateTable(root, "CONTRAT_PREVOYANCE_RUBRIQUE");
1957
            createTableRub.addForeignColumn("ID_RUBRIQUE_COTISATION", root.findTable("RUBRIQUE_COTISATION"));
1958
            createTableRub.addForeignColumn("ID_CONTRAT_PREVOYANCE", root.getTable("CONTRAT_PREVOYANCE"));
1959
 
1960
            try {
1961
                root.getBase().getDataSource().execute(createTableRub.asString());
1962
                insertUndef(createTableRub);
1963
                root.refetchTable("CONTRAT_PREVOYANCE_RUBRIQUE");
1964
                root.getSchema().updateVersion();
1965
            } catch (SQLException ex) {
1966
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_PREVOYANCE_RUBRIQUE", ex);
1967
            }
1968
        }
1969
 
1970
        if (!root.contains("CONTRAT_PREVOYANCE_RUBRIQUE_NET"))
1971
 
1972
        {
1973
 
1974
            final SQLCreateTable createTableRub = new SQLCreateTable(root, "CONTRAT_PREVOYANCE_RUBRIQUE_NET");
1975
            createTableRub.addForeignColumn("ID_RUBRIQUE_NET", root.findTable("RUBRIQUE_NET"));
1976
            createTableRub.addForeignColumn("ID_CONTRAT_PREVOYANCE", root.getTable("CONTRAT_PREVOYANCE"));
1977
 
1978
            try {
1979
                root.getBase().getDataSource().execute(createTableRub.asString());
1980
                insertUndef(createTableRub);
1981
                root.refetchTable("CONTRAT_PREVOYANCE_RUBRIQUE_NET");
1982
                root.getSchema().updateVersion();
1983
            } catch (SQLException ex) {
1984
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_PREVOYANCE_RUBRIQUE_NET", ex);
1985
            }
1986
        }
1987
        if (!root.contains("AYANT_DROIT")) {
1988
 
1989
            final SQLCreateTable createTableAyantDroit = new SQLCreateTable(root, "AYANT_DROIT");
1990
            createTableAyantDroit.addVarCharColumn("NOM", 256);
1991
            createTableAyantDroit.addForeignColumn("ID_SALARIE", root.findTable("SALARIE"));
1992
            createTableAyantDroit.addForeignColumn("ID_AYANT_DROIT_TYPE", root.findTable("AYANT_DROIT_TYPE"));
1993
            createTableAyantDroit.addBooleanColumn("REGIME_ALSACE", Boolean.FALSE, false);
1994
            createTableAyantDroit.addVarCharColumn("NIR", 256);
1995
            createTableAyantDroit.addVarCharColumn("PRENOMS", 256);
1996
            createTableAyantDroit.addVarCharColumn("CODE_ORGANISME_AFFILIATION", 256);
1997
            createTableAyantDroit.addVarCharColumn("CODE_OPTION", 256);
1998
            createTableAyantDroit.addVarCharColumn("NIR_OUVRANT_DROIT", 256);
1999
            createTableAyantDroit.addDateAndTimeColumn("DATE_DEBUT_RATTACHEMENT");
2000
            createTableAyantDroit.addDateAndTimeColumn("DATE_FIN_RATTACHEMENT");
2001
            createTableAyantDroit.addDateAndTimeColumn("DATE_NAISSANCE");
2002
            try {
2003
                root.getBase().getDataSource().execute(createTableAyantDroit.asString());
2004
                insertUndef(createTableAyantDroit);
2005
                root.refetchTable("AYANT_DROIT");
2006
                root.getSchema().updateVersion();
2007
            } catch (SQLException ex) {
2008
                throw new IllegalStateException("Erreur lors de la création de la table " + "AYANT_DROIT", ex);
2009
            }
2010
 
2011
            final SQLCreateTable createTablePrevAyant = new SQLCreateTable(root, "CONTRAT_PREVOYANCE_AYANT_DROIT");
2012
            createTablePrevAyant.addForeignColumn("ID_AYANT_DROIT", root.getTable("AYANT_DROIT"));
2013
            createTablePrevAyant.addForeignColumn("ID_CONTRAT_PREVOYANCE", root.getTable("CONTRAT_PREVOYANCE"));
2014
 
2015
            try {
2016
                root.getBase().getDataSource().execute(createTablePrevAyant.asString());
2017
                insertUndef(createTablePrevAyant);
2018
                root.refetchTable("CONTRAT_PREVOYANCE_AYANT_DROIT");
2019
                root.getSchema().updateVersion();
2020
            } catch (SQLException ex) {
2021
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_PREVOYANCE_AYANT_DROIT", ex);
2022
            }
2023
        }
2024
        if (!root.contains("CODE_PENIBILITE_CONTRAT_SALARIE")) {
2025
 
2026
            final SQLCreateTable createTableSal = new SQLCreateTable(root, "CODE_PENIBILITE_CONTRAT_SALARIE");
2027
            final SQLTable tableInfosSalarie = root.getTable("INFOS_SALARIE_PAYE");
2028
            createTableSal.addForeignColumn("ID_INFOS_SALARIE_PAYE", tableInfosSalarie);
2029
            createTableSal.addForeignColumn("ID_CODE_PENIBILITE", root.findTable("CODE_PENIBILITE"));
2030
 
2031
            try {
2032
                root.getBase().getDataSource().execute(createTableSal.asString());
2033
                insertUndef(createTableSal);
2034
                root.refetchTable("CODE_PENIBILITE_CONTRAT_SALARIE");
2035
                root.getSchema().updateVersion();
2036
 
2037
            } catch (SQLException ex) {
2038
                throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_PENIBILITE_CONTRAT_SALARIE", ex);
2039
            }
2040
        }
182 ilm 2041
 
2042
        if (!root.contains("ARRET_CHOMAGE_INTEMPERIE")) {
2043
 
2044
            final SQLCreateTable createTableSal = new SQLCreateTable(root, "ARRET_CHOMAGE_INTEMPERIE");
2045
            final SQLTable tableInfosSalarie = root.getTable("INFOS_SALARIE_PAYE");
2046
            createTableSal.addForeignColumn("ID_INFOS_SALARIE_PAYE", tableInfosSalarie);
2047
            createTableSal.addForeignColumn("ID_CODE_AMENAGEMENT_PARTIEL", root.findTable("CODE_AMENAGEMENT_PARTIEL"));
2048
            createTableSal.addForeignColumn("ID_CODE_SUSPENSION", root.findTable("CODE_SUSPENSION"));
2049
            createTableSal.addColumn("DATE_DEBUT_SUSPENSION", "date");
2050
            createTableSal.addColumn("DATE_FIN_SUSPENSION", "date");
2051
 
2052
            try {
2053
                root.getBase().getDataSource().execute(createTableSal.asString());
2054
                insertUndef(createTableSal);
2055
                root.refetchTable("ARRET_CHOMAGE_INTEMPERIE");
2056
                root.getSchema().updateVersion();
2057
            } catch (SQLException ex) {
2058
                throw new IllegalStateException("Erreur lors de la création de la table " + "ARRET_CHOMAGE_INTEMPERIE", ex);
2059
            }
2060
        }
2061
 
2062
        if (!tableContrat.contains("ID_CODE_CAISSE_CONGES_PAYES")) {
2063
            AlterTable alterContrat = new AlterTable(tableContrat);
2064
            alterContrat.addForeignColumn("ID_CODE_CAISSE_CONGES_PAYES", root.findTable("CODE_CAISSE_CONGES_PAYES"));
2065
            alterContrat.addDecimalColumn("TAUX_FRAIS_PROFESSIONNELS", 16, 4, null, true);
2066
            root.getBase().getDataSource().execute(alterContrat.asString());
2067
            root.getSchema().updateVersion();
2068
        }
2069
 
132 ilm 2070
    }
2071
 
2072
}