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 e27b39a7abeff22a1c0a03aa535a359de1e2087a Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 4 18:14:22 2014 +0100 refs #5997: [IMPORT] Améliorer la gestion des référentiels temporaires --- .../referential/ReferentialImportService.java | 65 ++++++++++------------ .../resources/i18n/tutti-service_fr_FR.properties | 2 +- 2 files changed, 31 insertions(+), 36 deletions(-) diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialImportService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialImportService.java index feca51c..24962ee 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialImportService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialImportService.java @@ -24,11 +24,8 @@ package fr.ifremer.tutti.service.referential; import com.google.common.base.Charsets; import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.collect.Collections2; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.common.io.Files; import fr.ifremer.tutti.persistence.entities.TuttiEntities; @@ -58,9 +55,7 @@ import java.io.File; import java.io.IOException; import java.io.Reader; import java.util.ArrayList; -import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -127,18 +122,18 @@ public class ReferentialImportService extends AbstractTuttiService { if (id != null && existingSpeciesIds.add(id)) { throw new IllegalArgumentException(t("tutti.service.referential.import.species.notExistingId.error", id)); - - } else if (StringUtils.isBlank(name)) { + } + if (StringUtils.isBlank(name)) { throw new IllegalArgumentException(t("tutti.service.referential.import.species.noName.error", id)); - - } else if (!delete && !existingSpeciesNames.add(name) && - (id == null || species != null && !species.getName().equals(name))) { + } + if (!delete && !existingSpeciesNames.add(name) && + (id == null || species != null && !species.getName().equals(name))) { throw new IllegalArgumentException(t("tutti.service.referential.import.species.existingName.error", name)); } if (delete) { if (id == null) { - throw new IllegalArgumentException(t("tutti.service.referential.import.species.cannotDeleteWithoutId.error", id)); + throw new IllegalArgumentException(t("tutti.service.referential.import.species.cannotDeleteWithoutId.error")); } if (persistenceService.isTemporarySpeciesUsed(id)) { throw new IllegalArgumentException(t("tutti.service.referential.import.species.used.error", id)); @@ -203,11 +198,11 @@ public class ReferentialImportService extends AbstractTuttiService { Set<String> existingVesselInternationalRegistrationCodes = Sets.newHashSet(Iterables.transform(existingVessels, new Function<Vessel, String>() { - @Override - public String apply(Vessel input) { - return input.getInternationalRegistrationCode(); - } - })); + @Override + public String apply(Vessel input) { + return input.getInternationalRegistrationCode(); + } + })); Map<String, Vessel> existingVesselsById = TuttiEntities.splitById(existingVessels); Set<String> existingVesselIds = new HashSet<>(existingVesselsById.keySet()); @@ -231,19 +226,19 @@ public class ReferentialImportService extends AbstractTuttiService { if (id != null && existingVesselIds.add(id)) { throw new IllegalArgumentException(t("tutti.service.referential.import.vessel.notExistingId.error", id)); - - } else if (StringUtils.isBlank(internationalRegistrationCode)) { + } + if (StringUtils.isBlank(internationalRegistrationCode)) { throw new IllegalArgumentException(t("tutti.service.referential.import.vessel.noInternationalRegistrationCode.error", id)); - - } else if (!delete && !existingVesselInternationalRegistrationCodes.add(internationalRegistrationCode) && - (id == null || vessel != null && !vessel.getRegistrationCode().equals(internationalRegistrationCode))) { + } + if (!delete && !existingVesselInternationalRegistrationCodes.add(internationalRegistrationCode) && + (id == null || vessel != null && !vessel.getRegistrationCode().equals(internationalRegistrationCode))) { throw new IllegalArgumentException(t("tutti.service.referential.import.vessel.existingInternationalRegistrationCode.error", internationalRegistrationCode)); } if (delete) { if (id == null) { - throw new IllegalArgumentException(t("tutti.service.referential.import.vessel.cannotDeleteWithoutId.error", id)); + throw new IllegalArgumentException(t("tutti.service.referential.import.vessel.cannotDeleteWithoutId.error")); } if (persistenceService.isTemporaryVesselUsed(id)) { throw new IllegalArgumentException(t("tutti.service.referential.import.vessel.used.error", id)); @@ -334,18 +329,18 @@ public class ReferentialImportService extends AbstractTuttiService { if (id != null && existingPersonIds.add(id)) { throw new IllegalArgumentException(t("tutti.service.referential.import.person.notExistingId.error", id)); - - } else if (StringUtils.isBlank(name)) { + } + if (StringUtils.isBlank(name)) { throw new IllegalArgumentException(t("tutti.service.referential.import.person.noName.error", id)); - - } else if (!delete && !existingPersonFullNames.add(name) && - (id == null || person != null && !person.getName().equals(name))) { + } + if (!delete && !existingPersonFullNames.add(name) && + (id == null || person != null && !person.getName().equals(name))) { throw new IllegalArgumentException(t("tutti.service.referential.import.person.existingName.error", name)); } if (delete) { if (id == null) { - throw new IllegalArgumentException(t("tutti.service.referential.import.person.cannotDeleteWithoutId.error", id)); + throw new IllegalArgumentException(t("tutti.service.referential.import.person.cannotDeleteWithoutId.error")); } if (persistenceService.isTemporaryPersonUsed(id)) { throw new IllegalArgumentException(t("tutti.service.referential.import.person.used.error", id)); @@ -398,7 +393,7 @@ public class ReferentialImportService extends AbstractTuttiService { protected String getPersonFullName(Person person) { return StringUtils.lowerCase( StringUtils.trimToEmpty(person.getFirstName()) + - StringUtils.trimToEmpty(person.getLastName())); + StringUtils.trimToEmpty(person.getLastName())); } public ReferentialImportResult<Gear> importTemporaryGear(File file) throws IOException { @@ -443,18 +438,18 @@ public class ReferentialImportService extends AbstractTuttiService { if (id != null && existingGearIds.add(id)) { throw new IllegalArgumentException(t("tutti.service.referential.import.gear.notExistingId.error", id)); - - } else if (StringUtils.isBlank(name)) { + } + if (StringUtils.isBlank(name)) { throw new IllegalArgumentException(t("tutti.service.referential.import.gear.noName.error", id)); - - } else if (!delete && !existingGearNames.add(name) && - (id == null || gear != null && !gear.getName().equals(name))) { + } + if (!delete && !existingGearNames.add(name) && + (id == null || gear != null && !gear.getName().equals(name))) { throw new IllegalArgumentException(t("tutti.service.referential.import.gear.existingName.error", name)); } if (delete) { if (id == null) { - throw new IllegalArgumentException(t("tutti.service.referential.import.gear.cannotDeleteWithoutId.error", id)); + throw new IllegalArgumentException(t("tutti.service.referential.import.gear.cannotDeleteWithoutId.error")); } if (persistenceService.isTemporaryGearUsed(id)) { throw new IllegalArgumentException(t("tutti.service.referential.import.gear.used.error", id)); diff --git a/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties b/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties index 0a5adc0..58ce574 100644 --- a/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties +++ b/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties @@ -205,7 +205,7 @@ tutti.service.referential.import.gear.notExistingId.error=L'identifiant '%s' n'a tutti.service.referential.import.gear.used.error=L'engin temporaire %s est utilisé dans l'application. Vous devez le remplacer pour pouvoir le supprimer. tutti.service.referential.import.gears.error=Erreur lors de l'import des engins du fichier %s tutti.service.referential.import.person.cannotDeleteWithoutId.error=L'identifiant est obligatoire pour la suppression -tutti.service.referential.import.person.existingName.error=Une personne avec ce nom (nom + prénom) existe déjà +tutti.service.referential.import.person.existingName.error=Une personne avec ce nom %s (nom + prénom) existe déjà tutti.service.referential.import.person.idNotNegative.error=L'identifiant d'une personne temporaire doit être négatif \: %s tutti.service.referential.import.person.noName.error=Le nom de la personne (prénom ou nom) est obligatoire tutti.service.referential.import.person.notExistingId.error=L'identifiant '%s' n'a pas été trouvé parmi les personnes temporaires -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.