Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: 4567a4c5 by Tony Chemit at 2023-02-15T10:54:06+01:00 Migration - Sur les captures, suppression de la méthode de mesure de poids si le poids n'est pas déclaré, ou qu'il est calculé dans l'action de consolidation - See #2628 - - - - - 9669eafb by Tony Chemit at 2023-02-15T10:54:55+01:00 Consolidate - Sur les captures, suppression de la méthode de mesure de poids si le poids n'est pas déclaré, ou qu'il est calculé dans l'action de consolidation - See #2628 - - - - - 3 changed files: - core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/common/TripConsolidateEngine.java - 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/08_fix_ps_observation_catch_weightMeasureMethod-common.sql Changes: ===================================== core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/common/TripConsolidateEngine.java ===================================== @@ -126,13 +126,14 @@ public class TripConsolidateEngine { SampleMeasure.PROPERTY_WEIGHT, SampleMeasure.PROPERTY_IS_WEIGHT_COMPUTED); - BeanMonitor nonTargetCatchMonitor = new BeanMonitor( + BeanMonitor catchMonitor = new BeanMonitor( Catch.PROPERTY_MEAN_LENGTH, Catch.PROPERTY_MEAN_LENGTH_COMPUTED_SOURCE, Catch.PROPERTY_MEAN_WEIGHT, Catch.PROPERTY_MEAN_WEIGHT_COMPUTED_SOURCE, Catch.PROPERTY_CATCH_WEIGHT, Catch.PROPERTY_CATCH_WEIGHT_COMPUTED_SOURCE, + Catch.PROPERTY_WEIGHT_MEASURE_METHOD, Catch.PROPERTY_TOTAL_COUNT, Catch.PROPERTY_TOTAL_COUNT_COMPUTED_SOURCE); @@ -196,7 +197,7 @@ public class TripConsolidateEngine { activityContext.activityObs = activity; activityContext.sampleMeasureObsMonitor = sampleMeasureMonitor; activityContext.sampleObsMonitor = sampleMonitor; - activityContext.catchObsMonitor = nonTargetCatchMonitor; + activityContext.catchObsMonitor = catchMonitor; activityContext.floatingObjectConsolidateEngine = floatingObjectConsolidateEngine; activityContext.activityPrefix = activityPrefix; try { @@ -267,6 +268,7 @@ public class TripConsolidateEngine { for (Catch aCatch : set.getCatches()) { activityContext.watchCatch(aCatch); updateCatch(activityContext, aCatch); + updateCatchWeightMeasureMethod(aCatch); activityContext.flushCatch(); } } @@ -355,6 +357,14 @@ public class TripConsolidateEngine { computeCatchMeanValues(aCatch, lengthWeightParameter); } + private void updateCatchWeightMeasureMethod(Catch aCatch) { + if (aCatch.getWeightMeasureMethod() != null && (aCatch.getCatchWeight() == null || aCatch.getCatchWeightComputedSource() != null)) { + // remove measure method when no catchWeight or catchWeight is computed + // See https://gitlab.com/ultreiaio/ird-observe/-/issues/2628 + aCatch.setWeightMeasureMethod(null); + } + } + private void updateCatchByLengthWeightRelation(Catch aCatch, LengthWeightParameter lengthWeightParameter) { // calcul via le paramétrage taille - poids ===================================== core/persistence/migration/src/main/java/fr/ird/observe/spi/migration/v9/DataSourceMigrationForVersion_9_1.java ===================================== @@ -92,8 +92,8 @@ public class DataSourceMigrationForVersion_9_1 extends ByMajorMigrationVersionRe public DataSourceMigrationForVersion_9_1() { super(Version.valueOf("9.1"), true); - ByMajorMigrationVersionResource.createResourceScriptVariables(this, "2022-09-14", "2022-09-14 00:00:00.000000"); - idFactory = new TopiaIdFactoryForBulkSupport(LocalDateTime.of(2022, 9, 14, 0, 0).toInstant(ZoneOffset.UTC).toEpochMilli()); + ByMajorMigrationVersionResource.createResourceScriptVariables(this, "2023-02-14", "2023-02-14 00:00:00.000000"); + idFactory = new TopiaIdFactoryForBulkSupport(LocalDateTime.of(2023, 2, 14, 0, 0).toInstant(ZoneOffset.UTC).toEpochMilli()); } static class WellPlanStructure { @@ -294,6 +294,9 @@ public class DataSourceMigrationForVersion_9_1 extends ByMajorMigrationVersionRe // See fr.ird.observe.persistence.test.request.DeleteReferentialRequestTest executor.addScript("07-tck", "fill-table-ps_localmarket_buyer"); } + + executor.addScript("08", "fix_ps_observation_catch_weightMeasureMethod"); + } @Override ===================================== core/persistence/migration/src/main/resources/db/migration/v9/9.1/08_fix_ps_observation_catch_weightMeasureMethod-common.sql ===================================== @@ -0,0 +1,23 @@ +--- +-- #%L +-- ObServe Core :: Persistence :: Migration +-- %% +-- Copyright (C) 2008 - 2023 IRD, Ultreia.io +-- %% +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as +-- published by the Free Software Foundation, either version 3 of the +-- License, or (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public +-- License along with this program. If not, see +-- <http://www.gnu.org/licenses/gpl-3.0.html>. +-- #L% +--- +UPDATE ps_observation.Catch SET weightMeasureMethod = NULL, lastUpdateDate = ${CURRENT_TIMESTAMP}, topiaVersion = topiaVersion + 1 WHERE weightMeasureMethod IS NOT NULL AND (catchWeight IS NULL OR catchWeightComputedSource IS NOT NULL); +UPDATE common.LastUpdateDate SET lastUpdateDate = ${CURRENT_TIMESTAMP} WHERE type ='fr.ird.observe.entities.data.ps.observation.Catch'; View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/6bafd72708af93dd53fe8e325... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/6bafd72708af93dd53fe8e325... You're receiving this email because of your account on gitlab.com.