branch feature/8157-2 updated (796926f -> 4d9cc98)
This is an automated email from the git hooks/post-receive script. New change to branch feature/8157-2 in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git from 796926f ajout du nombre d'observations dans l'export + on n'exporte pas les lignes sans obs ni prelevements (refs #8157) new 4d9cc98 Improve code 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 4d9cc9861b4d3c2685c65b04e3b96dd8d4945d35 Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Apr 6 14:36:41 2016 +0200 Improve code Summary of changes: .../sampling/CruiseSamplingInternalCache.java | 38 +++++++++++----------- 1 file changed, 19 insertions(+), 19 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/8157-2 in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 4d9cc9861b4d3c2685c65b04e3b96dd8d4945d35 Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Apr 6 14:36:41 2016 +0200 Improve code --- .../sampling/CruiseSamplingInternalCache.java | 38 +++++++++++----------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingInternalCache.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingInternalCache.java index f58b0a8..a5d87be 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingInternalCache.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingInternalCache.java @@ -28,15 +28,14 @@ import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; import fr.ifremer.tutti.persistence.entities.referential.Species; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import java.io.Closeable; import java.io.Serializable; -import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashSet; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Objects; @@ -59,7 +58,7 @@ class CruiseSamplingInternalCache implements Closeable { public static String createSamplingKey(Species species, CaracteristicQualitativeValue gender, Boolean maturity, int lengthStep) { Objects.requireNonNull(species); return species.getReferenceTaxonId() + KEY_SEPARATOR + (gender == null ? "" : gender.getId()) + - KEY_SEPARATOR + (maturity == null ? "" : maturity.toString()) + KEY_SEPARATOR + lengthStep; + KEY_SEPARATOR + (maturity == null ? "" : maturity.toString()) + KEY_SEPARATOR + lengthStep; } public static String addPrefixKey(Serializable prefix, String key) { @@ -177,20 +176,19 @@ class CruiseSamplingInternalCache implements Closeable { /** * Get the number of samplings by lengthstep for a species, maturity and gender, for the lengthsteps between min size and max size + * * @return a map of the number of samplings for each lengthstep in millimeters */ public List<CacheExtractedKey> getSamplingNumbers(Map<String, Species> speciesById) { + List<CacheExtractedKey> result = new LinkedList<>(); - Iterator<Map.Entry<String, SamplingData>> iterator = data.entrySet().iterator(); - List<CacheExtractedKey> result = new ArrayList<>(data.size()); - - while (iterator.hasNext()) { - Map.Entry<String, SamplingData> entry = iterator.next(); + for (Map.Entry<String, SamplingData> entry : data.entrySet()) { SamplingData samplingData = entry.getValue(); - if (samplingData != null && !samplingData.isEmpty()) { + if (!samplingData.isEmpty()) { + String[] keyTokens = entry.getKey().split(KEY_SEPARATOR); CacheExtractedKey key = new CacheExtractedKey(); @@ -213,7 +211,7 @@ class CruiseSamplingInternalCache implements Closeable { key.setMaturity(maturity); } - nextToken = keyTokens[i++]; + nextToken = keyTokens[i]; if (!StringUtils.isEmpty(nextToken)) { int lengthStep = Integer.parseInt(nextToken); key.setLengthStep(lengthStep); @@ -226,44 +224,46 @@ class CruiseSamplingInternalCache implements Closeable { } } + return result; + } private class SamplingData { - private MutableInt observationNb = new MutableInt(0); - private MutableInt samplingNb = new MutableInt(0); + private int observationNb; + private int samplingNb; public int incrementObservationNb() { - observationNb.increment(); + observationNb++; return getObservationNb(); } public int decrementObservationNb() { - observationNb.decrement(); + observationNb--; return getObservationNb(); } public int getObservationNb() { - return observationNb.intValue(); + return observationNb; } public int incrementSamplingNb() { - samplingNb.increment(); + samplingNb++; return getSamplingNb(); } public int decrementSamplingNb() { - samplingNb.decrement(); + samplingNb--; return getSamplingNb(); } public int getSamplingNb() { - return samplingNb.intValue(); + return samplingNb; } public boolean isEmpty() { - return samplingNb.intValue() == 0 && observationNb.intValue() == 0; + return samplingNb == 0 && observationNb == 0; } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm