This is an automated email from the git hooks/post-receive script. New commit to branch feature/8194 in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 9fb2cd515f531386f01e87fb48679264fdb0db90 Author: Kevin Morin <morin@codelutin.com> Date: Fri Mar 25 17:02:52 2016 +0100 on increment et decremente l'algo à partir du moment où il y a une taille (fixes #8194) --- .../frequency/SpeciesFrequencyUIHandler.java | 112 +++++++++------------ 1 file changed, 50 insertions(+), 62 deletions(-) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java index af42159..567eb03 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java @@ -224,89 +224,77 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci CaracteristicQualitativeValue gender = row.getGender(sexCaracteristic); Optional<CaracteristicQualitativeValue> maturity = row.getMaturityState(); - // we only update the frequencies if the row is valid - if (row.isValid()) { + if (IndividualObservationBatchRowModel.PROPERTY_SIZE.equals(propertyName)) { - if (log.isDebugEnabled()) { - log.debug("Row is valid"); - } - if (IndividualObservationBatchRowModel.PROPERTY_SIZE.equals(propertyName)) { + Float oldValue = (Float) evt.getOldValue(); + Float newValue = (Float) evt.getNewValue(); - Float oldValue = (Float) evt.getOldValue(); - Float newValue = (Float) evt.getNewValue(); + if (oldValue != null) { + individualObservationUICache.decrements(gender, maturity, oldValue); + } + if (newValue != null) { + individualObservationUICache.increments(gender, maturity, newValue); + } - if (oldValue != null) { - individualObservationUICache.decrements(gender, maturity, oldValue); - } - if (newValue != null) { - individualObservationUICache.increments(gender, maturity, newValue); - } + // we only update the frequencies if the row is valid + if (row.isValid() && getModel().mustCopyIndividualObservationSize()) { + updateFrequencyRowsNumbers(oldValue, newValue); - if (getModel().mustCopyIndividualObservationSize()) { - updateFrequencyRowsNumbers(oldValue, newValue); - - Float weight = row.getWeight(); - if (getModel().mustCopyIndividualObservationWeight() && weight != null) { - updateFrequencyRowsWeights(oldValue, -weight); - updateFrequencyRowsWeights(newValue, weight); - } + Float weight = row.getWeight(); + if (getModel().mustCopyIndividualObservationWeight() && weight != null) { + updateFrequencyRowsWeights(oldValue, -weight); + updateFrequencyRowsWeights(newValue, weight); } } + } - if (getModel().mustCopyIndividualObservationWeight() - && IndividualObservationBatchRowModel.PROPERTY_WEIGHT.equals(propertyName)) { - - Float oldValue = (Float) evt.getOldValue(); - Float newValue = (Float) evt.getNewValue(); - Float weightToAdd; + if (row.isValid() && getModel().mustCopyIndividualObservationWeight() + && IndividualObservationBatchRowModel.PROPERTY_WEIGHT.equals(propertyName)) { - if (oldValue == null) { - weightToAdd = newValue; + Float oldValue = (Float) evt.getOldValue(); + Float newValue = (Float) evt.getNewValue(); + Float weightToAdd; - } else if (newValue == null) { - weightToAdd = -oldValue; + if (oldValue == null) { + weightToAdd = newValue; - } else { - weightToAdd = newValue - oldValue; - } + } else if (newValue == null) { + weightToAdd = -oldValue; - if (weightToAdd != null) { - updateFrequencyRowsWeights(row.getSize(), weightToAdd); - } + } else { + weightToAdd = newValue - oldValue; } - if (row.withSize() - && (IndividualObservationBatchRowModel.PROPERTY_DEFAULT_CARACTERISTICS.equals(propertyName) - || IndividualObservationBatchRowModel.PROPERTY_CARACTERISTICS.equals(propertyName))) { + if (weightToAdd != null) { + updateFrequencyRowsWeights(row.getSize(), weightToAdd); + } + } - CaracteristicMap oldValue = (CaracteristicMap) evt.getOldValue(); - CaracteristicMap newValue = (CaracteristicMap) evt.getNewValue(); + if (row.withSize() + && (IndividualObservationBatchRowModel.PROPERTY_DEFAULT_CARACTERISTICS.equals(propertyName) + || IndividualObservationBatchRowModel.PROPERTY_CARACTERISTICS.equals(propertyName))) { - if (log.isInfoEnabled()) { - log.info("caracteristics changed"); - } + CaracteristicMap oldValue = (CaracteristicMap) evt.getOldValue(); + CaracteristicMap newValue = (CaracteristicMap) evt.getNewValue(); - if (row.getMaturityCaracteristic().isPresent()) { - Optional<CaracteristicQualitativeValue> oldMaturity = Optional.ofNullable((CaracteristicQualitativeValue) oldValue.get(row.getMaturityCaracteristic().get())); - Optional<CaracteristicQualitativeValue> newMaturity = Optional.ofNullable((CaracteristicQualitativeValue) newValue.get(row.getMaturityCaracteristic().get())); - if (log.isInfoEnabled()) { - log.info("maturities : " + oldMaturity + " " + newMaturity); - } - if (!Objects.equals(oldMaturity, newMaturity)) { - individualObservationUICache.decrements(gender, oldMaturity, row.getSize()); - individualObservationUICache.increments(gender, newMaturity, row.getSize()); - } - } + if (row.getMaturityCaracteristic().isPresent()) { + Optional<CaracteristicQualitativeValue> oldMaturity = Optional.ofNullable((CaracteristicQualitativeValue) oldValue.get(row.getMaturityCaracteristic().get())); + Optional<CaracteristicQualitativeValue> newMaturity = Optional.ofNullable((CaracteristicQualitativeValue) newValue.get(row.getMaturityCaracteristic().get())); - CaracteristicQualitativeValue oldGender = (CaracteristicQualitativeValue) oldValue.get(sexCaracteristic); - CaracteristicQualitativeValue newGender = (CaracteristicQualitativeValue) newValue.get(sexCaracteristic); - if (!Objects.equals(oldGender, newGender)) { - individualObservationUICache.decrements(oldGender, maturity, row.getSize()); - individualObservationUICache.increments(newGender, maturity, row.getSize()); + if (!Objects.equals(oldMaturity, newMaturity)) { + individualObservationUICache.decrements(gender, oldMaturity, row.getSize()); + individualObservationUICache.increments(gender, newMaturity, row.getSize()); } + } + CaracteristicQualitativeValue oldGender = (CaracteristicQualitativeValue) oldValue.get(sexCaracteristic); + CaracteristicQualitativeValue newGender = (CaracteristicQualitativeValue) newValue.get(sexCaracteristic); + if (!Objects.equals(oldGender, newGender)) { + individualObservationUICache.decrements(oldGender, maturity, row.getSize()); + individualObservationUICache.increments(newGender, maturity, row.getSize()); } + } // if the row's valid state changes, then remove or readd it to the frequencies -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.