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

Commits:

7 changed files:

Changes:

  • t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeRF1Action.java
    ... ... @@ -32,13 +32,13 @@ import fr.ird.t3.entities.reference.Species;
    32 32
     import fr.ird.t3.entities.reference.Vessel;
    
    33 33
     import fr.ird.t3.services.DecoratorService;
    
    34 34
     import fr.ird.t3.services.ioc.InjectDAO;
    
    35
    -import java.util.Collection;
    
    36
    -import java.util.List;
    
    37
    -import java.util.Set;
    
    38 35
     import org.apache.commons.collections.CollectionUtils;
    
    39 36
     import org.apache.commons.logging.Log;
    
    40 37
     import org.apache.commons.logging.LogFactory;
    
    41 38
     
    
    39
    +import java.util.Collection;
    
    40
    +import java.util.List;
    
    41
    +import java.util.Set;
    
    42 42
     
    
    43 43
     import static org.nuiton.i18n.I18n.l;
    
    44 44
     
    
    ... ... @@ -347,14 +347,12 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati
    347 347
     
    
    348 348
                         String warnMessage =
    
    349 349
                                 l(locale, "t3.level0.computeRF1.warning.too.low.rf1",
    
    350
    -                               decorate(completeTrip.getDepartureTrip()),
    
    351
    -                               decorate(completeTrip.getLandingTrip()),
    
    352
    -                               rf1,
    
    353
    -                               minimumRate
    
    354
    -                            );
    
    355
    -
    
    350
    +                                    completeTrip.getDepartureTrip().getVesselLabel(),
    
    351
    +                                    DecoratorService.formatDate(completeTrip.getDepartureTrip().getDepartureDate()),
    
    352
    +                                    DecoratorService.formatDate(completeTrip.getLandingTrip().getLandingDate()),
    
    353
    +                                    rf1,
    
    354
    +                                    minimumRate);
    
    356 355
                         addWarningMessage(warnMessage);
    
    357
    -
    
    358 356
                         nbCompleteAcceptedTripsWithBadRF1++;
    
    359 357
                     }
    
    360 358
     
    
    ... ... @@ -362,11 +360,11 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati
    362 360
     
    
    363 361
                         String warnMessage =
    
    364 362
                                 l(locale, "t3.level0.computeRF1.warning.too.high.rf1",
    
    365
    -                               decorate(completeTrip.getDepartureTrip()),
    
    366
    -                               decorate(completeTrip.getLandingTrip()),
    
    367
    -                               rf1,
    
    368
    -                               maximumRate
    
    369
    -                            );
    
    363
    +                                    completeTrip.getDepartureTrip().getVesselLabel(),
    
    364
    +                                    DecoratorService.formatDate(completeTrip.getDepartureTrip().getDepartureDate()),
    
    365
    +                                    DecoratorService.formatDate(completeTrip.getLandingTrip().getLandingDate()),
    
    366
    +                                    rf1,
    
    367
    +                                    maximumRate);
    
    370 368
                         addWarningMessage(warnMessage);
    
    371 369
                         nbCompleteAcceptedTripsWithBadRF1++;
    
    372 370
                     }
    

  • t3-actions/src/main/java/fr/ird/t3/actions/data/level1/AbstractLevel1Action.java
    ... ... @@ -33,7 +33,11 @@ import fr.ird.t3.services.DecoratorService;
    33 33
     import fr.ird.t3.services.ioc.InjectDAO;
    
    34 34
     import fr.ird.t3.services.ioc.InjectEntityById;
    
    35 35
     import java.util.Collection;
    
    36
    +import java.util.Comparator;
    
    37
    +import java.util.List;
    
    36 38
     import java.util.Set;
    
    39
    +import java.util.stream.Collectors;
    
    40
    +
    
    37 41
     import org.apache.commons.collections.CollectionUtils;
    
    38 42
     import org.nuiton.topia.persistence.TopiaException;
    
    39 43
     
    
    ... ... @@ -48,6 +52,10 @@ import static org.nuiton.i18n.I18n.l;
    48 52
      */
    
    49 53
     public abstract class AbstractLevel1Action extends T3Action<Level1Configuration> {
    
    50 54
     
    
    55
    +    private static final Comparator<Trip> TRIP_COMPARATOR = Comparator
    
    56
    +            .<Trip, Integer>comparing(t -> t.getVessel().getCode())
    
    57
    +            .thenComparing(Comparator.comparing(Trip::getLandingDate));
    
    58
    +
    
    51 59
         protected final Level1Step step;
    
    52 60
     
    
    53 61
         protected final Set<Level1Step> higherSteps;
    
    ... ... @@ -81,6 +89,10 @@ public abstract class AbstractLevel1Action extends T3Action<Level1Configuration>
    81 89
             return samplesByTrip.keySet();
    
    82 90
         }
    
    83 91
     
    
    92
    +    public List<Trip> getOrderedTrips() {
    
    93
    +        return samplesByTrip.keySet().stream().sorted(TRIP_COMPARATOR).collect(Collectors.toList());
    
    94
    +    }
    
    95
    +
    
    84 96
         public Collection<Sample> getSamples(Trip trip) {
    
    85 97
             return getSamplesByTrip().get(trip);
    
    86 98
         }
    

  • t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level1/RedistributeSampleNumberToSetAction.ftl
    ... ... @@ -49,7 +49,7 @@ Nombre de marées traitées : ${action.nbTripsTreated}
    49 49
     Nombre d'échantillons traités     : ${action.nbSamplesTreated}
    
    50 50
     Nombre d'échantillons non traités : ${action.nbSamplesNotTreated}
    
    51 51
     
    
    52
    -<#list action.trips as trip>
    
    52
    +<#list action.orderedTrips as trip>
    
    53 53
     Marée ${tripDecorator.toString(trip)} :
    
    54 54
     <#assign samples = action.getSamples(trip)/>
    
    55 55
     <#list samples as sample>
    

  • t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level1/RedistributeSampleNumberToSetAction_en.ftl
    ... ... @@ -49,7 +49,7 @@ Number of treated trips: ${action.nbTripsTreated}
    49 49
     Number of treated samples:   ${action.nbSamplesTreated}
    
    50 50
     Number of untreated samples: ${action.nbSamplesNotTreated}
    
    51 51
     
    
    52
    -<#list action.trips as trip>
    
    52
    +<#list action.orderedTrips as trip>
    
    53 53
     Trip ${tripDecorator.toString(trip)} :
    
    54 54
     <#assign samples = action.getSamples(trip)/>
    
    55 55
     <#list samples as sample>
    

  • t3-actions/src/main/resources/i18n/t3-actions_en_GB.properties
    ... ... @@ -33,8 +33,8 @@ t3.level0.computeRF1.warning.no.catches.but.some.landings=Trip %s has no catches
    33 33
     t3.level0.computeRF1.warning.no.landings.but.some.catches=Trip %s has no landing but some catches (%s), this trip will not be use to compute rf1.
    
    34 34
     t3.level0.computeRF1.warning.no.logbook=No log book for trip %s, use a null rf1 value
    
    35 35
     t3.level0.computeRF1.warning.no.species.usable.for.country=Could not find usable species fro Raising Factor 1 computation from country %s
    
    36
    -t3.level0.computeRF1.warning.too.high.rf1=For complete trip from %s to %s computed rf1 %s is too high (higher than %s)
    
    37
    -t3.level0.computeRF1.warning.too.low.rf1=For complete trip from %s to %s computed rf1 is too small (less than %s)
    
    36
    +t3.level0.computeRF1.warning.too.high.rf1=For complete trip %s from %s to %s computed rf1 %s is too high (higher than %s)
    
    37
    +t3.level0.computeRF1.warning.too.low.rf1=For complete trip %s from %s to %s computed rf1 is too small (less than %s)
    
    38 38
     t3.level0.computeRF1.warning.trip.is.not.complete=Trip %s is not compelte, can not compute any rf1 for it
    
    39 39
     t3.level0.computeRF2.computed.rf2.for.stratum=Computed rf2 for stratum \: %s
    
    40 40
     t3.level0.computeRF2.nbTrips.for.stratum=%s trip(s) for Stratum (%s) [%s/%s/%s/%s]
    

  • t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties
    ... ... @@ -33,8 +33,8 @@ t3.level0.computeRF1.warning.no.catches.but.some.landings=La marée %s n'a pas d
    33 33
     t3.level0.computeRF1.warning.no.landings.but.some.catches=La marée %s n'a pas de lots commerciaux mais des captures (%s), marée non utilisée dans le calcul du rf1.
    
    34 34
     t3.level0.computeRF1.warning.no.logbook=Pas de livre de bord pour la marée %s, utilisation de la valeur null pour le rf1
    
    35 35
     t3.level0.computeRF1.warning.no.species.usable.for.country=Aucune espèces utilisable dans le calcul du rf1 pour le pays %s
    
    36
    -t3.level0.computeRF1.warning.too.high.rf1=Pour la marée complète de %s à %s le rf1 calculé %s est trop grand (supérieur à %s)
    
    37
    -t3.level0.computeRF1.warning.too.low.rf1=Pour la marée complète de %s à %s le rf1 calculé %s est trop petit (inférieur à %s)
    
    36
    +t3.level0.computeRF1.warning.too.high.rf1=Pour la marée complète %s de %s à %s le rf1 calculé %s est trop grand (supérieur à %s)
    
    37
    +t3.level0.computeRF1.warning.too.low.rf1=Pour la marée complète %s de %s à %s le rf1 calculé %s est trop petit (inférieur à %s)
    
    38 38
     t3.level0.computeRF1.warning.trip.is.not.complete=La marée %s n'est pas complète, calcul du rf1 impossible
    
    39 39
     t3.level0.computeRF2.computed.rf2.for.stratum=Valeur du rf2 calculé pour la strate \: %s
    
    40 40
     t3.level0.computeRF2.nbTrips.for.stratum=%s marée(s) pour la Strate (%s) [%s/%s/%s/%s]
    

  • t3-domain/src/main/java/fr/ird/t3/services/DecoratorService.java
    ... ... @@ -48,10 +48,6 @@ import fr.ird.t3.entities.reference.zone.ZoneStratumAwareMeta;
    48 48
     import fr.ird.t3.entities.reference.zone.ZoneVersion;
    
    49 49
     import fr.ird.t3.entities.user.UserOutputDatabase;
    
    50 50
     import fr.ird.t3.entities.user.UserT3Database;
    
    51
    -import java.util.Collection;
    
    52
    -import java.util.List;
    
    53
    -import java.util.Locale;
    
    54
    -import java.util.Map;
    
    55 51
     import org.apache.commons.collections.CollectionUtils;
    
    56 52
     import org.apache.commons.jxpath.JXPathContext;
    
    57 53
     import org.nuiton.decorator.Decorator;
    
    ... ... @@ -60,6 +56,12 @@ import org.nuiton.decorator.DecoratorUtil;
    60 56
     import org.nuiton.decorator.JXPathDecorator;
    
    61 57
     import org.nuiton.topia.persistence.TopiaEntity;
    
    62 58
     
    
    59
    +import java.text.SimpleDateFormat;
    
    60
    +import java.util.Collection;
    
    61
    +import java.util.Date;
    
    62
    +import java.util.List;
    
    63
    +import java.util.Locale;
    
    64
    +import java.util.Map;
    
    63 65
     
    
    64 66
     import static org.nuiton.i18n.I18n.l;
    
    65 67
     
    
    ... ... @@ -75,6 +77,12 @@ public class DecoratorService extends T3ServiceSupport implements T3ServiceSingl
    75 77
     
    
    76 78
         private final DecoratorMulti18nProvider decoratorProvider;
    
    77 79
     
    
    80
    +    private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd/MM/yyyy");
    
    81
    +
    
    82
    +    public static String formatDate(Date date) {
    
    83
    +        return DATE_FORMAT.format(date);
    
    84
    +    }
    
    85
    +
    
    78 86
         public DecoratorService() {
    
    79 87
             decoratorProvider = new T3DecoratorProvider();
    
    80 88
         }