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

Commits:

7 changed files:

Changes:

  • t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ConvertCatchesWeightCategoriesAction.java
    ... ... @@ -8,12 +8,12 @@
    8 8
      * it under the terms of the GNU Affero General Public License as published by
    
    9 9
      * the Free Software Foundation, either version 3 of the License, or
    
    10 10
      * (at your option) any later version.
    
    11
    - * 
    
    11
    + *
    
    12 12
      * This program is distributed in the hope that it will be useful,
    
    13 13
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    14 14
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    15 15
      * GNU General Public License for more details.
    
    16
    - * 
    
    16
    + *
    
    17 17
      * You should have received a copy of the GNU Affero General Public License
    
    18 18
      * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    19 19
      * #L%
    
    ... ... @@ -109,74 +109,49 @@ public class ConvertCatchesWeightCategoriesAction extends AbstractLevel0Action<C
    109 109
         }
    
    110 110
     
    
    111 111
         private boolean executeForTrip(Trip trip) throws TopiaException {
    
    112
    -
    
    113 112
             incrementsProgression();
    
    114
    -
    
    115 113
             String tripStr = decorate(trip);
    
    116
    -
    
    117 114
             String message = l(locale, "t3.level0.convertCatchesWeightCategories.treat.trip", tripStr);
    
    118 115
             log.info(message);
    
    119 116
             addInfoMessage(message);
    
    120
    -
    
    121 117
             Map<Species, CatchWeightResult> tripResult = new HashMap<>();
    
    122
    -
    
    123
    -        if (!trip.isActivityEmpty()) {
    
    124
    -
    
    118
    +        if (trip.isActivityNotEmpty()) {
    
    125 119
                 // must remove previous corrected elementary catches
    
    126 120
                 for (Activity activity : trip.getActivity()) {
    
    127 121
                     activity.clearCorrectedElementaryCatch();
    
    128 122
                 }
    
    129
    -
    
    130 123
                 for (Activity activity : trip.getActivity()) {
    
    131 124
                     if (activity.isElementaryCatchEmpty()) {
    
    132 125
                         // no catches
    
    133 126
                         continue;
    
    134 127
                     }
    
    135
    -
    
    136 128
                     log.info(String.format("Treat activity %s with %d", activity.getDate(), activity.sizeElementaryCatch()));
    
    137 129
                     Ocean currentOcean = activity.getOcean();
    
    138 130
                     SchoolType schoolType = activity.getSchoolType();
    
    139
    -
    
    140 131
                     // get converter for this ocean and school type
    
    141 132
                     WeightCategoryLogBookConverter converter = converterProvider.getConverter(currentOcean, schoolType);
    
    142
    -
    
    143 133
                     if (converter == null) {
    
    144
    -
    
    145 134
                         // can not redistribute if no weight categories found
    
    146
    -                    message = l(locale, "t3.level0.convertCatchesWeightCategories.warning.noconverter.found",
    
    135
    +                    message = l(locale, "t3.level0.convertCatchesWeightCategories.warning.no.converter.found",
    
    147 136
                                 currentOcean.getLabel1(), schoolType.getLabel1());
    
    148
    -                    if (log.isWarnEnabled()) {
    
    149
    -                        log.warn(message);
    
    150
    -                    }
    
    137
    +                    log.warn(message);
    
    151 138
                         addWarningMessage(message);
    
    152 139
                         continue;
    
    153 140
                     }
    
    154
    -
    
    155 141
                     // split catches by species
    
    156 142
                     Multimap<Species, ElementaryCatch> catchesBySpecie = SpeciesTopiaDao.groupBySpecies(activity.getElementaryCatch());
    
    157
    -
    
    158 143
                     for (Species species : catchesBySpecie.keySet()) {
    
    159
    -
    
    160 144
                         CatchWeightResult catchWeightResult = getCatchWeightResult(tripResult, species);
    
    161
    -
    
    162 145
                         Collection<ElementaryCatch> catches = catchesBySpecie.get(species);
    
    163
    -
    
    164 146
                         catchWeightResult.addLogBookWeight(catches);
    
    165
    -
    
    166 147
                         log.info(String.format("Treat species %d with %d catches", species.getCode(), catches.size()));
    
    167
    -
    
    168 148
                         // converts to weight category treatment for this species
    
    169
    -
    
    170 149
                         Map<WeightCategoryTreatment, Float> distribution = converter.distribute(species, catches);
    
    171
    -
    
    172 150
                         if (MapUtils.isEmpty(distribution)) {
    
    173
    -
    
    174 151
                             // nothing to create
    
    175 152
                             continue;
    
    176 153
                         }
    
    177
    -
    
    178 154
                         Collection<CorrectedElementaryCatch> newCatches = new ArrayList<>();
    
    179
    -
    
    180 155
                         // create new catches
    
    181 156
                         for (Map.Entry<WeightCategoryTreatment, Float> e2 : distribution.entrySet()) {
    
    182 157
                             WeightCategoryTreatment weightCategoryTreatment = e2.getKey();
    
    ... ... @@ -193,10 +168,7 @@ public class ConvertCatchesWeightCategoriesAction extends AbstractLevel0Action<C
    193 168
                     }
    
    194 169
                 }
    
    195 170
             }
    
    196
    -
    
    197
    -        addInfoMessage(l(locale, "t3.level0.convertCatchesWeightCategories.resume.for.trip",
    
    198
    -                tripStr, tripResult.size()));
    
    199
    -
    
    171
    +        addInfoMessage(l(locale, "t3.level0.convertCatchesWeightCategories.resume.for.trip", tripStr, tripResult.size()));
    
    200 172
             for (Map.Entry<Species, CatchWeightResult> e : tripResult.entrySet()) {
    
    201 173
                 Species species = e.getKey();
    
    202 174
                 CatchWeightResult r = e.getValue();
    

  • t3-actions/src/main/resources/i18n/t3-actions_en_GB.properties
    ... ... @@ -49,7 +49,7 @@ t3.level0.computeWellPlanWeightCategoriesProportions.well.withWellPlan=Well (%s)
    49 49
     t3.level0.convertCatchesWeightCategories.resume.for.species=Species %s < logBook total weight \= %s , converted total weight \= %s>
    
    50 50
     t3.level0.convertCatchesWeightCategories.resume.for.trip=Trip %s converted for %s species
    
    51 51
     t3.level0.convertCatchesWeightCategories.treat.trip=Will treat trip %s
    
    52
    -t3.level0.convertCatchesWeightCategories.warning.noconverter.found=No converter found for ocean %s and schoolType %s
    
    52
    +t3.level0.convertCatchesWeightCategories.warning.no.converter.found=No converter found for ocean %s and schoolType %s
    
    53 53
     t3.level0.step.computeRf1=Compute RF1
    
    54 54
     t3.level0.step.computeRf2=Compute RF2
    
    55 55
     t3.level0.step.computeSetDurationAndPositiveSetCount=Compute Set Duration and positive set count
    

  • t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties
    ... ... @@ -49,7 +49,7 @@ t3.level0.computeWellPlanWeightCategoriesProportions.well.withWellPlan=Cuve avec
    49 49
     t3.level0.convertCatchesWeightCategories.resume.for.species=Espèce %s < poids total des captures du livre de bord \= %s , poids total converti \= %s>
    
    50 50
     t3.level0.convertCatchesWeightCategories.resume.for.trip=Marée %s convertie pour %s espèce(s)
    
    51 51
     t3.level0.convertCatchesWeightCategories.treat.trip=Traitement de la marée %s
    
    52
    -t3.level0.convertCatchesWeightCategories.warning.noconverter.found=Pas de converteur trouvé pour l'océan %s et le type de banc %s
    
    52
    +t3.level0.convertCatchesWeightCategories.warning.no.converter.found=Pas de converteur trouvé pour l'océan %s et le type de banc %s
    
    53 53
     t3.level0.step.computeRf1=Calcul du rf1
    
    54 54
     t3.level0.step.computeRf2=Calcul du rf2
    
    55 55
     t3.level0.step.computeSetDurationAndPositiveSetCount=Calcul de la durée d'une calée et de positive Set count
    

  • t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConverter.java
    ... ... @@ -24,6 +24,7 @@ import fr.ird.t3.entities.data.ElementaryCatch;
    24 24
     import fr.ird.t3.entities.reference.Ocean;
    
    25 25
     import fr.ird.t3.entities.reference.SchoolType;
    
    26 26
     import fr.ird.t3.entities.reference.Species;
    
    27
    +import fr.ird.t3.entities.reference.WeightCategoryLogBook;
    
    27 28
     import fr.ird.t3.entities.reference.WeightCategoryTreatment;
    
    28 29
     import org.apache.commons.collections.CollectionUtils;
    
    29 30
     
    
    ... ... @@ -40,16 +41,17 @@ import java.util.Map;
    40 41
     public interface WeightCategoryLogBookConverter {
    
    41 42
     
    
    42 43
         /**
    
    43
    -     * Obtains the total weight of given {@code catches} which are in {@code unknown} weight category (with a code 9).
    
    44
    +     * Obtains the total weight of given {@code catches} which are in {@code unknown} weight category.
    
    44 45
          *
    
    45 46
          * @param catches catches to use
    
    46 47
          * @return the total weight of given catches which uses the unknown weight category
    
    48
    +     * @see WeightCategoryLogBook#isUnknown()
    
    47 49
          */
    
    48 50
         static float getUnknownWeight(Collection<ElementaryCatch> catches) {
    
    49 51
             float result = 0;
    
    50 52
             if (CollectionUtils.isNotEmpty(catches)) {
    
    51 53
                 for (ElementaryCatch aCatch : catches) {
    
    52
    -                if (aCatch.getWeightCategoryLogBook().getCode() == 9) {
    
    54
    +                if (aCatch.getWeightCategoryLogBook().isUnknown()) {
    
    53 55
                         result += aCatch.getCatchWeightRf2();
    
    54 56
                     }
    
    55 57
                 }
    

  • t3-domain/src/main/java/fr/ird/t3/services/migration/T3MigrationCallbackV2_3.java
    ... ... @@ -48,7 +48,9 @@ public class T3MigrationCallbackV2_3 extends T3MigrationCallbackSupport {
    48 48
         @Override
    
    49 49
         protected void prepareMigrationScript(TopiaSqlSupport sqlSupport, List<String> queries, boolean showSql, boolean showProgression) throws TopiaException {
    
    50 50
             addScript("01", "add-Trip-tripType", queries);
    
    51
    +        addScript("02", "add-VesselActivity-row", queries);
    
    51 52
             addScript("03", "spatialize-ocean", queries);
    
    53
    +        addScript("04", "add-WeightCategoryLogbook-unknown", queries);
    
    52 54
         }
    
    53 55
     
    
    54 56
     }

  • t3-domain/src/main/resources/db/migration/V_2_3_04-add-WeightCategoryLogbook-unknown.sql
    1
    +---
    
    2
    +-- #%L
    
    3
    +-- T3 :: Domain
    
    4
    +-- %%
    
    5
    +-- Copyright (C) 2010 - 2018 IRD, Code Lutin, Ultreia.io
    
    6
    +-- %%
    
    7
    +-- This program is free software: you can redistribute it and/or modify
    
    8
    +-- it under the terms of the GNU Affero General Public License as published by
    
    9
    +-- the Free Software Foundation, either version 3 of the License, or
    
    10
    +-- (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 Affero General Public License
    
    18
    +-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    19
    +-- #L%
    
    20
    +---
    
    21
    +ALTER TABLE WeightCategoryLogbook ADD COLUMN unknown BOOLEAN DEFAULT FALSE NOT NULL;
    
    22
    +UPDATE WeightCategoryLogbook SET unknown = TRUE WHERE code=9;
    \ No newline at end of file

  • t3-domain/src/main/xmi/t3-persistence.zargo
    No preview for this file type