Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe
Commits:
-
36e112a1
by Tony Chemit at 2020-05-10T18:47:33+02:00
16 changed files:
- dto/src/main/java/fr/ird/observe/dto/decoration/DecoratorService.java
- observe-i18n/src/main/i18n/translations/observe_en_GB.properties
- observe-i18n/src/main/i18n/translations/observe_es_ES.properties
- observe-i18n/src/main/i18n/translations/observe_fr_FR.properties
- + persistence/.mvn/i18n/parse-java
- persistence/pom.xml
- + persistence/src/main/i18n/getters/java.getter
- persistence/src/main/java/fr/ird/observe/entities/referentiel/DuplicateLengthLengthParameterException.java
- persistence/src/main/java/fr/ird/observe/entities/referentiel/DuplicateLengthWeightParameterException.java
- persistence/src/main/java/fr/ird/observe/entities/referentiel/LengthLengthParameterNotFoundException.java
- persistence/src/main/java/fr/ird/observe/entities/referentiel/LengthLengthParameters.java
- persistence/src/main/java/fr/ird/observe/entities/referentiel/LengthWeightParameterNotFoundException.java
- persistence/src/main/java/fr/ird/observe/entities/referentiel/LengthWeightParameters.java
- services-local/src/main/java/fr/ird/observe/services/local/service/actions/consolidate/ConsolidateDataServiceLocal.java
- services-local/src/main/java/fr/ird/observe/services/local/service/actions/consolidate/ConsolidationActivitySeineDataContext.java
- services-local/src/test/java/fr/ird/observe/services/local/entity/LengthWeightParemetersTest.java
Changes:
| ... | ... | @@ -1084,4 +1084,17 @@ public class DecoratorService extends DecoratorProvider { |
| 1084 | 1084 |
}
|
| 1085 | 1085 |
|
| 1086 | 1086 |
};
|
| 1087 |
+ |
|
| 1088 |
+ public String toString(Object o) {
|
|
| 1089 |
+ if (o==null) {
|
|
| 1090 |
+ return null;
|
|
| 1091 |
+ }
|
|
| 1092 |
+ if (o instanceof ReferentialDtoReference) {
|
|
| 1093 |
+ return getReferentialReferenceDecorator(((ReferentialDtoReference<?,?>) o).getReferenceType()).toString(o);
|
|
| 1094 |
+ }
|
|
| 1095 |
+ if (o instanceof DataDtoReference) {
|
|
| 1096 |
+ return getDataReferenceDecorator(((DataDtoReference<?,?>) o).getReferenceType()).toString(o);
|
|
| 1097 |
+ }
|
|
| 1098 |
+ return getDecoratorByType(o.getClass()).toString(o);
|
|
| 1099 |
+ }
|
|
| 1087 | 1100 |
}
|
| ... | ... | @@ -1951,6 +1951,10 @@ observe.converter.error.float.format=Decimal format not correct for value %s |
| 1951 | 1951 |
observe.converter.error.no.convertor=could not convert decimal %s using convertor %s
|
| 1952 | 1952 |
observe.converter.error.noValue=No value to convert using convertor %s
|
| 1953 | 1953 |
observe.entity.message.updating=object '%1$s' is in editing mode.
|
| 1954 |
+observe.error.DuplicateLengthLengthParameterException=Found multiple length length relation for species\: %s, ocean\: %s, sex\: %s, date\: %s \:\n * %s
|
|
| 1955 |
+observe.error.DuplicateLengthWeightParameterException=Found multiple length weight paramters for species\: %s, ocean\: %s, sex\: %s, date\: %s \:\n * %s
|
|
| 1956 |
+observe.error.LengthLengthParameterNotFoundException=No length length relation found for species\: %s, ocean\: %s, sex\: %s, date\: %s \: %s
|
|
| 1957 |
+observe.error.LengthWeightParameterNotFoundException=No length weight relation found for species\: %s, ocean\: %s, sex\: %s, date\: %s \: %s
|
|
| 1954 | 1958 |
observe.error.can.not.create.directory=Can't create directory %&$s\!
|
| 1955 | 1959 |
observe.error.storage.could.not.backup.unsane.local.db=Can not save an borken database
|
| 1956 | 1960 |
observe.error.storage.could.not.load.local.db=Could not open local database for reason\: %s
|
| ... | ... | @@ -1951,6 +1951,10 @@ observe.converter.error.float.format=Formato de decimal incorrecto para el valor |
| 1951 | 1951 |
observe.converter.error.no.convertor=Impossible de convertir el decimal %s con el convertidor %s
|
| 1952 | 1952 |
observe.converter.error.noValue=Ningún valor necesita ser convertida con el convertidor %s
|
| 1953 | 1953 |
observe.entity.message.updating=Se está modificando el objeto actual '%1$s'.
|
| 1954 |
+observe.error.DuplicateLengthLengthParameterException=Found multiple length length relation for species\: %s, ocean\: %s, sex\: %s, date\: %s \:\n * %s \#TODO
|
|
| 1955 |
+observe.error.DuplicateLengthWeightParameterException=Found multiple length weight relation for species\: %s, ocean\: %s, sex\: %s, date\: %s \:\n * %s \#TODO
|
|
| 1956 |
+observe.error.LengthLengthParameterNotFoundException=No length length relation found for species\: %s, ocean\: %s, sex\: %s, date\: %s \: %s \#TODO
|
|
| 1957 |
+observe.error.LengthWeightParameterNotFoundException=No length weight relation found for species\: %s, ocean\: %s, sex\: %s, date\: %s \: %s \#TODO
|
|
| 1954 | 1958 |
observe.error.can.not.create.directory=¡Imposible crear el directorio %1$s\!
|
| 1955 | 1959 |
observe.error.storage.could.not.backup.unsane.local.db=Impossible grabar una base dañada
|
| 1956 | 1960 |
observe.error.storage.could.not.load.local.db=Impossible grabar la base local por la razón siguiente \: %s
|
| ... | ... | @@ -1951,6 +1951,10 @@ observe.converter.error.float.format=Format de décimal incorrecte pour la valeu |
| 1951 | 1951 |
observe.converter.error.no.convertor=Impossible de convertir le décimal %s depuis le convertisseur %s
|
| 1952 | 1952 |
observe.converter.error.noValue=Aucune valeur à convertir pour le convertisseur %s
|
| 1953 | 1953 |
observe.entity.message.updating=L'objet '%1$s' est en cours de modification.
|
| 1954 |
+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
|
|
| 1955 |
+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
|
|
| 1956 |
+observe.error.LengthLengthParameterNotFoundException=Aucune relation taille-taille trouvée pour l'espèce\: %s, l'ocean\: %s, le sexe\: %s et la date\: %s
|
|
| 1957 |
+observe.error.LengthWeightParameterNotFoundException=Aucune relation taille-poids trouvée pour l'espèce\: %s, l'ocean\: %s, le sexe\: %s et la date\: %s
|
|
| 1954 | 1958 |
observe.error.can.not.create.directory=Création du répertoire %1$s impossible\!
|
| 1955 | 1959 |
observe.error.storage.could.not.backup.unsane.local.db=Impossible d'enregistrer une base non endommagée
|
| 1956 | 1960 |
observe.error.storage.could.not.load.local.db=Impossible d'ouvrir la base locale pour la raison suivante \: %s
|
| ... | ... | @@ -86,7 +86,10 @@ |
| 86 | 86 |
<artifactId>nuiton-csv</artifactId>
|
| 87 | 87 |
<scope>test</scope>
|
| 88 | 88 |
</dependency>
|
| 89 |
- |
|
| 89 |
+ <dependency>
|
|
| 90 |
+ <groupId>io.ultreia.java4all.i18n</groupId>
|
|
| 91 |
+ <artifactId>i18n-runtime</artifactId>
|
|
| 92 |
+ </dependency>
|
|
| 90 | 93 |
<dependency>
|
| 91 | 94 |
<groupId>io.ultreia.java4all.http</groupId>
|
| 92 | 95 |
<artifactId>http-api</artifactId>
|
| 1 |
+observe.error.DuplicateLengthWeightParameterException
|
|
| 2 |
+observe.error.LengthLengthParameterNotFoundException
|
|
| 3 |
+observe.error.LengthWeightParameterNotFoundException
|
| ... | ... | @@ -22,8 +22,20 @@ package fr.ird.observe.entities.referentiel; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
+import fr.ird.observe.binder.referential.ReferentialEntityReferenceBinderSupport;
|
|
| 26 |
+import fr.ird.observe.dto.decoration.DecoratorService;
|
|
| 27 |
+import fr.ird.observe.dto.referential.LengthLengthParameterDto;
|
|
| 28 |
+import fr.ird.observe.dto.referential.LengthLengthParameterReference;
|
|
| 29 |
+import fr.ird.observe.dto.referential.LengthWeightParameterDto;
|
|
| 30 |
+import fr.ird.observe.dto.referential.LengthWeightParameterReference;
|
|
| 31 |
+import fr.ird.observe.dto.referential.ReferentialLocale;
|
|
| 32 |
+import fr.ird.observe.spi.DbModelHelper;
|
|
| 33 |
+ |
|
| 25 | 34 |
import java.util.Date;
|
| 26 | 35 |
import java.util.List;
|
| 36 |
+import java.util.stream.Collectors;
|
|
| 37 |
+ |
|
| 38 |
+import static io.ultreia.java4all.i18n.I18n.t;
|
|
| 27 | 39 |
|
| 28 | 40 |
/**
|
| 29 | 41 |
* Created on 28/08/15.
|
| ... | ... | @@ -44,7 +56,8 @@ public class DuplicateLengthLengthParameterException extends RuntimeException { |
| 44 | 56 |
|
| 45 | 57 |
protected final List<LengthLengthParameter> foundLengthLengthParameters;
|
| 46 | 58 |
|
| 47 |
- public DuplicateLengthLengthParameterException(Species species, Ocean ocean, Sex sex, Date date, List<LengthLengthParameter> foundLengthLengthParameters) {
|
|
| 59 |
+ public DuplicateLengthLengthParameterException(DecoratorService decoratorService, Species species, Ocean ocean, Sex sex, Date date, List<LengthLengthParameter> foundLengthLengthParameters) {
|
|
| 60 |
+ super(buildMessage(decoratorService, species, ocean, sex, date, foundLengthLengthParameters));
|
|
| 48 | 61 |
this.species = species;
|
| 49 | 62 |
this.ocean = ocean;
|
| 50 | 63 |
this.sex = sex;
|
| ... | ... | @@ -52,6 +65,18 @@ public class DuplicateLengthLengthParameterException extends RuntimeException { |
| 52 | 65 |
this.foundLengthLengthParameters = foundLengthLengthParameters;
|
| 53 | 66 |
}
|
| 54 | 67 |
|
| 68 |
+ private static String buildMessage(DecoratorService decoratorService, Species species, Ocean ocean, Sex sex, Date date, List<LengthLengthParameter> foundLengthLengthParameters) {
|
|
| 69 |
+ ReferentialEntityReferenceBinderSupport<LengthLengthParameterDto, LengthLengthParameterReference, LengthLengthParameter> entityContext = DbModelHelper.fromReferentialEntity(LengthLengthParameter.class).toEntityReferenceBinder();
|
|
| 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 -> entityContext.toReference(referentialLocale, e)).map(decoratorService::toString).collect(Collectors.joining("\n * "))
|
|
| 77 |
+ );
|
|
| 78 |
+ }
|
|
| 79 |
+ |
|
| 55 | 80 |
public Species getSpecies() {
|
| 56 | 81 |
return species;
|
| 57 | 82 |
}
|
| ... | ... | @@ -22,8 +22,20 @@ package fr.ird.observe.entities.referentiel; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
+import fr.ird.observe.binder.referential.ReferentialEntityReferenceBinderSupport;
|
|
| 26 |
+import fr.ird.observe.dto.decoration.DecoratorService;
|
|
| 27 |
+import fr.ird.observe.dto.referential.LengthWeightParameterDto;
|
|
| 28 |
+import fr.ird.observe.dto.referential.LengthWeightParameterReference;
|
|
| 29 |
+import fr.ird.observe.dto.referential.ReferentialDto;
|
|
| 30 |
+import fr.ird.observe.dto.referential.ReferentialLocale;
|
|
| 31 |
+import fr.ird.observe.spi.DbModelHelper;
|
|
| 32 |
+import fr.ird.observe.spi.context.ReferentialEntityContext;
|
|
| 33 |
+ |
|
| 25 | 34 |
import java.util.Date;
|
| 26 | 35 |
import java.util.List;
|
| 36 |
+import java.util.stream.Collectors;
|
|
| 37 |
+ |
|
| 38 |
+import static io.ultreia.java4all.i18n.I18n.t;
|
|
| 27 | 39 |
|
| 28 | 40 |
/**
|
| 29 | 41 |
* Created on 28/08/15.
|
| ... | ... | @@ -44,7 +56,8 @@ public class DuplicateLengthWeightParameterException extends RuntimeException { |
| 44 | 56 |
|
| 45 | 57 |
protected final List<LengthWeightParameter> foundLengthWeightParameters;
|
| 46 | 58 |
|
| 47 |
- public DuplicateLengthWeightParameterException(Species species, Ocean ocean, Sex sex, Date date, List<LengthWeightParameter> foundLengthWeightParameters) {
|
|
| 59 |
+ public DuplicateLengthWeightParameterException(DecoratorService decoratorService, Species species, Ocean ocean, Sex sex, Date date, List<LengthWeightParameter> foundLengthWeightParameters) {
|
|
| 60 |
+ super(buildMessage(decoratorService, species, ocean, sex, date, foundLengthWeightParameters));
|
|
| 48 | 61 |
this.species = species;
|
| 49 | 62 |
this.ocean = ocean;
|
| 50 | 63 |
this.sex = sex;
|
| ... | ... | @@ -52,6 +65,18 @@ public class DuplicateLengthWeightParameterException extends RuntimeException { |
| 52 | 65 |
this.foundLengthWeightParameters = foundLengthWeightParameters;
|
| 53 | 66 |
}
|
| 54 | 67 |
|
| 68 |
+ private static String buildMessage(DecoratorService decoratorService, Species species, Ocean ocean, Sex sex, Date date, List<LengthWeightParameter> foundLengthWeightParameters) {
|
|
| 69 |
+ ReferentialEntityReferenceBinderSupport<LengthWeightParameterDto, LengthWeightParameterReference, LengthWeightParameter> entityContext = DbModelHelper.fromReferentialEntity(LengthWeightParameter.class).toEntityReferenceBinder();
|
|
| 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 -> entityContext.toReference(referentialLocale, e)).map(decoratorService::toString).collect(Collectors.joining("\n * "))
|
|
| 77 |
+ );
|
|
| 78 |
+ }
|
|
| 79 |
+ |
|
| 55 | 80 |
public Species getSpecies() {
|
| 56 | 81 |
return species;
|
| 57 | 82 |
}
|
| ... | ... | @@ -22,8 +22,15 @@ package fr.ird.observe.entities.referentiel; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
+import fr.ird.observe.dto.decoration.DecoratorService;
|
|
| 26 |
+import fr.ird.observe.dto.reference.ReferentialDtoReference;
|
|
| 27 |
+import fr.ird.observe.dto.referential.ReferentialDto;
|
|
| 28 |
+import fr.ird.observe.spi.DbModelHelper;
|
|
| 29 |
+ |
|
| 25 | 30 |
import java.util.Date;
|
| 26 | 31 |
|
| 32 |
+import static io.ultreia.java4all.i18n.I18n.t;
|
|
| 33 |
+ |
|
| 27 | 34 |
/**
|
| 28 | 35 |
* Created on 29/08/15.
|
| 29 | 36 |
*
|
| ... | ... | @@ -41,13 +48,23 @@ public class LengthLengthParameterNotFoundException extends RuntimeException { |
| 41 | 48 |
|
| 42 | 49 |
protected final Date date;
|
| 43 | 50 |
|
| 44 |
- public LengthLengthParameterNotFoundException(Species species, Ocean ocean, Sex sex, Date date) {
|
|
| 51 |
+ public LengthLengthParameterNotFoundException(DecoratorService decoratorService, Species species, Ocean ocean, Sex sex, Date date) {
|
|
| 52 |
+ super(buildMessage(decoratorService, species, ocean, sex, date));
|
|
| 45 | 53 |
this.species = species;
|
| 46 | 54 |
this.ocean = ocean;
|
| 47 | 55 |
this.sex = sex;
|
| 48 | 56 |
this.date = date;
|
| 49 | 57 |
}
|
| 50 | 58 |
|
| 59 |
+ private static String buildMessage(DecoratorService decoratorService, Species species, Ocean ocean, Sex sex, Date date) {
|
|
| 60 |
+ |
|
| 61 |
+ return t("observe.error.LengthLengthParameterNotFoundException",
|
|
| 62 |
+ LengthLengthParameterNotFoundException.toString(decoratorService, species),
|
|
| 63 |
+ LengthLengthParameterNotFoundException.toString(decoratorService, ocean),
|
|
| 64 |
+ LengthLengthParameterNotFoundException.toString(decoratorService, sex),
|
|
| 65 |
+ date);
|
|
| 66 |
+ }
|
|
| 67 |
+ |
|
| 51 | 68 |
public Species getSpecies() {
|
| 52 | 69 |
return species;
|
| 53 | 70 |
}
|
| ... | ... | @@ -64,4 +81,10 @@ public class LengthLengthParameterNotFoundException extends RuntimeException { |
| 64 | 81 |
return date;
|
| 65 | 82 |
}
|
| 66 | 83 |
|
| 84 |
+ static <E extends ObserveReferentialEntity> String toString(DecoratorService decoratorService, E entity) {
|
|
| 85 |
+ if (entity == null) {
|
|
| 86 |
+ return null;
|
|
| 87 |
+ }
|
|
| 88 |
+ return decoratorService.toString(DbModelHelper.fromReferentialEntity(entity).toEntityReferenceBinder().toReference(decoratorService.getReferentialLocale(), entity));
|
|
| 89 |
+ }
|
|
| 67 | 90 |
}
|
| ... | ... | @@ -22,6 +22,7 @@ package fr.ird.observe.entities.referentiel; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
+import fr.ird.observe.dto.decoration.DecoratorService;
|
|
| 25 | 26 |
import fr.ird.observe.persistence.ObserveTopiaDaoSupplier;
|
| 26 | 27 |
import org.apache.commons.collections4.CollectionUtils;
|
| 27 | 28 |
|
| ... | ... | @@ -49,6 +50,7 @@ public class LengthLengthParameters { |
| 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 |
*
|
| 53 |
+ * @param decoratorService decorator service
|
|
| 52 | 54 |
* @param daoSupplier la transaction en cours d'utilisation
|
| 53 | 55 |
* @param species l'espèce sur lequel on recherche le paramétrage
|
| 54 | 56 |
* @param ocean l'ocean recherché (peut être null)
|
| ... | ... | @@ -59,7 +61,7 @@ public class LengthLengthParameters { |
| 59 | 61 |
* @return le paramétrage adéquate
|
| 60 | 62 |
* @since 1.5
|
| 61 | 63 |
*/
|
| 62 |
- public static Optional<LengthLengthParameter> findLengthLengthParameter(ObserveTopiaDaoSupplier daoSupplier,
|
|
| 64 |
+ public static Optional<LengthLengthParameter> findLengthLengthParameter(DecoratorService decoratorService, ObserveTopiaDaoSupplier daoSupplier,
|
|
| 63 | 65 |
Species species,
|
| 64 | 66 |
Ocean ocean,
|
| 65 | 67 |
Sex sex,
|
| ... | ... | @@ -85,7 +87,7 @@ public class LengthLengthParameters { |
| 85 | 87 |
}
|
| 86 | 88 |
|
| 87 | 89 |
if (CollectionUtils.isEmpty(list)) {
|
| 88 |
- throw new LengthLengthParameterNotFoundException(species, ocean, sex, date);
|
|
| 90 |
+ throw new LengthLengthParameterNotFoundException(decoratorService, species, ocean, sex, date);
|
|
| 89 | 91 |
}
|
| 90 | 92 |
|
| 91 | 93 |
// if (inputSizeMeasureType != null) {
|
| ... | ... | @@ -116,193 +118,14 @@ public class LengthLengthParameters { |
| 116 | 118 |
// au final il ne devrait en rester qu'un
|
| 117 | 119 |
|
| 118 | 120 |
if (list.size() > 1) {
|
| 119 |
- throw new DuplicateLengthLengthParameterException(species, ocean, sex, date, list);
|
|
| 121 |
+ throw new DuplicateLengthLengthParameterException(decoratorService, species, ocean, sex, date, list);
|
|
| 120 | 122 |
}
|
| 121 | 123 |
|
| 122 | 124 |
return Optional.of(list.get(0));
|
| 123 |
- |
|
| 124 | 125 |
}
|
| 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 | 126 |
|
| 210 | 127 |
private static Sex getUnknownSex(ObserveTopiaDaoSupplier daoSupplier) {
|
| 211 | 128 |
return daoSupplier.getSexDao().forCodeEquals("0").findUnique();
|
| 212 | 129 |
}
|
| 213 | 130 |
|
| 214 |
-// public static List<LengthLengthParameter> findBySpecies(ObserveTopiaDaoSupplier daoSupplier, Species species) {
|
|
| 215 |
-//
|
|
| 216 |
-// LengthLengthParameterTopiaDao dao = daoSupplier.getLengthLengthParameterDao();
|
|
| 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 |
- |
|
| 308 | 131 |
}
|
| ... | ... | @@ -22,7 +22,15 @@ package fr.ird.observe.entities.referentiel; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
+import fr.ird.observe.dto.decoration.DecoratorService;
|
|
| 26 |
+import fr.ird.observe.dto.referential.SpeciesDto;
|
|
| 27 |
+import fr.ird.observe.spi.DbModelHelper;
|
|
| 28 |
+import fr.ird.observe.spi.DtoModelHelper;
|
|
| 29 |
+ |
|
| 25 | 30 |
import java.util.Date;
|
| 31 |
+import java.util.stream.Collectors;
|
|
| 32 |
+ |
|
| 33 |
+import static io.ultreia.java4all.i18n.I18n.t;
|
|
| 26 | 34 |
|
| 27 | 35 |
/**
|
| 28 | 36 |
* Created on 29/08/15.
|
| ... | ... | @@ -41,13 +49,23 @@ public class LengthWeightParameterNotFoundException extends RuntimeException { |
| 41 | 49 |
|
| 42 | 50 |
protected final Date date;
|
| 43 | 51 |
|
| 44 |
- 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));
|
|
| 45 | 54 |
this.species = species;
|
| 46 | 55 |
this.ocean = ocean;
|
| 47 | 56 |
this.sex = sex;
|
| 48 | 57 |
this.date = date;
|
| 49 | 58 |
}
|
| 50 | 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 |
+ |
|
| 51 | 69 |
public Species getSpecies() {
|
| 52 | 70 |
return species;
|
| 53 | 71 |
}
|
| ... | ... | @@ -22,6 +22,7 @@ package fr.ird.observe.entities.referentiel; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
+import fr.ird.observe.dto.decoration.DecoratorService;
|
|
| 25 | 26 |
import fr.ird.observe.persistence.ObserveTopiaDaoSupplier;
|
| 26 | 27 |
import org.apache.commons.collections4.CollectionUtils;
|
| 27 | 28 |
|
| ... | ... | @@ -47,16 +48,17 @@ public class LengthWeightParameters { |
| 47 | 48 |
* <p>
|
| 48 | 49 |
* 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).
|
| 49 | 50 |
*
|
| 50 |
- * @param daoSupplier la transaction en cours d'utilisation
|
|
| 51 |
- * @param species l'espèce sur lequel on recherche le paramétrage
|
|
| 52 |
- * @param sex le sexe recherché (on essayera sans sexe (sexe.code=0) si non trouvé)
|
|
| 53 |
- * @param ocean l'ocean recherché (peut être null)
|
|
| 54 |
- * @param date le jour recherché
|
|
| 55 |
- * @param sizeMeasureType le type de mensuration recherché
|
|
| 51 |
+ * @param decoratorService decorator service
|
|
| 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é
|
|
| 56 | 58 |
* @return le paramétrage adéquate
|
| 57 | 59 |
* @since 1.5
|
| 58 | 60 |
*/
|
| 59 |
- public static LengthWeightParameter findLengthWeightParameter(ObserveTopiaDaoSupplier daoSupplier,
|
|
| 61 |
+ public static LengthWeightParameter findLengthWeightParameter(DecoratorService decoratorService, ObserveTopiaDaoSupplier daoSupplier,
|
|
| 60 | 62 |
Species species, Sex sex, Ocean ocean, Date date, SizeMeasureType sizeMeasureType) {
|
| 61 | 63 |
|
| 62 | 64 |
// Sex unknownSex = getUnknownSex(daoSupplier);
|
| ... | ... | @@ -77,7 +79,7 @@ public class LengthWeightParameters { |
| 77 | 79 |
// }
|
| 78 | 80 |
|
| 79 | 81 |
if (CollectionUtils.isEmpty(list)) {
|
| 80 |
- throw new LengthWeightParameterNotFoundException(species, ocean, sex, date);
|
|
| 82 |
+ throw new LengthWeightParameterNotFoundException(decoratorService, species, ocean, sex, date);
|
|
| 81 | 83 |
}
|
| 82 | 84 |
|
| 83 | 85 |
// if (sizeMeasureType != null) {
|
| ... | ... | @@ -96,190 +98,11 @@ public class LengthWeightParameters { |
| 96 | 98 |
// au final il ne devrait en rester qu'un
|
| 97 | 99 |
|
| 98 | 100 |
if (list.size() > 1) {
|
| 99 |
- throw new DuplicateLengthWeightParameterException(species, ocean, sex, date, list);
|
|
| 101 |
+ throw new DuplicateLengthWeightParameterException(decoratorService, species, ocean, sex, date, list);
|
|
| 100 | 102 |
}
|
| 101 | 103 |
|
| 102 | 104 |
return Objects.requireNonNull(list.get(0));
|
| 103 | 105 |
|
| 104 | 106 |
}
|
| 105 | 107 |
|
| 106 |
-// /**
|
|
| 107 |
-// * Recherche de la liste des {@link LengthWeightParameter} à partir des paramètres donnés.
|
|
| 108 |
-// * <p>
|
|
| 109 |
-// * La recherche peut ne peut être aussi exacte que les paramètres donnés :
|
|
| 110 |
-// * <p>
|
|
| 111 |
-// * Dans le cas d'une espèce faune, si non trouvé alors on recherche sur son
|
|
| 112 |
-// * speciesGroup d'espèce.
|
|
| 113 |
-// * <p>
|
|
| 114 |
-// * Si non trouvé pour l'océan donné (et que celui-ci est non null), alors on
|
|
| 115 |
-// * recherche avec un ocean vide.
|
|
| 116 |
-// *
|
|
| 117 |
-// * @param daoSupplier la transaction en cours d'utilisation
|
|
| 118 |
-// * @param species l'espèce sur lequel on recherche le paramétrage
|
|
| 119 |
-// * @param ocean l'ocean recherché (peut être null)
|
|
| 120 |
-// * @param sex le sexe recherché (on essayera sans sexe (sexe.code=0) si non trouvé)
|
|
| 121 |
-// * @param date le jour recherché
|
|
| 122 |
-// * @return le paramétrage adéquate
|
|
| 123 |
-// * @since 1.5
|
|
| 124 |
-// */
|
|
| 125 |
-// public static List<LengthWeightParameter> findLengthWeightParameter0(ObserveTopiaDaoSupplier daoSupplier,
|
|
| 126 |
-// Species species,
|
|
| 127 |
-// Ocean ocean,
|
|
| 128 |
-// Sex sex,
|
|
| 129 |
-// Date date) {
|
|
| 130 |
-//
|
|
| 131 |
-// Objects.requireNonNull(daoSupplier, "daoSupplier parameter can't be null");
|
|
| 132 |
-// Objects.requireNonNull(species, "species parameter can't be null");
|
|
| 133 |
-// Objects.requireNonNull(sex, "sex parameter can't be null");
|
|
| 134 |
-//
|
|
| 135 |
-// List<LengthWeightParameter> list = findBySpecies(daoSupplier, species);
|
|
| 136 |
-//
|
|
| 137 |
-// if (CollectionUtils.isEmpty(list)) {
|
|
| 138 |
-//
|
|
| 139 |
-// // aucun parametrage pour le type donne
|
|
| 140 |
-// return null;
|
|
| 141 |
-// }
|
|
| 142 |
-//
|
|
| 143 |
-// // filtrage par ocean
|
|
| 144 |
-// List<LengthWeightParameter> filterByOcean = filterByOcean(list, ocean);
|
|
| 145 |
-//
|
|
| 146 |
-// if (CollectionUtils.isEmpty(filterByOcean) && ocean != null) {
|
|
| 147 |
-//
|
|
| 148 |
-// // filtre par ocean null
|
|
| 149 |
-// filterByOcean = filterByOcean(list, null);
|
|
| 150 |
-// }
|
|
| 151 |
-// list = filterByOcean;
|
|
| 152 |
-//
|
|
| 153 |
-// if (CollectionUtils.isEmpty(list)) {
|
|
| 154 |
-//
|
|
| 155 |
-// // pas d'ocean adequate
|
|
| 156 |
-// return null;
|
|
| 157 |
-// }
|
|
| 158 |
-//
|
|
| 159 |
-// // filtrage par sexe
|
|
| 160 |
-// list = filterBySexe(list, sex);
|
|
| 161 |
-//
|
|
| 162 |
-// if (CollectionUtils.isEmpty(list)) {
|
|
| 163 |
-//
|
|
| 164 |
-// // pas de sexe adequate
|
|
| 165 |
-// return null;
|
|
| 166 |
-// }
|
|
| 167 |
-//
|
|
| 168 |
-// // filtrage par startDate de validite
|
|
| 169 |
-// list = filterByDateDebutValidite(list, date);
|
|
| 170 |
-//
|
|
| 171 |
-// if (CollectionUtils.isEmpty(list)) {
|
|
| 172 |
-//
|
|
| 173 |
-// // pas de date de debut adequate
|
|
| 174 |
-// return null;
|
|
| 175 |
-// }
|
|
| 176 |
-//
|
|
| 177 |
-// // filtrage par endDate de validite
|
|
| 178 |
-// list = filterByDateFinValidite(list, date);
|
|
| 179 |
-//
|
|
| 180 |
-// if (CollectionUtils.isEmpty(list)) {
|
|
| 181 |
-//
|
|
| 182 |
-// // pas de date de fin adequate
|
|
| 183 |
-// return null;
|
|
| 184 |
-// }
|
|
| 185 |
-//
|
|
| 186 |
-// return list;
|
|
| 187 |
-//
|
|
| 188 |
-// }
|
|
| 189 |
- |
|
| 190 |
-// private static Sex getUnknownSex(ObserveTopiaDaoSupplier daoSupplier) {
|
|
| 191 |
-// return daoSupplier.getSexDao().forCodeEquals("0").findUnique();
|
|
| 192 |
-// }
|
|
| 193 |
- |
|
| 194 |
-// public static List<LengthWeightParameter> findBySpecies(ObserveTopiaDaoSupplier daoSupplier, Species species) {
|
|
| 195 |
-//
|
|
| 196 |
-// LengthWeightParameterTopiaDao dao = daoSupplier.getLengthWeightParameterDao();
|
|
| 197 |
-//
|
|
| 198 |
-// List<LengthWeightParameter> list = dao.forSpeciesEquals(species).findAll();
|
|
| 199 |
-//
|
|
| 200 |
-// // on supprime les paramétrages qui ont a=0 ou a=null ou b=0 ou b = null
|
|
| 201 |
-// Iterator<LengthWeightParameter> itr = list.iterator();
|
|
| 202 |
-// while (itr.hasNext()) {
|
|
| 203 |
-// LengthWeightParameter p = itr.next();
|
|
| 204 |
-// Double a = p.getCoefficientValue(FormulaHelper.COEFFICIENT_A);
|
|
| 205 |
-// if (a == null || a == 0) {
|
|
| 206 |
-// itr.remove();
|
|
| 207 |
-// continue;
|
|
| 208 |
-// }
|
|
| 209 |
-//
|
|
| 210 |
-// Double b = p.getCoefficientValue(FormulaHelper.COEFFICIENT_B);
|
|
| 211 |
-// // on autorise d'avoir b à 0 (mais cela ne permet plus de calculer la taille à partir du poids)
|
|
| 212 |
-//// if (b == null || b == 0) {
|
|
| 213 |
-// if (b == null) {
|
|
| 214 |
-// itr.remove();
|
|
| 215 |
-// }
|
|
| 216 |
-// }
|
|
| 217 |
-// return list;
|
|
| 218 |
-//
|
|
| 219 |
-// }
|
|
| 220 |
-//
|
|
| 221 |
-// public static List<LengthWeightParameter> filterByOcean(List<LengthWeightParameter> list, Ocean ocean) {
|
|
| 222 |
-// List<LengthWeightParameter> result = new ArrayList<>();
|
|
| 223 |
-// if (ocean == null) {
|
|
| 224 |
-//
|
|
| 225 |
-// // on n'accepte que les parametrage sans ocean
|
|
| 226 |
-// for (LengthWeightParameter parametrageLengthWeight : list) {
|
|
| 227 |
-// if (parametrageLengthWeight.getOcean() == null) {
|
|
| 228 |
-// result.add(parametrageLengthWeight);
|
|
| 229 |
-// }
|
|
| 230 |
-// }
|
|
| 231 |
-// } else {
|
|
| 232 |
-// for (LengthWeightParameter parametrageLengthWeight : list) {
|
|
| 233 |
-// if (ocean.equals(parametrageLengthWeight.getOcean())) {
|
|
| 234 |
-// result.add(parametrageLengthWeight);
|
|
| 235 |
-// }
|
|
| 236 |
-// }
|
|
| 237 |
-// }
|
|
| 238 |
-// return result;
|
|
| 239 |
-// }
|
|
| 240 |
-//
|
|
| 241 |
-// public static List<LengthWeightParameter> filterBySexe(List<LengthWeightParameter> list, Sex sex) {
|
|
| 242 |
-// return list.stream().filter(l -> l.getSex() == sex).collect(Collectors.toList());
|
|
| 243 |
-// }
|
|
| 244 |
-//
|
|
| 245 |
-// public static List<LengthWeightParameter> filterBySizeMeasureType(List<LengthWeightParameter> list, SizeMeasureType sizeMeasureType) {
|
|
| 246 |
-// return list.stream().filter(l -> l.getSizeMeasureType() == sizeMeasureType).collect(Collectors.toList());
|
|
| 247 |
-// }
|
|
| 248 |
-//
|
|
| 249 |
-// public static List<LengthWeightParameter> filterByDateDebutValidite(List<LengthWeightParameter> list, Date startDate) {
|
|
| 250 |
-// return list.stream()
|
|
| 251 |
-// .filter(l -> l.getStartDate() == null || l.getStartDate().before(startDate) || l.getStartDate().equals(startDate))
|
|
| 252 |
-// .collect(Collectors.toList());
|
|
| 253 |
-// }
|
|
| 254 |
-//
|
|
| 255 |
-// public static List<LengthWeightParameter> filterByDateFinValidite(List<LengthWeightParameter> list, Date endDate) {
|
|
| 256 |
-// List<LengthWeightParameter> result = new ArrayList<>();
|
|
| 257 |
-//
|
|
| 258 |
-// if (endDate == null) {
|
|
| 259 |
-// // on n'accepte que les parametrages selon les critères suivants :
|
|
| 260 |
-// // - sans date de fin (i.e en cours de validite)
|
|
| 261 |
-// for (LengthWeightParameter parametrageLengthWeight : list) {
|
|
| 262 |
-//
|
|
| 263 |
-// Date date = parametrageLengthWeight.getEndDate();
|
|
| 264 |
-// if (date == null) {
|
|
| 265 |
-// result.add(parametrageLengthWeight);
|
|
| 266 |
-// }
|
|
| 267 |
-// }
|
|
| 268 |
-// } else {
|
|
| 269 |
-// // on n'accepte que les parametrages selon les critères suivants :
|
|
| 270 |
-// // - sans date de fin (i.e en cours de validite)
|
|
| 271 |
-// // - ceux dont la date de fin est avant la date de fin donnée
|
|
| 272 |
-// for (LengthWeightParameter parametrageLengthWeight : list) {
|
|
| 273 |
-//
|
|
| 274 |
-// Date date = parametrageLengthWeight.getEndDate();
|
|
| 275 |
-// if (date == null ||
|
|
| 276 |
-// date.after(endDate) ||
|
|
| 277 |
-// date.equals(endDate)) {
|
|
| 278 |
-// result.add(parametrageLengthWeight);
|
|
| 279 |
-// }
|
|
| 280 |
-// }
|
|
| 281 |
-// }
|
|
| 282 |
-// return result;
|
|
| 283 |
-// }
|
|
| 284 |
- |
|
| 285 | 108 |
}
|
| ... | ... | @@ -29,6 +29,7 @@ import fr.ird.observe.dto.data.seine.FloatingObjectDto; |
| 29 | 29 |
import fr.ird.observe.dto.data.seine.FloatingObjectPartDto;
|
| 30 | 30 |
import fr.ird.observe.dto.data.seine.NonTargetCatchComputedValueSource;
|
| 31 | 31 |
import fr.ird.observe.dto.data.seine.SchoolType;
|
| 32 |
+import fr.ird.observe.dto.decoration.DecoratorService;
|
|
| 32 | 33 |
import fr.ird.observe.dto.referential.ReferentialLocale;
|
| 33 | 34 |
import fr.ird.observe.entities.LengthWeightComputable;
|
| 34 | 35 |
import fr.ird.observe.entities.referentiel.LengthLengthParameter;
|
| ... | ... | @@ -157,7 +158,8 @@ public class ConsolidateDataServiceLocal extends ObserveServiceLocal implements |
| 157 | 158 |
|
| 158 | 159 |
FloatingObjectConsolidateEngine floatingObjectConsolidateEngine = new FloatingObjectConsolidateEngine(simplifiedObjectTypeManager);
|
| 159 | 160 |
|
| 160 |
- Optional<ConsolidateTripSeineDataResult> consolidateTripSeineDataResult = consolidateTripSeine(referenceLocale, floatingObjectConsolidateEngine, request.getTripSeineId(), failIfLengthWeightParameterNotFound, failIfLengthLengthParameterNotFound);
|
|
| 161 |
+ DecoratorService decoratorService = new DecoratorService(getReferentialLocale());
|
|
| 162 |
+ Optional<ConsolidateTripSeineDataResult> consolidateTripSeineDataResult = consolidateTripSeine(decoratorService, referenceLocale, floatingObjectConsolidateEngine, request.getTripSeineId(), failIfLengthWeightParameterNotFound, failIfLengthLengthParameterNotFound);
|
|
| 161 | 163 |
return consolidateTripSeineDataResult.orElse(null);
|
| 162 | 164 |
}
|
| 163 | 165 |
|
| ... | ... | @@ -178,7 +180,7 @@ public class ConsolidateDataServiceLocal extends ObserveServiceLocal implements |
| 178 | 180 |
return new SimplifiedObjectTypeManager(materialMapping, simplifiedObjectTypeSpecializedRules);
|
| 179 | 181 |
}
|
| 180 | 182 |
|
| 181 |
- private Optional<ConsolidateTripSeineDataResult> consolidateTripSeine(ReferentialLocale referenceLocale, FloatingObjectConsolidateEngine floatingObjectConsolidateEngine, String tripSeineId, boolean failIfLengthWeightParameterNotFound, boolean failIfLengthLengthParameterNotFound) {
|
|
| 183 |
+ private Optional<ConsolidateTripSeineDataResult> consolidateTripSeine(DecoratorService decoratorService, ReferentialLocale referenceLocale, FloatingObjectConsolidateEngine floatingObjectConsolidateEngine, String tripSeineId, boolean failIfLengthWeightParameterNotFound, boolean failIfLengthLengthParameterNotFound) {
|
|
| 182 | 184 |
|
| 183 | 185 |
log.info(String.format("Start consolidate trip: %s", tripSeineId));
|
| 184 | 186 |
|
| ... | ... | @@ -223,24 +225,25 @@ public class ConsolidateDataServiceLocal extends ObserveServiceLocal implements |
| 223 | 225 |
int routeMax = tripSeine.sizeRoute();
|
| 224 | 226 |
for (Route route : tripSeine.getRoute()) {
|
| 225 | 227 |
|
| 226 |
- String routePrefix =String.format("Route [%s/%s] ", ++routeIndex, routeMax);
|
|
| 228 |
+ String routePrefix = String.format("Route [%s/%s] ", ++routeIndex, routeMax);
|
|
| 227 | 229 |
log.info(String.format("%s Start consolidate route: %s", routePrefix, route.getTopiaId()));
|
| 228 | 230 |
int activityIndex = 0;
|
| 229 | 231 |
int activityMax = route.sizeActivitySeine();
|
| 230 | 232 |
for (ActivitySeine activitySeine : route.getActivitySeine()) {
|
| 231 | 233 |
|
| 232 |
- String activityPrefix =String.format("%s - Activity [%s/%s] ", routePrefix, ++activityIndex, activityMax);
|
|
| 234 |
+ String activityPrefix = String.format("%s - Activity [%s/%s] ", routePrefix, ++activityIndex, activityMax);
|
|
| 233 | 235 |
|
| 234 | 236 |
boolean floatingObjectEmpty = activitySeine.isFloatingObjectEmpty();
|
| 235 | 237 |
if (!activitySeine.isSetOperation() && floatingObjectEmpty) {
|
| 236 |
- log.info(String.format("%s Skip activity (No set nor dcp found): %s", activityPrefix, activitySeine.getTopiaId()));
|
|
| 237 |
- continue;
|
|
| 238 |
+ log.info(String.format("%s Skip activity (No set nor dcp found): %s", activityPrefix, activitySeine.getTopiaId()));
|
|
| 239 |
+ continue;
|
|
| 238 | 240 |
}
|
| 239 | 241 |
|
| 240 | 242 |
ConsolidateActivitySeineDataResultBuilder resultBuilder = new ConsolidateActivitySeineDataResultBuilder(applicationLocale, referenceLocale, activitySeine.getTopiaId(), ActivitySeines.decorate(referenceLocale.ordinal(), activitySeine));
|
| 241 | 243 |
|
| 242 | 244 |
ConsolidationActivitySeineDataContext activityContext = new ConsolidationActivitySeineDataContext();
|
| 243 | 245 |
activityContext.locale = applicationLocale;
|
| 246 |
+ activityContext.decoratorService = decoratorService;
|
|
| 244 | 247 |
activityContext.failIfLengthWeightParameterNotFound = failIfLengthWeightParameterNotFound;
|
| 245 | 248 |
activityContext.failIfLengthLengthParameterNotFound = failIfLengthLengthParameterNotFound;
|
| 246 | 249 |
activityContext.daoSupplier = persistenceContext;
|
| ... | ... | @@ -331,9 +334,9 @@ public class ConsolidateDataServiceLocal extends ObserveServiceLocal implements |
| 331 | 334 |
activityContext.watchTargetLength(targetLength);
|
| 332 | 335 |
|
| 333 | 336 |
updateLengthWeightAble(activityContext,
|
| 334 |
- targetLength.getSpecies(),
|
|
| 335 |
- null, /* pas de sexe precise */
|
|
| 336 |
- targetLength);
|
|
| 337 |
+ targetLength.getSpecies(),
|
|
| 338 |
+ null, /* pas de sexe precise */
|
|
| 339 |
+ targetLength);
|
|
| 337 | 340 |
|
| 338 | 341 |
activityContext.flushTargetLength();
|
| 339 | 342 |
|
| ... | ... | @@ -353,9 +356,9 @@ public class ConsolidateDataServiceLocal extends ObserveServiceLocal implements |
| 353 | 356 |
activityContext.watchNonTargetLenght(nonTargetLength);
|
| 354 | 357 |
|
| 355 | 358 |
updateLengthWeightAble(activityContext,
|
| 356 |
- nonTargetLength.getSpecies(),
|
|
| 357 |
- nonTargetLength.getSex(),
|
|
| 358 |
- nonTargetLength);
|
|
| 359 |
+ nonTargetLength.getSpecies(),
|
|
| 360 |
+ nonTargetLength.getSex(),
|
|
| 361 |
+ nonTargetLength);
|
|
| 359 | 362 |
|
| 360 | 363 |
activityContext.flushNonTargetLength();
|
| 361 | 364 |
|
| ... | ... | @@ -411,11 +414,11 @@ public class ConsolidateDataServiceLocal extends ObserveServiceLocal implements |
| 411 | 414 |
boolean notWhenArriving = !dcp.getObjectOperation().isWhenArriving();
|
| 412 | 415 |
boolean notWhenLeaving = !dcp.getObjectOperation().isWhenLeaving();
|
| 413 | 416 |
for (FloatingObjectPart floatingObjectPart : dcp.getFloatingObjectPart()) {
|
| 414 |
- if (floatingObjectPart.getWhenArriving()!=null && notWhenArriving) {
|
|
| 417 |
+ if (floatingObjectPart.getWhenArriving() != null && notWhenArriving) {
|
|
| 415 | 418 |
log.info(String.format("Set whenArriving to null for part: %s", floatingObjectPart.getTopiaId()));
|
| 416 | 419 |
floatingObjectPart.setWhenArriving(null);
|
| 417 | 420 |
}
|
| 418 |
- if (floatingObjectPart.getWhenLeaving()!=null && notWhenLeaving) {
|
|
| 421 |
+ if (floatingObjectPart.getWhenLeaving() != null && notWhenLeaving) {
|
|
| 419 | 422 |
log.info(String.format("Set whenLeaving to null for part: %s", floatingObjectPart.getTopiaId()));
|
| 420 | 423 |
floatingObjectPart.setWhenLeaving(null);
|
| 421 | 424 |
}
|
| ... | ... | @@ -27,6 +27,7 @@ import fr.ird.observe.dto.data.seine.DcpComputedValue; |
| 27 | 27 |
import fr.ird.observe.dto.data.seine.FloatingObjectDto;
|
| 28 | 28 |
import fr.ird.observe.dto.data.seine.FloatingObjectPartDto;
|
| 29 | 29 |
import fr.ird.observe.dto.data.seine.SchoolType;
|
| 30 |
+import fr.ird.observe.dto.decoration.DecoratorService;
|
|
| 30 | 31 |
import fr.ird.observe.entities.referentiel.LengthLengthParameter;
|
| 31 | 32 |
import fr.ird.observe.entities.referentiel.LengthLengthParameterNotFoundException;
|
| 32 | 33 |
import fr.ird.observe.entities.referentiel.LengthLengthParameters;
|
| ... | ... | @@ -72,6 +73,7 @@ class ConsolidationActivitySeineDataContext { |
| 72 | 73 |
boolean failIfLengthLengthParameterNotFound;
|
| 73 | 74 |
BeanMonitor targetLengthMonitor;
|
| 74 | 75 |
String activityPrefix;
|
| 76 |
+ DecoratorService decoratorService;
|
|
| 75 | 77 |
|
| 76 | 78 |
BeanMonitor nonTargetLengthMonitor;
|
| 77 | 79 |
|
| ... | ... | @@ -99,7 +101,7 @@ class ConsolidationActivitySeineDataContext { |
| 99 | 101 |
Ocean ocean = getOcean();
|
| 100 | 102 |
Date routeDate = getRouteDate();
|
| 101 | 103 |
try {
|
| 102 |
- return Optional.ofNullable(LengthWeightParameters.findLengthWeightParameter(daoSupplier, species, sex, ocean, routeDate, sizeMeasureType));
|
|
| 104 |
+ return Optional.ofNullable(LengthWeightParameters.findLengthWeightParameter(decoratorService, daoSupplier, species, sex, ocean, routeDate, sizeMeasureType));
|
|
| 103 | 105 |
} catch (LengthWeightParameterNotFoundException e) {
|
| 104 | 106 |
if (failIfLengthWeightParameterNotFound) {
|
| 105 | 107 |
throw e;
|
| ... | ... | @@ -113,7 +115,7 @@ class ConsolidationActivitySeineDataContext { |
| 113 | 115 |
Ocean ocean = getOcean();
|
| 114 | 116 |
Date routeDate = getRouteDate();
|
| 115 | 117 |
try {
|
| 116 |
- return LengthLengthParameters.findLengthLengthParameter(daoSupplier, species, ocean, sex, routeDate, inputSizeMeasureType, outputSizeMeasureType);
|
|
| 118 |
+ return LengthLengthParameters.findLengthLengthParameter(decoratorService, daoSupplier, species, ocean, sex, routeDate, inputSizeMeasureType, outputSizeMeasureType);
|
|
| 117 | 119 |
} catch (LengthLengthParameterNotFoundException e) {
|
| 118 | 120 |
if (failIfLengthLengthParameterNotFound) {
|
| 119 | 121 |
throw e;
|
| ... | ... | @@ -22,7 +22,9 @@ |
| 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;
|
|
| 25 | 26 |
import fr.ird.observe.dto.referential.ReferenceStatus;
|
| 27 |
+import fr.ird.observe.dto.referential.ReferentialLocale;
|
|
| 26 | 28 |
import fr.ird.observe.entities.referentiel.LengthWeightParameter;
|
| 27 | 29 |
import fr.ird.observe.entities.referentiel.LengthWeightParameterNotFoundException;
|
| 28 | 30 |
import fr.ird.observe.entities.referentiel.LengthWeightParameterTopiaDao;
|
| ... | ... | @@ -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,
|
| ... | ... | @@ -91,6 +94,7 @@ public class LengthWeightParemetersTest extends ServiceLocalTestSupport { |
| 91 | 94 |
@Before
|
| 92 | 95 |
public void setUp() {
|
| 93 | 96 |
|
| 97 |
+ decoratorService =new DecoratorService(ReferentialLocale.FR);
|
|
| 94 | 98 |
persistenceContext = localTestMethodResource.newPersistenceContext();
|
| 95 | 99 |
|
| 96 | 100 |
SpeciesTopiaDao speciesDAO = persistenceContext.getSpeciesDao();
|
| ... | ... | @@ -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 |
|