OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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