1
2
3
4 package nl.b3p.brmo.test.util.database.dbunit;
5
6 import java.sql.SQLException;
7 import org.dbunit.DatabaseUnitException;
8 import org.dbunit.database.IDatabaseConnection;
9 import org.dbunit.dataset.DefaultDataSet;
10 import org.dbunit.dataset.DefaultTable;
11 import org.dbunit.operation.DatabaseOperation;
12
13
14
15
16
17
18 public final class CleanUtil {
19
20
21 private CleanUtil() {}
22
23
24
25
26
27
28
29
30
31
32 public static void cleanRSGB_BRK(final IDatabaseConnection rsgb, final boolean deleteBrondocument)
33 throws DatabaseUnitException, SQLException {
34
35 if (deleteBrondocument) {
36 DatabaseOperation.TRUNCATE_TABLE.execute(
37 rsgb, new DefaultDataSet(new DefaultTable[] {new DefaultTable("brondocument")}));
38 }
39
40
41
42
43
44
45
46
47
48
49
50 DatabaseOperation.DELETE_ALL.execute(
51 rsgb,
52 new DefaultDataSet(
53 new DefaultTable[] {
54 new DefaultTable("kad_onrrnd_zk"),
55 new DefaultTable("kad_onrrnd_zk_his_rel"),
56 new DefaultTable("kad_onrrnd_zk_aantek"),
57 new DefaultTable("kad_onrrnd_zk_archief"),
58 new DefaultTable("kad_onrrnd_zk_aantek_archief"),
59 new DefaultTable("kad_perceel"),
60 new DefaultTable("kad_perceel_archief"),
61 new DefaultTable("subject"),
62 new DefaultTable("prs"),
63 new DefaultTable("nat_prs"),
64 new DefaultTable("ingeschr_nat_prs"),
65 new DefaultTable("niet_ingezetene"),
66 new DefaultTable("ander_nat_prs"),
67 new DefaultTable("niet_nat_prs"),
68 new DefaultTable("ingeschr_niet_nat_prs"),
69 new DefaultTable("app_re"),
70 new DefaultTable("app_re_archief"),
71 new DefaultTable("zak_recht"),
72 new DefaultTable("zak_recht_archief"),
73 new DefaultTable("zak_recht_aantek"),
74 new DefaultTable("benoemd_obj_kad_onrrnd_zk"),
75 new DefaultTable("herkomst_metadata"),
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105 }));
106 }
107
108
109
110
111
112
113
114
115
116 public static void cleanRSGB_BRK2(final IDatabaseConnection rsgbbrk)
117 throws DatabaseUnitException, SQLException {
118
119 DatabaseOperation.DELETE_ALL.execute(
120 rsgbbrk,
121 new DefaultDataSet(
122 new DefaultTable[] {
123
124 new DefaultTable("onroerendezaak"),
125 new DefaultTable("nietnatuurlijkpersoon"),
126 new DefaultTable("adres"),
127 new DefaultTable("natuurlijkpersoon"),
128 new DefaultTable("stuk"),
129 new DefaultTable("stukdeel"),
130 new DefaultTable("persoon"),
131 new DefaultTable("recht"),
132 new DefaultTable("publiekrechtelijkebeperking"),
133 new DefaultTable("onroerendezaakbeperking_archief"),
134 new DefaultTable("onroerendezaakfiliatie"),
135 new DefaultTable("recht_isbeperkttot"),
136 new DefaultTable("objectlocatie"),
137 new DefaultTable("onroerendezaakbeperking"),
138 new DefaultTable("recht_aantekeningrecht"),
139 new DefaultTable("recht_archief"),
140 new DefaultTable("recht_isbelastmet"),
141 new DefaultTable("appartementsrecht"),
142 new DefaultTable("appartementsrecht_archief"),
143 new DefaultTable("objectlocatie_archief"),
144 new DefaultTable("onroerendezaak_archief"),
145 new DefaultTable("perceel"),
146 new DefaultTable("perceel_archief"),
147 new DefaultTable("recht_aantekeningrecht_archief"),
148 new DefaultTable("recht_isbelastmet_archief"),
149 new DefaultTable("recht_isbeperkttot_archief"),
150 }));
151 }
152
153
154
155
156
157
158
159
160 public static void cleanRSGB_BRP(final IDatabaseConnection rsgb)
161 throws DatabaseUnitException, SQLException {
162 CleanUtil.cleanRSGB_BRP(rsgb, true);
163 }
164
165
166
167
168
169
170
171
172
173
174 public static void cleanRSGB_BRP(final IDatabaseConnection rsgb, final boolean deleteBrondocument)
175 throws DatabaseUnitException, SQLException {
176 if (deleteBrondocument) {
177 DatabaseOperation.DELETE_ALL.execute(
178 rsgb, new DefaultDataSet(new DefaultTable[] {new DefaultTable("brondocument")}));
179 }
180
181
182
183
184
185
186
187 DatabaseOperation.DELETE_ALL.execute(
188 rsgb,
189 new DefaultDataSet(
190 new DefaultTable[] {
191 new DefaultTable("subject"),
192 new DefaultTable("prs"),
193 new DefaultTable("nat_prs"),
194 new DefaultTable("ingeschr_nat_prs"),
195 new DefaultTable("niet_ingezetene"),
196 new DefaultTable("ander_nat_prs"),
197 new DefaultTable("niet_nat_prs"),
198 new DefaultTable("ingeschr_niet_nat_prs"),
199 new DefaultTable("ouder_kind_rel"),
200 new DefaultTable("huw_ger_partn"),
201 new DefaultTable("herkomst_metadata")
202 }));
203 }
204
205
206
207
208
209
210
211
212 public static void cleanRSGB_NHR(final IDatabaseConnection rsgb)
213 throws DatabaseUnitException, SQLException {
214 cleanRSGB_NHR(rsgb, true);
215 }
216
217
218
219
220
221
222
223
224
225
226 public static void cleanRSGB_NHR(final IDatabaseConnection rsgb, final boolean deleteBrondocument)
227 throws DatabaseUnitException, SQLException {
228
229 DatabaseOperation.DELETE_ALL.execute(
230 rsgb,
231 new DefaultDataSet(
232 new DefaultTable[] {
233 new DefaultTable("sbi_activiteit"),
234 new DefaultTable("functionaris"),
235 new DefaultTable("ondrnmng"),
236 new DefaultTable("maatschapp_activiteit"),
237 new DefaultTable("vestg"),
238 new DefaultTable("vestg_activiteit"),
239 new DefaultTable("vestg_naam"),
240 new DefaultTable("ander_btnlnds_niet_nat_prs"),
241 }));
242 cleanRSGB_BRP(rsgb, deleteBrondocument);
243 }
244
245
246
247
248
249
250
251
252
253
254 public static void cleanRSGB_WOZ(final IDatabaseConnection rsgb, final boolean deleteBrondocument)
255 throws DatabaseUnitException, SQLException {
256
257 DatabaseOperation.DELETE_ALL.execute(
258 rsgb,
259 new DefaultDataSet(
260 new DefaultTable[] {
261 new DefaultTable("woz_obj"),
262 new DefaultTable("woz_deelobj"),
263 new DefaultTable("woz_waarde"),
264 new DefaultTable("woz_omvat"),
265 new DefaultTable("woz_belang"),
266 new DefaultTable("woz_deelobj_archief"),
267 new DefaultTable("woz_obj_archief"),
268 new DefaultTable("woz_waarde_archief"),
269 new DefaultTable("locaand_adres"),
270 new DefaultTable("locaand_openb_rmte"),
271 }));
272
273 cleanRSGB_NHR(rsgb, deleteBrondocument);
274 }
275
276
277
278
279
280
281
282
283
284
285
286 public static void cleanSTAGING(final IDatabaseConnection staging, final boolean includeProcessen)
287 throws DatabaseUnitException, SQLException {
288 if (includeProcessen) {
289 DatabaseOperation.DELETE_ALL.execute(
290 staging,
291 new DefaultDataSet(
292 new DefaultTable[] {
293 new DefaultTable("automatisch_proces"),
294 new DefaultTable("automatisch_proces_config")
295 }));
296 }
297 DatabaseOperation.DELETE_ALL.execute(
298 staging,
299 new DefaultDataSet(
300 new DefaultTable[] {
301 new DefaultTable("laadproces"), new DefaultTable("bericht"), new DefaultTable("job")
302 }));
303 }
304 }