Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: 1eb81a8b by Tony Chemit at 2023-07-24T17:32:39+02:00 Ajout via la migration - - - - - d501503a by Tony Chemit at 2023-07-24T17:32:46+02:00 Mise à jour des fixtures - - - - - f9db81d7 by Tony Chemit at 2023-07-24T17:54:18+02:00 Ajout dans l'api de méthodes pour lire et écrire une caractéristique de type date - - - - - d2a67dd3 by Tony Chemit at 2023-07-24T17:54:18+02:00 Adaptation des ui pour rendre et éditer des caractéristiques de type date - - - - - 5bd6877e by Tony Chemit at 2023-07-24T17:54:29+02:00 Merge branch 'feature/issue_2763' into develop Rajouter un type Date (simple et sans time zone) dans GearCharacteristicType - Closes #2763 - - - - - 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: ===================================== client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/GearUseFeatureMeasurementCellEditor.java ===================================== @@ -26,13 +26,17 @@ import fr.ird.observe.client.util.table.JXTableUtil; import fr.ird.observe.dto.ProtectedIdsCommon; import fr.ird.observe.dto.referential.common.GearCharacteristicReference; import fr.ird.observe.dto.referential.common.GearCharacteristicTypeReference; +import io.ultreia.java4all.i18n.I18n; +import org.jdesktop.swingx.table.DatePickerCellEditor; import org.nuiton.jaxx.widgets.number.NumberCellEditor; import javax.swing.JTable; import javax.swing.event.CellEditorListener; import javax.swing.table.TableCellEditor; import java.awt.Component; +import java.text.SimpleDateFormat; import java.util.EventObject; +import java.util.Locale; import java.util.Map; import java.util.TreeMap; @@ -91,6 +95,8 @@ public class GearUseFeatureMeasurementCellEditor implements TableCellEditor { editorsByGearCharacteristicId.put(ProtectedIdsCommon.COMMON_GEAR_CHARACTERISTIC_TYPE_FLOAT_SIGNED, NumberCellEditor.newFloatColumnEditor(true)); editorsByGearCharacteristicId.put(ProtectedIdsCommon.COMMON_GEAR_CHARACTERISTIC_TYPE_INTEGER_UNSIGNED, JXTableUtil.newInteger4ColumnEditor(false)); editorsByGearCharacteristicId.put(ProtectedIdsCommon.COMMON_GEAR_CHARACTERISTIC_TYPE_FLOAT_UNSIGNED, NumberCellEditor.newFloatColumnEditor(false)); + boolean french = I18n.getDefaultLocale().equals(Locale.FRANCE); + editorsByGearCharacteristicId.put(ProtectedIdsCommon.COMMON_GEAR_CHARACTERISTIC_TYPE_DATE, new DatePickerCellEditor(new SimpleDateFormat(french ? "dd/MM/yyyy" : "yyyy-MM-dd"))); } return editorsByGearCharacteristicId; } ===================================== client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/GearUseFeatureMeasurementCellRenderer.java ===================================== @@ -22,6 +22,7 @@ package fr.ird.observe.client.datasource.editor.api.content.data; * #L% */ +import fr.ird.observe.client.util.table.JXTableUtil; import fr.ird.observe.dto.ProtectedIdsCommon; import fr.ird.observe.dto.referential.common.GearCharacteristicReference; import fr.ird.observe.dto.referential.common.GearCharacteristicTypeReference; @@ -47,6 +48,7 @@ public class GearUseFeatureMeasurementCellRenderer implements TableCellRenderer this.renderersByCharacteristicTypeId = new TreeMap<>(); TableCellRenderer booleanRenderer = table.getDefaultRenderer(Boolean.class); renderersByCharacteristicTypeId.put(ProtectedIdsCommon.COMMON_GEAR_CHARACTERISTIC_TYPE_BOOLEAN, booleanRenderer); + renderersByCharacteristicTypeId.put(ProtectedIdsCommon.COMMON_GEAR_CHARACTERISTIC_TYPE_DATE, JXTableUtil.newDateTableCellRenderer()); } @Override ===================================== client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/GearUseFeaturesMeasurementsTableModelSupport.java ===================================== @@ -46,6 +46,7 @@ import org.nuiton.jaxx.validator.swing.SwingValidator; import javax.swing.JScrollPane; import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * Created on 05/08/2021. @@ -165,7 +166,7 @@ public abstract class GearUseFeaturesMeasurementsTableModelSupport<E extends Bus return new ArrayList<>(); } GearDto gearDto = gearsById.get(gearId); - return GearUseFeaturesMeasurementAware.getDefaultGearUseFeaturesMeasurement(gearDto, this::createNewRow); + return GearUseFeaturesMeasurementAware.getDefaultGearUseFeaturesMeasurement(Objects.requireNonNull(gearDto), this::createNewRow); } } ===================================== core/api/dto/src/main/java/fr/ird/observe/dto/ProtectedIdsCommon.java ===================================== @@ -36,6 +36,7 @@ public interface ProtectedIdsCommon { String COMMON_GEAR_CHARACTERISTIC_TYPE_FLOAT_SIGNED = "fr.ird.referential.common.GearCharacteristicType#1239832686123#0.4"; String COMMON_GEAR_CHARACTERISTIC_TYPE_BOOLEAN = "fr.ird.referential.common.GearCharacteristicType#1239832686123#0.2"; String COMMON_GEAR_CHARACTERISTIC_TYPE_TEXT = "fr.ird.referential.common.GearCharacteristicType#1239832686123#0.1"; + String COMMON_GEAR_CHARACTERISTIC_TYPE_DATE = "fr.ird.referential.common.GearCharacteristicType#1464000000000#0.7"; String COMMON_OCEAN_ATLANTIC = "fr.ird.referential.common.Ocean#1239832686151#0.17595105505051245"; String COMMON_OCEAN_INDIAN = "fr.ird.referential.common.Ocean#1239832686152#0.8325731048817705"; } ===================================== core/api/dto/src/main/java/fr/ird/observe/dto/data/GearUseFeaturesMeasurementAware.java ===================================== @@ -27,6 +27,7 @@ import fr.ird.observe.dto.referential.common.GearDto; import io.ultreia.java4all.lang.Strings; import java.util.Comparator; +import java.util.Date; import java.util.List; import java.util.Objects; import java.util.function.Supplier; @@ -78,7 +79,11 @@ public interface GearUseFeaturesMeasurementAware extends InlineDataDto { if (aValue == null) { value = null; } else { - value = String.valueOf(aValue).trim(); + if (measure.getGearCharacteristic().getGearCharacteristicType().isDate()) { + value = String.valueOf(((Date)aValue).getTime()); + } else { + value = String.valueOf(aValue).trim(); + } if (value.isBlank()) { value = null; } ===================================== core/api/dto/src/main/java/fr/ird/observe/dto/referential/common/GearCharacteristicTypeAware.java ===================================== @@ -28,8 +28,10 @@ import fr.ird.observe.dto.reference.DtoReferenceAware; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.time.Instant; import java.util.Arrays; import java.util.Collections; +import java.util.Date; import java.util.LinkedHashSet; import java.util.Optional; import java.util.Set; @@ -58,6 +60,10 @@ public interface GearCharacteristicTypeAware extends DtoReferenceAware, DtoAndRe return FLOAT_IDS.contains(getTopiaId()); } + default boolean isDate() { + return ProtectedIdsCommon.COMMON_GEAR_CHARACTERISTIC_TYPE_DATE.equals(getTopiaId()); + } + default Object getTypeValue(Object value) { if (value != null && !value.toString().isEmpty()) { if (isBoolean()) { @@ -66,6 +72,8 @@ public interface GearCharacteristicTypeAware extends DtoReferenceAware, DtoAndRe value = Float.valueOf(value.toString()).intValue(); } else if (isFloat()) { value = Float.valueOf(value.toString()); + } else if (isDate()) { + value = Date.from(Instant.ofEpochMilli(Long.parseLong(value.toString()))); } } return value; ===================================== core/persistence/migration/src/main/java/fr/ird/observe/spi/migration/v9/DataSourceMigrationForVersion_9_2.java ===================================== @@ -70,6 +70,13 @@ public class DataSourceMigrationForVersion_9_2 extends ByMajorMigrationVersionRe executor.addScript("08", "issue-2497"); // See https://gitlab.com/ultreiaio/ird-observe/-/issues/2725 executor.addScript("09", "issue-2725"); + // See https://gitlab.com/ultreiaio/ird-observe/-/issues/2763 + if (withIds) { + executor.addScript("10", "issue-2763"); + if (isForTck()) { + executor.addScript("10", "issue-2763-tck"); + } + } } private void issue2714(MigrationVersionResourceExecutor executor) { ===================================== core/persistence/migration/src/main/resources/db/migration/v9/9.2/10_issue-2763-common.sql ===================================== @@ -0,0 +1,23 @@ +--- +-- #%L +-- ObServe Core :: Persistence :: Migration +-- %% +-- Copyright (C) 2008 - 2023 IRD, Ultreia.io +-- %% +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as +-- published by the Free Software Foundation, either version 3 of the +-- License, or (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public +-- License along with this program. If not, see +-- <http://www.gnu.org/licenses/gpl-3.0.html>. +-- #L% +--- +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); +UPDATE common.LastUpdateDate SET lastUpdateDate = ${CURRENT_TIMESTAMP} WHERE type ='fr.ird.observe.entities.referential.common.GearCharacteristicType'; ===================================== core/persistence/migration/src/main/resources/db/migration/v9/9.2/10_issue-2763-tck-common.sql ===================================== @@ -0,0 +1,23 @@ +--- +-- #%L +-- ObServe Core :: Persistence :: Migration +-- %% +-- Copyright (C) 2008 - 2023 IRD, Ultreia.io +-- %% +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as +-- published by the Free Software Foundation, either version 3 of the +-- License, or (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public +-- License along with this program. If not, see +-- <http://www.gnu.org/licenses/gpl-3.0.html>. +-- #L% +--- +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'); +UPDATE common.LastUpdateDate SET lastUpdateDate = ${CURRENT_TIMESTAMP} WHERE type ='fr.ird.observe.entities.referential.common.GearCharacteristic'; ===================================== core/persistence/test/src/test/resources/fixtures/persistence/table_count/referential.properties ===================================== @@ -23,8 +23,8 @@ common.country=91 common.dataQuality=5 common.fpaZone=45 common.gear=28 -common.gearCharacteristic=26 -common.gearCharacteristicType=6 +common.gearCharacteristic=27 +common.gearCharacteristicType=7 common.harbour=98 common.lastUpdateDate=158 common.lengthLengthParameter=1 ===================================== model/src/main/resources/fixtures/global.properties ===================================== @@ -25,4 +25,4 @@ REFERENCE_DATA_COUNT=68 ENTITIES_LIMIT_SIZE=100 # fr.ird.observe.services.service.referential.ReferentialService # fr.ird.observe.services.local.service.referential.DifferentialModelTest -REFERENTIAL_COUNT=4104 +REFERENTIAL_COUNT=4106 View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/dfadd9ccba799a5b9ca5d4ff5... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/dfadd9ccba799a5b9ca5d4ff5... You're receiving this email because of your account on gitlab.com.