Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe

Commits:

3 changed files:

Changes:

  • core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/common/TripConsolidateEngine.java
    ... ... @@ -126,13 +126,14 @@ public class TripConsolidateEngine {
    126 126
                     SampleMeasure.PROPERTY_WEIGHT,
    
    127 127
                     SampleMeasure.PROPERTY_IS_WEIGHT_COMPUTED);
    
    128 128
     
    
    129
    -        BeanMonitor nonTargetCatchMonitor = new BeanMonitor(
    
    129
    +        BeanMonitor catchMonitor = new BeanMonitor(
    
    130 130
                     Catch.PROPERTY_MEAN_LENGTH,
    
    131 131
                     Catch.PROPERTY_MEAN_LENGTH_COMPUTED_SOURCE,
    
    132 132
                     Catch.PROPERTY_MEAN_WEIGHT,
    
    133 133
                     Catch.PROPERTY_MEAN_WEIGHT_COMPUTED_SOURCE,
    
    134 134
                     Catch.PROPERTY_CATCH_WEIGHT,
    
    135 135
                     Catch.PROPERTY_CATCH_WEIGHT_COMPUTED_SOURCE,
    
    136
    +                Catch.PROPERTY_WEIGHT_MEASURE_METHOD,
    
    136 137
                     Catch.PROPERTY_TOTAL_COUNT,
    
    137 138
                     Catch.PROPERTY_TOTAL_COUNT_COMPUTED_SOURCE);
    
    138 139
     
    
    ... ... @@ -196,7 +197,7 @@ public class TripConsolidateEngine {
    196 197
                     activityContext.activityObs = activity;
    
    197 198
                     activityContext.sampleMeasureObsMonitor = sampleMeasureMonitor;
    
    198 199
                     activityContext.sampleObsMonitor = sampleMonitor;
    
    199
    -                activityContext.catchObsMonitor = nonTargetCatchMonitor;
    
    200
    +                activityContext.catchObsMonitor = catchMonitor;
    
    200 201
                     activityContext.floatingObjectConsolidateEngine = floatingObjectConsolidateEngine;
    
    201 202
                     activityContext.activityPrefix = activityPrefix;
    
    202 203
                     try {
    
    ... ... @@ -267,6 +268,7 @@ public class TripConsolidateEngine {
    267 268
                 for (Catch aCatch : set.getCatches()) {
    
    268 269
                     activityContext.watchCatch(aCatch);
    
    269 270
                     updateCatch(activityContext, aCatch);
    
    271
    +                updateCatchWeightMeasureMethod(aCatch);
    
    270 272
                     activityContext.flushCatch();
    
    271 273
                 }
    
    272 274
             }
    
    ... ... @@ -355,6 +357,14 @@ public class TripConsolidateEngine {
    355 357
             computeCatchMeanValues(aCatch, lengthWeightParameter);
    
    356 358
         }
    
    357 359
     
    
    360
    +    private void updateCatchWeightMeasureMethod(Catch aCatch) {
    
    361
    +        if (aCatch.getWeightMeasureMethod() != null && (aCatch.getCatchWeight() == null || aCatch.getCatchWeightComputedSource() != null)) {
    
    362
    +            // remove measure method when no catchWeight or catchWeight is computed
    
    363
    +            // See https://gitlab.com/ultreiaio/ird-observe/-/issues/2628
    
    364
    +            aCatch.setWeightMeasureMethod(null);
    
    365
    +        }
    
    366
    +    }
    
    367
    +
    
    358 368
         private void updateCatchByLengthWeightRelation(Catch aCatch,
    
    359 369
                                                        LengthWeightParameter lengthWeightParameter) {
    
    360 370
             // 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
    92 92
     
    
    93 93
         public DataSourceMigrationForVersion_9_1() {
    
    94 94
             super(Version.valueOf("9.1"), true);
    
    95
    -        ByMajorMigrationVersionResource.createResourceScriptVariables(this, "2022-09-14", "2022-09-14 00:00:00.000000");
    
    96
    -        idFactory = new TopiaIdFactoryForBulkSupport(LocalDateTime.of(2022, 9, 14, 0, 0).toInstant(ZoneOffset.UTC).toEpochMilli());
    
    95
    +        ByMajorMigrationVersionResource.createResourceScriptVariables(this, "2023-02-14", "2023-02-14 00:00:00.000000");
    
    96
    +        idFactory = new TopiaIdFactoryForBulkSupport(LocalDateTime.of(2023, 2, 14, 0, 0).toInstant(ZoneOffset.UTC).toEpochMilli());
    
    97 97
         }
    
    98 98
     
    
    99 99
         static class WellPlanStructure {
    
    ... ... @@ -294,6 +294,9 @@ public class DataSourceMigrationForVersion_9_1 extends ByMajorMigrationVersionRe
    294 294
                 // See fr.ird.observe.persistence.test.request.DeleteReferentialRequestTest
    
    295 295
                 executor.addScript("07-tck", "fill-table-ps_localmarket_buyer");
    
    296 296
             }
    
    297
    +
    
    298
    +        executor.addScript("08", "fix_ps_observation_catch_weightMeasureMethod");
    
    299
    +
    
    297 300
         }
    
    298 301
     
    
    299 302
         @Override
    

  • core/persistence/migration/src/main/resources/db/migration/v9/9.1/08_fix_ps_observation_catch_weightMeasureMethod-common.sql
    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 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);
    
    23
    +UPDATE common.LastUpdateDate SET lastUpdateDate = ${CURRENT_TIMESTAMP} WHERE type ='fr.ird.observe.entities.data.ps.observation.Catch';