Author: tchemit Date: 2014-04-07 19:09:47 +0200 (Mon, 07 Apr 2014) New Revision: 1858 Url: http://forge.codelutin.com/projects/wao/repository/revisions/1858 Log: refs #4487 validation of a contact + improve import i18n message in exception Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterObservationEndDateException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterTodayException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactObservationEndDateAfterTodayException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactObservationEndDateBeforeBeginDateException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactRestitutionDateBeforeDataInputDateException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/DuplicatedContactMainObserverInSecondaryObserversException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactMainObserverException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactObservationBeginDateException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactMainObserverCompanyException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactSecondaryObserverCompanyException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactCommentAdminException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactCommentException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactDataInputDateException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactDataReliabilityException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactMainObserverException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactNbObservantsForObservationDoneStateException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservationBeginDateException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservationEndDateException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservedDataControlException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactRestitutionException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactStateMotifException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UnwantedContactContactStateMotifException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoContactValidationException.java Removed: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactNotValidException.java Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/IllegalDeletionException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ImportErrorException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateContactCommand.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/AbstractImportCsvAction.java 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/ContactDataInputDateAfterObservationEndDateException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterObservationEndDateException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterObservationEndDateException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,18 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.entity.Contact; + +/** + * Created on 4/7/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class ContactDataInputDateAfterObservationEndDateException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + public ContactDataInputDateAfterObservationEndDateException(Contact contact) { + super(contact); + } +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterObservationEndDateException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterTodayException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterTodayException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterTodayException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,27 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.entity.Contact; + +import java.util.Date; + +/** + * Created on 4/7/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class ContactDataInputDateAfterTodayException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + protected Date now; + + public ContactDataInputDateAfterTodayException(Contact contact, Date now) { + super(contact); + this.now = now; + } + + public Date getNow() { + return now; + } +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactDataInputDateAfterTodayException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Deleted: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactNotValidException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactNotValidException.java 2014-04-07 17:07:49 UTC (rev 1857) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactNotValidException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -1,41 +0,0 @@ -package fr.ifremer.wao.services.service; - -/* - * #%L - * Wao :: Services - * %% - * Copyright (C) 2009 - 2014 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import fr.ifremer.wao.WaoException; - -/** - * Quand un contact n'est pas valide (lors d'une création ou d'un import). - * <p/> - * Created on 4/4/14. - * - * @author Tony Chemit <chemit@codelutin.com> - * @since 4.0 - */ -public class ContactNotValidException extends WaoException { - - private static final long serialVersionUID = 1L; - - public ContactNotValidException(String message) { - super(message); - } -} Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactObservationEndDateAfterTodayException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactObservationEndDateAfterTodayException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactObservationEndDateAfterTodayException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,27 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.entity.Contact; + +import java.util.Date; + +/** + * Created on 4/7/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class ContactObservationEndDateAfterTodayException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + protected Date today; + + public ContactObservationEndDateAfterTodayException(Contact contact, Date today) { + super(contact); + this.today = today; + } + + public Date getToday() { + return today; + } +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactObservationEndDateAfterTodayException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactObservationEndDateBeforeBeginDateException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactObservationEndDateBeforeBeginDateException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactObservationEndDateBeforeBeginDateException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,18 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.entity.Contact; + +/** + * Created on 4/7/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class ContactObservationEndDateBeforeBeginDateException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + public ContactObservationEndDateBeforeBeginDateException(Contact contact) { + super(contact); + } +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactObservationEndDateBeforeBeginDateException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactRestitutionDateBeforeDataInputDateException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactRestitutionDateBeforeDataInputDateException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactRestitutionDateBeforeDataInputDateException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,40 @@ +package fr.ifremer.wao.services.service; + +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import fr.ifremer.wao.entity.Contact; + +/** + * Created on 4/4/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class ContactRestitutionDateBeforeDataInputDateException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + public ContactRestitutionDateBeforeDataInputDateException(Contact contact) { + super(contact); + } + +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactRestitutionDateBeforeDataInputDateException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/DuplicatedContactMainObserverInSecondaryObserversException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/DuplicatedContactMainObserverInSecondaryObserversException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/DuplicatedContactMainObserverInSecondaryObserversException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,18 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.entity.Contact; + +/** + * Created on 4/7/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class DuplicatedContactMainObserverInSecondaryObserversException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + public DuplicatedContactMainObserverInSecondaryObserversException(Contact contact) { + super(contact); + } +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/DuplicatedContactMainObserverInSecondaryObserversException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/IllegalDeletionException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/IllegalDeletionException.java 2014-04-07 17:07:49 UTC (rev 1857) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/IllegalDeletionException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -40,6 +40,8 @@ */ public class IllegalDeletionException extends WaoException { + private static final long serialVersionUID = 1L; + protected static final ImmutableMap<Class<? extends TopiaEntity>, String> ENTITIES_I18N_KEYS = ImmutableMap.of( Contact.class, I18n.n("wao.action.delete.failure.attachedContacts"), Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ImportErrorException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ImportErrorException.java 2014-04-07 17:07:49 UTC (rev 1857) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ImportErrorException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -25,6 +25,8 @@ import org.nuiton.csv.ImportRuntimeException; import org.nuiton.i18n.I18n; +import java.util.Locale; + /** * Une erreur est survenue lors d'un import CSV. */ @@ -32,24 +34,22 @@ private static final long serialVersionUID = 1L; - //FIXME ? Why? - protected static final String MESSAGE = I18n.t("wao.import.failure"); - public ImportErrorException(ImportRuntimeException e) { super(e); } - public ImportErrorException(ContactNotValidException e) { - super(e); + public ImportErrorException(String message) { + super(message); } - public ImportErrorException(NullSampleMonthException e) { - super(e); + public String getMessage(Locale locale) { + String causeMessage; + if (getCause() == null) { + causeMessage = getMessage(); + } else { + causeMessage = getCause().getMessage(); + } + return I18n.l(locale, "wao.import.failure", causeMessage); } - @Override - public String getMessage() { - return MESSAGE + " " + getCause().getMessage(); - } - } Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactMainObserverException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactMainObserverException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactMainObserverException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,18 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.entity.Contact; + +/** + * Created on 4/7/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class InvalidContactMainObserverException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + public InvalidContactMainObserverException(Contact contact, String message) { + super(contact); + } +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactMainObserverException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactObservationBeginDateException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactObservationBeginDateException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactObservationBeginDateException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,18 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.entity.Contact; + +/** + * Created on 4/7/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class InvalidContactObservationBeginDateException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + public InvalidContactObservationBeginDateException(Contact contact) { + super(contact); + } +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InvalidContactObservationBeginDateException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactMainObserverCompanyException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactMainObserverCompanyException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactMainObserverCompanyException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,34 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.entity.Company; +import fr.ifremer.wao.entity.Contact; +import fr.ifremer.wao.entity.WaoUser; + +/** + * Created on 4/7/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class MismatchContactMainObserverCompanyException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + protected Company company; + + protected WaoUser observer; + + public MismatchContactMainObserverCompanyException(Contact contact, Company company, WaoUser observer) { + super(contact); + this.company = company; + this.observer = observer; + } + + public Company getCompany() { + return company; + } + + public WaoUser getObserver() { + return observer; + } +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactMainObserverCompanyException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactSecondaryObserverCompanyException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactSecondaryObserverCompanyException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactSecondaryObserverCompanyException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,34 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.entity.Company; +import fr.ifremer.wao.entity.Contact; +import fr.ifremer.wao.entity.WaoUser; + +/** + * Created on 4/7/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class MismatchContactSecondaryObserverCompanyException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + protected WaoUser observer; + + protected Company company; + + public MismatchContactSecondaryObserverCompanyException(Contact contact, WaoUser observer, Company company) { + super(contact); + this.observer = observer; + this.company = company; + } + + public WaoUser getObserver() { + return observer; + } + + public Company getCompany() { + return company; + } +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MismatchContactSecondaryObserverCompanyException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactCommentAdminException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactCommentAdminException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactCommentAdminException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,18 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.entity.Contact; + +/** + * Created on 4/7/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class MissingContactCommentAdminException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + public MissingContactCommentAdminException(Contact contact) { + super(contact); + } +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactCommentAdminException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactCommentException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactCommentException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactCommentException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,40 @@ +package fr.ifremer.wao.services.service; + +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import fr.ifremer.wao.entity.Contact; + +/** + * Created on 4/4/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class MissingContactCommentException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + public MissingContactCommentException(Contact contact) { + super(contact); + } + +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactCommentException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactDataInputDateException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactDataInputDateException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactDataInputDateException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,40 @@ +package fr.ifremer.wao.services.service; + +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import fr.ifremer.wao.entity.Contact; + +/** + * Created on 4/4/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class MissingContactDataInputDateException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + public MissingContactDataInputDateException(Contact contact) { + super(contact); + } + +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactDataInputDateException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactDataReliabilityException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactDataReliabilityException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactDataReliabilityException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,18 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.entity.Contact; + +/** + * Created on 4/7/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class MissingContactDataReliabilityException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + public MissingContactDataReliabilityException(Contact contact) { + super(contact); + } +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactDataReliabilityException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactMainObserverException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactMainObserverException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactMainObserverException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,18 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.entity.Contact; + +/** + * Created on 4/7/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class MissingContactMainObserverException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + public MissingContactMainObserverException(Contact contact) { + super(contact); + } +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactMainObserverException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactNbObservantsForObservationDoneStateException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactNbObservantsForObservationDoneStateException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactNbObservantsForObservationDoneStateException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,40 @@ +package fr.ifremer.wao.services.service; + +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import fr.ifremer.wao.entity.Contact; + +/** + * Created on 4/4/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class MissingContactNbObservantsForObservationDoneStateException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + public MissingContactNbObservantsForObservationDoneStateException(Contact contact) { + super(contact); + } + +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactNbObservantsForObservationDoneStateException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservationBeginDateException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservationBeginDateException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservationBeginDateException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,40 @@ +package fr.ifremer.wao.services.service; + +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import fr.ifremer.wao.entity.Contact; + +/** + * Created on 4/4/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class MissingContactObservationBeginDateException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + public MissingContactObservationBeginDateException(Contact contact) { + super(contact); + } + +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservationBeginDateException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservationEndDateException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservationEndDateException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservationEndDateException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,40 @@ +package fr.ifremer.wao.services.service; + +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import fr.ifremer.wao.entity.Contact; + +/** + * Created on 4/4/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class MissingContactObservationEndDateException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + public MissingContactObservationEndDateException(Contact contact) { + super(contact); + } + +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservationEndDateException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservedDataControlException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservedDataControlException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservedDataControlException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,18 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.entity.Contact; + +/** + * Created on 4/7/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class MissingContactObservedDataControlException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + public MissingContactObservedDataControlException(Contact contact) { + super(contact); + } +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactObservedDataControlException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactRestitutionException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactRestitutionException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactRestitutionException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,40 @@ +package fr.ifremer.wao.services.service; + +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import fr.ifremer.wao.entity.Contact; + +/** + * Created on 4/4/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class MissingContactRestitutionException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + public MissingContactRestitutionException(Contact contact) { + super(contact); + } + +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactRestitutionException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactStateMotifException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactStateMotifException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactStateMotifException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,40 @@ +package fr.ifremer.wao.services.service; + +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import fr.ifremer.wao.entity.Contact; + +/** + * Created on 4/4/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class MissingContactStateMotifException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + public MissingContactStateMotifException(Contact contact) { + super(contact); + } + +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingContactStateMotifException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native 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-04-07 17:07:49 UTC (rev 1857) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerContactsService.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -27,7 +27,9 @@ import com.google.common.collect.ImmutableSet; import fr.ifremer.wao.ContactsFilter; import fr.ifremer.wao.WaoTechnicalException; +import fr.ifremer.wao.WaoUtils; import fr.ifremer.wao.entity.Boat; +import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.Contact; import fr.ifremer.wao.entity.ContactImpl; import fr.ifremer.wao.entity.ContactState; @@ -238,8 +240,9 @@ List<Boat> boats = getBoatDao().findAll(); List<ContactStateMotif> motives = getContactStateMotifDao().findAll(); + Locale l = getLocale(); ImportModel<Contact> contactImportModel = - ObsMerContactImportExportModel.forImport(getLocale(), + ObsMerContactImportExportModel.forImport(l, obsProgram, waoUsers, sampleRows, @@ -258,27 +261,96 @@ UpdateContactCommand updateContactCommand = newUpdateContactCommand(authenticatedWaoUser, optionalContactId); - //FIXME Apply imported contact... -// updateContactCommand.setContact(contact); + if (updateContactCommand.isCreation()) { - try { - preValidate(authenticatedWaoUser, updateContactCommand, false); - } catch (ContactNotUpdatableException e) { - if (log.isWarnEnabled()) { - log.warn("Can't update contact: " + contactId); - } - continue; + // TODO bind everything ? + } else { + + // TODO bind only filled ? } + preValidate(authenticatedWaoUser, updateContactCommand, false); + save0(updateContactCommand); } } catch (ImportRuntimeException e) { throw new ImportErrorException(e); - } catch (ContactNotValidException e) { - throw new ImportErrorException(e); - } catch (NullSampleMonthException e) { - throw new ImportErrorException(e); + } catch (ContactNotUpdatableException e) { + String message = l(l, "wao.import.contact.failure.not.updatable"); + throw new ImportErrorException(message); + } catch (UnwantedContactContactStateMotifException e) { + String message = l(l, "wao.import.contact.failure.unwantedContactStateMotif"); + throw new ImportErrorException(message); + } catch (MissingContactNbObservantsForObservationDoneStateException e) { + String state = WaoUtils.l(l, e.getContact().getContactState()); + String message = l(l, "wao.import.contact.failure.missingObserver", state); + throw new ImportErrorException(message); + } catch (MissingContactObservationEndDateException e) { + String state = WaoUtils.l(l, e.getContact().getContactState()); + String message = l(l, "wao.import.contact.failure.missingObservationEndDate", state); + throw new ImportErrorException(message); + } catch (ContactDataInputDateAfterObservationEndDateException e) { + String message = l(l, "wao.import.contact.failure.dataInputDateAfterObservationEndDate"); + throw new ImportErrorException(message); + } catch (InvalidContactObservationBeginDateException e) { + String message = l(l, "wao.import.contact.failure.invalidObservationBeginDate"); + throw new ImportErrorException(message); + } catch (MissingContactRestitutionException e) { + String message = l(l, "wao.import.contact.failure.missingRestitution"); + throw new ImportErrorException(message); + } catch (ContactDataInputDateAfterTodayException e) { + String message = l(l, "wao.import.contact.failure.dataInputDateAfterObservationEndDate"); + throw new ImportErrorException(message); + } catch (MissingContactCommentException e) { + String state = WaoUtils.l(l, e.getContact().getContactState()); + String message = l(l, "wao.import.contact.failure.missingComment", state); + throw new ImportErrorException(message); + } catch (MismatchContactMainObserverCompanyException e) { + String companyName = e.getCompany().getName(); + String observerLogin = e.getObserver().getLogin(); + String message = l(l, "wao.import.contact.failure.mismatchCompanyForObserver", observerLogin, companyName); + throw new ImportErrorException(message); + } catch (ContactRestitutionDateBeforeDataInputDateException e) { + String message = l(l, "wao.import.contact.failure.transmissionDateBeforeDataInputDate"); + throw new ImportErrorException(message); + } catch (ContactObservationEndDateBeforeBeginDateException e) { + String message = l(l, "wao.import.contact.failure.observationEndDateBeforeBeginDate"); + throw new ImportErrorException(message); + } catch (DuplicatedContactMainObserverInSecondaryObserversException e) { + String message = l(l, "wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers"); + throw new ImportErrorException(message); + } catch (MissingContactDataReliabilityException e) { + String message = l(l, "wao.import.contact.failure.missingDataReliability"); + throw new ImportErrorException(message); + } catch (MismatchContactSecondaryObserverCompanyException e) { + String companyName = e.getCompany().getName(); + String observerLogin = e.getObserver().getLogin(); + String message = l(l, "wao.import.contact.failure.mismatchCompanyForObserver", observerLogin, companyName); + throw new ImportErrorException(message); + } catch (MissingContactObservedDataControlException e) { + String message = l(l, "wao.import.contact.failure.missingObservedDataControl"); + throw new ImportErrorException(message); + } catch (MissingContactStateMotifException e) { + String message = l(l, "wao.import.contact.failure.missingContactStateMotif"); + throw new ImportErrorException(message); + } catch (MissingContactDataInputDateException e) { + String message = l(l, "wao.import.contact.failure.missingDataInputDate"); + throw new ImportErrorException(message); + } catch (MissingContactMainObserverException e) { + String message = l(l, "wao.import.contact.failure.missingMainObserver"); + throw new ImportErrorException(message); + } catch (MissingContactCommentAdminException e) { + String dataReliability = WaoUtils.l(l, e.getContact().getDataReliability()); + String message = l(l, "wao.import.contact.failure.missingCommentAdmin", dataReliability); + throw new ImportErrorException(message); + } catch (ContactObservationEndDateAfterTodayException e) { + String message = l(l, "wao.import.contact.failure.observationEndDateAfterToday"); + throw new ImportErrorException(message); + } catch (MissingContactObservationBeginDateException e) { + String state = WaoUtils.l(l, e.getContact().getContactState()); + String message = l(l, "wao.import.contact.failure.missingObservationBeginDate", state); + throw new ImportErrorException(message); } commit(); @@ -286,7 +358,29 @@ public void preValidate(AuthenticatedWaoUser authenticatedWaoUser, UpdateContactCommand updateContactCommand, - boolean needUpdate) throws ContactNotUpdatableException, ContactNotValidException { + boolean needUpdate) throws + ContactNotUpdatableException, + MissingContactMainObserverException, + MismatchContactMainObserverCompanyException, + DuplicatedContactMainObserverInSecondaryObserversException, + MismatchContactSecondaryObserverCompanyException, + InvalidContactObservationBeginDateException, + ContactObservationEndDateBeforeBeginDateException, + ContactObservationEndDateAfterTodayException, + ContactDataInputDateAfterObservationEndDateException, + ContactDataInputDateAfterTodayException, + MissingContactCommentException, + MissingContactObservationBeginDateException, + MissingContactObservationEndDateException, + MissingContactNbObservantsForObservationDoneStateException, + MissingContactStateMotifException, + UnwantedContactContactStateMotifException, + MissingContactObservedDataControlException, + MissingContactRestitutionException, + MissingContactDataInputDateException, + ContactRestitutionDateBeforeDataInputDateException, + MissingContactDataReliabilityException, + MissingContactCommentAdminException { if (needUpdate) { Preconditions.checkState(!updateContactCommand.isCreation()); @@ -310,155 +404,204 @@ Locale l = serviceContext.getLocale(); - if (contact.getMainObserver() == null) { - throw new ContactNotValidException(l(l, "wao.import.contact.failure.missing.main.observer")); - } + Company company = contact.getSampleRow().getCompany(); - if (contact.isSecondaryObserversNotEmpty() && contact.getSecondaryObservers().contains(contact.getMainObserver())) { - throw new ContactNotValidException(l(l, "wao.import.contact.failure.mainObserver.cant.be.secondaryObserver")); - } + WaoUser mainObserver = contact.getMainObserver(); - for (WaoUser observer : contact.getAllObservers()) { - boolean observerWorksForCompanyInSampleRow = observer.getCompany().equals(contact.getSampleRow().getCompany()); + { + //--- + // mainObserver + //--- + + if (mainObserver == null) { + throw new MissingContactMainObserverException(contact); + } + + boolean observerWorksForCompanyInSampleRow = mainObserver.getCompany().equals(company); if (!observerWorksForCompanyInSampleRow) { - throw new ContactNotValidException(l(l, "wao.import.contact.failure.invalid.company.for.observer", - observer.getLogin(), contact.getSampleRow().getCompany().getName())); + throw new MismatchContactMainObserverCompanyException(contact, company, mainObserver); } } - // Validation for saving contact depends on contactState - ContactState contactState = contact.getContactState(); - Date observationBeginDate = contact.getObservationBeginDate(); - if (log.isDebugEnabled()) { - log.debug("For state : " + contactState + " and observation begin date " + observationBeginDate); - } + if (contact.isSecondaryObserversNotEmpty()) { - // need the sample months to be loaded, it's never the case :-( - // boolean operationBeginDateIsValid = contact.getSampleRow().isValid(observationBeginDate); + //--- + // secondaryObservers + //--- - String sampleRowCode = contact.getSampleRow().getCode(); - SampleRow sampleRow = getSampleRowDao().forCodeEquals(sampleRowCode).findAny(); + if (contact.getSecondaryObservers().contains(mainObserver)) { + throw new DuplicatedContactMainObserverInSecondaryObserversException(contact); + } - SampleMonth month = sampleRow.getSampleMonth(observationBeginDate); - boolean operationBeginDateIsValid = month != null; - - if (log.isDebugEnabled()) { - log.debug("operation begin data is valid : " + operationBeginDateIsValid); + for (WaoUser observer : contact.getSecondaryObservers()) { + boolean observerWorksForCompanyInSampleRow = observer.getCompany().equals(company); + if (!observerWorksForCompanyInSampleRow) { + throw new MismatchContactSecondaryObserverCompanyException(contact, observer, company); + } + } } - if (observationBeginDate != null && !operationBeginDateIsValid) { - throw new ContactNotValidException(l(l, "wao.import.contact.failure.invalid.trip.beginDate", - contact.getSampleRow().getCode())); - } - + Date observationBeginDate = contact.getObservationBeginDate(); Date observationEndDate = contact.getObservationEndDate(); - if (observationBeginDate != null && observationEndDate != null - && observationEndDate.before(observationBeginDate)) { - throw new ContactNotValidException(l(l, "wao.import.contact.failure.invalid.observation.endDate")); - } - Date dataInputDate = contact.getDataInputDate(); - // 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); + SampleRow sampleRow = contact.getSampleRow(); + + if (observationBeginDate != null) { + + //--- + // observationBeginDate + //--- + + SampleMonth month = sampleRow.getSampleMonth(observationBeginDate); + boolean operationBeginDateIsValid = month != null; + + if (!operationBeginDateIsValid) { + throw new InvalidContactObservationBeginDateException(contact); + } } - if (!observationEndDateIsBeforeDataInputDate) { - throw new ContactNotValidException(l(l, "wao.import.contact.failure.invalid.observation.end")); - } Date currentDate = serviceContext.getNow(); - if (observationEndDate != null && observationEndDate.after(currentDate)) { - throw new ContactNotValidException(l(l, "wao.import.contact.failure.invalid.trip.endDate")); - } - if (dataInputDate != null && dataInputDate.after(currentDate)) { - throw new ContactNotValidException(l(l, "wao.import.contact.failure.invalid.observation.end2")); - } + if (observationEndDate != null) { - // Non abouti - if (contactState == ContactState.OBSERVATION_CANCELLED && StringUtils.isBlank(contact.getComment())) { - throw new ContactNotValidException(l(l, "wao.business.contact.validation.commentMissingForState", - contact.getContactState().toString())); - // Observation réalisée - } else if (contactState.equals(ContactState.OBSERVATION_DONE)) { + //--- + // observationEndDate + //--- - if (observationBeginDate == null) { - throw new ContactNotValidException(l(l, "wao.import.contact.failure.missing.trip.beginDate", contactState)); + if (observationBeginDate != null + && observationEndDate.before(observationBeginDate)) { + throw new ContactObservationEndDateBeforeBeginDateException(contact); } - if (observationEndDate == null) { - throw new ContactNotValidException(l(l, "wao.import.contact.failure.missing.observation.endDate", contactState)); + + if (observationEndDate.after(currentDate)) { + throw new ContactObservationEndDateAfterTodayException(contact, currentDate); } - if (contact.getNbObservants() == 0) { - throw new ContactNotValidException(l(l, "wao.import.contact.failure.invalid.observer.state", contactState)); - } - if (contact.getObsProgram() == ObsProgram.OBSVENTE) { - if (contact.getTerrestrialLocation() == null) { - throw new ContactNotValidException(l(l, "wao.import.contact.failure.missing.observationArea")); + + } + + if (dataInputDate != null) { + + //--- + // dataInputDate + //--- + + if (observationEndDate != null) { + + // 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.before(DateUtil.setMaxTimeOfDay(dataInputDate)); + + if (!observationEndDateIsBeforeDataInputDate) { + throw new ContactDataInputDateAfterObservationEndDateException(contact); } } + + if (dataInputDate.after(currentDate)) { + throw new ContactDataInputDateAfterTodayException(contact, currentDate); + } } - boolean contactMustHaveAMotif = contact.getObsProgram() == ObsProgram.OBSMER - && (contactState == ContactState.CONTACT_REFUSED - || contactState == ContactState.CONTACT_DEFINITELY_REFUSED); + //--- + // contactState + //--- + + ContactState contactState = contact.getContactState(); + + boolean contactMustHaveAMotif = false; + switch (contactState) { + case OBSERVATION_CANCELLED: + + // Non abouti + + if (StringUtils.isBlank(contact.getComment())) { + throw new MissingContactCommentException(contact); + } + break; + case OBSERVATION_DONE: + + // Observation réalisée + + if (observationBeginDate == null) { + throw new MissingContactObservationBeginDateException(contact); + } + if (observationEndDate == null) { + throw new MissingContactObservationEndDateException(contact); + } + if (contact.getNbObservants() == 0) { + throw new MissingContactNbObservantsForObservationDoneStateException(contact); + } + break; + + case CONTACT_REFUSED: + contactMustHaveAMotif = true; + break; + case CONTACT_DEFINITELY_REFUSED: + contactMustHaveAMotif = true; + break; + + } + + //--- + // contactStateMotif + //--- + if (contactMustHaveAMotif && contact.getContactStateMotif() == null) { - throw new ContactNotValidException(l(l, "wao.business.contact.validation.contactStateMotifMissing")); + throw new MissingContactStateMotifException(contact); } if (!contactMustHaveAMotif && contact.getContactStateMotif() != null) { - throw new ContactNotValidException(l(l, "wao.business.contact.validation.contactStateMotifUnwanted")); + throw new UnwantedContactContactStateMotifException(contact); } - if (log.isDebugEnabled()) { - log.debug("validationProgram = " + contact.getValidationProgram()); - } + if (BooleanUtils.isTrue(contact.getValidationCompany())) { - if (BooleanUtils.isTrue(contact.getValidationCompany())) { + //--- + // validationCompany + //--- + // Pour valider un contact société, il faut que le contact aie une date de transmission - if (contact.getContactState() == ContactState.OBSERVATION_DONE && contact.getObservedDataControl() == null) { - throw new ContactNotValidException(l(l, "wao.business.contact.validation.observedDataControlMissingForValidation")); + if (ContactState.OBSERVATION_DONE == contactState && contact.getObservedDataControl() == null) { + throw new MissingContactObservedDataControlException(contact); } - if (contact.getObservedDataControl() == ObservedDataControl.ACCEPTED && contact.getRestitution() == null) { - throw new ContactNotValidException(l(l, "wao.business.contact.validation.restitutionMissingForValidation")); + Date restitution = contact.getRestitution(); + + if (ObservedDataControl.ACCEPTED == contact.getObservedDataControl() && restitution == null) { + throw new MissingContactRestitutionException(contact); } - if (contact.getDataInputDate() == null && contact.getRestitution() != null) { - throw new ContactNotValidException(l(l, "wao.import.contact.failure.missing.observationDate")); + if (dataInputDate == null && restitution != null) { + throw new MissingContactDataInputDateException(contact); } - if (contact.getDataInputDate() != null && contact.getRestitution() != null && contact.getRestitution().before(contact.getDataInputDate())) { - throw new ContactNotValidException(l(l, "wao.import.contact.failure.invalid.transmissionDate")); + if (dataInputDate != null && restitution != null && restitution.before(dataInputDate)) { + throw new ContactRestitutionDateBeforeDataInputDateException(contact); } } if (BooleanUtils.isTrue(contact.getValidationProgram())) { + + //--- + // validationProgram + //--- + // it's an admin validation, data-reliability field must be filled - if (log.isDebugEnabled()) { - log.debug("field data reliability is " + contact.getDataReliability()); - } - if (contact.getDataReliability() == null || - contact.getDataReliability() == DataReliability.UNKNOWN) { - throw new ContactNotValidException(l(l, "wao.business.contact.validation.dataReliabilityMissingForValidation")); - } else if (contact.getDataReliability() != DataReliability.RELIABLE + DataReliability dataReliability = contact.getDataReliability(); + + if (dataReliability == null || DataReliability.UNKNOWN == dataReliability) { + throw new MissingContactDataReliabilityException(contact); + } else if (DataReliability.RELIABLE != dataReliability && StringUtils.isEmpty(contact.getCommentAdmin())) { - throw new ContactNotValidException(l(l, "wao.business.contact.validation.commentAdminNecessaryForDataReliability", - contact.getDataReliability().toString())); + throw new MissingContactCommentAdminException(contact); } } } } public void save(UpdateContactCommand updateContactCommand, - boolean needUpdate) throws ContactNotValidException, ContactNotUpdatableException, NullSampleMonthException { + boolean needUpdate) throws ContactNotUpdatableException { if (needUpdate) { Preconditions.checkState(!updateContactCommand.isCreation()); @@ -490,7 +633,7 @@ commit(); } - protected void save0(UpdateContactCommand updateContactCommand) throws NullSampleMonthException { + protected void save0(UpdateContactCommand updateContactCommand) { // Get contact to validate (must exist) Contact contact = updateContactCommand.getContact(); Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UnwantedContactContactStateMotifException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UnwantedContactContactStateMotifException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UnwantedContactContactStateMotifException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,18 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.entity.Contact; + +/** + * Created on 4/7/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class UnwantedContactContactStateMotifException extends WaoContactValidationException { + + private static final long serialVersionUID = 1L; + + public UnwantedContactContactStateMotifException(Contact contact) { + super(contact); + } +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UnwantedContactContactStateMotifException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateContactCommand.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateContactCommand.java 2014-04-07 17:07:49 UTC (rev 1857) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateContactCommand.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -130,7 +130,7 @@ */ public boolean mustValidateContact() { boolean needValidation = isCreation() || // new contact - oldValidationProgram == null || // want to unvalidate a contact + oldValidationProgram == null || // want to validate a contact getValidationProgram() != null; // want to validate a contact return needValidation; } Copied: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoContactValidationException.java (from rev 1848, trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactNotValidException.java) =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoContactValidationException.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoContactValidationException.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -0,0 +1,48 @@ +package fr.ifremer.wao.services.service; + +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import fr.ifremer.wao.WaoException; +import fr.ifremer.wao.entity.Contact; + +/** + * Exception de base pour la validation d'une création - mise à jour ou import d'un contact. + * <p/> + * Created on 4/4/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +public class WaoContactValidationException extends WaoException { + + private static final long serialVersionUID = 1L; + + protected Contact contact; + + public WaoContactValidationException(Contact contact) { + this.contact = contact; + } + + public Contact getContact() { + return 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-04-07 17:07:49 UTC (rev 1857) +++ trunk/wao-services/src/main/resources/i18n/wao-services_en_GB.properties 2014-04-07 17:09:47 UTC (rev 1858) @@ -17,14 +17,6 @@ wao.business.completeSampling.false=No wao.business.completeSampling.true=Yes wao.business.completeSampling.undefined=Undefined -wao.business.contact.validation.commentAdminNecessaryForDataReliability=You must precise in admin comment why data reliability is '%s' -wao.business.contact.validation.commentMissingForState=You must give a comment for state '%s' -wao.business.contact.validation.contactStateMotifMissing=You must precise a motif for the refusal -wao.business.contact.validation.contactStateMotifUnwanted=You must not give a motif -wao.business.contact.validation.dataReliabilityMissingForValidation=You must provide data reliability before validating -wao.business.contact.validation.missingHoursOfBeginEndObservation=You must provide accurate time for the beginning and the end of observation -wao.business.contact.validation.observedDataControlMissingForValidation=You must provide a value for observed data control -wao.business.contact.validation.restitutionMissingForValidation=You must provide the restitution forward date wao.business.entity.UserProfile.description=%s on %s%s wao.business.mammalsCapture.mail.message=Hello,\n\nAn observer of the ObsMer program provided to WAO the following information\:\n\nTide\: %s\nProfession\: %s\n\nAccidental capture\:\n%s\n\nBest regards,\n\nObsmer program\nhttp\://www.ifremer.fr/wao wao.business.mammalsCapture.mail.subject=Obsmer WAO\: Information about an accidental capture @@ -39,33 +31,42 @@ wao.import.boat.failure.invalid.locationCode=The code '%s' is not a valid location code wao.import.boat.failure.missing.port=The port is required wao.import.contact.failure.boatMissing=You need to precise the plate number of the boat associated to the contact +wao.import.contact.failure.dataInputDateAfterObservationEndDate=La date de saisie des données doit être postérieure à la date de fin d'observation +wao.import.contact.failure.dataInputDateBeforeToday=La date de saisie des données doit être antérieur à la date du jour wao.import.contact.failure.districtMissing=You need to precise the boat district -wao.import.contact.failure.invalid.company.for.observer=L'observateur %s n'est pas membre de la société %s -wao.import.contact.failure.invalid.dataInputDate=La date de saisie des données ne peut pas être postérieure à la date du jour -wao.import.contact.failure.invalid.dataInputDate2=La date de saisie des données ne peut pas être antérieure à la date de fin d'observation -wao.import.contact.failure.invalid.observation.endDate=La date de fin d'observation ne peut pas être antérieure à celle du début -wao.import.contact.failure.invalid.observer.state=Il ne peut y avoir aucun observateur pour l'état '%s' -wao.import.contact.failure.invalid.transmissionDate=Il faut que la date de transmission de la restitution soit après la date de saisie des données -wao.import.contact.failure.invalid.trip.beginDate=La date de début de la marée doit correspondre à un mois valide (non vide) de la ligne -wao.import.contact.failure.invalid.trip.endDate=La date de fin de la marée ne peut pas être postérieure à la date du jour +wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers=Main observer can not be also a secondary observer +wao.import.contact.failure.invalidObservationBeginDate=La date de début de la marée doit correspondre à un mois valide (non vide) de la ligne wao.import.contact.failure.locationTypeMissing=The type of the location must be filled -wao.import.contact.failure.mainObserver.cant.be.secondaryObserver= -wao.import.contact.failure.mainObserver.cant.be.secondaryObserver.=L'utilisateur référant ne doit pas se trouver aussi parmi les observateurs secondaires -wao.import.contact.failure.missing.main.observer=Il faut au moins un observateur référant -wao.import.contact.failure.missing.observation.endDate=La date de fin d'observation est obligatoire pour l'état '%s' -wao.import.contact.failure.missing.observationArea=Il faut préciser un lieu d'observation -wao.import.contact.failure.missing.observationDate=Il faut préciser une date de saisie des données en plus de la date de transmission de la restitution -wao.import.contact.failure.missing.trip.beginDate=La date de début de marée est obligatoire pour l'état '%s' +wao.import.contact.failure.mismatchCompanyForObserver=L'observateur %s n'est pas membre de la société %s +wao.import.contact.failure.missingComment=You must give a comment for state '%s' +wao.import.contact.failure.missingCommentAdmin=You must precise in admin comment why data reliability is '%s' +wao.import.contact.failure.missingContactStateMotif=You must precise a motif for the refusal +wao.import.contact.failure.missingDataInputDate=Il faut préciser une date de saisie des données en plus de la date de transmission de la restitution +wao.import.contact.failure.missingDataReliability=You must provide data reliability before validating +wao.import.contact.failure.missingHoursOfBeginEndObservation=You must provide accurate time for the beginning and the end of observation +wao.import.contact.failure.missingMainBbserver=Il faut au moins un observateur référant +wao.import.contact.failure.missingMainObserver= +wao.import.contact.failure.missingObservationArea=Il faut préciser un lieu d'observation +wao.import.contact.failure.missingObservationBeginDate=La date de début de marée est obligatoire pour l'état '%s' +wao.import.contact.failure.missingObservationEndDate=La date de fin d'observation est obligatoire pour l'état '%s' +wao.import.contact.failure.missingObservedDataControl=You must provide a value for observed data control +wao.import.contact.failure.missingObserver=Il ne peut y avoir aucun observateur pour l'état '%s' +wao.import.contact.failure.missingRestitution=You must provide the restitution forward date +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.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 wao.import.contact.failure.unkwonCompany=Company named '%s' does not exist +wao.import.contact.failure.unwantedContactStateMotif=You must not give a motif wao.import.contact.failure.wrongBoat=There is no boat with plate number '%s' wao.import.contact.failure.wrongColor=The color '%s' is not a valid color. It must be composed of 6 characters without the hash (\#), see http\://en.wikipedia.org/wiki/Web_colors wao.import.contact.failure.wrongContactStateMotifCode=The code '%s' is not a valid code wao.import.contact.failure.wrongDistrict='%s' is not a valid boat district code wao.import.contact.failure.wrongSampleRowCode=The is no sample row with code '%s' wao.import.contact.failure.wrongTerrestrialLocation=There is no location of type '%s' with code '%s' -wao.import.failure=Import fail. +wao.import.failure=Import fail for reason\: %s. wao.import.failure.invalid.regionCode=The code '%s' is not a valid region code wao.import.failure.wrongLocationType='%s' is not a valid location type, allowed values are %s wao.import.failure.wrongObsDebCode=There is no profession code having code '%s' 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-04-07 17:07:49 UTC (rev 1857) +++ trunk/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties 2014-04-07 17:09:47 UTC (rev 1858) @@ -17,14 +17,6 @@ wao.business.completeSampling.false=Non wao.business.completeSampling.true=Oui wao.business.completeSampling.undefined=Non défini -wao.business.contact.validation.commentAdminNecessaryForDataReliability=Il faut préciser dans le commentaire administrateur pourquoi la donnée est '%s' -wao.business.contact.validation.commentMissingForState=Il faut préciser un commentaire pour l'état '%s' -wao.business.contact.validation.contactStateMotifMissing=Il faut préciser un motif de refus -wao.business.contact.validation.contactStateMotifUnwanted=Il ne faut pas préciser de motif de refus -wao.business.contact.validation.dataReliabilityMissingForValidation=Il faut préciser la qualité de la donnée avant de valider -wao.business.contact.validation.missingHoursOfBeginEndObservation=Il faut préciser les heures exactes de début et de fin d'observation -wao.business.contact.validation.observedDataControlMissingForValidation=Il faut préciser une valeur pour le contrôle des données observées -wao.business.contact.validation.restitutionMissingForValidation=Il faut préciser une date de transmission de la restitution de la donnée avant de valider wao.business.entity.UserProfile.description=%s sur %s%s wao.business.mammalsCapture.mail.message=Bonjour,\n\nUn observateur du programme Obsmer a renseigné dans WAO l'information suivante \:\n\nMarée \: %s\nMétier \: %s\n\nCapture accidentelle \:\n%s\n\nCordialement,\n\nLe programme Obsmer\nhttp\://www.ifremer.fr/wao wao.business.mammalsCapture.mail.subject=Obsmer WAO\: Information sur capture accidentelle @@ -38,33 +30,43 @@ wao.import.boat.failure.invalid.locationCode=Le code '%s' n'est pas un code de lieu valide wao.import.boat.failure.missing.port=Il faut préciser un port wao.import.contact.failure.boatMissing=Il faut préciser l'immatriculation du navire associé au contact +wao.import.contact.failure.dataInputDateAfterObservationEndDate= +wao.import.contact.failure.dataInputDateBeforeObservationEndDate=La date de saisie des données ne peut pas être antérieure à la date de fin d'observation +wao.import.contact.failure.dataInputDateBeforeToday=La date de saisie des données doit être antérieur à la date du jour wao.import.contact.failure.districtMissing=Il faut préciser le code d'un quartier maritime -wao.import.contact.failure.invalid.company.for.observer=L'observateur %s n'est pas membre de la société %s -wao.import.contact.failure.invalid.dataInputDate=La date de saisie des données ne peut pas être postérieure à la date du jour -wao.import.contact.failure.invalid.dataInputDate2=La date de saisie des données ne peut pas être antérieure à la date de fin d'observation -wao.import.contact.failure.invalid.observation.endDate=La date de fin d'observation ne peut pas être antérieure à celle du début -wao.import.contact.failure.invalid.observer.state=Il ne peut y avoir aucun observateur pour l'état '%s' -wao.import.contact.failure.invalid.transmissionDate=Il faut que la date de transmission de la restitution soit après la date de saisie des données -wao.import.contact.failure.invalid.trip.beginDate=La date de début de la marée doit correspondre à un mois valide (non vide) de la ligne -wao.import.contact.failure.invalid.trip.endDate=La date de fin de la marée ne peut pas être postérieure à la date du jour +wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers=L'utilisateur référant ne doit pas se trouver aussi parmi les observateurs secondaires +wao.import.contact.failure.invalid.observationBeginDate=La date de début de la marée doit correspondre à un mois valide (non vide) de la ligne +wao.import.contact.failure.invalidObservationBeginDate= wao.import.contact.failure.locationTypeMissing=Le type du lieu doit être renseigné -wao.import.contact.failure.mainObserver.cant.be.secondaryObserver= -wao.import.contact.failure.mainObserver.cant.be.secondaryObserver.=L'utilisateur référant ne doit pas se trouver aussi parmi les observateurs secondaires -wao.import.contact.failure.missing.main.observer=Il faut au moins un observateur référant -wao.import.contact.failure.missing.observation.endDate=La date de fin d'observation est obligatoire pour l'état '%s' -wao.import.contact.failure.missing.observationArea=Il faut préciser un lieu d'observation -wao.import.contact.failure.missing.observationDate=Il faut préciser une date de saisie des données en plus de la date de transmission de la restitution -wao.import.contact.failure.missing.trip.beginDate=La date de début de marée est obligatoire pour l'état '%s' +wao.import.contact.failure.mismatchCompanyForObserver=L'observateur %s n'est pas membre de la société %s +wao.import.contact.failure.missingComment=Il faut préciser un commentaire pour l'état '%s' +wao.import.contact.failure.missingCommentAdmin=Il faut préciser dans le commentaire administrateur pourquoi la donnée est '%s' +wao.import.contact.failure.missingContactStateMotif=Il faut préciser un motif de refus +wao.import.contact.failure.missingDataInputDate=Il faut préciser une date de saisie des données en plus de la date de transmission de la restitution +wao.import.contact.failure.missingDataReliability=Il faut préciser la qualité de la donnée avant de valider +wao.import.contact.failure.missingHoursOfBeginEndObservation=Il faut préciser les heures exactes de début et de fin d'observation +wao.import.contact.failure.missingMainObserver=Il faut au moins un observateur référant +wao.import.contact.failure.missingObservationArea=Il faut préciser un lieu d'observation +wao.import.contact.failure.missingObservationBeginDate=La date de début de marée est obligatoire pour l'état '%s' +wao.import.contact.failure.missingObservationEndDate=La date de fin d'observation est obligatoire pour l'état '%s' +wao.import.contact.failure.missingObservedDataControl=Il faut préciser une valeur pour le contrôle des données observées +wao.import.contact.failure.missingObserver=Il ne peut y avoir aucun observateur pour l'état '%s' +wao.import.contact.failure.missingRestitution=Il faut préciser une date de transmission de la restitution de la donnée avant de valider +wao.import.contact.failure.not.updatable=Vous n'avez pas les droits suffisants pour modifier le 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.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=Il faut que la date de transmission de la restitution soit après la date de saisie des données wao.import.contact.failure.unkwonCompany=Il n'y a pas de société ayant pour nom '%s' +wao.import.contact.failure.unwantedContactStateMotif=Il ne faut pas préciser de motif de refus wao.import.contact.failure.wrongBoat=Il n'y a pas de navire avec l'immatriculation '%s' wao.import.contact.failure.wrongColor=Le code couleur '%s' n'est pas valide, il doit être composé de six caractères sans dièze voir http\://fr.wikipedia.org/wiki/Couleurs_du_Web wao.import.contact.failure.wrongContactStateMotifCode=Le code '%s' n'est pas un code de motif de refus valide wao.import.contact.failure.wrongDistrict='%s' n'est pas un code quartier maritime valide wao.import.contact.failure.wrongSampleRowCode=Il n'y a pas de ligne du plan avec le code '%s' wao.import.contact.failure.wrongTerrestrialLocation=Il n'y a pas de lieu de type '%s' ayant pour code '%s' -wao.import.failure=Une erreur est survenue lors de l'import. +wao.import.failure=Une erreur est survenue lors de l'import \: %s. wao.import.failure.invalid.regionCode=Le code '%s' n'est pas un code de région valide wao.import.failure.wrongLocationType='%s' n'est pas un type de lieu valide, les valeurs admises sont %s wao.import.failure.wrongObsDebCode=Il n'y a pas de code métier ayant pour code '%s' Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/AbstractImportCsvAction.java =================================================================== --- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/AbstractImportCsvAction.java 2014-04-07 17:07:49 UTC (rev 1857) +++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/AbstractImportCsvAction.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -93,7 +93,7 @@ } catch (ImportErrorException e) { - session.addErrorMessages(e.getMessage()); + session.addErrorMessages(e.getMessage(getLocale())); result = ERROR; 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-04-07 17:07:49 UTC (rev 1857) +++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/EditContactAction.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -24,10 +24,31 @@ import com.google.common.base.Optional; import com.google.common.base.Strings; import com.opensymphony.xwork2.Preparable; +import fr.ifremer.wao.WaoUtils; import fr.ifremer.wao.services.AuthenticatedWaoUser; +import fr.ifremer.wao.services.service.ContactDataInputDateAfterObservationEndDateException; +import fr.ifremer.wao.services.service.ContactDataInputDateAfterTodayException; import fr.ifremer.wao.services.service.ContactNotUpdatableException; -import fr.ifremer.wao.services.service.ContactNotValidException; +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.DuplicatedContactMainObserverInSecondaryObserversException; +import fr.ifremer.wao.services.service.InvalidContactObservationBeginDateException; +import fr.ifremer.wao.services.service.MismatchContactMainObserverCompanyException; +import fr.ifremer.wao.services.service.MismatchContactSecondaryObserverCompanyException; +import fr.ifremer.wao.services.service.MissingContactCommentAdminException; +import fr.ifremer.wao.services.service.MissingContactCommentException; +import fr.ifremer.wao.services.service.MissingContactDataInputDateException; +import fr.ifremer.wao.services.service.MissingContactDataReliabilityException; +import fr.ifremer.wao.services.service.MissingContactMainObserverException; +import fr.ifremer.wao.services.service.MissingContactNbObservantsForObservationDoneStateException; +import fr.ifremer.wao.services.service.MissingContactObservationBeginDateException; +import fr.ifremer.wao.services.service.MissingContactObservationEndDateException; +import fr.ifremer.wao.services.service.MissingContactObservedDataControlException; +import fr.ifremer.wao.services.service.MissingContactRestitutionException; +import fr.ifremer.wao.services.service.MissingContactStateMotifException; import fr.ifremer.wao.services.service.ObsMerContactsService; +import fr.ifremer.wao.services.service.UnwantedContactContactStateMotifException; import fr.ifremer.wao.services.service.UpdateContactCommand; import fr.ifremer.wao.web.WaoJspActionSupport; import org.apache.struts2.convention.annotation.Result; @@ -86,9 +107,81 @@ try { service.preValidate(authenticatedWaoUser, updateContactCommand, true); } catch (ContactNotUpdatableException e) { - addActionError(t("wao.ui.contacts.validation.failure.not.updatable", e.getMessage())); - } catch (ContactNotValidException e) { - addActionError(t("wao.ui.contacts.validation.failure.not.valid", e.getMessage())); + addActionError(t("wao.ui.contacts.validation.failure.not.updatable")); + addFieldError("updateContactCommand.contact.", t("wao.ui.contacts.validation.failure.not.updatable", e.getMessage())); + + } catch (UnwantedContactContactStateMotifException e) { + addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.unwantedContactStateMotif")); + + } catch (MissingContactNbObservantsForObservationDoneStateException e) { + String state = WaoUtils.l(getLocale(), e.getContact().getContactState()); + addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingObserver", state)); + + } catch (MissingContactObservationEndDateException e) { + String state = WaoUtils.l(getLocale(), e.getContact().getContactState()); + addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingObservationEndDate", state)); + + } catch (ContactDataInputDateAfterObservationEndDateException e) { + addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.dataInputDateAfterObservationEndDate")); + + } catch (InvalidContactObservationBeginDateException e) { + addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.invalidObservationBeginDate")); + + } catch (MissingContactRestitutionException e) { + addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingRestitution")); + + } catch (ContactDataInputDateAfterTodayException e) { + addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.dataInputDateAfterObservationEndDate")); + + } catch (MissingContactCommentException e) { + String state = WaoUtils.l(getLocale(), e.getContact().getContactState()); + addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingComment", state)); + + } catch (MismatchContactMainObserverCompanyException e) { + String companyName = e.getCompany().getName(); + String observerLogin = e.getObserver().getLogin(); + addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.mismatchCompanyForObserver", observerLogin, companyName)); + + } catch (ContactRestitutionDateBeforeDataInputDateException e) { + addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.transmissionDateBeforeDataInputDate")); + + } catch (ContactObservationEndDateBeforeBeginDateException e) { + addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.observationEndDateBeforeBeginDate")); + + } catch (DuplicatedContactMainObserverInSecondaryObserversException e) { + addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers")); + + } catch (MissingContactDataReliabilityException e) { + addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingDataReliability")); + + } catch (MismatchContactSecondaryObserverCompanyException e) { + String companyName = e.getCompany().getName(); + String observerLogin = e.getObserver().getLogin(); + addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.mismatchCompanyForObserver", observerLogin, companyName)); + + } catch (MissingContactObservedDataControlException e) { + addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingObservedDataControl")); + + } catch (MissingContactStateMotifException e) { + addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingContactStateMotif")); + + } catch (MissingContactDataInputDateException e) { + addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingDataInputDate")); + + } catch (MissingContactMainObserverException e) { + addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingMainObserver")); + + } catch (MissingContactCommentAdminException e) { + String dataReliability = WaoUtils.l(getLocale(), e.getContact().getDataReliability()); + addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingCommentAdmin", dataReliability)); + + } catch (ContactObservationEndDateAfterTodayException e) { + addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.observationEndDateAfterToday")); + + } catch (MissingContactObservationBeginDateException e) { + String state = WaoUtils.l(getLocale(), e.getContact().getContactState()); + addFieldError("updateContactCommand.contact.", t("wao.import.contact.failure.missingObservationBeginDate", state)); + } } 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-04-07 17:07:49 UTC (rev 1857) +++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ValidateContactJsonAction.java 2014-04-07 17:09:47 UTC (rev 1858) @@ -24,9 +24,31 @@ import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.opensymphony.xwork2.Preparable; +import fr.ifremer.wao.WaoUtils; import fr.ifremer.wao.services.AuthenticatedWaoUser; +import fr.ifremer.wao.services.service.ContactDataInputDateAfterObservationEndDateException; +import fr.ifremer.wao.services.service.ContactDataInputDateAfterTodayException; import fr.ifremer.wao.services.service.ContactNotUpdatableException; -import fr.ifremer.wao.services.service.ContactNotValidException; +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.DuplicatedContactMainObserverInSecondaryObserversException; +import fr.ifremer.wao.services.service.InvalidContactObservationBeginDateException; +import fr.ifremer.wao.services.service.MismatchContactMainObserverCompanyException; +import fr.ifremer.wao.services.service.MismatchContactSecondaryObserverCompanyException; +import fr.ifremer.wao.services.service.MissingContactCommentAdminException; +import fr.ifremer.wao.services.service.MissingContactCommentException; +import fr.ifremer.wao.services.service.MissingContactDataInputDateException; +import fr.ifremer.wao.services.service.MissingContactDataReliabilityException; +import fr.ifremer.wao.services.service.MissingContactMainObserverException; +import fr.ifremer.wao.services.service.MissingContactNbObservantsForObservationDoneStateException; +import fr.ifremer.wao.services.service.MissingContactObservationBeginDateException; +import fr.ifremer.wao.services.service.MissingContactObservationEndDateException; +import fr.ifremer.wao.services.service.MissingContactObservedDataControlException; +import fr.ifremer.wao.services.service.MissingContactRestitutionException; +import fr.ifremer.wao.services.service.MissingContactStateMotifException; +import fr.ifremer.wao.services.service.UnwantedContactContactStateMotifException; +import fr.ifremer.wao.services.service.WaoContactValidationException; import fr.ifremer.wao.services.service.ObsMerContactsService; import fr.ifremer.wao.services.service.UpdateContactCommand; import fr.ifremer.wao.web.WaoJsonActionSupport; @@ -147,9 +169,79 @@ try { service.preValidate(authenticatedWaoUser, updateContactCommand, true); } catch (ContactNotUpdatableException e) { - errorMessage = t("wao.ui.contacts.validation.failure.not.updatable", e.getMessage()); - } catch (ContactNotValidException e) { - errorMessage = t("wao.ui.contacts.validation.failure.not.valid", e.getMessage()); + errorMessage = t("wao.ui.contacts.validation.failure.not.updatable"); + } catch (UnwantedContactContactStateMotifException e) { + errorMessage = t("wao.import.contact.failure.unwantedContactStateMotif"); + + } catch (MissingContactNbObservantsForObservationDoneStateException e) { + String state = WaoUtils.l(getLocale(), e.getContact().getContactState()); + errorMessage = t("wao.import.contact.failure.missingObserver", state); + + } catch (MissingContactObservationEndDateException e) { + String state = WaoUtils.l(getLocale(), e.getContact().getContactState()); + errorMessage = t("wao.import.contact.failure.missingObservationEndDate", state); + + } catch (ContactDataInputDateAfterObservationEndDateException e) { + errorMessage = t("wao.import.contact.failure.dataInputDateAfterObservationEndDate"); + + } catch (InvalidContactObservationBeginDateException e) { + errorMessage = t("wao.import.contact.failure.invalidObservationBeginDate"); + + } catch (MissingContactRestitutionException e) { + errorMessage = t("wao.import.contact.failure.missingRestitution"); + + } catch (ContactDataInputDateAfterTodayException e) { + errorMessage = t("wao.import.contact.failure.dataInputDateAfterObservationEndDate"); + + } catch (MissingContactCommentException e) { + String state = WaoUtils.l(getLocale(), e.getContact().getContactState()); + errorMessage = t("wao.import.contact.failure.missingComment", state); + + } catch (MismatchContactMainObserverCompanyException e) { + String companyName = e.getCompany().getName(); + String observerLogin = e.getObserver().getLogin(); + errorMessage = t("wao.import.contact.failure.mismatchCompanyForObserver", observerLogin, companyName); + + } catch (ContactRestitutionDateBeforeDataInputDateException e) { + errorMessage = t("wao.import.contact.failure.transmissionDateBeforeDataInputDate"); + + } catch (ContactObservationEndDateBeforeBeginDateException e) { + errorMessage = t("wao.import.contact.failure.observationEndDateBeforeBeginDate"); + + } catch (DuplicatedContactMainObserverInSecondaryObserversException e) { + errorMessage = t("wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers"); + + } catch (MissingContactDataReliabilityException e) { + errorMessage = t("wao.import.contact.failure.missingDataReliability"); + + } catch (MismatchContactSecondaryObserverCompanyException e) { + String companyName = e.getCompany().getName(); + String observerLogin = e.getObserver().getLogin(); + errorMessage = t("wao.import.contact.failure.mismatchCompanyForObserver", observerLogin, companyName); + + } catch (MissingContactObservedDataControlException e) { + errorMessage = t("wao.import.contact.failure.missingObservedDataControl"); + + } catch (MissingContactStateMotifException e) { + errorMessage = t("wao.import.contact.failure.missingContactStateMotif"); + + } catch (MissingContactDataInputDateException e) { + errorMessage = t("wao.import.contact.failure.missingDataInputDate"); + + } catch (MissingContactMainObserverException e) { + errorMessage = t("wao.import.contact.failure.missingMainObserver"); + + } catch (MissingContactCommentAdminException e) { + String dataReliability = WaoUtils.l(getLocale(), e.getContact().getDataReliability()); + errorMessage = t("wao.import.contact.failure.missingCommentAdmin", dataReliability); + + } catch (ContactObservationEndDateAfterTodayException e) { + errorMessage = t("wao.import.contact.failure.observationEndDateAfterToday"); + + } catch (MissingContactObservationBeginDateException e) { + String state = WaoUtils.l(getLocale(), e.getContact().getContactState()); + errorMessage = t("wao.import.contact.failure.missingObservationBeginDate", state); + } catch (Exception e) { if (log.isErrorEnabled()) { log.error(e); 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-04-07 17:07:49 UTC (rev 1857) +++ trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties 2014-04-07 17:09:47 UTC (rev 1858) @@ -5,6 +5,25 @@ wao.import.boatGroups.success=Import boats successful wao.import.boats.prompt=Import boat groups wao.import.boats.success=Import boat groups successful +wao.import.contact.failure.dataInputDateAfterObservationEndDate= +wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers= +wao.import.contact.failure.invalidObservationBeginDate= +wao.import.contact.failure.mismatchCompanyForObserver= +wao.import.contact.failure.missingComment= +wao.import.contact.failure.missingCommentAdmin= +wao.import.contact.failure.missingContactStateMotif= +wao.import.contact.failure.missingDataInputDate= +wao.import.contact.failure.missingDataReliability= +wao.import.contact.failure.missingMainObserver= +wao.import.contact.failure.missingObservationBeginDate= +wao.import.contact.failure.missingObservationEndDate= +wao.import.contact.failure.missingObservedDataControl= +wao.import.contact.failure.missingObserver= +wao.import.contact.failure.missingRestitution= +wao.import.contact.failure.observationEndDateAfterToday= +wao.import.contact.failure.observationEndDateBeforeBeginDate= +wao.import.contact.failure.transmissionDateBeforeDataInputDate= +wao.import.contact.failure.unwantedContactStateMotif= wao.import.contactStateMotives.prompt=Import contact state motives wao.import.contactStateMotives.success=Import contact state motives successful wao.import.fishingZones.prompt=Import fishing zones @@ -134,7 +153,7 @@ wao.ui.contacts.title=%s contacts found wao.ui.contacts.validation=Validation wao.ui.contacts.validation.failure=An error occurs %s -wao.ui.contacts.validation.failure.not.updatable=You can not modify this contact\: %s +wao.ui.contacts.validation.failure.not.updatable=You can not modify the contact wao.ui.contacts.validation.failure.not.valid=Contact is not valid\: %s wao.ui.contacts.validation.to.accept.state.success=Contact was accepted successful wao.ui.contacts.validation.to.reject.state.success=Contact was rejected successful 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-04-07 17:07:49 UTC (rev 1857) +++ trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties 2014-04-07 17:09:47 UTC (rev 1858) @@ -5,6 +5,25 @@ wao.import.boatGroups.success=Import des flotilles réalisé avec succès wao.import.boats.prompt=Import des navires wao.import.boats.success=Import des navires réalisé avec succès +wao.import.contact.failure.dataInputDateAfterObservationEndDate= +wao.import.contact.failure.duplicatedMainObserverInSecondaryObservers= +wao.import.contact.failure.invalidObservationBeginDate= +wao.import.contact.failure.mismatchCompanyForObserver= +wao.import.contact.failure.missingComment= +wao.import.contact.failure.missingCommentAdmin= +wao.import.contact.failure.missingContactStateMotif= +wao.import.contact.failure.missingDataInputDate= +wao.import.contact.failure.missingDataReliability= +wao.import.contact.failure.missingMainObserver= +wao.import.contact.failure.missingObservationBeginDate= +wao.import.contact.failure.missingObservationEndDate= +wao.import.contact.failure.missingObservedDataControl= +wao.import.contact.failure.missingObserver= +wao.import.contact.failure.missingRestitution= +wao.import.contact.failure.observationEndDateAfterToday= +wao.import.contact.failure.observationEndDateBeforeBeginDate= +wao.import.contact.failure.transmissionDateBeforeDataInputDate= +wao.import.contact.failure.unwantedContactStateMotif= wao.import.contactStateMotives.prompt=Import des motifs de refus wao.import.contactStateMotives.success=Import des motifs de refus réalisé avec succès wao.import.fishingZones.prompt=Import des zones de pêches @@ -134,7 +153,7 @@ wao.ui.contacts.title=%s contacts trouvés wao.ui.contacts.validation=Validations wao.ui.contacts.validation.failure=Une erreur est survenue %s -wao.ui.contacts.validation.failure.not.updatable=Vous n'avez pas les droits pour modifier ce contact \: %s +wao.ui.contacts.validation.failure.not.updatable=Vous n'avez pas les droits suffisants pour modifier le contact wao.ui.contacts.validation.failure.not.valid=Le contact n'a pas pu être validé pour la raison suivante \: %s wao.ui.contacts.validation.to.accept.state.success=Le contact a été accepté avec succès wao.ui.contacts.validation.to.reject.state.success=Le contact a été rejeté avec succès
participants (1)
-
tchemit@users.forge.codelutin.com