This is an automated email from the git hooks/post-receive script. New commit to branch feature/8204 in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit fb7af9a88a38c6192bc2187f7064447081790817 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Apr 4 15:45:53 2016 +0200 On decremente uniquement si le code matché est le plus haut + amélioration code --- .../tutti/service/sampling/CruiseSamplingCache.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingCache.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingCache.java index cfb80f0..c2a25e2 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingCache.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingCache.java @@ -355,7 +355,7 @@ public class CruiseSamplingCache implements Closeable { * @param gender le sexe de l'échantillon (peut-être null) * @param maturity la maturité de l'échantillon (peut-être null) * @param lengthStep la classe de taille de l'échantillon (en mm) - * @param samplingCode le code de prélèvement ajouté + * @param samplingCode le code de prélèvement ajouté */ public void addSampling(Integer fishingOperationId, Optional<Zone> optionalZone, @@ -593,8 +593,7 @@ public class CruiseSamplingCache implements Closeable { int operationSamplingNb = operationCache.decrementSamplingNb(operationKey); - removeSamplingCode(species.getReferenceTaxonId()); -// removeSamplingCode(species.getReferenceTaxonId(), samplingCode); + removeSamplingCode(species.getReferenceTaxonId(), samplingCode); if (log.isInfoEnabled()) { log.info("remove Sampling " + samplingKey + " => op " + operationSamplingNb + " / zone " + zoneSamplingNb + " / cruise " + totalSamplingNb); @@ -740,7 +739,7 @@ public class CruiseSamplingCache implements Closeable { // return highestSamplingCodeBySpecies.getOrDefault(speciesId, 0) + 1; } - public int addSamplingCode(Integer speciesId, String samplingCode) { + protected int addSamplingCode(Integer speciesId, String samplingCode) { String[] codeParts = samplingCode.split("#"); Integer code = Integer.parseInt(codeParts[codeParts.length - 1]); @@ -749,13 +748,13 @@ public class CruiseSamplingCache implements Closeable { // (key, highestSamplingCode) -> highestSamplingCode == null ? code : Math.max(highestSamplingCode, code)); MutableInt samplingCodeFound = highestSamplingCodeBySpecies.get(speciesId); - if (samplingCodeFound==null) { + if (samplingCodeFound == null) { samplingCodeFound = new MutableInt(code); highestSamplingCodeBySpecies.put(speciesId, samplingCodeFound); } else { samplingCodeFound.setValue(Math.max(samplingCodeFound.intValue(), code)); } - return samplingCodeFound.intValue(); + return samplingCodeFound.intValue(); // Ce code ne compile pas. // return highestSamplingCodeBySpecies.compute(speciesId, // (key, highestSamplingCode) -> { @@ -770,14 +769,12 @@ public class CruiseSamplingCache implements Closeable { } - public void removeSamplingCode(Integer speciesId) { -// public void removeSamplingCode(Integer speciesId, String samplingCode) { -// String[] codeParts = samplingCode.split("#"); -// Integer code = Integer.parseInt(codeParts[codeParts.length - 1]); + protected void removeSamplingCode(Integer speciesId, String samplingCode) { + int code = SamplingCodePrefix.extractSamplingCodeIdFromSamplingCode(samplingCode); // decrement the highest sampling code if it is this code MutableInt samplingCodeFound = highestSamplingCodeBySpecies.get(speciesId); - if (samplingCodeFound!=null) { + if (samplingCodeFound != null && code == samplingCodeFound.intValue()) { samplingCodeFound.decrement(); } // return highestSamplingCodeBySpecies.computeIfPresent(speciesId, -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.