branch feature/6392 updated (ecc4187 -> 6fa7fe7)
This is an automated email from the git hooks/post-receive script. New change to branch feature/6392 in repository wao. See http://git.codelutin.com/wao.git from ecc4187 Lors du calcul du plan ObsMer, on ne se repose plus sur les données dénormalisées en base mais on calcul les nombres d'observations par mois en même temps que le nombre de jours par mois. En même temps, on corrige le mode de calcul en affectant la marée au mois ayant le plus de jours (testable-cl #6392) new 6fa7fe7 Extraction, dans WaoUtils, de la méthode permettant de déduire le mois sur lequel compter le contact ObsMer The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 6fa7fe7c1a598b557a90ee49d6c2a6fcd256a824 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Feb 26 14:11:16 2015 +0100 Extraction, dans WaoUtils, de la méthode permettant de déduire le mois sur lequel compter le contact ObsMer Summary of changes: .../src/main/java/fr/ifremer/wao/WaoUtils.java | 17 +++++++++++++++++ .../wao/services/service/ObsMerSamplingPlanBuilder.java | 10 +--------- 2 files changed, 18 insertions(+), 9 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/6392 in repository wao. See http://git.codelutin.com/wao.git commit 6fa7fe7c1a598b557a90ee49d6c2a6fcd256a824 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Feb 26 14:11:16 2015 +0100 Extraction, dans WaoUtils, de la méthode permettant de déduire le mois sur lequel compter le contact ObsMer --- .../src/main/java/fr/ifremer/wao/WaoUtils.java | 17 +++++++++++++++++ .../wao/services/service/ObsMerSamplingPlanBuilder.java | 10 +--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java b/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java index 0f6a1ce..0c1ebfd 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java @@ -274,4 +274,21 @@ public class WaoUtils { } }; } + + /** + * Retourne la clé qui a la plus grande valeur, en présences des valeurs égales, on privilégie + * les premières clés trouvées. + */ + public static <T> T getKeyWithHighestValue(Map<T, Integer> map) { + T keyWithHighestValue = null; + int maxObservationDays = 0; + for (Map.Entry<T, Integer> entry : map.entrySet()) { + T aKey = entry.getKey(); + Integer aObservationDays = entry.getValue(); + if (aObservationDays > maxObservationDays) { + keyWithHighestValue = aKey; + } + } + return keyWithHighestValue; + } } diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java index b7ae22c..cc7758d 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java @@ -137,15 +137,7 @@ public class ObsMerSamplingPlanBuilder { doneObservation.getObservationEndDate()); // on en déduit le mois sur lequel il faut compter l'observation - Date month = null; - int maxObservationDays = 0; - for (Map.Entry<Date, Integer> entry : observationDaysByMonthsForObservation.entrySet()) { - Date aMonth = entry.getKey(); - Integer aObservationDays = entry.getValue(); - if (aObservationDays > maxObservationDays) { - month = aMonth; - } - } + Date month = WaoUtils.getKeyWithHighestValue(observationDaysByMonthsForObservation); if (log.isDebugEnabled()) { log.debug("contact " + doneObservation + " will be added to month " + month); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm