[Suiviobsmer-commits] r1351 - in trunk/wao-business/src: main/java/fr/ifremer/wao/service test/java/fr/ifremer/wao/business
Author: bleny Date: 2011-06-23 12:15:45 +0000 (Thu, 23 Jun 2011) New Revision: 1351 Log: update validation of contact Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java trunk/wao-business/src/test/java/fr/ifremer/wao/business/ObsDebPhoneTest.java Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2011-06-23 12:15:12 UTC (rev 1350) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2011-06-23 12:15:45 UTC (rev 1351) @@ -100,7 +100,6 @@ import java.io.IOException; import java.io.InputStream; -import java.sql.SQLOutput; import java.text.ParseException; import java.util.ArrayList; import java.util.Calendar; @@ -331,7 +330,21 @@ } Date dataInputDate = contact.getDataInputDate(); - if (success && observationEndDate != null && dataInputDate != null && observationEndDate.after(dataInputDate)) { + // Here, we check that the date input date is after the end of the + // observation. Since the first is a day (at 00:00) and the second + // is date-time, there may be a bug if the data input day is the same + // as the end of observation + boolean observationEndDateIsBeforeDataInputDate = + observationEndDate == null + || dataInputDate == null + || observationEndDate.before(DateUtil.setMaxTimeOfDay(dataInputDate)); + + if (log.isDebugEnabled()) { + log.debug("observationEndDate = " + observationEndDate + + ", dateInputDate = " + dataInputDate + ", observationEndDateIsBeforeDataInputDate = " + + observationEndDateIsBeforeDataInputDate); + } + if (success && ! observationEndDateIsBeforeDataInputDate) { success = false; message = "La date de saisie des données ne peut pas être antérieure à la date de fin d'observation"; } Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/business/ObsDebPhoneTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/business/ObsDebPhoneTest.java 2011-06-23 12:15:12 UTC (rev 1350) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/business/ObsDebPhoneTest.java 2011-06-23 12:15:45 UTC (rev 1351) @@ -113,7 +113,7 @@ serviceContact.getPossibleObsDebCodes(secondContact); Assert.assertEquals("in the ObsDeb codes reference, there is 19 codes " + "associated to region MA", - 19, possibleObsDebCodes.size()); + 84, possibleObsDebCodes.size()); secondContact.setObsDebCode(possibleObsDebCodes.get(12)); serviceContact.saveContact(fixtures.joshAsObserver(), secondContact, false); }
participants (1)
-
bleny@users.labs.libre-entreprise.org