This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository wao. See http://git.codelutin.com/wao.git commit f377b76b2097344b43e2c4dfcbcc7561db44775c Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Oct 23 14:31:01 2014 +0200 Ajout d'un état annulé (météo) pour ObsMer et impact (refs #5352) --- .../java/fr/ifremer/wao/entity/ContactState.java | 31 ++++++++--- .../java/fr/ifremer/wao/entity/ContactStates.java | 24 +++++++++ .../i18n/wao-persistence_en_GB.properties | 2 + .../i18n/wao-persistence_fr_FR.properties | 2 + .../wao/services/service/ContactsFilterValues.java | 2 +- .../wao/services/service/ContactsService.java | 6 +-- .../ifremer/wao/services/service/FilterOption.java | 22 +++++--- .../service/csv/ContactImportExportModel.java | 5 +- .../operations/ContactStateParserFormatter.java | 62 ++++++++++++++++++++++ .../resources/i18n/wao-services_en_GB.properties | 1 + .../resources/i18n/wao-services_fr_FR.properties | 1 + .../ifremer/wao/web/action/EditContactAction.java | 15 ++++-- .../wao/web/action/ValidateContactJsonAction.java | 9 ++-- .../src/main/webapp/WEB-INF/content/contacts.jsp | 2 +- .../src/main/webapp/WEB-INF/content/synthesis.jsp | 2 +- wao-web/src/main/webapp/wao.css | 1 - 16 files changed, 155 insertions(+), 32 deletions(-) diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactState.java b/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactState.java index 3d1d6ce..bb39ebd 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactState.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactState.java @@ -47,7 +47,7 @@ import static org.nuiton.i18n.I18n.n; * * @author fdesbois <fdesbois@codelutin.com> */ -public enum ContactState implements I18nAble { +public enum ContactState { /** Usually, the first step, observer just contacted someone */ CONTACT_START(n("ContactState.CONTACT_START")), @@ -58,9 +58,12 @@ public enum ContactState implements I18nAble { /** Observation was done, all data have been collected. Everything is fine */ OBSERVATION_DONE(n("ContactState.OBSERVATION_DONE")), - /** Observer failed to collect data, weather or any other circumstances made data collection impossible */ + /** Observer failed to collect data, weather (only in ObsVente) or any other circumstances made data collection impossible */ OBSERVATION_CANCELLED(n("ContactState.OBSERVATION_CANCELLED")), + /** Observer failed to collect data, weather or any other circumstances made data collection impossible */ + OBSERVATION_CANCELLED_WEATHER(n("ContactState.OBSERVATION_CANCELLED_WEATHER")), + /** After a contact start, people contacted refused the observation. Observer may try later. */ CONTACT_REFUSED(n("ContactState.CONTACT_REFUSED")), @@ -71,10 +74,10 @@ public enum ContactState implements I18nAble { ImmutableSet.copyOf(values()); protected static final ImmutableSet<ContactState> FINAL_CONTACT_STATES = - ImmutableSet.of(OBSERVATION_CANCELLED, CONTACT_REFUSED, CONTACT_DEFINITELY_REFUSED); + ImmutableSet.of(OBSERVATION_CANCELLED, OBSERVATION_CANCELLED_WEATHER, CONTACT_REFUSED, CONTACT_DEFINITELY_REFUSED); protected static final ImmutableSet<ContactState> UNFINISHED_CONTACT_STATES = - ImmutableSet.of(OBSERVATION_DONE, OBSERVATION_CANCELLED, CONTACT_REFUSED, CONTACT_DEFINITELY_REFUSED); + ImmutableSet.of(OBSERVATION_DONE, OBSERVATION_CANCELLED, OBSERVATION_CANCELLED_WEATHER, CONTACT_REFUSED, CONTACT_DEFINITELY_REFUSED); protected static final ImmutableSetMultimap<ObsProgram, ContactState> ALLOWED_CONTACT_STATES_PER_OBS_PROGRAM = ImmutableSetMultimap.<ObsProgram, ContactState>builder() @@ -88,9 +91,23 @@ public enum ContactState implements I18nAble { this.i18nKey = i18nKey; } - @Override - public String getI18nKey() { - return i18nKey; + public String getI18nKey(ObsProgram obsProgram) { + String result = i18nKey; + if (obsProgram.isObsMer() && OBSERVATION_CANCELLED == this) { + return n("ContactState.OBSERVATION_CANCELLED.obsMer"); + } + return result; + } + + public I18nAble toI18Able(ObsProgram obsProgram) { + final String i18nKey = getI18nKey(obsProgram); + return new I18nAble() { + + @Override + public String getI18nKey() { + return i18nKey; + } + }; } /** if true, the state may not be changed. */ diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactStates.java b/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactStates.java new file mode 100644 index 0000000..3c75d1b --- /dev/null +++ b/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactStates.java @@ -0,0 +1,24 @@ +package fr.ifremer.wao.entity; + +import com.google.common.base.Function; + +public class ContactStates { + + public static Function<ContactState, I18nAble> toI18Able(ObsProgram obsProgram) { + return new ToI18nAble(obsProgram); + } + + protected static class ToI18nAble implements Function<ContactState, I18nAble> { + + protected ObsProgram obsProgram; + + public ToI18nAble(ObsProgram obsProgram) { + this.obsProgram = obsProgram; + } + + @Override + public I18nAble apply(ContactState input) { + return input.toI18Able(obsProgram); + } + } +} diff --git a/wao-persistence/src/main/resources/i18n/wao-persistence_en_GB.properties b/wao-persistence/src/main/resources/i18n/wao-persistence_en_GB.properties index ec18ca6..75d34a3 100644 --- a/wao-persistence/src/main/resources/i18n/wao-persistence_en_GB.properties +++ b/wao-persistence/src/main/resources/i18n/wao-persistence_en_GB.properties @@ -5,6 +5,8 @@ ContactState.CONTACT_DEFINITELY_REFUSED=Definitely refused ContactState.CONTACT_REFUSED=Refused ContactState.CONTACT_START=Contact started ContactState.OBSERVATION_CANCELLED=Cancelled +ContactState.OBSERVATION_CANCELLED.obsMer=Cancelled (other reason) +ContactState.OBSERVATION_CANCELLED_WEATHER=Cancelled due to weather ContactState.OBSERVATION_DONE=Observation done ContactState.OBSERVATION_EXPECTED=Observation expected ContactState.OBSERVATION_NOT_DONE=Not observed diff --git a/wao-persistence/src/main/resources/i18n/wao-persistence_fr_FR.properties b/wao-persistence/src/main/resources/i18n/wao-persistence_fr_FR.properties index 1720713..b174041 100644 --- a/wao-persistence/src/main/resources/i18n/wao-persistence_fr_FR.properties +++ b/wao-persistence/src/main/resources/i18n/wao-persistence_fr_FR.properties @@ -5,6 +5,8 @@ ContactState.CONTACT_DEFINITELY_REFUSED=Refus définitif ContactState.CONTACT_REFUSED=Refus ContactState.CONTACT_START=Contact pris ContactState.OBSERVATION_CANCELLED=Annulée +ContactState.OBSERVATION_CANCELLED.obsMer=Annulée (autre motif) +ContactState.OBSERVATION_CANCELLED_WEATHER=Annulée (météo) ContactState.OBSERVATION_DONE=Observation réalisée ContactState.OBSERVATION_EXPECTED=Observation programmée ContactState.OBSERVATION_NOT_DONE=Non observé diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValues.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValues.java index 3f07c9c..685b673 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValues.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValues.java @@ -97,7 +97,7 @@ public class ContactsFilterValues extends AbstractFilterValues { ContactState contactState = contact.getContactState(); if (contactState != null) { - contactStates.add(FilterOption.forEnum(locale, contactState)); + contactStates.add(FilterOption.forEnumAndI18nKey(locale, contactState, contactState.getI18nKey(obsProgram))); } DataReliability dataReliability = contact.getDataReliability(); diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java index 68d9abb..a3f1387 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java @@ -433,7 +433,7 @@ public class ContactsService extends WaoServiceSupport { String message = l(l, "wao.import.contact.failure.unwantedContactStateMotif", lineNumber); throw new ImportErrorException(message); } catch (MissingContactObservationEndDateException e) { - String state = WaoUtils.l(l, e.getContact().getContactState()); + String state = WaoUtils.l(l, e.getContact().getContactState().toI18Able(obsProgram)); String message = l(l, "wao.import.contact.failure.missingObservationEndDate", lineNumber, state); throw new ImportErrorException(message); } catch (ContactDataInputDateBeforeObservationEndDateException e) { @@ -449,7 +449,7 @@ public class ContactsService extends WaoServiceSupport { String message = l(l, "wao.import.contact.failure.dataInputDateAfterToday", lineNumber); throw new ImportErrorException(message); } catch (MissingContactCommentException e) { - String state = WaoUtils.l(l, e.getContact().getContactState()); + String state = WaoUtils.l(l, e.getContact().getContactState().toI18Able(obsProgram)); String message = l(l, "wao.import.contact.failure.missingComment", state, lineNumber); throw new ImportErrorException(message); } catch (MismatchContactMainObserverCompanyException e) { @@ -497,7 +497,7 @@ public class ContactsService extends WaoServiceSupport { String message = l(l, "wao.import.contact.failure.observationEndDateAfterToday", lineNumber); throw new ImportErrorException(message); } catch (MissingContactObservationBeginDateException e) { - String state = WaoUtils.l(l, e.getContact().getContactState()); + String state = WaoUtils.l(l, e.getContact().getContactState().toI18Able(obsProgram)); String message = l(l, "wao.import.contact.failure.missingObservationBeginDate", lineNumber, state); throw new ImportErrorException(message); } catch (MissingContactMammalsInfoException e) { diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/FilterOption.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/FilterOption.java index 669781a..1673063 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/FilterOption.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/FilterOption.java @@ -41,24 +41,30 @@ public class FilterOption implements Comparable<FilterOption>, Serializable { * Both label and value is the given str. */ public static FilterOption forString(String str) { - FilterOption filterOption = new FilterOption(str, str); - return filterOption; + return forValueAndLabel(str, str); } /** - * Both label and value is the given str. + * For the value, we will use the {@link Enum#name()} and for the label we will + * use {@link fr.ifremer.wao.entity.I18nAble#getI18nKey()}. */ public static <T extends Enum & I18nAble> FilterOption forEnum(Locale locale, T enumValue) { - FilterOption filterOption = new FilterOption(enumValue.name(), l(locale, enumValue.getI18nKey())); - return filterOption; + return forEnumAndI18nKey(locale, enumValue, enumValue.getI18nKey()); + } + + public static FilterOption forEnumAndI18nKey(Locale locale, Enum enumValue, String i18nKey) { + return forEnumAndLabel(enumValue, l(locale, i18nKey)); + } + + public static FilterOption forEnumAndLabel(Enum enumValue, String label) { + return forValueAndLabel(enumValue.name(), label); } public static FilterOption forValueAndLabel(String value, String label) { - FilterOption filterOption = new FilterOption(value, label); - return filterOption; + return new FilterOption(value, label); } - public FilterOption(String value, String label) { + protected FilterOption(String value, String label) { this.value = value; this.label = label; } diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java index 5da5afb..5b45cb8 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java @@ -29,7 +29,6 @@ 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; import fr.ifremer.wao.entity.ContactStateMotif; import fr.ifremer.wao.entity.DataReliability; import fr.ifremer.wao.entity.LocationType; @@ -41,6 +40,7 @@ import fr.ifremer.wao.entity.WaoUser; import fr.ifremer.wao.services.service.csv.operations.BoatParserFormatter; import fr.ifremer.wao.services.service.csv.operations.CompanyParserFormatter; import fr.ifremer.wao.services.service.csv.operations.ContactStateMotivesParserFormatter; +import fr.ifremer.wao.services.service.csv.operations.ContactStateParserFormatter; import fr.ifremer.wao.services.service.csv.operations.DayParserFormatter; import fr.ifremer.wao.services.service.csv.operations.DayTimeParserFormatter; import fr.ifremer.wao.services.service.csv.operations.I18nAbleParserFormatter; @@ -171,7 +171,8 @@ public class ContactImportExportModel implements ImportExportModel<Contact> { }, new CompanyParserFormatter(locale, null) ); - modelBuilder.newColumnForImportExport("CONTACT_ETAT", "contactState", new I18nAbleParserFormatter<>(locale, ContactState.getAllowedStates(obsProgram))); + + modelBuilder.newColumnForImportExport("CONTACT_ETAT", "contactState", new ContactStateParserFormatter(locale, obsProgram)); modelBuilder.newColumnForImportExport("CONTACT_DEBUT_OBSERVATION", Contact.PROPERTY_OBSERVATION_BEGIN_DATE, new DayTimeParserFormatter(locale)); modelBuilder.newColumnForImportExport("CONTACT_FIN_OBSERVATION", Contact.PROPERTY_OBSERVATION_END_DATE, new DayTimeParserFormatter(locale)); modelBuilder.newColumnForImportExport("CONTACT_SAISIE_DONNEES", Contact.PROPERTY_DATA_INPUT_DATE, new DayParserFormatter(locale)); diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/ContactStateParserFormatter.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/ContactStateParserFormatter.java new file mode 100644 index 0000000..cb68235 --- /dev/null +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/ContactStateParserFormatter.java @@ -0,0 +1,62 @@ +package fr.ifremer.wao.services.service.csv.operations; + +import fr.ifremer.wao.entity.ContactState; +import fr.ifremer.wao.entity.ObsProgram; +import org.apache.commons.lang3.StringUtils; +import org.nuiton.csv.ValueParserFormatter; + +import java.text.ParseException; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +import static org.nuiton.i18n.I18n.l; + +/** + * Un {@link org.nuiton.csv.ValueParserFormatter} qui tient compte du fait que le + * libellé de l'état varie selon le programme. + * + * @since 4.2 + */ +public class ContactStateParserFormatter implements ValueParserFormatter<ContactState> { + + protected Locale locale; + + protected ObsProgram obsProgram; + + protected Map<String, ContactState> allowedContactStates; + + public ContactStateParserFormatter(Locale locale, ObsProgram obsProgram) { + this.locale = locale; + this.obsProgram = obsProgram; + } + + @Override + public String format(ContactState contactState) { + String format = ""; + if (contactState != null) { + format = l(locale, contactState.getI18nKey(obsProgram)); + } + return format; + } + + @Override + public ContactState parse(String s) throws ParseException { + if (StringUtils.isBlank(s)) { + throw new IllegalArgumentException(l(locale, "wao.import.contact.failure.missingContactState")); + } + if (allowedContactStates == null) { + allowedContactStates = new HashMap<>(); + for (ContactState contactState : ContactState.getAllowedStates(obsProgram)) { + String key = l(locale, contactState.getI18nKey(obsProgram)); + allowedContactStates.put(key, contactState); + } + } + ContactState contactState = allowedContactStates.get(s); + if (contactState == null) { + throw new IllegalArgumentException(l(locale, "wao.import.failure.wrongValue", s, allowedContactStates.keySet().toString())); + } + return contactState; + } + +} diff --git a/wao-services/src/main/resources/i18n/wao-services_en_GB.properties b/wao-services/src/main/resources/i18n/wao-services_en_GB.properties index 01994eb..1daefb6 100644 --- a/wao-services/src/main/resources/i18n/wao-services_en_GB.properties +++ b/wao-services/src/main/resources/i18n/wao-services_en_GB.properties @@ -45,6 +45,7 @@ wao.import.contact.failure.mismatchCompanyForObserver=L'observateur %s n'est pas 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.missingContactMammalsInfo=You must provide information about capture +wao.import.contact.failure.missingContactState=You must provide the contact state 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 diff --git a/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties b/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties index 317d740..1c2cfe2 100644 --- a/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties +++ b/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties @@ -43,6 +43,7 @@ wao.import.contact.failure.mismatchCompanyForObserver=Ligne %s \: L'observateur wao.import.contact.failure.missingComment=Ligne %s \: Il faut préciser un commentaire pour l'état '%s' wao.import.contact.failure.missingCommentAdmin=Ligne %s \: Il faut préciser dans le commentaire administrateur pourquoi la donnée est '%s' wao.import.contact.failure.missingContactMammalsInfo=Ligne %s \: Il faut préciser le détail des espèces capturées +wao.import.contact.failure.missingContactState=Ligne %s \: Il faut préciser l'état du contact wao.import.contact.failure.missingContactStateMotif=Ligne %s \: Il faut préciser un motif de refus wao.import.contact.failure.missingDataInputDate=Ligne %s \: 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=Ligne %s \: Il faut préciser la qualité de la donnée avant de valider diff --git a/wao-web/src/main/java/fr/ifremer/wao/web/action/EditContactAction.java b/wao-web/src/main/java/fr/ifremer/wao/web/action/EditContactAction.java index f2df285..ddc28fd 100644 --- a/wao-web/src/main/java/fr/ifremer/wao/web/action/EditContactAction.java +++ b/wao-web/src/main/java/fr/ifremer/wao/web/action/EditContactAction.java @@ -29,6 +29,7 @@ import fr.ifremer.wao.WaoUtils; import fr.ifremer.wao.entity.ContactState; import fr.ifremer.wao.entity.ContactStateMotif; import fr.ifremer.wao.entity.DataReliability; +import fr.ifremer.wao.entity.ObsProgram; import fr.ifremer.wao.entity.ObservedDataControl; import fr.ifremer.wao.entity.SamplingStrategy; import fr.ifremer.wao.entity.TerrestrialLocation; @@ -207,9 +208,11 @@ public class EditContactAction extends WaoJspActionSupport implements Preparable for (WaoUser waoUser : sortedWaoUsers) { observers.put(waoUser.getTopiaId(), waoUser.getFullName()); } + + ObsProgram obsProgram = updateContactCommand.getContact().getObsProgram(); contactStates = new EnumMap<>(ContactState.class); - for (ContactState contactState : ContactState.getAllowedStates(getAuthenticatedWaoUser().getObsProgram())) { - contactStates.put(contactState, WaoUtils.l(getLocale(), contactState)); + for (ContactState contactState : ContactState.getAllowedStates(getObsProgram())) { + contactStates.put(contactState, WaoUtils.l(getLocale(), contactState.toI18Able(obsProgram))); } contactStateMotives = new TreeMap<>(); @@ -248,6 +251,8 @@ public class EditContactAction extends WaoJspActionSupport implements Preparable AuthenticatedWaoUser authenticatedWaoUser = session.getAuthenticatedWaoUser(); + ObsProgram obsProgram = updateContactCommand.getContact().getObsProgram(); + try { service.validate(authenticatedWaoUser, updateContactCommand); } catch (ContactNotUpdatableException e) { @@ -257,7 +262,7 @@ public class EditContactAction extends WaoJspActionSupport implements Preparable addFieldError("updateContactCommand.contact.contactStateMotif", t("wao.ui.form.Contact.error.unwantedContactStateMotif")); } catch (MissingContactObservationEndDateException e) { - String state = WaoUtils.l(getLocale(), e.getContact().getContactState()); + String state = WaoUtils.l(getLocale(), e.getContact().getContactState().toI18Able(obsProgram)); addFieldError("updateContactCommand.contact.observationEndDate", t("wao.ui.form.Contact.error.missingObservationEndDate", state)); } catch (ContactDataInputDateBeforeObservationEndDateException e) { @@ -273,7 +278,7 @@ public class EditContactAction extends WaoJspActionSupport implements Preparable addFieldError("updateContactCommand.contact.dataInputDate", t("wao.ui.form.Contact.error.dataInputDateAfterToday")); } catch (MissingContactCommentException e) { - String state = WaoUtils.l(getLocale(), e.getContact().getContactState()); + String state = WaoUtils.l(getLocale(), e.getContact().getContactState().toI18Able(obsProgram)); addFieldError("updateContactCommand.contact.comment", t("wao.ui.form.Contact.error.missingComment", state)); } catch (MismatchContactMainObserverCompanyException e) { @@ -321,7 +326,7 @@ public class EditContactAction extends WaoJspActionSupport implements Preparable addFieldError("updateContactCommand.contact.observationEndDate", t("wao.ui.form.Contact.error.observationEndDateAfterToday")); } catch (MissingContactObservationBeginDateException e) { - String state = WaoUtils.l(getLocale(), e.getContact().getContactState()); + String state = WaoUtils.l(getLocale(), e.getContact().getContactState().toI18Able(obsProgram)); addFieldError("updateContactCommand.contact.observationBeginDate", t("wao.ui.form.Contact.error.missingObservationBeginDate", state)); } catch (MissingContactMammalsInfoException e) { diff --git a/wao-web/src/main/java/fr/ifremer/wao/web/action/ValidateContactJsonAction.java b/wao-web/src/main/java/fr/ifremer/wao/web/action/ValidateContactJsonAction.java index b341e94..b41f82f 100644 --- a/wao-web/src/main/java/fr/ifremer/wao/web/action/ValidateContactJsonAction.java +++ b/wao-web/src/main/java/fr/ifremer/wao/web/action/ValidateContactJsonAction.java @@ -26,6 +26,7 @@ import com.opensymphony.xwork2.Preparable; import fr.ifremer.wao.WaoTechnicalException; import fr.ifremer.wao.WaoUtils; import fr.ifremer.wao.entity.Contact; +import fr.ifremer.wao.entity.ObsProgram; import fr.ifremer.wao.services.AuthenticatedWaoUser; import fr.ifremer.wao.services.service.ContactDataInputDateAfterTodayException; import fr.ifremer.wao.services.service.ContactDataInputDateBeforeObservationEndDateException; @@ -164,6 +165,8 @@ public class ValidateContactJsonAction extends WaoJsonActionSupport implements P } } + ObsProgram obsProgram = updateContactCommand.getContact().getObsProgram(); + try { service.validate(authenticatedWaoUser, updateContactCommand); } catch (ContactNotUpdatableException e) { @@ -173,7 +176,7 @@ public class ValidateContactJsonAction extends WaoJsonActionSupport implements P errorMessage = t("wao.ui.form.Contact.error.unwantedContactStateMotif"); } catch (MissingContactObservationEndDateException e) { - String state = WaoUtils.l(getLocale(), e.getContact().getContactState()); + String state = WaoUtils.l(getLocale(), e.getContact().getContactState().toI18Able(obsProgram)); errorMessage = t("wao.ui.form.Contact.error.missingObservationEndDate", state); } catch (ContactDataInputDateBeforeObservationEndDateException e) { @@ -189,7 +192,7 @@ public class ValidateContactJsonAction extends WaoJsonActionSupport implements P errorMessage = t("wao.ui.form.Contact.error.dataInputDateAfterToday"); } catch (MissingContactCommentException e) { - String state = WaoUtils.l(getLocale(), e.getContact().getContactState()); + String state = WaoUtils.l(getLocale(), e.getContact().getContactState().toI18Able(obsProgram)); errorMessage = t("wao.ui.form.Contact.error.missingComment", state); } catch (MismatchContactMainObserverCompanyException e) { @@ -237,7 +240,7 @@ public class ValidateContactJsonAction extends WaoJsonActionSupport implements P errorMessage = t("wao.ui.form.Contact.error.observationEndDateAfterToday"); } catch (MissingContactObservationBeginDateException e) { - String state = WaoUtils.l(getLocale(), e.getContact().getContactState()); + String state = WaoUtils.l(getLocale(), e.getContact().getContactState().toI18Able(obsProgram)); errorMessage = t("wao.ui.form.Contact.error.missingObservationBeginDate", state); } catch (MissingContactTerrestrialLocationException e) { diff --git a/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp b/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp index fd774af..a644fea 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp @@ -472,7 +472,7 @@ </ul> </td> <td> - <s:text name="%{contactState.i18nKey}"/> + <s:text name="%{contactState.getI18nKey(obsProgram)}"/> <s:if test="contactStateMotif != null"> <s:property value="contactStateMotif.name"/> </s:if> diff --git a/wao-web/src/main/webapp/WEB-INF/content/synthesis.jsp b/wao-web/src/main/webapp/WEB-INF/content/synthesis.jsp index 2e659e2..0f1d4ac 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/synthesis.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/synthesis.jsp @@ -281,7 +281,7 @@ </th> <s:iterator value="synthesis.companySynthesesOrderedByName.iterator.next().contactsStatesStatistics.keySet()" var="contactState"> <th> - <s:text name="%{#contactState.i18nKey}"/> + <s:text name="%{#contactState.getI18nKey(obsProgram)}"/> </th> </s:iterator> <th> diff --git a/wao-web/src/main/webapp/wao.css b/wao-web/src/main/webapp/wao.css index 52b3e19..712c4da 100644 --- a/wao-web/src/main/webapp/wao.css +++ b/wao-web/src/main/webapp/wao.css @@ -892,6 +892,5 @@ main.form .form-wrapper .form-actions button.btn { .syntheses th, .syntheses td { text-align: right; - white-space: nowrap; max-width: 50%; } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.