Author: bleny Date: 2014-06-23 22:29:40 +0200 (Mon, 23 Jun 2014) New Revision: 2093 Url: http://forge.codelutin.com/projects/wao/repository/revisions/2093 Log: refs #5295 deal with export for contacts with no terrestrial location Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java 2014-06-23 20:11:03 UTC (rev 2092) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java 2014-06-23 20:29:40 UTC (rev 2093) @@ -24,7 +24,6 @@ package fr.ifremer.wao.services.service.csv; import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableSet; import fr.ifremer.wao.WaoUtils; import fr.ifremer.wao.entity.Boat; import fr.ifremer.wao.entity.Company; @@ -61,10 +60,12 @@ import java.text.ParseException; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Set; public class ContactImportExportModel implements ImportExportModel<Contact> { @@ -212,7 +213,7 @@ }); modelBuilder.newColumnForImportExport("CONTACT_TRANSMISSION_RESTITUTION", Contact.PROPERTY_RESTITUTION, Common.DAY); - List<ObservedDataControl> observedDataControlsValues = new LinkedList<>(); + Set<ObservedDataControl> observedDataControlsValues = new HashSet<>(); Collections.addAll(observedDataControlsValues, ObservedDataControl.values()); observedDataControlsValues.add(null); I18nAbleParserFormatter<ObservedDataControl> valueParserFormatter = new I18nAbleParserFormatter<>(locale, observedDataControlsValues); @@ -223,12 +224,15 @@ if (obsProgram.isObsVente()) { modelBuilder.newColumnForImportExport("CONTACT_ECHANTILLONNAGE_COMPLET", Contact.PROPERTY_COMPLETE_SAMPLING, Common.BOOLEAN); - // FIXME 20110606 bleny contact.getTerrestrialLocation() may be null, export will fail - - // terrestrial location for both ObsVente and ObsDeb + // terrestrial location + Set<LocationType> locationTypes = new HashSet<>(); + locationTypes.add(LocationType.PORT); + locationTypes.add(LocationType.AUCTION); + locationTypes.add(null); + I18nAbleParserFormatter<LocationType> locationTypeParserFormatter = + new I18nAbleParserFormatter<>(locale, locationTypes); + locationTypeParserFormatter.setAcceptNullValues(true); ValueGetterSetter<Contact, LocationType> locationTypeGetter = new Common.ValueSaver<>(); - ValueParserFormatter<LocationType> locationTypeParserFormatter = - new I18nAbleParserFormatter<>(locale, ImmutableSet.of(LocationType.AUCTION, LocationType.PORT)); modelBuilder.newMandatoryColumn( "CONTACT_LIEU_TYPE", locationTypeParserFormatter, @@ -278,8 +282,9 @@ @Override public Iterable<ImportableColumn<Contact, Object>> getColumnsForImport() { return (Iterable) getModel().getColumnsForImport(); - } /** will get terrestrial location depending on location code and pushed location type */ + } + /** will get terrestrial location depending on location code and pushed location type */ protected static class TerrestrialLocationParserFormatter implements ValueParserFormatter<TerrestrialLocation> { protected Locale locale;