Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
bf41e7c3
by Tony Chemit at 2023-11-13T11:09:58+01:00
4 changed files:
- core/persistence/migration/src/main/java/fr/ird/observe/spi/migration/v9/DataSourceMigrationForVersion_9_1.java
- + core/persistence/migration/src/main/resources/db/migration/v9/9.1/10_2_add_referential_common_Country_22-common.sql
- + core/persistence/migration/src/main/resources/db/migration/v9/9.1/10_2_add_referential_common_Country_72-common.sql
- + core/persistence/migration/src/main/resources/db/migration/v9/9.1/10_2_add_referential_common_Country_finalize-common.sql
Changes:
| ... | ... | @@ -302,6 +302,10 @@ public class DataSourceMigrationForVersion_9_1 extends ByMajorMigrationVersionRe |
| 302 | 302 | executor.addScript("09", "adapt_table-common_vessel-add-fields");
|
| 303 | 303 | // See https://gitlab.com/ultreiaio/ird-observe/-/issues/2646
|
| 304 | 304 | executor.addScript("10", "adapt_table-common_vessel-rename-field");
|
| 305 | + if (withIds) {
|
|
| 306 | + // See https://gitlab.com/ultreiaio/ird-observe/-/issues/2800
|
|
| 307 | + addCountries(executor);
|
|
| 308 | + }
|
|
| 305 | 309 | // See https://gitlab.com/ultreiaio/ird-observe/-/issues/2659
|
| 306 | 310 | executor.addScript("11", "adapt_table-common_fpazone-add-fields");
|
| 307 | 311 | if (withIds) {
|
| ... | ... | @@ -367,6 +371,22 @@ public class DataSourceMigrationForVersion_9_1 extends ByMajorMigrationVersionRe |
| 367 | 371 | }
|
| 368 | 372 | }
|
| 369 | 373 | |
| 374 | + private void addCountries(MigrationVersionResourceExecutor executor) {
|
|
| 375 | + Set<String> existingCodes = executor.findMultipleResultAstSet(SqlQuery.wrap("SELECT topiaId FROM common.Country", resultSet -> resultSet.getString(1)));
|
|
| 376 | + Set<String> newCodes = new LinkedHashSet<>();
|
|
| 377 | + if (!existingCodes.contains("fr.ird.referential.common.Country#1239832675593#0.24921769452411147")) {
|
|
| 378 | + executor.addScript("10_2", "add_referential_common_Country_22");
|
|
| 379 | + newCodes.add("22");
|
|
| 380 | + }
|
|
| 381 | + if (!existingCodes.contains("fr.ird.referential.common.Country#1464000000000#0.00072")) {
|
|
| 382 | + executor.addScript("10_2", "add_referential_common_Country_72");
|
|
| 383 | + newCodes.add("72");
|
|
| 384 | + }
|
|
| 385 | + if (!newCodes.isEmpty()) {
|
|
| 386 | + executor.addScript("10_2", "add_referential_common_Country_finalize");
|
|
| 387 | + }
|
|
| 388 | + }
|
|
| 389 | + |
|
| 370 | 390 | private Map<String, List<WellPlanStructure>> splitByTrip(List<WellPlanStructure> existingWellPlan) {
|
| 371 | 391 | String tripId = null;
|
| 372 | 392 | List<WellPlanStructure> forTrip = null;
|
| 1 | +---
|
|
| 2 | +-- #%L
|
|
| 3 | +-- ObServe Core :: Persistence :: Migration
|
|
| 4 | +-- %%
|
|
| 5 | +-- Copyright (C) 2008 - 2023 IRD, Ultreia.io
|
|
| 6 | +-- %%
|
|
| 7 | +-- This program is free software: you can redistribute it and/or modify
|
|
| 8 | +-- it under the terms of the GNU General Public License as
|
|
| 9 | +-- published by the Free Software Foundation, either version 3 of the
|
|
| 10 | +-- License, or (at your option) any later version.
|
|
| 11 | +--
|
|
| 12 | +-- This program is distributed in the hope that it will be useful,
|
|
| 13 | +-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 14 | +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 15 | +-- GNU General Public License for more details.
|
|
| 16 | +--
|
|
| 17 | +-- You should have received a copy of the GNU General Public
|
|
| 18 | +-- License along with this program. If not, see
|
|
| 19 | +-- <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 20 | +-- #L%
|
|
| 21 | +---
|
|
| 22 | +INSERT INTO common.country (topiaid, topiaversion, topiacreatedate, lastupdatedate, code, uri, homeid, needcomment, status, label1, label2, label3, label4, label5, label6, label7, label8, iso2code, iso3code) VALUES ('fr.ird.referential.common.Country#1239832675593#0.24921769452411147', 22, '2009-04-15 00:00:00.014000', '2020-03-06 16:01:25.630000', '22', null, null, false, 1, 'Mauritius', 'Maurice', 'Mauricio', null, null, null, null, null, 'MU', 'MUS'); |
|
| \ No newline at end of file |
| 1 | +---
|
|
| 2 | +-- #%L
|
|
| 3 | +-- ObServe Core :: Persistence :: Migration
|
|
| 4 | +-- %%
|
|
| 5 | +-- Copyright (C) 2008 - 2023 IRD, Ultreia.io
|
|
| 6 | +-- %%
|
|
| 7 | +-- This program is free software: you can redistribute it and/or modify
|
|
| 8 | +-- it under the terms of the GNU General Public License as
|
|
| 9 | +-- published by the Free Software Foundation, either version 3 of the
|
|
| 10 | +-- License, or (at your option) any later version.
|
|
| 11 | +--
|
|
| 12 | +-- This program is distributed in the hope that it will be useful,
|
|
| 13 | +-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 14 | +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 15 | +-- GNU General Public License for more details.
|
|
| 16 | +--
|
|
| 17 | +-- You should have received a copy of the GNU General Public
|
|
| 18 | +-- License along with this program. If not, see
|
|
| 19 | +-- <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 20 | +-- #L%
|
|
| 21 | +---
|
|
| 22 | +INSERT INTO common.country (topiaid, topiaversion, topiacreatedate, lastupdatedate, code, uri, homeid, needcomment, status, label1, label2, label3, label4, label5, label6, label7, label8, iso2code, iso3code) VALUES ('fr.ird.referential.common.Country#1464000000000#0.00072', 3, '2018-06-13 18:31:03.000000', '2020-03-06 16:21:07.403000', '72', null, null, false, 1, 'Namibia', 'Namibie', 'Namibia', null, null, null, null, null, 'NA', 'NAM'); |
|
| \ No newline at end of file |
| 1 | +---
|
|
| 2 | +-- #%L
|
|
| 3 | +-- ObServe Core :: Persistence :: Migration
|
|
| 4 | +-- %%
|
|
| 5 | +-- Copyright (C) 2008 - 2023 IRD, Ultreia.io
|
|
| 6 | +-- %%
|
|
| 7 | +-- This program is free software: you can redistribute it and/or modify
|
|
| 8 | +-- it under the terms of the GNU General Public License as
|
|
| 9 | +-- published by the Free Software Foundation, either version 3 of the
|
|
| 10 | +-- License, or (at your option) any later version.
|
|
| 11 | +--
|
|
| 12 | +-- This program is distributed in the hope that it will be useful,
|
|
| 13 | +-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 14 | +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 15 | +-- GNU General Public License for more details.
|
|
| 16 | +--
|
|
| 17 | +-- You should have received a copy of the GNU General Public
|
|
| 18 | +-- License along with this program. If not, see
|
|
| 19 | +-- <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 20 | +-- #L%
|
|
| 21 | +---
|
|
| 22 | +UPDATE common.LastUpdateDate SET lastUpdateDate = ${CURRENT_TIMESTAMP} WHERE type ='fr.ird.observe.entities.referential.common.Country'; |