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

Commits:

29 changed files:

Changes:

  • t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeSetDurationAndPositiveSetCountAction.java
    ... ... @@ -59,9 +59,9 @@ public class ComputeSetDurationAndPositiveSetCountAction extends AbstractLevel0A
    59 59
         @InjectDAO(entityType = SetDuration.class)
    
    60 60
         private SetDurationTopiaDao setDurationDAO;
    
    61 61
         /** Count of treated activities. */
    
    62
    -    private int nbActivities;
    
    62
    +    int nbActivities;
    
    63 63
         /** Count of positive activities found. */
    
    64
    -    private int nbPositiveActivities;
    
    64
    +    int nbPositiveActivities;
    
    65 65
         /** Count of set (sum(a.setCount) on each activity trip). */
    
    66 66
         private int nbSet;
    
    67 67
         /**
    

  • t3-actions/src/main/java/fr/ird/t3/actions/data/level1/AbstractLevel1Action.java
    ... ... @@ -28,20 +28,17 @@ import fr.ird.t3.entities.data.N1ResultState;
    28 28
     import fr.ird.t3.entities.data.Sample;
    
    29 29
     import fr.ird.t3.entities.data.Trip;
    
    30 30
     import fr.ird.t3.entities.data.TripTopiaDao;
    
    31
    -import fr.ird.t3.entities.reference.Ocean;
    
    32 31
     import fr.ird.t3.services.DecoratorService;
    
    33 32
     import fr.ird.t3.services.ioc.InjectDAO;
    
    34
    -import fr.ird.t3.services.ioc.InjectEntityById;
    
    33
    +import org.apache.commons.collections.CollectionUtils;
    
    34
    +import org.nuiton.topia.persistence.TopiaException;
    
    35
    +
    
    35 36
     import java.util.Collection;
    
    36 37
     import java.util.Comparator;
    
    37 38
     import java.util.List;
    
    38 39
     import java.util.Set;
    
    39 40
     import java.util.stream.Collectors;
    
    40 41
     
    
    41
    -import org.apache.commons.collections.CollectionUtils;
    
    42
    -import org.nuiton.topia.persistence.TopiaException;
    
    43
    -
    
    44
    -
    
    45 42
     import static org.nuiton.i18n.I18n.l;
    
    46 43
     
    
    47 44
     /**
    
    ... ... @@ -56,15 +53,12 @@ public abstract class AbstractLevel1Action extends T3Action<Level1Configuration>
    56 53
                 .<Trip, Integer>comparing(t -> t.getVessel().getCode())
    
    57 54
                 .thenComparing(Comparator.comparing(Trip::getLandingDate));
    
    58 55
     
    
    59
    -    protected final Level1Step step;
    
    60
    -
    
    61
    -    protected final Set<Level1Step> higherSteps;
    
    62
    -
    
    63 56
         @InjectDAO(entityType = Trip.class)
    
    64 57
         protected TripTopiaDao tripDAO;
    
    65 58
     
    
    66
    -    @InjectEntityById(entityType = Ocean.class)
    
    67
    -    protected Ocean ocean;
    
    59
    +    protected final Level1Step step;
    
    60
    +
    
    61
    +    protected final Set<Level1Step> higherSteps;
    
    68 62
     
    
    69 63
         /** For a trip, selected samples to treat. */
    
    70 64
         protected Multimap<Trip, Sample> samplesByTrip;
    
    ... ... @@ -77,10 +71,6 @@ public abstract class AbstractLevel1Action extends T3Action<Level1Configuration>
    77 71
             higherSteps = Level1Step.allAfter(step);
    
    78 72
         }
    
    79 73
     
    
    80
    -    public Ocean getOcean() {
    
    81
    -        return ocean;
    
    82
    -    }
    
    83
    -
    
    84 74
         public Multimap<Trip, Sample> getSamplesByTrip() {
    
    85 75
             return samplesByTrip;
    
    86 76
         }
    

  • t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ComputeWeightOfCategoriesForSetAction.java
    ... ... @@ -27,9 +27,9 @@ import fr.ird.t3.entities.data.Trip;
    27 27
     import fr.ird.t3.entities.data.WellSetAllSpecies;
    
    28 28
     import fr.ird.t3.entities.data.WellSetAllSpeciesTopiaDao;
    
    29 29
     import fr.ird.t3.services.ioc.InjectDAO;
    
    30
    -import java.util.Collection;
    
    31 30
     import org.nuiton.topia.persistence.TopiaException;
    
    32 31
     
    
    32
    +import java.util.Collection;
    
    33 33
     
    
    34 34
     import static org.nuiton.i18n.I18n.l;
    
    35 35
     
    
    ... ... @@ -127,9 +127,7 @@ public class ComputeWeightOfCategoriesForSetAction extends AbstractLevel1Action
    127 127
     
    
    128 128
                 // can not  compute propMinus10Weight and propPlus10Weight
    
    129 129
     
    
    130
    -            String message =
    
    131
    -                    l(locale, "t3.level1.computeWeightOfCategoriesForSet.sample.noComputePropWeight"
    
    132
    -                    );
    
    130
    +            String message = l(locale, "t3.level1.computeWeightOfCategoriesForSet.sample.noComputePropWeight");
    
    133 131
                 addInfoMessage(message);
    
    134 132
     
    
    135 133
             } else {
    

  • t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ConvertSampleSetSpeciesFrequencyToWeightAction.java
    ... ... @@ -21,12 +21,10 @@ package fr.ird.t3.actions.data.level1;
    21 21
      * #L%
    
    22 22
      */
    
    23 23
     
    
    24
    -import com.google.common.base.Preconditions;
    
    25 24
     import com.google.common.collect.ArrayListMultimap;
    
    26 25
     import com.google.common.collect.Lists;
    
    27 26
     import com.google.common.collect.Maps;
    
    28 27
     import com.google.common.collect.Multimap;
    
    29
    -import com.google.common.collect.Sets;
    
    30 28
     import fr.ird.t3.T3IOUtil;
    
    31 29
     import fr.ird.t3.entities.CountAndWeight;
    
    32 30
     import fr.ird.t3.entities.T3Suppliers;
    
    ... ... @@ -51,16 +49,17 @@ import fr.ird.t3.entities.reference.WeightCategorySample;
    51 49
     import fr.ird.t3.entities.reference.WeightCategorySampleTopiaDao;
    
    52 50
     import fr.ird.t3.services.DecoratorService;
    
    53 51
     import fr.ird.t3.services.ioc.InjectDAO;
    
    52
    +import org.nuiton.topia.persistence.TopiaException;
    
    53
    +import org.nuiton.util.TimeLog;
    
    54
    +
    
    54 55
     import java.util.Collection;
    
    55 56
     import java.util.Collections;
    
    56 57
     import java.util.Date;
    
    57 58
     import java.util.HashMap;
    
    58 59
     import java.util.List;
    
    59 60
     import java.util.Map;
    
    61
    +import java.util.Objects;
    
    60 62
     import java.util.Set;
    
    61
    -import org.nuiton.topia.persistence.TopiaException;
    
    62
    -import org.nuiton.util.TimeLog;
    
    63
    -
    
    64 63
     
    
    65 64
     import static org.nuiton.i18n.I18n.l;
    
    66 65
     
    
    ... ... @@ -72,38 +71,27 @@ import static org.nuiton.i18n.I18n.l;
    72 71
      */
    
    73 72
     public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLevel1Action {
    
    74 73
     
    
    74
    +    private final Map<String, List<WeightCategorySample>> weightCategoryCache;
    
    75 75
         @InjectDAO(entityType = LengthWeightConversion.class)
    
    76
    -    protected LengthWeightConversionTopiaDao lengthWeightConversionDAO;
    
    77
    -
    
    76
    +    private LengthWeightConversionTopiaDao lengthWeightConversionDAO;
    
    78 77
         @InjectDAO(entityType = SampleSetSpeciesCatWeight.class)
    
    79
    -    protected SampleSetSpeciesCatWeightTopiaDao sampleSetSpeciesCatWeightDAO;
    
    80
    -
    
    78
    +    private SampleSetSpeciesCatWeightTopiaDao sampleSetSpeciesCatWeightDAO;
    
    81 79
         @InjectDAO(entityType = WeightCategorySample.class)
    
    82
    -    protected WeightCategorySampleTopiaDao weightCategorySampleDAO;
    
    83
    -
    
    84
    -    protected LengthWeightConversionHelper conversionHelper;
    
    85
    -
    
    86
    -    protected final Map<String, List<WeightCategorySample>> weightCategoryCache;
    
    80
    +    private WeightCategorySampleTopiaDao weightCategorySampleDAO;
    
    81
    +    private LengthWeightConversionHelper conversionHelper;
    
    87 82
     
    
    88 83
         protected List<WeightCategorySample> getWeightCategories(SampleSet sampleSet) throws TopiaException {
    
    89
    -
    
    90 84
             Activity activity = sampleSet.getActivity();
    
    91
    -        Ocean ocean1 = activity.getOcean();
    
    85
    +        Ocean ocean = activity.getOcean();
    
    92 86
             SchoolType schoolType = activity.getSchoolType();
    
    93
    -        String key = ocean1.getTopiaId() + "-" + schoolType.getTopiaId();
    
    87
    +        String key = ocean.getTopiaId() + "-" + schoolType.getTopiaId();
    
    94 88
             List<WeightCategorySample> result = weightCategoryCache.get(key);
    
    95
    -
    
    96 89
             if (result == null) {
    
    97
    -
    
    98
    -            result = weightCategorySampleDAO.forOceanEquals(ocean1).findAll();
    
    90
    +            result = weightCategorySampleDAO.forOceanEquals(ocean).findAll();
    
    99 91
                 WeightCategories.sort(result);
    
    100 92
                 weightCategoryCache.put(key, result);
    
    101 93
             }
    
    102
    -
    
    103
    -        Preconditions.checkNotNull(
    
    104
    -                result,
    
    105
    -                "Could not find any weight categories for ocean " + ocean.getLabel1() );
    
    106
    -        return result;
    
    94
    +        return Objects.requireNonNull(result, "Could not find any weight categories for ocean " + ocean.getLabel1());
    
    107 95
         }
    
    108 96
     
    
    109 97
         public ConvertSampleSetSpeciesFrequencyToWeightAction() {
    
    ... ... @@ -141,21 +129,18 @@ public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLeve
    141 129
     
    
    142 130
                 String tripStr = decorate(trip, DecoratorService.WITH_ID);
    
    143 131
     
    
    144
    -            getTimeLog().log(s0, "treat trip " + tripStr);
    
    132
    +            getTimeLog().log(s0, String.format("treat trip %s", tripStr));
    
    145 133
     
    
    146 134
                 // flush transaction otherwise too much data in memory
    
    147
    -            flushTransaction("Flush transaction for " + tripStr);
    
    135
    +            flushTransaction(String.format("Flush transaction for %s", tripStr));
    
    148 136
             }
    
    149 137
             return true;
    
    150 138
         }
    
    151 139
     
    
    152
    -    protected void doExecuteTrip(Trip trip,
    
    153
    -                                 Collection<Sample> samples) throws TopiaException {
    
    140
    +    protected void doExecuteTrip(Trip trip, Collection<Sample> samples) throws TopiaException {
    
    154 141
     
    
    155 142
             incrementsProgression();
    
    156 143
     
    
    157
    -        Set<Activity> tripActivities = Sets.newHashSet();
    
    158
    -
    
    159 144
             // extrapolate for each sample set number to set
    
    160 145
             for (Sample sample : samples) {
    
    161 146
     
    
    ... ... @@ -173,16 +158,14 @@ public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLeve
    173 158
                     // found a new activity to convert
    
    174 159
                     convertFrequenciesToCatWeight(sampleSet);
    
    175 160
     
    
    176
    -                getTimeLog().log(s1,
    
    177
    -                                 "convertSampleSetSpeciesFrequencyToWeight for " +
    
    178
    -                                 tripActivities.size() + " sets.");
    
    161
    +                getTimeLog().log(s1, String.format("convertSampleSetSpeciesFrequencyToWeight for %d sets.", sample.sizeSampleSet()));
    
    179 162
     
    
    180 163
                 }
    
    181 164
     
    
    182 165
                 // mark sample as treated for this step of level 1 treatment
    
    183 166
                 markAsTreated(sample);
    
    184 167
     
    
    185
    -            getTimeLog().log(s0, "treat sample " + sampleStr);
    
    168
    +            getTimeLog().log(s0, String.format("treat sample %s", sampleStr));
    
    186 169
             }
    
    187 170
     
    
    188 171
             // mar trip as treated for this level 1 step
    
    ... ... @@ -191,8 +174,7 @@ public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLeve
    191 174
     
    
    192 175
         protected void convertFrequenciesToCatWeight(SampleSet sampleSet) throws TopiaException {
    
    193 176
     
    
    194
    -        Collection<SampleSetSpeciesFrequency> frequencies =
    
    195
    -                sampleSet.getSampleSetSpeciesFrequency();
    
    177
    +        Collection<SampleSetSpeciesFrequency> frequencies = sampleSet.getSampleSetSpeciesFrequency();
    
    196 178
     
    
    197 179
             Activity activity = sampleSet.getActivity();
    
    198 180
     
    
    ... ... @@ -200,15 +182,12 @@ public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLeve
    200 182
             Ocean activityOcean = activity.getOcean();
    
    201 183
     
    
    202 184
             // group frequencies by species
    
    203
    -        Multimap<Species, SampleSetSpeciesFrequency> frequenciesBySpecies =
    
    204
    -                SpeciesTopiaDao.groupBySpecies(frequencies);
    
    185
    +        Multimap<Species, SampleSetSpeciesFrequency> frequenciesBySpecies = SpeciesTopiaDao.groupBySpecies(frequencies);
    
    205 186
     
    
    206
    -        Multimap<Species, Integer> lengthClassesBySpecies =
    
    207
    -                ArrayListMultimap.create();
    
    187
    +        Multimap<Species, Integer> lengthClassesBySpecies = ArrayListMultimap.create();
    
    208 188
     
    
    209 189
             // collect all length classes by species
    
    210
    -        SampleSetSpeciesFrequencyTopiaDao.collectLengthClasses(
    
    211
    -                frequenciesBySpecies, lengthClassesBySpecies);
    
    190
    +        SampleSetSpeciesFrequencyTopiaDao.collectLengthClasses(frequenciesBySpecies, lengthClassesBySpecies);
    
    212 191
     
    
    213 192
             // get all available weight categories
    
    214 193
             List<WeightCategorySample> weightCategories = getWeightCategories(sampleSet);
    
    ... ... @@ -216,19 +195,11 @@ public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLeve
    216 195
             for (Species species : frequenciesBySpecies.keySet()) {
    
    217 196
     
    
    218 197
                 // get conversion for species
    
    219
    -            LengthWeightConversion conversion =
    
    220
    -                    conversionHelper.getConversions(
    
    221
    -                            species,
    
    222
    -                            activityOcean,
    
    223
    -                            0,
    
    224
    -                            date
    
    225
    -                    );
    
    226
    -
    
    227
    -            Collection<SampleSetSpeciesFrequency> frequenciesForSpecies =
    
    228
    -                    frequenciesBySpecies.get(species);
    
    229
    -
    
    230
    -            List<Integer> lengthClasses =
    
    231
    -                    Lists.newArrayList(lengthClassesBySpecies.get(species));
    
    198
    +            LengthWeightConversion conversion = conversionHelper.getConversions(species, activityOcean, 0, date);
    
    199
    +
    
    200
    +            Collection<SampleSetSpeciesFrequency> frequenciesForSpecies = frequenciesBySpecies.get(species);
    
    201
    +
    
    202
    +            List<Integer> lengthClasses = Lists.newArrayList(lengthClassesBySpecies.get(species));
    
    232 203
                 Collections.sort(lengthClasses);
    
    233 204
     
    
    234 205
                 Map<WeightCategorySample, CountAndWeight> countAndWeightsByCategories =
    
    ... ... @@ -238,9 +209,7 @@ public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLeve
    238 209
                                 frequenciesForSpecies,
    
    239 210
                                 lengthClasses);
    
    240 211
     
    
    241
    -            // now we can build for the given activity and species the entries
    
    242
    -            // in SetWeight
    
    243
    -
    
    212
    +            // now we can build for the given activity and species the entries in SetWeight
    
    244 213
                 fill(sampleSet, species, countAndWeightsByCategories);
    
    245 214
             }
    
    246 215
         }
    
    ... ... @@ -250,17 +219,12 @@ public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLeve
    250 219
                                                                                   Collection<SampleSetSpeciesFrequency> frequencies,
    
    251 220
                                                                                   List<Integer> lengthClasses) throws TopiaException {
    
    252 221
     
    
    253
    -        Map<Integer, WeightCategorySample> weightCategorie =
    
    254
    -                conversionHelper.getWeightCategoriesDistribution(
    
    255
    -                        conversion,
    
    256
    -                        weightCategories,
    
    257
    -                        lengthClasses);
    
    222
    +        Map<Integer, WeightCategorySample> weightCategoryMap =
    
    223
    +                conversionHelper.getWeightCategoriesDistribution(conversion, weightCategories, lengthClasses);
    
    258 224
     
    
    259 225
             Map<WeightCategorySample, CountAndWeight> result = new HashMap<>();
    
    260 226
     
    
    261
    -        T3IOUtil.fillMapWithDefaultValue(result,
    
    262
    -                                         weightCategorie.values(),
    
    263
    -                                         T3Suppliers.COUNT_AND_WEIGHT_DEFAULT_VALUE);
    
    227
    +        T3IOUtil.fillMapWithDefaultValue(result, weightCategoryMap.values(), T3Suppliers.COUNT_AND_WEIGHT_DEFAULT_VALUE);
    
    264 228
     
    
    265 229
             for (SampleSetSpeciesFrequency setSize : frequencies) {
    
    266 230
     
    
    ... ... @@ -268,7 +232,7 @@ public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLeve
    268 232
                 int lfLengthClass = setSize.getLfLengthClass();
    
    269 233
     
    
    270 234
                 // find the correct category for this length class
    
    271
    -            WeightCategorySample weightCategory = weightCategorie.get(lfLengthClass);
    
    235
    +            WeightCategorySample weightCategory = weightCategoryMap.get(lfLengthClass);
    
    272 236
     
    
    273 237
                 CountAndWeight countAndWeight = result.get(weightCategory);
    
    274 238
     
    
    ... ... @@ -276,8 +240,7 @@ public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLeve
    276 240
     
    
    277 241
                 countAndWeight.addCount(number);
    
    278 242
                 // convert to weight from lf length class
    
    279
    -            countAndWeight.addWeight(number *
    
    280
    -                      conversion.computeWeightFromLFLengthClass(lfLengthClass));
    
    243
    +            countAndWeight.addWeight(number * conversion.computeWeightFromLFLengthClass(lfLengthClass));
    
    281 244
     
    
    282 245
             }
    
    283 246
     
    
    ... ... @@ -295,7 +258,7 @@ public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLeve
    295 258
                 CountAndWeight countAndWeight  = e2.getValue();
    
    296 259
                 float count = countAndWeight.getCount();
    
    297 260
     
    
    298
    -            // weight must be stored in tons but are in kilogramms
    
    261
    +            // weight must be stored in tons but are in kilograms
    
    299 262
                 Float weight = countAndWeight.getWeight() / 1000;
    
    300 263
     
    
    301 264
                 SampleSetSpeciesCatWeight setSpeciesCatWeight = sampleSetSpeciesCatWeightDAO.create(
    

  • t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ConvertSetSpeciesFrequencyToWeightAction.java
    ... ... @@ -8,19 +8,18 @@
    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%
    
    20 20
      */
    
    21 21
     package fr.ird.t3.actions.data.level1;
    
    22 22
     
    
    23
    -import com.google.common.base.Preconditions;
    
    24 23
     import com.google.common.collect.ArrayListMultimap;
    
    25 24
     import com.google.common.collect.Lists;
    
    26 25
     import com.google.common.collect.Maps;
    
    ... ... @@ -49,16 +48,17 @@ import fr.ird.t3.entities.reference.WeightCategorySample;
    49 48
     import fr.ird.t3.entities.reference.WeightCategorySampleTopiaDao;
    
    50 49
     import fr.ird.t3.services.DecoratorService;
    
    51 50
     import fr.ird.t3.services.ioc.InjectDAO;
    
    51
    +import org.nuiton.topia.persistence.TopiaException;
    
    52
    +import org.nuiton.util.TimeLog;
    
    53
    +
    
    52 54
     import java.util.Collection;
    
    53 55
     import java.util.Collections;
    
    54 56
     import java.util.Date;
    
    55 57
     import java.util.HashMap;
    
    56 58
     import java.util.List;
    
    57 59
     import java.util.Map;
    
    60
    +import java.util.Objects;
    
    58 61
     import java.util.Set;
    
    59
    -import org.nuiton.topia.persistence.TopiaException;
    
    60
    -import org.nuiton.util.TimeLog;
    
    61
    -
    
    62 62
     
    
    63 63
     import static org.nuiton.i18n.I18n.l;
    
    64 64
     
    
    ... ... @@ -70,48 +70,34 @@ import static org.nuiton.i18n.I18n.l;
    70 70
      */
    
    71 71
     public class ConvertSetSpeciesFrequencyToWeightAction extends AbstractLevel1Action {
    
    72 72
     
    
    73
    +    protected final Map<String, List<WeightCategorySample>> weightCategoryCache;
    
    73 74
         @InjectDAO(entityType = LengthWeightConversion.class)
    
    74 75
         protected LengthWeightConversionTopiaDao lengthWeightConversionDAO;
    
    75
    -
    
    76 76
         @InjectDAO(entityType = SetSpeciesCatWeight.class)
    
    77 77
         protected SetSpeciesCatWeightTopiaDao setSpeciesCatWeightDAO;
    
    78
    -
    
    79 78
         @InjectDAO(entityType = WeightCategorySample.class)
    
    80 79
         protected WeightCategorySampleTopiaDao weightCategorySampleDAO;
    
    81
    -
    
    82 80
         protected int nbTreatedSets;
    
    83
    -
    
    84 81
         protected float nbTreatedFishesInSamples;
    
    85
    -
    
    86 82
         protected float nbCreatedFishesInSetSpeciesFrequency;
    
    87
    -
    
    88 83
         protected LengthWeightConversionHelper conversionHelper;
    
    89 84
     
    
    90
    -    protected final Map<String, List<WeightCategorySample>> weightCategoryCache;
    
    85
    +    public ConvertSetSpeciesFrequencyToWeightAction() {
    
    86
    +        super(Level1Step.CONVERT_SET_SPECIES_FREQUENCY_TO_WEIGHT);
    
    87
    +        weightCategoryCache = Maps.newTreeMap();
    
    88
    +    }
    
    91 89
     
    
    92 90
         protected List<WeightCategorySample> getWeightCategories(Activity activity) throws TopiaException {
    
    93
    -
    
    94
    -        Ocean ocean1 = activity.getOcean();
    
    91
    +        Ocean ocean = activity.getOcean();
    
    95 92
             SchoolType schoolType = activity.getSchoolType();
    
    96
    -        String key = ocean1.getTopiaId() + "-" + schoolType.getTopiaId();
    
    93
    +        String key = ocean.getTopiaId() + "-" + schoolType.getTopiaId();
    
    97 94
             List<WeightCategorySample> result = weightCategoryCache.get(key);
    
    98
    -
    
    99 95
             if (result == null) {
    
    100
    -
    
    101
    -            result = weightCategorySampleDAO.findAllByOcean(ocean1);
    
    96
    +            result = weightCategorySampleDAO.forOceanEquals(ocean).findAll();
    
    102 97
                 WeightCategories.sort(result);
    
    103 98
                 weightCategoryCache.put(key, result);
    
    104 99
             }
    
    105
    -
    
    106
    -        Preconditions.checkNotNull(
    
    107
    -                result,
    
    108
    -                "Could not find any weight categories for ocean " + ocean.getLabel1());
    
    109
    -        return result;
    
    110
    -    }
    
    111
    -
    
    112
    -    public ConvertSetSpeciesFrequencyToWeightAction() {
    
    113
    -        super(Level1Step.CONVERT_SET_SPECIES_FREQUENCY_TO_WEIGHT);
    
    114
    -        weightCategoryCache = Maps.newTreeMap();
    
    100
    +        return Objects.requireNonNull(result, "Could not find any weight categories for ocean " + ocean.getLabel1());
    
    115 101
         }
    
    116 102
     
    
    117 103
         public int getNbTreatedSets() {
    
    ... ... @@ -140,7 +126,7 @@ public class ConvertSetSpeciesFrequencyToWeightAction extends AbstractLevel1Acti
    140 126
         }
    
    141 127
     
    
    142 128
         @Override
    
    143
    -    protected boolean executeAction() throws Exception {
    
    129
    +    protected boolean executeAction() {
    
    144 130
     
    
    145 131
             Set<Trip> trips = samplesByTrip.keySet();
    
    146 132
             setNbSteps(samplesByTrip.size() + trips.size());
    
    ... ... @@ -164,8 +150,7 @@ public class ConvertSetSpeciesFrequencyToWeightAction extends AbstractLevel1Acti
    164 150
             return true;
    
    165 151
         }
    
    166 152
     
    
    167
    -    protected void doExecuteTrip(Trip trip,
    
    168
    -                                 Collection<Sample> samples) throws TopiaException {
    
    153
    +    protected void doExecuteTrip(Trip trip, Collection<Sample> samples) throws TopiaException {
    
    169 154
     
    
    170 155
             incrementsProgression();
    
    171 156
     
    
    ... ... @@ -184,8 +169,7 @@ public class ConvertSetSpeciesFrequencyToWeightAction extends AbstractLevel1Acti
    184 169
                 float nb = sample.getTotalStandardiseSampleSpeciesFrequencyNumber();
    
    185 170
     
    
    186 171
                 addInfoMessage(
    
    187
    -                    l(locale, "t3.level1.convertSetSpeciesFrequencyToWeight.sample.nbFishes",
    
    188
    -                            sampleStr, nb));
    
    172
    +                    l(locale, "t3.level1.convertSetSpeciesFrequencyToWeight.sample.nbFishes", sampleStr, nb));
    
    189 173
                 nbTreatedFishesInSamples += nb;
    
    190 174
     
    
    191 175
                 for (SampleSet sampleSet : sample.getSampleSet()) {
    
    ... ... @@ -200,17 +184,14 @@ public class ConvertSetSpeciesFrequencyToWeightAction extends AbstractLevel1Acti
    200 184
                         // found a new activity to convert
    
    201 185
                         convertFrequenciesToCatWeight(activity);
    
    202 186
     
    
    203
    -                    getTimeLog().log(
    
    204
    -                            s1,
    
    205
    -                            "convertSetSpeciesFrequencyToWeight for " +
    
    206
    -                                    tripActivities.size() + " sets.");
    
    187
    +                    getTimeLog().log(s1, String.format("convertSetSpeciesFrequencyToWeight for %d sets.", tripActivities.size()));
    
    207 188
                     }
    
    208 189
                 }
    
    209 190
     
    
    210 191
                 // mark sample as treated for this step of level 1 treatment
    
    211 192
                 markAsTreated(sample);
    
    212 193
     
    
    213
    -            getTimeLog().log(s0, "treat sample " + sampleStr);
    
    194
    +            getTimeLog().log(s0, String.format("treat sample %s", sampleStr));
    
    214 195
             }
    
    215 196
     
    
    216 197
             nbTreatedSets += tripActivities.size();
    
    ... ... @@ -226,50 +207,32 @@ public class ConvertSetSpeciesFrequencyToWeightAction extends AbstractLevel1Acti
    226 207
             Date date = activity.getDate();
    
    227 208
             Ocean activityOcean = activity.getOcean();
    
    228 209
     
    
    229
    -
    
    230 210
             // group frequencies by species
    
    231 211
             Multimap<Species, SetSpeciesFrequency> setSpeciesFrequencyBySpecies =
    
    232 212
                     SpeciesTopiaDao.groupBySpecies(frequencies);
    
    233 213
     
    
    234
    -        Multimap<Species, Integer> lengthClassesBySpecies =
    
    235
    -                ArrayListMultimap.create();
    
    214
    +        Multimap<Species, Integer> lengthClassesBySpecies = ArrayListMultimap.create();
    
    236 215
     
    
    237 216
             // collect all length classes by species
    
    238
    -        SetSpeciesFrequencyTopiaDao.collectLengthClasses(
    
    239
    -                setSpeciesFrequencyBySpecies, lengthClassesBySpecies);
    
    217
    +        SetSpeciesFrequencyTopiaDao.collectLengthClasses(setSpeciesFrequencyBySpecies, lengthClassesBySpecies);
    
    240 218
     
    
    241 219
             // get all available weight categories
    
    242
    -        List<WeightCategorySample> weightCategories =
    
    243
    -                getWeightCategories(activity);
    
    220
    +        List<WeightCategorySample> weightCategories = getWeightCategories(activity);
    
    244 221
     
    
    245 222
             for (Species species : setSpeciesFrequencyBySpecies.keySet()) {
    
    246 223
     
    
    247 224
                 // get conversion for species
    
    248
    -            LengthWeightConversion conversion =
    
    249
    -                    conversionHelper.getConversions(
    
    250
    -                            species,
    
    251
    -                            activityOcean,
    
    252
    -                            0,
    
    253
    -                            date
    
    254
    -                    );
    
    255
    -
    
    256
    -            Collection<SetSpeciesFrequency> setSizes =
    
    257
    -                    setSpeciesFrequencyBySpecies.get(species);
    
    258
    -
    
    259
    -            List<Integer> lengthClasses =
    
    260
    -                    Lists.newArrayList(lengthClassesBySpecies.get(species));
    
    225
    +            LengthWeightConversion conversion = conversionHelper.getConversions(species, activityOcean, 0, date);
    
    226
    +
    
    227
    +            Collection<SetSpeciesFrequency> setSizes = setSpeciesFrequencyBySpecies.get(species);
    
    228
    +
    
    229
    +            List<Integer> lengthClasses = Lists.newArrayList(lengthClassesBySpecies.get(species));
    
    261 230
                 Collections.sort(lengthClasses);
    
    262 231
     
    
    263 232
                 Map<WeightCategorySample, CountAndWeight> countAndWeightsByCategories =
    
    264
    -                    convertForSpecies(
    
    265
    -                            weightCategories,
    
    266
    -                            conversion,
    
    267
    -                            setSizes,
    
    268
    -                            lengthClasses);
    
    269
    -
    
    270
    -            // now we can build for the given activity and species the entries
    
    271
    -            // in SetWeight
    
    233
    +                    convertForSpecies(weightCategories, conversion, setSizes, lengthClasses);
    
    272 234
     
    
    235
    +            // now we can build for the given activity and species the entries in SetWeight
    
    273 236
                 fill(activity, species, countAndWeightsByCategories);
    
    274 237
             }
    
    275 238
         }
    
    ... ... @@ -279,7 +242,7 @@ public class ConvertSetSpeciesFrequencyToWeightAction extends AbstractLevel1Acti
    279 242
                                                                             Collection<SetSpeciesFrequency> setSizes,
    
    280 243
                                                                             List<Integer> lengthClasses) throws TopiaException {
    
    281 244
     
    
    282
    -        Map<Integer, WeightCategorySample> weightCategorie = conversionHelper.getWeightCategoriesDistribution(
    
    245
    +        Map<Integer, WeightCategorySample> weightCategoryMap = conversionHelper.getWeightCategoriesDistribution(
    
    283 246
                     conversion,
    
    284 247
                     weightCategories,
    
    285 248
                     lengthClasses
    
    ... ... @@ -287,9 +250,7 @@ public class ConvertSetSpeciesFrequencyToWeightAction extends AbstractLevel1Acti
    287 250
     
    
    288 251
             Map<WeightCategorySample, CountAndWeight> result = new HashMap<>();
    
    289 252
     
    
    290
    -        T3IOUtil.fillMapWithDefaultValue(result,
    
    291
    -                weightCategorie.values(),
    
    292
    -                T3Suppliers.COUNT_AND_WEIGHT_DEFAULT_VALUE);
    
    253
    +        T3IOUtil.fillMapWithDefaultValue(result, weightCategoryMap.values(), T3Suppliers.COUNT_AND_WEIGHT_DEFAULT_VALUE);
    
    293 254
     
    
    294 255
             for (SetSpeciesFrequency setSize : setSizes) {
    
    295 256
     
    
    ... ... @@ -297,8 +258,7 @@ public class ConvertSetSpeciesFrequencyToWeightAction extends AbstractLevel1Acti
    297 258
                 int lfLengthClass = setSize.getLfLengthClass();
    
    298 259
     
    
    299 260
                 // find the correct category for this length class
    
    300
    -            WeightCategorySample weightCategory =
    
    301
    -                    weightCategorie.get(lfLengthClass);
    
    261
    +            WeightCategorySample weightCategory = weightCategoryMap.get(lfLengthClass);
    
    302 262
     
    
    303 263
                 CountAndWeight countAndWeight = result.get(weightCategory);
    
    304 264
     
    
    ... ... @@ -313,12 +273,9 @@ public class ConvertSetSpeciesFrequencyToWeightAction extends AbstractLevel1Acti
    313 273
             return result;
    
    314 274
         }
    
    315 275
     
    
    316
    -    private void fill(Activity activity,
    
    317
    -                      Species species,
    
    318
    -                      Map<WeightCategorySample, CountAndWeight> countAndWeightsByCategories) throws TopiaException {
    
    276
    +    private void fill(Activity activity, Species species, Map<WeightCategorySample, CountAndWeight> countAndWeightsByCategories) throws TopiaException {
    
    319 277
     
    
    320
    -        for (Map.Entry<WeightCategorySample, CountAndWeight> e2 :
    
    321
    -                countAndWeightsByCategories.entrySet()) {
    
    278
    +        for (Map.Entry<WeightCategorySample, CountAndWeight> e2 : countAndWeightsByCategories.entrySet()) {
    
    322 279
                 WeightCategorySample categorySample = e2.getKey();
    
    323 280
     
    
    324 281
                 CountAndWeight countAndWeight = e2.getValue();
    

  • t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ExtrapolateSampleCountedAndMeasuredAction.java
    ... ... @@ -28,11 +28,11 @@ import fr.ird.t3.entities.data.SampleSpecies;
    28 28
     import fr.ird.t3.entities.data.Trip;
    
    29 29
     import fr.ird.t3.entities.reference.Species;
    
    30 30
     import fr.ird.t3.entities.reference.SpeciesTopiaDao;
    
    31
    +
    
    31 32
     import java.util.Collection;
    
    32 33
     import java.util.List;
    
    33 34
     import java.util.Map;
    
    34 35
     
    
    35
    -
    
    36 36
     import static org.nuiton.i18n.I18n.l;
    
    37 37
     
    
    38 38
     /**
    
    ... ... @@ -50,9 +50,7 @@ public class ExtrapolateSampleCountedAndMeasuredAction extends AbstractLevel1Act
    50 50
         }
    
    51 51
     
    
    52 52
         public List<SpeciesCountAndMeasuredModel> getResultSpeciesModel() {
    
    53
    -        List<SpeciesCountAndMeasuredModel> result =
    
    54
    -                getResultAsList(RESULT_SPECIES_MODEL, SpeciesCountAndMeasuredModel.class);
    
    55
    -        return result;
    
    53
    +        return getResultAsList(RESULT_SPECIES_MODEL, SpeciesCountAndMeasuredModel.class);
    
    56 54
         }
    
    57 55
     
    
    58 56
         public SpeciesCountAndMeasuredModel getTotalSpeciesModel() {
    
    ... ... @@ -81,7 +79,7 @@ public class ExtrapolateSampleCountedAndMeasuredAction extends AbstractLevel1Act
    81 79
         }
    
    82 80
     
    
    83 81
         @Override
    
    84
    -    protected boolean executeAction() throws Exception {
    
    82
    +    protected boolean executeAction() {
    
    85 83
     
    
    86 84
             Map<Species, SpeciesCountAndMeasuredModel> model = Maps.newHashMap();
    
    87 85
     
    
    ... ... @@ -110,8 +108,7 @@ public class ExtrapolateSampleCountedAndMeasuredAction extends AbstractLevel1Act
    110 108
             return true;
    
    111 109
         }
    
    112 110
     
    
    113
    -    protected void doExecuteSample(Sample sample,
    
    114
    -                                   Map<Species, SpeciesCountAndMeasuredModel> model) {
    
    111
    +    protected void doExecuteSample(Sample sample, Map<Species, SpeciesCountAndMeasuredModel> model) {
    
    115 112
     
    
    116 113
             incrementsProgression();
    
    117 114
     
    
    ... ... @@ -120,7 +117,6 @@ public class ExtrapolateSampleCountedAndMeasuredAction extends AbstractLevel1Act
    120 117
                        sample.getSampleNumber()));
    
    121 118
     
    
    122 119
             if (sample.isSampleSpeciesEmpty()) {
    
    123
    -
    
    124 120
                 // no sample species, nothing to do...
    
    125 121
                 return;
    
    126 122
             }
    
    ... ... @@ -145,9 +141,7 @@ public class ExtrapolateSampleCountedAndMeasuredAction extends AbstractLevel1Act
    145 141
                 float measuredCount = 0;
    
    146 142
                 for (SampleSpecies aSampleSpecies : sampleSpecies) {
    
    147 143
                     totalCount += aSampleSpecies.getTotalCount();
    
    148
    -
    
    149
    -                measuredCount +=
    
    150
    -                        aSampleSpecies.getTotalSampleSpeciesFrequencyNumber();
    
    144
    +                measuredCount += aSampleSpecies.getTotalSampleSpeciesFrequencyNumber();
    
    151 145
                 }
    
    152 146
                 float rf0 = totalCount / measuredCount;
    
    153 147
     
    
    ... ... @@ -161,7 +155,6 @@ public class ExtrapolateSampleCountedAndMeasuredAction extends AbstractLevel1Act
    161 155
     
    
    162 156
                 // apply rf0 on each sample
    
    163 157
                 for (SampleSpecies sampleSpecie : sampleSpecies) {
    
    164
    -
    
    165 158
                     sampleSpecie.applyRf0(rf0);
    
    166 159
                 }
    
    167 160
             }
    

  • t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ExtrapolateSampleWeightToSetAction.java
    ... ... @@ -20,9 +20,7 @@
    20 20
      */
    
    21 21
     package fr.ird.t3.actions.data.level1;
    
    22 22
     
    
    23
    -import com.google.common.collect.Maps;
    
    24 23
     import com.google.common.collect.Multimap;
    
    25
    -import com.google.common.collect.Sets;
    
    26 24
     import fr.ird.t3.entities.data.Activity;
    
    27 25
     import fr.ird.t3.entities.data.RfUsageStatus;
    
    28 26
     import fr.ird.t3.entities.data.Sample;
    
    ... ... @@ -45,14 +43,16 @@ import fr.ird.t3.entities.reference.WeightCategoryWellPlan;
    45 43
     import fr.ird.t3.entities.reference.WeightCategoryWellPlanTopiaDao;
    
    46 44
     import fr.ird.t3.services.DecoratorService;
    
    47 45
     import fr.ird.t3.services.ioc.InjectDAO;
    
    48
    -import java.util.Collection;
    
    49
    -import java.util.Map;
    
    50
    -import java.util.Set;
    
    51 46
     import org.apache.commons.logging.Log;
    
    52 47
     import org.apache.commons.logging.LogFactory;
    
    53 48
     import org.nuiton.topia.persistence.TopiaException;
    
    54 49
     import org.nuiton.util.TimeLog;
    
    55 50
     
    
    51
    +import java.util.Collection;
    
    52
    +import java.util.HashMap;
    
    53
    +import java.util.HashSet;
    
    54
    +import java.util.Map;
    
    55
    +import java.util.Set;
    
    56 56
     
    
    57 57
     import static org.nuiton.i18n.I18n.l;
    
    58 58
     
    
    ... ... @@ -125,7 +125,7 @@ public class ExtrapolateSampleWeightToSetAction extends AbstractLevel1Action {
    125 125
         }
    
    126 126
     
    
    127 127
         @Override
    
    128
    -    protected boolean executeAction() throws Exception {
    
    128
    +    protected boolean executeAction() {
    
    129 129
     
    
    130 130
             Set<Trip> trips = samplesByTrip.keySet();
    
    131 131
             setNbSteps(samplesByTrip.size() + trips.size());
    
    ... ... @@ -153,11 +153,11 @@ public class ExtrapolateSampleWeightToSetAction extends AbstractLevel1Action {
    153 153
     
    
    154 154
             incrementsProgression();
    
    155 155
     
    
    156
    +        //FIXME I replace ocean by trip.departureHarbour.ocean, check this is ok (See #260)
    
    156 157
             // get the length class +10kg limit
    
    157
    -        Map<Species, Integer> limitLengthClassBySpecie =
    
    158
    -                getThredHoldPlus10ForSpecies(trip, samples, ocean);
    
    158
    +        Map<Species, Integer> limitLengthClassBySpecie = getThredHoldPlus10ForSpecies(trip, samples, trip.getDepartureHarbour().getOcean());
    
    159 159
     
    
    160
    -        Set<Activity> tripActivities = Sets.newHashSet();
    
    160
    +        Set<Activity> tripActivities = new HashSet<>();
    
    161 161
     
    
    162 162
             // extrapolate for each sample set number to set
    
    163 163
             for (Sample sample : samples) {
    
    ... ... @@ -187,11 +187,7 @@ public class ExtrapolateSampleWeightToSetAction extends AbstractLevel1Action {
    187 187
                         activity.clearSetSpeciesCatWeight();
    
    188 188
                     }
    
    189 189
     
    
    190
    -                doExecuteSampleWell(
    
    191
    -                        activity,
    
    192
    -                        sampleSet,
    
    193
    -                        sampleStr,
    
    194
    -                        limitLengthClassBySpecie);
    
    190
    +                doExecuteSampleWell(activity, sampleSet, sampleStr, limitLengthClassBySpecie);
    
    195 191
     
    
    196 192
                 }
    
    197 193
     
    
    ... ... @@ -244,11 +240,7 @@ public class ExtrapolateSampleWeightToSetAction extends AbstractLevel1Action {
    244 240
             sampleSet.setRfTot(rfContext.getRfTot());
    
    245 241
     
    
    246 242
             // fill the SetSpecieFrequency table
    
    247
    -        fillSetSpeciesFrequency(
    
    248
    -                activity,
    
    249
    -                limitLengthClassBySpecie,
    
    250
    -                sampleSet,
    
    251
    -                rfContext);
    
    243
    +        fillSetSpeciesFrequency(activity, limitLengthClassBySpecie, sampleSet, rfContext);
    
    252 244
     
    
    253 245
         }
    
    254 246
     
    
    ... ... @@ -330,9 +322,7 @@ public class ExtrapolateSampleWeightToSetAction extends AbstractLevel1Action {
    330 322
          * @throws TopiaException if any pb while finding convertors
    
    331 323
          * @see SampleWellSampleWeight
    
    332 324
          */
    
    333
    -    protected SampleWellSetWeight computeSampleWellSetWeight(
    
    334
    -            String sampleWellStr,
    
    335
    -            SampleSet sampleSet) throws TopiaException {
    
    325
    +    protected SampleWellSetWeight computeSampleWellSetWeight(String sampleWellStr, SampleSet sampleSet) throws TopiaException {
    
    336 326
     
    
    337 327
             float pondt = sampleSet.getWeightedWeight();
    
    338 328
             Float pondm = sampleSet.getWeightedWeightMinus10();
    
    ... ... @@ -489,11 +479,7 @@ public class ExtrapolateSampleWeightToSetAction extends AbstractLevel1Action {
    489 479
             return rfContext;
    
    490 480
         }
    
    491 481
     
    
    492
    -    public void fillSetSpeciesFrequency(
    
    493
    -            Activity activity,
    
    494
    -            Map<Species, Integer> limitLengthClassBySpecies,
    
    495
    -            SampleSet sampleSet,
    
    496
    -            RFContext rfContext) throws TopiaException {
    
    482
    +    public void fillSetSpeciesFrequency(Activity activity, Map<Species, Integer> limitLengthClassBySpecies, SampleSet sampleSet, RFContext rfContext) throws TopiaException {
    
    497 483
     
    
    498 484
             // group sample set frequencies by species
    
    499 485
             Multimap<Species, SampleSetSpeciesFrequency> sampleSetSpeciesFrequencyBySpecies =
    
    ... ... @@ -542,18 +528,15 @@ public class ExtrapolateSampleWeightToSetAction extends AbstractLevel1Action {
    542 528
          * @param trip    the trip where samples are done
    
    543 529
          * @param samples the sample to scan
    
    544 530
          * @param ocean   ocean where trip happens
    
    545
    -     * @return the universe of legnth class limits computed indexed by species
    
    531
    +     * @return the universe of length class limits computed indexed by species
    
    546 532
          * @throws TopiaException if any db problems while requesting
    
    547 533
          */
    
    548
    -    public Map<Species, Integer> getThredHoldPlus10ForSpecies(Trip trip,
    
    549
    -                                                              Collection<Sample> samples,
    
    550
    -                                                              Ocean ocean) throws TopiaException {
    
    534
    +    public Map<Species, Integer> getThredHoldPlus10ForSpecies(Trip trip, Collection<Sample> samples, Ocean ocean) throws TopiaException {
    
    551 535
     
    
    552 536
             Set<Species> species = SpeciesTopiaDao.getAllSpeciesFromSampleSpecies(samples);
    
    553 537
     
    
    554
    -        // for each of those species, found the length class wich matches a
    
    555
    -        // weight > 10Kg
    
    556
    -        Map<Species, Integer> result = Maps.newHashMap();
    
    538
    +        // for each of those species, found the length class which matches a weight > 10Kg
    
    539
    +        Map<Species, Integer> result = new HashMap<>();
    
    557 540
             for (Species specie : species) {
    
    558 541
     
    
    559 542
                 LengthWeightConversion conversion = conversionHelper.getConversions(
    
    ... ... @@ -577,8 +560,7 @@ public class ExtrapolateSampleWeightToSetAction extends AbstractLevel1Action {
    577 560
     
    
    578 561
             if (log.isDebugEnabled()) {
    
    579 562
                 for (Map.Entry<Species, Integer> entry : result.entrySet()) {
    
    580
    -                log.debug("Species " + entry.getKey().getCode() +
    
    581
    -                        " - limit 10Kg length class : " + entry.getValue());
    
    563
    +                log.debug(String.format("Species %d - limit 10Kg length class : %d", entry.getKey().getCode(), entry.getValue()));
    
    582 564
     
    
    583 565
                 }
    
    584 566
             }
    

  • t3-actions/src/main/java/fr/ird/t3/actions/data/level1/Level1Configuration.java
    ... ... @@ -20,9 +20,7 @@
    20 20
      */
    
    21 21
     package fr.ird.t3.actions.data.level1;
    
    22 22
     
    
    23
    -import com.google.common.base.Preconditions;
    
    24 23
     import com.google.common.base.Predicate;
    
    25
    -import com.google.common.collect.Iterables;
    
    26 24
     import com.google.common.collect.Lists;
    
    27 25
     import com.google.common.collect.Maps;
    
    28 26
     import com.google.common.collect.Multimap;
    
    ... ... @@ -44,13 +42,13 @@ import org.apache.commons.logging.Log;
    44 42
     import org.apache.commons.logging.LogFactory;
    
    45 43
     import org.nuiton.decorator.Decorator;
    
    46 44
     
    
    47
    -import java.util.Arrays;
    
    48 45
     import java.util.Collection;
    
    49 46
     import java.util.EnumSet;
    
    50 47
     import java.util.List;
    
    51 48
     import java.util.Locale;
    
    52 49
     import java.util.Map;
    
    53 50
     import java.util.Set;
    
    51
    +import java.util.stream.Collectors;
    
    54 52
     
    
    55 53
     import static org.nuiton.i18n.I18n.l;
    
    56 54
     
    
    ... ... @@ -84,11 +82,12 @@ public class Level1Configuration implements T3ActionConfiguration {
    84 82
         /** Ids of fleet countries to use. */
    
    85 83
         protected List<String> fleetIds;
    
    86 84
     
    
    85
    +    /** Ids of ocean to use. */
    
    86
    +    protected List<String> oceanIds;
    
    87
    +
    
    87 88
         /** Ids of trips to use. */
    
    88 89
         protected Multimap<String, String> sampleIdsByTripId;
    
    89 90
     
    
    90
    -    /** Id of selected ocean. */
    
    91
    -    protected String oceanId;
    
    92 91
     
    
    93 92
         /** begin date to use. */
    
    94 93
         protected T3Date beginDate;
    
    ... ... @@ -150,12 +149,12 @@ public class Level1Configuration implements T3ActionConfiguration {
    150 149
             getExecutedSteps().add(step);
    
    151 150
         }
    
    152 151
     
    
    153
    -    public String getOceanId() {
    
    154
    -        return oceanId;
    
    152
    +    public List<String> getOceanIds() {
    
    153
    +        return oceanIds;
    
    155 154
         }
    
    156 155
     
    
    157
    -    public void setOceanId(String oceanId) {
    
    158
    -        this.oceanId = oceanId;
    
    156
    +    public void setOceanIds(List<String> oceanIds) {
    
    157
    +        this.oceanIds = oceanIds;
    
    159 158
         }
    
    160 159
     
    
    161 160
         public Multimap<String, String> getSampleIdsByTripId() {
    
    ... ... @@ -306,32 +305,23 @@ public class Level1Configuration implements T3ActionConfiguration {
    306 305
     
    
    307 306
             Multimap<String, String> result = TreeMultimap.create();
    
    308 307
     
    
    309
    -        if (oceanId == null) {
    
    308
    +        if (oceanIds == null) {
    
    310 309
     
    
    311 310
                 // no matching trips (so no matching trip
    
    312 311
                 return result;
    
    313 312
             }
    
    314
    -        Preconditions.checkNotNull(oceanId);
    
    315
    -
    
    316
    -        Ocean ocean =
    
    317
    -                Iterables.find(oceans, T3Predicates.equalsTopiaEntity(oceanId));
    
    318 313
     
    
    319
    -        Preconditions.checkNotNull(ocean);
    
    314
    +        Set<Ocean> usableOceans = oceans.stream().filter(o -> oceanIds.contains(o.getTopiaId())).collect(Collectors.toSet());
    
    320 315
     
    
    321
    -        Predicate<Trip> tripPredicate =
    
    322
    -                T3Predicates.tripUsingOcean(Arrays.asList(ocean));
    
    316
    +        Predicate<Trip> tripPredicate = T3Predicates.tripUsingOcean(usableOceans);
    
    323 317
     
    
    324
    -        Decorator<Trip> tripDecorator =
    
    325
    -                decoratorService.getDecorator(locale, Trip.class, DecoratorService.WITH_ID);
    
    318
    +        Decorator<Trip> tripDecorator = decoratorService.getDecorator(locale, Trip.class, DecoratorService.WITH_ID);
    
    326 319
     
    
    327
    -        Decorator<Sample> sampleDecorator =
    
    328
    -                decoratorService.getDecorator(locale, Sample.class, DecoratorService.WITH_ID);
    
    320
    +        Decorator<Sample> sampleDecorator = decoratorService.getDecorator(locale, Sample.class, DecoratorService.WITH_ID);
    
    329 321
     
    
    330
    -        String sampleWellEmptyReason =
    
    331
    -                l(locale, "t3.level1.notSelectedSample.sampleWellEmpty");
    
    322
    +        String sampleWellEmptyReason = l(locale, "t3.level1.notSelectedSample.sampleWellEmpty");
    
    332 323
     
    
    333
    -        String sampleNoMatchingActivityReason =
    
    334
    -                l(locale, "t3.level1.notSelectedSample.sampleNoMatchingActivity");
    
    324
    +        String sampleNoMatchingActivityReason = l(locale, "t3.level1.notSelectedSample.sampleNoMatchingActivity");
    
    335 325
     
    
    336 326
             Decorator<SampleQuality> sampleQualityDecorator = decoratorService.getDecorator(locale, SampleQuality.class, null);
    
    337 327
             Decorator<SampleType> sampleTypeDecorator = decoratorService.getDecorator(locale, SampleType.class, null);
    

  • t3-actions/src/main/java/fr/ird/t3/actions/data/level1/RedistributeSampleNumberToSetAction.java
    ... ... @@ -31,11 +31,11 @@ import fr.ird.t3.entities.data.Trip;
    31 31
     import fr.ird.t3.entities.reference.Species;
    
    32 32
     import fr.ird.t3.entities.reference.SpeciesTopiaDao;
    
    33 33
     import fr.ird.t3.services.ioc.InjectDAO;
    
    34
    +import org.nuiton.topia.persistence.TopiaException;
    
    35
    +
    
    34 36
     import java.util.Collection;
    
    35 37
     import java.util.Map;
    
    36 38
     import java.util.Set;
    
    37
    -import org.nuiton.topia.persistence.TopiaException;
    
    38
    -
    
    39 39
     
    
    40 40
     import static org.nuiton.i18n.I18n.l;
    
    41 41
     
    
    ... ... @@ -55,9 +55,7 @@ public class RedistributeSampleNumberToSetAction extends AbstractLevel1Action {
    55 55
         }
    
    56 56
     
    
    57 57
         public Set<Species> getSpeciesOfSample(Sample sample) {
    
    58
    -        Set<Species> result = SpeciesTopiaDao.getAllSpecies(
    
    59
    -                sample.getStandardiseSampleSpecies());
    
    60
    -        return result;
    
    58
    +        return SpeciesTopiaDao.getAllSpecies(sample.getStandardiseSampleSpecies());
    
    61 59
         }
    
    62 60
     
    
    63 61
         public SpeciesModel getResultSpeciesModel(Sample sample, Species species) {
    
    ... ... @@ -88,7 +86,7 @@ public class RedistributeSampleNumberToSetAction extends AbstractLevel1Action {
    88 86
         }
    
    89 87
     
    
    90 88
         @Override
    
    91
    -    protected boolean executeAction() throws Exception {
    
    89
    +    protected boolean executeAction() {
    
    92 90
     
    
    93 91
             setNbSteps(2 * samplesByTrip.size());
    
    94 92
     
    
    ... ... @@ -125,8 +123,8 @@ public class RedistributeSampleNumberToSetAction extends AbstractLevel1Action {
    125 123
             }
    
    126 124
             incrementsProgression();
    
    127 125
     
    
    128
    -        long sampleTotalNumber = 0l;
    
    129
    -        long sampleWellTotalNumber = 0l;
    
    126
    +        long sampleTotalNumber = 0L;
    
    127
    +        long sampleWellTotalNumber = 0L;
    
    130 128
     
    
    131 129
             for (StandardiseSampleSpecies sampleSpecies :
    
    132 130
                     sample.getStandardiseSampleSpecies()) {
    

  • t3-actions/src/main/java/fr/ird/t3/actions/data/level1/StandardizeSampleMeasuresAction.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%
    
    ... ... @@ -36,14 +36,15 @@ import fr.ird.t3.entities.reference.SpeciesLengthStep;
    36 36
     import fr.ird.t3.entities.reference.SpeciesLengthStepTopiaDao;
    
    37 37
     import fr.ird.t3.entities.reference.SpeciesTopiaDao;
    
    38 38
     import fr.ird.t3.services.ioc.InjectDAO;
    
    39
    -import java.util.Collection;
    
    40
    -import java.util.List;
    
    41
    -import java.util.Map;
    
    42 39
     import org.apache.commons.collections.CollectionUtils;
    
    43 40
     import org.apache.commons.logging.Log;
    
    44 41
     import org.apache.commons.logging.LogFactory;
    
    45 42
     import org.nuiton.topia.persistence.TopiaException;
    
    46 43
     
    
    44
    +import java.util.Collection;
    
    45
    +import java.util.List;
    
    46
    +import java.util.Map;
    
    47
    +import java.util.TreeMap;
    
    47 48
     
    
    48 49
     import static org.nuiton.i18n.I18n.l;
    
    49 50
     
    
    ... ... @@ -61,29 +62,22 @@ import static org.nuiton.i18n.I18n.l;
    61 62
      */
    
    62 63
     public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
    
    63 64
     
    
    65
    +    public static final String RESULT_SPECIES_MODEL = "speciesModel";
    
    64 66
         /** Logger. */
    
    65
    -    private static final Log log =
    
    66
    -            LogFactory.getLog(StandardizeSampleMeasuresAction.class);
    
    67
    -
    
    67
    +    private static final Log log = LogFactory.getLog(StandardizeSampleMeasuresAction.class);
    
    68 68
         @InjectDAO(entityType = StandardiseSampleSpecies.class)
    
    69
    -    protected StandardiseSampleSpeciesTopiaDao standardiseSampleSpeciesDAO;
    
    70
    -
    
    69
    +    private StandardiseSampleSpeciesTopiaDao standardiseSampleSpeciesDAO;
    
    71 70
         @InjectDAO(entityType = StandardiseSampleSpeciesFrequency.class)
    
    72
    -    protected StandardiseSampleSpeciesFrequencyTopiaDao standardiseSampleSpeciesFrequencyDAO;
    
    73
    -
    
    71
    +    private StandardiseSampleSpeciesFrequencyTopiaDao standardiseSampleSpeciesFrequencyDAO;
    
    74 72
         @InjectDAO(entityType = SpeciesLengthStep.class)
    
    75
    -    protected SpeciesLengthStepTopiaDao speciesLengthStepDAO;
    
    76
    -
    
    77
    -    public static final String RESULT_SPECIES_MODEL = "speciesModel";
    
    73
    +    private SpeciesLengthStepTopiaDao speciesLengthStepDAO;
    
    78 74
     
    
    79 75
         public StandardizeSampleMeasuresAction() {
    
    80 76
             super(Level1Step.STANDARDIZE_SAMPLE_MEASURE);
    
    81 77
         }
    
    82 78
     
    
    83 79
         public List<StandardizeSpeciesCountModel> getResultSpeciesModel() {
    
    84
    -        List<StandardizeSpeciesCountModel> result =
    
    85
    -                getResultAsList(RESULT_SPECIES_MODEL, StandardizeSpeciesCountModel.class);
    
    86
    -        return result;
    
    80
    +        return getResultAsList(RESULT_SPECIES_MODEL, StandardizeSpeciesCountModel.class);
    
    87 81
         }
    
    88 82
     
    
    89 83
         public StandardizeSpeciesCountModel getTotalSpeciesModel() {
    
    ... ... @@ -101,7 +95,7 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
    101 95
         }
    
    102 96
     
    
    103 97
         @Override
    
    104
    -    protected boolean executeAction() throws Exception {
    
    98
    +    protected boolean executeAction() {
    
    105 99
     
    
    106 100
             Map<Species, StandardizeSpeciesCountModel> model = Maps.newHashMap();
    
    107 101
     
    
    ... ... @@ -114,11 +108,7 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
    114 108
     
    
    115 109
                 for (Sample sample : samples) {
    
    116 110
     
    
    117
    -                doExecuteSample(
    
    118
    -                        trip,
    
    119
    -                        sample,
    
    120
    -                        model
    
    121
    -                );
    
    111
    +                doExecuteSample(trip, sample, model);
    
    122 112
     
    
    123 113
                     // mark sample as treated for this step of level 1 treatment
    
    124 114
                     markAsTreated(sample);
    
    ... ... @@ -135,23 +125,20 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
    135 125
             return true;
    
    136 126
         }
    
    137 127
     
    
    138
    -    protected void doExecuteSample(Trip trip,
    
    139
    -                                   Sample sample,
    
    140
    -                                   Map<Species, StandardizeSpeciesCountModel> model) throws TopiaException {
    
    128
    +    private void doExecuteSample(Trip trip, Sample sample, Map<Species, StandardizeSpeciesCountModel> model) throws TopiaException {
    
    141 129
     
    
    142 130
             incrementsProgression();
    
    143 131
     
    
    144 132
             String tripStr = decorate(trip);
    
    145 133
     
    
    146
    -        addInfoMessage(l(locale, "t3.level1.standardizeSampleMeasures.treat.sample",
    
    147
    -                          tripStr, sample.getSampleNumber()));
    
    134
    +        addInfoMessage(l(locale, "t3.level1.standardizeSampleMeasures.treat.sample", tripStr, sample.getSampleNumber()));
    
    148 135
     
    
    149 136
             if (!sample.isStandardiseSampleSpeciesEmpty()) {
    
    150 137
     
    
    151 138
                 // was already computed, remove previous data
    
    152 139
                 addInfoMessage(
    
    153 140
                         l(locale, "t3.level1.standardizeSampleMeasures.treat.remove.previously.treated.data",
    
    154
    -                       sample.sizeStandardiseSampleSpecies()));
    
    141
    +                            sample.sizeStandardiseSampleSpecies()));
    
    155 142
                 sample.clearStandardiseSampleSpecies();
    
    156 143
             }
    
    157 144
     
    
    ... ... @@ -162,8 +149,7 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
    162 149
             }
    
    163 150
     
    
    164 151
             // split sample species by species
    
    165
    -        Multimap<Species, SampleSpecies> sampleSpeciesBySpecies =
    
    166
    -                SpeciesTopiaDao.groupBySpecies(sample.getSampleSpecies());
    
    152
    +        Multimap<Species, SampleSpecies> sampleSpeciesBySpecies = SpeciesTopiaDao.groupBySpecies(sample.getSampleSpecies());
    
    167 153
     
    
    168 154
             for (Species species : sampleSpeciesBySpecies.keySet()) {
    
    169 155
     
    
    ... ... @@ -175,22 +161,14 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
    175 161
                 }
    
    176 162
     
    
    177 163
                 // get sample species for this species
    
    178
    -            Collection<SampleSpecies> sampleSpecies =
    
    179
    -                    sampleSpeciesBySpecies.get(species);
    
    164
    +            Collection<SampleSpecies> sampleSpecies = sampleSpeciesBySpecies.get(species);
    
    180 165
     
    
    181
    -            // obtain once for all the length classes for this species on
    
    182
    -            // this ocean
    
    166
    +            //FIXME I replace ocean by trip.departureHarbour.ocean, check this is ok (See #260)
    
    167
    +            // obtain once for all the length classes for this species on this ocean
    
    183 168
                 Multimap<Integer, SpeciesLengthStep> proportionsForSpecies =
    
    184
    -                    speciesLengthStepDAO.findAllByOceanAndSpeciesGroupByLd1Class(
    
    185
    -                            ocean,
    
    186
    -                            species);
    
    187
    -
    
    188
    -            doExecuteSampleSpecies(species,
    
    189
    -                                   sampleSpecies,
    
    190
    -                                   sample,
    
    191
    -                                   speciesCountModel,
    
    192
    -                                   proportionsForSpecies
    
    193
    -            );
    
    169
    +                    speciesLengthStepDAO.findAllByOceanAndSpeciesGroupByLd1Class(trip.getDepartureHarbour().getOcean(), species);
    
    170
    +
    
    171
    +            doExecuteSampleSpecies(species, sampleSpecies, sample, speciesCountModel, proportionsForSpecies);
    
    194 172
             }
    
    195 173
         }
    
    196 174
     
    
    ... ... @@ -204,23 +182,16 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
    204 182
     
    
    205 183
             // each species will give exactly one entry in StandardiseSampleSpecies table
    
    206 184
             StandardiseSampleSpecies standardiseSampleSpecies =
    
    207
    -                standardiseSampleSpeciesDAO.create(
    
    208
    -                        StandardiseSampleSpecies.PROPERTY_SPECIES, species
    
    209
    -                );
    
    185
    +                standardiseSampleSpeciesDAO.create(StandardiseSampleSpecies.PROPERTY_SPECIES, species);
    
    210 186
     
    
    211
    -        // contains for each lflengthclass, the number of fishes
    
    187
    +        // contains for each lfLengthClass, the number of fishes
    
    212 188
             Map<Integer, Float> frequencies = Maps.newTreeMap();
    
    213 189
             float measuredCount = 0;
    
    214 190
             float totalCount = 0;
    
    215 191
             for (SampleSpecies sampleSpecie : sampleSpecies) {
    
    216 192
                 measuredCount += sampleSpecie.getMeasuredCount();
    
    217 193
                 totalCount += sampleSpecie.getTotalCount();
    
    218
    -
    
    219
    -            collectSampleSpeciesFrequencies(
    
    220
    -                    proportionsForSpecies,
    
    221
    -                    sampleSpecie,
    
    222
    -                    frequencies
    
    223
    -            );
    
    194
    +            collectSampleSpeciesFrequencies(proportionsForSpecies, sampleSpecie, frequencies);
    
    224 195
             }
    
    225 196
     
    
    226 197
             // set the total measured count computed
    
    ... ... @@ -238,13 +209,12 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
    238 209
     
    
    239 210
                 // must recode length classes
    
    240 211
     
    
    241
    -            finalFrequencies = Maps.newTreeMap();
    
    212
    +            finalFrequencies = new TreeMap<>();
    
    242 213
     
    
    243 214
                 for (Map.Entry<Integer, Float> ee : frequencies.entrySet()) {
    
    244 215
                     Integer lfLengthClass = ee.getKey();
    
    245 216
                     Float numberExtrapolated = ee.getValue();
    
    246
    -                int finalLengthClass = lfLengthClass -
    
    247
    -                                       lfLengthClass % lfLengthClassStep;
    
    217
    +                int finalLengthClass = lfLengthClass - lfLengthClass % lfLengthClassStep;
    
    248 218
     
    
    249 219
                     Float finalNumber = finalFrequencies.get(finalLengthClass);
    
    250 220
                     if (finalNumber == null) {
    
    ... ... @@ -277,10 +247,7 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
    277 247
             // attach to sample new data
    
    278 248
             sample.addStandardiseSampleSpecies(standardiseSampleSpecies);
    
    279 249
             addInfoMessage(l(locale, "t3.level1.standardizeSampleMeasures.treat.resume.for.species",
    
    280
    -                          decorate(species),
    
    281
    -                          oldCOunt,
    
    282
    -                          newCount
    
    283
    -        ));
    
    250
    +                decorate(species), oldCOunt, newCount));
    
    284 251
         }
    
    285 252
     
    
    286 253
         protected void collectSampleSpeciesFrequencies(Multimap<Integer, SpeciesLengthStep> proportionsForSpecies,
    
    ... ... @@ -304,16 +271,15 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
    304 271
     
    
    305 272
                     // ld1 length class is in cm in sample, but in milimeter in SpeciesLengthStep table
    
    306 273
                     int ld1LengthClass = sampleSpeciesFrequency.getLengthClass() * 10;
    
    307
    -                Collection<SpeciesLengthStep> proportions =
    
    308
    -                        proportionsForSpecies.get(ld1LengthClass);
    
    274
    +                Collection<SpeciesLengthStep> proportions = proportionsForSpecies.get(ld1LengthClass);
    
    309 275
     
    
    310 276
                     if (CollectionUtils.isEmpty(proportions)) {
    
    311 277
     
    
    312 278
                         //TODO This should be an error ?
    
    313 279
                         String message = l(locale, "t3.level1.standardizeSampleMeasures.warning.lfConversion.not.found",
    
    314
    -                                        decorate(ocean),
    
    315
    -                                        decorate(species),
    
    316
    -                                        ld1LengthClass);
    
    280
    +                            decorate(getConfiguration().getOceans()),
    
    281
    +                            decorate(species),
    
    282
    +                            ld1LengthClass);
    
    317 283
                         if (log.isWarnEnabled()) {
    
    318 284
                             log.warn(message);
    
    319 285
                         }
    
    ... ... @@ -336,14 +302,8 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
    336 302
     
    
    337 303
                 // just add lf frequencies
    
    338 304
     
    
    339
    -            for (SampleSpeciesFrequency sampleSpecyFrequency :
    
    340
    -                    sampleSpecies.getSampleSpeciesFrequency()) {
    
    341
    -
    
    342
    -                addLFFrequency(
    
    343
    -                        sampleSpecyFrequency.getLengthClass(),
    
    344
    -                        sampleSpecyFrequency.getNumberExtrapolated(),
    
    345
    -                        frequencies
    
    346
    -                );
    
    305
    +            for (SampleSpeciesFrequency sampleSpecyFrequency : sampleSpecies.getSampleSpeciesFrequency()) {
    
    306
    +                addLFFrequency(sampleSpecyFrequency.getLengthClass(), sampleSpecyFrequency.getNumberExtrapolated(), frequencies);
    
    347 307
                 }
    
    348 308
             }
    
    349 309
         }
    
    ... ... @@ -352,12 +312,7 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
    352 312
                                    float number,
    
    353 313
                                    Map<Integer, Float> frequencies) throws TopiaException {
    
    354 314
     
    
    355
    -        Float standardiseSampleSpecieFrequency = frequencies.get(lengthClass);
    
    356
    -        if (standardiseSampleSpecieFrequency == null) {
    
    357
    -
    
    358
    -            standardiseSampleSpecieFrequency = 0.f;
    
    359
    -            frequencies.put(lengthClass, standardiseSampleSpecieFrequency);
    
    360
    -        }
    
    315
    +        Float standardiseSampleSpecieFrequency = frequencies.computeIfAbsent(lengthClass, k -> 0.f);
    
    361 316
     
    
    362 317
             standardiseSampleSpecieFrequency += number;
    
    363 318
     
    

  • t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeSetDurationAndPositiveSetCountActionResumeTest.java
    ... ... @@ -60,13 +60,11 @@ public class ComputeSetDurationAndPositiveSetCountActionResumeTest extends Abstr
    60 60
     
    
    61 61
             Map<String, Object> parameters = super.createTemplateParameters();
    
    62 62
     
    
    63
    -        Map<String, String> vesselSimpleTypes = new TreeMap<String, String>();
    
    64
    -        putInMap(vesselSimpleTypes,
    
    65
    -                 fixtures.vesselSimpleTypeCanneur(),
    
    66
    -                 fixtures.vesselSimpleTypeSenneur());
    
    63
    +        Map<String, String> vesselSimpleTypes = new TreeMap<>();
    
    64
    +        putInMap(vesselSimpleTypes, fixtures.vesselSimpleTypeCanneur(), fixtures.vesselSimpleTypeSenneur());
    
    67 65
             parameters.put("vesselSimpleTypes", vesselSimpleTypes);
    
    68 66
     
    
    69
    -        Map<String, String> fleets = new TreeMap<String, String>();
    
    67
    +        Map<String, String> fleets = new TreeMap<>();
    
    70 68
             putInMap(fleets, fixtures.frenchCountry());
    
    71 69
             parameters.put("fleets", fleets);
    
    72 70
     
    

  • t3-actions/src/test/java/fr/ird/t3/actions/data/level1/ComputeWeightOfCategoriesForSetActionResumeTest.java
    ... ... @@ -23,7 +23,6 @@ package fr.ird.t3.actions.data.level1;
    23 23
     import org.junit.Test;
    
    24 24
     
    
    25 25
     import java.util.Locale;
    
    26
    -import java.util.Map;
    
    27 26
     
    
    28 27
     /**
    
    29 28
      * To test the resume generation of action
    
    ... ... @@ -44,13 +43,13 @@ public class ComputeWeightOfCategoriesForSetActionResumeTest extends AbstractLev
    44 43
             action.nbSampleWithoutWell = 1;
    
    45 44
         }
    
    46 45
     
    
    47
    -    @Override
    
    48
    -    protected Map<String, Object> createTemplateParameters() {
    
    49
    -
    
    50
    -        Map<String, Object> parameters = super.createTemplateParameters();
    
    51
    -
    
    52
    -        return parameters;
    
    53
    -    }
    
    46
    +//    @Override
    
    47
    +//    protected Map<String, Object> createTemplateParameters() {
    
    48
    +//
    
    49
    +//        Map<String, Object> parameters = super.createTemplateParameters();
    
    50
    +//
    
    51
    +//        return parameters;
    
    52
    +//    }
    
    54 53
     
    
    55 54
         @Test
    
    56 55
         public void testRender() throws Exception {
    

  • t3-actions/src/test/java/fr/ird/t3/actions/data/level1/ConvertSampleSetSpeciesFrequencyToWeightActionResumeTest.java
    ... ... @@ -24,7 +24,6 @@ package fr.ird.t3.actions.data.level1;
    24 24
     import org.junit.Test;
    
    25 25
     
    
    26 26
     import java.util.Locale;
    
    27
    -import java.util.Map;
    
    28 27
     
    
    29 28
     /**
    
    30 29
      * Tests the {@link ConvertSampleSetSpeciesFrequencyToWeightAction}.
    
    ... ... @@ -43,13 +42,13 @@ public class ConvertSampleSetSpeciesFrequencyToWeightActionResumeTest extends Ab
    43 42
             super.prepareAction(action, locale);
    
    44 43
         }
    
    45 44
     
    
    46
    -    @Override
    
    47
    -    protected Map<String, Object> createTemplateParameters() {
    
    48
    -
    
    49
    -        Map<String, Object> parameters = super.createTemplateParameters();
    
    50
    -
    
    51
    -        return parameters;
    
    52
    -    }
    
    45
    +//    @Override
    
    46
    +//    protected Map<String, Object> createTemplateParameters() {
    
    47
    +//
    
    48
    +//        Map<String, Object> parameters = super.createTemplateParameters();
    
    49
    +//
    
    50
    +//        return parameters;
    
    51
    +//    }
    
    53 52
     
    
    54 53
         @Test
    
    55 54
         public void testRender() throws Exception {
    

  • t3-actions/src/test/java/fr/ird/t3/actions/data/level1/ConvertSetSpeciesFrequencyToWeightActionResumeTest.java
    ... ... @@ -23,7 +23,6 @@ package fr.ird.t3.actions.data.level1;
    23 23
     import org.junit.Test;
    
    24 24
     
    
    25 25
     import java.util.Locale;
    
    26
    -import java.util.Map;
    
    27 26
     
    
    28 27
     /**
    
    29 28
      * Tests the {@link ConvertSetSpeciesFrequencyToWeightAction}.
    
    ... ... @@ -45,13 +44,13 @@ public class ConvertSetSpeciesFrequencyToWeightActionResumeTest extends Abstract
    45 44
             action.nbCreatedFishesInSetSpeciesFrequency = 102;
    
    46 45
         }
    
    47 46
     
    
    48
    -    @Override
    
    49
    -    protected Map<String, Object> createTemplateParameters() {
    
    50
    -
    
    51
    -        Map<String, Object> parameters = super.createTemplateParameters();
    
    52
    -
    
    53
    -        return parameters;
    
    54
    -    }
    
    47
    +//    @Override
    
    48
    +//    protected Map<String, Object> createTemplateParameters() {
    
    49
    +//
    
    50
    +//        Map<String, Object> parameters = super.createTemplateParameters();
    
    51
    +//
    
    52
    +//        return parameters;
    
    53
    +//    }
    
    55 54
     
    
    56 55
         @Test
    
    57 56
         public void testRender() throws Exception {
    

  • t3-actions/src/test/java/fr/ird/t3/actions/data/level1/ExtrapolateSampleWeightToSetActionResumeTest.java
    ... ... @@ -23,7 +23,6 @@ package fr.ird.t3.actions.data.level1;
    23 23
     import org.junit.Test;
    
    24 24
     
    
    25 25
     import java.util.Locale;
    
    26
    -import java.util.Map;
    
    27 26
     
    
    28 27
     /**
    
    29 28
      * To test the resume generation of action
    
    ... ... @@ -46,13 +45,13 @@ public class ExtrapolateSampleWeightToSetActionResumeTest extends AbstractLevel1
    46 45
             action.nbCreatedFishesInSetSpeciesFrequency = 102;
    
    47 46
         }
    
    48 47
     
    
    49
    -    @Override
    
    50
    -    protected Map<String, Object> createTemplateParameters() {
    
    51
    -
    
    52
    -        Map<String, Object> parameters = super.createTemplateParameters();
    
    53
    -
    
    54
    -        return parameters;
    
    55
    -    }
    
    48
    +//    @Override
    
    49
    +//    protected Map<String, Object> createTemplateParameters() {
    
    50
    +//
    
    51
    +//        Map<String, Object> parameters = super.createTemplateParameters();
    
    52
    +//
    
    53
    +//        return parameters;
    
    54
    +//    }
    
    56 55
     
    
    57 56
         @Test
    
    58 57
         public void testRender() throws Exception {
    

  • t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/AbstractLevel1ConfigureAction.java
    ... ... @@ -33,15 +33,16 @@ import fr.ird.t3.entities.reference.SampleType;
    33 33
     import fr.ird.t3.services.ioc.InjectDAO;
    
    34 34
     import fr.ird.t3.services.ioc.InjectDecoratedBeans;
    
    35 35
     import fr.ird.t3.web.actions.AbstractConfigureAction;
    
    36
    +import org.apache.commons.collections.MapUtils;
    
    37
    +import org.apache.commons.logging.Log;
    
    38
    +import org.apache.commons.logging.LogFactory;
    
    39
    +
    
    36 40
     import java.util.Arrays;
    
    37 41
     import java.util.Collection;
    
    38 42
     import java.util.EnumSet;
    
    39 43
     import java.util.Iterator;
    
    40 44
     import java.util.Map;
    
    41 45
     import java.util.Set;
    
    42
    -import org.apache.commons.collections.MapUtils;
    
    43
    -import org.apache.commons.logging.Log;
    
    44
    -import org.apache.commons.logging.LogFactory;
    
    45 46
     
    
    46 47
     /**
    
    47 48
      * Abstract run action for all level1 actions.
    
    ... ... @@ -57,26 +58,26 @@ public class AbstractLevel1ConfigureAction extends AbstractConfigureAction<Level
    57 58
     
    
    58 59
         private static final long serialVersionUID = 1L;
    
    59 60
     
    
    60
    -    protected final Level1Step[] requiredSteps;
    
    61
    +    private final Level1Step[] requiredSteps;
    
    61 62
     
    
    62
    -    protected final Level1Step currentStep;
    
    63
    +    private final Level1Step currentStep;
    
    63 64
     
    
    64 65
         @InjectDAO(entityType = Sample.class)
    
    65
    -    protected transient SampleTopiaDao sampleDAO;
    
    66
    +    private transient SampleTopiaDao sampleDAO;
    
    66 67
     
    
    67 68
         @InjectDecoratedBeans(beanType = SampleQuality.class, filterById = true, pathIds = "sampleQualityIds")
    
    68
    -    protected Map<String, String> sampleQualities;
    
    69
    +    private Map<String, String> sampleQualities;
    
    69 70
     
    
    70 71
         @InjectDecoratedBeans(beanType = SampleType.class, filterById = true)
    
    71
    -    protected Map<String, String> sampleTypes;
    
    72
    +    private Map<String, String> sampleTypes;
    
    72 73
     
    
    73 74
         @InjectDecoratedBeans(beanType = Country.class)
    
    74
    -    protected Map<String, String> fleets;
    
    75
    +    private Map<String, String> fleets;
    
    75 76
     
    
    76
    -    @InjectDecoratedBeans(beanType = Ocean.class)
    
    77
    -    protected Map<String, String> oceans;
    
    77
    +    @InjectDecoratedBeans(beanType = Ocean.class, filterById = true)
    
    78
    +    private Map<String, String> oceans;
    
    78 79
     
    
    79
    -    protected Map<String, String> useRfMinus10AndRfPlus10OrNot;
    
    80
    +    private Map<String, String> useRfMinus10AndRfPlus10OrNot;
    
    80 81
     
    
    81 82
         public AbstractLevel1ConfigureAction(Level1Step currentStep) {
    
    82 83
             super(Level1Configuration.class);
    
    ... ... @@ -110,7 +111,7 @@ public class AbstractLevel1ConfigureAction extends AbstractConfigureAction<Level
    110 111
                 log.info("Selected fleet countries  : " + configuration.getFleetIds());
    
    111 112
                 log.info("Selected sample qualities : " + configuration.getSampleQualityIds());
    
    112 113
                 log.info("Selected sample types     : " + configuration.getSampleTypeIds());
    
    113
    -            log.info("Selected ocean            : " + configuration.getOceanId());
    
    114
    +            log.info("Selected oceans           : " + configuration.getOceanIds());
    
    114 115
                 log.info("Selected begin date       : " + configuration.getBeginDate());
    
    115 116
                 log.info("Selected end   date       : " + configuration.getEndDate());
    
    116 117
                 log.info("Executed steps            : " + configuration.getExecutedSteps());
    
    ... ... @@ -118,12 +119,12 @@ public class AbstractLevel1ConfigureAction extends AbstractConfigureAction<Level
    118 119
         }
    
    119 120
     
    
    120 121
         @Override
    
    121
    -    public String input() throws Exception {
    
    122
    +    public String input() {
    
    122 123
             return INPUT;
    
    123 124
         }
    
    124 125
     
    
    125 126
         @Override
    
    126
    -    public String execute() throws Exception {
    
    127
    +    public String execute() {
    
    127 128
     
    
    128 129
             prepareActionContext();
    
    129 130
             return SUCCESS;
    
    ... ... @@ -136,14 +137,12 @@ public class AbstractLevel1ConfigureAction extends AbstractConfigureAction<Level
    136 137
     
    
    137 138
                 // all required step already executed with this configuration
    
    138 139
                 if (log.isInfoEnabled()) {
    
    139
    -                log.info("Current configuration already treats all required step " +
    
    140
    -                                 Arrays.toString(requiredSteps));
    
    140
    +                log.info(String.format("Current configuration already treats all required step %s", Arrays.toString(requiredSteps)));
    
    141 141
                 }
    
    142 142
     
    
    143 143
             } else {
    
    144 144
     
    
    145
    -            // check on each selected sample of the configuration which steps
    
    146
    -            // are missing
    
    145
    +            // check on each selected sample of the configuration which steps are missing
    
    147 146
     
    
    148 147
                 Multimap<Level1Step, Sample> missingSteps =
    
    149 148
                         getMissingRequiredStepsExecutedOnSample();
    
    ... ... @@ -152,10 +151,7 @@ public class AbstractLevel1ConfigureAction extends AbstractConfigureAction<Level
    152 151
     
    
    153 152
                     // ok every steps were previously executed on selected sample
    
    154 153
                     if (log.isInfoEnabled()) {
    
    155
    -                    log.info("All required steps " +
    
    156
    -                                     Arrays.toString(requiredSteps) +
    
    157
    -                                     "were already executed on selected samples " +
    
    158
    -                                     "of current configuration.");
    
    154
    +                    log.info(String.format("All required steps %s were already executed on selected samples of current configuration.", Arrays.toString(requiredSteps)));
    
    159 155
                     }
    
    160 156
                 } else {
    
    161 157
     
    
    ... ... @@ -209,8 +205,7 @@ public class AbstractLevel1ConfigureAction extends AbstractConfigureAction<Level
    209 205
         }
    
    210 206
     
    
    211 207
         public Multimap<String, String> getTripIds() {
    
    212
    -        Multimap<String, String> ids = getConfiguration().getSampleIdsByTripId();
    
    213
    -        return ids;
    
    208
    +        return getConfiguration().getSampleIdsByTripId();
    
    214 209
         }
    
    215 210
     
    
    216 211
         /**
    
    ... ... @@ -228,7 +223,7 @@ public class AbstractLevel1ConfigureAction extends AbstractConfigureAction<Level
    228 223
                 if (!executedSteps.contains(requiredStep)) {
    
    229 224
     
    
    230 225
                     if (log.isWarnEnabled()) {
    
    231
    -                    log.warn("A required step [" + requiredStep + "] was still not executed with this configuration ");
    
    226
    +                    log.warn(String.format("A required step [%s] was still not executed with this configuration ", requiredStep));
    
    232 227
                     }
    
    233 228
                     return false;
    
    234 229
                 }
    
    ... ... @@ -249,19 +244,17 @@ public class AbstractLevel1ConfigureAction extends AbstractConfigureAction<Level
    249 244
     
    
    250 245
             Collection<String> sampleIds = getTripIds().values();
    
    251 246
     
    
    252
    -        Multimap<Level1Step, Sample> missingStates =
    
    253
    -                HashMultimap.create();
    
    247
    +        Multimap<Level1Step, Sample> missingStates = HashMultimap.create();
    
    254 248
             for (String sampleId : sampleIds) {
    
    255 249
     
    
    256
    -            Sample sample = sampleDAO.findByTopiaId(sampleId);
    
    250
    +            Sample sample = sampleDAO.forTopiaIdEquals(sampleId).findUnique();
    
    257 251
     
    
    258 252
                 for (Level1Step requiredStep : requiredSteps) {
    
    259 253
     
    
    260 254
                     boolean sampleState = requiredStep.getState(sample);
    
    261 255
                     if (!sampleState) {
    
    262 256
                         if (log.isWarnEnabled()) {
    
    263
    -                        log.warn("Required step " + requiredStep +
    
    264
    -                                         " is missing for sample " + sampleId);
    
    257
    +                        log.warn(String.format("Required step %s is missing for sample %s", requiredStep, sampleId));
    
    265 258
                         }
    
    266 259
                         missingStates.put(requiredStep, sample);
    
    267 260
                     }
    

  • t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/AbstractLevel1RunAction.java
    ... ... @@ -34,7 +34,6 @@ import org.apache.commons.collections.MapUtils;
    34 34
     
    
    35 35
     import java.util.Collection;
    
    36 36
     import java.util.Date;
    
    37
    -import java.util.Iterator;
    
    38 37
     import java.util.Map;
    
    39 38
     import java.util.Set;
    
    40 39
     
    
    ... ... @@ -48,24 +47,18 @@ public abstract class AbstractLevel1RunAction<A extends AbstractLevel1Action> ex
    48 47
     
    
    49 48
         private static final long serialVersionUID = 1L;
    
    50 49
     
    
    51
    -    protected final Level1Step currentStep;
    
    52
    -
    
    50
    +    private final Level1Step currentStep;
    
    53 51
         @InjectDecoratedBeans(beanType = SampleQuality.class, filterById = true, pathIds = "sampleQualityIds")
    
    54
    -    protected Map<String, String> sampleQualities;
    
    55
    -
    
    52
    +    private Map<String, String> sampleQualities;
    
    56 53
         @InjectDecoratedBeans(beanType = SampleType.class, filterById = true)
    
    57
    -    protected Map<String, String> sampleTypes;
    
    58
    -
    
    54
    +    private Map<String, String> sampleTypes;
    
    59 55
         @InjectDecoratedBeans(beanType = Country.class, filterById = true)
    
    60
    -    protected Map<String, String> fleets;
    
    56
    +    private Map<String, String> fleets;
    
    57
    +    @InjectDecoratedBeans(beanType = Ocean.class, filterById = true)
    
    58
    +    private Map<String, String> oceans;
    
    59
    +    private Map<String, String> useRfMinus10AndRfPlus10OrNot;
    
    61 60
     
    
    62
    -    @InjectDecoratedBeans(beanType = Ocean.class, filterById = true, filterBySingleId = true)
    
    63
    -    protected Map<String, String> oceans;
    
    64
    -
    
    65
    -    protected Map<String, String> useRfMinus10AndRfPlus10OrNot;
    
    66
    -
    
    67
    -    protected AbstractLevel1RunAction(Class<A> actionType,
    
    68
    -                                      Level1Step currentStep) {
    
    61
    +    AbstractLevel1RunAction(Class<A> actionType, Level1Step currentStep) {
    
    69 62
             super(actionType);
    
    70 63
             this.currentStep = currentStep;
    
    71 64
         }
    
    ... ... @@ -73,21 +66,13 @@ public abstract class AbstractLevel1RunAction<A extends AbstractLevel1Action> ex
    73 66
         @Override
    
    74 67
         protected void executeAction(A action) throws Exception {
    
    75 68
     
    
    76
    -        // when beginning a step, remove from executed one all the step with
    
    77
    -        // higher ranks...
    
    69
    +        // when beginning a step, remove from executed one all the step with higher ranks...
    
    78 70
     
    
    79 71
             Level1Configuration configuration = getConfiguration();
    
    80
    -        Set<Level1Step> executedSteps =
    
    81
    -                configuration.getExecutedSteps();
    
    72
    +        Set<Level1Step> executedSteps = configuration.getExecutedSteps();
    
    82 73
             int ordinal = currentStep.ordinal();
    
    83 74
     
    
    84
    -        Iterator<Level1Step> itr = executedSteps.iterator();
    
    85
    -        while (itr.hasNext()) {
    
    86
    -            Level1Step step = itr.next();
    
    87
    -            if (step.ordinal() >= ordinal) {
    
    88
    -                itr.remove();
    
    89
    -            }
    
    90
    -        }
    
    75
    +        executedSteps.removeIf(step -> step.ordinal() >= ordinal);
    
    91 76
     
    
    92 77
             super.executeAction(action);
    
    93 78
     
    
    ... ... @@ -134,8 +119,7 @@ public abstract class AbstractLevel1RunAction<A extends AbstractLevel1Action> ex
    134 119
         }
    
    135 120
     
    
    136 121
         public Multimap<String, String> getTripIds() {
    
    137
    -        Multimap<String, String> ids = getConfiguration().getSampleIdsByTripId();
    
    138
    -        return ids;
    
    122
    +        return getConfiguration().getSampleIdsByTripId();
    
    139 123
         }
    
    140 124
     
    
    141 125
         public Map<String, String> getUseRfMinus10AndRfPlus10OrNot() {
    
    ... ... @@ -143,14 +127,8 @@ public abstract class AbstractLevel1RunAction<A extends AbstractLevel1Action> ex
    143 127
         }
    
    144 128
     
    
    145 129
         @Override
    
    146
    -    protected Map<String, Object> prepareResumeParameters(A action,
    
    147
    -                                                          Exception error,
    
    148
    -                                                          Date startDate,
    
    149
    -                                                          Date endDate) {
    
    150
    -        Map<String, Object> map = super.prepareResumeParameters(action,
    
    151
    -                                                                error,
    
    152
    -                                                                startDate,
    
    153
    -                                                                endDate);
    
    130
    +    protected Map<String, Object> prepareResumeParameters(A action, Exception error, Date startDate, Date endDate) {
    
    131
    +        Map<String, Object> map = super.prepareResumeParameters(action, error, startDate, endDate);
    
    154 132
             map.put("oceans", oceans);
    
    155 133
             map.put("sampleQualities", sampleQualities);
    
    156 134
             map.put("sampleTypes", sampleTypes);
    

  • t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ComputeWeightOfCategoriesForSetRunAction.java
    ... ... @@ -34,7 +34,6 @@ public class ComputeWeightOfCategoriesForSetRunAction extends AbstractLevel1RunA
    34 34
         private static final long serialVersionUID = 1L;
    
    35 35
     
    
    36 36
         public ComputeWeightOfCategoriesForSetRunAction() {
    
    37
    -        super(ComputeWeightOfCategoriesForSetAction.class,
    
    38
    -              Level1Step.COMPUTE_WEIGHT_OF_CATEGORIES_FOR_SET);
    
    37
    +        super(ComputeWeightOfCategoriesForSetAction.class, Level1Step.COMPUTE_WEIGHT_OF_CATEGORIES_FOR_SET);
    
    39 38
         }
    
    40 39
     }

  • t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ConvertSampleSetSpeciesFrequencyToWeightRunAction.java
    ... ... @@ -35,7 +35,6 @@ public class ConvertSampleSetSpeciesFrequencyToWeightRunAction extends AbstractL
    35 35
         private static final long serialVersionUID = 1L;
    
    36 36
     
    
    37 37
         public ConvertSampleSetSpeciesFrequencyToWeightRunAction() {
    
    38
    -        super(ConvertSampleSetSpeciesFrequencyToWeightAction.class,
    
    39
    -              Level1Step.CONVERT_SAMPLE_SET_SPECIES_FREQUENCY_TO_WEIGHT);
    
    38
    +        super(ConvertSampleSetSpeciesFrequencyToWeightAction.class, Level1Step.CONVERT_SAMPLE_SET_SPECIES_FREQUENCY_TO_WEIGHT);
    
    40 39
         }
    
    41 40
     }

  • t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ConvertSetSpeciesFrequencyToWeightRunAction.java
    ... ... @@ -34,7 +34,6 @@ public class ConvertSetSpeciesFrequencyToWeightRunAction extends AbstractLevel1R
    34 34
         private static final long serialVersionUID = 1L;
    
    35 35
     
    
    36 36
         public ConvertSetSpeciesFrequencyToWeightRunAction() {
    
    37
    -        super(ConvertSetSpeciesFrequencyToWeightAction.class,
    
    38
    -              Level1Step.CONVERT_SET_SPECIES_FREQUENCY_TO_WEIGHT);
    
    37
    +        super(ConvertSetSpeciesFrequencyToWeightAction.class, Level1Step.CONVERT_SET_SPECIES_FREQUENCY_TO_WEIGHT);
    
    39 38
         }
    
    40 39
     }

  • t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ExtrapolateSampleCountedAndMeasuredRunAction.java
    ... ... @@ -38,24 +38,13 @@ public class ExtrapolateSampleCountedAndMeasuredRunAction extends AbstractLevel1
    38 38
         private static final long serialVersionUID = 1L;
    
    39 39
     
    
    40 40
         public ExtrapolateSampleCountedAndMeasuredRunAction() {
    
    41
    -        super(ExtrapolateSampleCountedAndMeasuredAction.class,
    
    42
    -              Level1Step.EXTRAPOLATE_SAMPLE_COUNTED_AND_MEASURED);
    
    41
    +        super(ExtrapolateSampleCountedAndMeasuredAction.class, Level1Step.EXTRAPOLATE_SAMPLE_COUNTED_AND_MEASURED);
    
    43 42
         }
    
    44 43
     
    
    45 44
         @Override
    
    46
    -    protected Map<String, Object> prepareResumeParameters(
    
    47
    -            ExtrapolateSampleCountedAndMeasuredAction action,
    
    48
    -            Exception error,
    
    49
    -            Date startDate,
    
    50
    -            Date endDate) {
    
    51
    -        Map<String, Object> parameters =
    
    52
    -                super.prepareResumeParameters(action,
    
    53
    -                                              error,
    
    54
    -                                              startDate,
    
    55
    -                                              endDate
    
    56
    -                );
    
    45
    +    protected Map<String, Object> prepareResumeParameters(ExtrapolateSampleCountedAndMeasuredAction action, Exception error, Date startDate, Date endDate) {
    
    46
    +        Map<String, Object> parameters = super.prepareResumeParameters(action, error, startDate, endDate);
    
    57 47
             parameters.put("speciesDecorator", getDecorator(Species.class));
    
    58
    -
    
    59 48
             return parameters;
    
    60 49
         }
    
    61 50
     
    

  • t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ExtrapolateSampleWeightToSetRunAction.java
    ... ... @@ -34,7 +34,6 @@ public class ExtrapolateSampleWeightToSetRunAction extends AbstractLevel1RunActi
    34 34
         private static final long serialVersionUID = 1L;
    
    35 35
     
    
    36 36
         public ExtrapolateSampleWeightToSetRunAction() {
    
    37
    -        super(ExtrapolateSampleWeightToSetAction.class,
    
    38
    -              Level1Step.EXTRAPOLATE_SAMPLE_WEIGHT_TO_SET);
    
    37
    +        super(ExtrapolateSampleWeightToSetAction.class, Level1Step.EXTRAPOLATE_SAMPLE_WEIGHT_TO_SET);
    
    39 38
         }
    
    40 39
     }

  • t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ManageLevel1ConfigurationAction.java
    ... ... @@ -35,22 +35,21 @@ import fr.ird.t3.entities.reference.SampleType;
    35 35
     import fr.ird.t3.entities.reference.SampleTypeTopiaDao;
    
    36 36
     import fr.ird.t3.entities.type.T3Date;
    
    37 37
     import fr.ird.t3.services.DecoratorService;
    
    38
    -import fr.ird.t3.services.ioc.InjectDAO;
    
    39 38
     import fr.ird.t3.services.ioc.InjectDecoratedBeans;
    
    40 39
     import fr.ird.t3.services.ioc.InjectFromDAO;
    
    41 40
     import fr.ird.t3.web.actions.AbstractConfigureAction;
    
    42
    -import java.util.Collection;
    
    43
    -import java.util.Date;
    
    44
    -import java.util.List;
    
    45
    -import java.util.Map;
    
    46 41
     import org.apache.commons.collections.CollectionUtils;
    
    47 42
     import org.apache.commons.collections.MapUtils;
    
    48
    -import org.apache.commons.lang3.StringUtils;
    
    49 43
     import org.apache.commons.lang3.tuple.MutablePair;
    
    50 44
     import org.apache.struts2.interceptor.validation.SkipValidation;
    
    51 45
     import org.nuiton.decorator.Decorator;
    
    52 46
     import org.nuiton.topia.persistence.util.TopiaEntityHelper;
    
    53 47
     
    
    48
    +import java.util.Collection;
    
    49
    +import java.util.Date;
    
    50
    +import java.util.List;
    
    51
    +import java.util.Map;
    
    52
    +
    
    54 53
     /**
    
    55 54
      * Action to manage the configuration of level 1.
    
    56 55
      *
    
    ... ... @@ -62,26 +61,23 @@ public class ManageLevel1ConfigurationAction extends AbstractConfigureAction<Lev
    62 61
         private static final long serialVersionUID = 1L;
    
    63 62
     
    
    64 63
         @InjectDecoratedBeans(beanType = SampleQuality.class)
    
    65
    -    protected Map<String, String> sampleQualities;
    
    64
    +    private Map<String, String> sampleQualities;
    
    66 65
     
    
    67 66
         @InjectDecoratedBeans(beanType = SampleType.class)
    
    68
    -    protected Map<String, String> sampleTypes;
    
    67
    +    private Map<String, String> sampleTypes;
    
    69 68
     
    
    70 69
         @InjectDecoratedBeans(beanType = Country.class)
    
    71
    -    protected Map<String, String> fleets;
    
    70
    +    private Map<String, String> fleets;
    
    72 71
     
    
    73 72
         @InjectDecoratedBeans(beanType = Ocean.class)
    
    74
    -    protected Map<String, String> oceans;
    
    73
    +    private Map<String, String> oceans;
    
    75 74
     
    
    76 75
         @InjectFromDAO(entityType = Trip.class, method = "findAllForLevel1")
    
    77
    -    protected Collection<Trip> trips;
    
    76
    +    private Collection<Trip> trips;
    
    78 77
     
    
    79
    -    @InjectDAO(entityType = Ocean.class)
    
    80
    -    protected transient OceanTopiaDao oceanDAO;
    
    78
    +    private Map<String, Trip> tripByTopiaIds;
    
    81 79
     
    
    82
    -    protected Map<String, Trip> tripByTopiaIds;
    
    83
    -
    
    84
    -    protected Map<String, String> useRfMinus10AndRfPlus10OrNot;
    
    80
    +    private Map<String, String> useRfMinus10AndRfPlus10OrNot;
    
    85 81
     
    
    86 82
         public ManageLevel1ConfigurationAction() {
    
    87 83
             super(Level1Configuration.class);
    
    ... ... @@ -124,18 +120,17 @@ public class ManageLevel1ConfigurationAction extends AbstractConfigureAction<Lev
    124 120
                 conf.setSampleTypes(sortToList(SampleTypeTopiaDao.getAllSampleTypes(trips)));
    
    125 121
                 conf.setFleets(sortToList(CountryTopiaDao.getAllFleetCountries(trips)));
    
    126 122
                 conf.setOceans(sortToList(OceanTopiaDao.getAllOcean(trips)));
    
    127
    -            if (StringUtils.isEmpty(conf.getOceanId()) &&
    
    128
    -                CollectionUtils.isNotEmpty(conf.getOceans())) {
    
    129
    -                conf.setOceanId(conf.getOceans().get(0).getTopiaId());
    
    130
    -            }
    
    123
    +//            if (StringUtils.isEmpty(conf.getOceanId()) &&
    
    124
    +//                CollectionUtils.isNotEmpty(conf.getOceans())) {
    
    125
    +//                conf.setOceanId(conf.getOceans().get(0).getTopiaId());
    
    126
    +//            }
    
    131 127
     
    
    132 128
                 // set ids list to empty lists
    
    133 129
                 List<String> ids;
    
    134 130
     
    
    135 131
                 // use default sample qualities
    
    136 132
                 ids = T3EntityHelper.selectIdsByCodes(conf.getSampleQualities(), 1, 2, 3, 9);
    
    137
    -            conf.setSampleQualityIds(
    
    138
    -                    ids);
    
    133
    +            conf.setSampleQualityIds(ids);
    
    139 134
     
    
    140 135
                 // use default sample types
    
    141 136
                 ids = T3EntityHelper.selectIdsByCodes(conf.getSampleTypes(), 1, 2, 3, 9);
    
    ... ... @@ -165,8 +160,7 @@ public class ManageLevel1ConfigurationAction extends AbstractConfigureAction<Lev
    165 160
             injectOnly(InjectDecoratedBeans.class);
    
    166 161
     
    
    167 162
             DecoratorService decoratorService = newService(DecoratorService.class);
    
    168
    -        Multimap<String, String> matchingTrips = conf.getMatchingTrips(
    
    169
    -                trips, getLocale(), decoratorService);
    
    163
    +        Multimap<String, String> matchingTrips = conf.getMatchingTrips(trips, getLocale(), decoratorService);
    
    170 164
             conf.setSampleIdsByTripId(matchingTrips);
    
    171 165
         }
    
    172 166
     
    
    ... ... @@ -179,7 +173,7 @@ public class ManageLevel1ConfigurationAction extends AbstractConfigureAction<Lev
    179 173
             }
    
    180 174
         }
    
    181 175
     
    
    182
    -    public final String prepareConfiguration() throws Exception {
    
    176
    +    public final String prepareConfiguration() {
    
    183 177
     
    
    184 178
             if (!isConfigurationInSession() && !hasFieldErrors()) {
    
    185 179
     
    
    ... ... @@ -189,7 +183,7 @@ public class ManageLevel1ConfigurationAction extends AbstractConfigureAction<Lev
    189 183
             return INPUT;
    
    190 184
         }
    
    191 185
     
    
    192
    -    public String saveConfiguration() throws Exception {
    
    186
    +    public String saveConfiguration() {
    
    193 187
             Level1Configuration config = getConfiguration();
    
    194 188
     
    
    195 189
             // each time configuration is modified, reset executed steps for
    
    ... ... @@ -205,7 +199,7 @@ public class ManageLevel1ConfigurationAction extends AbstractConfigureAction<Lev
    205 199
         }
    
    206 200
     
    
    207 201
         @SkipValidation
    
    208
    -    public String removeConfiguration() throws Exception {
    
    202
    +    public String removeConfiguration() {
    
    209 203
     
    
    210 204
             boolean saved = isConfigurationInSession();
    
    211 205
             if (saved) {
    
    ... ... @@ -238,9 +232,7 @@ public class ManageLevel1ConfigurationAction extends AbstractConfigureAction<Lev
    238 232
         }
    
    239 233
     
    
    240 234
         public Map<String, Collection<String>> getTripIds() {
    
    241
    -        Map<String, Collection<String>> ids =
    
    242
    -                getConfiguration().getSampleIdsByTripId().asMap();
    
    243
    -        return ids;
    
    235
    +        return getConfiguration().getSampleIdsByTripId().asMap();
    
    244 236
         }
    
    245 237
     
    
    246 238
         public Map<String, String> getSampleQualities() {
    

  • t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/RedistributeSampleNumberToSetRunAction.java
    ... ... @@ -41,23 +41,12 @@ public class RedistributeSampleNumberToSetRunAction extends AbstractLevel1RunAct
    41 41
         private static final long serialVersionUID = 1L;
    
    42 42
     
    
    43 43
         public RedistributeSampleNumberToSetRunAction() {
    
    44
    -        super(RedistributeSampleNumberToSetAction.class,
    
    45
    -              Level1Step.REDISTRIBUTE_SAMPLE_SET_TO_SET);
    
    44
    +        super(RedistributeSampleNumberToSetAction.class, Level1Step.REDISTRIBUTE_SAMPLE_SET_TO_SET);
    
    46 45
         }
    
    47 46
     
    
    48 47
         @Override
    
    49
    -    protected Map<String, Object> prepareResumeParameters(
    
    50
    -            RedistributeSampleNumberToSetAction action,
    
    51
    -            Exception error,
    
    52
    -            Date startDate,
    
    53
    -            Date endDate) {
    
    54
    -        Map<String, Object> parameters = super.prepareResumeParameters(
    
    55
    -                action,
    
    56
    -                error,
    
    57
    -                startDate,
    
    58
    -                endDate
    
    59
    -        );
    
    60
    -
    
    48
    +    protected Map<String, Object> prepareResumeParameters(RedistributeSampleNumberToSetAction action, Exception error, Date startDate, Date endDate) {
    
    49
    +        Map<String, Object> parameters = super.prepareResumeParameters(action, error, startDate, endDate);
    
    61 50
             parameters.put("speciesDecorator", getDecorator(Species.class));
    
    62 51
             parameters.put("tripDecorator", getDecorator(Trip.class, DecoratorService.WITH_ID));
    
    63 52
             parameters.put("activityDecorator", getDecorator(Activity.class));
    

  • t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/StandardizeSampleMeasuresRunAction.java
    ... ... @@ -38,24 +38,13 @@ public class StandardizeSampleMeasuresRunAction extends AbstractLevel1RunAction<
    38 38
         private static final long serialVersionUID = 1L;
    
    39 39
     
    
    40 40
         public StandardizeSampleMeasuresRunAction() {
    
    41
    -        super(StandardizeSampleMeasuresAction.class,
    
    42
    -              Level1Step.STANDARDIZE_SAMPLE_MEASURE);
    
    41
    +        super(StandardizeSampleMeasuresAction.class, Level1Step.STANDARDIZE_SAMPLE_MEASURE);
    
    43 42
         }
    
    44 43
     
    
    45 44
         @Override
    
    46
    -    protected Map<String, Object> prepareResumeParameters(
    
    47
    -            StandardizeSampleMeasuresAction action,
    
    48
    -            Exception error,
    
    49
    -            Date startDate,
    
    50
    -            Date endDate) {
    
    51
    -        Map<String, Object> parameters =
    
    52
    -                super.prepareResumeParameters(action,
    
    53
    -                                              error,
    
    54
    -                                              startDate,
    
    55
    -                                              endDate
    
    56
    -                );
    
    45
    +    protected Map<String, Object> prepareResumeParameters(StandardizeSampleMeasuresAction action, Exception error, Date startDate, Date endDate) {
    
    46
    +        Map<String, Object> parameters = super.prepareResumeParameters(action, error, startDate, endDate);
    
    57 47
             parameters.put("speciesDecorator", getDecorator(Species.class));
    
    58
    -
    
    59 48
             return parameters;
    
    60 49
         }
    
    61 50
     }

  • t3-web/src/main/resources/fr/ird/t3/web/actions/data/level1/ManageLevel1ConfigurationAction-validateLevel1Configuration-validation.xml
    ... ... @@ -48,9 +48,10 @@
    48 48
     
    
    49 49
       </field>
    
    50 50
     
    
    51
    -  <field name="configuration.oceanId">
    
    51
    +  <field name="configuration.oceanIds">
    
    52 52
     
    
    53
    -    <field-validator type="requiredstring">
    
    53
    +    <field-validator type="fieldexpression">
    
    54
    +      <param name="expression">!configuration.oceanIds.empty</param>
    
    54 55
           <message key="t3.error.no.ocean.selected"/>
    
    55 56
         </field-validator>
    
    56 57
     
    

  • t3-web/src/main/resources/fr/ird/t3/web/actions/data/level1/ManageLevel1ConfigurationAction-validation.xml
    ... ... @@ -48,7 +48,7 @@
    48 48
     
    
    49 49
       </field>
    
    50 50
     
    
    51
    -  <field name="configuration.oceanId">
    
    51
    +  <field name="configuration.oceanIds">
    
    52 52
     
    
    53 53
         <field-validator type="fieldexpression">
    
    54 54
           <param name="expression">!configuration.oceans.empty</param>
    

  • t3-web/src/main/webapp/WEB-INF/jsp/data/level1/level1Configuration.jsp
    ... ... @@ -56,8 +56,9 @@
    56 56
                         list="fleets" template="mycheckboxlist"/>
    
    57 57
     
    
    58 58
           <%-- selected ocean --%>
    
    59
    -    <s:select key="configuration.oceanId" list="oceans" requiredLabel="true"
    
    60
    -              label='%{getText("t3.common.ocean")}'/>
    
    59
    +    <s:checkboxlist key="configuration.oceanIds" requiredLabel="true"
    
    60
    +                    label='%{getText("t3.common.ocean")}'
    
    61
    +                    list="oceans" template="mycheckboxlist"/>
    
    61 62
     
    
    62 63
           <%-- selected begin date --%>
    
    63 64
         <sj:datepicker key="configuration.beginDate" requiredLabel="true"
    

  • t3-web/src/main/webapp/WEB-INF/jsp/data/level1/level1ConfigurationResume.jsp
    ... ... @@ -45,8 +45,9 @@
    45 45
                         label='%{getText("t3.common.fleetCountry")}'/>
    
    46 46
     
    
    47 47
           <%-- selected ocean --%>
    
    48
    -    <s:select key="configuration.oceanId" disabled="true" list="oceans"
    
    49
    -              label='%{getText("t3.common.ocean")}'/>
    
    48
    +    <s:checkboxlist key="configuration.oceanIds" disabled="true"
    
    49
    +                    list="fleets" template="mycheckboxlist"
    
    50
    +                    label='%{getText("t3.common.ocean")}'/>
    
    50 51
     
    
    51 52
           <%-- selected begin date --%>
    
    52 53
         <s:textfield key="configuration.beginDate" disabled="true"