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 e9b2e58c8c57845ee9d2c7465552664f4e616c5a Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Aug 26 12:32:11 2014 +0200 fixes #5672: #5624 MELANGE pas importé comme du mélange --- .../service/psionimport/PsionImportService.java | 67 +++------------------- .../tutti/service/pupitri/PupitriCatch.java | 27 ++++++++- .../tutti/service/pupitri/PupitriImportResult.java | 11 +++- 3 files changed, 41 insertions(+), 64 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 f487be7..7fd533d 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 @@ -98,16 +98,6 @@ public class PsionImportService extends AbstractTuttiService { 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. * <p/> @@ -381,57 +371,14 @@ public class PsionImportService extends AbstractTuttiService { // could not load this species - 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; + 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; } if (alreadyUsedSpecies.contains(species)) { diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriCatch.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriCatch.java index 8c9f784..10f4781 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriCatch.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriCatch.java @@ -22,12 +22,15 @@ package fr.ifremer.tutti.service.pupitri; * #L% */ +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; import fr.ifremer.tutti.persistence.entities.referential.Species; +import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.mutable.MutableFloat; import java.io.Serializable; import java.util.Map; +import java.util.Set; /** * @author kmorin <kmorin@codelutin.com> @@ -37,7 +40,18 @@ public class PupitriCatch implements Serializable { private static final long serialVersionUID = 1L; - public static final String MELAG_META_SPECIES = "MELA-NGE"; + private static final String MELAG_META_SPECIES = "MELA-NGE"; + + private static final String MELAG_2_META_SPECIES = "MELANGE"; + + /** + * All MELAG species. + * + * @since 3.7 + */ + private static final Set<String> MELAG_SPECIES = ImmutableSet.copyOf( + new String[]{MELAG_META_SPECIES, MELAG_2_META_SPECIES}); + protected Species species; @@ -64,7 +78,7 @@ public class PupitriCatch implements Serializable { public boolean isMelagMetaSpecies() { - boolean melagMetaSpecies = MELAG_META_SPECIES.equals(species.getSurveyCode()); + boolean melagMetaSpecies = MELAG_SPECIES.contains(species.getSurveyCode()); return melagMetaSpecies; } @@ -117,4 +131,13 @@ public class PupitriCatch implements Serializable { } return true; } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("species", species.getSurveyCode()) + .append("sorted", sorted) + .append("weightBySign", weightBySign) + .toString(); + } } diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportResult.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportResult.java index ca6863a..ec7dff5 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportResult.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportResult.java @@ -25,6 +25,8 @@ package fr.ifremer.tutti.service.pupitri; import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.referential.Species; import org.apache.commons.lang3.mutable.MutableFloat; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.io.File; import java.util.ArrayList; @@ -43,6 +45,9 @@ import java.util.Set; */ public class PupitriImportResult { + /** Logger. */ + private static final Log log = LogFactory.getLog(PupitriImportResult.class); + final File trunkFile; final File carrousselFile; @@ -207,7 +212,9 @@ public class PupitriImportResult { if (aCatch.isMelagMetaSpecies()) { - + if (log.isInfoEnabled()) { + log.info("Found a MELAG catch: "+aCatch); + } // add weight to melag addMelagTotalWeight(aCatch.getWeight(Signs.DEFAULT)); @@ -259,7 +266,7 @@ public class PupitriImportResult { if (useMelag && aCatch.isMelagMetaSpecies()) { - // remove the MELA-GNE species from import + // remove the MELAG species from import iterator.remove(); continue; -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.