[wao] branch develop updated (ed8f594 -> c8247a7)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository wao. See http://git.codelutin.com/wao.git from ed8f594 Ajout de la colonne 'PLAN_NOM_PROGRAMME' manquante dans le modèle d'import/export CSV des contacts ObsMer et ObsVente (fixes #5996) new ffe84f4 Dans l'action ContactsFilterValuesJsonAction, on permet de passer filterValuesField pour alléger de beaucoup le JSON qui sera renvoyé à l'utilisateur new 4e7600f Remaniement de l'énumération ContactState car la matrice de booléen est difficille à lire new f377b76 Ajout d'un état annulé (météo) pour ObsMer et impact (refs #5352) new 68b1d71 Correction d'une règle CSS pour un style que ne devrait s'appliquer qu'aux plans d'échantillonnage new 0013a92 Ajout d'une interface utilisateur pour invalider tous les caches sans redémarrer Wao new 06ec27b On remplace un libellé en dur par une traduction new c8247a7 Par migration sql, on supprime de la base des clause DEFAULT obsolètes The 7 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit c8247a751389c904fc91006b3b50a33d0c8747f2 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Oct 23 16:27:38 2014 +0200 Par migration sql, on supprime de la base des clause DEFAULT obsolètes commit 06ec27b8397b96d8c6006d993844878d468f0dbc Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Oct 23 16:22:21 2014 +0200 On remplace un libellé en dur par une traduction commit 0013a92295d659fb9eb5b055b3e31f6dab8835c7 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Oct 23 16:19:33 2014 +0200 Ajout d'une interface utilisateur pour invalider tous les caches sans redémarrer Wao commit 68b1d711ffc554db7e0bbe04457b4336b5fa10db Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Oct 23 15:48:53 2014 +0200 Correction d'une règle CSS pour un style que ne devrait s'appliquer qu'aux plans d'échantillonnage 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) commit 4e7600f4079624b8b66354a5ecb23fbd52f992f6 Author: Brendan Le Ny <bleny@codelutin.com> Date: Wed Oct 22 17:04:14 2014 +0200 Remaniement de l'énumération ContactState car la matrice de booléen est difficille à lire commit ffe84f4c096360a214ec54a6f96dccc900b98d5c Author: Brendan Le Ny <bleny@codelutin.com> Date: Wed Oct 22 12:12:42 2014 +0200 Dans l'action ContactsFilterValuesJsonAction, on permet de passer filterValuesField pour alléger de beaucoup le JSON qui sera renvoyé à l'utilisateur Summary of changes: .../java/fr/ifremer/wao/entity/ContactState.java | 108 ++++++++++----------- .../java/fr/ifremer/wao/entity/ContactStates.java | 24 +++++ ...__average_tide_time_to_int,_clean_defaults.sql} | 5 + .../i18n/wao-persistence_en_GB.properties | 2 + .../i18n/wao-persistence_fr_FR.properties | 2 + .../ifremer/wao/services/AuthenticatedWaoUser.java | 4 + .../wao/services/service/AbstractFilterValues.java | 10 +- .../wao/services/service/BoatsFilterValues.java | 5 +- .../wao/services/service/ContactsFilterValues.java | 62 +++++++++++- .../wao/services/service/ContactsService.java | 6 +- .../ifremer/wao/services/service/FilterOption.java | 22 +++-- .../wao/services/service/InitWaoService.java | 17 ++++ .../services/service/SampleRowsFilterValues.java | 16 +-- .../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 + .../web/action/ContactsFilterValuesJsonAction.java | 23 ++++- .../ifremer/wao/web/action/EditContactAction.java | 15 ++- .../wao/web/action/ValidateContactJsonAction.java | 9 +- .../administration/InvalidateAllCachesAction.java | 26 +++++ .../main/resources/i18n/wao-web_en_GB.properties | 4 + .../main/resources/i18n/wao-web_fr_FR.properties | 4 + .../administration/invalidate-all-caches-input.jsp | 29 ++++++ .../administration/referential-management.jsp | 8 +- .../src/main/webapp/WEB-INF/content/contacts.jsp | 2 +- .../src/main/webapp/WEB-INF/content/synthesis.jsp | 2 +- .../src/main/webapp/WEB-INF/decorators/layout.jsp | 8 ++ wao-web/src/main/webapp/wao.css | 15 ++- 29 files changed, 377 insertions(+), 120 deletions(-) create mode 100644 wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactStates.java rename wao-persistence/src/main/resources/db/migration/{V4_2__average_tide_time_to_int.sql => V4_2__average_tide_time_to_int,_clean_defaults.sql} (78%) create mode 100644 wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/ContactStateParserFormatter.java create mode 100644 wao-web/src/main/java/fr/ifremer/wao/web/action/administration/InvalidateAllCachesAction.java create mode 100644 wao-web/src/main/webapp/WEB-INF/content/administration/invalidate-all-caches-input.jsp -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
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 ffe84f4c096360a214ec54a6f96dccc900b98d5c Author: Brendan Le Ny <bleny@codelutin.com> Date: Wed Oct 22 12:12:42 2014 +0200 Dans l'action ContactsFilterValuesJsonAction, on permet de passer filterValuesField pour alléger de beaucoup le JSON qui sera renvoyé à l'utilisateur --- .../wao/services/service/AbstractFilterValues.java | 10 +++- .../wao/services/service/BoatsFilterValues.java | 5 +- .../wao/services/service/ContactsFilterValues.java | 60 ++++++++++++++++++++-- .../services/service/SampleRowsFilterValues.java | 16 +----- .../web/action/ContactsFilterValuesJsonAction.java | 23 +++++++-- 5 files changed, 88 insertions(+), 26 deletions(-) diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/AbstractFilterValues.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/AbstractFilterValues.java index 4c92e3e..1e638d2 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/AbstractFilterValues.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/AbstractFilterValues.java @@ -21,6 +21,8 @@ package fr.ifremer.wao.services.service; * #L% */ +import com.google.common.base.Optional; +import fr.ifremer.wao.entity.ObsProgram; import org.apache.commons.beanutils.BeanUtilsBean; import java.io.Serializable; @@ -31,8 +33,14 @@ public abstract class AbstractFilterValues implements Serializable { protected Locale locale; - public AbstractFilterValues(Locale locale) { + protected ObsProgram obsProgram; + + protected Optional<String> optionalCompanyId; + + public AbstractFilterValues(Locale locale, ObsProgram obsProgram, Optional<String> optionalCompanyId) { this.locale = locale; + this.obsProgram = obsProgram; + this.optionalCompanyId = optionalCompanyId; } public Locale getLocale() { diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValues.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValues.java index dfd8953..7cda05d 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValues.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValues.java @@ -60,7 +60,7 @@ public class BoatsFilterValues extends AbstractFilterValues { protected Set<String> boatIds = new HashSet<>(); public BoatsFilterValues(Locale locale, ObsProgram obsProgram, Optional<String> optionalCompanyId) { - super(locale); + super(locale, obsProgram, optionalCompanyId); this.elligibleForSampleRowsFilterValues = new SampleRowsFilterValues(locale, obsProgram, optionalCompanyId); } @@ -150,8 +150,7 @@ public class BoatsFilterValues extends AbstractFilterValues { } public BoatsFilterValues getCopyWithSingleProperty(String propertyName) { - // FIXME brendan 20/05/14 null is a design fail :-( - BoatsFilterValues copy = new BoatsFilterValues(locale, elligibleForSampleRowsFilterValues.getObsProgram(), null); + BoatsFilterValues copy = new BoatsFilterValues(locale, obsProgram, optionalCompanyId); copyProperty(copy, propertyName); return copy; } 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 7563e72..3f07c9c 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 @@ -81,7 +81,7 @@ public class ContactsFilterValues extends AbstractFilterValues { protected SortedSet<FilterOption> completeSamplings = new TreeSet<>(); public ContactsFilterValues(Locale locale, ObsProgram obsProgram, Optional<String> optionalCompanyId) { - super(locale); + super(locale, obsProgram, optionalCompanyId); this.boatsFilterValues = new BoatsFilterValues(locale, obsProgram, optionalCompanyId); this.sampleRowsFilterValues = new SampleRowsFilterValues(locale, obsProgram, optionalCompanyId); } @@ -157,54 +157,106 @@ public class ContactsFilterValues extends AbstractFilterValues { return boatsFilterValues; } + public void setBoatsFilterValues(BoatsFilterValues boatsFilterValues) { + this.boatsFilterValues = boatsFilterValues; + } + public SampleRowsFilterValues getSampleRowsFilterValues() { return sampleRowsFilterValues; } + public void setSampleRowsFilterValues(SampleRowsFilterValues sampleRowsFilterValues) { + this.sampleRowsFilterValues = sampleRowsFilterValues; + } + public SortedSet<FilterOption> getBoatRegistrationCodes() { return boatRegistrationCodes; } + public void setBoatRegistrationCodes(SortedSet<FilterOption> boatRegistrationCodes) { + this.boatRegistrationCodes = boatRegistrationCodes; + } + public SortedSet<FilterOption> getContactStates() { return contactStates; } + public void setContactStates(SortedSet<FilterOption> contactStates) { + this.contactStates = contactStates; + } + public SortedSet<FilterOption> getDataReliabilities() { return dataReliabilities; } + public void setDataReliabilities(SortedSet<FilterOption> dataReliabilities) { + this.dataReliabilities = dataReliabilities; + } + public SortedSet<FilterOption> getActualSamplingStrategies() { return actualSamplingStrategies; } + public void setActualSamplingStrategies(SortedSet<FilterOption> actualSamplingStrategies) { + this.actualSamplingStrategies = actualSamplingStrategies; + } + public SortedSet<FilterOption> getObservedDataControls() { return observedDataControls; } + public void setObservedDataControls(SortedSet<FilterOption> observedDataControls) { + this.observedDataControls = observedDataControls; + } + public SortedSet<FilterOption> getObservers() { return observers; } + public void setObservers(SortedSet<FilterOption> observers) { + this.observers = observers; + } + public SortedSet<FilterOption> getTerrestrialLocations() { return terrestrialLocations; } + public void setTerrestrialLocations(SortedSet<FilterOption> terrestrialLocations) { + this.terrestrialLocations = terrestrialLocations; + } + public SortedSet<FilterOption> getContactStateMotives() { return contactStateMotives; } + public void setContactStateMotives(SortedSet<FilterOption> contactStateMotives) { + this.contactStateMotives = contactStateMotives; + } + public SortedSet<FilterOption> getCompanyAcceptations() { return companyAcceptations; } + public void setCompanyAcceptations(SortedSet<FilterOption> companyAcceptations) { + this.companyAcceptations = companyAcceptations; + } + public SortedSet<FilterOption> getProgramAcceptations() { return programAcceptations; } + public void setProgramAcceptations(SortedSet<FilterOption> programAcceptations) { + this.programAcceptations = programAcceptations; + } + public SortedSet<FilterOption> getCompleteSamplings() { return completeSamplings; } + public void setCompleteSamplings(SortedSet<FilterOption> completeSamplings) { + this.completeSamplings = completeSamplings; + } + protected void addBooleanFilterOption(SortedSet<FilterOption> options, Boolean booleanValue, String nullI18nKey, @@ -226,7 +278,9 @@ public class ContactsFilterValues extends AbstractFilterValues { } @Override - public <T extends AbstractFilterValues> T getCopyWithSingleProperty(String propertyName) { - throw new UnsupportedOperationException(); + public ContactsFilterValues getCopyWithSingleProperty(String propertyName) { + ContactsFilterValues copy = new ContactsFilterValues(locale, obsProgram, optionalCompanyId); + copyProperty(copy, propertyName); + return copy; } } \ No newline at end of file diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SampleRowsFilterValues.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SampleRowsFilterValues.java index a748b24..56f836c 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/SampleRowsFilterValues.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SampleRowsFilterValues.java @@ -44,10 +44,6 @@ public class SampleRowsFilterValues extends AbstractFilterValues { private static final long serialVersionUID = 1L; - protected ObsProgram obsProgram; - - protected Optional<String> optionalCompanyId; - protected SortedSet<FilterOption> fishingZoneFacadeNames = new TreeSet<>(); protected SortedSet<FilterOption> fishingZoneSectorNames = new TreeSet<>(); @@ -69,17 +65,7 @@ public class SampleRowsFilterValues extends AbstractFilterValues { protected SortedSet<FilterOption> targetSpeciesDcfs = new TreeSet<>(); public SampleRowsFilterValues(Locale locale, ObsProgram obsProgram, Optional<String> optionalCompanyId) { - super(locale); - this.obsProgram = obsProgram; - this.optionalCompanyId = optionalCompanyId; - } - - public ObsProgram getObsProgram() { - return obsProgram; - } - - public Optional<String> getOptionalCompanyId() { - return optionalCompanyId; + super(locale, obsProgram, optionalCompanyId); } public void addSampleRow(SampleRow sampleRow) { diff --git a/wao-web/src/main/java/fr/ifremer/wao/web/action/ContactsFilterValuesJsonAction.java b/wao-web/src/main/java/fr/ifremer/wao/web/action/ContactsFilterValuesJsonAction.java index 1e52bb7..5b84cb9 100644 --- a/wao-web/src/main/java/fr/ifremer/wao/web/action/ContactsFilterValuesJsonAction.java +++ b/wao-web/src/main/java/fr/ifremer/wao/web/action/ContactsFilterValuesJsonAction.java @@ -26,6 +26,7 @@ import fr.ifremer.wao.ContactsFilter; import fr.ifremer.wao.services.service.ContactsFilterValues; import fr.ifremer.wao.services.service.ContactsService; import fr.ifremer.wao.web.WaoJsonActionSupport; +import org.apache.commons.lang3.StringUtils; /** * Created on 4/3/14. @@ -43,10 +44,16 @@ public class ContactsFilterValuesJsonAction extends WaoJsonActionSupport impleme protected ContactsFilterValues filterValues; + protected String filterValuesField; + public void setService(ContactsService service) { this.service = service; } + public void setFilterValuesField(String filterValuesField) { + this.filterValuesField = filterValuesField; + } + public ContactsFilter getFilter() { if (filter == null) { prepare(); @@ -54,10 +61,6 @@ public class ContactsFilterValuesJsonAction extends WaoJsonActionSupport impleme return filter; } - public ContactsFilterValues getFilterValues() { - return filterValues; - } - @Override public void prepare() { @@ -69,8 +72,20 @@ public class ContactsFilterValuesJsonAction extends WaoJsonActionSupport impleme filterValues = service.getContactsFilterValues(session.getAuthenticatedWaoUser(), filter); + if (StringUtils.isNotBlank(filterValuesField)) { + + // le client ne demande qu'un seul champ, on peut éviter de retourner l'objet complet + + filterValues = filterValues.getCopyWithSingleProperty(filterValuesField); + + } + return SUCCESS; } + public ContactsFilterValues getFilterValues() { + return filterValues; + } + } \ No newline at end of file -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
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 4e7600f4079624b8b66354a5ecb23fbd52f992f6 Author: Brendan Le Ny <bleny@codelutin.com> Date: Wed Oct 22 17:04:14 2014 +0200 Remaniement de l'énumération ContactState car la matrice de booléen est difficille à lire --- .../java/fr/ifremer/wao/entity/ContactState.java | 85 ++++++++-------------- 1 file changed, 30 insertions(+), 55 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 69ee1aa..3d1d6ce 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 @@ -24,8 +24,8 @@ package fr.ifremer.wao.entity; -import java.util.ArrayList; -import java.util.List; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSetMultimap; import static org.nuiton.i18n.I18n.n; @@ -47,43 +47,45 @@ import static org.nuiton.i18n.I18n.n; * * @author fdesbois <fdesbois@codelutin.com> */ -public enum ContactState implements I18nAble{ +public enum ContactState implements I18nAble { /** Usually, the first step, observer just contacted someone */ - CONTACT_START(n("ContactState.CONTACT_START"), false, false, false), + CONTACT_START(n("ContactState.CONTACT_START")), /** Observer has now someone to meet */ - OBSERVATION_EXPECTED(n("ContactState.OBSERVATION_EXPECTED"), false, false, true), + OBSERVATION_EXPECTED(n("ContactState.OBSERVATION_EXPECTED")), /** Observation was done, all data have been collected. Everything is fine */ - OBSERVATION_DONE(n("ContactState.OBSERVATION_DONE"), true, false, true), + OBSERVATION_DONE(n("ContactState.OBSERVATION_DONE")), /** Observer failed to collect data, weather or any other circumstances made data collection impossible */ - OBSERVATION_CANCELLED(n("ContactState.OBSERVATION_CANCELLED"), true, true, true), + OBSERVATION_CANCELLED(n("ContactState.OBSERVATION_CANCELLED")), /** After a contact start, people contacted refused the observation. Observer may try later. */ - CONTACT_REFUSED(n("ContactState.CONTACT_REFUSED"), true ,true, false), + CONTACT_REFUSED(n("ContactState.CONTACT_REFUSED")), /** After a contact refused, people contacted still refuse the observation. Observer may not try later. */ - CONTACT_DEFINITELY_REFUSED(n("ContactState.CONTACT_DEFINITELY_REFUSED"), true, true, false); + CONTACT_DEFINITELY_REFUSED(n("ContactState.CONTACT_DEFINITELY_REFUSED")); - private String i18nKey; + protected static final ImmutableSet<ContactState> ALL_CONTACT_STATES = + ImmutableSet.copyOf(values()); - /** if true, the state may not be changed. */ - private boolean finalState; + protected static final ImmutableSet<ContactState> FINAL_CONTACT_STATES = + ImmutableSet.of(OBSERVATION_CANCELLED, CONTACT_REFUSED, CONTACT_DEFINITELY_REFUSED); - /** if true, observation in this state has no collected data */ - private boolean unfinishedState; + protected static final ImmutableSet<ContactState> UNFINISHED_CONTACT_STATES = + ImmutableSet.of(OBSERVATION_DONE, OBSERVATION_CANCELLED, CONTACT_REFUSED, CONTACT_DEFINITELY_REFUSED); - /** true if this value can be used for a contact of program {@link fr.ifremer.wao.entity.ObsProgram#OBSVENTE} */ - protected boolean allowedForObsVente; + protected static final ImmutableSetMultimap<ObsProgram, ContactState> ALLOWED_CONTACT_STATES_PER_OBS_PROGRAM = + ImmutableSetMultimap.<ObsProgram, ContactState>builder() + .putAll(ObsProgram.OBSMER, ALL_CONTACT_STATES) + .putAll(ObsProgram.OBSVENTE, ImmutableSet.of(OBSERVATION_EXPECTED, OBSERVATION_DONE, OBSERVATION_CANCELLED)) + .build(); - ContactState(String i18nKey, boolean finalState, boolean unfinishedState, - boolean allowedForObsVente) { + protected String i18nKey; + + ContactState(String i18nKey) { this.i18nKey = i18nKey; - this.finalState = finalState; - this.unfinishedState = unfinishedState; - this.allowedForObsVente = allowedForObsVente; } @Override @@ -91,49 +93,22 @@ public enum ContactState implements I18nAble{ return i18nKey; } + /** if true, the state may not be changed. */ public boolean isFinalState() { - return this.finalState; + return FINAL_CONTACT_STATES.contains(this); } + /** if true, observation in this state has no collected data */ public boolean isUnfinishedState() { - return this.unfinishedState; - } - - /** - * Get the contactState corresponding to the {@code ordinal} value. - * - * @param ordinal reference for the ContactState - * @return ContactState - */ - public static ContactState valueOf(int ordinal) { - for (ContactState curr : ContactState.values()) { - if (ordinal == curr.ordinal()) { - return curr; - } - } - return null; + return UNFINISHED_CONTACT_STATES.contains(this); } public boolean isAllowed(ObsProgram obsProgram) { - boolean allowed; - if (obsProgram == ObsProgram.OBSMER) { - allowed = true; - } else if (obsProgram == ObsProgram.OBSVENTE) { - allowed = allowedForObsVente; - } else { - throw new IllegalStateException(); - } - return allowed; + return getAllowedStates(obsProgram).contains(this); } - public static List<ContactState> getAllowedStates(ObsProgram obsProgram) { - List<ContactState> allowedStates = new ArrayList<>(); - for (ContactState contactState : values()) { - if (contactState.isAllowed(obsProgram)) { - allowedStates.add(contactState); - } - } - return allowedStates; + public static ImmutableSet<ContactState> getAllowedStates(ObsProgram obsProgram) { + return ALLOWED_CONTACT_STATES_PER_OBS_PROGRAM.get(obsProgram); } /** -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
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>.
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 68b1d711ffc554db7e0bbe04457b4336b5fa10db Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Oct 23 15:48:53 2014 +0200 Correction d'une règle CSS pour un style que ne devrait s'appliquer qu'aux plans d'échantillonnage --- wao-web/src/main/webapp/wao.css | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/wao-web/src/main/webapp/wao.css b/wao-web/src/main/webapp/wao.css index 712c4da..35ad0c1 100644 --- a/wao-web/src/main/webapp/wao.css +++ b/wao-web/src/main/webapp/wao.css @@ -347,13 +347,6 @@ h3 { text-align: center; } -.large-table thead tr:first-child th { - color: #b2f0b2; - letter-spacing: 0.5px; - text-transform: uppercase; - background-color: #666; -} - .effort .month { font-size: 21px; letter-spacing: 1px; @@ -563,6 +556,13 @@ button.#sampling-plan-filters-form_0:hover { margin-bottom: 20px; } +table.sampling-plan thead tr:first-child th { + color: #b2f0b2; + letter-spacing: 0.5px; + text-transform: uppercase; + background-color: #666; +} + table.sampling-plan tr.facade-row { color: white; background-color: seagreen; -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
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 0013a92295d659fb9eb5b055b3e31f6dab8835c7 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Oct 23 16:19:33 2014 +0200 Ajout d'une interface utilisateur pour invalider tous les caches sans redémarrer Wao --- .../ifremer/wao/services/AuthenticatedWaoUser.java | 4 +++ .../wao/services/service/InitWaoService.java | 17 +++++++++++++ .../administration/InvalidateAllCachesAction.java | 26 +++++++++++++++++++ .../main/resources/i18n/wao-web_en_GB.properties | 4 +++ .../main/resources/i18n/wao-web_fr_FR.properties | 4 +++ .../administration/invalidate-all-caches-input.jsp | 29 ++++++++++++++++++++++ .../src/main/webapp/WEB-INF/decorators/layout.jsp | 8 ++++++ 7 files changed, 92 insertions(+) diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/AuthenticatedWaoUser.java b/wao-services/src/main/java/fr/ifremer/wao/services/AuthenticatedWaoUser.java index e67f14d..6f162bf 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/AuthenticatedWaoUser.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/AuthenticatedWaoUser.java @@ -145,6 +145,10 @@ public class AuthenticatedWaoUser implements Serializable{ return userProfile.isAdmin() && isCanWrite(); } + public boolean isAuthorizedToInvalidateAllCaches() { + return userProfile.isAdmin() && isCanWrite(); + } + public boolean isAuthorizedToViewCompanies() { return userProfile.isAdmin(); } diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/InitWaoService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/InitWaoService.java index c90205a..8013668 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/InitWaoService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/InitWaoService.java @@ -72,4 +72,21 @@ public class InitWaoService extends WaoServiceSupport { } + public void invalidateAllCaches() { + + if (log.isInfoEnabled()) { + log.info("début de l'invalidation de tous les caches"); + } + + serviceContext.getSamplingPlansCache().invalidateAll(); + serviceContext.getBoatsFilterValuesCache().invalidateAll(); + serviceContext.getContactsFilterValuesCache().invalidateAll(); + serviceContext.getSynthesesCache().invalidateAll(); + + if (log.isInfoEnabled()) { + log.info("fin de l'invalidation de tous les caches"); + } + + } + } diff --git a/wao-web/src/main/java/fr/ifremer/wao/web/action/administration/InvalidateAllCachesAction.java b/wao-web/src/main/java/fr/ifremer/wao/web/action/administration/InvalidateAllCachesAction.java new file mode 100644 index 0000000..9041c19 --- /dev/null +++ b/wao-web/src/main/java/fr/ifremer/wao/web/action/administration/InvalidateAllCachesAction.java @@ -0,0 +1,26 @@ +package fr.ifremer.wao.web.action.administration; + +import fr.ifremer.wao.services.service.InitWaoService; +import fr.ifremer.wao.web.WaoJspActionSupport; +import org.nuiton.i18n.I18n; + +public class InvalidateAllCachesAction extends WaoJspActionSupport { + + protected InitWaoService service; + + public void setService(InitWaoService service) { + this.service = service; + } + + @Override + public String execute() { + + service.invalidateAllCaches(); + + addActionMessage(getText(I18n.n("wao.ui.action.invalidateAllCaches.success"))); + + return INPUT; + + } + +} diff --git a/wao-web/src/main/resources/i18n/wao-web_en_GB.properties b/wao-web/src/main/resources/i18n/wao-web_en_GB.properties index 5ed97b4..4a8da23 100644 --- a/wao-web/src/main/resources/i18n/wao-web_en_GB.properties +++ b/wao-web/src/main/resources/i18n/wao-web_en_GB.properties @@ -62,6 +62,9 @@ wao.ui.action.exportSamplingPlanCsvWithStatistics=Export the plan and the statis wao.ui.action.filter=Apply filters wao.ui.action.goBackToSamplingPlan=Back to sampling plan wao.ui.action.hideFilters=Hide filters +wao.ui.action.invalidateAllCaches=Invalidate all caches +wao.ui.action.invalidateAllCaches.disclaimer=Invalidate all caches will result in very low performance for some minutes +wao.ui.action.invalidateAllCaches.success=Caches were successfully invalidated wao.ui.action.login=Connection wao.ui.action.logout=Logout wao.ui.action.reduceView=Reduce view @@ -483,6 +486,7 @@ wao.ui.page.ContactForm.mammalsInfo.disclaimer=Warning, all the information you wao.ui.page.ContactForm.title=Contact edition wao.ui.page.Contacts.title=Contacts wao.ui.page.Index.title=Home +wao.ui.page.InvalidateAllCaches.title=Caches invalidation wao.ui.page.ReferentialManagement.title=Referentials management wao.ui.page.SamplingPlan.title=Sampling plan wao.ui.page.Synthesis.title=Synthesis diff --git a/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties b/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties index 5de8dc6..92b4202 100644 --- a/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties +++ b/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties @@ -63,6 +63,9 @@ wao.ui.action.exportSamplingPlanCsvWithStatistics=Exporter au format CSV le plan wao.ui.action.filter=Appliquer les filtres wao.ui.action.goBackToSamplingPlan=Retourner au plan d'échantillonnage wao.ui.action.hideFilters=Masquer les filtres +wao.ui.action.invalidateAllCaches=Purger tous les caches +wao.ui.action.invalidateAllCaches.disclaimer=La purge de tous les caches de WAO permet de forcer le recalcul des différentes données affichées à partir des données en base. Cela va entraîner des performances dégradées pendant quelques minutes, le temps que les caches soient de nouveaux remplis. +wao.ui.action.invalidateAllCaches.success=Les caches ont été purgés avec succès wao.ui.action.login=Connexion wao.ui.action.logout=Déconnexion wao.ui.action.reduceView=Réduire la vue @@ -484,6 +487,7 @@ wao.ui.page.ContactForm.mammalsInfo.disclaimer=Noms scientifiques, nombre d'indi wao.ui.page.ContactForm.title=Modification d'un contact wao.ui.page.Contacts.title=Contacts wao.ui.page.Index.title=Accueil +wao.ui.page.InvalidateAllCaches.title=Purge des caches wao.ui.page.ReferentialManagement.title=Gestion des référentiels wao.ui.page.SamplingPlan.title=Plan d'échantillonnage wao.ui.page.Synthesis.title=Synthèse diff --git a/wao-web/src/main/webapp/WEB-INF/content/administration/invalidate-all-caches-input.jsp b/wao-web/src/main/webapp/WEB-INF/content/administration/invalidate-all-caches-input.jsp new file mode 100644 index 0000000..0896101 --- /dev/null +++ b/wao-web/src/main/webapp/WEB-INF/content/administration/invalidate-all-caches-input.jsp @@ -0,0 +1,29 @@ +<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> +<%@taglib uri="/struts-tags" prefix="s" %> + +<html> + <head> + <title> + <s:text name="wao.ui.page.InvalidateAllCaches.title" /> + </title> + <content tag="mainClass">form</content> + </head> + + <body> + + <s:form action="invalidate-all-caches" method="POST"> + + <h1><s:text name="wao.ui.page.InvalidateAllCaches.title" /></h1> + + <div class="alert alert-warn"> + <s:text name="wao.ui.action.invalidateAllCaches.disclaimer" /> + </div> + + <s:submit type="button" cssClass="btn btn-danger"> + <i class="icon-trash"></i> <s:text name="wao.ui.action.invalidateAllCaches" /> + </s:submit> + + </s:form> + + </body> +</html> \ No newline at end of file diff --git a/wao-web/src/main/webapp/WEB-INF/decorators/layout.jsp b/wao-web/src/main/webapp/WEB-INF/decorators/layout.jsp index 3dc5ff1..211341f 100644 --- a/wao-web/src/main/webapp/WEB-INF/decorators/layout.jsp +++ b/wao-web/src/main/webapp/WEB-INF/decorators/layout.jsp @@ -188,6 +188,14 @@ </s:a> </li> </s:if> + <s:if test="authenticatedWaoUser.authorizedToInvalidateAllCaches"> + <li> + <s:url namespace="/administration" action="invalidate-all-caches!input" id="invalidateAllCachesUrl" /> + <s:a href="%{invalidateAllCachesUrl}"> + <i class="fa fa-gear"></i> <s:text name="wao.ui.page.InvalidateAllCaches.title" /> + </s:a> + </li> + </s:if> <s:if test="authenticatedWaoUser.authorizedToViewCompanies"> <li> <s:url namespace="/administration" action="companies" id="companiesUrl" /> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
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 06ec27b8397b96d8c6006d993844878d468f0dbc Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Oct 23 16:22:21 2014 +0200 On remplace un libellé en dur par une traduction --- .../WEB-INF/content/administration/referential-management.jsp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wao-web/src/main/webapp/WEB-INF/content/administration/referential-management.jsp b/wao-web/src/main/webapp/WEB-INF/content/administration/referential-management.jsp index 8e00704..88899f0 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/administration/referential-management.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/administration/referential-management.jsp @@ -45,7 +45,7 @@ <s:file name="csvFile" cssClass="float-left" /> <s:submit type="button"> - <i class="icon-upload"></i> Importer + <i class="icon-upload"></i> <s:text name="wao.ui.action.csvImport" /> </s:submit> </fieldset> @@ -61,7 +61,7 @@ <s:file name="csvFile" cssClass="float-left" /> <s:submit type="button"> - <i class="icon-upload"></i> Importer + <i class="icon-upload"></i> <s:text name="wao.ui.action.csvImport" /> </s:submit> </fieldset> @@ -77,7 +77,7 @@ <s:file name="csvFile" cssClass="float-left"/> <s:submit type="button"> - <i class="icon-upload"></i> Importer + <i class="icon-upload"></i> <s:text name="wao.ui.action.csvImport" /> </s:submit> </fieldset> @@ -94,7 +94,7 @@ <s:file name="csvFile" cssClass="float-left" /> <s:submit type="button"> - <i class="icon-upload"></i> Importer + <i class="icon-upload"></i> <s:text name="wao.ui.action.csvImport" /> </s:submit> </fieldset> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
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 c8247a751389c904fc91006b3b50a33d0c8747f2 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Oct 23 16:27:38 2014 +0200 Par migration sql, on supprime de la base des clause DEFAULT obsolètes --- ...to_int.sql => V4_2__average_tide_time_to_int,_clean_defaults.sql} | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wao-persistence/src/main/resources/db/migration/V4_2__average_tide_time_to_int.sql b/wao-persistence/src/main/resources/db/migration/V4_2__average_tide_time_to_int,_clean_defaults.sql similarity index 78% rename from wao-persistence/src/main/resources/db/migration/V4_2__average_tide_time_to_int.sql rename to wao-persistence/src/main/resources/db/migration/V4_2__average_tide_time_to_int,_clean_defaults.sql index acba741..612ad66 100644 --- a/wao-persistence/src/main/resources/db/migration/V4_2__average_tide_time_to_int.sql +++ b/wao-persistence/src/main/resources/db/migration/V4_2__average_tide_time_to_int,_clean_defaults.sql @@ -22,3 +22,8 @@ -- On change le type de la colonne pour entier en arrondissant à l'entier supérieur ALTER TABLE SampleRow ALTER COLUMN averageTideTime TYPE integer USING ceiling(averageTideTime); + +-- On supprime des default qui n'ont plus de sens suite à la conversion ordinal vers name dans champs de type énumaration + +ALTER TABLE Contact ALTER COLUMN dataReliability DROP DEFAULT; +ALTER TABLE SampleRow ALTER COLUMN averageObservationsCount DROP DEFAULT; -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm