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

Commits:

16 changed files:

Changes:

  • dto/src/main/java/fr/ird/observe/dto/decoration/DecoratorService.java
    ... ... @@ -23,6 +23,7 @@ package fr.ird.observe.dto.decoration;
    23 23
      */
    
    24 24
     
    
    25 25
     import fr.ird.observe.dto.DtoToReference;
    
    26
    +import fr.ird.observe.dto.reference.DataDtoReference;
    
    26 27
     import fr.ird.observe.dto.reference.ReferentialDtoReference;
    
    27 28
     import fr.ird.observe.dto.referential.ReferentialDto;
    
    28 29
     import fr.ird.observe.spi.DtoModelHelper;
    
    ... ... @@ -67,4 +68,17 @@ public class DecoratorService extends DecoratorServiceSupport<DecoratorServiceIn
    67 68
         protected void init(DecoratorServiceInitializer initializer) {
    
    68 69
             ObserveGlobalModelInitializer.run(initializer);
    
    69 70
         }
    
    71
    +
    
    72
    +    public String toString(Object o) {
    
    73
    +        if (o==null) {
    
    74
    +            return null;
    
    75
    +        }
    
    76
    +        if (o instanceof ReferentialDtoReference) {
    
    77
    +            return getReferentialReferenceDecorator(((ReferentialDtoReference<?,?>) o).getReferenceType()).toString(o);
    
    78
    +        }
    
    79
    +        if (o instanceof DataDtoReference) {
    
    80
    +            return getDataReferenceDecorator(((DataDtoReference<?,?>) o).getReferenceType()).toString(o);
    
    81
    +        }
    
    82
    +        return getDecoratorByType(o.getClass()).toString(o);
    
    83
    +    }
    
    70 84
     }

  • observe-i18n/src/main/i18n/translations/observe_en_GB.properties
    ... ... @@ -2293,6 +2293,10 @@ observe.data.ps.observation.TransmittingBuoy.types=Transmitting buoys
    2293 2293
     observe.entity.message.creating=Creating object '%1$s'.
    
    2294 2294
     observe.entity.message.reading=Object '%1$s' is not open, no modification allowed.
    
    2295 2295
     observe.entity.message.updating=Updating object '%1$s'.
    
    2296
    +observe.error.DuplicateLengthLengthParameterException=Found multiple length length relation for species\: %s, ocean\: %s, sex\: %s, date\: %s \:\n * %s
    
    2297
    +observe.error.DuplicateLengthWeightParameterException=Found multiple length weight paramters for species\: %s, ocean\: %s, sex\: %s, date\: %s \:\n * %s
    
    2298
    +observe.error.LengthLengthParameterNotFoundException=No length length relation found for species\: %s, ocean\: %s, sex\: %s, date\: %s \: %s
    
    2299
    +observe.error.LengthWeightParameterNotFoundException=No length weight relation found for species\: %s, ocean\: %s, sex\: %s, date\: %s \: %s
    
    2296 2300
     observe.error.can.not.create.directory=Can't create directory %&$s\!
    
    2297 2301
     observe.error.storage.could.not.backup.unsane.local.db=Can not save an borken database
    
    2298 2302
     observe.error.storage.could.not.load.local.db=Could not open local database for reason\: %s
    

  • observe-i18n/src/main/i18n/translations/observe_es_ES.properties
    ... ... @@ -2293,6 +2293,10 @@ observe.data.ps.observation.TransmittingBuoy.types=Balizas leidas
    2293 2293
     observe.entity.message.creating=Se está crear el objeto actual '%1$s'.
    
    2294 2294
     observe.entity.message.reading=Object '%1$s' is not open, no modification allowed.
    
    2295 2295
     observe.entity.message.updating=Se está modificando el objeto actual '%1$s'.
    
    2296
    +observe.error.DuplicateLengthLengthParameterException=Found multiple length length relation for species\: %s, ocean\: %s, sex\: %s, date\: %s \:\n * %s \#TODO
    
    2297
    +observe.error.DuplicateLengthWeightParameterException=Found multiple length weight relation for species\: %s, ocean\: %s, sex\: %s, date\: %s \:\n * %s \#TODO
    
    2298
    +observe.error.LengthLengthParameterNotFoundException=No length length relation found for species\: %s, ocean\: %s, sex\: %s, date\: %s \: %s \#TODO
    
    2299
    +observe.error.LengthWeightParameterNotFoundException=No length weight relation found for species\: %s, ocean\: %s, sex\: %s, date\: %s \: %s \#TODO
    
    2296 2300
     observe.error.can.not.create.directory=¡Imposible crear el directorio %1$s\!
    
    2297 2301
     observe.error.storage.could.not.backup.unsane.local.db=Impossible grabar una base dañada
    
    2298 2302
     observe.error.storage.could.not.load.local.db=Impossible grabar la base local por la razón siguiente \: %s
    

  • observe-i18n/src/main/i18n/translations/observe_fr_FR.properties
    ... ... @@ -2293,6 +2293,10 @@ observe.data.ps.observation.TransmittingBuoy.types=Balises lues
    2293 2293
     observe.entity.message.creating=L'objet '%1$s' est en cours de création.
    
    2294 2294
     observe.entity.message.reading=L'objet '%1$s' n'est pas ouvert, aucune modification possible.
    
    2295 2295
     observe.entity.message.updating=L'objet '%1$s' est en cours de modification.
    
    2296
    +observe.error.DuplicateLengthLengthParameterException=Plusieurs relations taille-taille ont été trouvées pour l'espèce\: %s, l'ocean\: %s, le sexe\: %s et la date\: %s \:\n * %s
    
    2297
    +observe.error.DuplicateLengthWeightParameterException=Plusieurs relations taille-poids ont été trouvées pour l'espèce\: %s, l'ocean\: %s, le sexe\: %s et la date\: %s \:\n * %s
    
    2298
    +observe.error.LengthLengthParameterNotFoundException=Aucune relation taille-taille trouvée pour l'espèce\: %s, l'ocean\: %s, le sexe\: %s et la date\: %s
    
    2299
    +observe.error.LengthWeightParameterNotFoundException=Aucune relation taille-poids trouvée pour l'espèce\: %s, l'ocean\: %s, le sexe\: %s et la date\: %s
    
    2296 2300
     observe.error.can.not.create.directory=Création du répertoire %1$s impossible\!
    
    2297 2301
     observe.error.storage.could.not.backup.unsane.local.db=Impossible d'enregistrer une base non endommagée
    
    2298 2302
     observe.error.storage.could.not.load.local.db=Impossible d'ouvrir la base locale pour la raison suivante \: %s
    

  • persistence/.mvn/i18n/parse-java

  • persistence/pom.xml
    ... ... @@ -97,7 +97,10 @@
    97 97
           <artifactId>nuiton-csv</artifactId>
    
    98 98
           <scope>test</scope>
    
    99 99
         </dependency>
    
    100
    -
    
    100
    +    <dependency>
    
    101
    +      <groupId>io.ultreia.java4all.i18n</groupId>
    
    102
    +      <artifactId>i18n-runtime</artifactId>
    
    103
    +    </dependency>
    
    101 104
         <dependency>
    
    102 105
           <groupId>io.ultreia.java4all.http</groupId>
    
    103 106
           <artifactId>http-api</artifactId>
    

  • persistence/src/main/i18n/getters/java.getter
    1
    +observe.error.DuplicateLengthWeightParameterException
    
    2
    +observe.error.LengthLengthParameterNotFoundException
    
    3
    +observe.error.LengthWeightParameterNotFoundException

  • persistence/src/main/java/fr/ird/observe/entities/referential/DuplicateLengthLengthParameterException.java
    ... ... @@ -22,13 +22,21 @@ package fr.ird.observe.entities.referential;
    22 22
      * #L%
    
    23 23
      */
    
    24 24
     
    
    25
    +import fr.ird.observe.dto.decoration.DecoratorService;
    
    26
    +import fr.ird.observe.dto.referential.ReferentialLocale;
    
    27
    +import fr.ird.observe.dto.referential.common.LengthLengthParameterDto;
    
    28
    +import fr.ird.observe.dto.referential.common.LengthLengthParameterReference;
    
    25 29
     import fr.ird.observe.entities.referential.common.LengthLengthParameter;
    
    26 30
     import fr.ird.observe.entities.referential.common.Ocean;
    
    27 31
     import fr.ird.observe.entities.referential.common.Sex;
    
    28 32
     import fr.ird.observe.entities.referential.common.Species;
    
    33
    +import fr.ird.observe.spi.DbModelHelper;
    
    29 34
     
    
    30 35
     import java.util.Date;
    
    31 36
     import java.util.List;
    
    37
    +import java.util.stream.Collectors;
    
    38
    +
    
    39
    +import static io.ultreia.java4all.i18n.I18n.t;
    
    32 40
     
    
    33 41
     /**
    
    34 42
      * Created on 28/08/15.
    
    ... ... @@ -49,7 +57,8 @@ public class DuplicateLengthLengthParameterException extends RuntimeException {
    49 57
     
    
    50 58
         protected final List<LengthLengthParameter> foundLengthLengthParameters;
    
    51 59
     
    
    52
    -    public DuplicateLengthLengthParameterException(Species species, Ocean ocean, Sex sex, Date date, List<LengthLengthParameter> foundLengthLengthParameters) {
    
    60
    +    public DuplicateLengthLengthParameterException(DecoratorService decoratorService, Species species, Ocean ocean, Sex sex, Date date, List<LengthLengthParameter> foundLengthLengthParameters) {
    
    61
    +        super(buildMessage(decoratorService, species, ocean, sex, date, foundLengthLengthParameters));
    
    53 62
             this.species = species;
    
    54 63
             this.ocean = ocean;
    
    55 64
             this.sex = sex;
    
    ... ... @@ -57,6 +66,18 @@ public class DuplicateLengthLengthParameterException extends RuntimeException {
    57 66
             this.foundLengthLengthParameters = foundLengthLengthParameters;
    
    58 67
         }
    
    59 68
     
    
    69
    +    private static String buildMessage(DecoratorService decoratorService, Species species, Ocean ocean, Sex sex, Date date, List<LengthLengthParameter> foundLengthLengthParameters) {
    
    70
    +        ReferentialLocale referentialLocale = decoratorService.getReferentialLocale();
    
    71
    +        return t("observe.error.DuplicateLengthWeightParameterException",
    
    72
    +                 LengthLengthParameterNotFoundException.toString(decoratorService, species),
    
    73
    +                 LengthLengthParameterNotFoundException.toString(decoratorService, ocean),
    
    74
    +                 LengthLengthParameterNotFoundException.toString(decoratorService, sex),
    
    75
    +                 date,
    
    76
    +                 foundLengthLengthParameters.stream().map(e -> e.toReference(referentialLocale)).map(decoratorService::toString).collect(Collectors.joining("\n * "))
    
    77
    +        );
    
    78
    +    }
    
    79
    +
    
    80
    +
    
    60 81
         public Species getSpecies() {
    
    61 82
             return species;
    
    62 83
         }
    

  • persistence/src/main/java/fr/ird/observe/entities/referential/DuplicateLengthWeightParameterException.java
    ... ... @@ -22,13 +22,21 @@ package fr.ird.observe.entities.referential;
    22 22
      * #L%
    
    23 23
      */
    
    24 24
     
    
    25
    +import fr.ird.observe.dto.decoration.DecoratorService;
    
    26
    +import fr.ird.observe.dto.referential.ReferentialLocale;
    
    27
    +import fr.ird.observe.dto.referential.common.LengthWeightParameterDto;
    
    28
    +import fr.ird.observe.dto.referential.common.LengthWeightParameterReference;
    
    25 29
     import fr.ird.observe.entities.referential.common.LengthWeightParameter;
    
    26 30
     import fr.ird.observe.entities.referential.common.Ocean;
    
    27 31
     import fr.ird.observe.entities.referential.common.Sex;
    
    28 32
     import fr.ird.observe.entities.referential.common.Species;
    
    33
    +import fr.ird.observe.spi.DbModelHelper;
    
    29 34
     
    
    30 35
     import java.util.Date;
    
    31 36
     import java.util.List;
    
    37
    +import java.util.stream.Collectors;
    
    38
    +
    
    39
    +import static io.ultreia.java4all.i18n.I18n.t;
    
    32 40
     
    
    33 41
     /**
    
    34 42
      * Created on 28/08/15.
    
    ... ... @@ -49,7 +57,8 @@ public class DuplicateLengthWeightParameterException extends RuntimeException {
    49 57
     
    
    50 58
         protected final List<LengthWeightParameter> foundLengthWeightParameters;
    
    51 59
     
    
    52
    -    public DuplicateLengthWeightParameterException(Species species, Ocean ocean, Sex sex, Date date, List<LengthWeightParameter> foundLengthWeightParameters) {
    
    60
    +    public DuplicateLengthWeightParameterException(DecoratorService decoratorService, Species species, Ocean ocean, Sex sex, Date date, List<LengthWeightParameter> foundLengthWeightParameters) {
    
    61
    +        super(buildMessage(decoratorService, species, ocean, sex, date, foundLengthWeightParameters));
    
    53 62
             this.species = species;
    
    54 63
             this.ocean = ocean;
    
    55 64
             this.sex = sex;
    
    ... ... @@ -57,6 +66,17 @@ public class DuplicateLengthWeightParameterException extends RuntimeException {
    57 66
             this.foundLengthWeightParameters = foundLengthWeightParameters;
    
    58 67
         }
    
    59 68
     
    
    69
    +    private static String buildMessage(DecoratorService decoratorService, Species species, Ocean ocean, Sex sex, Date date, List<LengthWeightParameter> foundLengthWeightParameters) {
    
    70
    +        ReferentialLocale referentialLocale = decoratorService.getReferentialLocale();
    
    71
    +        return t("observe.error.DuplicateLengthWeightParameterException",
    
    72
    +                 LengthLengthParameterNotFoundException.toString(decoratorService, species),
    
    73
    +                 LengthLengthParameterNotFoundException.toString(decoratorService, ocean),
    
    74
    +                 LengthLengthParameterNotFoundException.toString(decoratorService, sex),
    
    75
    +                 date,
    
    76
    +                 foundLengthWeightParameters.stream().map(e -> e.toReference(referentialLocale)).map(decoratorService::toString).collect(Collectors.joining("\n * "))
    
    77
    +        );
    
    78
    +    }
    
    79
    +
    
    60 80
         public Species getSpecies() {
    
    61 81
             return species;
    
    62 82
         }
    

  • persistence/src/main/java/fr/ird/observe/entities/referential/LengthLengthParameterNotFoundException.java
    ... ... @@ -22,12 +22,16 @@ package fr.ird.observe.entities.referential;
    22 22
      * #L%
    
    23 23
      */
    
    24 24
     
    
    25
    +import fr.ird.observe.dto.decoration.DecoratorService;
    
    25 26
     import fr.ird.observe.entities.referential.common.Ocean;
    
    26 27
     import fr.ird.observe.entities.referential.common.Sex;
    
    27 28
     import fr.ird.observe.entities.referential.common.Species;
    
    29
    +import fr.ird.observe.spi.DbModelHelper;
    
    28 30
     
    
    29 31
     import java.util.Date;
    
    30 32
     
    
    33
    +import static io.ultreia.java4all.i18n.I18n.t;
    
    34
    +
    
    31 35
     /**
    
    32 36
      * Created on 29/08/15.
    
    33 37
      *
    
    ... ... @@ -45,13 +49,23 @@ public class LengthLengthParameterNotFoundException extends RuntimeException {
    45 49
     
    
    46 50
         protected final Date date;
    
    47 51
     
    
    48
    -    public LengthLengthParameterNotFoundException(Species species, Ocean ocean, Sex sex, Date date) {
    
    52
    +    public LengthLengthParameterNotFoundException(DecoratorService decoratorService, Species species, Ocean ocean, Sex sex, Date date) {
    
    53
    +        super(buildMessage(decoratorService, species, ocean, sex, date));
    
    49 54
             this.species = species;
    
    50 55
             this.ocean = ocean;
    
    51 56
             this.sex = sex;
    
    52 57
             this.date = date;
    
    53 58
         }
    
    54 59
     
    
    60
    +    private static String buildMessage(DecoratorService decoratorService, Species species, Ocean ocean, Sex sex, Date date) {
    
    61
    +
    
    62
    +        return t("observe.error.LengthLengthParameterNotFoundException",
    
    63
    +                 LengthLengthParameterNotFoundException.toString(decoratorService, species),
    
    64
    +                 LengthLengthParameterNotFoundException.toString(decoratorService, ocean),
    
    65
    +                 LengthLengthParameterNotFoundException.toString(decoratorService, sex),
    
    66
    +                 date);
    
    67
    +    }
    
    68
    +
    
    55 69
         public Species getSpecies() {
    
    56 70
             return species;
    
    57 71
         }
    
    ... ... @@ -68,4 +82,11 @@ public class LengthLengthParameterNotFoundException extends RuntimeException {
    68 82
             return date;
    
    69 83
         }
    
    70 84
     
    
    85
    +
    
    86
    +    static <E extends ReferentialEntity<?, ?>> String toString(DecoratorService decoratorService, E entity) {
    
    87
    +        if (entity == null) {
    
    88
    +            return null;
    
    89
    +        }
    
    90
    +        return decoratorService.toString(entity.toReference(decoratorService.getReferentialLocale()));
    
    91
    +    }
    
    71 92
     }

  • persistence/src/main/java/fr/ird/observe/entities/referential/LengthWeightParameterNotFoundException.java
    ... ... @@ -22,12 +22,16 @@ package fr.ird.observe.entities.referential;
    22 22
      * #L%
    
    23 23
      */
    
    24 24
     
    
    25
    +import fr.ird.observe.dto.decoration.DecoratorService;
    
    26
    +import fr.ird.observe.entities.referential.LengthLengthParameterNotFoundException;
    
    25 27
     import fr.ird.observe.entities.referential.common.Ocean;
    
    26 28
     import fr.ird.observe.entities.referential.common.Sex;
    
    27 29
     import fr.ird.observe.entities.referential.common.Species;
    
    28 30
     
    
    29 31
     import java.util.Date;
    
    30 32
     
    
    33
    +import static io.ultreia.java4all.i18n.I18n.t;
    
    34
    +
    
    31 35
     /**
    
    32 36
      * Created on 29/08/15.
    
    33 37
      *
    
    ... ... @@ -45,13 +49,23 @@ public class LengthWeightParameterNotFoundException extends RuntimeException {
    45 49
     
    
    46 50
         protected final Date date;
    
    47 51
     
    
    48
    -    public LengthWeightParameterNotFoundException(Species species, Ocean ocean, Sex sex, Date date) {
    
    52
    +    public LengthWeightParameterNotFoundException(DecoratorService decoratorService, Species species, Ocean ocean, Sex sex, Date date) {
    
    53
    +        super(buildMessage(decoratorService, species, ocean, sex, date));
    
    49 54
             this.species = species;
    
    50 55
             this.ocean = ocean;
    
    51 56
             this.sex = sex;
    
    52 57
             this.date = date;
    
    53 58
         }
    
    54 59
     
    
    60
    +    private static String buildMessage(DecoratorService decoratorService, Species species, Ocean ocean, Sex sex, Date date) {
    
    61
    +
    
    62
    +        return t("observe.error.LengthWeightParameterNotFoundException",
    
    63
    +                 LengthLengthParameterNotFoundException.toString(decoratorService, species),
    
    64
    +                 LengthLengthParameterNotFoundException.toString(decoratorService, ocean),
    
    65
    +                 LengthLengthParameterNotFoundException.toString(decoratorService, sex),
    
    66
    +                 date);
    
    67
    +    }
    
    68
    +
    
    55 69
         public Species getSpecies() {
    
    56 70
             return species;
    
    57 71
         }
    

  • persistence/src/main/java/fr/ird/observe/entities/referential/common/LengthLengthParameters.java
    ... ... @@ -22,6 +22,7 @@ package fr.ird.observe.entities.referential.common;
    22 22
      * #L%
    
    23 23
      */
    
    24 24
     
    
    25
    +import fr.ird.observe.dto.decoration.DecoratorService;
    
    25 26
     import fr.ird.observe.entities.referential.DuplicateLengthLengthParameterException;
    
    26 27
     import fr.ird.observe.entities.referential.LengthLengthParameterNotFoundException;
    
    27 28
     import fr.ird.observe.entities.ObserveTopiaDaoSupplier;
    
    ... ... @@ -50,6 +51,7 @@ public class LengthLengthParameters {
    50 51
          * <p>
    
    51 52
          * Si non trouvé sur le sexe (et que le sexe n'est pas indéterminé) , alors on recherche avec le sexe indéterminé (sexe=0).
    
    52 53
          *
    
    54
    +     * @param decoratorService      le service de décoration
    
    53 55
          * @param daoSupplier           la transaction en cours d'utilisation
    
    54 56
          * @param species               l'espèce sur lequel on recherche le paramétrage
    
    55 57
          * @param ocean                 l'ocean recherché (peut être null)
    
    ... ... @@ -60,7 +62,8 @@ public class LengthLengthParameters {
    60 62
          * @return le paramétrage adéquate
    
    61 63
          * @since 1.5
    
    62 64
          */
    
    63
    -    public static Optional<LengthLengthParameter> findLengthLengthParameter(ObserveTopiaDaoSupplier daoSupplier,
    
    65
    +    public static Optional<LengthLengthParameter> findLengthLengthParameter(DecoratorService decoratorService,
    
    66
    +                                                                            ObserveTopiaDaoSupplier daoSupplier,
    
    64 67
                                                                                 Species species,
    
    65 68
                                                                                 Ocean ocean,
    
    66 69
                                                                                 Sex sex,
    
    ... ... @@ -85,7 +88,7 @@ public class LengthLengthParameters {
    85 88
             }
    
    86 89
     
    
    87 90
             if (CollectionUtils.isEmpty(list)) {
    
    88
    -            throw new LengthLengthParameterNotFoundException(species, ocean, sex, date);
    
    91
    +            throw new LengthLengthParameterNotFoundException(decoratorService, species, ocean, sex, date);
    
    89 92
             }
    
    90 93
     
    
    91 94
     //        if (inputSizeMeasureType != null) {
    
    ... ... @@ -116,192 +119,14 @@ public class LengthLengthParameters {
    116 119
             // au final il ne devrait en rester qu'un
    
    117 120
     
    
    118 121
             if (list.size() > 1) {
    
    119
    -            throw new DuplicateLengthLengthParameterException(species, ocean, sex, date, list);
    
    122
    +            throw new DuplicateLengthLengthParameterException(decoratorService, species, ocean, sex, date, list);
    
    120 123
             }
    
    121 124
     
    
    122 125
             return Optional.of(list.get(0));
    
    123 126
     
    
    124 127
         }
    
    125
    -//
    
    126
    -//    /**
    
    127
    -//     * Recherche de la liste des {@link LengthLengthParameter} à partir des paramètres donnés.
    
    128
    -//     * <p>
    
    129
    -//     * La recherche peut ne peut être aussi exacte que les paramètres donnés :
    
    130
    -//     * <p>
    
    131
    -//     * Dans le cas d'une espèce faune, si non trouvé alors on recherche sur son
    
    132
    -//     * speciesGroup d'espèce.
    
    133
    -//     * <p>
    
    134
    -//     * Si non trouvé pour l'océan donné (et que celui-ci est non null), alors on
    
    135
    -//     * recherche avec un ocean vide.
    
    136
    -//     *
    
    137
    -//     * @param daoSupplier la transaction en cours d'utilisation
    
    138
    -//     * @param species     l'espèce sur lequel on recherche le paramétrage
    
    139
    -//     * @param ocean       l'ocean recherché (peut être null)
    
    140
    -//     * @param sex         le sexe recherché (on essayera sans sexe (sexe.code=0) si non trouvé)
    
    141
    -//     * @param date        le jour recherché
    
    142
    -//     * @return le paramétrage adéquate
    
    143
    -//     * @since 1.5
    
    144
    -//     */
    
    145
    -//    public static List<LengthLengthParameter> findLengthLengthParameter0(ObserveTopiaDaoSupplier daoSupplier,
    
    146
    -//                                                                         Species species,
    
    147
    -//                                                                         Ocean ocean,
    
    148
    -//                                                                         Sex sex,
    
    149
    -//                                                                         Date date) {
    
    150
    -//
    
    151
    -//        Objects.requireNonNull(daoSupplier, "daoSupplier parameter can't be null");
    
    152
    -//        Objects.requireNonNull(species, "species parameter can't be null");
    
    153
    -//        Objects.requireNonNull(sex, "sex parameter can't be null");
    
    154
    -//
    
    155
    -//        List<LengthLengthParameter> list = findBySpecies(daoSupplier, species);
    
    156
    -//
    
    157
    -//        if (CollectionUtils.isEmpty(list)) {
    
    158
    -//
    
    159
    -//            // aucun parametrage pour le type donne
    
    160
    -//            return null;
    
    161
    -//        }
    
    162
    -//
    
    163
    -//        // filtrage par ocean
    
    164
    -//        List<LengthLengthParameter> filterByOcean = filterByOcean(list, ocean);
    
    165
    -//
    
    166
    -//        if (CollectionUtils.isEmpty(filterByOcean) && ocean != null) {
    
    167
    -//
    
    168
    -//            // filtre par ocean null
    
    169
    -//            filterByOcean = filterByOcean(list, null);
    
    170
    -//        }
    
    171
    -//        list = filterByOcean;
    
    172
    -//
    
    173
    -//        if (CollectionUtils.isEmpty(list)) {
    
    174
    -//
    
    175
    -//            // pas d'ocean adequate
    
    176
    -//            return null;
    
    177
    -//        }
    
    178
    -//
    
    179
    -//        // filtrage par sexe
    
    180
    -//        list = filterBySexe(list, sex);
    
    181
    -//
    
    182
    -//        if (CollectionUtils.isEmpty(list)) {
    
    183
    -//
    
    184
    -//            // pas de sexe adequate
    
    185
    -//            return null;
    
    186
    -//        }
    
    187
    -//
    
    188
    -//        // filtrage par startDate de validite
    
    189
    -//        list = filterByDateDebutValidite(list, date);
    
    190
    -//
    
    191
    -//        if (CollectionUtils.isEmpty(list)) {
    
    192
    -//
    
    193
    -//            // pas de date de debut adequate
    
    194
    -//            return null;
    
    195
    -//        }
    
    196
    -//
    
    197
    -//        // filtrage par endDate de validite
    
    198
    -//        list = filterByDateFinValidite(list, date);
    
    199
    -//
    
    200
    -//        if (CollectionUtils.isEmpty(list)) {
    
    201
    -//
    
    202
    -//            // pas de date de fin adequate
    
    203
    -//            return null;
    
    204
    -//        }
    
    205
    -//
    
    206
    -//        return list;
    
    207
    -//
    
    208
    -//    }
    
    209 128
     
    
    210 129
         private static Sex getUnknownSex(ObserveTopiaDaoSupplier daoSupplier) {
    
    211 130
             return daoSupplier.getCommonSexDao().forCodeEquals("0").findUnique();
    
    212 131
         }
    
    213
    -
    
    214
    -//    public static List<LengthLengthParameter> findBySpecies(ObserveTopiaDaoSupplier daoSupplier, Species species) {
    
    215
    -//
    
    216
    -//        LengthLengthParameterTopiaDao dao = daoSupplier.getCommonLengthLengthParameterDao();
    
    217
    -//
    
    218
    -//        List<LengthLengthParameter> list = dao.forSpeciesEquals(species).findAll();
    
    219
    -//
    
    220
    -//        // on supprime les paramétrages qui ont a=0 ou a=null ou b=0 ou b = null
    
    221
    -//        Iterator<LengthLengthParameter> itr = list.iterator();
    
    222
    -//        while (itr.hasNext()) {
    
    223
    -//            LengthLengthParameter p = itr.next();
    
    224
    -//            Double a = p.getCoefficientValue(FormulaHelper.COEFFICIENT_A);
    
    225
    -//            if (a == null || a == 0) {
    
    226
    -//                itr.remove();
    
    227
    -//                continue;
    
    228
    -//            }
    
    229
    -//
    
    230
    -//            Double b = p.getCoefficientValue(FormulaHelper.COEFFICIENT_B);
    
    231
    -//            // on autorise d'avoir b à 0 (mais cela ne permet plus de calculer la taille à partir du poids)
    
    232
    -////            if (b == null || b == 0) {
    
    233
    -//            if (b == null) {
    
    234
    -//                itr.remove();
    
    235
    -//            }
    
    236
    -//        }
    
    237
    -//        return list;
    
    238
    -//
    
    239
    -//    }
    
    240
    -
    
    241
    -//    public static List<LengthLengthParameter> filterByOcean(List<LengthLengthParameter> list, Ocean ocean) {
    
    242
    -//        List<LengthLengthParameter> result = new ArrayList<>();
    
    243
    -//        if (ocean == null) {
    
    244
    -//
    
    245
    -//            // on n'accepte que les parametrage sans ocean
    
    246
    -//            for (LengthLengthParameter parametrageLengthWeight : list) {
    
    247
    -//                if (parametrageLengthWeight.getOcean() == null) {
    
    248
    -//                    result.add(parametrageLengthWeight);
    
    249
    -//                }
    
    250
    -//            }
    
    251
    -//        } else {
    
    252
    -//            for (LengthLengthParameter parametrageLengthWeight : list) {
    
    253
    -//                if (ocean.equals(parametrageLengthWeight.getOcean())) {
    
    254
    -//                    result.add(parametrageLengthWeight);
    
    255
    -//                }
    
    256
    -//            }
    
    257
    -//        }
    
    258
    -//        return result;
    
    259
    -//    }
    
    260
    -//
    
    261
    -//    public static List<LengthLengthParameter> filterBySexe(List<LengthLengthParameter> list, Sex sex) {
    
    262
    -//        return list.stream().filter(l -> l.getSex() == sex).collect(Collectors.toList());
    
    263
    -//    }
    
    264
    -//
    
    265
    -//    public static List<LengthLengthParameter> filterByInputSizeMeasureType(List<LengthLengthParameter> list, SizeMeasureType sizeMeasureType) {
    
    266
    -//        return list.stream().filter(l -> l.getInputSizeMeasureType() == sizeMeasureType).collect(Collectors.toList());
    
    267
    -//    }
    
    268
    -//public static List<LengthLengthParameter> filterByOutputSizeMeasureType(List<LengthLengthParameter> list, SizeMeasureType sizeMeasureType) {
    
    269
    -//        return list.stream().filter(l -> l.getOutputSizeMeasureType() == sizeMeasureType).collect(Collectors.toList());
    
    270
    -//    }
    
    271
    -//
    
    272
    -//    public static List<LengthLengthParameter> filterByDateDebutValidite(List<LengthLengthParameter> list, Date startDate) {
    
    273
    -//        return list.stream()
    
    274
    -//                .filter(l -> l.getStartDate() == null || l.getStartDate().before(startDate) || l.getStartDate().equals(startDate))
    
    275
    -//                .collect(Collectors.toList());
    
    276
    -//    }
    
    277
    -//
    
    278
    -//    public static List<LengthLengthParameter> filterByDateFinValidite(List<LengthLengthParameter> list, Date endDate) {
    
    279
    -//        List<LengthLengthParameter> result = new ArrayList<>();
    
    280
    -//
    
    281
    -//        if (endDate == null) {
    
    282
    -//            // on n'accepte que les parametrages selon les critères suivants :
    
    283
    -//            // - sans date de fin (i.e en cours de validite)
    
    284
    -//            for (LengthLengthParameter parametrageLengthWeight : list) {
    
    285
    -//
    
    286
    -//                Date date = parametrageLengthWeight.getEndDate();
    
    287
    -//                if (date == null) {
    
    288
    -//                    result.add(parametrageLengthWeight);
    
    289
    -//                }
    
    290
    -//            }
    
    291
    -//        } else {
    
    292
    -//            // on n'accepte que les parametrages selon les critères suivants :
    
    293
    -//            // - sans date de fin (i.e en cours de validite)
    
    294
    -//            // - ceux dont la date de fin est avant la date de fin donnée
    
    295
    -//            for (LengthLengthParameter parametrageLengthWeight : list) {
    
    296
    -//
    
    297
    -//                Date date = parametrageLengthWeight.getEndDate();
    
    298
    -//                if (date == null ||
    
    299
    -//                        date.after(endDate) ||
    
    300
    -//                        date.equals(endDate)) {
    
    301
    -//                    result.add(parametrageLengthWeight);
    
    302
    -//                }
    
    303
    -//            }
    
    304
    -//        }
    
    305
    -//        return result;
    
    306
    -//    }
    
    307 132
     }

  • persistence/src/main/java/fr/ird/observe/entities/referential/common/LengthWeightParameters.java
    ... ... @@ -22,6 +22,7 @@ package fr.ird.observe.entities.referential.common;
    22 22
      * #L%
    
    23 23
      */
    
    24 24
     
    
    25
    +import fr.ird.observe.dto.decoration.DecoratorService;
    
    25 26
     import fr.ird.observe.entities.referential.DuplicateLengthWeightParameterException;
    
    26 27
     import fr.ird.observe.entities.referential.LengthWeightParameterNotFoundException;
    
    27 28
     import fr.ird.observe.entities.ObserveTopiaDaoSupplier;
    
    ... ... @@ -49,16 +50,18 @@ public class LengthWeightParameters {
    49 50
          * <p>
    
    50 51
          * Si non trouvé sur le sexe (et que le sexe n'est pas indéterminé) , alors on recherche avec le sexe indéterminé (sexe=0).
    
    51 52
          *
    
    52
    -     * @param daoSupplier     la transaction en cours d'utilisation
    
    53
    -     * @param species         l'espèce sur lequel on recherche le paramétrage
    
    54
    -     * @param sex             le sexe recherché (on essayera sans sexe (sexe.code=0) si non trouvé)
    
    55
    -     * @param ocean           l'ocean recherché (peut être null)
    
    56
    -     * @param date            le jour recherché
    
    57
    -     * @param sizeMeasureType le type de mensuration recherché
    
    53
    +     * @param decoratorService le service de décoration
    
    54
    +     * @param daoSupplier      la transaction en cours d'utilisation
    
    55
    +     * @param species          l'espèce sur lequel on recherche le paramétrage
    
    56
    +     * @param sex              le sexe recherché (on essayera sans sexe (sexe.code=0) si non trouvé)
    
    57
    +     * @param ocean            l'ocean recherché (peut être null)
    
    58
    +     * @param date             le jour recherché
    
    59
    +     * @param sizeMeasureType  le type de mensuration recherché
    
    58 60
          * @return le paramétrage adéquate
    
    59 61
          * @since 1.5
    
    60 62
          */
    
    61
    -    public static LengthWeightParameter findLengthWeightParameter(ObserveTopiaDaoSupplier daoSupplier,
    
    63
    +    public static LengthWeightParameter findLengthWeightParameter(DecoratorService decoratorService,
    
    64
    +                                                                  ObserveTopiaDaoSupplier daoSupplier,
    
    62 65
                                                                       Species species, Sex sex, Ocean ocean, Date date, SizeMeasureType sizeMeasureType) {
    
    63 66
     
    
    64 67
     //        Sex unknownSex = getUnknownSex(daoSupplier);
    
    ... ... @@ -79,7 +82,7 @@ public class LengthWeightParameters {
    79 82
     //        }
    
    80 83
     
    
    81 84
             if (CollectionUtils.isEmpty(list)) {
    
    82
    -            throw new LengthWeightParameterNotFoundException(species, ocean, sex, date);
    
    85
    +            throw new LengthWeightParameterNotFoundException(decoratorService, species, ocean, sex, date);
    
    83 86
             }
    
    84 87
     
    
    85 88
     //        if (sizeMeasureType != null) {
    
    ... ... @@ -98,190 +101,11 @@ public class LengthWeightParameters {
    98 101
             // au final il ne devrait en rester qu'un
    
    99 102
     
    
    100 103
             if (list.size() > 1) {
    
    101
    -            throw new DuplicateLengthWeightParameterException(species, ocean, sex, date, list);
    
    104
    +            throw new DuplicateLengthWeightParameterException(decoratorService, species, ocean, sex, date, list);
    
    102 105
             }
    
    103 106
     
    
    104 107
             return Objects.requireNonNull(list.get(0));
    
    105 108
     
    
    106 109
         }
    
    107 110
     
    
    108
    -//    /**
    
    109
    -//     * Recherche de la liste des {@link LengthWeightParameter} à partir des paramètres donnés.
    
    110
    -//     * <p>
    
    111
    -//     * La recherche peut ne peut être aussi exacte que les paramètres donnés :
    
    112
    -//     * <p>
    
    113
    -//     * Dans le cas d'une espèce faune, si non trouvé alors on recherche sur son
    
    114
    -//     * speciesGroup d'espèce.
    
    115
    -//     * <p>
    
    116
    -//     * Si non trouvé pour l'océan donné (et que celui-ci est non null), alors on
    
    117
    -//     * recherche avec un ocean vide.
    
    118
    -//     *
    
    119
    -//     * @param daoSupplier la transaction en cours d'utilisation
    
    120
    -//     * @param species     l'espèce sur lequel on recherche le paramétrage
    
    121
    -//     * @param ocean       l'ocean recherché (peut être null)
    
    122
    -//     * @param sex         le sexe recherché (on essayera sans sexe (sexe.code=0) si non trouvé)
    
    123
    -//     * @param date        le jour recherché
    
    124
    -//     * @return le paramétrage adéquate
    
    125
    -//     * @since 1.5
    
    126
    -//     */
    
    127
    -//    public static List<LengthWeightParameter> findLengthWeightParameter0(ObserveTopiaDaoSupplier daoSupplier,
    
    128
    -//                                                                         Species species,
    
    129
    -//                                                                         Ocean ocean,
    
    130
    -//                                                                         Sex sex,
    
    131
    -//                                                                         Date date) {
    
    132
    -//
    
    133
    -//        Objects.requireNonNull(daoSupplier, "daoSupplier parameter can't be null");
    
    134
    -//        Objects.requireNonNull(species, "species parameter can't be null");
    
    135
    -//        Objects.requireNonNull(sex, "sex parameter can't be null");
    
    136
    -//
    
    137
    -//        List<LengthWeightParameter> list = findBySpecies(daoSupplier, species);
    
    138
    -//
    
    139
    -//        if (CollectionUtils.isEmpty(list)) {
    
    140
    -//
    
    141
    -//            // aucun parametrage pour le type donne
    
    142
    -//            return null;
    
    143
    -//        }
    
    144
    -//
    
    145
    -//        // filtrage par ocean
    
    146
    -//        List<LengthWeightParameter> filterByOcean = filterByOcean(list, ocean);
    
    147
    -//
    
    148
    -//        if (CollectionUtils.isEmpty(filterByOcean) && ocean != null) {
    
    149
    -//
    
    150
    -//            // filtre par ocean null
    
    151
    -//            filterByOcean = filterByOcean(list, null);
    
    152
    -//        }
    
    153
    -//        list = filterByOcean;
    
    154
    -//
    
    155
    -//        if (CollectionUtils.isEmpty(list)) {
    
    156
    -//
    
    157
    -//            // pas d'ocean adequate
    
    158
    -//            return null;
    
    159
    -//        }
    
    160
    -//
    
    161
    -//        // filtrage par sexe
    
    162
    -//        list = filterBySexe(list, sex);
    
    163
    -//
    
    164
    -//        if (CollectionUtils.isEmpty(list)) {
    
    165
    -//
    
    166
    -//            // pas de sexe adequate
    
    167
    -//            return null;
    
    168
    -//        }
    
    169
    -//
    
    170
    -//        // filtrage par startDate de validite
    
    171
    -//        list = filterByDateDebutValidite(list, date);
    
    172
    -//
    
    173
    -//        if (CollectionUtils.isEmpty(list)) {
    
    174
    -//
    
    175
    -//            // pas de date de debut adequate
    
    176
    -//            return null;
    
    177
    -//        }
    
    178
    -//
    
    179
    -//        // filtrage par endDate de validite
    
    180
    -//        list = filterByDateFinValidite(list, date);
    
    181
    -//
    
    182
    -//        if (CollectionUtils.isEmpty(list)) {
    
    183
    -//
    
    184
    -//            // pas de date de fin adequate
    
    185
    -//            return null;
    
    186
    -//        }
    
    187
    -//
    
    188
    -//        return list;
    
    189
    -//
    
    190
    -//    }
    
    191
    -
    
    192
    -//    private static Sex getUnknownSex(ObserveTopiaDaoSupplier daoSupplier) {
    
    193
    -//        return daoSupplier.getCommonSexDao().forCodeEquals("0").findUnique();
    
    194
    -//    }
    
    195
    -
    
    196
    -//    public static List<LengthWeightParameter> findBySpecies(ObserveTopiaDaoSupplier daoSupplier, Species species) {
    
    197
    -//
    
    198
    -//        LengthWeightParameterTopiaDao dao = daoSupplier.getCommonLengthWeightParameterDao();
    
    199
    -//
    
    200
    -//        List<LengthWeightParameter> list = dao.forSpeciesEquals(species).findAll();
    
    201
    -//
    
    202
    -//        // on supprime les paramétrages qui ont a=0 ou a=null ou b=0 ou b = null
    
    203
    -//        Iterator<LengthWeightParameter> itr = list.iterator();
    
    204
    -//        while (itr.hasNext()) {
    
    205
    -//            LengthWeightParameter p = itr.next();
    
    206
    -//            Double a = p.getCoefficientValue(FormulaHelper.COEFFICIENT_A);
    
    207
    -//            if (a == null || a == 0) {
    
    208
    -//                itr.remove();
    
    209
    -//                continue;
    
    210
    -//            }
    
    211
    -//
    
    212
    -//            Double b = p.getCoefficientValue(FormulaHelper.COEFFICIENT_B);
    
    213
    -//            // on autorise d'avoir b à 0 (mais cela ne permet plus de calculer la taille à partir du poids)
    
    214
    -////            if (b == null || b == 0) {
    
    215
    -//            if (b == null) {
    
    216
    -//                itr.remove();
    
    217
    -//            }
    
    218
    -//        }
    
    219
    -//        return list;
    
    220
    -//
    
    221
    -//    }
    
    222
    -//
    
    223
    -//    public static List<LengthWeightParameter> filterByOcean(List<LengthWeightParameter> list, Ocean ocean) {
    
    224
    -//        List<LengthWeightParameter> result = new ArrayList<>();
    
    225
    -//        if (ocean == null) {
    
    226
    -//
    
    227
    -//            // on n'accepte que les parametrage sans ocean
    
    228
    -//            for (LengthWeightParameter parametrageLengthWeight : list) {
    
    229
    -//                if (parametrageLengthWeight.getOcean() == null) {
    
    230
    -//                    result.add(parametrageLengthWeight);
    
    231
    -//                }
    
    232
    -//            }
    
    233
    -//        } else {
    
    234
    -//            for (LengthWeightParameter parametrageLengthWeight : list) {
    
    235
    -//                if (ocean.equals(parametrageLengthWeight.getOcean())) {
    
    236
    -//                    result.add(parametrageLengthWeight);
    
    237
    -//                }
    
    238
    -//            }
    
    239
    -//        }
    
    240
    -//        return result;
    
    241
    -//    }
    
    242
    -//
    
    243
    -//    public static List<LengthWeightParameter> filterBySexe(List<LengthWeightParameter> list, Sex sex) {
    
    244
    -//        return list.stream().filter(l -> l.getSex() == sex).collect(Collectors.toList());
    
    245
    -//    }
    
    246
    -//
    
    247
    -//    public static List<LengthWeightParameter> filterBySizeMeasureType(List<LengthWeightParameter> list, SizeMeasureType sizeMeasureType) {
    
    248
    -//        return list.stream().filter(l -> l.getSizeMeasureType() == sizeMeasureType).collect(Collectors.toList());
    
    249
    -//    }
    
    250
    -//
    
    251
    -//    public static List<LengthWeightParameter> filterByDateDebutValidite(List<LengthWeightParameter> list, Date startDate) {
    
    252
    -//        return list.stream()
    
    253
    -//                .filter(l -> l.getStartDate() == null || l.getStartDate().before(startDate) || l.getStartDate().equals(startDate))
    
    254
    -//                .collect(Collectors.toList());
    
    255
    -//    }
    
    256
    -//
    
    257
    -//    public static List<LengthWeightParameter> filterByDateFinValidite(List<LengthWeightParameter> list, Date endDate) {
    
    258
    -//        List<LengthWeightParameter> result = new ArrayList<>();
    
    259
    -//
    
    260
    -//        if (endDate == null) {
    
    261
    -//            // on n'accepte que les parametrages selon les critères suivants :
    
    262
    -//            // - sans date de fin (i.e en cours de validite)
    
    263
    -//            for (LengthWeightParameter parametrageLengthWeight : list) {
    
    264
    -//
    
    265
    -//                Date date = parametrageLengthWeight.getEndDate();
    
    266
    -//                if (date == null) {
    
    267
    -//                    result.add(parametrageLengthWeight);
    
    268
    -//                }
    
    269
    -//            }
    
    270
    -//        } else {
    
    271
    -//            // on n'accepte que les parametrages selon les critères suivants :
    
    272
    -//            // - sans date de fin (i.e en cours de validite)
    
    273
    -//            // - ceux dont la date de fin est avant la date de fin donnée
    
    274
    -//            for (LengthWeightParameter parametrageLengthWeight : list) {
    
    275
    -//
    
    276
    -//                Date date = parametrageLengthWeight.getEndDate();
    
    277
    -//                if (date == null ||
    
    278
    -//                        date.after(endDate) ||
    
    279
    -//                        date.equals(endDate)) {
    
    280
    -//                    result.add(parametrageLengthWeight);
    
    281
    -//                }
    
    282
    -//            }
    
    283
    -//        }
    
    284
    -//        return result;
    
    285
    -//    }
    
    286
    -
    
    287 111
     }

  • services-local/src/main/java/fr/ird/observe/services/local/service/actions/consolidate/ConsolidateDataServiceLocal.java
    ... ... @@ -27,6 +27,8 @@ import com.google.common.collect.ImmutableSet;
    27 27
     import fr.ird.observe.dto.data.ps.NonTargetCatchComputedValueSource;
    
    28 28
     import fr.ird.observe.dto.data.ps.observation.FloatingObjectDto;
    
    29 29
     import fr.ird.observe.dto.data.ps.observation.FloatingObjectPartDto;
    
    30
    +import fr.ird.observe.dto.decoration.DecoratorService;
    
    31
    +import fr.ird.observe.dto.decoration.DecoratorServiceApplicationComponent;
    
    30 32
     import fr.ird.observe.dto.referential.I18nReferentialHelper;
    
    31 33
     import fr.ird.observe.dto.referential.ReferentialLocale;
    
    32 34
     import fr.ird.observe.entities.EntityHelper;
    
    ... ... @@ -152,8 +154,8 @@ public class ConsolidateDataServiceLocal extends ObserveServiceLocal implements
    152 154
             SimplifiedObjectTypeManager simplifiedObjectTypeManager = newSimplifiedObjectTypeManager(simplifiedObjectTypeSpecializedRules);
    
    153 155
     
    
    154 156
             FloatingObjectConsolidateEngine floatingObjectConsolidateEngine = new FloatingObjectConsolidateEngine(simplifiedObjectTypeManager);
    
    155
    -
    
    156
    -        Optional<ConsolidateTripSeineDataResult> consolidateTripSeineDataResult = consolidateTripSeine(referenceLocale, floatingObjectConsolidateEngine, request.getTripSeineId(), failIfLengthWeightParameterNotFound, failIfLengthLengthParameterNotFound);
    
    157
    +        DecoratorService decoratorService = DecoratorServiceApplicationComponent.value();
    
    158
    +        Optional<ConsolidateTripSeineDataResult> consolidateTripSeineDataResult = consolidateTripSeine(decoratorService,referenceLocale, floatingObjectConsolidateEngine, request.getTripSeineId(), failIfLengthWeightParameterNotFound, failIfLengthLengthParameterNotFound);
    
    157 159
             return consolidateTripSeineDataResult.orElse(null);
    
    158 160
         }
    
    159 161
     
    
    ... ... @@ -174,7 +176,7 @@ public class ConsolidateDataServiceLocal extends ObserveServiceLocal implements
    174 176
             return new SimplifiedObjectTypeManager(materialMapping, simplifiedObjectTypeSpecializedRules);
    
    175 177
         }
    
    176 178
     
    
    177
    -    private Optional<ConsolidateTripSeineDataResult> consolidateTripSeine(ReferentialLocale referenceLocale, FloatingObjectConsolidateEngine floatingObjectConsolidateEngine, String tripSeineId, boolean failIfLengthWeightParameterNotFound, boolean failIfLengthLengthParameterNotFound) {
    
    179
    +    private Optional<ConsolidateTripSeineDataResult> consolidateTripSeine(DecoratorService decoratorService, ReferentialLocale referenceLocale, FloatingObjectConsolidateEngine floatingObjectConsolidateEngine, String tripSeineId, boolean failIfLengthWeightParameterNotFound, boolean failIfLengthLengthParameterNotFound) {
    
    178 180
     
    
    179 181
             log.info(String.format("Start consolidate trip: %s", tripSeineId));
    
    180 182
     
    
    ... ... @@ -235,6 +237,7 @@ public class ConsolidateDataServiceLocal extends ObserveServiceLocal implements
    235 237
     
    
    236 238
                     ConsolidationActivitySeineDataContext activityContext = new ConsolidationActivitySeineDataContext();
    
    237 239
                     activityContext.locale = applicationLocale;
    
    240
    +                activityContext.decoratorService = decoratorService;
    
    238 241
                     activityContext.failIfLengthWeightParameterNotFound = failIfLengthWeightParameterNotFound;
    
    239 242
                     activityContext.failIfLengthLengthParameterNotFound = failIfLengthLengthParameterNotFound;
    
    240 243
                     activityContext.daoSupplier = persistenceContext;
    

  • services-local/src/main/java/fr/ird/observe/services/local/service/actions/consolidate/ConsolidationActivitySeineDataContext.java
    ... ... @@ -24,6 +24,7 @@ package fr.ird.observe.services.local.service.actions.consolidate;
    24 24
     
    
    25 25
     import fr.ird.observe.dto.data.ps.DcpComputedValue;
    
    26 26
     import fr.ird.observe.dto.data.ps.observation.FloatingObjectDto;
    
    27
    +import fr.ird.observe.dto.decoration.DecoratorService;
    
    27 28
     import fr.ird.observe.entities.ObserveTopiaDaoSupplier;
    
    28 29
     import fr.ird.observe.entities.data.ps.common.Trip;
    
    29 30
     import fr.ird.observe.entities.data.ps.observation.Activity;
    
    ... ... @@ -67,6 +68,7 @@ class ConsolidationActivitySeineDataContext {
    67 68
         boolean failIfLengthWeightParameterNotFound;
    
    68 69
         boolean failIfLengthLengthParameterNotFound;
    
    69 70
         BeanMonitor targetLengthMonitor;
    
    71
    +    DecoratorService decoratorService;
    
    70 72
         String activityPrefix;
    
    71 73
     
    
    72 74
         BeanMonitor nonTargetLengthMonitor;
    
    ... ... @@ -93,7 +95,7 @@ class ConsolidationActivitySeineDataContext {
    93 95
             Ocean ocean = getOcean();
    
    94 96
             Date routeDate = getRouteDate();
    
    95 97
             try {
    
    96
    -            return Optional.ofNullable(LengthWeightParameters.findLengthWeightParameter(daoSupplier, species, sex, ocean, routeDate, sizeMeasureType));
    
    98
    +            return Optional.ofNullable(LengthWeightParameters.findLengthWeightParameter(decoratorService, daoSupplier, species, sex, ocean, routeDate, sizeMeasureType));
    
    97 99
             } catch (LengthWeightParameterNotFoundException e) {
    
    98 100
                 if (failIfLengthWeightParameterNotFound) {
    
    99 101
                     throw e;
    
    ... ... @@ -107,7 +109,7 @@ class ConsolidationActivitySeineDataContext {
    107 109
             Ocean ocean = getOcean();
    
    108 110
             Date routeDate = getRouteDate();
    
    109 111
             try {
    
    110
    -            return LengthLengthParameters.findLengthLengthParameter(daoSupplier, species, ocean, sex, routeDate, inputSizeMeasureType, outputSizeMeasureType);
    
    112
    +            return LengthLengthParameters.findLengthLengthParameter(decoratorService, daoSupplier, species, ocean, sex, routeDate, inputSizeMeasureType, outputSizeMeasureType);
    
    111 113
             } catch (LengthLengthParameterNotFoundException e) {
    
    112 114
                 if (failIfLengthLengthParameterNotFound) {
    
    113 115
                     throw e;
    

  • services-local/src/test/java/fr/ird/observe/services/local/entity/LengthWeightParemetersTest.java
    ... ... @@ -22,6 +22,8 @@
    22 22
     package fr.ird.observe.services.local.entity;
    
    23 23
     
    
    24 24
     import com.opensymphony.xwork2.interceptor.annotations.After;
    
    25
    +import fr.ird.observe.dto.decoration.DecoratorService;
    
    26
    +import fr.ird.observe.dto.decoration.DecoratorServiceApplicationComponent;
    
    25 27
     import fr.ird.observe.dto.referential.ReferenceStatus;
    
    26 28
     import fr.ird.observe.entities.ObserveTopiaDaoSupplier;
    
    27 29
     import fr.ird.observe.entities.ObserveTopiaPersistenceContext;
    
    ... ... @@ -61,6 +63,7 @@ public class LengthWeightParemetersTest extends ServiceLocalTestSupport {
    61 63
         private static final Logger log = LogManager.getLogger(LengthWeightParemetersTest.class);
    
    62 64
     
    
    63 65
         private ObserveTopiaPersistenceContext persistenceContext;
    
    66
    +    private DecoratorService decoratorService;
    
    64 67
     
    
    65 68
         protected static void createLengthWeightParameter(LengthWeightParameterTopiaDao lengthWeightParameterDao,
    
    66 69
                                                           Species species,
    
    ... ... @@ -93,6 +96,7 @@ public class LengthWeightParemetersTest extends ServiceLocalTestSupport {
    93 96
     
    
    94 97
             persistenceContext = localTestMethodResource.newPersistenceContext();
    
    95 98
     
    
    99
    +        decoratorService = DecoratorServiceApplicationComponent.value();
    
    96 100
             SpeciesTopiaDao speciesDAO = persistenceContext.getCommonSpeciesDao();
    
    97 101
             OceanTopiaDao oceanDAO = persistenceContext.getCommonOceanDao();
    
    98 102
             SexTopiaDao sexDao = persistenceContext.getCommonSexDao();
    
    ... ... @@ -239,7 +243,7 @@ public class LengthWeightParemetersTest extends ServiceLocalTestSupport {
    239 243
             if (log.isInfoEnabled()) {
    
    240 244
                 log.info("Try to find length weith parameter for species " + species.getFaoCode() + " - ocean " + ocean.getLabel1() + " - sex " + (sex == null ? "null" : sex.getLabel1()) + " at " + date);
    
    241 245
             }
    
    242
    -        LengthWeightParameter lengthWeightParameter = LengthWeightParameters.findLengthWeightParameter(supplier, species, sex, ocean, date, expectedSizeMeasureType);
    
    246
    +        LengthWeightParameter lengthWeightParameter = LengthWeightParameters.findLengthWeightParameter(decoratorService, supplier, species, sex, ocean, date, expectedSizeMeasureType);
    
    243 247
     
    
    244 248
             Assert.assertNotNull("length weith parameter not found for species " + species.getFaoCode() + " - ocean " + ocean.getLabel1() + " - sex " + (sex == null ? "null" : sex.getLabel1()) + " at " + date, lengthWeightParameter);
    
    245 249
             Assert.assertEquals("Expected sex is " + expectedSex.getLabel1() + " but the one found was " + lengthWeightParameter.getSex().getLabel1(), expectedSex, lengthWeightParameter.getSex());
    
    ... ... @@ -255,7 +259,7 @@ public class LengthWeightParemetersTest extends ServiceLocalTestSupport {
    255 259
                 log.info("Try to find length weith parameter for species " + species.getFaoCode() + " - ocean " + ocean.getLabel1() + " - sex " + (sex == null ? "null" : sex.getLabel1()) + " at " + date);
    
    256 260
             }
    
    257 261
             try {
    
    258
    -            LengthWeightParameters.findLengthWeightParameter(supplier, species, sex, ocean, date, expectedSizeMeasureType);
    
    262
    +            LengthWeightParameters.findLengthWeightParameter(decoratorService, supplier, species, sex, ocean, date, expectedSizeMeasureType);
    
    259 263
                 Assert.fail();
    
    260 264
             } catch (LengthWeightParameterNotFoundException e) {
    
    261 265