[Suiviobsmer-commits] r1043 - trunk/wao-business/src/main/java/fr/ifremer/wao/service
Author: bleny Date: 2011-02-23 15:54:22 +0000 (Wed, 23 Feb 2011) New Revision: 1043 Log: bugfix in terrestrial import ; region useless Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java 2011-02-23 12:21:19 UTC (rev 1042) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java 2011-02-23 15:54:22 UTC (rev 1043) @@ -278,7 +278,6 @@ @Override protected void executeImportTerrestrialLocations(TopiaContext transaction, InputStream input) throws Exception { - TerrestrialLocationDAO dao = WaoDAOHelper.getTerrestrialLocationDAO(transaction); // first, we will read the CSV file, line by line @@ -302,9 +301,9 @@ TerrestrialLocation location = locationIterator.next(); // look if already exists and update existing or add new - TerrestrialLocation existingLocation = dao.findByProperties(TerrestrialLocation.PROPERTY_CODE, location.getCode(), - TerrestrialLocation.PROPERTY_NAME, location.getName(), - TerrestrialLocation.PROPERTY_LOCATION_TYPE_ORDINAL, location.getLocationTypeOrdinal()); + TerrestrialLocation existingLocation = dao.findByProperties( + TerrestrialLocation.PROPERTY_CODE, location.getCode(), + TerrestrialLocation.PROPERTY_LOCATION_TYPE_ORDINAL, location.getLocationTypeOrdinal()); if (existingLocation == null) { dao.create(location); locationAdded += 1; @@ -338,7 +337,7 @@ BinderFactory.newBinder(TerrestrialLocation.class); // counts for logging int districtAdded = 0, districtUpdated = 0; - int regionAdded = 0, regionUpdated = 0; +// int regionAdded = 0, regionUpdated = 0; for (String districtCode : districtCodes) { // for each district code found @@ -385,39 +384,39 @@ districtUpdated += 1; } - // creating a region object for this district - TerrestrialLocation region = dao.newInstance(); - locationBinder.copyExcluding(district, region, TerrestrialLocation.TOPIA_ID, - TerrestrialLocation.TOPIA_CREATE_DATE, TerrestrialLocation.TOPIA_VERSION, - TerrestrialLocation.PROPERTY_DEPARTMENT_CODE, TerrestrialLocation.PROPERTY_DEPARTMENT_NAME, - TerrestrialLocation.PROPERTY_SUB_REGION_IFREMER_CODE, TerrestrialLocation.PROPERTY_SUB_REGION_IFREMER_NAME); - - // prevent to deal with case "Hors France" - if (region.getRegionIfremerCode() != null) { - - // try to find it if it's already in DB - TerrestrialLocation existingRegion = dao.findByProperties( - TerrestrialLocation.PROPERTY_REGION_IFREMER_CODE, region.getRegionIfremerCode(), - TerrestrialLocation.PROPERTY_DISTRICT_CODE, null, - TerrestrialLocation.PROPERTY_LOCATION_TYPE_ORDINAL, null); - - // create or update - if (existingRegion == null) { - dao.create(region); - regionAdded += 1; - } else { - locationBinder.copyExcluding(region, existingRegion, TerrestrialLocation.TOPIA_ID, - TerrestrialLocation.TOPIA_CREATE_DATE, TerrestrialLocation.TOPIA_VERSION); - dao.update(existingRegion); - regionUpdated += 1; - } - } +// // creating a region object for this district +// TerrestrialLocation region = dao.newInstance(); +// locationBinder.copyExcluding(district, region, TerrestrialLocation.TOPIA_ID, +// TerrestrialLocation.TOPIA_CREATE_DATE, TerrestrialLocation.TOPIA_VERSION, +// TerrestrialLocation.PROPERTY_DEPARTMENT_CODE, TerrestrialLocation.PROPERTY_DEPARTMENT_NAME, +// TerrestrialLocation.PROPERTY_SUB_REGION_IFREMER_CODE, TerrestrialLocation.PROPERTY_SUB_REGION_IFREMER_NAME); +// +// // prevent to deal with case "Hors France" +// if (region.getRegionIfremerCode() != null) { +// +// // try to find it if it's already in DB +// TerrestrialLocation existingRegion = dao.findByProperties( +// TerrestrialLocation.PROPERTY_REGION_IFREMER_CODE, region.getRegionIfremerCode(), +// TerrestrialLocation.PROPERTY_DISTRICT_CODE, null, +// TerrestrialLocation.PROPERTY_LOCATION_TYPE_ORDINAL, null); +// +// // create or update +// if (existingRegion == null) { +// dao.create(region); +// regionAdded += 1; +// } else { +// locationBinder.copyExcluding(region, existingRegion, TerrestrialLocation.TOPIA_ID, +// TerrestrialLocation.TOPIA_CREATE_DATE, TerrestrialLocation.TOPIA_VERSION); +// dao.update(existingRegion); +// regionUpdated += 1; +// } +// } } if (log.isInfoEnabled()) { log.info(locationAdded + " terrestrial locations added, " + locationUpdated + " updated"); log.info(districtAdded + " terrestrial district added, " + districtUpdated + " updated"); - log.info(regionAdded + " terrestrial region added, " + regionUpdated + " updated"); +// log.info(regionAdded + " terrestrial region added, " + regionUpdated + " updated"); } transaction.commitTransaction();
participants (1)
-
bleny@users.labs.libre-entreprise.org