Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: 5b631f82 by tchemit at 2020-04-06T15:01:48+02:00 Vérifier la présence ou ajouter un champ PS trip.homeid - Closes #1383 - - - - - 12 changed files: - client-core/src/main/java/fr/ird/observe/client/ui/content/data/seine/TripSeineUI.jaxx - client-core/src/main/java/fr/ird/observe/client/ui/content/data/seine/TripSeineUI.jcss - dto/src/main/models/Observe.model - persistence/src/main/java/fr/ird/observe/binder/data/seine/TripSeineEntityDtoBinder.java - + persistence/src/main/java/fr/ird/observe/persistence/migration/DataSourceMigrationForVersion_7_5_1.java - persistence/src/main/models/Observe.model - pom.xml - + test/src/main/resources/db/7.5.1/dataForTestLongline.sql.gz - + test/src/main/resources/db/7.5.1/dataForTestSeine.sql.gz - + test/src/main/resources/db/7.5.1/empty_h2.sql.gz - + test/src/main/resources/db/7.5.1/empty_pg.sql.gz - + test/src/main/resources/db/7.5.1/referentiel.sql.gz Changes: ===================================== client-core/src/main/java/fr/ird/observe/client/ui/content/data/seine/TripSeineUI.jaxx ===================================== @@ -157,6 +157,22 @@ protected boolean canEditOcean(java.util.LinkedHashSet<RouteStubDto> routes) { </cell> </row> + <!-- homeId --> + <row> + + <cell anchor='west'> + <JLabel id='homeIdLabel'/> + </cell> + <cell anchor='east' weightx="1" fill="both"> + <JPanel layout='{new BorderLayout()}'> + <JToolBar id='homeIdToolbar' constraints='BorderLayout.WEST'> + <JButton id='resetHomeId' styleClass='resetButton'/> + </JToolBar> + <JTextField id='homeId' constraints='BorderLayout.CENTER'/> + </JPanel> + </cell> + </row> + <!-- id ers --> <row> ===================================== client-core/src/main/java/fr/ird/observe/client/ui/content/data/seine/TripSeineUI.jcss ===================================== @@ -77,6 +77,16 @@ NumberEditor { selectedItem:{bean.getLandingHarbour()}; } +#resetHomeId { + toolTipText:"observe.common.DataDto.action.reset.homeId.tip"; + _resetPropertyName: {TripSeineDto.PROPERTY_HOME_ID}; +} + +#homeId { + text:{getStringValue(bean.getHomeId())}; + _propertyName: {TripSeineDto.PROPERTY_HOME_ID}; +} + #resetErsId { toolTipText:"observe.common.DataDto.action.reset.ersId.tip"; _resetPropertyName:{TripSeineDto.PROPERTY_ERS_ID}; ===================================== dto/src/main/models/Observe.model ===================================== @@ -817,6 +817,7 @@ formsUrl + {*:1} String reportsUrl + {*:1} String historicalData + {*:1} boolean ersId + {*:1} String +homeId + {*:1} String routeCount + {*:1} int observer {*:0..1} fr.ird.observe.dto.referential.PersonReference | notNull captain {*:0..1} fr.ird.observe.dto.referential.PersonReference | mayNotNull ===================================== persistence/src/main/java/fr/ird/observe/binder/data/seine/TripSeineEntityDtoBinder.java ===================================== @@ -50,6 +50,7 @@ public class TripSeineEntityDtoBinder extends DataEntityDtoBinderSupport<TripSei entity.setFormsUrl(dto.getFormsUrl()); entity.setReportsUrl(dto.getReportsUrl()); entity.setErsId(dto.getErsId()); + entity.setHomeId(dto.getHomeId()); entity.setOcean(toEntity(dto.getOcean())); entity.setVessel(toEntity(dto.getVessel())); @@ -74,6 +75,7 @@ public class TripSeineEntityDtoBinder extends DataEntityDtoBinderSupport<TripSei dto.setFormsUrl(entity.getFormsUrl()); dto.setReportsUrl(entity.getReportsUrl()); dto.setErsId(entity.getErsId()); + dto.setHomeId(entity.getHomeId()); dto.setOcean(toReferentialReference(referentialLocale, entity.getOcean())); dto.setVessel(toReferentialReference(referentialLocale, entity.getVessel())); dto.setProgram(toReferentialReference(referentialLocale, entity.getProgram())); ===================================== persistence/src/main/java/fr/ird/observe/persistence/migration/DataSourceMigrationForVersion_7_5_1.java ===================================== @@ -0,0 +1,78 @@ +package fr.ird.observe.persistence.migration; + +/*- + * #%L + * ObServe :: Persistence + * %% + * Copyright (C) 2008 - 2020 IRD, Code Lutin, 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% + */ + +import com.google.auto.service.AutoService; +import org.apache.commons.lang3.tuple.Pair; +import org.nuiton.topia.persistence.support.TopiaSqlQuery; +import org.nuiton.topia.service.migration.resources.MigrationVersionResource; +import org.nuiton.topia.service.migration.resources.MigrationVersionResourceExecutor; +import org.nuiton.version.Versions; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Set; + +/** + * @author Tony Chemit - dev@tchemit.fr + * @since 7.5.1 + */ +@AutoService(MigrationVersionResource.class) +public class DataSourceMigrationForVersion_7_5_1 extends MigrationVersionResource { + + public DataSourceMigrationForVersion_7_5_1() { + super(Versions.valueOf("7.5.1")); + } + + @Override + public void generateSqlScript(MigrationVersionResourceExecutor executor) { + Set<Pair<String, String>> tripIdAndComment = executor.findMultipleResultAstSet(new TopiaSqlQuery<Pair<String, String>>() { + @SuppressWarnings("SqlDialectInspection") + @Override + public PreparedStatement prepareQuery(Connection connection) throws SQLException { + return connection.prepareStatement("SELECT topiaId, comment FROM observe_seine.trip WHERE comment LIKE '#%#%'"); + } + + @Override + public Pair<String, String> prepareResult(ResultSet set) throws SQLException { + return Pair.of(set.getString(1), set.getString(2)); + } + }); + + executor.writeSql("ALTER TABLE observe_seine.trip ADD COLUMN homeId VARCHAR(255)"); + + for (Pair<String, String> pair : tripIdAndComment) { + String tripId = pair.getKey(); + String comment = pair.getValue().trim(); + + int endIndex = comment.indexOf('#', 1); + String homeId = comment.substring(1, endIndex - 1); + String newComment = endIndex + 1 == comment.length() ? "NULL" : (String.format("'%s'", comment.substring(endIndex + 1).trim().replaceAll("'","''"))); + executor.writeSql(String.format("UPDATE observe_seine.trip t SET comment = %s, homeId = '%s', topiaVersion = topiaVersion + 1, lastUpdateDate = CURRENT_TIMESTAMP WHERE t.topiaId = '%s';", newComment, homeId, tripId)); + } + } + +} + ===================================== persistence/src/main/models/Observe.model ===================================== @@ -851,6 +851,7 @@ vessel {*:1} referentiel.Vessel seine.TripSeine > CommentableEntity >> Trip | entity dbName=Trip startDate + {*:1} Date | hibernateAttributeType.java.util.Date=date endDate + {*:1} Date | hibernateAttributeType.java.util.Date=date +homeId + {*:1} String checkLevel + {*:1} int formsUrl + {*:1} String reportsUrl + {*:1} String ===================================== pom.xml ===================================== @@ -26,7 +26,7 @@ <parent> <groupId>io.ultreia.maven</groupId> <artifactId>pom</artifactId> - <version>2020.14</version> + <version>2020.15</version> </parent> <groupId>fr.ird.observe</groupId> @@ -149,7 +149,7 @@ <devMode>true</devMode> <!--persistence model version--> - <observe.model.version>7.5</observe.model.version> + <observe.model.version>7.5.1</observe.model.version> <!-- build timestamp configuration --> <maven.build.timestamp.format>dd/MM/yyyy HH:mm z</maven.build.timestamp.format> ===================================== test/src/main/resources/db/7.5.1/dataForTestLongline.sql.gz ===================================== Binary files /dev/null and b/test/src/main/resources/db/7.5.1/dataForTestLongline.sql.gz differ ===================================== test/src/main/resources/db/7.5.1/dataForTestSeine.sql.gz ===================================== Binary files /dev/null and b/test/src/main/resources/db/7.5.1/dataForTestSeine.sql.gz differ ===================================== test/src/main/resources/db/7.5.1/empty_h2.sql.gz ===================================== Binary files /dev/null and b/test/src/main/resources/db/7.5.1/empty_h2.sql.gz differ ===================================== test/src/main/resources/db/7.5.1/empty_pg.sql.gz ===================================== Binary files /dev/null and b/test/src/main/resources/db/7.5.1/empty_pg.sql.gz differ ===================================== test/src/main/resources/db/7.5.1/referentiel.sql.gz ===================================== Binary files /dev/null and b/test/src/main/resources/db/7.5.1/referentiel.sql.gz differ View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/5b631f82d7aca107b0b637f4c9... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/5b631f82d7aca107b0b637f4c9... You're receiving this email because of your account on gitlab.com.
participants (1)
-
Tony CHEMIT