Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
1b950311
by Tony Chemit at 2022-10-01T11:40:41+02:00
-
204bf1eb
by Tony Chemit at 2022-10-01T12:33:41+02:00
-
08ef6fae
by Tony Chemit at 2022-10-01T12:45:46+02:00
18 changed files:
- core/api/dto/src/main/java/fr/ird/observe/spi/validation/validators/ps/common/TripCheckRouteObsLogValues.java
- core/api/dto/src/main/java/fr/ird/observe/spi/validation/validators/ps/observation/RouteCheckStartLogValue.java
- core/persistence/java/target/extracted-sources/friend/models/Observe/persistence.model
- model/src/main/models/Observe/dto/01-referential-common.model
- model/src/main/models/Observe/dto/class/decorator.properties
- model/src/main/models/Observe/dto/class/decoratorWithClassifier.properties
- model/src/main/models/Observe/persistence/01-referential-common.model
- toolkit/api/src/main/i18n/getters/java.getter
- toolkit/api/src/main/i18n/translations/toolkit_en_GB.properties
- toolkit/api/src/main/i18n/translations/toolkit_es_ES.properties
- toolkit/api/src/main/i18n/translations/toolkit_fr_FR.properties
- toolkit/api/src/main/java/fr/ird/observe/dto/WithStartEndDate.java
- core/api/dto/src/main/java/fr/ird/observe/dto/referential/common/WindAware.java → toolkit/api/src/main/java/fr/ird/observe/dto/referential/WindAware.java
- toolkit/api/src/main/java/fr/ird/observe/spi/decoration/DataGroupByDecoratorDefinition.java
- toolkit/api/src/main/java/fr/ird/observe/spi/decoration/DataGroupByDecoratorDefinitionForSearch.java
- toolkit/api/src/main/java/fr/ird/observe/spi/decoration/DataGroupByDecoratorRenderer.java
- toolkit/api/src/main/java/fr/ird/observe/spi/decoration/DefaultDecoratorRenderer.java
- toolkit/api/src/main/java/fr/ird/observe/spi/decoration/I18nDecoratorHelper.java
Changes:
| ... | ... | @@ -31,6 +31,7 @@ import fr.ird.observe.spi.validation.validators.collection.CollectionValidationW |
| 31 | 31 | import io.ultreia.java4all.i18n.I18n;
|
| 32 | 32 | |
| 33 | 33 | import java.util.Collection;
|
| 34 | +import java.util.Locale;
|
|
| 34 | 35 | |
| 35 | 36 | /**
|
| 36 | 37 | * Created on 11/03/2022.
|
| ... | ... | @@ -57,7 +58,7 @@ public class TripCheckRouteObsLogValues extends CollectionFieldValidationSupport |
| 57 | 58 | |
| 58 | 59 | @Override
|
| 59 | 60 | protected void addError(CollectionValidationWalkerContext<TripDto, RouteReference> context, Object object) {
|
| 60 | - setDefaultMessage(MESSAGE_KEY + String.format(MESSAGE_PARAMETERS, context.getCurrent().getStartLogValue(), I18nDecoratorHelper.getDateLabel(context.getCurrent().getDate()), context.getPrevious().getEndLogValue()));
|
|
| 61 | + setDefaultMessage(MESSAGE_KEY + String.format(MESSAGE_PARAMETERS, context.getCurrent().getStartLogValue(), I18nDecoratorHelper.getDateLabel(Locale.getDefault(), context.getCurrent().getDate()), context.getPrevious().getEndLogValue()));
|
|
| 61 | 62 | addFieldError(getFieldName(), object);
|
| 62 | 63 | }
|
| 63 | 64 |
| ... | ... | @@ -32,6 +32,7 @@ import fr.ird.observe.spi.validation.validators.collection.CollectionValidationW |
| 32 | 32 | import io.ultreia.java4all.i18n.I18n;
|
| 33 | 33 | |
| 34 | 34 | import java.util.Collection;
|
| 35 | +import java.util.Locale;
|
|
| 35 | 36 | |
| 36 | 37 | /**
|
| 37 | 38 | * Created on 09/03/2022.
|
| ... | ... | @@ -68,7 +69,7 @@ public class RouteCheckStartLogValue extends CollectionFieldValidationSupport<Tr |
| 68 | 69 | |
| 69 | 70 | @Override
|
| 70 | 71 | protected void addError(CollectionValidationWalkerContext<TripDto, RouteReference> context, Object object) {
|
| 71 | - setDefaultMessage(MESSAGE_KEY + String.format(MESSAGE_PARAMETERS, route.getStartLogValue(), context.getCurrent().getEndLogValue(), I18nDecoratorHelper.getDateLabel(context.getCurrent().getDate())));
|
|
| 72 | + setDefaultMessage(MESSAGE_KEY + String.format(MESSAGE_PARAMETERS, route.getStartLogValue(), context.getCurrent().getEndLogValue(), I18nDecoratorHelper.getDateLabel(Locale.getDefault(), context.getCurrent().getDate())));
|
|
| 72 | 73 | addFieldError(getFieldName(), object);
|
| 73 | 74 | }
|
| 74 | 75 |
| ... | ... | @@ -205,7 +205,7 @@ referential.common.VesselType > referential.I18nReferentialEntity |
| 205 | 205 | |
| 206 | 206 | referential.common.WeightMeasureType > referential.I18nReferentialEntity
|
| 207 | 207 | |
| 208 | -referential.common.Wind > referential.I18nReferentialEntity >> fr.ird.observe.dto.referential.common.WindAware
|
|
| 208 | +referential.common.Wind > referential.I18nReferentialEntity >> fr.ird.observe.dto.referential.WindAware
|
|
| 209 | 209 | minSpeed Integer
|
| 210 | 210 | maxSpeed Integer
|
| 211 | 211 | minSwellHeight Float
|
| ... | ... | @@ -4,7 +4,7 @@ interface referential.WithFormula > WithStartEndDate |
| 4 | 4 | |
| 5 | 5 | interface referential.common.GearCharacteristicTypeAware > DtoAndReferenceAware
|
| 6 | 6 | |
| 7 | -interface referential.common.WindAware > DtoAndReferenceAware
|
|
| 7 | +interface referential.WindAware > DtoAndReferenceAware
|
|
| 8 | 8 | |
| 9 | 9 | interface referential.MinMaxWeightAware > DtoAndReferenceAware
|
| 10 | 10 | |
| ... | ... | @@ -167,7 +167,7 @@ referential.common.VesselType > referential.I18nReferential |
| 167 | 167 | |
| 168 | 168 | referential.common.WeightMeasureType > referential.I18nReferential
|
| 169 | 169 | |
| 170 | -referential.common.Wind > referential.I18nReferential >> referential.common.WindAware
|
|
| 170 | +referential.common.Wind > referential.I18nReferential >> referential.WindAware
|
|
| 171 | 171 | minSpeed Integer
|
| 172 | 172 | maxSpeed Integer
|
| 173 | 173 | minSwellHeight Float
|
| ... | ... | @@ -100,14 +100,14 @@ presets.RemoteDataSourceConfiguration=${name} |
| 100 | 100 | presets.ServerDataSourceConfiguration=${name}
|
| 101 | 101 | referential.common.FpaZone=${code}##${this::label}
|
| 102 | 102 | referential.common.Harbour=${this::label}##${code}##${locode}
|
| 103 | -referential.common.LengthLengthParameter=${species/faoCode}##${species::label}##$(observe.Common.ocean) ${ocean::labelOrUnknown}##$(observe.Common.sex) ${sex::label}##${validityRangeLabel}##${inputSizeMeasureType::labelOrUnknown}##${outputSizeMeasureType::labelOrUnknown}
|
|
| 104 | -referential.common.LengthWeightParameter=${species/faoCode}##${species::label}##$(observe.Common.ocean) ${ocean::labelOrUnknown}##$(observe.Common.sex) ${sex::label}##${validityRangeLabel}##${sizeMeasureType::labelOrUnknown}
|
|
| 103 | +referential.common.LengthLengthParameter=${species/faoCode}##${species::label}##$(observe.Common.ocean) ${ocean::labelOrUnknown}##$(observe.Common.sex) ${sex::label}##${this::validityRangeLabel}##${inputSizeMeasureType::labelOrUnknown}##${outputSizeMeasureType::labelOrUnknown}
|
|
| 104 | +referential.common.LengthWeightParameter=${species/faoCode}##${species::label}##$(observe.Common.ocean) ${ocean::labelOrUnknown}##$(observe.Common.sex) ${sex::label}##${this::validityRangeLabel}##${sizeMeasureType::labelOrUnknown}
|
|
| 105 | 105 | referential.common.Person=${lastName}##${firstName}
|
| 106 | 106 | referential.common.ShipOwner=${code}##${label}
|
| 107 | 107 | referential.common.Species=${faoCode}##${scientificLabel}##${this::label}
|
| 108 | 108 | referential.common.Vessel=${this::label}##${code}
|
| 109 | 109 | referential.common.VesselSizeCategory=${code}##${gaugeLabel}##${capacityLabel}
|
| 110 | -referential.common.Wind=${code}##${this::label}##${speedRange}##${swellHeight}
|
|
| 110 | +referential.common.Wind=${code}##${this::label}##${this::speedRange}##${this::swellHeight}
|
|
| 111 | 111 | referential.ll.observation.SensorBrand=${code}##${brandName}
|
| 112 | 112 | referential.ps.common.AcquisitionStatus=${code}##${this::label}##${_fieldEnabler::fieldEnabler}
|
| 113 | 113 | referential.ps.common.ObjectMaterial=${code::noCode}##${this::label}
|
| ... | ... | @@ -28,10 +28,10 @@ data.ps.logbook.ActivityStub=WithRoute|${date::date}##${time::niceTime}##${vesse |
| 28 | 28 | data.ps.observation.Activity=WithRoute|${date::date}##${time::niceTime}##${vesselActivity::label}
|
| 29 | 29 | presets.RemoteDataSourceConfiguration=WithUrl|${name}##${url}
|
| 30 | 30 | presets.ServerDataSourceConfiguration=WithUrl|${name}##${url}
|
| 31 | -referential.common.FpaZone=Long|${code}##${this::label}##${validityRangeLabel}
|
|
| 31 | +referential.common.FpaZone=Long|${code}##${this::label}##${this::validityRangeLabel}
|
|
| 32 | 32 | referential.common.Harbour=Long|${this::label}##${code}##${locode}
|
| 33 | -referential.common.Vessel=Long|${this::label}##${code}##${vesselType::label}##$(observe.referential.common.Vessel.flagCountry) ${flagCountry::label}##$(observe.referential.common.Vessel.fleetCountry) ${fleetCountry::label}##${validityRangeLabel}
|
|
| 33 | +referential.common.Vessel=Long|${this::label}##${code}##${vesselType::label}##$(observe.referential.common.Vessel.flagCountry) ${flagCountry::label}##$(observe.referential.common.Vessel.fleetCountry) ${fleetCountry::label}##${this::validityRangeLabel}
|
|
| 34 | 34 | referential.ll.common.Program=Long|[LL] $(observe.Common.program) ${this::label}
|
| 35 | 35 | referential.ps.common.Program=Long|[PS] $(observe.Common.program) ${this::label}
|
| 36 | 36 | referential.ps.common.WeightCategory=Long|${code}##${species::speciesLabel}##${this::label}
|
| 37 | -referential.ps.localmarket.Packaging=Long|${code}##${this::label}##${harbour::label}##${batchComposition::label}##${batchWeightType::label}##${validityRangeLabel} |
|
| 37 | +referential.ps.localmarket.Packaging=Long|${code}##${this::label}##${harbour::label}##${batchComposition::label}##${batchWeightType::label}##${this::validityRangeLabel} |
| ... | ... | @@ -165,7 +165,7 @@ referential.common.VesselType > referential.I18nReferentialEntity |
| 165 | 165 | |
| 166 | 166 | referential.common.WeightMeasureType > referential.I18nReferentialEntity
|
| 167 | 167 | |
| 168 | -referential.common.Wind > referential.I18nReferentialEntity >> fr.ird.observe.dto.referential.common.WindAware
|
|
| 168 | +referential.common.Wind > referential.I18nReferentialEntity >> fr.ird.observe.dto.referential.WindAware
|
|
| 169 | 169 | minSpeed Integer
|
| 170 | 170 | maxSpeed Integer
|
| 171 | 171 | minSwellHeight Float
|
| ... | ... | @@ -12,6 +12,7 @@ observe.Common.action.goto.tip |
| 12 | 12 | observe.Common.action.save.tip
|
| 13 | 13 | observe.Common.dataGroupBy.count
|
| 14 | 14 | observe.Common.dataGroupBy.count.null
|
| 15 | +observe.Common.date.format
|
|
| 15 | 16 | observe.Common.navigation.config.DataGroupBy.mandatory
|
| 16 | 17 | observe.Common.navigation.config.DataGroupBy.optional
|
| 17 | 18 | observe.Common.navigation.config.groupByFlavor
|
| ... | ... | @@ -32,6 +33,8 @@ observe.Common.no.value |
| 32 | 33 | observe.Common.nocode
|
| 33 | 34 | observe.Common.none
|
| 34 | 35 | observe.Common.size
|
| 36 | +observe.Common.time.format
|
|
| 37 | +observe.Common.timestamp.format
|
|
| 35 | 38 | observe.Common.type.data
|
| 36 | 39 | observe.Common.type.referential
|
| 37 | 40 | observe.Common.undefined
|
| ... | ... | @@ -10,6 +10,8 @@ observe.Common.action.goto.tip=Go to «%s» |
| 10 | 10 | observe.Common.action.save.tip=Save modifications on data of type `%s`
|
| 11 | 11 | observe.Common.dataGroupBy.count=Usage count\: %d
|
| 12 | 12 | observe.Common.dataGroupBy.count.null=No usage found
|
| 13 | +observe.Common.date.format=%1$tY-%1$tm-%1$td
|
|
| 14 | +observe.Common.month.format=%1$tY-%1$tm
|
|
| 13 | 15 | observe.Common.navigation.config.DataGroupBy.mandatory=mandatory %s group by
|
| 14 | 16 | observe.Common.navigation.config.DataGroupBy.optional=optional %s group by
|
| 15 | 17 | observe.Common.navigation.config.DataGroupByOption.loadDisabledGroupBy=Show disabled groups
|
| ... | ... | @@ -46,6 +48,8 @@ observe.Common.no.value=No value |
| 46 | 48 | observe.Common.nocode=Nocode
|
| 47 | 49 | observe.Common.none=None
|
| 48 | 50 | observe.Common.size=%d element(s)
|
| 51 | +observe.Common.time.format=%1$tH\:%1$tM
|
|
| 52 | +observe.Common.timestamp.format=%1$tY-%1$tm-%1$td %1$tH\:%1$tM
|
|
| 49 | 53 | observe.Common.type.data=Data
|
| 50 | 54 | observe.Common.type.referential=Referential
|
| 51 | 55 | observe.Common.undefined=Undefined
|
| ... | ... | @@ -10,6 +10,8 @@ observe.Common.action.goto.tip=Go to «%s» \#TODO |
| 10 | 10 | observe.Common.action.save.tip=Guardar las modificaciones on data of type `%s` \#TODO
|
| 11 | 11 | observe.Common.dataGroupBy.count=Usage count\: %d
|
| 12 | 12 | observe.Common.dataGroupBy.count.null=No usage found
|
| 13 | +observe.Common.date.format=%1$tY-%1$tm-%1$td
|
|
| 14 | +observe.Common.month.format=%1$tY-%1$tm
|
|
| 13 | 15 | observe.Common.navigation.config.DataGroupBy.mandatory=mandatory %s group by
|
| 14 | 16 | observe.Common.navigation.config.DataGroupBy.optional=optional %s group by
|
| 15 | 17 | observe.Common.navigation.config.DataGroupByOption.loadDisabledGroupBy=Show disabled group by
|
| ... | ... | @@ -46,6 +48,8 @@ observe.Common.no.value=No value |
| 46 | 48 | observe.Common.nocode=codigo ausente
|
| 47 | 49 | observe.Common.none=Ninguno
|
| 48 | 50 | observe.Common.size=%d element(s) \#TODO
|
| 51 | +observe.Common.time.format=%1$tH\:%1$tM
|
|
| 52 | +observe.Common.timestamp.format=%1$tY-%1$tm-%1$td %1$tH\:%1$tM
|
|
| 49 | 53 | observe.Common.type.data=Datos
|
| 50 | 54 | observe.Common.type.referential=Referential
|
| 51 | 55 | observe.Common.undefined=indeterminado
|
| ... | ... | @@ -10,6 +10,8 @@ observe.Common.action.goto.tip=Accéder à «%s» |
| 10 | 10 | observe.Common.action.save.tip=Sauver les modifications sur la donnée de type «%s»
|
| 11 | 11 | observe.Common.dataGroupBy.count=Nombre d'utilisation\: %d
|
| 12 | 12 | observe.Common.dataGroupBy.count.null=Non utilisé
|
| 13 | +observe.Common.date.format=%1$td/%1$tm/%1$tY
|
|
| 14 | +observe.Common.month.format=%1$tm/%1$tY
|
|
| 13 | 15 | observe.Common.navigation.config.DataGroupBy.mandatory=critère %s obligatoire
|
| 14 | 16 | observe.Common.navigation.config.DataGroupBy.optional=critère %s optionnel
|
| 15 | 17 | observe.Common.navigation.config.DataGroupByOption.loadDisabledGroupBy=Afficher les critères désactivés
|
| ... | ... | @@ -46,6 +48,8 @@ observe.Common.no.value=Valeur non définie |
| 46 | 48 | observe.Common.nocode=code absent
|
| 47 | 49 | observe.Common.none=Aucun
|
| 48 | 50 | observe.Common.size=%d élément(s)
|
| 51 | +observe.Common.time.format=%1$tH\:%1$tM
|
|
| 52 | +observe.Common.timestamp.format=%1$td/%1$tm/%1$tY %1$tH\:%1$tM
|
|
| 49 | 53 | observe.Common.type.data=Donnée
|
| 50 | 54 | observe.Common.type.referential=Référentiel
|
| 51 | 55 | observe.Common.undefined=Non défini
|
| ... | ... | @@ -27,6 +27,7 @@ import fr.ird.observe.spi.decoration.I18nDecoratorHelper; |
| 27 | 27 | |
| 28 | 28 | import java.util.Comparator;
|
| 29 | 29 | import java.util.Date;
|
| 30 | +import java.util.Locale;
|
|
| 30 | 31 | |
| 31 | 32 | /**
|
| 32 | 33 | * Created by tchemit on 10/07/2018.
|
| ... | ... | @@ -45,12 +46,12 @@ public interface WithStartEndDate extends DtoAndReferenceAware { |
| 45 | 46 | |
| 46 | 47 | Date getEndDate();
|
| 47 | 48 | |
| 48 | - default String getValidityRangeLabel() {
|
|
| 49 | - return I18nDecoratorHelper.getValidityRangeLabel(getStartDate(), getEndDate());
|
|
| 49 | + default String getValidityRangeLabel(Locale locale) {
|
|
| 50 | + return I18nDecoratorHelper.getValidityRangeLabel(locale, getStartDate(), getEndDate());
|
|
| 50 | 51 | }
|
| 51 | 52 | |
| 52 | - default String getStartEndDateLabel() {
|
|
| 53 | - return I18nDecoratorHelper.getStartEndDateLabel(getStartDate(), getEndDate());
|
|
| 53 | + default String getStartEndDateLabel(Locale locale) {
|
|
| 54 | + return I18nDecoratorHelper.getStartEndDateLabel(locale, getStartDate(), getEndDate());
|
|
| 54 | 55 | }
|
| 55 | 56 | |
| 56 | 57 | default boolean acceptDate(Date date) {
|
| 1 | -package fr.ird.observe.dto.referential.common;
|
|
| 1 | +package fr.ird.observe.dto.referential;
|
|
| 2 | 2 | |
| 3 | 3 | /*-
|
| 4 | 4 | * #%L
|
| 5 | - * ObServe Core :: API :: Dto
|
|
| 5 | + * ObServe Toolkit :: API
|
|
| 6 | 6 | * %%
|
| 7 | 7 | * Copyright (C) 2008 - 2022 IRD, Ultreia.io
|
| 8 | 8 | * %%
|
| ... | ... | @@ -24,6 +24,8 @@ package fr.ird.observe.dto.referential.common; |
| 24 | 24 | |
| 25 | 25 | import fr.ird.observe.spi.decoration.I18nDecoratorHelper;
|
| 26 | 26 | |
| 27 | +import java.util.Locale;
|
|
| 28 | + |
|
| 27 | 29 | /**
|
| 28 | 30 | * Created on 18/07/2021.
|
| 29 | 31 | *
|
| ... | ... | @@ -40,11 +42,11 @@ public interface WindAware { |
| 40 | 42 | |
| 41 | 43 | Float getMinSwellHeight();
|
| 42 | 44 | |
| 43 | - default String getSpeedRange() {
|
|
| 44 | - return I18nDecoratorHelper.getSpeedRange(getMinSpeed(), getMaxSpeed());
|
|
| 45 | + default String getSpeedRange(Locale locale) {
|
|
| 46 | + return I18nDecoratorHelper.getSpeedRange(locale, getMinSpeed(), getMaxSpeed());
|
|
| 45 | 47 | }
|
| 46 | 48 | |
| 47 | - default String getSwellHeight() {
|
|
| 48 | - return I18nDecoratorHelper.getSwellHeight(getMinSwellHeight(), getMaxSwellHeight());
|
|
| 49 | + default String getSwellHeight(Locale locale) {
|
|
| 50 | + return I18nDecoratorHelper.getSwellHeight(locale, getMinSwellHeight(), getMaxSwellHeight());
|
|
| 49 | 51 | }
|
| 50 | 52 | } |
| ... | ... | @@ -24,7 +24,6 @@ package fr.ird.observe.spi.decoration; |
| 24 | 24 | |
| 25 | 25 | import fr.ird.observe.dto.data.DataGroupBy;
|
| 26 | 26 | import io.ultreia.java4all.decoration.DecoratorDefinition;
|
| 27 | -import io.ultreia.java4all.i18n.I18n;
|
|
| 28 | 27 | |
| 29 | 28 | import java.util.Locale;
|
| 30 | 29 | |
| ... | ... | @@ -58,14 +57,9 @@ public class DataGroupByDecoratorDefinition<O extends DataGroupBy<?>> extends De |
| 58 | 57 | ensureContextIndex(index);
|
| 59 | 58 | switch (index) {
|
| 60 | 59 | case 0:
|
| 61 | - return renderer.onNullValue("definitionLabel", locale, source.getDefinitionLabel(locale));
|
|
| 60 | + return renderer.decorateDefinitionLabel(locale, source);
|
|
| 62 | 61 | case 1:
|
| 63 | - String filterText = source.getFilterText();
|
|
| 64 | - if (source.isNull()) {
|
|
| 65 | - // the service just gave us the i18n key
|
|
| 66 | - filterText = I18n.l(locale, filterText);
|
|
| 67 | - }
|
|
| 68 | - return renderer.onNullValue("filterText", locale, filterText);
|
|
| 62 | + return renderer.decorateFilterText(locale, source);
|
|
| 69 | 63 | default:
|
| 70 | 64 | throw new IllegalStateException("No index with value: " + index);
|
| 71 | 65 | }
|
| ... | ... | @@ -60,12 +60,7 @@ public class DataGroupByDecoratorDefinitionForSearch<O extends DataGroupBy<?>> e |
| 60 | 60 | ensureContextIndex(index);
|
| 61 | 61 | switch (index) {
|
| 62 | 62 | case 0:
|
| 63 | - String filterText = source.getFilterText();
|
|
| 64 | - if (source.isNull()) {
|
|
| 65 | - // the service just gave us the i18n key
|
|
| 66 | - filterText = I18n.l(locale, filterText);
|
|
| 67 | - }
|
|
| 68 | - return renderer.onNullValue("filterText", locale, filterText);
|
|
| 63 | + return renderer.decorateFilterText(locale, source);
|
|
| 69 | 64 | case 1:
|
| 70 | 65 | return decorateCount(locale, source);
|
| 71 | 66 | default:
|
| ... | ... | @@ -23,6 +23,12 @@ package fr.ird.observe.spi.decoration; |
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | 25 | import fr.ird.observe.dto.data.DataGroupBy;
|
| 26 | +import io.ultreia.java4all.i18n.I18n;
|
|
| 27 | + |
|
| 28 | +import java.util.Arrays;
|
|
| 29 | +import java.util.Collections;
|
|
| 30 | +import java.util.List;
|
|
| 31 | +import java.util.Locale;
|
|
| 26 | 32 | |
| 27 | 33 | /**
|
| 28 | 34 | * Created on 23/01/2022.
|
| ... | ... | @@ -36,4 +42,38 @@ public class DataGroupByDecoratorRenderer<O extends DataGroupBy<?>> extends Java |
| 36 | 42 | super(type);
|
| 37 | 43 | }
|
| 38 | 44 | |
| 45 | + public String decorateDefinitionLabel(Locale locale, O source) {
|
|
| 46 | + return onNullValue("definitionLabel", locale, source.getDefinitionLabel(locale));
|
|
| 47 | + }
|
|
| 48 | + |
|
| 49 | + public String decorateFilterText(Locale locale, O source) {
|
|
| 50 | + String filterText = source.getFilterText();
|
|
| 51 | + if (source.isNull()) {
|
|
| 52 | + // the service just gave us the i18n key
|
|
| 53 | + filterText = I18n.l(locale, filterText);
|
|
| 54 | + } else {
|
|
| 55 | + if (source.definition().isTemporal()) {
|
|
| 56 | + // use correct locale to display the temporal value
|
|
| 57 | + filterText = translateDate(locale, source.getFilterValue());
|
|
| 58 | + }
|
|
| 59 | + }
|
|
| 60 | + return onNullValue("filterText", locale, filterText);
|
|
| 61 | + }
|
|
| 62 | + |
|
| 63 | + protected String translateDate(Locale locale, String value) {
|
|
| 64 | + if (Locale.FRANCE.equals(locale)) {
|
|
| 65 | + List<String> split = Arrays.asList(value.split("-"));
|
|
| 66 | + switch (split.size()) {
|
|
| 67 | + case 1:
|
|
| 68 | + return value;
|
|
| 69 | + case 2:
|
|
| 70 | + case 3:
|
|
| 71 | + Collections.reverse(split);
|
|
| 72 | + return String.join("/", split);
|
|
| 73 | + default:
|
|
| 74 | + throw new IllegalStateException("Can't manage here date: " + value);
|
|
| 75 | + }
|
|
| 76 | + }
|
|
| 77 | + return value;
|
|
| 78 | + }
|
|
| 39 | 79 | } |
| ... | ... | @@ -24,6 +24,7 @@ package fr.ird.observe.spi.decoration; |
| 24 | 24 | |
| 25 | 25 | import fr.ird.observe.dto.WithStartEndDate;
|
| 26 | 26 | import fr.ird.observe.dto.referential.I18nReferentialHelper;
|
| 27 | +import fr.ird.observe.dto.referential.WindAware;
|
|
| 27 | 28 | import fr.ird.observe.dto.referential.WithI18n;
|
| 28 | 29 | import io.ultreia.java4all.decoration.DecoratorRenderer;
|
| 29 | 30 | import io.ultreia.java4all.i18n.I18n;
|
| ... | ... | @@ -69,6 +70,18 @@ public class DefaultDecoratorRenderer<O> extends DecoratorRenderer<O> { |
| 69 | 70 | return source == null ? onNullValue(locale, null) : I18nReferentialHelper.getLabel(locale, source);
|
| 70 | 71 | }
|
| 71 | 72 | |
| 73 | + public String validityRangeLabel(Locale locale, WithStartEndDate source) {
|
|
| 74 | + return source == null ? onNullValue(locale, null) : source.getValidityRangeLabel(locale);
|
|
| 75 | + }
|
|
| 76 | + |
|
| 77 | + public String speedRange(Locale locale, WindAware source) {
|
|
| 78 | + return source == null ? onNullValue(locale, null) : source.getSpeedRange(locale);
|
|
| 79 | + }
|
|
| 80 | + |
|
| 81 | + public String swellHeight(Locale locale, WindAware source) {
|
|
| 82 | + return source == null ? onNullValue(locale, null) : source.getSwellHeight(locale);
|
|
| 83 | + }
|
|
| 84 | + |
|
| 72 | 85 | public String labelOrUnknown(Locale locale, WithI18n source) {
|
| 73 | 86 | return source == null ? onUnknownValue(locale, null) : I18nReferentialHelper.getLabel(locale, source);
|
| 74 | 87 | }
|
| ... | ... | @@ -84,7 +97,7 @@ public class DefaultDecoratorRenderer<O> extends DecoratorRenderer<O> { |
| 84 | 97 | }
|
| 85 | 98 | |
| 86 | 99 | public String date(Locale locale, Date time) {
|
| 87 | - return time == null ? onNullValue(locale, null) : I18nDecoratorHelper.getDateLabel(time);
|
|
| 100 | + return time == null ? onNullValue(locale, null) : I18nDecoratorHelper.getDateLabel(locale, time);
|
|
| 88 | 101 | }
|
| 89 | 102 | |
| 90 | 103 | public String niceDate(Locale locale, Date time) {
|
| ... | ... | @@ -102,11 +115,11 @@ public class DefaultDecoratorRenderer<O> extends DecoratorRenderer<O> { |
| 102 | 115 | }
|
| 103 | 116 | |
| 104 | 117 | public String time(Locale locale, Date time) {
|
| 105 | - return time == null ? onNullValue(locale, null) : I18nDecoratorHelper.getTimeLabel(time);
|
|
| 118 | + return time == null ? onNullValue(locale, null) : I18nDecoratorHelper.getTimeLabel(locale, time);
|
|
| 106 | 119 | }
|
| 107 | 120 | |
| 108 | 121 | public String timestamp(Locale locale, Date time) {
|
| 109 | - return time == null ? onNullValue(locale, null) : I18nDecoratorHelper.getTimestampLabel(time);
|
|
| 122 | + return time == null ? onNullValue(locale, null) : I18nDecoratorHelper.getTimestampLabel(locale, time);
|
|
| 110 | 123 | }
|
| 111 | 124 | |
| 112 | 125 | protected boolean isDateOrTimestamp(String propertyName) {
|
| ... | ... | @@ -110,69 +110,70 @@ public abstract class I18nDecoratorHelper extends BeanPropertyI18nKeyProducerPro |
| 110 | 110 | return i18nDecoratorHelper.getDefaultLabelsBuilder().getI18nPropertyKey(type, propertyName);
|
| 111 | 111 | }
|
| 112 | 112 | |
| 113 | - public static String getValidityRangeLabel(Date startDate, Date endDate) {
|
|
| 113 | + public static String getValidityRangeLabel(Locale locale, Date startDate, Date endDate) {
|
|
| 114 | 114 | if (startDate == null && endDate == null) {
|
| 115 | 115 | return t("observe.Common.undefined");
|
| 116 | 116 | }
|
| 117 | 117 | if (startDate != null && endDate != null) {
|
| 118 | 118 | StringBuilder result = new StringBuilder();
|
| 119 | - I18nDecoratorHelper.getDateLabel(result, startDate);
|
|
| 119 | + I18nDecoratorHelper.getDateLabel(locale, result, startDate);
|
|
| 120 | 120 | result.append(" - ");
|
| 121 | - I18nDecoratorHelper.getDateLabel(result, endDate);
|
|
| 121 | + I18nDecoratorHelper.getDateLabel(locale, result, endDate);
|
|
| 122 | 122 | return result.toString();
|
| 123 | 123 | }
|
| 124 | 124 | if (startDate != null) {
|
| 125 | 125 | StringBuilder result = new StringBuilder(" > ");
|
| 126 | - I18nDecoratorHelper.getDateLabel(result, startDate);
|
|
| 126 | + I18nDecoratorHelper.getDateLabel(locale, result, startDate);
|
|
| 127 | 127 | return result.toString();
|
| 128 | 128 | }
|
| 129 | 129 | StringBuilder result = new StringBuilder(" < ");
|
| 130 | - I18nDecoratorHelper.getDateLabel(result, endDate);
|
|
| 130 | + I18nDecoratorHelper.getDateLabel(locale, result, endDate);
|
|
| 131 | 131 | return result.toString();
|
| 132 | 132 | }
|
| 133 | 133 | |
| 134 | - public static String getStartEndDateLabel(Date startDate, Date endDate) {
|
|
| 134 | + public static String getStartEndDateLabel(Locale locale, Date startDate, Date endDate) {
|
|
| 135 | 135 | StringBuilder result = new StringBuilder();
|
| 136 | - I18nDecoratorHelper.getDateLabel(result, startDate, I18n.t("observe.WithStartEndDate.noStartDate"));
|
|
| 136 | + I18nDecoratorHelper.getDateLabel(locale, result, startDate, I18n.t("observe.WithStartEndDate.noStartDate"));
|
|
| 137 | 137 | result.append(" - ");
|
| 138 | - I18nDecoratorHelper.getDateLabel(result, endDate, I18n.t("observe.WithStartEndDate.noEndDate"));
|
|
| 138 | + I18nDecoratorHelper.getDateLabel(locale, result, endDate, I18n.t("observe.WithStartEndDate.noEndDate"));
|
|
| 139 | 139 | return result.toString();
|
| 140 | 140 | }
|
| 141 | 141 | |
| 142 | - public static void getDateLabel(StringBuilder result, Date date, String nullLabel) {
|
|
| 142 | + public static void getDateLabel(Locale locale, StringBuilder result, Date date, String nullLabel) {
|
|
| 143 | 143 | if (date == null) {
|
| 144 | 144 | result.append(nullLabel);
|
| 145 | 145 | } else {
|
| 146 | - getDateLabel(result, date);
|
|
| 146 | + getDateLabel(locale, result, date);
|
|
| 147 | 147 | }
|
| 148 | 148 | }
|
| 149 | 149 | |
| 150 | - public static void getDateLabel(StringBuilder result, Date date) {
|
|
| 151 | - result.append(String.format("%1$td/%1$tm/%1$tY", date));
|
|
| 150 | + public static void getDateLabel(Locale locale, StringBuilder result, Date date) {
|
|
| 151 | + result.append(getDateLabel(locale, date));
|
|
| 152 | 152 | }
|
| 153 | 153 | |
| 154 | - public static String getDateLabel(Date date) {
|
|
| 155 | - return String.format("%1$td/%1$tm/%1$tY", date);
|
|
| 154 | + public static String getDateLabel(Locale locale, Date date) {
|
|
| 155 | + return I18n.l(locale, "observe.Common.date.format", date);
|
|
| 156 | 156 | }
|
| 157 | 157 | |
| 158 | - public static String getTimestampLabel(Date date) {
|
|
| 159 | - return String.format("%1$td/%1$tm/%1$tY %1$tH:%1$tM", date);
|
|
| 158 | + public static String getTimestampLabel(Locale locale, Date date) {
|
|
| 159 | + |
|
| 160 | + return I18n.l(locale, "observe.Common.timestamp.format", date);
|
|
| 160 | 161 | }
|
| 161 | 162 | |
| 162 | - public static String getTimeLabel(Date date) {
|
|
| 163 | - return String.format("%1$tH:%1$tM", date);
|
|
| 163 | + public static String getTimeLabel(Locale locale, Date date) {
|
|
| 164 | + return I18n.l(locale, "observe.Common.time.format", date);
|
|
| 164 | 165 | }
|
| 165 | 166 | |
| 166 | - public static String getSpeedRange(Integer minValue, Integer maxValue) {
|
|
| 167 | + public static String getSpeedRange(Locale locale, Integer minValue, Integer maxValue) {
|
|
| 167 | 168 | String min = minValue == null ? "" : minValue + "";
|
| 168 | 169 | String max = maxValue == null ? "" : maxValue + "";
|
| 169 | - return I18n.t("observe.referential.common.Wind.speedRange") + String.format("[%-4s < %-4s]", min, max);
|
|
| 170 | + return I18n.l(locale, "observe.referential.common.Wind.speedRange") + String.format("[%-4s < %-4s]", min, max);
|
|
| 170 | 171 | }
|
| 171 | 172 | |
| 172 | - public static String getSwellHeight(Float minValue, Float maxValue) {
|
|
| 173 | + public static String getSwellHeight(Locale locale, Float minValue, Float maxValue) {
|
|
| 173 | 174 | String min = minValue == null ? "" : minValue + "";
|
| 174 | 175 | String max = maxValue == null ? "" : maxValue + "";
|
| 175 | - return I18n.t("observe.referential.common.Wind.swellHeight") + String.format("[%-4s < %-4s]", min, max);
|
|
| 176 | + return I18n.l(locale, "observe.referential.common.Wind.swellHeight") + String.format("[%-4s < %-4s]", min, max);
|
|
| 176 | 177 | }
|
| 177 | 178 | |
| 178 | 179 | public static String decorateCoordinate(Float latitude, Float longitude) {
|