[Suiviobsmer-commits] r1330 - trunk/wao-business/src/main/java/fr/ifremer/wao/io/csv2/models
Author: bleny Date: 2011-06-09 13:15:38 +0000 (Thu, 09 Jun 2011) New Revision: 1330 Log: fix contacts import/export when null terrestriallocation in ObsVente Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/io/csv2/models/ContactImportExportModel.java Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/io/csv2/models/ContactImportExportModel.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/io/csv2/models/ContactImportExportModel.java 2011-06-09 10:20:19 UTC (rev 1329) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/io/csv2/models/ContactImportExportModel.java 2011-06-09 13:15:38 UTC (rev 1330) @@ -76,7 +76,11 @@ @Override public String format(TerrestrialLocation terrestrialLocation) { - return terrestrialLocation.getCode(); + String code = ""; + if (terrestrialLocation != null) { + code = terrestrialLocation.getCode(); + } + return code; } @Override @@ -93,23 +97,23 @@ indexedLocations.put(locationType, locationsForType); } } - if (StringUtils.isEmpty(code)) { - throw new IllegalArgumentException(WaoUtils._("wao.import.contact.failure.terrestrialLocationMissing")); + TerrestrialLocation terrestrialLocation = null; + if (StringUtils.isNotBlank(code)) { + LocationType locationType; + try { + locationType = locationTypeGetter.get(null); + } catch (Exception e) { + throw new RuntimeException(e); + } + if (locationType == null) { + throw new IllegalArgumentException(WaoUtils._("wao.import.contact.failure.locationTypeMissing")); + } + terrestrialLocation = indexedLocations.get(locationType).get(code); + if (terrestrialLocation == null) { + throw new IllegalArgumentException(WaoUtils._("wao.import.contact.failure.wrongTerrestrialLocation", + locationType.toString(), code)); + } } - LocationType locationType; - try { - locationType = locationTypeGetter.get(null); - } catch (Exception e) { - throw new RuntimeException(e); - } - if (locationType == null) { - throw new IllegalArgumentException(WaoUtils._("wao.import.contact.failure.locationTypeMissing")); - } - TerrestrialLocation terrestrialLocation = indexedLocations.get(locationType).get(code); - if (terrestrialLocation == null) { - throw new IllegalArgumentException(WaoUtils._("wao.import.contact.failure.wrongTerrestrialLocation", - locationType.toString(), code)); - } return terrestrialLocation; } }
participants (1)
-
bleny@users.labs.libre-entreprise.org