branch develop updated (0446a18 -> 6d0b357)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository observe. See http://git.codelutin.com/observe.git from 0446a18 [Référentiel] Ajout d'un observateur/valeur pas défaut de "code" (termine #7288) Merge branch 'feature/7288' into develop new f90e134 Nettoyage de code, renommage de variables et bien s'assurer qu'on n'écrase pas une donnée existante (refs #7285) new 6d0b357 [PS] La fonction calcul écrase une donnée observée (termine #7285) Merge branch 'feature/7285' into develop The 2 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 6d0b35714dcf20f36b215f61fc936ab5de25bfbf Merge: 0446a18 f90e134 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Aug 11 06:55:31 2015 +0200 [PS] La fonction calcul écrase une donnée observée (termine #7285) Merge branch 'feature/7285' into develop commit f90e134b09ac861fd6f9f7af5b3c030efb455767 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Aug 11 06:55:29 2015 +0200 Nettoyage de code, renommage de variables et bien s'assurer qu'on n'écrase pas une donnée existante (refs #7285) Summary of changes: .../fr/ird/observe/ConsolidateDataService.java | 238 +++++++++++---------- 1 file changed, 127 insertions(+), 111 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See http://git.codelutin.com/observe.git commit f90e134b09ac861fd6f9f7af5b3c030efb455767 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Aug 11 06:55:29 2015 +0200 Nettoyage de code, renommage de variables et bien s'assurer qu'on n'écrase pas une donnée existante (refs #7285) --- .../fr/ird/observe/ConsolidateDataService.java | 238 +++++++++++---------- 1 file changed, 127 insertions(+), 111 deletions(-) diff --git a/observe-business/src/main/java/fr/ird/observe/ConsolidateDataService.java b/observe-business/src/main/java/fr/ird/observe/ConsolidateDataService.java index ef0999e..39cd13d 100644 --- a/observe-business/src/main/java/fr/ird/observe/ConsolidateDataService.java +++ b/observe-business/src/main/java/fr/ird/observe/ConsolidateDataService.java @@ -104,11 +104,6 @@ public class ConsolidateDataService { NonTargetCatch.PROPERTY_TOTAL_COUNT_COMPUTED_SOURCE ); - protected final BeanMonitor speciesMonitor = new BeanMonitor( - NonTargetLength.PROPERTY_LENGTH_SOURCE, - NonTargetLength.PROPERTY_WEIGHT, - NonTargetLength.PROPERTY_WEIGHT_SOURCE); - protected Decorator<TripSeine> mareeDecorator; protected Decorator<Species> speciesDecorator; @@ -121,7 +116,8 @@ public class ConsolidateDataService { protected String speciesThonLabel; - protected final SendMessageAble LOG_ESSAGER = new SendMessageAble() { + protected final SendMessageAble LOG_MESSAGER = new SendMessageAble() { + @Override public void sendMessage(String message) { if (log.isInfoEnabled()) { @@ -160,14 +156,6 @@ public class ConsolidateDataService { return speciesDecorator.toString(species); } -// public String decorate(Species species) { -// if (speciesThonDecorator == null) { -// speciesThonDecorator = -// getDecoratorService().getDecoratorByType(Species.class); -// } -// return speciesThonDecorator.toString(species); -// } - public String decorate(ActivitySeine activitySeine) { if (activityDecorator == null) { activityDecorator = @@ -408,6 +396,7 @@ public class ConsolidateDataService { if (!set.isNonTargetSampleEmpty()) { samples = Collections2.filter(set.getNonTargetSample().iterator().next().getNonTargetLength(), new Predicate<NonTargetLength>() { + @Override public boolean apply(NonTargetLength input) { return species.equals(input.getSpecies()); @@ -474,49 +463,61 @@ public class ConsolidateDataService { Collection<NonTargetLength> samples, LengthWeightParameter parametrage) throws DataSourceException { - Float meanLength = null; - NonTargetCatchComputedValueSource computedSource = null; + Float meanLength = nonTargetCatch.getMeanLength(); + + if (meanLength == null) { + + // on essaye de calculer la taille moyenne à partir des échantillons - if (CollectionUtils.isNotEmpty(samples)) { + NonTargetCatchComputedValueSource computedSource = null; - // on calcul la taille moyenne à partir des échantillons - float totalTaille = 0f; - int nbIndividus = 0; - for (NonTargetLength sample : samples) { + if (CollectionUtils.isNotEmpty(samples)) { - Integer count = sample.getCount(); - Float length = sample.getLength(); + // on calcul la taille moyenne à partir des échantillons + float totalLength = 0f; + int totalCount = 0; + for (NonTargetLength sample : samples) { - if (count != null && length != null) { - nbIndividus += count; - totalTaille += length * count; + Integer count = sample.getCount(); + Float length = sample.getLength(); + + if (count != null && length != null) { + totalCount += count; + totalLength += length * count; + } + } + + if (totalCount != 0) { + + meanLength = totalLength / totalCount; + + computedSource = NonTargetCatchComputedValueSource.FROM_SAMPLE; } } - if (nbIndividus != 0) { + if (meanLength == null && parametrage != null) { - meanLength = totalTaille / nbIndividus; + // on prend directement la valeur fournie par le référentiel - computedSource = NonTargetCatchComputedValueSource.FROM_SAMPLE; + meanLength = parametrage.getMeanLength(); + computedSource = NonTargetCatchComputedValueSource.FROM_REFERENTIEL; } - } - if (meanLength == null && parametrage != null) { + if (meanLength != null) { - // on prend directement la valeur fournie par le référentiel + // la taille moyenne a pu etre calculee, on la pousse alors + nonTargetCatch.setMeanLength(meanLength); + nonTargetCatch.setMeanLengthComputedSource(computedSource); + + } - meanLength = parametrage.getMeanLength(); - computedSource = NonTargetCatchComputedValueSource.FROM_REFERENTIEL; } if (meanLength != null) { - // la taille moyenne a pu etre calculee, on la pousse alors - nonTargetCatch.setMeanLength(meanLength); - nonTargetCatch.setMeanLengthComputedSource(computedSource); - // on peut aussi relancer la calcul du cas n°1 updateNonTargetCatchByLengthWeightRelation(nonTargetCatch, parametrage); + } } @@ -526,31 +527,40 @@ public class ConsolidateDataService { LengthWeightParameter parametrage) throws DataSourceException { - if (CollectionUtils.isNotEmpty(samples)) { + Integer totalCount = nonTargetCatch.getTotalCount(); + + if (totalCount == null) { - // on calcul la taille moyenne à partir des échantillons - int nbIndividus = 0; - for (NonTargetLength sample : samples) { + if (CollectionUtils.isNotEmpty(samples)) { - Integer count = sample.getCount(); + // on calcul la nombre d'individus à partir des échantillons + totalCount = 0; + for (NonTargetLength sample : samples) { - if (count != null) { - nbIndividus += count; + Integer count = sample.getCount(); + + if (count != null) { + totalCount += count; + } } - } - if (nbIndividus != 0) { + if (totalCount != 0) { - nonTargetCatch.setTotalCount(nbIndividus); - nonTargetCatch.setTotalCountComputedSource(NonTargetCatchComputedValueSource.FROM_SAMPLE); + nonTargetCatch.setTotalCount(totalCount); + nonTargetCatch.setTotalCountComputedSource(NonTargetCatchComputedValueSource.FROM_SAMPLE); - if (nonTargetCatch.getMeanWeight() != null || nonTargetCatch.getMeanLength() != null) { - // on peut aussi relancer la calcul du cas n°1 - updateNonTargetCatchByLengthWeightRelation(nonTargetCatch, parametrage); } } + + } + + if (nonTargetCatch.getMeanWeight() != null || nonTargetCatch.getMeanLength() != null) { + + // on peut aussi relancer la calcul du cas n°1 + updateNonTargetCatchByLengthWeightRelation(nonTargetCatch, parametrage); } + } private void computeNonTargetCatchMeanValues(NonTargetCatch nonTargetCatch, @@ -558,17 +568,22 @@ public class ConsolidateDataService { if (parametrage != null) { - nonTargetCatch.setMeanLength(parametrage.getMeanLength()); - nonTargetCatch.setMeanLengthComputedSource(NonTargetCatchComputedValueSource.FROM_REFERENTIEL); + if (nonTargetCatch.getMeanLength() == null) { + nonTargetCatch.setMeanLength(parametrage.getMeanLength()); + nonTargetCatch.setMeanLengthComputedSource(NonTargetCatchComputedValueSource.FROM_REFERENTIEL); + } - nonTargetCatch.setMeanWeight(parametrage.getMeanWeight()); - nonTargetCatch.setMeanWeightComputedSource(NonTargetCatchComputedValueSource.FROM_REFERENTIEL); + if (nonTargetCatch.getMeanWeight() == null) { + nonTargetCatch.setMeanWeight(parametrage.getMeanWeight()); + nonTargetCatch.setMeanWeightComputedSource(NonTargetCatchComputedValueSource.FROM_REFERENTIEL); + } if (nonTargetCatch.getMeanWeight() != null || nonTargetCatch.getMeanLength() != null) { // on peut aussi relancer la calcul du cas n°1 updateNonTargetCatchByLengthWeightRelation(nonTargetCatch, parametrage); } + } } @@ -576,14 +591,14 @@ public class ConsolidateDataService { Float meanWeight = nonTargetCatch.getMeanWeight(); Float catchWeight = nonTargetCatch.getCatchWeight(); - Integer nbEstime = nonTargetCatch.getTotalCount(); + Integer totalCount = nonTargetCatch.getTotalCount(); String entityLabel = getNonTargetCatcheLabel(); - if (catchWeight == null && nbEstime != null && meanWeight != null) { + if (catchWeight == null && totalCount != null && meanWeight != null) { // calcul le weight poids à partir de nb estime et du poids moyen - catchWeight = meanWeight * (float) nbEstime / 1000; + catchWeight = meanWeight * (float) totalCount / 1000; nonTargetCatch.setCatchWeight(catchWeight); nonTargetCatch.setCatchWeightComputedSource(NonTargetCatchComputedValueSource.FROM_DATA); String message = String.format(MESSAGE_FORMAT_3, @@ -593,22 +608,22 @@ public class ConsolidateDataService { t("observe.common.meanWeight"), meanWeight, t("observe.common.totalCount"), - nbEstime); + totalCount); if (log.isInfoEnabled()) { log.info(message); } } - if (nbEstime == null && catchWeight != null && meanWeight != null) { + if (totalCount == null && catchWeight != null && meanWeight != null) { // calcul le nb estime à partir du poids estime et du poids moyen - nbEstime = (int) ((float) 1000 * catchWeight / meanWeight); - nonTargetCatch.setTotalCount(nbEstime); + totalCount = (int) ((float) 1000 * catchWeight / meanWeight); + nonTargetCatch.setTotalCount(totalCount); nonTargetCatch.setTotalCountComputedSource(NonTargetCatchComputedValueSource.FROM_DATA); String message = String.format(MESSAGE_FORMAT_3, entityLabel, t("observe.common.totalCount"), - nbEstime, + totalCount, t("observe.common.meanWeight"), meanWeight, t("observe.common.catchWeight"), @@ -618,13 +633,13 @@ public class ConsolidateDataService { } } - if (meanWeight == null && nbEstime != null && nbEstime != 0 && catchWeight != null && + if (meanWeight == null && totalCount != null && totalCount != 0 && catchWeight != null && !NonTargetCatchComputedValueSource.FROM_SAMPLE.equals(nonTargetCatch.getTotalCountComputedSource())) { // calcul le poids moyen à partir de nb estime et du poids estime // uniquement si le nombre estimé ne vient pas des échantillons (voir http://forge.codelutin.com/issues/4670) - meanWeight = catchWeight * (float) 1000 / (float) nbEstime; + meanWeight = catchWeight * (float) 1000 / (float) totalCount; nonTargetCatch.setMeanWeight(meanWeight); nonTargetCatch.setMeanWeightComputedSource(NonTargetCatchComputedValueSource.FROM_DATA); String message = String.format(MESSAGE_FORMAT_3, @@ -632,7 +647,7 @@ public class ConsolidateDataService { t("observe.common.meanWeight"), meanWeight, t("observe.common.totalCount"), - nbEstime, + totalCount, t("observe.common.catchWeight"), catchWeight); if (log.isInfoEnabled()) { @@ -653,23 +668,24 @@ public class ConsolidateDataService { String entityLabel = getSpeciesLabel(); Float weight = e.getWeight(); - boolean computePoids = false; - boolean computeTaille = false; - Float taille = e.getLength(); + Float length = e.getLength(); - if (weight == null && taille != null) { + boolean computeWeight = false; + boolean computeLength = false; - // on essaye de calculer le weight - computePoids = true; + if (weight == null && length != null) { + + // on essaye de calculer le poids + computeWeight = true; } - if (taille == null && weight != null) { + if (length == null && weight != null) { - // on essaye de calcule la length - computeTaille = true; + // on essaye de calcule la taille + computeLength = true; } - if (!computeTaille && !computePoids) { + if (!computeLength && !computeWeight) { // rien a calculer return; @@ -699,15 +715,15 @@ public class ConsolidateDataService { return; } - if (computeTaille) { - Float newTaille = parametrage.computeLength(weight); - if (newTaille != null) { + if (computeLength) { + Float newLength = parametrage.computeLength(weight); + if (newLength != null) { // la taille a ete calculee String message = "[" + t(entityLabel) + "] " + t("observe.message.consolidate.computed.taille", - newTaille, + newLength, weight, parametrage.getWeightLengthFormula(), parametrage.getCoefficients() @@ -715,31 +731,31 @@ public class ConsolidateDataService { if (log.isInfoEnabled()) { log.info(message); } - e.setLength(newTaille); + e.setLength(newLength); e.setLengthSource(true); return; } - // la taille n'a pas changee, on peut quitter car il est impossible + // la taille n'a pas ete changee, on peut quitter car il est impossible // de calculer et la taille et le poids... return; } // on cherche obligatoirement a calculer le poids - Float newPoids = parametrage.computeWeight(taille); - if (newPoids != null) { + Float newWeight = parametrage.computeWeight(length); + if (newWeight != null) { // le poids a ete calcule String message = "[" + t(entityLabel) + "] " + t("observe.message.consolidate.computed.weight", - newPoids, - taille, + newWeight, + length, parametrage.getLengthWeightFormula(), parametrage.getCoefficients()); if (log.isInfoEnabled()) { log.info(message); } - e.setWeight(newPoids); + e.setWeight(newWeight); e.setWeightSource(true); } } @@ -751,23 +767,23 @@ public class ConsolidateDataService { String entityLabel = getSpeciesLabel(); Float weight = e.getWeight(); - boolean computePoids = false; - boolean computeTaille = false; - Float taille = e.getLength(); + boolean computeWeight = false; + boolean computeLength = false; + Float length = e.getLength(); - if (weight == null && taille != null) { + if (weight == null && length != null) { - // on essaye de calculer le weight - computePoids = true; + // on essaye de calculer le poids + computeWeight = true; } - if (taille == null && weight != null) { + if (length == null && weight != null) { - // on essaye de calcule la length - computeTaille = true; + // on essaye de calcule la taille + computeLength = true; } - if (!computeTaille && !computePoids) { + if (!computeLength && !computeWeight) { // rien a calculer return; @@ -787,15 +803,15 @@ public class ConsolidateDataService { return; } - if (computeTaille) { - Float newTaille = parametrage.computeLength(weight); - if (newTaille != null) { + if (computeLength) { + Float newLength = parametrage.computeLength(weight); + if (newLength != null) { // la taille a ete calculee String message = "[" + t(entityLabel) + "] " + t("observe.message.consolidate.computed.taille", - newTaille, + newLength, weight, parametrage.getWeightLengthFormula(), parametrage.getCoefficients() @@ -803,31 +819,31 @@ public class ConsolidateDataService { if (log.isInfoEnabled()) { log.info(message); } - e.setLength(newTaille); + e.setLength(newLength); e.setLengthSource(true); return; } - // la taille n'a pas changee, on peut quitter car il est impossible + // la taille n'a pas ete changee, on peut quitter car il est impossible // de calculer et la taille et le poids... return; } - // on cherche obligatoirement a calculer le weight - Float newPoids = parametrage.computeWeight(taille); - if (newPoids != null) { + // on cherche obligatoirement a calculer le poids + Float newWeight = parametrage.computeWeight(length); + if (newWeight != null) { // le weight a ete calcule String message = "[" + t(entityLabel) + "] " + t("observe.message.consolidate.computed.weight", - newPoids, - taille, + newWeight, + length, parametrage.getLengthWeightFormula(), parametrage.getCoefficients()); if (log.isInfoEnabled()) { log.info(message); } - e.setWeight(newPoids); + e.setWeight(newWeight); e.setWeightSource(true); } } @@ -862,6 +878,6 @@ public class ConsolidateDataService { } protected SendMessageAble getMessager(SendMessageAble messager) { - return messager == null ? LOG_ESSAGER : messager; + return messager == null ? LOG_MESSAGER : messager; } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See http://git.codelutin.com/observe.git commit 6d0b35714dcf20f36b215f61fc936ab5de25bfbf Merge: 0446a18 f90e134 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Aug 11 06:55:31 2015 +0200 [PS] La fonction calcul écrase une donnée observée (termine #7285) Merge branch 'feature/7285' into develop .../fr/ird/observe/ConsolidateDataService.java | 238 +++++++++++---------- 1 file changed, 127 insertions(+), 111 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
participants (1)
-
codelutin.com scm