Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
e231274d
by Tony Chemit at 2024-01-25T08:02:39+01:00
-
ee974f7a
by Tony Chemit at 2024-01-25T08:02:39+01:00
19 changed files:
- client/core/pom.xml
- client/core/src/main/java/fr/ird/observe/client/datasource/api/ObserveSwingDataSource.java
- client/core/src/main/java/fr/ird/observe/client/datasource/h2/backup/LocalDatabaseBackupTaskSupport.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/wizard/StorageBackupUILauncher.java
- core/api/services/pom.xml
- core/services/local/src/main/java/fr/ird/observe/services/local/service/DataSourceServiceLocalSupport.java
- core/services/local/src/test/java/fr/ird/observe/services/local/service/DataSourceServiceLocalReadTest.java
- core/services/test/pom.xml
- core/services/test/src/main/java/fr/ird/observe/services/service/DataSourceServiceFixtures.java
- pom.xml
- server/core/src/main/filtered-resources/META-INF/mapping-api-client.wm
- server/core/src/main/java/fr/ird/observe/server/controller/DataSourceServiceRestApi.java
- toolkit/api-services/pom.xml
- toolkit/api-services/src/main/java/fr/ird/observe/services/service/DataSourceService.java
- toolkit/api/src/main/java/fr/ird/observe/navigation/tree/io/ToolkitTreeNodeStates.java
- toolkit/persistence/src/main/java/org/nuiton/topia/persistence/TopiaApplicationContext.java
- toolkit/persistence/src/main/java/org/nuiton/topia/persistence/internal/AbstractTopiaApplicationContext.java
- toolkit/persistence/src/main/java/org/nuiton/topia/persistence/jdbc/JdbcHelperH2.java
- toolkit/plugin/src/main/java/fr/ird/observe/toolkit/maven/plugin/tck/MigrateTckDatabases.java
Changes:
| ... | ... | @@ -79,6 +79,11 @@ |
| 79 | 79 | <artifactId>toolkit-api-services</artifactId>
|
| 80 | 80 | <version>${project.version}</version>
|
| 81 | 81 | </dependency>
|
| 82 | + <dependency>
|
|
| 83 | + <groupId>${project.groupId}</groupId>
|
|
| 84 | + <artifactId>toolkit-persistence</artifactId>
|
|
| 85 | + <version>${project.version}</version>
|
|
| 86 | + </dependency>
|
|
| 82 | 87 | <dependency>
|
| 83 | 88 | <groupId>com.google.code.gson</groupId>
|
| 84 | 89 | <artifactId>gson</artifactId>
|
| ... | ... | @@ -57,6 +57,7 @@ import fr.ird.observe.dto.data.ps.dcp.FloatingObjectPresetsStorage; |
| 57 | 57 | import fr.ird.observe.dto.reference.ReferentialDtoReference;
|
| 58 | 58 | import fr.ird.observe.dto.reference.ReferentialDtoReferenceSet;
|
| 59 | 59 | import fr.ird.observe.dto.referential.ReferentialDto;
|
| 60 | +import fr.ird.observe.entities.ObserveTopiaConfigurationFactory;
|
|
| 60 | 61 | import fr.ird.observe.navigation.id.IdAggregateModel;
|
| 61 | 62 | import fr.ird.observe.navigation.id.IdModel;
|
| 62 | 63 | import fr.ird.observe.navigation.id.IdNode;
|
| ... | ... | @@ -80,6 +81,8 @@ import io.ultreia.java4all.util.Version; |
| 80 | 81 | import io.ultreia.java4all.util.sql.SqlScript;
|
| 81 | 82 | import org.apache.logging.log4j.LogManager;
|
| 82 | 83 | import org.apache.logging.log4j.Logger;
|
| 84 | +import org.nuiton.topia.persistence.TopiaConfiguration;
|
|
| 85 | +import org.nuiton.topia.persistence.jdbc.JdbcHelperH2;
|
|
| 83 | 86 | |
| 84 | 87 | import javax.swing.BoundedRangeModel;
|
| 85 | 88 | import javax.swing.Icon;
|
| ... | ... | @@ -715,4 +718,13 @@ public class ObserveSwingDataSource extends AbstractJavaBean implements ObserveS |
| 715 | 718 | }
|
| 716 | 719 | return String.format("%s (%s)", getLabel(), txt);
|
| 717 | 720 | }
|
| 721 | + |
|
| 722 | + public void backup(File file) {
|
|
| 723 | + if (!isLocal()) {
|
|
| 724 | + throw new IllegalStateException("Cant backup a none H2 database.");
|
|
| 725 | + }
|
|
| 726 | + TopiaConfiguration configuration = ObserveTopiaConfigurationFactory.create(getConfiguration());
|
|
| 727 | + JdbcHelperH2 jdbcHelperH2 = new JdbcHelperH2(configuration);
|
|
| 728 | + jdbcHelperH2.backup(file, true);
|
|
| 729 | + }
|
|
| 718 | 730 | } |
| ... | ... | @@ -81,7 +81,7 @@ public abstract class LocalDatabaseBackupTaskSupport implements Runnable { |
| 81 | 81 | ClientUIContextApplicationComponent.value().getBusyModel().addTask(startMessage + " - " + file);
|
| 82 | 82 | ObserveSwingDataSource mainDataSource = dataSourcesManager.getMainDataSource();
|
| 83 | 83 | try {
|
| 84 | - mainDataSource.getDataSourceService().backup(file);
|
|
| 84 | + mainDataSource.backup(file);
|
|
| 85 | 85 | } finally {
|
| 86 | 86 | String endMessage = t("observe.ui.datasource.backup.done", new Date(), Strings.convertTime(System.nanoTime() - t0));
|
| 87 | 87 | ClientUIContextApplicationComponent.value().setUiStatus(endMessage);
|
| ... | ... | @@ -127,7 +127,7 @@ public class StorageBackupUILauncher extends StorageUILauncher { |
| 127 | 127 | progressModel.setMaximum(1);
|
| 128 | 128 | try {
|
| 129 | 129 | log.info(String.format("Exporting to %s", backupFile));
|
| 130 | - incomingSource.getDataSourceService().backup(backupFile);
|
|
| 130 | + incomingSource.backup(backupFile);
|
|
| 131 | 131 | progressModel.increments();
|
| 132 | 132 | } catch (Exception e) {
|
| 133 | 133 | throw new ObserveSwingTechnicalException(e);
|
| ... | ... | @@ -155,7 +155,7 @@ public class StorageBackupUILauncher extends StorageUILauncher { |
| 155 | 155 | |
| 156 | 156 | // finally backup temporary storage
|
| 157 | 157 | log.info(String.format("Exporting to %s", backupFile));
|
| 158 | - targetSource.getDataSourceService().backup(backupFile);
|
|
| 158 | + targetSource.backup(backupFile);
|
|
| 159 | 159 | progressModel.increments();
|
| 160 | 160 | } catch (DatabaseNotFoundException | DatabaseConnexionNotAuthorizedException | BabModelVersionException |
|
| 161 | 161 | IncompatibleDataSourceCreateConfigurationException |
|
| ... | ... | @@ -161,5 +161,64 @@ |
| 161 | 161 | </plugin>
|
| 162 | 162 | </plugins>
|
| 163 | 163 | </pluginManagement>
|
| 164 | + <plugins>
|
|
| 165 | + <plugin>
|
|
| 166 | + <groupId>io.ultreia.java4all.http</groupId>
|
|
| 167 | + <artifactId>http-maven-plugin</artifactId>
|
|
| 168 | + <dependencies>
|
|
| 169 | + <dependency>
|
|
| 170 | + <groupId>${project.groupId}</groupId>
|
|
| 171 | + <artifactId>core-api-dto</artifactId>
|
|
| 172 | + <version>${project.version}</version>
|
|
| 173 | + </dependency>
|
|
| 174 | + <dependency>
|
|
| 175 | + <groupId>${project.groupId}</groupId>
|
|
| 176 | + <artifactId>core-api-dto-consolidation</artifactId>
|
|
| 177 | + <version>${project.version}</version>
|
|
| 178 | + </dependency>
|
|
| 179 | + <dependency>
|
|
| 180 | + <groupId>${project.groupId}</groupId>
|
|
| 181 | + <artifactId>core-api-dto-validation</artifactId>
|
|
| 182 | + <version>${project.version}</version>
|
|
| 183 | + </dependency>
|
|
| 184 | + <dependency>
|
|
| 185 | + <groupId>${project.groupId}</groupId>
|
|
| 186 | + <artifactId>toolkit-api</artifactId>
|
|
| 187 | + <version>${project.version}</version>
|
|
| 188 | + </dependency>
|
|
| 189 | + <dependency>
|
|
| 190 | + <groupId>${project.groupId}</groupId>
|
|
| 191 | + <artifactId>toolkit-api-services</artifactId>
|
|
| 192 | + <version>${project.version}</version>
|
|
| 193 | + </dependency>
|
|
| 194 | + <dependency>
|
|
| 195 | + <groupId>${project.groupId}</groupId>
|
|
| 196 | + <artifactId>toolkit-api-validation</artifactId>
|
|
| 197 | + <version>${project.version}</version>
|
|
| 198 | + </dependency>
|
|
| 199 | + </dependencies>
|
|
| 200 | + <executions>
|
|
| 201 | + <execution>
|
|
| 202 | + <goals>
|
|
| 203 | + <goal>check-services-types</goal>
|
|
| 204 | + </goals>
|
|
| 205 | + <configuration>
|
|
| 206 | + <acceptedTypes>
|
|
| 207 | + <acceptedType>io.ultreia.java4all.util.Version</acceptedType>
|
|
| 208 | + <acceptedType>java.lang.Class</acceptedType>
|
|
| 209 | + <acceptedType>java.lang.String</acceptedType>
|
|
| 210 | + <acceptedType>java.util.List</acceptedType>
|
|
| 211 | + <acceptedType>java.util.Set</acceptedType>
|
|
| 212 | + <acceptedType>java.util.Map</acceptedType>
|
|
| 213 | + <acceptedType>java.util.Date</acceptedType>
|
|
| 214 | + </acceptedTypes>
|
|
| 215 | + <acceptedAssignableTypes>
|
|
| 216 | + <acceptedAssignableType>io.ultreia.java4all.util.json.JsonAware</acceptedAssignableType>
|
|
| 217 | + </acceptedAssignableTypes>
|
|
| 218 | + </configuration>
|
|
| 219 | + </execution>
|
|
| 220 | + </executions>
|
|
| 221 | + </plugin>
|
|
| 222 | + </plugins>
|
|
| 164 | 223 | </build>
|
| 165 | 224 | </project> |
| ... | ... | @@ -37,7 +37,6 @@ import io.ultreia.java4all.util.sql.SqlScript; |
| 37 | 37 | import org.apache.logging.log4j.LogManager;
|
| 38 | 38 | import org.apache.logging.log4j.Logger;
|
| 39 | 39 | |
| 40 | -import java.io.File;
|
|
| 41 | 40 | import java.util.Date;
|
| 42 | 41 | import java.util.LinkedHashSet;
|
| 43 | 42 | import java.util.Objects;
|
| ... | ... | @@ -62,11 +61,6 @@ public class DataSourceServiceLocalSupport extends ObserveServiceLocal implement |
| 62 | 61 | });
|
| 63 | 62 | }
|
| 64 | 63 | |
| 65 | - @Override
|
|
| 66 | - public void backup(File backupFile) {
|
|
| 67 | - getTopiaApplicationContext().backup(backupFile, true);
|
|
| 68 | - }
|
|
| 69 | - |
|
| 70 | 64 | @Override
|
| 71 | 65 | public <D extends BusinessDto> boolean isIdValid(Class<D> type, String id) {
|
| 72 | 66 | DtoEntityContext<D, ?, ?, ?> spi = ObservePersistenceBusinessProject.fromDto(type);
|
| ... | ... | @@ -36,16 +36,4 @@ public class DataSourceServiceLocalReadTest extends GeneratedDataSourceServiceLo |
| 36 | 36 | fixtures.setTemporaryDirectory(null);
|
| 37 | 37 | }
|
| 38 | 38 | }
|
| 39 | - |
|
| 40 | - @Override
|
|
| 41 | - public void backup() {
|
|
| 42 | - fixtures.setTemporaryDirectory(localTestMethodResource.getTemporaryDirectoryRoot());
|
|
| 43 | - fixtures.setDataSourceConnection(localTestMethodResource.getDataSourceConnection());
|
|
| 44 | - try {
|
|
| 45 | - super.backup();
|
|
| 46 | - } finally {
|
|
| 47 | - fixtures.setTemporaryDirectory(null);
|
|
| 48 | - fixtures.setDataSourceConnection(null);
|
|
| 49 | - }
|
|
| 50 | - }
|
|
| 51 | 39 | } |
| ... | ... | @@ -94,11 +94,6 @@ |
| 94 | 94 | <artifactId>toolkit-api-validation</artifactId>
|
| 95 | 95 | <version>${project.version}</version>
|
| 96 | 96 | </dependency>
|
| 97 | - <dependency>
|
|
| 98 | - <groupId>${project.groupId}</groupId>
|
|
| 99 | - <artifactId>toolkit-persistence</artifactId>
|
|
| 100 | - <version>${project.version}</version>
|
|
| 101 | - </dependency>
|
|
| 102 | 97 | <dependency>
|
| 103 | 98 | <groupId>com.google.code.gson</groupId>
|
| 104 | 99 | <artifactId>gson</artifactId>
|
| ... | ... | @@ -38,7 +38,6 @@ import io.ultreia.java4all.util.Version; |
| 38 | 38 | import io.ultreia.java4all.util.sql.SqlScript;
|
| 39 | 39 | import org.junit.Assert;
|
| 40 | 40 | |
| 41 | -import java.io.File;
|
|
| 42 | 41 | import java.nio.file.Path;
|
| 43 | 42 | import java.util.Collections;
|
| 44 | 43 | import java.util.Set;
|
| ... | ... | @@ -56,23 +55,6 @@ public class DataSourceServiceFixtures extends GeneratedDataSourceServiceFixture |
| 56 | 55 | Assert.assertFalse(actual);
|
| 57 | 56 | }
|
| 58 | 57 | |
| 59 | - @Override
|
|
| 60 | - public void backup(ObserveServicesProvider servicesProvider, DataSourceService service) {
|
|
| 61 | - if (testDirectory == null && (dataSourceConnection == null || !dataSourceConnection.isLocal())) {
|
|
| 62 | - super.backup(servicesProvider, service);
|
|
| 63 | - return;
|
|
| 64 | - }
|
|
| 65 | - File backupFile = testDirectory.resolve("backup-" + System.nanoTime() + ".sql.gz").toFile();
|
|
| 66 | - Assert.assertFalse(backupFile.exists());
|
|
| 67 | - service.backup(backupFile);
|
|
| 68 | - Assert.assertTrue(backupFile.exists());
|
|
| 69 | - Version dbVersion = servicesProvider.getAnonymousService().getModelVersion();
|
|
| 70 | - ObserveDataSourceConfigurationTopiaH2 targetConfiguration = ObserveDataSourceConfigurationTopiaH2.createTemporaryConfiguration(testDirectory.toFile(), dbVersion);
|
|
| 71 | - try (ObserveTopiaApplicationContext topiaApplicationContext = ObserveTopiaApplicationContextFactory.createContext(targetConfiguration)) {
|
|
| 72 | - topiaApplicationContext.newJdbcHelperH2().restore(backupFile);
|
|
| 73 | - }
|
|
| 74 | - }
|
|
| 75 | - |
|
| 76 | 58 | @Override
|
| 77 | 59 | public void close(ObserveServicesProvider servicesProvider, DataSourceService service) {
|
| 78 | 60 | // FIXME:Test Remove super method invocation and implements fixture
|
| ... | ... | @@ -147,36 +129,36 @@ public class DataSourceServiceFixtures extends GeneratedDataSourceServiceFixture |
| 147 | 129 | protected void produceMoveSqlScript(DataSourceService service, boolean pg) {
|
| 148 | 130 | String psObsRouteVariable = getVariableName(fr.ird.observe.dto.data.ps.observation.RouteDto.class);
|
| 149 | 131 | String psObsRouteId = getVariable(psObsRouteVariable);
|
| 150 | - String psObsRouteIdTarget = getVariable(psObsRouteVariable+".move");
|
|
| 132 | + String psObsRouteIdTarget = getVariable(psObsRouteVariable + ".move");
|
|
| 151 | 133 | String psObsActivityVariable = getVariableName(fr.ird.observe.dto.data.ps.observation.ActivityDto.class);
|
| 152 | 134 | String psObsActivityId = getVariable(psObsActivityVariable);
|
| 153 | - String psObsActivityIdTarget = getVariable(psObsActivityVariable+".move");
|
|
| 135 | + String psObsActivityIdTarget = getVariable(psObsActivityVariable + ".move");
|
|
| 154 | 136 | String psObsSetId = getVariable(getVariableName(fr.ird.observe.dto.data.ps.observation.SetDto.class));
|
| 155 | 137 | |
| 156 | 138 | String psLogbookRouteVariable = getVariableName(fr.ird.observe.dto.data.ps.logbook.RouteDto.class);
|
| 157 | 139 | String psLogbookRouteId = getVariable(psLogbookRouteVariable);
|
| 158 | - String psLogbookRouteIdTarget = getVariable(psLogbookRouteVariable+".move");
|
|
| 140 | + String psLogbookRouteIdTarget = getVariable(psLogbookRouteVariable + ".move");
|
|
| 159 | 141 | String psLogbookActivityId = getVariable(getVariableName(fr.ird.observe.dto.data.ps.logbook.ActivityDto.class));
|
| 160 | 142 | |
| 161 | 143 | String llObsActivityVariable = getVariableName(fr.ird.observe.dto.data.ll.observation.ActivityDto.class);
|
| 162 | 144 | String llObsActivityId = getVariable(llObsActivityVariable);
|
| 163 | - String llObsActivityIdTarget = getVariable(llObsActivityVariable+".move");
|
|
| 145 | + String llObsActivityIdTarget = getVariable(llObsActivityVariable + ".move");
|
|
| 164 | 146 | |
| 165 | 147 | String llObSetId = getVariable(getVariableName(fr.ird.observe.dto.data.ll.observation.SetDto.class));
|
| 166 | 148 | |
| 167 | 149 | String llLogbookActivityVariable = getVariableName(fr.ird.observe.dto.data.ll.logbook.ActivityDto.class);
|
| 168 | 150 | String llLogbookActivityId = getVariable(llLogbookActivityVariable);
|
| 169 | - String llLogbookActivityIdTarget = getVariable(llLogbookActivityVariable+".move");
|
|
| 151 | + String llLogbookActivityIdTarget = getVariable(llLogbookActivityVariable + ".move");
|
|
| 170 | 152 | |
| 171 | 153 | String llLogbookSetId = getVariable(getVariableName(fr.ird.observe.dto.data.ll.logbook.SetDto.class));
|
| 172 | 154 | String psCommTripVariable = getVariableName(fr.ird.observe.dto.data.ps.common.TripDto.class);
|
| 173 | 155 | |
| 174 | 156 | String psCommonTripId = getVariable(psCommTripVariable);
|
| 175 | - String psCommonTripIdTarget = getVariable(psCommTripVariable +".move");
|
|
| 157 | + String psCommonTripIdTarget = getVariable(psCommTripVariable + ".move");
|
|
| 176 | 158 | |
| 177 | 159 | String llCommTripVariable = getVariableName(fr.ird.observe.dto.data.ll.common.TripDto.class);
|
| 178 | 160 | String llCommonTripId = getVariable(llCommTripVariable);
|
| 179 | - String llCommonTripIdTarget = getVariable(llCommTripVariable +".move");
|
|
| 161 | + String llCommonTripIdTarget = getVariable(llCommTripVariable + ".move");
|
|
| 180 | 162 | |
| 181 | 163 | testRequest(service, new ReplicateRequest(pg, psCommonTripId, psCommonTripIdTarget, "fr.ird.observe.entities.data.ps.observation.Route", psObsRouteId));
|
| 182 | 164 | |
| ... | ... | @@ -225,11 +207,11 @@ public class DataSourceServiceFixtures extends GeneratedDataSourceServiceFixture |
| 225 | 207 | this.testDirectory = testDirectory;
|
| 226 | 208 | }
|
| 227 | 209 | |
| 228 | - public void setDataSourceConnection(ObserveDataSourceConnection dataSourceConnection) {
|
|
| 229 | - this.dataSourceConnection = dataSourceConnection;
|
|
| 230 | - }
|
|
| 231 | - |
|
| 232 | 210 | public ObserveDataSourceConnection getDataSourceConnection() {
|
| 233 | 211 | return dataSourceConnection;
|
| 234 | 212 | }
|
| 213 | + |
|
| 214 | + public void setDataSourceConnection(ObserveDataSourceConnection dataSourceConnection) {
|
|
| 215 | + this.dataSourceConnection = dataSourceConnection;
|
|
| 216 | + }
|
|
| 235 | 217 | } |
| ... | ... | @@ -23,7 +23,7 @@ |
| 23 | 23 | <parent>
|
| 24 | 24 | <groupId>io.ultreia.maven</groupId>
|
| 25 | 25 | <artifactId>pom</artifactId>
|
| 26 | - <version>2024.01</version>
|
|
| 26 | + <version>2024.03</version>
|
|
| 27 | 27 | </parent>
|
| 28 | 28 | <groupId>fr.ird.observe</groupId>
|
| 29 | 29 | <artifactId>ird-observe</artifactId>
|
| ... | ... | @@ -29,7 +29,6 @@ GET /AnonymousService/getServerVersion Anon |
| 29 | 29 | GET /AnonymousService/getUsers AnonymousServiceRestApi.getUsers
|
| 30 | 30 | GET /AnonymousService/migrateData AnonymousServiceRestApi.migrateData
|
| 31 | 31 | GET /AnonymousService/open AnonymousServiceRestApi.open
|
| 32 | -GET /DataSourceService/backup DataSourceServiceRestApi.backup
|
|
| 33 | 32 | GET /DataSourceService/close DataSourceServiceRestApi.close
|
| 34 | 33 | POST /DataSourceService/executeSqlScript DataSourceServiceRestApi.executeSqlScript
|
| 35 | 34 | GET /DataSourceService/getLastUpdateDate DataSourceServiceRestApi.getLastUpdateDate
|
| ... | ... | @@ -28,7 +28,6 @@ import fr.ird.observe.server.security.ObserveWebUserSession; |
| 28 | 28 | import org.apache.logging.log4j.LogManager;
|
| 29 | 29 | import org.apache.logging.log4j.Logger;
|
| 30 | 30 | |
| 31 | -import java.io.File;
|
|
| 32 | 31 | import java.util.LinkedHashMap;
|
| 33 | 32 | import java.util.Map;
|
| 34 | 33 | |
| ... | ... | @@ -57,8 +56,4 @@ public class DataSourceServiceRestApi extends GeneratedDataSourceServiceRestApi |
| 57 | 56 | result.put("credentials", session.getConnection().getDataSourceInformation().getCredentials());
|
| 58 | 57 | return result;
|
| 59 | 58 | }
|
| 60 | - |
|
| 61 | - @Override
|
|
| 62 | - public void backup(File backupFile) {
|
|
| 63 | - }
|
|
| 64 | 59 | } |
| ... | ... | @@ -122,5 +122,54 @@ |
| 122 | 122 | </plugin>
|
| 123 | 123 | </plugins>
|
| 124 | 124 | </pluginManagement>
|
| 125 | + <plugins>
|
|
| 126 | + <plugin>
|
|
| 127 | + <groupId>io.ultreia.java4all.http</groupId>
|
|
| 128 | + <artifactId>http-maven-plugin</artifactId>
|
|
| 129 | + <dependencies>
|
|
| 130 | + <dependency>
|
|
| 131 | + <groupId>${project.groupId}</groupId>
|
|
| 132 | + <artifactId>toolkit-api</artifactId>
|
|
| 133 | + <version>${project.version}</version>
|
|
| 134 | + </dependency>
|
|
| 135 | + <dependency>
|
|
| 136 | + <groupId>${project.groupId}</groupId>
|
|
| 137 | + <artifactId>toolkit-api-datasource</artifactId>
|
|
| 138 | + <version>${project.version}</version>
|
|
| 139 | + </dependency>
|
|
| 140 | + <dependency>
|
|
| 141 | + <groupId>${project.groupId}</groupId>
|
|
| 142 | + <artifactId>toolkit-api-decoration</artifactId>
|
|
| 143 | + <version>${project.version}</version>
|
|
| 144 | + </dependency>
|
|
| 145 | + <dependency>
|
|
| 146 | + <groupId>${project.groupId}</groupId>
|
|
| 147 | + <artifactId>toolkit-api-report</artifactId>
|
|
| 148 | + <version>${project.version}</version>
|
|
| 149 | + </dependency>
|
|
| 150 | + </dependencies>
|
|
| 151 | + <executions>
|
|
| 152 | + <execution>
|
|
| 153 | + <goals>
|
|
| 154 | + <goal>check-services-types</goal>
|
|
| 155 | + </goals>
|
|
| 156 | + <configuration>
|
|
| 157 | + <acceptedTypes>
|
|
| 158 | + <acceptedType>io.ultreia.java4all.util.Version</acceptedType>
|
|
| 159 | + <acceptedType>java.lang.Class</acceptedType>
|
|
| 160 | + <acceptedType>java.lang.String</acceptedType>
|
|
| 161 | + <acceptedType>java.util.List</acceptedType>
|
|
| 162 | + <acceptedType>java.util.Set</acceptedType>
|
|
| 163 | + <acceptedType>java.util.Map</acceptedType>
|
|
| 164 | + <acceptedType>java.util.Date</acceptedType>
|
|
| 165 | + </acceptedTypes>
|
|
| 166 | + <acceptedAssignableTypes>
|
|
| 167 | + <acceptedAssignableType>io.ultreia.java4all.util.json.JsonAware</acceptedAssignableType>
|
|
| 168 | + </acceptedAssignableTypes>
|
|
| 169 | + </configuration>
|
|
| 170 | + </execution>
|
|
| 171 | + </executions>
|
|
| 172 | + </plugin>
|
|
| 173 | + </plugins>
|
|
| 125 | 174 | </build>
|
| 126 | 175 | </project> |
| ... | ... | @@ -34,7 +34,6 @@ import io.ultreia.java4all.http.spi.Service; |
| 34 | 34 | import io.ultreia.java4all.http.spi.Write;
|
| 35 | 35 | import io.ultreia.java4all.util.sql.SqlScript;
|
| 36 | 36 | |
| 37 | -import java.io.File;
|
|
| 38 | 37 | import java.util.Date;
|
| 39 | 38 | import java.util.Set;
|
| 40 | 39 | |
| ... | ... | @@ -49,9 +48,6 @@ public interface DataSourceService extends ObserveService { |
| 49 | 48 | @Get
|
| 50 | 49 | void close();
|
| 51 | 50 | |
| 52 | - @Get
|
|
| 53 | - void backup(File backupFile);
|
|
| 54 | - |
|
| 55 | 51 | @Get
|
| 56 | 52 | @MethodCredential
|
| 57 | 53 | <D extends BusinessDto> boolean isIdValid(Class<D> type, String id);
|
| ... | ... | @@ -22,6 +22,8 @@ package fr.ird.observe.navigation.tree.io; |
| 22 | 22 | * #L%
|
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | +import io.ultreia.java4all.util.json.JsonAware;
|
|
| 26 | + |
|
| 25 | 27 | import java.util.LinkedHashMap;
|
| 26 | 28 | import java.util.Map;
|
| 27 | 29 | import java.util.Objects;
|
| ... | ... | @@ -37,7 +39,7 @@ import java.util.stream.Stream; |
| 37 | 39 | * @author Tony Chemit - dev@tchemit.fr
|
| 38 | 40 | * @since 5.0.17
|
| 39 | 41 | */
|
| 40 | -public class ToolkitTreeNodeStates {
|
|
| 42 | +public class ToolkitTreeNodeStates implements JsonAware {
|
|
| 41 | 43 | |
| 42 | 44 | private final Map<String, Object> states = new LinkedHashMap<>();
|
| 43 | 45 |
| ... | ... | @@ -40,7 +40,6 @@ import org.nuiton.topia.service.sql.TopiaSqlService; |
| 40 | 40 | import org.nuiton.topia.service.sql.blob.TopiaEntitySqlBlobIdsIterator;
|
| 41 | 41 | |
| 42 | 42 | import java.io.Closeable;
|
| 43 | -import java.io.File;
|
|
| 44 | 43 | import java.nio.file.Path;
|
| 45 | 44 | import java.util.ArrayList;
|
| 46 | 45 | import java.util.List;
|
| ... | ... | @@ -121,8 +120,6 @@ public interface TopiaApplicationContext<K extends TopiaPersistenceContext> exte |
| 121 | 120 | getMigrationService().runSchemaMigration();
|
| 122 | 121 | }
|
| 123 | 122 | |
| 124 | - void backup(File backupFile, boolean compress);
|
|
| 125 | - |
|
| 126 | 123 | /**
|
| 127 | 124 | * Get the list of entities (ToPIA or not) that Hibernate has to handle. By default it only contains ToPIA entities
|
| 128 | 125 | * but you may override it to add any other Hibernate entity.
|
| ... | ... | @@ -53,7 +53,6 @@ import org.nuiton.topia.service.migration.TopiaMigrationService; |
| 53 | 53 | import org.nuiton.topia.service.sql.TopiaSqlService;
|
| 54 | 54 | import org.nuiton.topia.service.sql.blob.TopiaEntitySqlBlobIdsIterator;
|
| 55 | 55 | |
| 56 | -import java.io.File;
|
|
| 57 | 56 | import java.nio.file.Path;
|
| 58 | 57 | import java.util.Arrays;
|
| 59 | 58 | import java.util.LinkedHashSet;
|
| ... | ... | @@ -248,17 +247,6 @@ public abstract class AbstractTopiaApplicationContext<K extends TopiaPersistence |
| 248 | 247 | return Objects.hash(authenticationToken);
|
| 249 | 248 | }
|
| 250 | 249 | |
| 251 | - @Override
|
|
| 252 | - public final void backup(File backupFile, boolean compress) {
|
|
| 253 | - if (!getConfiguration().isH2Configuration()) {
|
|
| 254 | - throw new IllegalStateException("Cant backup a none H2 database.");
|
|
| 255 | - }
|
|
| 256 | - try (K p = newPersistenceContext()) {
|
|
| 257 | - String sqlScript = String.format("SCRIPT NOPASSWORDS NOSETTINGS BLOCKSIZE 2048 TO '%s' %s CHARSET 'UTF-8';", backupFile.getAbsolutePath(), compress ? "COMPRESSION GZIP" : "");
|
|
| 258 | - p.getSqlSupport().executeSql(sqlScript);
|
|
| 259 | - }
|
|
| 260 | - }
|
|
| 261 | - |
|
| 262 | 250 | @Override
|
| 263 | 251 | public final void executeSqlStatements(SqlScript content) {
|
| 264 | 252 | try {
|
| ... | ... | @@ -78,7 +78,7 @@ public class JdbcHelperH2 extends JdbcHelper { |
| 78 | 78 | * @param compress if true then use gzip to compress file
|
| 79 | 79 | */
|
| 80 | 80 | public void backup(File file, boolean compress) {
|
| 81 | - String options = "";
|
|
| 81 | + String options = " BLOCKSIZE 2048 CHARSET 'UTF-8'";
|
|
| 82 | 82 | if (compress) {
|
| 83 | 83 | options += " COMPRESSION GZIP";
|
| 84 | 84 | }
|
| ... | ... | @@ -100,7 +100,7 @@ public class MigrateTckDatabases extends PersistenceRunner { |
| 100 | 100 | |
| 101 | 101 | applicationContext.executeSqlStatements(SqlScript.of(backupFile));
|
| 102 | 102 | Path checkBackupFile = getTemporaryPath().resolve("check-backup-" + backupFile.toFile().getName().replace(".sql.gz", "-check.sql"));
|
| 103 | - applicationContext.backup(checkBackupFile.toFile(), false);
|
|
| 103 | + applicationContext.newJdbcHelperH2().backup(checkBackupFile.toFile(), false);
|
|
| 104 | 104 | log.info(String.format("[%S] Check - backup to %s", tckDbName, checkBackupFile));
|
| 105 | 105 | }
|
| 106 | 106 | }
|