Author: bleny Date: 2011-01-21 16:45:45 +0000 (Fri, 21 Jan 2011) New Revision: 936 Log: set sendEmail on a new Contact to prevent spam Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.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-01-21 16:06:17 UTC (rev 935) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2011-01-21 16:45:45 UTC (rev 936) @@ -231,11 +231,29 @@ newContact.setSampleRow(row); newContact.setContactState(ContactState.CONTACT_START); + ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); + + // Some admin have reported multiple send of a same email (same + // observer and same boat), it's not welcome. + // Here, we try to find an old contact showing + // that this user already sent an email. + Contact contact = dao.findByProperties(Contact.PROPERTY_BOAT, boat, + Contact.PROPERTY_MAIN_OBSERVER, user, + Contact.PROPERTY_EMAIL_SENT, true); + if (contact != null) { + // prevent re-send of the mail + newContact.setEmailSent(true); + } + + // In the case of ObsVente, we may have a user who wants to create + // multiple contact for a same day. Here we try, to ease the input + // of data by trying to pre-fill some field using data given + // in a previous entered contact + if (newContact.getObsProgram() == ObsProgram.OBSVENTE) { // try to pre-fill some field for user-experience - ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); - // let's try to find a similar contact + // let's try to find a recent similar contact Map<String, Object> properties = new HashMap<String, Object>(); properties.put(Contact.PROPERTY_OBS_PROGRAM_ORDINAL, ObsProgram.OBSVENTE.ordinal()); properties.put(Contact.PROPERTY_SAMPLE_ROW, row);