Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
a9b945a9
by Tony Chemit at 2023-09-05T13:19:59+02:00
-
383d2cc2
by Tony Chemit at 2023-09-05T13:42:15+02:00
9 changed files:
- client/datasource/actions/src/main/i18n/templates/validationReport_en_GB.ftl
- client/datasource/actions/src/main/i18n/templates/validationReport_es_ES.ftl
- client/datasource/actions/src/main/i18n/templates/validationReport_fr_FR.ftl
- client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/validate/ValidateConfigUI.jaxx
- client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/validate/ValidateModel.java
- client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/validate/actions/Start.java
- client/runner/src/test/java/fr/ird/observe/client/ObserveTextGeneratorTest.java
- toolkit/api-decoration/src/main/java/fr/ird/observe/decoration/ToolkitIdLabelDecoratorRenderer.java
- toolkit/api/src/main/java/fr/ird/observe/dto/I18nDecoratorHelper.java
Changes:
| ... | ... | @@ -60,7 +60,7 @@ |
| 60 | 60 | <meta charset="UTF-8">
|
| 61 | 61 | <meta lang="en">
|
| 62 | 62 | <meta content="text/html">
|
| 63 | - <title>Rapport de validation</title>
|
|
| 63 | + <title>Validation report</title>
|
|
| 64 | 64 | <style>
|
| 65 | 65 | #result {
|
| 66 | 66 | list-style-type: none;
|
| ... | ... | @@ -79,7 +79,6 @@ |
| 79 | 79 | |
| 80 | 80 | .caret::before {
|
| 81 | 81 | content: "\1f5c0";
|
| 82 | - /*content: "\25B6";*/
|
|
| 83 | 82 | color: #027BFF;
|
| 84 | 83 | display: inline-block;
|
| 85 | 84 | margin-right: 6px;
|
| ... | ... | @@ -87,7 +86,6 @@ |
| 87 | 86 | |
| 88 | 87 | .caretSymbol::before {
|
| 89 | 88 | content: "\1f5c0";
|
| 90 | - /*content: "\25B6";*/
|
|
| 91 | 89 | color: #027BFF;
|
| 92 | 90 | display: inline-block;
|
| 93 | 91 | margin-right: 6px;
|
| ... | ... | @@ -106,7 +104,6 @@ |
| 106 | 104 | .caret-down::before {
|
| 107 | 105 | content: "\1f5c1";
|
| 108 | 106 | color: #027BFF;
|
| 109 | - /*transform: rotate(90deg);*/
|
|
| 110 | 107 | }
|
| 111 | 108 | |
| 112 | 109 | #result .nested {
|
| ... | ... | @@ -122,10 +119,8 @@ |
| 122 | 119 | }
|
| 123 | 120 | |
| 124 | 121 | table {
|
| 125 | - /*font-family: arial, sans-serif;*/
|
|
| 126 | 122 | border-collapse: collapse;
|
| 127 | 123 | width: 90%;
|
| 128 | - /*margin-left: 20px;*/
|
|
| 129 | 124 | margin-top: 10px;
|
| 130 | 125 | margin-bottom: 10px;
|
| 131 | 126 | }
|
| ... | ... | @@ -171,26 +166,30 @@ |
| 171 | 166 | </style>
|
| 172 | 167 | </head>
|
| 173 | 168 | <body>
|
| 174 | -<b>TODO</b>
|
|
| 175 | -<h1>Rapport de validation</h1>
|
|
| 169 | +<h1>Validation report</h1>
|
|
| 176 | 170 | |
| 177 | 171 | <h2>Configuration</h2>
|
| 178 | 172 | |
| 179 | 173 | <ul>
|
| 180 | - <li>Rapport de validation généré le ${.data_model.now}</li>
|
|
| 181 | - <li>Niveau(x) de validation :
|
|
| 174 | + <li>Validation report generated at ${.data_model.now}</li>
|
|
| 175 | + <li>Type of data to validate: <#if .data_model.modelMode.name()=="DATA">Business data<#else>Referential</#if></li>
|
|
| 176 | + <li>Validation scope(s):
|
|
| 182 | 177 | <#list .data_model.scopes as scope>
|
| 183 | 178 | <span class="<#if scope.name() == "ERROR">error<#else>warning</#if>">${scope.label}</span>
|
| 184 | 179 | </#list>
|
| 185 | 180 | </li>
|
| 186 | - <li>Context : ${.data_model.contextName}</li>
|
|
| 181 | + <li>Max speed value used in activities speed validation: ${.data_model.validationSpeedMaxValue}</li>
|
|
| 182 | + <li>Force validation of activities speed: ${.data_model.validationSpeedEnable?string("yes", "no")}</li>
|
|
| 183 | + <li>Force validation of species length max: ${.data_model.validationLengthWeightEnable?string("yes", "no")}</li>
|
|
| 184 | + <li>To bypass validation of disabled referential (display them as warnings): ${.data_model.validationUseDisabledReferential?string("yes", "no")}</li>
|
|
| 185 | + <li>Dictionary of required observed systems per species on senne set: ...</li>
|
|
| 187 | 186 | </ul>
|
| 188 | 187 | |
| 189 | -<h2>Résultat</h2>
|
|
| 188 | +<h2>Results</h2>
|
|
| 190 | 189 | <h3>Notes</h3>
|
| 191 | -<div class="information">Pour déplier un nœud, cliquez sur l'icone <span class="caretSymbol"></span> (la combinaison avec la touche <b>Maj</b> effectue l'action sur le sous-arbre constitué de ses fils).</div>
|
|
| 192 | -<div class="information">Pour replier un nœud, cliquez sur l'icone <span class="caret-down"></span> (la combinaison avec la touche <b>Maj</b> effectue l'action sur le sous-arbre constitué de ses fils).</div>
|
|
| 193 | -<div class="information">Un clic sur un identifiant le sélectionne automatiquement.</div>
|
|
| 190 | +<div class="information">To expand a node, click on icon <span class="caretSymbol"></span> (Combination with key <b>Shift</b> will also expand his inner sub-tree).</div>
|
|
| 191 | +<div class="information">To collapse a note, click on icon <span class="caret-down"></span> (Combination with key <b>Shift</b> will also collapse his inner sub-tree).</div>
|
|
| 192 | +<div class="information">A click on a id will select it automatically.</div>
|
|
| 194 | 193 | <br/>
|
| 195 | 194 | <#assign rootNode = .data_model.rootNode />
|
| 196 | 195 | <ul id="result">
|
| ... | ... | @@ -202,7 +201,6 @@ |
| 202 | 201 | |
| 203 | 202 | <script>
|
| 204 | 203 | function expand(node) {
|
| 205 | - // console.info("will expand child " + node.id);
|
|
| 206 | 204 | node.classList.add("caret-down");
|
| 207 | 205 | node.parentElement.querySelector(".nested").classList.add("active");
|
| 208 | 206 | }
|
| ... | ... | @@ -224,11 +222,9 @@ |
| 224 | 222 | for (const caret of document.getElementsByClassName("caret")) {
|
| 225 | 223 | caret.addEventListener("click", function (event) {
|
| 226 | 224 | let expanded = this.classList.contains("caret-down");
|
| 227 | - // console.info("do click on " + this.id+", was expanded? "+expanded);
|
|
| 228 | 225 | toggle(expanded, this);
|
| 229 | 226 | |
| 230 | 227 | if (event.shiftKey) {
|
| 231 | - // console.info("SHIFT on " + this.id+" was expanded? "+expanded);
|
|
| 232 | 228 | for (const child of this.parentElement.querySelector(".nested").getElementsByClassName("caret")) {
|
| 233 | 229 | toggle(expanded, child);
|
| 234 | 230 | }
|
| ... | ... | @@ -60,7 +60,7 @@ |
| 60 | 60 | <meta charset="UTF-8">
|
| 61 | 61 | <meta lang="es">
|
| 62 | 62 | <meta content="text/html">
|
| 63 | - <title>Rapport de validation</title>
|
|
| 63 | + <title>Validation report</title>
|
|
| 64 | 64 | <style>
|
| 65 | 65 | #result {
|
| 66 | 66 | list-style-type: none;
|
| ... | ... | @@ -79,7 +79,6 @@ |
| 79 | 79 | |
| 80 | 80 | .caret::before {
|
| 81 | 81 | content: "\1f5c0";
|
| 82 | - /*content: "\25B6";*/
|
|
| 83 | 82 | color: #027BFF;
|
| 84 | 83 | display: inline-block;
|
| 85 | 84 | margin-right: 6px;
|
| ... | ... | @@ -87,7 +86,6 @@ |
| 87 | 86 | |
| 88 | 87 | .caretSymbol::before {
|
| 89 | 88 | content: "\1f5c0";
|
| 90 | - /*content: "\25B6";*/
|
|
| 91 | 89 | color: #027BFF;
|
| 92 | 90 | display: inline-block;
|
| 93 | 91 | margin-right: 6px;
|
| ... | ... | @@ -106,7 +104,6 @@ |
| 106 | 104 | .caret-down::before {
|
| 107 | 105 | content: "\1f5c1";
|
| 108 | 106 | color: #027BFF;
|
| 109 | - /*transform: rotate(90deg);*/
|
|
| 110 | 107 | }
|
| 111 | 108 | |
| 112 | 109 | #result .nested {
|
| ... | ... | @@ -122,10 +119,8 @@ |
| 122 | 119 | }
|
| 123 | 120 | |
| 124 | 121 | table {
|
| 125 | - /*font-family: arial, sans-serif;*/
|
|
| 126 | 122 | border-collapse: collapse;
|
| 127 | 123 | width: 90%;
|
| 128 | - /*margin-left: 20px;*/
|
|
| 129 | 124 | margin-top: 10px;
|
| 130 | 125 | margin-bottom: 10px;
|
| 131 | 126 | }
|
| ... | ... | @@ -171,25 +166,31 @@ |
| 171 | 166 | </style>
|
| 172 | 167 | </head>
|
| 173 | 168 | <body>
|
| 174 | -<h1>Rapport de validation</h1>
|
|
| 169 | +<b>TODO</b>
|
|
| 170 | +<h1>Validation report</h1>
|
|
| 175 | 171 | |
| 176 | 172 | <h2>Configuration</h2>
|
| 177 | 173 | |
| 178 | 174 | <ul>
|
| 179 | - <li>Rapport de validation généré le ${.data_model.now}</li>
|
|
| 180 | - <li>Niveau(x) de validation :
|
|
| 175 | + <li>Validation report generated at ${.data_model.now}</li>
|
|
| 176 | + <li>Tipo de datos a validar: <#if .data_model.modelMode.name()=="DATA">Datos<#else>Referencial</#if></li>
|
|
| 177 | + <li>Validation scope(s):
|
|
| 181 | 178 | <#list .data_model.scopes as scope>
|
| 182 | 179 | <span class="<#if scope.name() == "ERROR">error<#else>warning</#if>">${scope.label}</span>
|
| 183 | 180 | </#list>
|
| 184 | 181 | </li>
|
| 185 | - <li>Context : ${.data_model.contextName}</li>
|
|
| 182 | + <li>Velocidad máxima autorizada en el control de las velocidades de las actividades: ${.data_model.validationSpeedMaxValue}</li>
|
|
| 183 | + <li>Forzar la validación de las velocidades de las actividades: ${.data_model.validationSpeedEnable?string("yes", "no")}</li>
|
|
| 184 | + <li>Forzar la validación de la talla de especies min/max: ${.data_model.validationLengthWeightEnable?string("yes", "no")}</li>
|
|
| 185 | + <li>Para que la utilización de referenciales obsoletos sea autorizado (se advertirá en los mensajes de validación): ${.data_model.validationUseDisabledReferential?string("yes", "no")}</li>
|
|
| 186 | + <li>Diccionario de sistemas observados requeridos por especies en la modalidad de cerco: ...</li>
|
|
| 186 | 187 | </ul>
|
| 187 | 188 | |
| 188 | -<h2>Résultat</h2>
|
|
| 189 | +<h2>Results</h2>
|
|
| 189 | 190 | <h3>Notes</h3>
|
| 190 | -<div class="information">Pour déplier un nœud, cliquez sur l'icone <span class="caretSymbol"></span> (la combinaison avec la touche <b>Maj</b> effectue l'action sur le sous-arbre constitué de ses fils).</div>
|
|
| 191 | -<div class="information">Pour replier un nœud, cliquez sur l'icone <span class="caret-down"></span> (la combinaison avec la touche <b>Maj</b> effectue l'action sur le sous-arbre constitué de ses fils).</div>
|
|
| 192 | -<div class="information">Un clic sur un identifiant le sélectionne automatiquement.</div>
|
|
| 191 | +<div class="information">To expand a node, click on icon <span class="caretSymbol"></span> (Combination with key <b>Shift</b> will also expand his inner sub-tree).</div>
|
|
| 192 | +<div class="information">To collapse a note, click on icon <span class="caret-down"></span> (Combination with key <b>Shift</b> will also collapse his inner sub-tree).</div>
|
|
| 193 | +<div class="information">A click on a id will select it automatically.</div>
|
|
| 193 | 194 | <br/>
|
| 194 | 195 | <#assign rootNode = .data_model.rootNode />
|
| 195 | 196 | <ul id="result">
|
| ... | ... | @@ -201,7 +202,6 @@ |
| 201 | 202 | |
| 202 | 203 | <script>
|
| 203 | 204 | function expand(node) {
|
| 204 | - // console.info("will expand child " + node.id);
|
|
| 205 | 205 | node.classList.add("caret-down");
|
| 206 | 206 | node.parentElement.querySelector(".nested").classList.add("active");
|
| 207 | 207 | }
|
| ... | ... | @@ -223,11 +223,9 @@ |
| 223 | 223 | for (const caret of document.getElementsByClassName("caret")) {
|
| 224 | 224 | caret.addEventListener("click", function (event) {
|
| 225 | 225 | let expanded = this.classList.contains("caret-down");
|
| 226 | - // console.info("do click on " + this.id+", was expanded? "+expanded);
|
|
| 227 | 226 | toggle(expanded, this);
|
| 228 | 227 | |
| 229 | 228 | if (event.shiftKey) {
|
| 230 | - // console.info("SHIFT on " + this.id+" was expanded? "+expanded);
|
|
| 231 | 229 | for (const child of this.parentElement.querySelector(".nested").getElementsByClassName("caret")) {
|
| 232 | 230 | toggle(expanded, child);
|
| 233 | 231 | }
|
| ... | ... | @@ -79,7 +79,6 @@ |
| 79 | 79 | |
| 80 | 80 | .caret::before {
|
| 81 | 81 | content: "\1f5c0";
|
| 82 | - /*content: "\25B6";*/
|
|
| 83 | 82 | color: #027BFF;
|
| 84 | 83 | display: inline-block;
|
| 85 | 84 | margin-right: 6px;
|
| ... | ... | @@ -87,7 +86,6 @@ |
| 87 | 86 | |
| 88 | 87 | .caretSymbol::before {
|
| 89 | 88 | content: "\1f5c0";
|
| 90 | - /*content: "\25B6";*/
|
|
| 91 | 89 | color: #027BFF;
|
| 92 | 90 | display: inline-block;
|
| 93 | 91 | margin-right: 6px;
|
| ... | ... | @@ -106,7 +104,6 @@ |
| 106 | 104 | .caret-down::before {
|
| 107 | 105 | content: "\1f5c1";
|
| 108 | 106 | color: #027BFF;
|
| 109 | - /*transform: rotate(90deg);*/
|
|
| 110 | 107 | }
|
| 111 | 108 | |
| 112 | 109 | #result .nested {
|
| ... | ... | @@ -122,7 +119,6 @@ |
| 122 | 119 | }
|
| 123 | 120 | |
| 124 | 121 | table {
|
| 125 | - /*font-family: arial, sans-serif;*/
|
|
| 126 | 122 | border-collapse: collapse;
|
| 127 | 123 | width: 90%;
|
| 128 | 124 | margin-left: 20px;
|
| ... | ... | @@ -177,12 +173,17 @@ |
| 177 | 173 | |
| 178 | 174 | <ul>
|
| 179 | 175 | <li>Rapport de validation généré le ${.data_model.now}</li>
|
| 176 | + <li>Type de données à valider : <#if .data_model.modelMode.name()=="DATA">Données métiers<#else>Référentiel</#if></li>
|
|
| 180 | 177 | <li>Niveau(x) de validation :
|
| 181 | 178 | <#list .data_model.scopes as scope>
|
| 182 | 179 | <span class="<#if scope.name() == "ERROR">error<#else>warning</#if>">${scope.label}</span>
|
| 183 | 180 | </#list>
|
| 184 | 181 | </li>
|
| 185 | - <li>Context : ${.data_model.contextName}</li>
|
|
| 182 | + <li>Vitesse maximale autorisée dans le contrôle des vitesses d'activités : ${.data_model.validationSpeedMaxValue}</li>
|
|
| 183 | + <li>Forcer la validation des vitesses d'activités : ${.data_model.validationSpeedEnable?string("Oui", "Non")}</li>
|
|
| 184 | + <li>Forcer la validation des bornes min/max de taille d'espèce : ${.data_model.validationLengthWeightEnable?string("Oui", "Non")}</li>
|
|
| 185 | + <li>Pour autoriser l'utilisation de référentiels obsolètes (les messages de validation passent en avertissement): ${.data_model.validationUseDisabledReferential?string("Oui", "Non")}</li>
|
|
| 186 | + <li>Dictionnaire des systèmes observées requis par espèces dans le modèle Seine: ...</li>
|
|
| 186 | 187 | </ul>
|
| 187 | 188 | |
| 188 | 189 | <h2>Résultat</h2>
|
| ... | ... | @@ -104,7 +104,6 @@ public void destroy() { |
| 104 | 104 | <JSeparator orientation='{JSeparator.HORIZONTAL}'/>
|
| 105 | 105 | </cell>
|
| 106 | 106 | </row>
|
| 107 | - <!-- TODO See https://gitlab.com/ultreiaio/ird-observe/-/issues/2212-->
|
|
| 108 | 107 | <row>
|
| 109 | 108 | <cell anchor="west">
|
| 110 | 109 | <JLabel id='validationSpeedMaxValueLabel' styleClass="skipI18n"/>
|
| ... | ... | @@ -30,6 +30,7 @@ import fr.ird.observe.client.datasource.editor.api.wizard.connexion.DataSourceSe |
| 30 | 30 | import fr.ird.observe.datasource.configuration.ObserveDataSourceInformation;
|
| 31 | 31 | import fr.ird.observe.decoration.DecoratorService;
|
| 32 | 32 | import fr.ird.observe.dto.BusinessDto;
|
| 33 | +import fr.ird.observe.dto.I18nDecoratorHelper;
|
|
| 33 | 34 | import fr.ird.observe.dto.ToolkitIdLabel;
|
| 34 | 35 | import fr.ird.observe.dto.referential.ReferentialDto;
|
| 35 | 36 | import fr.ird.observe.dto.validation.DtoValidationContext;
|
| ... | ... | @@ -42,6 +43,7 @@ import fr.ird.observe.validation.definition.ValidatorDto; |
| 42 | 43 | import io.ultreia.java4all.application.template.spi.GenerateTemplate;
|
| 43 | 44 | import io.ultreia.java4all.bean.spi.GenerateJavaBeanDefinition;
|
| 44 | 45 | import io.ultreia.java4all.decoration.Decorator;
|
| 46 | +import io.ultreia.java4all.i18n.I18n;
|
|
| 45 | 47 | import io.ultreia.java4all.lang.Strings;
|
| 46 | 48 | import org.apache.logging.log4j.LogManager;
|
| 47 | 49 | import org.apache.logging.log4j.Logger;
|
| ... | ... | @@ -76,7 +78,10 @@ public class ValidateModel extends AdminActionModel { |
| 76 | 78 | */
|
| 77 | 79 | private static final String REPORT_PATTERN = "report-%1$tF--%1$tk-%1$tM-%1$tS.html";
|
| 78 | 80 | private static final Logger log = LogManager.getLogger(ValidateModel.class);
|
| 79 | - private static final SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyy HH:mm");
|
|
| 81 | + /**
|
|
| 82 | + * Timestamp formatter.
|
|
| 83 | + */
|
|
| 84 | + private final SimpleDateFormat timestampFormatter;
|
|
| 80 | 85 | /**
|
| 81 | 86 | * les scopes a utiliser
|
| 82 | 87 | */
|
| ... | ... | @@ -133,6 +138,7 @@ public class ValidateModel extends AdminActionModel { |
| 133 | 138 | public ValidateModel() {
|
| 134 | 139 | super(AdminStep.VALIDATE);
|
| 135 | 140 | scopes = EnumSet.noneOf(NuitonValidatorScope.class);
|
| 141 | + timestampFormatter = I18nDecoratorHelper.newTimestampFormat(I18n.getDefaultLocale());
|
|
| 136 | 142 | }
|
| 137 | 143 | |
| 138 | 144 | @Override
|
| ... | ... | @@ -369,7 +375,7 @@ public class ValidateModel extends AdminActionModel { |
| 369 | 375 | }
|
| 370 | 376 | |
| 371 | 377 | public String getNow() {
|
| 372 | - return df.format(new Date());
|
|
| 378 | + return timestampFormatter.format(new Date());
|
|
| 373 | 379 | }
|
| 374 | 380 | |
| 375 | 381 | public boolean withoutMessages() {
|
| ... | ... | @@ -168,8 +168,6 @@ public class Start extends ValidateUIActionSupport { |
| 168 | 168 | |
| 169 | 169 | ValidationResult result;
|
| 170 | 170 | |
| 171 | - //FIXME Ajouter la configuration dans le rapport généré
|
|
| 172 | - //FIXME Ajouter la configuration de la base dans le rapport généré
|
|
| 173 | 171 | ValidationRequestConfiguration configuration = stepModel.toValidationRequestConfiguration();
|
| 174 | 172 | if (dataModel.getConfig().isLoadReferential()) {
|
| 175 | 173 |
| ... | ... | @@ -66,6 +66,7 @@ public class ObserveTextGeneratorTest extends ClientTestSupport implements WithC |
| 66 | 66 | request.setScopes(new LinkedHashSet<>(Arrays.asList(NuitonValidatorScope.ERROR, NuitonValidatorScope.WARNING)));
|
| 67 | 67 | request.setValidationContext(DtoValidationContext.UPDATE_VALIDATION_CONTEXT);
|
| 68 | 68 | configuration.setValidationSpeedEnable(true);
|
| 69 | + configuration.setValidationSpeedMaxValue(30f);
|
|
| 69 | 70 | configuration.setValidationLengthWeightEnable(true);
|
| 70 | 71 | |
| 71 | 72 | ValidationResult result = dataSource.getValidateService().validateData(configuration, request);
|
| ... | ... | @@ -76,6 +77,7 @@ public class ObserveTextGeneratorTest extends ClientTestSupport implements WithC |
| 76 | 77 | model.addScope(NuitonValidatorScope.ERROR);
|
| 77 | 78 | model.addScope(NuitonValidatorScope.WARNING);
|
| 78 | 79 | model.setContextName(request.getValidationContext());
|
| 80 | + model.setValidationSpeedMaxValue(configuration.getValidationSpeedMaxValue());
|
|
| 79 | 81 | model.setModelMode(ValidationModelMode.DATA);
|
| 80 | 82 | model.setValidationResult(result);
|
| 81 | 83 | String content = ValidateModelTemplate.generate(model);
|
| ... | ... | @@ -24,6 +24,7 @@ package fr.ird.observe.decoration; |
| 24 | 24 | |
| 25 | 25 | import com.google.common.collect.ArrayListMultimap;
|
| 26 | 26 | import com.google.common.collect.Multimap;
|
| 27 | +import fr.ird.observe.dto.I18nDecoratorHelper;
|
|
| 27 | 28 | import fr.ird.observe.dto.ToolkitIdLabel;
|
| 28 | 29 | import io.ultreia.java4all.decoration.DecoratorDefinition;
|
| 29 | 30 | import org.apache.logging.log4j.LogManager;
|
| ... | ... | @@ -33,7 +34,6 @@ import java.text.ParseException; |
| 33 | 34 | import java.text.SimpleDateFormat;
|
| 34 | 35 | import java.util.List;
|
| 35 | 36 | import java.util.Locale;
|
| 36 | -import java.util.Objects;
|
|
| 37 | 37 | import java.util.Set;
|
| 38 | 38 | |
| 39 | 39 | /**
|
| ... | ... | @@ -44,10 +44,6 @@ import java.util.Set; |
| 44 | 44 | */
|
| 45 | 45 | public class ToolkitIdLabelDecoratorRenderer extends JavaBeanDecoratorRenderer<ToolkitIdLabel> {
|
| 46 | 46 | private static final Logger log = LogManager.getLogger(ToolkitIdLabelDecoratorRenderer.class);
|
| 47 | - public final SimpleDateFormat frenchDateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
|
| 48 | - public final SimpleDateFormat frenchTimestampFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm");
|
|
| 49 | - public final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
| 50 | - public final SimpleDateFormat timestampFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
| 51 | 47 | |
| 52 | 48 | public ToolkitIdLabelDecoratorRenderer(Set<String> codeProperties) {
|
| 53 | 49 | super(ToolkitIdLabel.class);
|
| ... | ... | @@ -63,12 +59,12 @@ public class ToolkitIdLabelDecoratorRenderer extends JavaBeanDecoratorRenderer<T |
| 63 | 59 | }
|
| 64 | 60 | if (isDate(propertyName)) {
|
| 65 | 61 | // sort on date, can not use toString render to sort (wrong order when using date pattern dd/MM/yyyy)
|
| 66 | - sortByDate(pos, Objects.equals(locale.getLanguage(), "fr") ? frenchDateFormat : dateFormat, dataList);
|
|
| 62 | + sortByDate(pos, I18nDecoratorHelper.newDateFormat(locale), dataList);
|
|
| 67 | 63 | return;
|
| 68 | 64 | }
|
| 69 | 65 | if (isTimestamp(propertyName)) {
|
| 70 | 66 | // sort on timestamp, can not use toString render to sort (wrong order when using date pattern dd/MM/yyyy HH:mm)
|
| 71 | - sortByDate(pos, Objects.equals(locale.getLanguage(), "fr") ? frenchTimestampFormat : timestampFormat, dataList);
|
|
| 67 | + sortByDate(pos, I18nDecoratorHelper.newTimestampFormat(locale), dataList);
|
|
| 72 | 68 | return;
|
| 73 | 69 | }
|
| 74 | 70 | // always sort as using natural order from numbers
|
| ... | ... | @@ -28,9 +28,11 @@ import io.ultreia.java4all.i18n.spi.bean.BeanPropertyI18nKeyProducerProvider; |
| 28 | 28 | import io.ultreia.java4all.lang.Numbers;
|
| 29 | 29 | import io.ultreia.java4all.lang.Strings;
|
| 30 | 30 | |
| 31 | +import java.text.SimpleDateFormat;
|
|
| 31 | 32 | import java.util.Date;
|
| 32 | 33 | import java.util.Iterator;
|
| 33 | 34 | import java.util.Locale;
|
| 35 | +import java.util.Objects;
|
|
| 34 | 36 | import java.util.ServiceLoader;
|
| 35 | 37 | |
| 36 | 38 | import static io.ultreia.java4all.i18n.I18n.getDefaultLocale;
|
| ... | ... | @@ -77,6 +79,12 @@ public abstract class I18nDecoratorHelper extends BeanPropertyI18nKeyProducerPro |
| 77 | 79 | return INSTANCE;
|
| 78 | 80 | }
|
| 79 | 81 | |
| 82 | + public static SimpleDateFormat newDateFormat(Locale locale) {
|
|
| 83 | + return Objects.equals(locale.getLanguage(), "fr") ? new SimpleDateFormat("dd/MM/yyyy") : new SimpleDateFormat("yyyy-MM-dd");
|
|
| 84 | + }
|
|
| 85 | + public static SimpleDateFormat newTimestampFormat(Locale locale) {
|
|
| 86 | + return Objects.equals(locale.getLanguage(), "fr") ? new SimpleDateFormat("dd/MM/yyyy HH:mm") : new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
| 87 | + }
|
|
| 80 | 88 | |
| 81 | 89 | public static String getTypeKey(Class<?> key) {
|
| 82 | 90 | return getPropertyI18nKey(key, "type");
|