This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See http://git.codelutin.com/tutti.git commit d5580b6d1ec38fe5d8b235ef85aa9f5735aadc8f Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Feb 17 16:50:19 2015 +0100 utilisation de TaxonCache dans les handler d'ui --- .../frequency/BenthosFrequencyUIHandler.java | 30 +++++---------- .../CreateIndividualObservationBatchUIHandler.java | 18 ++++----- .../frequency/SpeciesFrequencyUIHandler.java | 43 ++++++---------------- 3 files changed, 30 insertions(+), 61 deletions(-) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java index b9e15de..63f95f0 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java @@ -23,12 +23,12 @@ package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency; */ import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; -import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.persistence.entities.referential.TaxonCache; +import fr.ifremer.tutti.persistence.entities.referential.TaxonCaches; import fr.ifremer.tutti.type.WeightUnit; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler; @@ -85,8 +85,6 @@ public class BenthosFrequencyUIHandler extends AbstractTuttiTableUIHandler<Benth private BenthosFrequencyCellComponent.FrequencyCellEditor frequencyEditor; - private Map<Integer, SpeciesProtocol> speciesProtocol; - private Map<String, Caracteristic> lengthStepCaracteristics; private JFreeChart chart; @@ -100,6 +98,8 @@ public class BenthosFrequencyUIHandler extends AbstractTuttiTableUIHandler<Benth protected ApplyBenthosFrequencyRafaleAction applyBenthosFrequencyRafaleAction; + private TaxonCache taxonCache; + public BenthosFrequencyUIHandler() { super(BenthosFrequencyRowModel.PROPERTY_LENGTH_STEP, BenthosFrequencyRowModel.PROPERTY_NUMBER, @@ -207,14 +207,7 @@ public class BenthosFrequencyUIHandler extends AbstractTuttiTableUIHandler<Benth BenthosFrequencyUIModel model = getModel(); - if (getContext().isProtocolFilled()) { - - // FIXME 20130128 kmorin: the species have no technical id - speciesProtocol = getPersistenceService().toBenthosProtocolMap(); - - } else { - speciesProtocol = Maps.newHashMap(); - } + taxonCache = TaxonCaches.createBenthosCacheWithoutVernacularCode(getPersistenceService(), getDataContext().getProtocol()); Caracteristic modelCaracteristic = model.getLengthStepCaracteristic(); initBeanFilterableComboBox(ui.getLengthStepCaracteristicComboBox(), @@ -526,14 +519,12 @@ public class BenthosFrequencyUIHandler extends AbstractTuttiTableUIHandler<Benth Species species = speciesBatch.getSpecies(); - SpeciesProtocol sProtocol = speciesProtocol.get(species.getReferenceTaxonId()); - - if (sProtocol != null) { + String lengthStepPmfmId = taxonCache.getLengthStepPmfmId(species); - String lengthStepPmfmId = sProtocol.getLengthStepPmfmId(); + if (lengthStepPmfmId != null) { lengthStepCaracteristic = lengthStepCaracteristics.get(lengthStepPmfmId); - lengthStep = sProtocol.getLengthStep(); + lengthStep = taxonCache.getLengthStep(species); if (log.isInfoEnabled()) { log.info("Use existing from protocol lengthStep " + @@ -551,9 +542,8 @@ public class BenthosFrequencyUIHandler extends AbstractTuttiTableUIHandler<Benth FrequencyConfigurationMode mode = FrequencyConfigurationMode.AUTO_GEN; if (lengthStepCaracteristic == null) { - Integer taxonId = speciesBatch.getSpecies().getReferenceTaxonId(); - SpeciesProtocol speciesProtocol = this.speciesProtocol.get(taxonId); - if (speciesProtocol == null || speciesProtocol.getLengthStepPmfmId() == null) { + String lengthStepPmfmId = taxonCache.getLengthStepPmfmId(speciesBatch.getSpecies()); + if (lengthStepPmfmId == null) { mode = FrequencyConfigurationMode.SIMPLE_COUNTING; } } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/CreateIndividualObservationBatchUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/CreateIndividualObservationBatchUIHandler.java index cdd7cb0..8a03c1b 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/CreateIndividualObservationBatchUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/CreateIndividualObservationBatchUIHandler.java @@ -27,10 +27,11 @@ import com.google.common.collect.Maps; import com.google.common.collect.Sets; import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch; -import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.persistence.entities.referential.TaxonCache; +import fr.ifremer.tutti.persistence.entities.referential.TaxonCaches; import fr.ifremer.tutti.service.DecoratorService; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler; @@ -42,15 +43,15 @@ import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler; import fr.ifremer.tutti.ui.swing.util.TuttiUI; import jaxx.runtime.SwingUtil; import jaxx.runtime.swing.Table; -import org.nuiton.jaxx.application.bean.JavaBeanObjectUtil; -import org.nuiton.jaxx.widgets.number.NumberEditor; import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox; import jaxx.runtime.validator.swing.SwingValidator; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.decorator.Decorator; +import org.nuiton.jaxx.application.bean.JavaBeanObjectUtil; import org.nuiton.jaxx.application.swing.util.Cancelable; +import org.nuiton.jaxx.widgets.number.NumberEditor; import javax.swing.JComponent; import javax.swing.JLabel; @@ -118,20 +119,19 @@ public class CreateIndividualObservationBatchUIHandler extends AbstractTuttiUIHa if (getDataContext().isProtocolFilled()) { - final Map<Integer, SpeciesProtocol> speciesProtocolMap = - getContext().getPersistenceService().toSpeciesProtocolMap(); - final Map<String, Caracteristic> lengthStepCaracteristicMap = TuttiEntities.splitById(lengthStepCaracteristics); + final TaxonCache taxonCache = TaxonCaches.createSpeciesCacheWithoutVernacularCode(getPersistenceService(), getDataContext().getProtocol()); + getModel().addPropertyChangeListener(IndividualObservationBatch.PROPERTY_SPECIES, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { Species species = (Species) evt.getNewValue(); if (species != null) { - SpeciesProtocol speciesProtocol = speciesProtocolMap.get(species.getReferenceTaxonId()); - if (speciesProtocol != null) { - String lengthStepPmfmId = speciesProtocol.getLengthStepPmfmId(); + + String lengthStepPmfmId = taxonCache.getLengthStepPmfmId(species); + if (lengthStepPmfmId != null) { Caracteristic lengthStepCaracteristic = lengthStepCaracteristicMap.get(lengthStepPmfmId); getModel().setLengthStepCaracteristic(lengthStepCaracteristic); } 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 4a4a574..60c44cc 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 @@ -23,15 +23,15 @@ package fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency; */ import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import fr.ifremer.tutti.ichtyometer.feed.event.FeedReaderEvent; import fr.ifremer.tutti.ichtyometer.feed.event.FeedReaderListener; import fr.ifremer.tutti.ichtyometer.feed.record.FeedReaderMeasureRecord; import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; -import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.persistence.entities.referential.TaxonCache; +import fr.ifremer.tutti.persistence.entities.referential.TaxonCaches; import fr.ifremer.tutti.type.WeightUnit; import fr.ifremer.tutti.ui.swing.TuttiUIContext; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI; @@ -90,7 +90,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci private FrequencyCellEditor frequencyEditor; - private Map<Integer, SpeciesProtocol> speciesProtocol; + private TaxonCache taxonCache; private Map<String, Caracteristic> lengthStepCaracteristics; @@ -262,14 +262,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci SpeciesFrequencyUIModel model = getModel(); - if (getContext().isProtocolFilled()) { - - // FIXME 20130128 kmorin: the species have no technical id - speciesProtocol = getPersistenceService().toSpeciesProtocolMap(); - - } else { - speciesProtocol = Maps.newHashMap(); - } + taxonCache = TaxonCaches.createSpeciesCacheWithoutVernacularCode(getPersistenceService(), getDataContext().getProtocol()); final Caracteristic modelCaracteristic = model.getLengthStepCaracteristic(); initBeanFilterableComboBox(this.ui.getLengthStepCaracteristicComboBox(), @@ -368,19 +361,6 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci } }); -// getContext().addPropertyChangeListener(TuttiUIContext.PROPERTY_ICHTYOMETER_CONNECTED, new PropertyChangeListener() { -// @Override -// public void propertyChange(PropertyChangeEvent evt) { -// SwingUtilities.invokeLater( -// new Runnable() { -// @Override -// public void run() { -// updateLogVisibility(); -// } -// }); -// } -// }); - // init histogram chart = ChartFactory.createXYBarChart(null, @@ -598,14 +578,12 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci Species species = speciesBatch.getSpecies(); - SpeciesProtocol sProtocol = speciesProtocol.get(species.getReferenceTaxonId()); - - if (sProtocol != null) { + String lengthStepPmfmId = taxonCache.getLengthStepPmfmId(species); - String lengthStepPmfmId = sProtocol.getLengthStepPmfmId(); + if (lengthStepPmfmId != null) { lengthStepCaracteristic = lengthStepCaracteristics.get(lengthStepPmfmId); - lengthStep = sProtocol.getLengthStep(); + lengthStep = taxonCache.getLengthStep(species); if (log.isInfoEnabled()) { log.info("Use existing from protocol lengthStep " + @@ -613,7 +591,9 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci decorate(lengthStepCaracteristic) + " / " + lengthStep); } + } + } if (getContext().isIchtyometerConnected()) { @@ -630,9 +610,8 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci FrequencyConfigurationMode mode = FrequencyConfigurationMode.AUTO_GEN; if (lengthStepCaracteristic == null) { - Integer taxonId = speciesBatch.getSpecies().getReferenceTaxonId(); - SpeciesProtocol speciesProtocol = this.speciesProtocol.get(taxonId); - if (speciesProtocol == null || speciesProtocol.getLengthStepPmfmId() == null) { + String speciesLengthStepPmfmId = taxonCache.getLengthStepPmfmId(speciesBatch.getSpecies()); + if (speciesLengthStepPmfmId == null) { mode = FrequencyConfigurationMode.SIMPLE_COUNTING; } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.