This is an automated email from the git hooks/post-receive script. New commit to branch feature/7089 in repository tutti. See http://git.codelutin.com/tutti.git commit f1aea258af7dd09e22584686d8f604f344c05604 Author: Kevin Morin <morin@codelutin.com> Date: Wed Jan 6 17:50:27 2016 +0100 suppression des especes deja utilisée et de leurs synonymes dans la liste de toutes les espèces (fixes #7089) --- .../benthos/actions/RenameBenthosBatchAction.java | 29 +++++++++++++++------- .../species/actions/RenameSpeciesBatchAction.java | 26 +++++++++++++------ 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/actions/RenameBenthosBatchAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/actions/RenameBenthosBatchAction.java index 6ed18ff..a9b0ec3 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/actions/RenameBenthosBatchAction.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/actions/RenameBenthosBatchAction.java @@ -23,6 +23,7 @@ package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.actions; */ import com.google.common.collect.Lists; +import com.google.common.collect.Multimap; import fr.ifremer.tutti.persistence.entities.data.SampleCategory; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; import fr.ifremer.tutti.persistence.entities.referential.Species; @@ -70,22 +71,32 @@ public class RenameBenthosBatchAction extends LongActionSupport<BenthosBatchUIMo int selectedRowIndex = SwingUtil.getSelectedModelRow(table); BenthosBatchRowModel row = tableModel.getEntry(selectedRowIndex); + List<Species> referents = getDataContext().getReferentSpecies(); + Map<String, Species> referentsById = Speciess.splitReferenceSpeciesByReferenceTaxonId(referents); + BenthosBatchUIModel model = handler.getModel(); - List<Species> allSpecies = new ArrayList<>(getDataContext().getSpecies()); - List<Species> speciesList = Lists.newArrayList( - getDataContext().getReferentBenthosWithSurveyCode()); + SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory(); Serializable categoryValue = firstSampleCategory.getCategoryValue(); - speciesList.removeAll( - model.getSpeciesUsed().get( - (CaracteristicQualitativeValue) categoryValue)); + Collection<Species> speciesUsedForFirstCategory = + model.getSpeciesUsed().get((CaracteristicQualitativeValue) categoryValue); + + List<Species> allSpeciesList = new ArrayList<>(getDataContext().getSpecies()); + allSpeciesList.removeAll(speciesUsedForFirstCategory); + //remove the synonyms of the already used species + Multimap<String, Species> speciesByReferent = Speciess.splitByReferenceTaxonId(allSpeciesList); + for (Species species : speciesUsedForFirstCategory) { + Collection<Species> synonyms = speciesByReferent.get(String.valueOf(species.getReferenceTaxonId())); + allSpeciesList.removeAll(synonyms); + } + + List<Species> speciesList = Lists.newArrayList(getDataContext().getReferentBenthosWithSurveyCode()); + speciesList.removeAll(speciesUsedForFirstCategory); - selectedSpecies = openAddSpeciesDialog(t("tutti.selectSpecies.title"), allSpecies, speciesList); + selectedSpecies = openAddSpeciesDialog(t("tutti.selectSpecies.title"), allSpeciesList, speciesList); if (!selectedSpecies.isReferenceTaxon()) { String decoratedSynonym = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL); - List<Species> referents = getDataContext().getReferentSpecies(); - Map<String, Species> referentsById = Speciess.splitReferenceSpeciesByReferenceTaxonId(referents); String taxonId = String.valueOf(selectedSpecies.getReferenceTaxonId()); selectedSpecies = referentsById.get(taxonId); String decoratedReferent = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL); diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/actions/RenameSpeciesBatchAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/actions/RenameSpeciesBatchAction.java index a9dab4b..576a22e 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/actions/RenameSpeciesBatchAction.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/actions/RenameSpeciesBatchAction.java @@ -23,6 +23,7 @@ package fr.ifremer.tutti.ui.swing.content.operation.catches.species.actions; */ import com.google.common.collect.Lists; +import com.google.common.collect.Multimap; import fr.ifremer.tutti.persistence.entities.data.SampleCategory; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; import fr.ifremer.tutti.persistence.entities.referential.Species; @@ -69,21 +70,32 @@ public class RenameSpeciesBatchAction extends LongActionSupport<SpeciesBatchUIMo int selectedRowIndex = SwingUtil.getSelectedModelRow(table); SpeciesBatchRowModel row = tableModel.getEntry(selectedRowIndex); + List<Species> referents = getDataContext().getReferentSpecies(); + Map<String, Species> referentsById = Speciess.splitReferenceSpeciesByReferenceTaxonId(referents); + SpeciesBatchUIModel model = handler.getModel(); - List<Species> allSpeciesList = new ArrayList<>(getDataContext().getSpecies()); - List<Species> speciesList = Lists.newArrayList( - getDataContext().getReferentSpeciesWithSurveyCode()); + SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory(); Serializable categoryValue = firstSampleCategory.getCategoryValue(); - speciesList.removeAll( - model.getSpeciesUsed().get((CaracteristicQualitativeValue) categoryValue)); + Collection<Species> speciesUsedForFirstCategory = + model.getSpeciesUsed().get((CaracteristicQualitativeValue) categoryValue); + + List<Species> allSpeciesList = new ArrayList<>(getDataContext().getSpecies()); + allSpeciesList.removeAll(speciesUsedForFirstCategory); + //remove the synonyms of the already used species + Multimap<String, Species> speciesByReferent = Speciess.splitByReferenceTaxonId(allSpeciesList); + for (Species species : speciesUsedForFirstCategory) { + Collection<Species> synonyms = speciesByReferent.get(String.valueOf(species.getReferenceTaxonId())); + allSpeciesList.removeAll(synonyms); + } + + List<Species> speciesList = Lists.newArrayList(getDataContext().getReferentSpeciesWithSurveyCode()); + speciesList.removeAll(speciesUsedForFirstCategory); selectedSpecies = openAddSpeciesDialog(t("tutti.selectSpecies.title"), allSpeciesList, speciesList); if (!selectedSpecies.isReferenceTaxon()) { String decoratedSynonym = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL); - List<Species> referents = getDataContext().getReferentSpecies(); - Map<String, Species> referentsById = Speciess.splitReferenceSpeciesByReferenceTaxonId(referents); String taxonId = String.valueOf(selectedSpecies.getReferenceTaxonId()); selectedSpecies = referentsById.get(taxonId); String decoratedReferent = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.