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 |
|
|
|
16 |
import org.openconcerto.sql.model.DBRoot;
|
|
|
17 |
import org.openconcerto.sql.model.SQLBase;
|
|
|
18 |
import org.openconcerto.sql.model.SQLRow;
|
|
|
19 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
|
|
20 |
import org.openconcerto.sql.model.SQLRowValues;
|
|
|
21 |
import org.openconcerto.sql.model.SQLSelect;
|
|
|
22 |
import org.openconcerto.sql.model.SQLSyntax;
|
|
|
23 |
import org.openconcerto.sql.model.SQLTable;
|
|
|
24 |
import org.openconcerto.sql.model.Where;
|
|
|
25 |
import org.openconcerto.sql.request.Inserter;
|
|
|
26 |
import org.openconcerto.sql.request.Inserter.Insertion;
|
|
|
27 |
import org.openconcerto.sql.utils.AlterTable;
|
|
|
28 |
import org.openconcerto.sql.utils.ReOrder;
|
|
|
29 |
import org.openconcerto.sql.utils.SQLCreateTable;
|
|
|
30 |
import org.openconcerto.utils.Tuple2;
|
|
|
31 |
|
|
|
32 |
import java.sql.SQLException;
|
|
|
33 |
import java.util.ArrayList;
|
|
|
34 |
import java.util.Arrays;
|
|
|
35 |
import java.util.List;
|
|
|
36 |
|
|
|
37 |
public class DSNInstallationUtils {
|
|
|
38 |
|
|
|
39 |
private void insertUndef(final SQLCreateTable ct) throws SQLException {
|
|
|
40 |
// check that we can use insertReturnFirstField()
|
|
|
41 |
if (ct.getPrimaryKey().size() != 1)
|
|
|
42 |
throw new IllegalStateException("Not one and only one field in the PK : " + ct.getPrimaryKey());
|
|
|
43 |
final Insertion<?> insertion = new Inserter(ct).insertReturnFirstField("(" + SQLBase.quoteIdentifier(SQLSyntax.ORDER_NAME) + ") VALUES(" + ReOrder.MIN_ORDER + ")", false);
|
|
|
44 |
assert insertion.getCount() == 1;
|
|
|
45 |
if (insertion.getRows().size() != 1)
|
|
|
46 |
throw new IllegalStateException("Missing ID " + insertion.getRows());
|
|
|
47 |
SQLTable.setUndefID(ct.getRoot().getSchema(), ct.getName(), ((Number) insertion.getRows().get(0)).intValue());
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
private void insertValues(List<Tuple2<String, String>> values, SQLTable table) throws SQLException {
|
|
|
51 |
for (Tuple2<String, String> tuple2 : values) {
|
|
|
52 |
SQLRowValues rowVals = new SQLRowValues(table);
|
|
|
53 |
rowVals.put("CODE", tuple2.get0());
|
|
|
54 |
rowVals.put("NOM", tuple2.get1());
|
|
|
55 |
rowVals.commit();
|
|
|
56 |
}
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
public void updateDSNCommonTable(final DBRoot root) throws SQLException {
|
|
|
60 |
|
|
|
61 |
SQLTable societeCommonT = root.getTable("SOCIETE_COMMON");
|
|
|
62 |
if (!societeCommonT.contains("IBAN")) {
|
|
|
63 |
AlterTable t = new AlterTable(societeCommonT);
|
|
|
64 |
t.addVarCharColumn("IBAN", 256);
|
|
|
65 |
t.addVarCharColumn("BIC", 256);
|
|
|
66 |
root.getBase().getDataSource().execute(t.asString());
|
|
|
67 |
root.refetchTable("SOCIETE_COMMON");
|
|
|
68 |
root.getSchema().updateVersion();
|
|
|
69 |
}
|
|
|
70 |
if (!societeCommonT.contains("ORG_PROTECTION_SOCIAL_ID")) {
|
|
|
71 |
AlterTable t = new AlterTable(societeCommonT);
|
|
|
72 |
t.addVarCharColumn("ORG_PROTECTION_SOCIAL_ID", 256);
|
|
|
73 |
root.getBase().getDataSource().execute(t.asString());
|
|
|
74 |
root.refetchTable("SOCIETE_COMMON");
|
|
|
75 |
root.getSchema().updateVersion();
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
SQLTable tableRubCot = root.getTable("RUBRIQUE_COTISATION");
|
|
|
79 |
if (!tableRubCot.contains("ASSIETTE_PLAFONNEE")) {
|
|
|
80 |
AlterTable tableRub = new AlterTable(tableRubCot);
|
|
|
81 |
tableRub.addBooleanColumn("ASSIETTE_PLAFONNEE", false, false);
|
|
|
82 |
root.getBase().getDataSource().execute(tableRub.asString());
|
|
|
83 |
root.refetchTable("RUBRIQUE_COTISATION");
|
|
|
84 |
root.getSchema().updateVersion();
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
if (!root.contains("CODE_CAISSE_TYPE_RUBRIQUE")) {
|
|
|
88 |
final SQLCreateTable createTableCode = new SQLCreateTable(root, "CODE_CAISSE_TYPE_RUBRIQUE");
|
|
|
89 |
createTableCode.addVarCharColumn("CODE", 25);
|
|
|
90 |
createTableCode.addVarCharColumn("NOM", 512);
|
|
|
91 |
createTableCode.addVarCharColumn("CAISSE_COTISATION", 512);
|
|
|
92 |
|
|
|
93 |
try {
|
|
|
94 |
root.getBase().getDataSource().execute(createTableCode.asString());
|
|
|
95 |
insertUndef(createTableCode);
|
|
|
96 |
root.refetchTable("CODE_CAISSE_TYPE_RUBRIQUE");
|
|
|
97 |
|
|
|
98 |
final SQLTable table = root.getTable("CODE_CAISSE_TYPE_RUBRIQUE");
|
|
|
99 |
|
|
|
100 |
DsnUrssafCode codeUrssaf = new DsnUrssafCode();
|
|
|
101 |
codeUrssaf.insertCode(table);
|
|
|
102 |
|
|
|
103 |
List<String> tableRubName = Arrays.asList("RUBRIQUE_BRUT", "RUBRIQUE_COTISATION", "RUBRIQUE_NET");
|
|
|
104 |
for (String t : tableRubName) {
|
|
|
105 |
AlterTable tableRub = new AlterTable(root.getTable(t));
|
|
|
106 |
tableRub.addForeignColumn("ID_CODE_CAISSE_TYPE_RUBRIQUE", table);
|
|
|
107 |
root.getBase().getDataSource().execute(tableRub.asString());
|
|
|
108 |
root.refetchTable(t);
|
|
|
109 |
}
|
|
|
110 |
root.getSchema().updateVersion();
|
|
|
111 |
|
|
|
112 |
} catch (SQLException ex) {
|
|
|
113 |
throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_CAISSE_TYPE_RUBRIQUE", ex);
|
|
|
114 |
}
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
if (!root.contains("MOTIF_ARRET_TRAVAIL")) {
|
|
|
118 |
final SQLCreateTable createTableMotif = new SQLCreateTable(root, "MOTIF_ARRET_TRAVAIL");
|
|
|
119 |
createTableMotif.addVarCharColumn("CODE", 25);
|
|
|
120 |
createTableMotif.addVarCharColumn("NOM", 512);
|
|
|
121 |
|
|
|
122 |
try {
|
|
|
123 |
root.getBase().getDataSource().execute(createTableMotif.asString());
|
|
|
124 |
insertUndef(createTableMotif);
|
|
|
125 |
root.refetchTable("MOTIF_ARRET_TRAVAIL");
|
|
|
126 |
root.getSchema().updateVersion();
|
|
|
127 |
|
|
|
128 |
final SQLTable table = root.getTable("MOTIF_ARRET_TRAVAIL");
|
|
|
129 |
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
|
|
|
130 |
v.add(Tuple2.create("01", "maladie"));
|
|
|
131 |
v.add(Tuple2.create("02", "maternité /adoption"));
|
|
|
132 |
v.add(Tuple2.create("03", "paternité / accueil de l’enfant"));
|
|
|
133 |
v.add(Tuple2.create("04", "congé suite à un accident de trajet"));
|
|
|
134 |
v.add(Tuple2.create("05", "congé suite à maladie professionnelle"));
|
|
|
135 |
v.add(Tuple2.create("06", "congé suite à accident de travail ou de service"));
|
|
|
136 |
v.add(Tuple2.create("07", "femme enceinte dispensée de travail"));
|
|
|
137 |
v.add(Tuple2.create("99", "annulation"));
|
|
|
138 |
|
|
|
139 |
insertValues(v, table);
|
|
|
140 |
} catch (SQLException ex) {
|
|
|
141 |
throw new IllegalStateException("Erreur lors de la création de la table " + "MOTIF_ARRET_TRAVAIL", ex);
|
|
|
142 |
}
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
if (!root.contains("CODE_BASE_ASSUJETTIE")) {
|
|
|
146 |
final SQLCreateTable createTableCodeBase = new SQLCreateTable(root, "CODE_BASE_ASSUJETTIE");
|
|
|
147 |
createTableCodeBase.addVarCharColumn("CODE", 25);
|
|
|
148 |
createTableCodeBase.addVarCharColumn("NOM", 512);
|
|
|
149 |
|
|
|
150 |
try {
|
|
|
151 |
root.getBase().getDataSource().execute(createTableCodeBase.asString());
|
|
|
152 |
insertUndef(createTableCodeBase);
|
|
|
153 |
root.refetchTable("CODE_BASE_ASSUJETTIE");
|
|
|
154 |
root.getSchema().updateVersion();
|
|
|
155 |
|
|
|
156 |
final SQLTable table = root.getTable("CODE_BASE_ASSUJETTIE");
|
|
|
157 |
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
|
|
|
158 |
|
|
|
159 |
v.add(Tuple2.create("02", "Assiette brute plafonnée"));
|
|
|
160 |
v.add(Tuple2.create("03", "Assiette brute déplafonnée"));
|
|
|
161 |
v.add(Tuple2.create("04", "Assiette de la contribution sociale généralisée"));
|
|
|
162 |
v.add(Tuple2.create("07", "Assiette des contributions d'Assurance Chômage"));
|
|
|
163 |
v.add(Tuple2.create("08", "Assiette retraite CPRP SNCF"));
|
|
|
164 |
v.add(Tuple2.create("09", "Assiette de compensation bilatérale maladie CPRP SNCF"));
|
|
|
165 |
v.add(Tuple2.create("10", "Base brute fiscale"));
|
|
|
166 |
v.add(Tuple2.create("11", "Base forfaitaire soumise aux cotisations de Sécurité Sociale"));
|
|
|
167 |
v.add(Tuple2.create("12", "Assiette du crédit d'impôt compétitivité-emploi"));
|
|
|
168 |
v.add(Tuple2.create("13", "Assiette du forfait social à 8%"));
|
|
|
169 |
v.add(Tuple2.create("14", "Assiette du forfait social à 20%"));
|
|
|
170 |
|
|
|
171 |
insertValues(v, table);
|
|
|
172 |
} catch (SQLException ex) {
|
|
|
173 |
throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_BASE_ASSUJETTIE", ex);
|
|
|
174 |
}
|
|
|
175 |
}
|
|
|
176 |
if (!tableRubCot.contains("ID_CODE_BASE_ASSUJETTIE")) {
|
|
|
177 |
AlterTable alterTableCot = new AlterTable(tableRubCot);
|
|
|
178 |
alterTableCot.addForeignColumn("ID_CODE_BASE_ASSUJETTIE", root.getTable("CODE_BASE_ASSUJETTIE"));
|
|
|
179 |
root.getBase().getDataSource().execute(alterTableCot.asString());
|
|
|
180 |
root.refetchTable("RUBRIQUE_COTISATION");
|
|
|
181 |
root.getSchema().updateVersion();
|
|
|
182 |
}
|
|
|
183 |
|
|
|
184 |
if (!root.contains("CODE_TYPE_RUBRIQUE_BRUT")) {
|
|
|
185 |
final SQLCreateTable createTableCodeBase = new SQLCreateTable(root, "CODE_TYPE_RUBRIQUE_BRUT");
|
|
|
186 |
createTableCodeBase.addVarCharColumn("CODE", 25);
|
|
|
187 |
createTableCodeBase.addVarCharColumn("NOM", 512);
|
|
|
188 |
createTableCodeBase.addVarCharColumn("TYPE", 512);
|
|
|
189 |
|
|
|
190 |
try {
|
|
|
191 |
root.getBase().getDataSource().execute(createTableCodeBase.asString());
|
|
|
192 |
insertUndef(createTableCodeBase);
|
|
|
193 |
root.refetchTable("CODE_TYPE_RUBRIQUE_BRUT");
|
|
|
194 |
root.getSchema().updateVersion();
|
|
|
195 |
|
|
|
196 |
DsnBrutCode brutCode = new DsnBrutCode();
|
|
|
197 |
brutCode.insertCode(root.getTable("CODE_TYPE_RUBRIQUE_BRUT"));
|
|
|
198 |
} catch (SQLException ex) {
|
|
|
199 |
throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_BASE_ASSUJETTIE", ex);
|
|
|
200 |
}
|
|
|
201 |
}
|
|
|
202 |
|
|
|
203 |
SQLTable tableRubBrut = root.getTable("RUBRIQUE_BRUT");
|
|
|
204 |
if (!tableRubBrut.contains("ID_CODE_TYPE_RUBRIQUE_BRUT")) {
|
|
|
205 |
|
|
|
206 |
AlterTable alterTableBrut = new AlterTable(tableRubBrut);
|
|
|
207 |
alterTableBrut.addForeignColumn("ID_CODE_TYPE_RUBRIQUE_BRUT", root.getTable("CODE_TYPE_RUBRIQUE_BRUT"));
|
|
|
208 |
root.getBase().getDataSource().execute(alterTableBrut.asString());
|
|
|
209 |
root.refetchTable("RUBRIQUE_BRUT");
|
|
|
210 |
root.getSchema().updateVersion();
|
|
|
211 |
}
|
|
|
212 |
|
|
|
213 |
if (!root.contains("DSN_REGIME_LOCAL")) {
|
|
|
214 |
final SQLCreateTable createTableMotif = new SQLCreateTable(root, "DSN_REGIME_LOCAL");
|
|
|
215 |
createTableMotif.addVarCharColumn("CODE", 25);
|
|
|
216 |
createTableMotif.addVarCharColumn("NOM", 512);
|
|
|
217 |
|
|
|
218 |
try {
|
|
|
219 |
root.getBase().getDataSource().execute(createTableMotif.asString());
|
|
|
220 |
insertUndef(createTableMotif);
|
|
|
221 |
root.refetchTable("DSN_REGIME_LOCAL");
|
|
|
222 |
root.getSchema().updateVersion();
|
|
|
223 |
|
|
|
224 |
final SQLTable table = root.getTable("DSN_REGIME_LOCAL");
|
|
|
225 |
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
|
|
|
226 |
v.add(Tuple2.create("99", "non applicable"));
|
|
|
227 |
v.add(Tuple2.create("01", "régime local Alsace Moselle"));
|
|
|
228 |
insertValues(v, table);
|
|
|
229 |
} catch (SQLException ex) {
|
|
|
230 |
throw new IllegalStateException("Erreur lors de la création de la table " + "DSN_REGIME_LOCAL", ex);
|
|
|
231 |
}
|
|
|
232 |
}
|
|
|
233 |
|
|
|
234 |
if (!root.contains("CONTRAT_MODALITE_TEMPS")) {
|
|
|
235 |
final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CONTRAT_MODALITE_TEMPS");
|
|
|
236 |
createTableMotif.addVarCharColumn("CODE", 25);
|
|
|
237 |
createTableMotif.addVarCharColumn("NOM", 512);
|
|
|
238 |
|
|
|
239 |
try {
|
|
|
240 |
root.getBase().getDataSource().execute(createTableMotif.asString());
|
|
|
241 |
insertUndef(createTableMotif);
|
|
|
242 |
root.refetchTable("CONTRAT_MODALITE_TEMPS");
|
|
|
243 |
root.getSchema().updateVersion();
|
|
|
244 |
|
|
|
245 |
final SQLTable table = root.getTable("CONTRAT_MODALITE_TEMPS");
|
|
|
246 |
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
|
|
|
247 |
v.add(Tuple2.create("10", "temps plein"));
|
|
|
248 |
v.add(Tuple2.create("20", "temps partiel"));
|
|
|
249 |
v.add(Tuple2.create("21", "temps partiel thérapeutique"));
|
|
|
250 |
v.add(Tuple2.create("99", "salarié non concerné"));
|
|
|
251 |
insertValues(v, table);
|
|
|
252 |
} catch (SQLException ex) {
|
|
|
253 |
throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_MODALITE_TEMPS", ex);
|
|
|
254 |
}
|
|
|
255 |
}
|
|
|
256 |
|
|
|
257 |
if (!root.contains("CONTRAT_REGIME_MALADIE")) {
|
|
|
258 |
final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CONTRAT_REGIME_MALADIE");
|
|
|
259 |
createTableMotif.addVarCharColumn("CODE", 25);
|
|
|
260 |
createTableMotif.addVarCharColumn("NOM", 512);
|
|
|
261 |
|
|
|
262 |
try {
|
|
|
263 |
root.getBase().getDataSource().execute(createTableMotif.asString());
|
|
|
264 |
insertUndef(createTableMotif);
|
|
|
265 |
root.refetchTable("CONTRAT_REGIME_MALADIE");
|
|
|
266 |
root.getSchema().updateVersion();
|
|
|
267 |
|
|
|
268 |
final SQLTable table = root.getTable("CONTRAT_REGIME_MALADIE");
|
|
|
269 |
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
|
|
|
270 |
v.add(Tuple2.create("134", "régime spécial de la SNCF"));
|
|
|
271 |
v.add(Tuple2.create("135", "régime spécial de la RATP"));
|
|
|
272 |
v.add(Tuple2.create("136", "établissement des invalides de la marine (ENIM)"));
|
|
|
273 |
v.add(Tuple2.create("137", "mineurs ou assimilés (CANMSS)"));
|
|
|
274 |
v.add(Tuple2.create("138", "militaires de carrière (CNMSS)"));
|
|
|
275 |
v.add(Tuple2.create("140", "clercs et employés de notaires (CRPCEN)"));
|
|
|
276 |
v.add(Tuple2.create("141", "chambre de commerce et d'industrie de Paris"));
|
|
|
277 |
v.add(Tuple2.create("144", "Assemblée Nationale"));
|
|
|
278 |
v.add(Tuple2.create("145", "Sénat"));
|
|
|
279 |
v.add(Tuple2.create("146", "port autonome de Bordeaux"));
|
|
|
280 |
v.add(Tuple2.create("147", "industries électriques et gazières (CAMIEG)"));
|
|
|
281 |
v.add(Tuple2.create("149", "régimes des cultes (CAVIMAC)"));
|
|
|
282 |
v.add(Tuple2.create("200", "régime général (CNAM)"));
|
|
|
283 |
v.add(Tuple2.create("300", "régime agricole (MSA)"));
|
|
|
284 |
v.add(Tuple2.create("400", "régime spécial Banque de France"));
|
|
|
285 |
v.add(Tuple2.create("900", "autre régime (réservé Polynésie Française, Nouvelle Calédonie)"));
|
|
|
286 |
v.add(Tuple2.create("999", "autre"));
|
|
|
287 |
|
|
|
288 |
insertValues(v, table);
|
|
|
289 |
} catch (SQLException ex) {
|
|
|
290 |
throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_REGIME_MALADIE", ex);
|
|
|
291 |
}
|
|
|
292 |
}
|
|
|
293 |
|
|
|
294 |
if (!root.contains("CONTRAT_REGIME_VIEILLESSE")) {
|
|
|
295 |
final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CONTRAT_REGIME_VIEILLESSE");
|
|
|
296 |
createTableMotif.addVarCharColumn("CODE", 25);
|
|
|
297 |
createTableMotif.addVarCharColumn("NOM", 512);
|
|
|
298 |
|
|
|
299 |
try {
|
|
|
300 |
root.getBase().getDataSource().execute(createTableMotif.asString());
|
|
|
301 |
insertUndef(createTableMotif);
|
|
|
302 |
root.refetchTable("CONTRAT_REGIME_VIEILLESSE");
|
|
|
303 |
root.getSchema().updateVersion();
|
|
|
304 |
|
|
|
305 |
final SQLTable table = root.getTable("CONTRAT_REGIME_VIEILLESSE");
|
|
|
306 |
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
|
|
|
307 |
v.add(Tuple2.create("120", "retraite des agents des collectivités locales (CNRACL)"));
|
|
|
308 |
v.add(Tuple2.create("121", "pensions des ouvriers des établissements industriels de l'Etat (FSPOEIE)"));
|
|
|
309 |
v.add(Tuple2.create("122", "pensions civiles et militaires de retraite de l'Etat (SRE)"));
|
|
|
310 |
v.add(Tuple2.create("134", "régime spécial de la SNCF"));
|
|
|
311 |
v.add(Tuple2.create("135", "régime spécial de la RATP"));
|
|
|
312 |
v.add(Tuple2.create("136", "établissement des invalides de la marine (ENIM)"));
|
|
|
313 |
v.add(Tuple2.create("137", "mineurs ou assimilés (fonds Caisse des Dépôts)"));
|
|
|
314 |
v.add(Tuple2.create("139", "Banque de France"));
|
|
|
315 |
v.add(Tuple2.create("140", "clercs et employés de notaires (CRPCEN)"));
|
|
|
316 |
v.add(Tuple2.create("141", "chambre de commerce et d'industrie de Paris"));
|
|
|
317 |
v.add(Tuple2.create("144", "Assemblée Nationale"));
|
|
|
318 |
v.add(Tuple2.create("145", "Sénat"));
|
|
|
319 |
v.add(Tuple2.create("147", "industries électriques et gazières (CNIEG)"));
|
|
|
320 |
v.add(Tuple2.create("149", "régime des cultes (CAVIMAC)"));
|
|
|
321 |
v.add(Tuple2.create("157", "régime de retraite des avocats (CNBF)"));
|
|
|
322 |
v.add(Tuple2.create("158", "SEITA"));
|
|
|
323 |
v.add(Tuple2.create("159", "Comédie Française"));
|
|
|
324 |
v.add(Tuple2.create("160", "Opéra de Paris"));
|
|
|
325 |
v.add(Tuple2.create("200", "régime général (CNAV)"));
|
|
|
326 |
v.add(Tuple2.create("300", "régime agricole (MSA)"));
|
|
|
327 |
v.add(Tuple2.create("900", "autre régime (réservé Polynésie Française, Nouvelle Calédonie, Principauté de Monaco)"));
|
|
|
328 |
v.add(Tuple2.create("903", "salariés étrangers exemptés d'affiliation pour le risque vieillesse"));
|
|
|
329 |
v.add(Tuple2.create("999", "cas particuliers d'affiliation"));
|
|
|
330 |
|
|
|
331 |
insertValues(v, table);
|
|
|
332 |
} catch (SQLException ex) {
|
|
|
333 |
throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_REGIME_VIEILLESSE", ex);
|
|
|
334 |
}
|
|
|
335 |
}
|
|
|
336 |
|
|
|
337 |
if (!root.contains("CONTRAT_MOTIF_RECOURS")) {
|
|
|
338 |
final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CONTRAT_MOTIF_RECOURS");
|
|
|
339 |
createTableMotif.addVarCharColumn("CODE", 25);
|
|
|
340 |
createTableMotif.addVarCharColumn("NOM", 512);
|
|
|
341 |
|
|
|
342 |
try {
|
|
|
343 |
root.getBase().getDataSource().execute(createTableMotif.asString());
|
|
|
344 |
insertUndef(createTableMotif);
|
|
|
345 |
root.refetchTable("CONTRAT_MOTIF_RECOURS");
|
|
|
346 |
root.getSchema().updateVersion();
|
|
|
347 |
|
|
|
348 |
final SQLTable table = root.getTable("CONTRAT_MOTIF_RECOURS");
|
|
|
349 |
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
|
|
|
350 |
v.add(Tuple2.create("01", "Remplacement d'un salarié"));
|
|
|
351 |
v.add(Tuple2.create("02", "Accroissement temporaire de l'activité de l'entreprise"));
|
|
|
352 |
v.add(Tuple2.create("03", "Emplois à caractère saisonnier"));
|
|
|
353 |
v.add(Tuple2.create("04", "Contrat vendanges"));
|
|
|
354 |
v.add(Tuple2.create("05", "Contrat à durée déterminée d’usage"));
|
|
|
355 |
v.add(Tuple2.create("06", "Contrat à durée déterminée à objet défini"));
|
|
|
356 |
v.add(Tuple2.create("07", "Remplacement d'un chef d'entreprise"));
|
|
|
357 |
v.add(Tuple2.create("08", "Remplacement du chef d'une exploitation agricole"));
|
|
|
358 |
v.add(Tuple2.create("09", "Recrutement de personnes sans emploi rencontrant des difficultés sociales et professionnelles particulières"));
|
|
|
359 |
v.add(Tuple2.create("10", "Complément de formation professionnelle au salarié"));
|
|
|
360 |
v.add(Tuple2.create("11",
|
|
|
361 |
"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"));
|
|
|
362 |
v.add(Tuple2.create("12", "Remplacement d’un salarié passé provisoirement à temps partiel"));
|
|
|
363 |
v.add(Tuple2.create("13", "Attente de la suppression définitive du poste du salarié ayant quitté définitivement l’entreprise"));
|
|
|
364 |
insertValues(v, table);
|
|
|
365 |
} catch (SQLException ex) {
|
|
|
366 |
throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_MOTIF_RECOURS", ex);
|
|
|
367 |
}
|
|
|
368 |
}
|
|
|
369 |
|
|
|
370 |
if (!root.contains("CONTRAT_DETACHE_EXPATRIE")) {
|
|
|
371 |
final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CONTRAT_DETACHE_EXPATRIE");
|
|
|
372 |
createTableMotif.addVarCharColumn("CODE", 25);
|
|
|
373 |
createTableMotif.addVarCharColumn("NOM", 512);
|
|
|
374 |
|
|
|
375 |
try {
|
|
|
376 |
root.getBase().getDataSource().execute(createTableMotif.asString());
|
|
|
377 |
insertUndef(createTableMotif);
|
|
|
378 |
root.refetchTable("CONTRAT_DETACHE_EXPATRIE");
|
|
|
379 |
root.getSchema().updateVersion();
|
|
|
380 |
|
|
|
381 |
final SQLTable table = root.getTable("CONTRAT_DETACHE_EXPATRIE");
|
|
|
382 |
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
|
|
|
383 |
v.add(Tuple2.create("01", "Détaché"));
|
|
|
384 |
v.add(Tuple2.create("02", "Expatrié"));
|
|
|
385 |
v.add(Tuple2.create("03", "Frontalier"));
|
|
|
386 |
v.add(Tuple2.create("99", "Salarié non concerné"));
|
|
|
387 |
insertValues(v, table);
|
|
|
388 |
} catch (SQLException ex) {
|
|
|
389 |
throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_DETACHE_EXPATRIE", ex);
|
|
|
390 |
}
|
|
|
391 |
}
|
|
|
392 |
|
|
|
393 |
if (!root.contains("DSN_NATURE")) {
|
|
|
394 |
final SQLCreateTable createTableMotif = new SQLCreateTable(root, "DSN_NATURE");
|
|
|
395 |
createTableMotif.addVarCharColumn("CODE", 25);
|
|
|
396 |
createTableMotif.addVarCharColumn("NOM", 512);
|
|
|
397 |
|
|
|
398 |
try {
|
|
|
399 |
root.getBase().getDataSource().execute(createTableMotif.asString());
|
|
|
400 |
insertUndef(createTableMotif);
|
|
|
401 |
root.refetchTable("DSN_NATURE");
|
|
|
402 |
root.getSchema().updateVersion();
|
|
|
403 |
|
|
|
404 |
final SQLTable table = root.getTable("DSN_NATURE");
|
|
|
405 |
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
|
|
|
406 |
v.add(Tuple2.create("01", "DSN Mensuelle"));
|
|
|
407 |
v.add(Tuple2.create("02", "Signalement Fin du contrat de travail"));
|
|
|
408 |
v.add(Tuple2.create("04", "Signalement Arrêt de travail"));
|
|
|
409 |
v.add(Tuple2.create("05", "Signalement Reprise suite à arrêt de travail"));
|
|
|
410 |
v.add(Tuple2.create("06", "DSN reprise d'historique"));
|
|
|
411 |
insertValues(v, table);
|
|
|
412 |
} catch (SQLException ex) {
|
|
|
413 |
throw new IllegalStateException("Erreur lors de la création de la table " + "DSN_NATURE", ex);
|
|
|
414 |
}
|
|
|
415 |
}
|
|
|
416 |
|
|
|
417 |
if (!root.contains("DSN_TYPE")) {
|
|
|
418 |
final SQLCreateTable createTableMotif = new SQLCreateTable(root, "DSN_TYPE");
|
|
|
419 |
createTableMotif.addVarCharColumn("CODE", 25);
|
|
|
420 |
createTableMotif.addVarCharColumn("NOM", 512);
|
|
|
421 |
|
|
|
422 |
try {
|
|
|
423 |
root.getBase().getDataSource().execute(createTableMotif.asString());
|
|
|
424 |
insertUndef(createTableMotif);
|
|
|
425 |
root.refetchTable("DSN_TYPE");
|
|
|
426 |
root.getSchema().updateVersion();
|
|
|
427 |
|
|
|
428 |
final SQLTable table = root.getTable("DSN_TYPE");
|
|
|
429 |
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
|
|
|
430 |
v.add(Tuple2.create("01", "déclaration normale"));
|
|
|
431 |
v.add(Tuple2.create("02", "déclaration normale néant"));
|
|
|
432 |
v.add(Tuple2.create("03", "déclaration annule et remplace intégral"));
|
|
|
433 |
v.add(Tuple2.create("04", "déclaration annule"));
|
|
|
434 |
v.add(Tuple2.create("05", "annule et remplace néant"));
|
|
|
435 |
insertValues(v, table);
|
|
|
436 |
} catch (SQLException ex) {
|
|
|
437 |
throw new IllegalStateException("Erreur lors de la création de la table " + "DSN_TYPE", ex);
|
|
|
438 |
}
|
|
|
439 |
}
|
|
|
440 |
|
|
|
441 |
if (!root.contains("CONTRAT_DISPOSITIF_POLITIQUE")) {
|
|
|
442 |
final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CONTRAT_DISPOSITIF_POLITIQUE");
|
|
|
443 |
createTableMotif.addVarCharColumn("CODE", 25);
|
|
|
444 |
createTableMotif.addVarCharColumn("NOM", 512);
|
|
|
445 |
|
|
|
446 |
try {
|
|
|
447 |
root.getBase().getDataSource().execute(createTableMotif.asString());
|
|
|
448 |
insertUndef(createTableMotif);
|
|
|
449 |
root.refetchTable("CONTRAT_DISPOSITIF_POLITIQUE");
|
|
|
450 |
root.getSchema().updateVersion();
|
|
|
451 |
|
|
|
452 |
final SQLTable table = root.getTable("CONTRAT_DISPOSITIF_POLITIQUE");
|
|
|
453 |
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
|
|
|
454 |
v.add(Tuple2.create("21", "CUI - Contrat Initiative Emploi"));
|
|
|
455 |
v.add(Tuple2.create("41", "CUI - Contrat d'Accompagnement dans l'Emploi"));
|
|
|
456 |
v.add(Tuple2.create("42", "CUI - Contrat d'accès à l'emploi - DOM"));
|
|
|
457 |
v.add(Tuple2.create("50", "Emploi d'avenir secteur marchand"));
|
|
|
458 |
v.add(Tuple2.create("51", "Emploi d'avenir secteur non marchand"));
|
|
|
459 |
v.add(Tuple2.create("61", "Contrat de Professionnalisation"));
|
|
|
460 |
v.add(Tuple2.create("64", "Contrat d'apprentissage entreprises artisanales ou de moins de 11 salariés (loi du 3 janvier 1979)"));
|
|
|
461 |
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)"));
|
|
|
462 |
v.add(Tuple2.create("70", "Contrat à durée déterminée pour les séniors"));
|
|
|
463 |
v.add(Tuple2.create("71", "Contrat à durée déterminée d’insertion"));
|
|
|
464 |
v.add(Tuple2.create("80", "Contrat de génération"));
|
|
|
465 |
v.add(Tuple2.create("81", "Contrat d'apprentissage secteur public (Loi de 1992)"));
|
|
|
466 |
v.add(Tuple2.create("82", "Contrat à durée indéterminée intérimaire"));
|
|
|
467 |
v.add(Tuple2.create("99", "Non concerné"));
|
|
|
468 |
insertValues(v, table);
|
|
|
469 |
} catch (SQLException ex) {
|
|
|
470 |
throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_DISPOSITIF_POLITIQUE", ex);
|
|
|
471 |
}
|
|
|
472 |
}
|
|
|
473 |
|
|
|
474 |
if (!root.contains("MOTIF_REPRISE_ARRET_TRAVAIL")) {
|
|
|
475 |
final SQLCreateTable createTableMotif = new SQLCreateTable(root, "MOTIF_REPRISE_ARRET_TRAVAIL");
|
|
|
476 |
createTableMotif.addVarCharColumn("CODE", 25);
|
|
|
477 |
createTableMotif.addVarCharColumn("NOM", 512);
|
|
|
478 |
|
|
|
479 |
try {
|
|
|
480 |
root.getBase().getDataSource().execute(createTableMotif.asString());
|
|
|
481 |
insertUndef(createTableMotif);
|
|
|
482 |
root.refetchTable("MOTIF_REPRISE_ARRET_TRAVAIL");
|
|
|
483 |
root.getSchema().updateVersion();
|
|
|
484 |
|
|
|
485 |
final SQLTable table = root.getTable("MOTIF_REPRISE_ARRET_TRAVAIL");
|
|
|
486 |
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
|
|
|
487 |
v.add(Tuple2.create("01", "reprise normale"));
|
|
|
488 |
v.add(Tuple2.create("02", "reprise temps partiel thérapeutique"));
|
|
|
489 |
v.add(Tuple2.create("03", "reprise temps partiel raison personnelle"));
|
|
|
490 |
insertValues(v, table);
|
|
|
491 |
} catch (SQLException ex) {
|
|
|
492 |
throw new IllegalStateException("Erreur lors de la création de la table " + "MOTIF_REPRISE_ARRET_TRAVAIL", ex);
|
|
|
493 |
}
|
|
|
494 |
}
|
|
|
495 |
|
|
|
496 |
if (!root.contains("MOTIF_FIN_CONTRAT")) {
|
|
|
497 |
final SQLCreateTable createTableMotif = new SQLCreateTable(root, "MOTIF_FIN_CONTRAT");
|
|
|
498 |
createTableMotif.addVarCharColumn("CODE", 25);
|
|
|
499 |
createTableMotif.addVarCharColumn("NOM", 512);
|
|
|
500 |
|
|
|
501 |
try {
|
|
|
502 |
root.getBase().getDataSource().execute(createTableMotif.asString());
|
|
|
503 |
insertUndef(createTableMotif);
|
|
|
504 |
root.refetchTable("MOTIF_FIN_CONTRAT");
|
|
|
505 |
root.getSchema().updateVersion();
|
|
|
506 |
|
|
|
507 |
final SQLTable table = root.getTable("MOTIF_FIN_CONTRAT");
|
|
|
508 |
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
|
|
|
509 |
v.add(Tuple2.create("011", "licenciement suite à liquidation judiciaire ou à redressement judiciaire"));
|
|
|
510 |
v.add(Tuple2.create("012", "licenciement suite à fermeture définitive de l'établissement"));
|
|
|
511 |
v.add(Tuple2.create("014", "licenciement pour motif économique"));
|
|
|
512 |
v.add(Tuple2.create("015", "licenciement pour fin de chantier"));
|
|
|
513 |
v.add(Tuple2.create("020", "licenciement pour autre motif"));
|
|
|
514 |
v.add(Tuple2.create("025", "autre fin de contrat pour motif économique"));
|
|
|
515 |
v.add(Tuple2.create("026", "rupture pour motif économique dans le cadre d’un contrat de sécurisation professionnelle CSP"));
|
|
|
516 |
v.add(Tuple2.create("031", "fin de contrat à durée déterminée ou fin d'accueil occasionnel"));
|
|
|
517 |
v.add(Tuple2.create("032", "fin de mission d'intérim"));
|
|
|
518 |
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"));
|
|
|
519 |
v.add(Tuple2.create("034", "fin de période d'essai à l'initiative de l'employeur"));
|
|
|
520 |
v.add(Tuple2.create("035", "fin de période d'essai à l'initiative du salarié"));
|
|
|
521 |
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"));
|
|
|
522 |
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é"));
|
|
|
523 |
v.add(Tuple2.create("038", "mise à la retraite par l'employeur"));
|
|
|
524 |
v.add(Tuple2.create("039", "départ à la retraite à l'initiative du salarié"));
|
|
|
525 |
v.add(Tuple2.create("043", "rupture conventionnelle"));
|
|
|
526 |
v.add(Tuple2.create("058", "prise d'acte de la rupture de contrat de travail"));
|
|
|
527 |
v.add(Tuple2.create("059", "démission"));
|
|
|
528 |
v.add(Tuple2.create("065", "décès de l'employeur ou internement / conduit à un licenciement autre motif"));
|
|
|
529 |
v.add(Tuple2.create("066", "décès du salarié / rupture force majeure"));
|
|
|
530 |
v.add(Tuple2.create("081", "fin de contrat d'apprentissage"));
|
|
|
531 |
v.add(Tuple2.create("082", "résiliation judiciaire du contrat de travail"));
|
|
|
532 |
v.add(Tuple2.create("083", "rupture de contrat de travail ou d’un contrat de mission pour force majeure"));
|
|
|
533 |
v.add(Tuple2.create("084", "rupture d'un commun accord du CDD, du contrat d'apprentissage ou d’un contrat de mission"));
|
|
|
534 |
v.add(Tuple2.create("085", "fin de mandat"));
|
|
|
535 |
v.add(Tuple2.create("086", "licenciement convention CATS"));
|
|
|
536 |
v.add(Tuple2.create("087", "licenciement pour faute grave"));
|
|
|
537 |
v.add(Tuple2.create("088", "licenciement pour faute lourde"));
|
|
|
538 |
v.add(Tuple2.create("089", "licenciement pour force majeure"));
|
|
|
539 |
v.add(Tuple2.create("091", "licenciement pour inaptitude physique d'origine non professionnelle"));
|
|
|
540 |
v.add(Tuple2.create("092", "licenciement pour inaptitude physique d'origine professionnelle"));
|
|
|
541 |
v.add(Tuple2.create("093", "licenciement suite à décision d'une autorité administrative"));
|
|
|
542 |
v.add(Tuple2.create("094", "rupture anticipée du contrat de travail pour arrêt de tournage"));
|
|
|
543 |
v.add(Tuple2.create("095", "rupture anticipée du contrat de travail ou d’un contrat de mission pour faute grave"));
|
|
|
544 |
v.add(Tuple2.create("096", "rupture anticipée du contrat de travail ou d’un contrat de mission pour faute lourde"));
|
|
|
545 |
v.add(Tuple2.create("097", "rupture anticipée d’un contrat de travail ou d’un contrat de mission suite à fermeture de l'établissement"));
|
|
|
546 |
v.add(Tuple2.create("098", "retrait d'enfant"));
|
|
|
547 |
v.add(Tuple2.create("998", "transfert du contrat de travail sans rupture du contrat vers un autre établissement n'effectuant pas encore de DSN"));
|
|
|
548 |
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"));
|
|
|
549 |
insertValues(v, table);
|
|
|
550 |
} catch (SQLException ex) {
|
|
|
551 |
throw new IllegalStateException("Erreur lors de la création de la table " + "MOTIF_FIN_CONTRAT", ex);
|
|
|
552 |
}
|
|
|
553 |
}
|
|
|
554 |
|
|
|
555 |
DSNUpdateRubrique dsnUpdateRubrique = new DSNUpdateRubrique(root);
|
|
|
556 |
dsnUpdateRubrique.updateRubriqueCotisation();
|
|
|
557 |
}
|
|
|
558 |
|
|
|
559 |
public void updateDSN(final DBRoot root) throws SQLException {
|
|
|
560 |
final SQLTable tableCodeStatutCat = root.getTable("CODE_STATUT_CATEGORIEL");
|
|
|
561 |
SQLRow rowNonCadre = tableCodeStatutCat.getRow(4);
|
|
|
562 |
if (rowNonCadre != null) {
|
|
|
563 |
rowNonCadre.createEmptyUpdateRow().put("CODE", "04").commit();
|
|
|
564 |
}
|
|
|
565 |
SQLRow rowSansStatut = tableCodeStatutCat.getRow(4);
|
|
|
566 |
if (rowSansStatut != null) {
|
|
|
567 |
rowSansStatut.createEmptyUpdateRow().put("CODE", "99").commit();
|
|
|
568 |
}
|
|
|
569 |
|
|
|
570 |
if (!root.contains("ARRET_TRAVAIL")) {
|
|
|
571 |
|
|
|
572 |
final SQLCreateTable createTable = new SQLCreateTable(root, "ARRET_TRAVAIL");
|
|
|
573 |
createTable.addForeignColumn("SALARIE");
|
|
|
574 |
createTable.addDateAndTimeColumn("DATE_DERNIER_JOUR_TRAV");
|
|
|
575 |
createTable.addDateAndTimeColumn("DATE_FIN_PREV");
|
|
|
576 |
createTable.addBooleanColumn("SUBROGATION", Boolean.FALSE, false);
|
|
|
577 |
createTable.addDateAndTimeColumn("DATE_DEBUT_SUBROGATION");
|
|
|
578 |
createTable.addDateAndTimeColumn("DATE_FIN_SUBROGATION");
|
|
|
579 |
createTable.addForeignColumn("ID_MOTIF_ARRET_TRAVAIL", root.findTable("MOTIF_ARRET_TRAVAIL"));
|
|
|
580 |
createTable.addForeignColumn("ID_MOTIF_REPRISE_ARRET_TRAVAIL", root.findTable("MOTIF_REPRISE_ARRET_TRAVAIL"));
|
|
|
581 |
createTable.addDateAndTimeColumn("DATE_REPRISE");
|
|
|
582 |
createTable.addDateAndTimeColumn("DATE_ACCIDENT");
|
|
|
583 |
|
|
|
584 |
try {
|
|
|
585 |
root.getBase().getDataSource().execute(createTable.asString());
|
|
|
586 |
insertUndef(createTable);
|
|
|
587 |
root.refetchTable("ARRET_TRAVAIL");
|
|
|
588 |
root.getSchema().updateVersion();
|
|
|
589 |
} catch (SQLException ex) {
|
|
|
590 |
throw new IllegalStateException("Erreur lors de la création de la table " + "ARRET_TRAVAIL", ex);
|
|
|
591 |
}
|
|
|
592 |
}
|
|
|
593 |
|
|
|
594 |
if (!root.contains("REPRISE_TRAVAIL")) {
|
|
|
595 |
|
|
|
596 |
final SQLCreateTable createTable = new SQLCreateTable(root, "REPRISE_TRAVAIL");
|
|
|
597 |
createTable.addForeignColumn("SALARIE");
|
|
|
598 |
createTable.addDateAndTimeColumn("DATE_DERNIER_JOUR_TRAV");
|
|
|
599 |
createTable.addDateAndTimeColumn("DATE_FIN_PREV");
|
|
|
600 |
createTable.addBooleanColumn("SUBROGATION", Boolean.FALSE, false);
|
|
|
601 |
createTable.addDateAndTimeColumn("DATE_DEBUT_SUBROGATION");
|
|
|
602 |
createTable.addDateAndTimeColumn("DATE_FIN_SUBROGATION");
|
|
|
603 |
createTable.addForeignColumn("ID_MOTIF_ARRET_TRAVAIL", root.findTable("MOTIF_ARRET_TRAVAIL"));
|
|
|
604 |
createTable.addForeignColumn("ID_MOTIF_REPRISE_ARRET_TRAVAIL", root.findTable("MOTIF_REPRISE_ARRET_TRAVAIL"));
|
|
|
605 |
createTable.addDateAndTimeColumn("DATE_REPRISE");
|
|
|
606 |
createTable.addDateAndTimeColumn("DATE_ACCIDENT");
|
|
|
607 |
createTable.addDateAndTimeColumn("DATE");
|
|
|
608 |
createTable.addVarCharColumn("COMMENTAIRES", 2048);
|
|
|
609 |
|
|
|
610 |
try {
|
|
|
611 |
root.getBase().getDataSource().execute(createTable.asString());
|
|
|
612 |
insertUndef(createTable);
|
|
|
613 |
root.refetchTable("REPRISE_TRAVAIL");
|
|
|
614 |
root.getSchema().updateVersion();
|
|
|
615 |
} catch (SQLException ex) {
|
|
|
616 |
throw new IllegalStateException("Erreur lors de la création de la table " + "REPRISE_TRAVAIL", ex);
|
|
|
617 |
}
|
|
|
618 |
}
|
|
|
619 |
|
|
|
620 |
if (!root.contains("DECLARATION_DSN")) {
|
|
|
621 |
|
|
|
622 |
final SQLCreateTable createTable = new SQLCreateTable(root, "DECLARATION_DSN");
|
|
|
623 |
createTable.addForeignColumn("ID_DSN_NATURE", root.findTable("DSN_NATURE"));
|
|
|
624 |
|
|
|
625 |
createTable.addDateAndTimeColumn("DATE");
|
|
|
626 |
createTable.addDateAndTimeColumn("DATE_ENVOI");
|
|
|
627 |
createTable.addBooleanColumn("TEST", Boolean.FALSE, false);
|
|
|
628 |
createTable.addBooleanColumn("ENVOYE", Boolean.FALSE, false);
|
|
|
629 |
createTable.addVarCharColumn("COMMENTAIRE", 1024);
|
|
|
630 |
createTable.addVarCharColumn("DSN_FILE", 75000);
|
|
|
631 |
createTable.addIntegerColumn("NUMERO", 1);
|
|
|
632 |
createTable.addIntegerColumn("ANNEE", 2016);
|
|
|
633 |
createTable.addForeignColumn("MOIS");
|
|
|
634 |
|
|
|
635 |
try {
|
|
|
636 |
root.getBase().getDataSource().execute(createTable.asString());
|
|
|
637 |
insertUndef(createTable);
|
|
|
638 |
root.refetchTable("DECLARATION_DSN");
|
|
|
639 |
root.getSchema().updateVersion();
|
|
|
640 |
} catch (SQLException ex) {
|
|
|
641 |
throw new IllegalStateException("Erreur lors de la création de la table " + "DECLARATION_DSN", ex);
|
|
|
642 |
}
|
|
|
643 |
}
|
|
|
644 |
|
|
|
645 |
SQLTable tableArret = root.getTable("ARRET_TRAVAIL");
|
|
|
646 |
if (!tableArret.contains("DATE")) {
|
|
|
647 |
AlterTable alter = new AlterTable(tableArret);
|
|
|
648 |
alter.addDateAndTimeColumn("DATE");
|
|
|
649 |
alter.addVarCharColumn("COMMENTAIRES", 2048);
|
|
|
650 |
root.getBase().getDataSource().execute(alter.asString());
|
|
|
651 |
root.refetchTable("ARRET_TRAVAIL");
|
|
|
652 |
root.getSchema().updateVersion();
|
|
|
653 |
}
|
|
|
654 |
|
|
|
655 |
SQLTable tableDsn = root.getTable("DECLARATION_DSN");
|
|
|
656 |
if (!tableDsn.contains("ID_ARRET_TRAVAIL")) {
|
|
|
657 |
AlterTable alter = new AlterTable(tableDsn);
|
|
|
658 |
alter.addForeignColumn("ID_ARRET_TRAVAIL", root.findTable("ARRET_TRAVAIL"));
|
|
|
659 |
root.getBase().getDataSource().execute(alter.asString());
|
|
|
660 |
root.getSchema().updateVersion();
|
|
|
661 |
}
|
|
|
662 |
if (!tableDsn.contains("ID_REPRISE_TRAVAIL")) {
|
|
|
663 |
AlterTable alter = new AlterTable(tableDsn);
|
|
|
664 |
alter.addForeignColumn("ID_REPRISE_TRAVAIL", root.findTable("REPRISE_TRAVAIL"));
|
|
|
665 |
root.getBase().getDataSource().execute(alter.asString());
|
|
|
666 |
root.getSchema().updateVersion();
|
|
|
667 |
}
|
|
|
668 |
if (!tableDsn.contains("ID_MOIS_REGUL")) {
|
|
|
669 |
AlterTable alter = new AlterTable(tableDsn);
|
|
|
670 |
alter.addForeignColumn("ID_MOIS_REGUL", root.findTable("MOIS"));
|
|
|
671 |
root.getBase().getDataSource().execute(alter.asString());
|
|
|
672 |
root.getSchema().updateVersion();
|
|
|
673 |
}
|
|
|
674 |
|
|
|
675 |
if (!tableDsn.contains("ANNULE_REMPLACE")) {
|
|
|
676 |
AlterTable alter = new AlterTable(tableDsn);
|
|
|
677 |
alter.addBooleanColumn("ANNULE_REMPLACE", Boolean.FALSE, false);
|
|
|
678 |
root.getBase().getDataSource().execute(alter.asString());
|
|
|
679 |
root.getSchema().updateVersion();
|
|
|
680 |
}
|
|
|
681 |
|
|
|
682 |
// if (!root.contains("FIN_CONTRAT")) {
|
|
|
683 |
//
|
|
|
684 |
// final SQLCreateTable createTable = new SQLCreateTable(root, "FIN_CONTRAT");
|
|
|
685 |
// createTable.addForeignColumn("SALARIE");
|
|
|
686 |
// createTable.addDateAndTimeColumn("DATE_FIN");
|
|
|
687 |
// createTable.addDateAndTimeColumn("DATE_FIN_PREV");
|
|
|
688 |
// createTable.addBooleanColumn("SUBROGATION", Boolean.FALSE, false);
|
|
|
689 |
// createTable.addDateAndTimeColumn("DATE_DEBUT_SUBROGATION");
|
|
|
690 |
// createTable.addDateAndTimeColumn("DATE_FIN_SUBROGATION");
|
|
|
691 |
// createTable.addForeignColumn("ID_MOTIF_ARRET_TRAVAIL",
|
|
|
692 |
// root.findTable("MOTIF_ARRET_TRAVAIL"));
|
|
|
693 |
// createTable.addForeignColumn("ID_MOTIF_REPRISE_ARRET_TRAVAIL",
|
|
|
694 |
// root.findTable("MOTIF_REPRISE_ARRET_TRAVAIL"));
|
|
|
695 |
// createTable.addDateAndTimeColumn("DATE_REPRISE");
|
|
|
696 |
// createTable.addDateAndTimeColumn("DATE_ACCIDENT");
|
|
|
697 |
//
|
|
|
698 |
// try {
|
|
|
699 |
// root.getBase().getDataSource().execute(createTable.asString());
|
|
|
700 |
// insertUndef(createTable);
|
|
|
701 |
// root.refetchTable("FIN_CONTRAT");
|
|
|
702 |
// root.getSchema().updateVersion();
|
|
|
703 |
// } catch (SQLException ex) {
|
|
|
704 |
// throw new IllegalStateException("Erreur lors de la création de la table " +
|
|
|
705 |
// "FIN_CONTRAT", ex);
|
|
|
706 |
// }
|
|
|
707 |
// }
|
|
|
708 |
|
|
|
709 |
SQLTable tableContrat = root.getTable("CONTRAT_SALARIE");
|
|
|
710 |
if (!tableContrat.contains("NUMERO")) {
|
|
|
711 |
AlterTable alter = new AlterTable(tableContrat);
|
|
|
712 |
alter.addColumn("NUMERO", "varchar(" + 128 + ") default '00000' NOT NULL");
|
|
|
713 |
root.getBase().getDataSource().execute(alter.asString());
|
|
|
714 |
root.getSchema().updateVersion();
|
|
|
715 |
}
|
|
|
716 |
|
|
|
717 |
if (!tableContrat.contains("CODE_REGIME_RETRAITE_DSN")) {
|
|
|
718 |
AlterTable alter = new AlterTable(tableContrat);
|
|
|
719 |
alter.addColumn("CODE_REGIME_RETRAITE_DSN", "varchar(" + 128 + ") default '00000' NOT NULL");
|
|
|
720 |
root.getBase().getDataSource().execute(alter.asString());
|
|
|
721 |
root.getSchema().updateVersion();
|
|
|
722 |
}
|
|
|
723 |
|
|
|
724 |
if (!tableContrat.contains("DATE_PREV_FIN")) {
|
|
|
725 |
AlterTable alter = new AlterTable(tableContrat);
|
|
|
726 |
alter.addDateAndTimeColumn("DATE_PREV_FIN");
|
|
|
727 |
root.getBase().getDataSource().execute(alter.asString());
|
|
|
728 |
root.getSchema().updateVersion();
|
|
|
729 |
}
|
|
|
730 |
|
|
|
731 |
boolean updateContrat = false;
|
|
|
732 |
if (!tableContrat.contains("ID_CONTRAT_MODALITE_TEMPS")) {
|
|
|
733 |
updateContrat = true;
|
|
|
734 |
AlterTable alter = new AlterTable(tableContrat);
|
|
|
735 |
alter.addForeignColumn("ID_CONTRAT_MODALITE_TEMPS", root.findTable("CONTRAT_MODALITE_TEMPS"));
|
|
|
736 |
root.getBase().getDataSource().execute(alter.asString());
|
|
|
737 |
root.getSchema().updateVersion();
|
|
|
738 |
}
|
|
|
739 |
if (!tableContrat.contains("ID_CONTRAT_REGIME_MALADIE")) {
|
|
|
740 |
AlterTable alter = new AlterTable(tableContrat);
|
|
|
741 |
alter.addForeignColumn("ID_CONTRAT_REGIME_MALADIE", root.findTable("CONTRAT_REGIME_MALADIE"));
|
|
|
742 |
root.getBase().getDataSource().execute(alter.asString());
|
|
|
743 |
root.getSchema().updateVersion();
|
|
|
744 |
}
|
|
|
745 |
if (!tableContrat.contains("ID_CONTRAT_REGIME_VIEILLESSE")) {
|
|
|
746 |
AlterTable alter = new AlterTable(tableContrat);
|
|
|
747 |
alter.addForeignColumn("ID_CONTRAT_REGIME_VIEILLESSE", root.findTable("CONTRAT_REGIME_VIEILLESSE"));
|
|
|
748 |
root.getBase().getDataSource().execute(alter.asString());
|
|
|
749 |
root.getSchema().updateVersion();
|
|
|
750 |
}
|
|
|
751 |
if (!tableContrat.contains("ID_CONTRAT_MOTIF_RECOURS")) {
|
|
|
752 |
AlterTable alter = new AlterTable(tableContrat);
|
|
|
753 |
alter.addForeignColumn("ID_CONTRAT_MOTIF_RECOURS", root.findTable("CONTRAT_MOTIF_RECOURS"));
|
|
|
754 |
root.getBase().getDataSource().execute(alter.asString());
|
|
|
755 |
root.getSchema().updateVersion();
|
|
|
756 |
}
|
|
|
757 |
if (!tableContrat.contains("ID_CONTRAT_DETACHE_EXPATRIE")) {
|
|
|
758 |
AlterTable alter = new AlterTable(tableContrat);
|
|
|
759 |
alter.addForeignColumn("ID_CONTRAT_DETACHE_EXPATRIE", root.findTable("CONTRAT_DETACHE_EXPATRIE"));
|
|
|
760 |
root.getBase().getDataSource().execute(alter.asString());
|
|
|
761 |
root.getSchema().updateVersion();
|
|
|
762 |
}
|
|
|
763 |
if (!tableContrat.contains("ID_CONTRAT_DISPOSITIF_POLITIQUE")) {
|
|
|
764 |
AlterTable alter = new AlterTable(tableContrat);
|
|
|
765 |
alter.addForeignColumn("ID_CONTRAT_DISPOSITIF_POLITIQUE", root.findTable("CONTRAT_DISPOSITIF_POLITIQUE"));
|
|
|
766 |
root.getBase().getDataSource().execute(alter.asString());
|
|
|
767 |
root.getSchema().updateVersion();
|
|
|
768 |
}
|
|
|
769 |
|
|
|
770 |
if (updateContrat) {
|
|
|
771 |
root.refetchTable("CONTRAT_SALARIE");
|
|
|
772 |
tableContrat = root.findTable("CONTRAT_SALARIE");
|
|
|
773 |
SQLSelect sel = new SQLSelect();
|
|
|
774 |
sel.addSelectStar(tableContrat);
|
|
|
775 |
List<SQLRow> contrats = SQLRowListRSH.execute(sel);
|
|
|
776 |
|
|
|
777 |
SQLSelect selModal = new SQLSelect();
|
|
|
778 |
final SQLTable tableModaliteTemps = root.findTable("CONTRAT_MODALITE_TEMPS");
|
|
|
779 |
selModal.addSelectStar(tableModaliteTemps);
|
|
|
780 |
selModal.setWhere(new Where(tableModaliteTemps.getField("CODE"), "=", "10"));
|
|
|
781 |
SQLRow contratModalite = SQLRowListRSH.execute(selModal).get(0);
|
|
|
782 |
|
|
|
783 |
SQLSelect selMaladie = new SQLSelect();
|
|
|
784 |
final SQLTable tableMaladie = root.findTable("CONTRAT_REGIME_MALADIE");
|
|
|
785 |
selMaladie.addSelectStar(tableMaladie);
|
|
|
786 |
selMaladie.setWhere(new Where(tableMaladie.getField("CODE"), "=", "200"));
|
|
|
787 |
SQLRow contratMaladie = SQLRowListRSH.execute(selMaladie).get(0);
|
|
|
788 |
|
|
|
789 |
SQLSelect selViel = new SQLSelect();
|
|
|
790 |
final SQLTable tableViel = root.findTable("CONTRAT_REGIME_VIEILLESSE");
|
|
|
791 |
selViel.addSelectStar(tableViel);
|
|
|
792 |
selViel.setWhere(new Where(tableViel.getField("CODE"), "=", "200"));
|
|
|
793 |
SQLRow contratViel = SQLRowListRSH.execute(selViel).get(0);
|
|
|
794 |
|
|
|
795 |
SQLSelect selDetacheExp = new SQLSelect();
|
|
|
796 |
final SQLTable tableDetacheExp = root.findTable("CONTRAT_DETACHE_EXPATRIE");
|
|
|
797 |
selDetacheExp.addSelectStar(tableDetacheExp);
|
|
|
798 |
selDetacheExp.setWhere(new Where(tableDetacheExp.getField("CODE"), "=", "99"));
|
|
|
799 |
SQLRow contratDetacheExp = SQLRowListRSH.execute(selDetacheExp).get(0);
|
|
|
800 |
|
|
|
801 |
SQLSelect selDispoPolitique = new SQLSelect();
|
|
|
802 |
final SQLTable tableDispoPol = root.findTable("CONTRAT_DISPOSITIF_POLITIQUE");
|
|
|
803 |
selDispoPolitique.addSelectStar(tableDispoPol);
|
|
|
804 |
selDispoPolitique.setWhere(new Where(tableDispoPol.getField("CODE"), "=", "99"));
|
|
|
805 |
SQLRow contratDispoPol = SQLRowListRSH.execute(selDispoPolitique).get(0);
|
|
|
806 |
|
|
|
807 |
for (SQLRow contrat : contrats) {
|
|
|
808 |
|
|
|
809 |
final SQLRowValues createEmptyUpdateRow = contrat.createEmptyUpdateRow();
|
|
|
810 |
createEmptyUpdateRow.put("ID_CONTRAT_MODALITE_TEMPS", contratModalite.getID());
|
|
|
811 |
createEmptyUpdateRow.put("ID_CONTRAT_REGIME_MALADIE", contratMaladie.getID());
|
|
|
812 |
createEmptyUpdateRow.put("ID_CONTRAT_REGIME_VIEILLESSE", contratViel.getID());
|
|
|
813 |
createEmptyUpdateRow.put("ID_CONTRAT_DETACHE_EXPATRIE", contratDetacheExp.getID());
|
|
|
814 |
createEmptyUpdateRow.put("ID_CONTRAT_DISPOSITIF_POLITIQUE", contratDispoPol.getID());
|
|
|
815 |
createEmptyUpdateRow.commit();
|
|
|
816 |
}
|
|
|
817 |
}
|
|
|
818 |
|
|
|
819 |
}
|
|
|
820 |
|
|
|
821 |
}
|