r2038 - in trunk: wao-services/src/main/java/fr/ifremer/wao/services/service wao-services/src/main/resources/i18n wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer wao-web/src/main/resources/i18n
Author: bleny Date: 2014-06-17 11:49:07 +0200 (Tue, 17 Jun 2014) New Revision: 2038 Url: http://forge.codelutin.com/projects/wao/repository/revisions/2038 Log: fixes #5218 add a validation rule Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactWithObservedDataControlToCorrectionAskedException.java Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java trunk/wao-services/src/main/resources/i18n/wao-services_en_GB.properties trunk/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactWithObservedDataControlToCorrectionAskedException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactWithObservedDataControlToCorrectionAskedException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactWithObservedDataControlToCorrectionAskedException.java 2014-06-17 09:49:07 UTC (rev 2038) @@ -0,0 +1,15 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.entity.Contact; + +/** + * Un contact en correction demandée ne peut pas être accepté par la société. + */ +public class ContactWithObservedDataControlToCorrectionAskedException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + public ContactWithObservedDataControlToCorrectionAskedException(Contact contact) { + super(contact); + } +} Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java 2014-06-17 09:05:43 UTC (rev 2037) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java 2014-06-17 09:49:07 UTC (rev 2038) @@ -383,6 +383,9 @@ } catch (MissingContactObservedDataControlException e) { String message = l(l, "wao.import.contact.failure.missingObservedDataControl", lineNumber); throw new ImportErrorException(message); + } catch (ContactWithObservedDataControlToCorrectionAskedException e) { + String message = l(l, "wao.import.contact.failure.observedDataControlToCorrectionAsked", lineNumber); + throw new ImportErrorException(message); } catch (MissingContactStateMotifException e) { String message = l(l, "wao.import.contact.failure.missingContactStateMotif", lineNumber); throw new ImportErrorException(message); @@ -443,6 +446,7 @@ MissingContactStateMotifException, UnwantedContactContactStateMotifException, MissingContactObservedDataControlException, + ContactWithObservedDataControlToCorrectionAskedException, MissingContactRestitutionException, MissingContactDataInputDateException, ContactRestitutionDateBeforeDataInputDateException, @@ -628,12 +632,16 @@ // validationCompany //--- + if (ContactState.OBSERVATION_DONE == contactState) { + if (contact.getObservedDataControl() == null) { + throw new MissingContactObservedDataControlException(contact); + } else if (contact.getObservedDataControl().equals(ObservedDataControl.CORRECTION_ASKED)) { + throw new ContactWithObservedDataControlToCorrectionAskedException(contact); + } + } + // Pour valider un contact société, il faut que le contact aie une date de transmission - if (ContactState.OBSERVATION_DONE == contactState && contact.getObservedDataControl() == null) { - throw new MissingContactObservedDataControlException(contact); - } Date restitution = contact.getRestitution(); - if (ObservedDataControl.ACCEPTED == contact.getObservedDataControl() && restitution == null) { throw new MissingContactRestitutionException(contact); } Modified: trunk/wao-services/src/main/resources/i18n/wao-services_en_GB.properties =================================================================== --- trunk/wao-services/src/main/resources/i18n/wao-services_en_GB.properties 2014-06-17 09:05:43 UTC (rev 2037) +++ trunk/wao-services/src/main/resources/i18n/wao-services_en_GB.properties 2014-06-17 09:49:07 UTC (rev 2038) @@ -59,6 +59,7 @@ wao.import.contact.failure.not.updatable=Insufficient credentials to update contact wao.import.contact.failure.observationEndDateAfterToday=La date de fin de la marée ne peut pas être postérieure à la date du jour wao.import.contact.failure.observationEndDateBeforeBeginDate=La date de fin d'observation ne peut pas être antérieure à celle du début +wao.import.contact.failure.observedDataControlToCorrectionAsked=A contact cannot be accepted if observed data control shows that a correction is asked wao.import.contact.failure.sampleRowCodeMissing=The code of the sample row line is missing wao.import.contact.failure.terrestrialLocationMissing=The code of the terrestrial location is missing wao.import.contact.failure.transmissionDateBeforeDataInputDate=Il faut que la date de transmission de la restitution soit après la date de saisie des données Modified: trunk/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties =================================================================== --- trunk/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties 2014-06-17 09:05:43 UTC (rev 2037) +++ trunk/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties 2014-06-17 09:49:07 UTC (rev 2038) @@ -56,6 +56,7 @@ wao.import.contact.failure.not.updatable=Ligne %s \: Vous n'avez pas les droits suffisants pour modifier le contact wao.import.contact.failure.observationEndDateAfterToday=Ligne %s \: La date de fin de la marée doit être antérieure à la date du jour wao.import.contact.failure.observationEndDateBeforeBeginDate=Ligne %s \: La date de fin d'observation doit être postérieure à celle du début +wao.import.contact.failure.observedDataControlToCorrectionAsked=Un contact ne peut être accepté si le contrôle des données observées indique qu'une correction est demandée wao.import.contact.failure.sampleRowCodeMissing=Il manque le code de la ligne de plan associée wao.import.contact.failure.terrestrialLocationMissing=Il manque le code du lieu wao.import.contact.failure.transmissionDateBeforeDataInputDate=Ligne %s \: La date de transmission de la restitution doit être postérieure à la date de saisie des données Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java =================================================================== --- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java 2014-06-17 09:05:43 UTC (rev 2037) +++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java 2014-06-17 09:49:07 UTC (rev 2038) @@ -37,6 +37,7 @@ import fr.ifremer.wao.services.service.ContactObservationEndDateAfterTodayException; import fr.ifremer.wao.services.service.ContactObservationEndDateBeforeBeginDateException; import fr.ifremer.wao.services.service.ContactRestitutionDateBeforeDataInputDateException; +import fr.ifremer.wao.services.service.ContactWithObservedDataControlToCorrectionAskedException; import fr.ifremer.wao.services.service.DuplicatedContactMainObserverInSecondaryObserversException; import fr.ifremer.wao.services.service.InvalidContactObservationBeginDateException; import fr.ifremer.wao.services.service.MismatchContactMainObserverCompanyException; @@ -266,6 +267,9 @@ } catch (MissingContactObservedDataControlException e) { addFieldError("updateContactCommand.contact.observedDataControl", t("wao.ui.form.Contact.error.missingObservedDataControl")); + } catch (ContactWithObservedDataControlToCorrectionAskedException e) { + addFieldError("updateContactCommand.contact.observedDataControl", t("wao.ui.form.Contact.error.observedDataControlToCorrectionAsked")); + } catch (MissingContactStateMotifException e) { addFieldError("updateContactCommand.contact.contactStateMotif", t("wao.ui.form.Contact.error.missingContactStateMotif")); Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java =================================================================== --- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java 2014-06-17 09:05:43 UTC (rev 2037) +++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java 2014-06-17 09:49:07 UTC (rev 2038) @@ -24,6 +24,7 @@ import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.opensymphony.xwork2.Preparable; +import fr.ifremer.wao.WaoTechnicalException; import fr.ifremer.wao.WaoUtils; import fr.ifremer.wao.entity.Contact; import fr.ifremer.wao.services.AuthenticatedWaoUser; @@ -33,6 +34,7 @@ import fr.ifremer.wao.services.service.ContactObservationEndDateAfterTodayException; import fr.ifremer.wao.services.service.ContactObservationEndDateBeforeBeginDateException; import fr.ifremer.wao.services.service.ContactRestitutionDateBeforeDataInputDateException; +import fr.ifremer.wao.services.service.ContactWithObservedDataControlToCorrectionAskedException; import fr.ifremer.wao.services.service.DuplicatedContactMainObserverInSecondaryObserversException; import fr.ifremer.wao.services.service.InvalidContactObservationBeginDateException; import fr.ifremer.wao.services.service.MismatchContactMainObserverCompanyException; @@ -144,7 +146,7 @@ } @Override - public String execute() throws Exception { + public String execute() { AuthenticatedWaoUser authenticatedWaoUser = session.getAuthenticatedWaoUser(); @@ -205,6 +207,9 @@ } catch (MissingContactObservedDataControlException e) { errorMessage = t("wao.ui.form.Contact.error.missingObservedDataControl"); + } catch (ContactWithObservedDataControlToCorrectionAskedException e) { + errorMessage = t("wao.ui.form.Contact.error.observedDataControlToCorrectionAsked"); + } catch (MissingContactStateMotifException e) { errorMessage = t("wao.ui.form.Contact.error.missingContactStateMotif"); @@ -234,7 +239,11 @@ if (isSuccessful()) { - service.save(updateContactCommand, true); + try { + service.save(updateContactCommand, true); + } catch (ContactNotUpdatableException e) { + throw new WaoTechnicalException("should never occur", e); + } if (validationState == null) { successMessage = t("wao.ui.contacts.validation.to.unvalidate.state.success"); } else if (validationState) { Modified: trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties =================================================================== --- trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties 2014-06-17 09:05:43 UTC (rev 2037) +++ trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties 2014-06-17 09:49:07 UTC (rev 2038) @@ -297,6 +297,7 @@ wao.ui.form.Contact.error.missingRestitution= wao.ui.form.Contact.error.observationEndDateAfterToday= wao.ui.form.Contact.error.observationEndDateBeforeBeginDate= +wao.ui.form.Contact.error.observedDataControlToCorrectionAsked= wao.ui.form.Contact.error.transmissionDateBeforeDataInputDate= wao.ui.form.Contact.error.unwantedContactStateMotif= wao.ui.form.SampleRow.boatsDescription=This field contains registration numbers of the ships that areeligible for this ligne. You can use any separator to separate numbers (space, dot, line-return, comma) Modified: trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties =================================================================== --- trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties 2014-06-17 09:05:43 UTC (rev 2037) +++ trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties 2014-06-17 09:49:07 UTC (rev 2038) @@ -297,6 +297,7 @@ wao.ui.form.Contact.error.missingRestitution=Il faut préciser une date de transmission de la restitution de la donnée avant de valider wao.ui.form.Contact.error.observationEndDateAfterToday=La date de fin de la marée ne peut pas être postérieure à la date du jour wao.ui.form.Contact.error.observationEndDateBeforeBeginDate=La date de fin d'observation ne peut pas être antérieure à celle du début +wao.ui.form.Contact.error.observedDataControlToCorrectionAsked=Un contact ne peut être accepté si le contrôle des données observées indique qu'une correction est demandée wao.ui.form.Contact.error.transmissionDateBeforeDataInputDate=Il faut que la date de transmission de la restitution soit après la date de saisie des données wao.ui.form.Contact.error.unwantedContactStateMotif=Il ne faut pas préciser de motif de refus wao.ui.form.SampleRow.boatsDescription=Ce champs correspond aux immatriculations des navires qui sont éligibles pour cette ligne. Vous pouvez utiliser n'importe quel séparateur pour séparer les immatriculations (virgule, point, espace ou saut de ligne)
participants (1)
-
bleny@users.forge.codelutin.com