Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
1eb81a8b
by Tony Chemit at 2023-07-24T17:32:39+02:00
-
d501503a
by Tony Chemit at 2023-07-24T17:32:46+02:00
-
f9db81d7
by Tony Chemit at 2023-07-24T17:54:18+02:00
-
d2a67dd3
by Tony Chemit at 2023-07-24T17:54:18+02:00
-
5bd6877e
by Tony Chemit at 2023-07-24T17:54:29+02:00
11 changed files:
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/GearUseFeatureMeasurementCellEditor.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/GearUseFeatureMeasurementCellRenderer.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/GearUseFeaturesMeasurementsTableModelSupport.java
- core/api/dto/src/main/java/fr/ird/observe/dto/ProtectedIdsCommon.java
- core/api/dto/src/main/java/fr/ird/observe/dto/data/GearUseFeaturesMeasurementAware.java
- core/api/dto/src/main/java/fr/ird/observe/dto/referential/common/GearCharacteristicTypeAware.java
- core/persistence/migration/src/main/java/fr/ird/observe/spi/migration/v9/DataSourceMigrationForVersion_9_2.java
- + core/persistence/migration/src/main/resources/db/migration/v9/9.2/10_issue-2763-common.sql
- + core/persistence/migration/src/main/resources/db/migration/v9/9.2/10_issue-2763-tck-common.sql
- core/persistence/test/src/test/resources/fixtures/persistence/table_count/referential.properties
- model/src/main/resources/fixtures/global.properties
Changes:
| ... | ... | @@ -26,13 +26,17 @@ import fr.ird.observe.client.util.table.JXTableUtil; |
| 26 | 26 | import fr.ird.observe.dto.ProtectedIdsCommon;
|
| 27 | 27 | import fr.ird.observe.dto.referential.common.GearCharacteristicReference;
|
| 28 | 28 | import fr.ird.observe.dto.referential.common.GearCharacteristicTypeReference;
|
| 29 | +import io.ultreia.java4all.i18n.I18n;
|
|
| 30 | +import org.jdesktop.swingx.table.DatePickerCellEditor;
|
|
| 29 | 31 | import org.nuiton.jaxx.widgets.number.NumberCellEditor;
|
| 30 | 32 | |
| 31 | 33 | import javax.swing.JTable;
|
| 32 | 34 | import javax.swing.event.CellEditorListener;
|
| 33 | 35 | import javax.swing.table.TableCellEditor;
|
| 34 | 36 | import java.awt.Component;
|
| 37 | +import java.text.SimpleDateFormat;
|
|
| 35 | 38 | import java.util.EventObject;
|
| 39 | +import java.util.Locale;
|
|
| 36 | 40 | import java.util.Map;
|
| 37 | 41 | import java.util.TreeMap;
|
| 38 | 42 | |
| ... | ... | @@ -91,6 +95,8 @@ public class GearUseFeatureMeasurementCellEditor implements TableCellEditor { |
| 91 | 95 | editorsByGearCharacteristicId.put(ProtectedIdsCommon.COMMON_GEAR_CHARACTERISTIC_TYPE_FLOAT_SIGNED, NumberCellEditor.newFloatColumnEditor(true));
|
| 92 | 96 | editorsByGearCharacteristicId.put(ProtectedIdsCommon.COMMON_GEAR_CHARACTERISTIC_TYPE_INTEGER_UNSIGNED, JXTableUtil.newInteger4ColumnEditor(false));
|
| 93 | 97 | editorsByGearCharacteristicId.put(ProtectedIdsCommon.COMMON_GEAR_CHARACTERISTIC_TYPE_FLOAT_UNSIGNED, NumberCellEditor.newFloatColumnEditor(false));
|
| 98 | + boolean french = I18n.getDefaultLocale().equals(Locale.FRANCE);
|
|
| 99 | + editorsByGearCharacteristicId.put(ProtectedIdsCommon.COMMON_GEAR_CHARACTERISTIC_TYPE_DATE, new DatePickerCellEditor(new SimpleDateFormat(french ? "dd/MM/yyyy" : "yyyy-MM-dd")));
|
|
| 94 | 100 | }
|
| 95 | 101 | return editorsByGearCharacteristicId;
|
| 96 | 102 | }
|
| ... | ... | @@ -22,6 +22,7 @@ package fr.ird.observe.client.datasource.editor.api.content.data; |
| 22 | 22 | * #L%
|
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | +import fr.ird.observe.client.util.table.JXTableUtil;
|
|
| 25 | 26 | import fr.ird.observe.dto.ProtectedIdsCommon;
|
| 26 | 27 | import fr.ird.observe.dto.referential.common.GearCharacteristicReference;
|
| 27 | 28 | import fr.ird.observe.dto.referential.common.GearCharacteristicTypeReference;
|
| ... | ... | @@ -47,6 +48,7 @@ public class GearUseFeatureMeasurementCellRenderer implements TableCellRenderer |
| 47 | 48 | this.renderersByCharacteristicTypeId = new TreeMap<>();
|
| 48 | 49 | TableCellRenderer booleanRenderer = table.getDefaultRenderer(Boolean.class);
|
| 49 | 50 | renderersByCharacteristicTypeId.put(ProtectedIdsCommon.COMMON_GEAR_CHARACTERISTIC_TYPE_BOOLEAN, booleanRenderer);
|
| 51 | + renderersByCharacteristicTypeId.put(ProtectedIdsCommon.COMMON_GEAR_CHARACTERISTIC_TYPE_DATE, JXTableUtil.newDateTableCellRenderer());
|
|
| 50 | 52 | }
|
| 51 | 53 | |
| 52 | 54 | @Override
|
| ... | ... | @@ -46,6 +46,7 @@ import org.nuiton.jaxx.validator.swing.SwingValidator; |
| 46 | 46 | import javax.swing.JScrollPane;
|
| 47 | 47 | import java.util.ArrayList;
|
| 48 | 48 | import java.util.List;
|
| 49 | +import java.util.Objects;
|
|
| 49 | 50 | |
| 50 | 51 | /**
|
| 51 | 52 | * Created on 05/08/2021.
|
| ... | ... | @@ -165,7 +166,7 @@ public abstract class GearUseFeaturesMeasurementsTableModelSupport<E extends Bus |
| 165 | 166 | return new ArrayList<>();
|
| 166 | 167 | }
|
| 167 | 168 | GearDto gearDto = gearsById.get(gearId);
|
| 168 | - return GearUseFeaturesMeasurementAware.getDefaultGearUseFeaturesMeasurement(gearDto, this::createNewRow);
|
|
| 169 | + return GearUseFeaturesMeasurementAware.getDefaultGearUseFeaturesMeasurement(Objects.requireNonNull(gearDto), this::createNewRow);
|
|
| 169 | 170 | }
|
| 170 | 171 | }
|
| 171 | 172 |
| ... | ... | @@ -36,6 +36,7 @@ public interface ProtectedIdsCommon { |
| 36 | 36 | String COMMON_GEAR_CHARACTERISTIC_TYPE_FLOAT_SIGNED = "fr.ird.referential.common.GearCharacteristicType#1239832686123#0.4";
|
| 37 | 37 | String COMMON_GEAR_CHARACTERISTIC_TYPE_BOOLEAN = "fr.ird.referential.common.GearCharacteristicType#1239832686123#0.2";
|
| 38 | 38 | String COMMON_GEAR_CHARACTERISTIC_TYPE_TEXT = "fr.ird.referential.common.GearCharacteristicType#1239832686123#0.1";
|
| 39 | + String COMMON_GEAR_CHARACTERISTIC_TYPE_DATE = "fr.ird.referential.common.GearCharacteristicType#1464000000000#0.7";
|
|
| 39 | 40 | String COMMON_OCEAN_ATLANTIC = "fr.ird.referential.common.Ocean#1239832686151#0.17595105505051245";
|
| 40 | 41 | String COMMON_OCEAN_INDIAN = "fr.ird.referential.common.Ocean#1239832686152#0.8325731048817705";
|
| 41 | 42 | } |
| ... | ... | @@ -27,6 +27,7 @@ import fr.ird.observe.dto.referential.common.GearDto; |
| 27 | 27 | import io.ultreia.java4all.lang.Strings;
|
| 28 | 28 | |
| 29 | 29 | import java.util.Comparator;
|
| 30 | +import java.util.Date;
|
|
| 30 | 31 | import java.util.List;
|
| 31 | 32 | import java.util.Objects;
|
| 32 | 33 | import java.util.function.Supplier;
|
| ... | ... | @@ -78,7 +79,11 @@ public interface GearUseFeaturesMeasurementAware extends InlineDataDto { |
| 78 | 79 | if (aValue == null) {
|
| 79 | 80 | value = null;
|
| 80 | 81 | } else {
|
| 81 | - value = String.valueOf(aValue).trim();
|
|
| 82 | + if (measure.getGearCharacteristic().getGearCharacteristicType().isDate()) {
|
|
| 83 | + value = String.valueOf(((Date)aValue).getTime());
|
|
| 84 | + } else {
|
|
| 85 | + value = String.valueOf(aValue).trim();
|
|
| 86 | + }
|
|
| 82 | 87 | if (value.isBlank()) {
|
| 83 | 88 | value = null;
|
| 84 | 89 | }
|
| ... | ... | @@ -28,8 +28,10 @@ import fr.ird.observe.dto.reference.DtoReferenceAware; |
| 28 | 28 | import org.apache.logging.log4j.LogManager;
|
| 29 | 29 | import org.apache.logging.log4j.Logger;
|
| 30 | 30 | |
| 31 | +import java.time.Instant;
|
|
| 31 | 32 | import java.util.Arrays;
|
| 32 | 33 | import java.util.Collections;
|
| 34 | +import java.util.Date;
|
|
| 33 | 35 | import java.util.LinkedHashSet;
|
| 34 | 36 | import java.util.Optional;
|
| 35 | 37 | import java.util.Set;
|
| ... | ... | @@ -58,6 +60,10 @@ public interface GearCharacteristicTypeAware extends DtoReferenceAware, DtoAndRe |
| 58 | 60 | return FLOAT_IDS.contains(getTopiaId());
|
| 59 | 61 | }
|
| 60 | 62 | |
| 63 | + default boolean isDate() {
|
|
| 64 | + return ProtectedIdsCommon.COMMON_GEAR_CHARACTERISTIC_TYPE_DATE.equals(getTopiaId());
|
|
| 65 | + }
|
|
| 66 | + |
|
| 61 | 67 | default Object getTypeValue(Object value) {
|
| 62 | 68 | if (value != null && !value.toString().isEmpty()) {
|
| 63 | 69 | if (isBoolean()) {
|
| ... | ... | @@ -66,6 +72,8 @@ public interface GearCharacteristicTypeAware extends DtoReferenceAware, DtoAndRe |
| 66 | 72 | value = Float.valueOf(value.toString()).intValue();
|
| 67 | 73 | } else if (isFloat()) {
|
| 68 | 74 | value = Float.valueOf(value.toString());
|
| 75 | + } else if (isDate()) {
|
|
| 76 | + value = Date.from(Instant.ofEpochMilli(Long.parseLong(value.toString())));
|
|
| 69 | 77 | }
|
| 70 | 78 | }
|
| 71 | 79 | return value;
|
| ... | ... | @@ -70,6 +70,13 @@ public class DataSourceMigrationForVersion_9_2 extends ByMajorMigrationVersionRe |
| 70 | 70 | executor.addScript("08", "issue-2497");
|
| 71 | 71 | // See https://gitlab.com/ultreiaio/ird-observe/-/issues/2725
|
| 72 | 72 | executor.addScript("09", "issue-2725");
|
| 73 | + // See https://gitlab.com/ultreiaio/ird-observe/-/issues/2763
|
|
| 74 | + if (withIds) {
|
|
| 75 | + executor.addScript("10", "issue-2763");
|
|
| 76 | + if (isForTck()) {
|
|
| 77 | + executor.addScript("10", "issue-2763-tck");
|
|
| 78 | + }
|
|
| 79 | + }
|
|
| 73 | 80 | }
|
| 74 | 81 | |
| 75 | 82 | private void issue2714(MigrationVersionResourceExecutor executor) {
|
| 1 | +---
|
|
| 2 | +-- #%L
|
|
| 3 | +-- ObServe Core :: Persistence :: Migration
|
|
| 4 | +-- %%
|
|
| 5 | +-- Copyright (C) 2008 - 2023 IRD, Ultreia.io
|
|
| 6 | +-- %%
|
|
| 7 | +-- This program is free software: you can redistribute it and/or modify
|
|
| 8 | +-- it under the terms of the GNU General Public License as
|
|
| 9 | +-- published by the Free Software Foundation, either version 3 of the
|
|
| 10 | +-- License, or (at your option) any later version.
|
|
| 11 | +--
|
|
| 12 | +-- This program is distributed in the hope that it will be useful,
|
|
| 13 | +-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 14 | +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 15 | +-- GNU General Public License for more details.
|
|
| 16 | +--
|
|
| 17 | +-- You should have received a copy of the GNU General Public
|
|
| 18 | +-- License along with this program. If not, see
|
|
| 19 | +-- <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 20 | +-- #L%
|
|
| 21 | +---
|
|
| 22 | +INSERT INTO common.GearCharacteristicType (topiaId, topiaVersion, topiaCreateDate, lastUpdateDate, code, uri, homeid, needComment, status, label1, label2, label3, label4, label5, label6, label7, label8) VALUES ('fr.ird.referential.common.GearCharacteristicType#${REFERENTIAL_PREFIX}0.7', 0, ${CURRENT_DATE}, ${CURRENT_TIMESTAMP}, 'DATE', null, null, false, 1, 'Date', 'Date', 'Fecha', null, null, null, null, null);
|
|
| 23 | +UPDATE common.LastUpdateDate SET lastUpdateDate = ${CURRENT_TIMESTAMP} WHERE type ='fr.ird.observe.entities.referential.common.GearCharacteristicType'; |
| 1 | +---
|
|
| 2 | +-- #%L
|
|
| 3 | +-- ObServe Core :: Persistence :: Migration
|
|
| 4 | +-- %%
|
|
| 5 | +-- Copyright (C) 2008 - 2023 IRD, Ultreia.io
|
|
| 6 | +-- %%
|
|
| 7 | +-- This program is free software: you can redistribute it and/or modify
|
|
| 8 | +-- it under the terms of the GNU General Public License as
|
|
| 9 | +-- published by the Free Software Foundation, either version 3 of the
|
|
| 10 | +-- License, or (at your option) any later version.
|
|
| 11 | +--
|
|
| 12 | +-- This program is distributed in the hope that it will be useful,
|
|
| 13 | +-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 14 | +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 15 | +-- GNU General Public License for more details.
|
|
| 16 | +--
|
|
| 17 | +-- You should have received a copy of the GNU General Public
|
|
| 18 | +-- License along with this program. If not, see
|
|
| 19 | +-- <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 20 | +-- #L%
|
|
| 21 | +---
|
|
| 22 | +INSERT INTO common.GearCharacteristic (TOPIAID, TOPIAVERSION, TOPIACREATEDATE, LASTUPDATEDATE, CODE, URI, HOMEID, NEEDCOMMENT, STATUS, LABEL1, LABEL2, LABEL3, LABEL4, LABEL5, LABEL6, LABEL7, LABEL8, UNIT, GEARCHARACTERISTICTYPE) VALUES ('fr.ird.referential.common.GearCharacteristic#${REFERENTIAL_PREFIX}0.11', 0, ${CURRENT_DATE}, ${CURRENT_TIMESTAMP}, '1', null, null, false, 1, 'create date', 'Date de création', 'fecha', null, null, null, null, null, null, 'fr.ird.referential.common.GearCharacteristicType#1464000000000#0.7');
|
|
| 23 | +UPDATE common.LastUpdateDate SET lastUpdateDate = ${CURRENT_TIMESTAMP} WHERE type ='fr.ird.observe.entities.referential.common.GearCharacteristic'; |
| ... | ... | @@ -23,8 +23,8 @@ common.country=91 |
| 23 | 23 | common.dataQuality=5
|
| 24 | 24 | common.fpaZone=45
|
| 25 | 25 | common.gear=28
|
| 26 | -common.gearCharacteristic=26
|
|
| 27 | -common.gearCharacteristicType=6
|
|
| 26 | +common.gearCharacteristic=27
|
|
| 27 | +common.gearCharacteristicType=7
|
|
| 28 | 28 | common.harbour=98
|
| 29 | 29 | common.lastUpdateDate=158
|
| 30 | 30 | common.lengthLengthParameter=1
|
| ... | ... | @@ -25,4 +25,4 @@ REFERENCE_DATA_COUNT=68 |
| 25 | 25 | ENTITIES_LIMIT_SIZE=100
|
| 26 | 26 | # fr.ird.observe.services.service.referential.ReferentialService
|
| 27 | 27 | # fr.ird.observe.services.local.service.referential.DifferentialModelTest
|
| 28 | -REFERENTIAL_COUNT=4104 |
|
| 28 | +REFERENTIAL_COUNT=4106 |