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 bb19a974e8558916c5df92775e33c13a2f8dc62c Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Aug 23 16:32:30 2014 +0200 fixes #5624: [CAPTURE] import psion, il faut traiter MELA-NGE ou MELANGE comme du mélange, actuellement il importe correctementement que MELA-NGE --- .../service/psionimport/PsionImportService.java | 77 ++++++++++++++++++---- 1 file changed, 66 insertions(+), 11 deletions(-) diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportService.java index d929c90..f487be7 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportService.java @@ -25,6 +25,7 @@ package fr.ifremer.tutti.service.psionimport; import com.google.common.base.Charsets; import com.google.common.base.Joiner; import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -89,13 +90,23 @@ public class PsionImportService extends AbstractTuttiService { private static final Log log = LogFactory.getLog(PsionImportService.class); - protected static final Set<String> NO_CATEGORY_VALUES = Sets.newHashSet("N", "n"); + protected static final ImmutableSet<String> NO_CATEGORY_VALUES = ImmutableSet.copyOf(new String[]{"N", "n"}); - protected static final Set<String> SIZE_CATEGORY_VALUES = Sets.newHashSet("G", "g", "P", "p"); + protected static final ImmutableSet<String> SIZE_CATEGORY_VALUES = ImmutableSet.copyOf(new String[]{"G", "g", "P", "p"}); - protected static final Set<String> SEX_CATEGORY_VALUES = Sets.newHashSet("I", "i", "F", "f", "M", "m"); + protected static final ImmutableSet<String> SEX_CATEGORY_VALUES = ImmutableSet.copyOf(new String[]{"I", "i", "F", "f", "M", "m"}); - protected static final Set<String> MATURITY_CATEGORY_VALUES = Sets.newHashSet("1", "2", "3", "4", "5"); + protected static final ImmutableSet<String> MATURITY_CATEGORY_VALUES = ImmutableSet.copyOf(new String[]{"1", "2", "3", "4", "5"}); + + public static final String MELAG_SPECIES_1 = "MELA-NGE"; + + public static final String MELAG_SPECIES_2 = "MELANGE"; + + /** + * All MELAG species. + * @since 3.7 + */ + public static final Set<String> MELAG_SPECIES = ImmutableSet.copyOf(new String[]{MELAG_SPECIES_1, MELAG_SPECIES_2}); /** * All usables keywords in a psion import. @@ -369,14 +380,58 @@ public class PsionImportService extends AbstractTuttiService { if (species == null) { // could not load this species - badSpecies = value; - batch = null; - String error = t("tutti.service.psionimport.error.species.not.found", lineNumber, value); - if (log.isWarnEnabled()) { - log.warn(error); + + if (MELAG_SPECIES.contains(value)) { + + // using a MELAG species, can try with other possible values + // see https://forge.codelutin.com/issues/5624 + + if (MELAG_SPECIES_1.equals(value)) { + + // try with MELANGE_2 + species = speciesBySurveyCode.get(MELAG_SPECIES_2); + + if (species != null) { + + // use as value MELANGE_2 + if (log.isInfoEnabled()) { + log.info("Replace value " + value + " by " + MELAG_SPECIES_2); + } + value = MELAG_SPECIES_2; + + } + + } else if (MELAG_SPECIES_2.equals(value)) { + + // try with MELANGE_1 + species = speciesBySurveyCode.get(MELAG_SPECIES_1); + + if (species != null) { + + // use as value MELANGE_1 + if (log.isInfoEnabled()) { + log.info("Replace value " + value + " by " + MELAG_SPECIES_1); + } + value = MELAG_SPECIES_1; + } + + } + + } + + if (species == null) { + + // species not found for sure (after MELAG tries...) + + badSpecies = value; + batch = null; + String error = t("tutti.service.psionimport.error.species.not.found", lineNumber, value); + if (log.isWarnEnabled()) { + log.warn(error); + } + importModel.addError(error); + continue; } - importModel.addError(error); - continue; } if (alreadyUsedSpecies.contains(species)) { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.