Author: bleny Date: 2013-05-15 11:14:32 +0200 (Wed, 15 May 2013) New Revision: 1658 Url: http://forge.codelutin.com/projects/wao/repository/revisions/1658 Log: refs #1967 fixes bug when computing differences when updating terrestrial locations on a sample row Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java 2013-05-13 13:58:38 UTC (rev 1657) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java 2013-05-15 09:14:32 UTC (rev 1658) @@ -233,6 +233,49 @@ // using the three list to add info if ( ! removedTerrestrialLocations.isEmpty()) { + addChange("Les lieux terrestres suivants ont été dissociés : " + + StringUtils.join(removedTerrestrialLocations, ", ")); + } +// if ( ! keptTerrestrialLocations.isEmpty()) { +// addChange("Les lieux terrestres suivants sont toujours associées : " + +// StringUtils.join(keptTerrestrialLocations, ", ")); +// } + if ( ! addedTerrestrialLocations.isEmpty()) { + addChange("Les lieux terrestres suivants ont été ajoutés : " + + StringUtils.join(addedTerrestrialLocations, ", ")); + } + } + + protected void compareTerrestrialDistricts() { + Collection<TerrestrialLocation> oldTerrestrialLocations; + if (oldRow == null) { + oldTerrestrialLocations = Collections.emptyList(); + } else { + oldTerrestrialLocations = oldRow.getTerrestrialLocations(); + } + Collection<TerrestrialLocation> newTerrestrialLocations = newRow.getTerrestrialLocations(); + + // Lists for boats by status + List<String> removedTerrestrialLocations = new ArrayList<String>(); + List<String> keptTerrestrialLocations = new ArrayList<String>(); + List<String> addedTerrestrialLocations = new ArrayList<String>(); + + // filling the three lists + for (TerrestrialLocation oldTerrestrialLocation : oldTerrestrialLocations) { + if ( ! newTerrestrialLocations.contains(oldTerrestrialLocation)) { + removedTerrestrialLocations.add(oldTerrestrialLocation.getDistrictCode()); + } + } + for (TerrestrialLocation newTerrestrialLocation : newTerrestrialLocations) { + if (oldTerrestrialLocations.contains(newTerrestrialLocation)) { + keptTerrestrialLocations.add(newTerrestrialLocation.getDistrictCode()); + } else { + addedTerrestrialLocations.add(newTerrestrialLocation.getDistrictCode()); + } + } + + // using the three list to add info + if ( ! removedTerrestrialLocations.isEmpty()) { addChange("Les quartiers maritimes suivants ont été dissociées : " + StringUtils.join(removedTerrestrialLocations, ", ")); } @@ -567,7 +610,7 @@ compareFishingZones(); } if (ObsProgram.OBSVENTE.equals(obsProgram)) { - compareTerrestrialLocations(); + compareTerrestrialDistricts(); comparePrograms(); comparePeriods(); compareProfession();