Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe
Commits:
-
78ccbf3a
by Tony Chemit at 2022-04-30T12:53:02+02:00
-
f32f45b3
by Tony Chemit at 2022-04-30T12:53:02+02:00
-
b36df46d
by Tony Chemit at 2022-04-30T12:53:02+02:00
-
89a4ed2b
by Tony Chemit at 2022-04-30T12:53:02+02:00
-
3f2ade36
by Tony Chemit at 2022-04-30T14:47:45+02:00
14 changed files:
- client-core/src/main/java/fr/ird/observe/client/ui/content/ContentUIInitializer.java
- client-core/src/main/java/fr/ird/observe/client/ui/content/data/longline/TripLonglineUI.jcss
- client-core/src/main/java/fr/ird/observe/client/ui/content/data/seine/TripSeineUI.jcss
- client-core/src/main/java/fr/ird/observe/client/ui/storage/ObstunaAdminAction.java
- common-service/src/main/java/fr/ird/observe/services/configuration/DataSourceCreateConfigurationDto.java
- persistence/src/main/models/Observe.model
- pom.xml
- server-core/src/main/filtered-resources/mapping
- server-core/src/main/java/fr/ird/observe/server/controller/v1/DataSourceServiceRestApi.java
- services-local/src/main/java/fr/ird/observe/services/local/service/DataSourceServiceLocal.java
- services-local/src/main/java/fr/ird/observe/services/local/service/actions/consolidate/ConsolidateDataServiceLocal.java
- services/src/main/java/fr/ird/observe/services/service/DataSourceService.java
- services/src/main/java/fr/ird/observe/services/service/actions/synchro/referential/legacy/UnidirectionalReferentialSynchronizeEngine.java
- services/src/main/java/fr/ird/observe/services/service/referential/differential/DifferentialModel.java
Changes:
| ... | ... | @@ -40,6 +40,7 @@ import fr.ird.observe.client.ui.util.BooleanEditor; |
| 40 | 40 | import fr.ird.observe.client.ui.util.UIHelper;
|
| 41 | 41 | import fr.ird.observe.client.ui.util.time.UnlimitedTimeEditor;
|
| 42 | 42 | import fr.ird.observe.client.ui.util.tripMap.ObserveMapPane;
|
| 43 | +import fr.ird.observe.client.ui.util.tripMap.TripMapUI;
|
|
| 43 | 44 | import fr.ird.observe.client.validation.ObserveSwingValidator;
|
| 44 | 45 | import fr.ird.observe.dto.I18nEnumHelper;
|
| 45 | 46 | import fr.ird.observe.dto.IdDto;
|
| ... | ... | @@ -633,16 +634,15 @@ public class ContentUIInitializer<E extends IdDto, UI extends ContentUI<E, UI>> |
| 633 | 634 | protected void init(JComponent editor, Set<String> notBlockingComponents) {
|
| 634 | 635 | final Boolean propertyName = (Boolean) editor.getClientProperty(CLIENT_PROPERTY_NOT_BLOCKING);
|
| 635 | 636 | if (propertyName != null) {
|
| 636 | - |
|
| 637 | 637 | if (editor instanceof FilterableDoubleList) {
|
| 638 | - |
|
| 639 | 638 | notBlockingComponents.add("universeListPane");
|
| 640 | 639 | notBlockingComponents.add("selectedListPane");
|
| 641 | - |
|
| 640 | + } else if (editor instanceof TripMapUI) {
|
|
| 641 | + notBlockingComponents.add("zoomIt");
|
|
| 642 | + notBlockingComponents.add("zoomOut");
|
|
| 643 | + notBlockingComponents.add("zoomPlus");
|
|
| 642 | 644 | } else {
|
| 643 | - |
|
| 644 | 645 | notBlockingComponents.add(editor.getName());
|
| 645 | - |
|
| 646 | 646 | }
|
| 647 | 647 | }
|
| 648 | 648 | }
|
| ... | ... | @@ -102,6 +102,10 @@ |
| 102 | 102 | enabled:{!model.isCreatingMode()}
|
| 103 | 103 | }
|
| 104 | 104 | |
| 105 | +#tripMap {
|
|
| 106 | + _notBlocking: true;
|
|
| 107 | +}
|
|
| 108 | + |
|
| 105 | 109 | #reopen {
|
| 106 | 110 | _toolTipText:{t("observe.common.TripDto.action.reopen.tip")};
|
| 107 | 111 | }
|
| ... | ... | @@ -147,6 +147,10 @@ NumberEditor { |
| 147 | 147 | enabled:{!model.isCreatingMode()}
|
| 148 | 148 | }
|
| 149 | 149 | |
| 150 | +#tripMap {
|
|
| 151 | + _notBlocking: true;
|
|
| 152 | +}
|
|
| 153 | + |
|
| 150 | 154 | #reopen {
|
| 151 | 155 | _toolTipText:{t("observe.common.TripDto.action.reopen.tip")};
|
| 152 | 156 | }
|
| ... | ... | @@ -37,9 +37,12 @@ import fr.ird.observe.services.configuration.topia.ObserveDataSourceConfiguratio |
| 37 | 37 | import fr.ird.observe.services.service.BabModelVersionException;
|
| 38 | 38 | import fr.ird.observe.services.service.DatabaseConnexionNotAuthorizedException;
|
| 39 | 39 | import fr.ird.observe.services.service.DatabaseNotFoundException;
|
| 40 | -import org.apache.logging.log4j.Logger;
|
|
| 40 | +import fr.ird.observe.services.service.sql.AddSqlScriptProducerRequest;
|
|
| 41 | +import fr.ird.observe.services.service.sql.SqlScriptProducerService;
|
|
| 41 | 42 | import org.apache.logging.log4j.LogManager;
|
| 43 | +import org.apache.logging.log4j.Logger;
|
|
| 42 | 44 | import org.nuiton.jaxx.runtime.JAXXContext;
|
| 45 | +import org.nuiton.topia.persistence.script.TopiaSqlScript;
|
|
| 43 | 46 | import org.nuiton.version.Version;
|
| 44 | 47 | |
| 45 | 48 | import java.awt.Window;
|
| ... | ... | @@ -65,7 +68,7 @@ public enum ObstunaAdminAction { |
| 65 | 68 | CREATE() {
|
| 66 | 69 | @Override
|
| 67 | 70 | public RemoteUILauncher newLauncher(JAXXContext context, Window frame, boolean serverMode) {
|
| 68 | - return new RemoteUILauncher(this, context, frame, I18nEnumHelper.getLabel(this),serverMode ) {
|
|
| 71 | + return new RemoteUILauncher(this, context, frame, I18nEnumHelper.getLabel(this), serverMode) {
|
|
| 69 | 72 | |
| 70 | 73 | DataSourceCreateConfigurationDto createConfigurationDto;
|
| 71 | 74 | ObserveSwingDataSource dataSource;
|
| ... | ... | @@ -148,6 +151,29 @@ public enum ObstunaAdminAction { |
| 148 | 151 | log.info("Create db...");
|
| 149 | 152 | }
|
| 150 | 153 | |
| 154 | + ObserveDataSourceConfiguration importReferentialConfig = createConfigurationDto.getImportReferentialDataSourceConfiguration();
|
|
| 155 | + |
|
| 156 | + ObserveDataSourceConfiguration importDataDataSourceConfiguration = createConfigurationDto.getImportDataDataSourceConfiguration();
|
|
| 157 | + |
|
| 158 | + if (importReferentialConfig != null && importDataDataSourceConfiguration == null) {
|
|
| 159 | + |
|
| 160 | + // simple referential import, prepare dump here
|
|
| 161 | + |
|
| 162 | + Version dbVersion = dataSource.getVersion();
|
|
| 163 | + AddSqlScriptProducerRequest request = AddSqlScriptProducerRequest.forPostgres(dbVersion).addSchema().addReferential();
|
|
| 164 | + |
|
| 165 | + TopiaSqlScript referentialDump;
|
|
| 166 | + |
|
| 167 | + try (ObserveSwingDataSource importDataSource = Objects.requireNonNull(ObserveSwingApplicationContext.get().getDataSourcesManager().newDataSource(importReferentialConfig))) {
|
|
| 168 | + importDataSource.open();
|
|
| 169 | + |
|
| 170 | + SqlScriptProducerService dumpProducerService = importDataSource.getSqlScriptProducerService();
|
|
| 171 | + referentialDump = dumpProducerService.produceAddSqlScript(request);
|
|
| 172 | + createConfigurationDto.setImportDatabase(referentialDump);
|
|
| 173 | + }
|
|
| 174 | + }
|
|
| 175 | + |
|
| 176 | + |
|
| 151 | 177 | try {
|
| 152 | 178 | dataSource.create(createConfigurationDto);
|
| 153 | 179 | |
| ... | ... | @@ -161,6 +187,11 @@ public enum ObstunaAdminAction { |
| 161 | 187 | }
|
| 162 | 188 | }
|
| 163 | 189 | }
|
| 190 | + /*
|
|
| 191 | + INSERT INTO observe_common.vessel(topiaid,
|
|
| 192 | + topiaversion,
|
|
| 193 | + topiacreatedate, lastupdatedate, code, uri, needcomment, status, label1, label2, label3, label4, label5, label6, label7, label8, vesselsizecategory, vesseltype, flagcountry, keelcode, fleetcountry, changedate, yearservice, length, capacity, power, searchmaximum, comment, iattcid, ctoiid, nationalid, comid, tuviid, imoid, radiocallsignid, shipowner) VALUES ('fr.ird.observe.entities.referentiel.Vessel#1239832677818#0.8965634485687902', 23, '2009-04-15 00:00:00.1', '2022-03-25 10:22:37.082', '225', NULL, false, 1, 'PERE BRIANT', 'PERE BRIANT', 'PERE BRIANT', NULL, NULL, NULL, NULL, NULL, 'fr.ird.observe.entities.referentiel.VesselSizeCategory#1239832675542#0.750774668545597', 'fr.ird.observe.entities.referentiel.VesselType#1239832675735#0.307197212385357', 'fr.ird.observe.entities.referentiel.Country#1239832675583#0.9493110781716075', 209, 1, NULL, 1975, 64.65, 1575, 4000, 12, clob3: STRINGDECODE('Coul\u00e9 le 22/09/2011 au large du Gabon (20/09/2012 plus de positionnement VMS)'), 'ATEU0FRA00054', NULL, 'CC243864', NULL, NULL, '7363035', NULL, NULL)
|
|
| 194 | + */
|
|
| 164 | 195 | |
| 165 | 196 | @Override
|
| 166 | 197 | protected void applySecurity() {
|
| ... | ... | @@ -180,7 +211,7 @@ public enum ObstunaAdminAction { |
| 180 | 211 | UPDATE() {
|
| 181 | 212 | @Override
|
| 182 | 213 | public RemoteUILauncher newLauncher(JAXXContext context, Window frame, boolean serverMode) {
|
| 183 | - return new RemoteUILauncher(this, context, frame, I18nEnumHelper.getLabel(this),serverMode ) {
|
|
| 214 | + return new RemoteUILauncher(this, context, frame, I18nEnumHelper.getLabel(this), serverMode) {
|
|
| 184 | 215 | |
| 185 | 216 | ObserveSwingDataSource dataSource;
|
| 186 | 217 | ObserveDataSourceInformation dataSourceInformation;
|
| ... | ... | @@ -239,7 +270,7 @@ public enum ObstunaAdminAction { |
| 239 | 270 | SECURITY() {
|
| 240 | 271 | @Override
|
| 241 | 272 | public RemoteUILauncher newLauncher(JAXXContext context, Window frame, boolean serverMode) {
|
| 242 | - return new RemoteUILauncher(this, context, frame, I18nEnumHelper.getLabel(this),serverMode ) {
|
|
| 273 | + return new RemoteUILauncher(this, context, frame, I18nEnumHelper.getLabel(this), serverMode) {
|
|
| 243 | 274 | |
| 244 | 275 | ObserveSwingDataSource dataSource;
|
| 245 | 276 | ImmutableSet<ObserveDbUserDto> users;
|
| ... | ... | @@ -269,7 +300,10 @@ public enum ObstunaAdminAction { |
| 269 | 300 | public String getLabel() {
|
| 270 | 301 | return I18nEnumHelper.getLabel(this);
|
| 271 | 302 | }
|
| 272 | - /** Logger */
|
|
| 303 | + |
|
| 304 | + /**
|
|
| 305 | + * Logger
|
|
| 306 | + */
|
|
| 273 | 307 | private static final Logger log = LogManager.getLogger(ObstunaAdminAction.class);
|
| 274 | 308 | |
| 275 | 309 | public static ObstunaAdminAction valueOfIgnoreCase(String value) {
|
| ... | ... | @@ -111,6 +111,9 @@ public class DataSourceCreateConfigurationDto extends AbstractObserveDto { |
| 111 | 111 | public void setImportDatabase(TopiaSqlScript importDatabase) {
|
| 112 | 112 | Objects.requireNonNull(importDatabase, "'importDatabase' can't be null.");
|
| 113 | 113 | this.optionalImportDatabase = importDatabase;
|
| 114 | + if (optionalImportReferentialDataSourceConfiguration != null && optionalImportDataDataSourceConfiguration == null) {
|
|
| 115 | + optionalImportReferentialDataSourceConfiguration = null;
|
|
| 116 | + }
|
|
| 114 | 117 | }
|
| 115 | 118 | |
| 116 | 119 | public void setImportReferentialDataSourceConfiguration(ObserveDataSourceConfiguration importReferentialDataSourceConfiguration) {
|
| ... | ... | @@ -387,7 +387,7 @@ startDate + {*:1} Date |
| 387 | 387 | endDate + {*:1} Date
|
| 388 | 388 | |
| 389 | 389 | referentiel.Gear > referentiel.I18nReferentialEntity | entity
|
| 390 | -gearCaracteristic {*:*} referentiel.GearCaracteristic | lazy=false
|
|
| 390 | +gearCaracteristic {*:*} referentiel.GearCaracteristic | lazy=false orderBy=code
|
|
| 391 | 391 | |
| 392 | 392 | referentiel.GearCaracteristic > referentiel.I18nReferentialEntity | entity
|
| 393 | 393 | unit + {*:1} String
|
| ... | ... | @@ -485,7 +485,7 @@ referentiel.SizeMeasureType > referentiel.I18nReferentialEntity | entity |
| 485 | 485 | |
| 486 | 486 | referentiel.Species > referentiel.I18nReferentialEntity | entity
|
| 487 | 487 | speciesGroup {*:0..1} referentiel.SpeciesGroup | lazy=false
|
| 488 | -ocean {*:*} referentiel.Ocean | lazy=false
|
|
| 488 | +ocean {*:*} referentiel.Ocean | lazy=false orderBy=code
|
|
| 489 | 489 | faoCode + {*:1} String
|
| 490 | 490 | scientificLabel + {*:1} String
|
| 491 | 491 | homeId + {*:1} String
|
| ... | ... | @@ -497,7 +497,7 @@ maxWeight + {*:1} Float | sqlType=numeric |
| 497 | 497 | sizeMeasureType {*:0..1} referentiel.SizeMeasureType
|
| 498 | 498 | |
| 499 | 499 | referentiel.SpeciesGroup > referentiel.I18nReferentialEntity | entity
|
| 500 | -speciesGroupReleaseMode {*:*} referentiel.SpeciesGroupReleaseMode | unique lazy=false
|
|
| 500 | +speciesGroupReleaseMode {*:*} referentiel.SpeciesGroupReleaseMode | unique lazy=false orderBy=code
|
|
| 501 | 501 | |
| 502 | 502 | referentiel.SpeciesGroupReleaseMode > referentiel.I18nReferentialEntity | entity
|
| 503 | 503 |
| ... | ... | @@ -160,7 +160,7 @@ |
| 160 | 160 | <!-- build timestamp configuration -->
|
| 161 | 161 | <maven.build.timestamp.format>dd/MM/yyyy HH:mm z</maven.build.timestamp.format>
|
| 162 | 162 | <buildDate>${maven.build.timestamp}</buildDate>
|
| 163 | - <maven.version>3.8.4</maven.version>
|
|
| 163 | + <maven.version>3.8.5</maven.version>
|
|
| 164 | 164 | |
| 165 | 165 | <!--Fixed versions-->
|
| 166 | 166 | <lib.version.nuiton.validation>3.1</lib.version.nuiton.validation>
|
| ... | ... | @@ -170,17 +170,25 @@ |
| 170 | 170 | <lib.version.java4all.topia>1.1.17</lib.version.java4all.topia>
|
| 171 | 171 | <lib.version.nuiton.utils>3.0</lib.version.nuiton.utils>
|
| 172 | 172 | <lib.version.java4all.jaxx>3.0-alpha-75</lib.version.java4all.jaxx>
|
| 173 | - |
|
| 174 | - <lib.version.log4j2>2.17.1</lib.version.log4j2>
|
|
| 175 | -<!-- <lib.version.hibernate>5.6.3.Final</lib.version.hibernate>-->
|
|
| 173 | + <lib.version.hibernate>5.6.8.Final</lib.version.hibernate>
|
|
| 174 | + <lib.version.hikariCP>4.0.3</lib.version.hikariCP>
|
|
| 176 | 175 | <!-- <lib.version.hikariCP>5.0.0</lib.version.hikariCP>-->
|
| 177 | -<!-- <lib.version.bytebuddy>1.12.2</lib.version.bytebuddy>-->
|
|
| 178 | - <lib.version.postgresql>42.3.1</lib.version.postgresql>
|
|
| 176 | + <lib.version.bytebuddy>1.12.9</lib.version.bytebuddy>
|
|
| 177 | + <lib.version.nuiton.topia>3.8.1</lib.version.nuiton.topia>
|
|
| 178 | + <lib.version.nuiton.version>1.0</lib.version.nuiton.version>
|
|
| 179 | + <lib.version.log4j2>2.17.2</lib.version.log4j2>
|
|
| 180 | + <lib.version.slf4j>1.7.32</lib.version.slf4j>
|
|
| 181 | + <lib.version.javassist>3.28.0-GA</lib.version.javassist>
|
|
| 182 | + <lib.version.jackson>2.12.0</lib.version.jackson>
|
|
| 183 | + <lib.version.mockito>4.4.0</lib.version.mockito>
|
|
| 184 | + <lib.version.google.guava>31.1-jre</lib.version.google.guava>
|
|
| 185 | + <lib.version.google.gson>2.9.0</lib.version.google.gson>
|
|
| 186 | + <lib.version.google.auto-service>1.0.1</lib.version.google.auto-service>
|
|
| 187 | + <lib.version.postgresql>42.3.4</lib.version.postgresql>
|
|
| 179 | 188 | <lib.version.commons-io>2.11.0</lib.version.commons-io>
|
| 180 | 189 | <lib.version.commons-lang3>3.12.0</lib.version.commons-lang3>
|
| 181 | - <lib.version.checker-qual>3.20.0</lib.version.checker-qual>
|
|
| 190 | + <lib.version.checker-qual>3.21.4</lib.version.checker-qual>
|
|
| 182 | 191 | <lib.version.sisu.plexus>0.3.5</lib.version.sisu.plexus>
|
| 183 | - |
|
| 184 | 192 | <!-- license header configuration -->
|
| 185 | 193 | <license.licenseName>gpl_v3</license.licenseName>
|
| 186 | 194 | <license.organizationName>IRD, Code Lutin, Ultreia.io</license.organizationName>
|
| ... | ... | @@ -221,6 +229,52 @@ |
| 221 | 229 | |
| 222 | 230 | <dependencyManagement>
|
| 223 | 231 | <dependencies>
|
| 232 | + <dependency>
|
|
| 233 | + <groupId>commons-validator</groupId>
|
|
| 234 | + <artifactId>commons-validator</artifactId>
|
|
| 235 | + <version>1.7</version>
|
|
| 236 | + </dependency>
|
|
| 237 | + <dependency>
|
|
| 238 | + <groupId>commons-io</groupId>
|
|
| 239 | + <artifactId>commons-io</artifactId>
|
|
| 240 | + <version>2.11.0</version>
|
|
| 241 | + </dependency>
|
|
| 242 | + <dependency>
|
|
| 243 | + <groupId>org.apache.commons</groupId>
|
|
| 244 | + <artifactId>commons-lang3</artifactId>
|
|
| 245 | + <version>3.12.0</version>
|
|
| 246 | + </dependency>
|
|
| 247 | + <dependency>
|
|
| 248 | + <groupId>org.apache.httpcomponents</groupId>
|
|
| 249 | + <artifactId>httpclient</artifactId>
|
|
| 250 | + <version>4.5.13</version>
|
|
| 251 | + </dependency>
|
|
| 252 | + <dependency>
|
|
| 253 | + <groupId>org.apache.httpcomponents</groupId>
|
|
| 254 | + <artifactId>httpcore</artifactId>
|
|
| 255 | + <version>4.4.15</version>
|
|
| 256 | + </dependency>
|
|
| 257 | + <dependency>
|
|
| 258 | + <groupId>org.apache.httpcomponents</groupId>
|
|
| 259 | + <artifactId>httpmime</artifactId>
|
|
| 260 | + <version>4.5.13</version>
|
|
| 261 | + </dependency>
|
|
| 262 | + <dependency>
|
|
| 263 | + <groupId>org.jboss.logging</groupId>
|
|
| 264 | + <artifactId>jboss-logging</artifactId>
|
|
| 265 | + <version>3.4.3.Final</version>
|
|
| 266 | + </dependency>
|
|
| 267 | + <dependency>
|
|
| 268 | + <groupId>org.freemarker</groupId>
|
|
| 269 | + <artifactId>freemarker</artifactId>
|
|
| 270 | + <version>2.3.31</version>
|
|
| 271 | + </dependency>
|
|
| 272 | + <dependency>
|
|
| 273 | + <groupId>junit</groupId>
|
|
| 274 | + <artifactId>junit</artifactId>
|
|
| 275 | + <version>4.13.2</version>
|
|
| 276 | + <scope>test</scope>
|
|
| 277 | + </dependency>
|
|
| 224 | 278 | <dependency>
|
| 225 | 279 | <groupId>org.eclipse.sisu</groupId>
|
| 226 | 280 | <artifactId>org.eclipse.sisu.inject</artifactId>
|
| ... | ... | @@ -58,7 +58,7 @@ GET /api/v1/DataSourceService/backup |
| 58 | 58 | GET /api/v1/DataSourceService/checkCanConnect v1.DataSourceServiceRestApi.checkCanConnect
|
| 59 | 59 | GET /api/v1/DataSourceService/checkCanConnectOrBeEmpty v1.DataSourceServiceRestApi.checkCanConnectOrBeEmpty
|
| 60 | 60 | GET /api/v1/DataSourceService/close v1.DataSourceServiceRestApi.close
|
| 61 | -GET /api/v1/DataSourceService/create v1.DataSourceServiceRestApi.create
|
|
| 61 | +POST /api/v1/DataSourceService/create v1.DataSourceServiceRestApi.create
|
|
| 62 | 62 | GET /api/v1/DataSourceService/destroy v1.DataSourceServiceRestApi.destroy
|
| 63 | 63 | GET /api/v1/DataSourceService/getReferentialTypesInShell v1.DataSourceServiceRestApi.getReferentialTypesInShell
|
| 64 | 64 | GET /api/v1/DataSourceService/getUsers v1.DataSourceServiceRestApi.getUsers
|
| ... | ... | @@ -53,6 +53,12 @@ public class DataSourceServiceRestApi extends GeneratedDataSourceServiceRestApi |
| 53 | 53 | /** Logger. */
|
| 54 | 54 | private static final Logger log = LogManager.getLogger(DataSourceServiceRestApi.class);
|
| 55 | 55 | |
| 56 | + @Override
|
|
| 57 | + public ObserveDataSourceInformation checkCanConnectOrBeEmpty(ObserveDataSourceConfiguration dataSourceConfiguration) throws DatabaseNotFoundException, DatabaseConnexionNotAuthorizedException {
|
|
| 58 | + ObserveDataSourceConfiguration dataSourceConfigurationTopia = getTopiaDataSourceConfiguration(dataSourceConfiguration);
|
|
| 59 | + return getAnonymousService(dataSourceConfigurationTopia).checkCanConnectOrBeEmpty(dataSourceConfigurationTopia);
|
|
| 60 | + }
|
|
| 61 | + |
|
| 56 | 62 | @Override
|
| 57 | 63 | public ObserveDataSourceInformation checkCanConnect(ObserveDataSourceConfiguration dataSourceConfiguration) throws DatabaseConnexionNotAuthorizedException, DatabaseNotFoundException {
|
| 58 | 64 |
| ... | ... | @@ -68,8 +68,6 @@ import org.nuiton.version.Version; |
| 68 | 68 | import org.nuiton.version.Versions;
|
| 69 | 69 | |
| 70 | 70 | import java.io.File;
|
| 71 | -import java.io.IOException;
|
|
| 72 | -import java.nio.file.Files;
|
|
| 73 | 71 | import java.nio.file.Path;
|
| 74 | 72 | import java.util.LinkedHashSet;
|
| 75 | 73 | import java.util.Optional;
|
| ... | ... | @@ -290,6 +288,7 @@ public class DataSourceServiceLocal extends ObserveServiceLocal implements DataS |
| 290 | 288 | |
| 291 | 289 | dataSourceCreateConfiguration.validateConfiguration();
|
| 292 | 290 | Path temporaryDirectory = getTemporaryDirectory(dataSourceConfiguration);
|
| 291 | + log.debug("Will use temporary directory: " + temporaryDirectory);
|
|
| 293 | 292 | boolean initSchema = !dataSourceCreateConfiguration.isImportDatabase();
|
| 294 | 293 | |
| 295 | 294 | ObserveTopiaApplicationContext topiaApplicationContext = ObserveTopiaApplicationContextFactory.createTopiaApplicationContext((ObserveDataSourceConfigurationTopiaSupport) dataSourceConfiguration, initSchema);
|
| ... | ... | @@ -301,41 +300,45 @@ public class DataSourceServiceLocal extends ObserveServiceLocal implements DataS |
| 301 | 300 | log.info("Create new database from a script.");
|
| 302 | 301 | TopiaSqlScript importDatabase = dataSourceCreateConfiguration.getImportDatabase();
|
| 303 | 302 | |
| 304 | - if (((ObserveDataSourceConfigurationTopiaSupport) dataSourceConfiguration).isH2Database()) {
|
|
| 305 | - topiaApplicationContext.executeSqlStatements(importDatabase);
|
|
| 306 | - topiaApplicationContext.getMigrationService().createSchemaIfNotExist();
|
|
| 307 | - topiaApplicationContext.getMigrationService().runSchemaMigration();
|
|
| 308 | - } else { // base postgres
|
|
| 309 | - |
|
| 310 | - // on realise les import dans un base H2 temporaire
|
|
| 311 | - File tmpDir;
|
|
| 312 | - try {
|
|
| 313 | - tmpDir = Files.createTempDirectory(temporaryDirectory, "obstuna").toFile();
|
|
| 314 | - } catch (IOException e) {
|
|
| 315 | - throw new IllegalStateException("could not create temporary directory ", e);
|
|
| 316 | - }
|
|
| 317 | - |
|
| 318 | - ObserveDataSourceConfigurationTopiaH2 temporaryConfiguration = createTemporaryConfiguration(tmpDir, dataSourceConfiguration.getModelVersion());
|
|
| 319 | - |
|
| 320 | - ObserveTopiaApplicationContext temporaryTopiaApplicationContext = ObserveTopiaApplicationContextFactory.createTopiaApplicationContext(temporaryConfiguration, false);
|
|
| 321 | - temporaryTopiaApplicationContext.executeSqlStatements(importDatabase);
|
|
| 322 | - temporaryTopiaApplicationContext.getMigrationService().createSchemaIfNotExist();
|
|
| 323 | - temporaryTopiaApplicationContext.getMigrationService().runSchemaMigration();
|
|
| 324 | - |
|
| 325 | - SqlScriptProducerService dumpProducerService = serviceContext.newService(temporaryConfiguration, SqlScriptProducerService.class);
|
|
| 326 | - AddSqlScriptProducerRequest request = AddSqlScriptProducerRequest.forPostgres(dataSourceConfiguration.getModelVersion()).addSchema().addReferential().addAllData();
|
|
| 327 | - TopiaSqlScript dump = dumpProducerService.produceAddSqlScript(request);
|
|
| 328 | - topiaApplicationContext.executeSqlStatements(dump);
|
|
| 329 | - topiaApplicationContext.getMigrationService().createSchemaIfNotExist();
|
|
| 330 | - topiaApplicationContext.getMigrationService().runSchemaMigration();
|
|
| 331 | - |
|
| 332 | - temporaryTopiaApplicationContext.close();
|
|
| 333 | - File databaseFile = temporaryConfiguration.getDatabaseFile();
|
|
| 334 | - |
|
| 335 | - if (!databaseFile.delete()) {
|
|
| 336 | - throw new IllegalStateException("could not delete " + databaseFile);
|
|
| 337 | - }
|
|
| 338 | - }
|
|
| 303 | + topiaApplicationContext.executeSqlStatements(importDatabase);
|
|
| 304 | + topiaApplicationContext.getMigrationService().createSchemaIfNotExist();
|
|
| 305 | + topiaApplicationContext.getMigrationService().runSchemaMigration();
|
|
| 306 | + |
|
| 307 | +// if (((ObserveDataSourceConfigurationTopiaSupport) dataSourceConfiguration).isH2Database()) {
|
|
| 308 | +// topiaApplicationContext.executeSqlStatements(importDatabase);
|
|
| 309 | +// topiaApplicationContext.getMigrationService().createSchemaIfNotExist();
|
|
| 310 | +// topiaApplicationContext.getMigrationService().runSchemaMigration();
|
|
| 311 | +// } else { // base postgres
|
|
| 312 | +//
|
|
| 313 | +// // on realise les import dans un base H2 temporaire
|
|
| 314 | +// File tmpDir;
|
|
| 315 | +// try {
|
|
| 316 | +// tmpDir = Files.createTempDirectory(temporaryDirectory, "obstuna").toFile();
|
|
| 317 | +// } catch (IOException e) {
|
|
| 318 | +// throw new IllegalStateException("could not create temporary directory ", e);
|
|
| 319 | +// }
|
|
| 320 | +//
|
|
| 321 | +// ObserveDataSourceConfigurationTopiaH2 temporaryConfiguration = createTemporaryConfiguration(tmpDir, dataSourceConfiguration.getModelVersion());
|
|
| 322 | +// temporaryConfiguration.setTemporaryDirectory(temporaryDirectory);
|
|
| 323 | +// ObserveTopiaApplicationContext temporaryTopiaApplicationContext = ObserveTopiaApplicationContextFactory.createTopiaApplicationContext(temporaryConfiguration, false);
|
|
| 324 | +// temporaryTopiaApplicationContext.executeSqlStatements(importDatabase);
|
|
| 325 | +// temporaryTopiaApplicationContext.getMigrationService().createSchemaIfNotExist();
|
|
| 326 | +// temporaryTopiaApplicationContext.getMigrationService().runSchemaMigration();
|
|
| 327 | +//
|
|
| 328 | +// SqlScriptProducerService dumpProducerService = serviceContext.newService(temporaryConfiguration, SqlScriptProducerService.class);
|
|
| 329 | +// AddSqlScriptProducerRequest request = AddSqlScriptProducerRequest.forPostgres(dataSourceConfiguration.getModelVersion()).addSchema().addReferential().addAllData();
|
|
| 330 | +// TopiaSqlScript dump = dumpProducerService.produceAddSqlScript(request);
|
|
| 331 | +// topiaApplicationContext.executeSqlStatements(dump);
|
|
| 332 | +// topiaApplicationContext.getMigrationService().createSchemaIfNotExist();
|
|
| 333 | +// topiaApplicationContext.getMigrationService().runSchemaMigration();
|
|
| 334 | +//
|
|
| 335 | +// temporaryTopiaApplicationContext.close();
|
|
| 336 | +// File databaseFile = temporaryConfiguration.getDatabaseFile();
|
|
| 337 | +//
|
|
| 338 | +// if (!databaseFile.delete()) {
|
|
| 339 | +// throw new IllegalStateException("could not delete " + databaseFile);
|
|
| 340 | +// }
|
|
| 341 | +// }
|
|
| 339 | 342 | |
| 340 | 343 | } else {
|
| 341 | 344 | |
| ... | ... | @@ -539,7 +542,10 @@ public class DataSourceServiceLocal extends ObserveServiceLocal implements DataS |
| 539 | 542 | |
| 540 | 543 | @Override
|
| 541 | 544 | public Set<ObserveDbUserDto> getUsers(ObserveDataSourceConfiguration dataSourceConfiguration) {
|
| 542 | - |
|
| 545 | + // Make sure temporary directory set in configuration
|
|
| 546 | + // See https://gitlab.com/ultreiaio/ird-observe/-/issues/2214
|
|
| 547 | + Path temporaryDirectory = getTemporaryDirectory(dataSourceConfiguration);
|
|
| 548 | + log.debug("Will use temporary directory: " + temporaryDirectory);
|
|
| 543 | 549 | Set<ObserveDbUserDto> users = new LinkedHashSet<>();
|
| 544 | 550 | |
| 545 | 551 | // pas d'user pour les bases autres que postgresql
|
| ... | ... | @@ -226,7 +226,7 @@ public class ConsolidateDataServiceLocal extends ObserveServiceLocal implements |
| 226 | 226 | for (Route route : tripSeine.getRoute()) {
|
| 227 | 227 | |
| 228 | 228 | String routePrefix = String.format("Route [%s/%s] ", ++routeIndex, routeMax);
|
| 229 | - log.info(String.format("%s Start consolidate route: %s", routePrefix, route.getTopiaId()));
|
|
| 229 | + log.debug(String.format("%s Start consolidate route: %s", routePrefix, route.getTopiaId()));
|
|
| 230 | 230 | int activityIndex = 0;
|
| 231 | 231 | int activityMax = route.sizeActivitySeine();
|
| 232 | 232 | for (ActivitySeine activitySeine : route.getActivitySeine()) {
|
| ... | ... | @@ -235,7 +235,7 @@ public class ConsolidateDataServiceLocal extends ObserveServiceLocal implements |
| 235 | 235 | |
| 236 | 236 | boolean floatingObjectEmpty = activitySeine.isFloatingObjectEmpty();
|
| 237 | 237 | if (!activitySeine.isSetOperation() && floatingObjectEmpty) {
|
| 238 | - log.info(String.format("%s Skip activity (No set nor dcp found): %s", activityPrefix, activitySeine.getTopiaId()));
|
|
| 238 | + log.debug(String.format("%s Skip activity (No set nor dcp found): %s", activityPrefix, activitySeine.getTopiaId()));
|
|
| 239 | 239 | continue;
|
| 240 | 240 | }
|
| 241 | 241 | |
| ... | ... | @@ -300,7 +300,7 @@ public class ConsolidateDataServiceLocal extends ObserveServiceLocal implements |
| 300 | 300 | |
| 301 | 301 | ActivitySeine activity = activityContext.activity;
|
| 302 | 302 | |
| 303 | - log.info(String.format("%s Start consolidate activity: %s", activityContext.activityPrefix, activity.getTopiaId()));
|
|
| 303 | + log.debug(String.format("%s Start consolidate activity: %s", activityContext.activityPrefix, activity.getTopiaId()));
|
|
| 304 | 304 | |
| 305 | 305 | if (activity.isFloatingObjectNotEmpty()) {
|
| 306 | 306 |
| ... | ... | @@ -32,6 +32,7 @@ import fr.ird.observe.services.configuration.ObserveDataSourceConfiguration; |
| 32 | 32 | import fr.ird.observe.services.configuration.ObserveDataSourceConnection;
|
| 33 | 33 | import fr.ird.observe.services.configuration.ObserveDataSourceInformation;
|
| 34 | 34 | import io.ultreia.java4all.http.spi.Get;
|
| 35 | +import io.ultreia.java4all.http.spi.Post;
|
|
| 35 | 36 | |
| 36 | 37 | import java.io.Closeable;
|
| 37 | 38 | import java.io.File;
|
| ... | ... | @@ -50,7 +51,7 @@ public interface DataSourceService extends ObserveService, Closeable { |
| 50 | 51 | @Get(addAuthtoken = false)
|
| 51 | 52 | ObserveDataSourceInformation checkCanConnectOrBeEmpty(ObserveDataSourceConfiguration dataSourceConfiguration) throws DatabaseNotFoundException, DatabaseConnexionNotAuthorizedException;
|
| 52 | 53 | |
| 53 | - @Get(addAuthtoken = false)
|
|
| 54 | + @Post(addAuthtoken = false, useMultiPartForm = true)
|
|
| 54 | 55 | ObserveDataSourceConnection create(ObserveDataSourceConfiguration dataSourceConfiguration, DataSourceCreateConfigurationDto dataSourceCreateConfiguration)
|
| 55 | 56 | throws IncompatibleDataSourceCreateConfigurationException, DataSourceCreateWithNoReferentialImportException,
|
| 56 | 57 | BabModelVersionException, DatabaseConnexionNotAuthorizedException, DatabaseNotFoundException;
|
| ... | ... | @@ -40,6 +40,7 @@ import org.apache.commons.collections4.CollectionUtils; |
| 40 | 40 | import org.apache.logging.log4j.LogManager;
|
| 41 | 41 | import org.apache.logging.log4j.Logger;
|
| 42 | 42 | |
| 43 | +import java.util.Collections;
|
|
| 43 | 44 | import java.util.LinkedHashSet;
|
| 44 | 45 | import java.util.LinkedList;
|
| 45 | 46 | import java.util.List;
|
| ... | ... | @@ -110,7 +111,7 @@ public class UnidirectionalReferentialSynchronizeEngine { |
| 110 | 111 | Set<String> insertAssociationSqlRequests = new LinkedHashSet<>();
|
| 111 | 112 | Set<String> deleteAssociationSqlRequests = new LinkedHashSet<>();
|
| 112 | 113 | Set<String> updateSqlRequests = new LinkedHashSet<>();
|
| 113 | - Set<String> deleteSqlRequests = new LinkedHashSet<>();
|
|
| 114 | + List<String> deleteSqlRequests = new LinkedList<>();
|
|
| 114 | 115 | |
| 115 | 116 | Set<String> sqlRequests = new LinkedHashSet<>();
|
| 116 | 117 | |
| ... | ... | @@ -142,7 +143,6 @@ public class UnidirectionalReferentialSynchronizeEngine { |
| 142 | 143 | |
| 143 | 144 | Set<String> generatedSqlRequests = localService.generateSqlRequests(referentialSynchronizeRequest);
|
| 144 | 145 | for (String sqlStatement : generatedSqlRequests) {
|
| 145 | - |
|
| 146 | 146 | if (sqlStatement.startsWith("INSERT")) {
|
| 147 | 147 | insertSqlRequests.add(sqlStatement);
|
| 148 | 148 | } else if (sqlStatement.startsWith("$$_INSERT")) {
|
| ... | ... | @@ -155,12 +155,13 @@ public class UnidirectionalReferentialSynchronizeEngine { |
| 155 | 155 | deleteSqlRequests.add(sqlStatement);
|
| 156 | 156 | }
|
| 157 | 157 | }
|
| 158 | - |
|
| 159 | 158 | }
|
| 160 | 159 | sqlRequests.addAll(deleteAssociationSqlRequests);
|
| 161 | 160 | sqlRequests.addAll(insertSqlRequests);
|
| 162 | 161 | sqlRequests.addAll(insertAssociationSqlRequests);
|
| 163 | 162 | sqlRequests.addAll(updateSqlRequests);
|
| 163 | + // always reverse delete order - See 2306
|
|
| 164 | + Collections.reverse(deleteSqlRequests);
|
|
| 164 | 165 | sqlRequests.addAll(deleteSqlRequests);
|
| 165 | 166 | |
| 166 | 167 | context.setSqlRequests(sqlRequests);
|
| ... | ... | @@ -187,12 +188,18 @@ public class UnidirectionalReferentialSynchronizeEngine { |
| 187 | 188 | UnidirectionalReferentialSynchronizeRequest.Builder<D> builder = UnidirectionalReferentialSynchronizeRequest.builder(dtoType);
|
| 188 | 189 | |
| 189 | 190 | List<D> leftAddDifferentials = new LinkedList<>();
|
| 191 | + List<D> leftUpdateDifferentials = new LinkedList<>();
|
|
| 190 | 192 | DifferentialList leftDifferentials = leftDiffStates.get(dtoType);
|
| 191 | 193 | if (leftDifferentials != null) {
|
| 192 | - leftDifferentials.getStates().stream().filter(f -> f.getDifferentialType() == DifferentialType.ADDED).forEach(d -> {
|
|
| 193 | - @SuppressWarnings("unchecked") D thisSourceDto = (D) d.getThisSourceDto();
|
|
| 194 | - leftAddDifferentials.add(thisSourceDto);
|
|
| 195 | - });
|
|
| 194 | + for (Differential differential : leftDifferentials.getStates()) {
|
|
| 195 | + @SuppressWarnings("unchecked") D thisSourceDto = (D) differential.getThisSourceDto();
|
|
| 196 | + if (differential.getDifferentialType() == DifferentialType.ADDED) {
|
|
| 197 | + leftAddDifferentials.add(thisSourceDto);
|
|
| 198 | + } else {
|
|
| 199 | + @SuppressWarnings("unchecked") D rightDto = (D) differential.getOptionalOtherSideDto().orElse(null);
|
|
| 200 | + leftUpdateDifferentials.add(rightDto);
|
|
| 201 | + }
|
|
| 202 | + }
|
|
| 196 | 203 | }
|
| 197 | 204 | |
| 198 | 205 | DifferentialList rightDifferentials = rightDiffStates.get(dtoType);
|
| ... | ... | @@ -219,6 +226,11 @@ public class UnidirectionalReferentialSynchronizeEngine { |
| 219 | 226 | rightUpdateDifferentials.forEach(builder::entityToUpdate);
|
| 220 | 227 | }
|
| 221 | 228 | |
| 229 | + // Tous les référentiels mises à jour dans la base local doivent être mis à jour depuis la base centrale
|
|
| 230 | + if (!leftUpdateDifferentials.isEmpty()) {
|
|
| 231 | + leftUpdateDifferentials.forEach(builder::entityToUpdate);
|
|
| 232 | + }
|
|
| 233 | + |
|
| 222 | 234 | // Tous les référentiels non présents dans la base centrale doivent être supprimés en local
|
| 223 | 235 | if (!leftAddDifferentials.isEmpty()) {
|
| 224 | 236 |
| ... | ... | @@ -179,9 +179,11 @@ public class DifferentialModel { |
| 179 | 179 | D rightSideDto = rightSideDtoMap.get(id);
|
| 180 | 180 | |
| 181 | 181 | int compareLastUpdateDate = compareTo(leftSideDto, rightSideDto);
|
| 182 | - if (0 == compareLastUpdateDate) {
|
|
| 183 | - continue;
|
|
| 184 | - }
|
|
| 182 | + // always compare properties to be sure to have all modifications
|
|
| 183 | + // See 2306
|
|
| 184 | +// if (0 == compareLastUpdateDate) {
|
|
| 185 | +// continue;
|
|
| 186 | +// }
|
|
| 185 | 187 | |
| 186 | 188 | // something may be modified
|
| 187 | 189 |