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

Commits:

1 changed file:

Changes:

  • t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeRF2Action.java
    ... ... @@ -23,6 +23,7 @@ package fr.ird.t3.actions.data.level0;
    23 23
     import com.google.common.collect.ArrayListMultimap;
    
    24 24
     import com.google.common.collect.ListMultimap;
    
    25 25
     import com.google.common.collect.Multimap;
    
    26
    +import com.google.common.collect.TreeMultimap;
    
    26 27
     import fr.ird.t3.entities.data.CompleteTrip;
    
    27 28
     import fr.ird.t3.entities.data.RaisingFactor2;
    
    28 29
     import fr.ird.t3.entities.data.RaisingFactor2TopiaDao;
    
    ... ... @@ -53,7 +54,6 @@ import java.util.HashSet;
    53 54
     import java.util.Iterator;
    
    54 55
     import java.util.List;
    
    55 56
     import java.util.Set;
    
    56
    -import java.util.TreeSet;
    
    57 57
     
    
    58 58
     import static org.nuiton.i18n.I18n.l;
    
    59 59
     
    
    ... ... @@ -83,7 +83,7 @@ public class ComputeRF2Action extends AbstractLevel0Action<ComputeRF2Configurati
    83 83
         private VesselSimpleTypeTopiaDao vesselSimpleTypeDAO;
    
    84 84
         /** usable complete trips group by vessel */
    
    85 85
         private ListMultimap<Vessel, CompleteTrip> completeTripsByVessel;
    
    86
    -    private Set<String> tripStrDone;
    
    86
    +    private Multimap<String, String> tripDone;
    
    87 87
     
    
    88 88
         public ComputeRF2Action() {
    
    89 89
             super(Level0Step.COMPUTE_RF2);
    
    ... ... @@ -119,7 +119,7 @@ public class ComputeRF2Action extends AbstractLevel0Action<ComputeRF2Configurati
    119 119
                 // use all fleets
    
    120 120
                 fleets = countryDAO.findAll();
    
    121 121
             }
    
    122
    -        tripStrDone = new TreeSet<>();
    
    122
    +        tripDone = TreeMultimap.create();
    
    123 123
             List<Trip> tripList = getUsableTrips(landingHarbours, true);
    
    124 124
             setTrips(tripList);
    
    125 125
             completeTripsByVessel = ArrayListMultimap.create();
    
    ... ... @@ -253,15 +253,17 @@ public class ComputeRF2Action extends AbstractLevel0Action<ComputeRF2Configurati
    253 253
                 // must update it
    
    254 254
                 raisingFactor2DAO.update(raisingFactor);
    
    255 255
             }
    
    256
    -        if (rf2 != 1) {
    
    257
    -            nbTripsWithRF2 += trips.size();
    
    258
    -        }
    
    259 256
             // set rf2 to all trips
    
    260 257
             for (CompleteTrip trip : trips) {
    
    261 258
                 String tripStr = decorate(trip);
    
    262
    -            String message = l(locale, "t3.level0.computeRF1.resume.rf2.for.trip", tripStr, rf2);
    
    263
    -            log.info(message);
    
    264
    -            addInfoMessage(message);
    
    259
    +            if (canLog(tripStr,"nbTrips")) {
    
    260
    +                if (rf2 != 1) {
    
    261
    +                    nbTripsWithRF2++;
    
    262
    +                }
    
    263
    +                String message = l(locale, "t3.level0.computeRF1.resume.rf2.for.trip", tripStr, rf2);
    
    264
    +                log.info(message);
    
    265
    +                addInfoMessage(message);
    
    266
    +            }
    
    265 267
                 trip.applyRf2(rf2);
    
    266 268
                 markTripAsTreated(trip);
    
    267 269
             }
    
    ... ... @@ -283,12 +285,12 @@ public class ComputeRF2Action extends AbstractLevel0Action<ComputeRF2Configurati
    283 285
                         tripCatchWeight = trip.getElementaryCatchTotalWeightRf1(species);
    
    284 286
                     }
    
    285 287
                     totalCatchWeight += tripCatchWeight;
    
    286
    -                if (tripStrDone.add(tripStr)) {
    
    288
    +                if (canLog(tripStr,"compute")) {
    
    287 289
                         addInfoMessage(l(locale, "t3.level0.computeRF2.resume.rf1.for.trip", tripStr, tripCatchWeight, tripLandingWeight));
    
    288 290
                     }
    
    289 291
                 } else {
    
    290 292
                     // this trip does not have any landing catches for given species
    
    291
    -                if (tripStrDone.add(tripStr)) {
    
    293
    +                if (canLog(tripStr,"compute")) {
    
    292 294
                         addWarningMessage(l(locale, "t3.level0.computeRF2.resume.skip.for.trip", tripStr));
    
    293 295
                     }
    
    294 296
                 }
    
    ... ... @@ -308,4 +310,12 @@ public class ComputeRF2Action extends AbstractLevel0Action<ComputeRF2Configurati
    308 310
             }
    
    309 311
         }
    
    310 312
     
    
    313
    +    private boolean canLog(String key, String method) {
    
    314
    +        boolean exist = tripDone.containsEntry(key, method);
    
    315
    +        if (!exist) {
    
    316
    +            tripDone.put(key, method);
    
    317
    +        }
    
    318
    +        return !exist;
    
    319
    +    }
    
    320
    +
    
    311 321
     }