Commit e876a14a authored by PECQUOT's avatar PECQUOT

[enh] Change import/export file type for contexts and filters for better...

[enh] Change import/export file type for contexts and filters for better compatibility and file size (Mantis #43800)
[add] ReefDb-Converter : separated module for converting contexts/filters file from old version of Dali to new file type (Mantis #48940)
Signed-off-by: PECQUOT's avatarlp1ee9d <ludovic.pecquot@e-is.pro>
parent 352b4e20
## Sprint 78 - v3.7.5
- Pas de mise à jour de modèle
- Ajout d'un module séparé `reefdb-converter` pour convertir les fichiers de contextes et filtres provenant d'une version ancienne de ReefDb (ex: 3.6.2) pour les rendre compatibles avec la version 3.7.5
## Sprint 77 - v3.7.4
- Aucune mise à jour de base de données
......
......@@ -171,7 +171,7 @@
<maven.compiler.debug>true</maven.compiler.debug>
<!-- Quadrige3 Core version -->
<quadrige3-core.version>3.5.5</quadrige3-core.version>
<quadrige3-core.version>3.5.6</quadrige3-core.version>
<!-- Last ReefDb launcher version -->
<launcherVersion>3.0.3</launcherVersion>
......
This diff is collapsed.
${project.name} Help
-
Command line usage :
To show help (list all options) :
> launch.bat -h
Convert an old version of context file (including filters) to new version :
> launch.bat --convert-context <context_file.dat>
Convert an old version of filter file to new version :
> launch.bat --convert-filter <filter_file.dat>
Note: the file path can be absolute or relative to the current directory
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.ifremer.common</groupId>
<artifactId>common-parent</artifactId>
<version>3.0.6</version>
</parent>
<groupId>fr.ifremer.reefdb</groupId>
<artifactId>reefdb-converter</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>Reef DB :: Converter</name>
<url>http://doc.e-is.pro/reefdb</url>
<inceptionYear>2019</inceptionYear>
<organization>
<name>Ifremer</name>
<url>http://www.ifremer.fr</url>
</organization>
<licenses>
<license>
<name>Affero General Public License (AGPL)</name>
<url>http://www.gnu.org/licenses/agpl.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>lp1ee9d</id>
<name>Ludovic Pecquot</name>
<email>ludovic.pecquot at e-is dot pro</email>
<organization>EIS</organization>
<organizationUrl>http://www.e-is.pro</organizationUrl>
<roles>
<role>developer</role>
</roles>
<timezone>Europe/Paris</timezone>
</developer>
</developers>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<platform>ifremer.fr</platform>
<projectId>${project.artifactId}</projectId>
<ciViewId>${project.artifactId}</ciViewId>
<javaVersion>1.8</javaVersion>
<signatureArtifactId>java18</signatureArtifactId>
<signatureVersion>1.0</signatureVersion>
<!-- bundle configuration -->
<bundlePrefix>${project.artifactId}-${project.version}</bundlePrefix>
<maven.jar.main.class>
fr.ifremer.reefdb.converter.ConverterMain
</maven.jar.main.class>
<!-- Connexion using port redirection - https://domicile.ifremer.fr -->
<distribution.site.host>127.0.0.1:4022</distribution.site.host>
<distribution.repository.id>ifremer-public-repository</distribution.repository.id>
<distribution.repository.url>scp://${distribution.site.host}/home/wwwinter/www/htdocs/maven/repository</distribution.repository.url>
<distribution.snapshotRepository.id>ifremer-public-snapshots</distribution.snapshotRepository.id>
<distribution.snapshotRepository.url>scp://${distribution.site.host}/home/wwwinter/www/htdocs/maven/snapshots</distribution.snapshotRepository.url>
<distribution.internet.url>http://www.ifremer.fr/maven/repository</distribution.internet.url>
</properties>
<repositories>
<repository>
<id>reefdb-public-group</id>
<url>http://nexus.e-is.pro/nexus/content/groups/reefdb</url>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<releases>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>reefdb-public-group</id>
<url>http://nexus.e-is.pro/nexus/content/groups/reefdb</url>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<releases>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
</releases>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>fr.ifremer.reefdb</groupId>
<artifactId>reefdb-core</artifactId>
<version>3.6.2</version>
</dependency>
<dependency>
<groupId>fr.ifremer.quadrige3</groupId>
<artifactId>quadrige3-core-shared</artifactId>
<version>3.3.6</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>22.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.1</version>
</dependency>
<dependency>
<groupId>org.swinglabs.swingx</groupId>
<artifactId>swingx-common</artifactId>
<version>1.6.5-1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.9.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<excludedArtifacts>reefdb-core</excludedArtifacts>
<includeTransitiveDependencies>false</includeTransitiveDependencies>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<useUniqueVersions>false</useUniqueVersions>
<addClasspath>true</addClasspath>
<classpathPrefix>./lib/</classpathPrefix>
<mainClass>${maven.jar.main.class}</mainClass>
</manifest>
<manifestEntries>
<url>${project.url}</url>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>default-bundle</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<defaultGoal>package</defaultGoal>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<goals>
<goal>copy-dependencies</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<includeScope>compile</includeScope>
<excludeTransitive>true</excludeTransitive>
<excludeScope>test</excludeScope>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<silent>true</silent>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>assembly-standalone</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<attach>true</attach>
<finalName>${bundlePrefix}</finalName>
<descriptors>
<descriptor>
src/main/assembly/standalone.xml
</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>eis-deploy</id>
<properties>
<distribution.repository.id>eis-nexus-deploy</distribution.repository.id>
<distribution.repository.url>http://nexus.e-is.pro/nexus/content/repositories/reefdb-releases</distribution.repository.url>
<distribution.snapshotRepository.id>eis-nexus-deploy</distribution.snapshotRepository.id>
<distribution.snapshotRepository.url>http://nexus.e-is.pro/nexus/content/repositories/reefdb-snapshots</distribution.snapshotRepository.url>
<distribution.internet.url>http://nexus.e-is.pro/nexus/content/groups/public</distribution.internet.url>
</properties>
</profile>
</profiles>
</project>
README
${project.name} Help
------------------------------------
Command line usage :
To show help (list all options) :
> launch.bat -h
Convert an old version of context file (including filters) to new version :
> launch.bat --convert-context <context_file.dat>
Convert an old version of filter file to new version :
> launch.bat --convert-filter <filter_file.dat>
Note: the file path can be absolute or relative to the current directory
\ No newline at end of file
@echo off
REM Comment out this line to specify your JAVA path:
REM SET JAVA_HOME=<path_to_java>
set OLDDIR=%CD%
cd /d %~dp0%
set APP_BASEDIR=%CD%
set JAVA_COMMAND=%JAVA_HOME%\bin\java
set JAVA_OPTS=-Xmx1024M
rem Comment out if oracle connection need TNS_ADMIN file:
rem set JAVA_OPTS=%JAVA_OPTS% -Doracle.net.tns_admin=\\brest\tnsnames
if not exist "%JAVA_HOME%" goto :no_java
echo ===============================================================================
echo .
echo ${project.name}
echo .
echo JAVA: %JAVA_COMMAND%
echo .
echo JAVA_OPTS: %JAVA_OPTS%
echo .
echo ===============================================================================
echo .
call "%JAVA_COMMAND%" %JAVA_OPTS% -jar ${project.build.finalName}.${project.packaging} %1 %2 %3 %4 %5 %6 %7 %8 %9
set exitcode=%ERRORLEVEL%
echo Stop with exitcode: %exitcode%
cd %OLDDIR%
exit /b %exitcode%
goto :end
:no_java
echo "Java not detected ! Please set environment variable JAVA_HOME before launching,"
echo "or edit the file 'launch.bat' and insert this line :"
echo " SET JAVA_HOME=<path_to_java>"
:end
#!/bin/bash
#Comment out this line to specify your JAVA path:
#export JAVA_HOME=/etc/jre...
export APP_BASEDIR=$(pwd)
export JAVA_COMMAND=$JAVA_HOME/bin/java
cd $APP_BASEDIR
if [ -d $JAVA_HOME ]; then
echo "${project.name}"
echo " basedir: $APP_BASEDIR"
echo " jre home: $JAVA_HOME"
MEMORY="-Xmx1024M"
#APP_JVM_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000"
REP=$(dirname $0)
cd $REP
echo "launch java"
echo "java command: $JAVA_COMMAND"
$JAVA_COMMAND $MEMORY $APP_JVM_OPTS -jar ${project.build.finalName}.${project.packaging} $*
exitcode=$?
echo "Stop ${project.name} with exitcode: $exitcode"
exit $exitcode
else
echo "Java not detected ! Please set environment variable JAVA_HOME before launching,"
echo "or edit the file 'launch.sh' and insert this line :"
echo " export JAVA_HOME=<path_to_java>"
fi
${project.version}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
Reef DB :: Converter
%%
Copyright (C) 2019 Ifremer
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero 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 Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
-->
<assembly
xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>standalone</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>target</directory>
<outputDirectory/>
<includes>
<include>${project.build.finalName}.${project.packaging}</include>
</includes>
</fileSet>
<fileSet>
<directory>target/lib</directory>
<outputDirectory>lib</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
<excludes>
<exclude>junit-*.jar</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>src/main/assembly/min</directory>
<outputDirectory/>
<filtered>true</filtered>
<fileMode>0755</fileMode>
<includes>
<include>launch.sh</include>
<include>launch.bat</include>
<include>version.appup</include>
<include>README*</include>
</includes>
</fileSet>
<fileSet>
<includes>
<include>LICENSE*</include>
</includes>
</fileSet>
</fileSets>
</assembly>
package fr.ifremer.reefdb.converter;
/*-
* #%L
* Reef DB :: Converter
* %%
* Copyright (C) 2019 Ifremer
* %%
* This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero 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 Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
import fr.ifremer.reefdb.converter.context.ContextConverter;
import fr.ifremer.reefdb.converter.context.FilterConverter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.MessageFormat;
import java.util.*;
/**
* Launcher application that do post-update logic, launch application and listen to exit code
*
* @author Ludovic Pecquot <ludovic.pecquot@e-is.pro>
*/
public class ConverterMain {
private static ResourceBundle bundle;
private static Path baseDir;
/**
* <p>main.</p>
*
* @param args the command line arguments
*/
public static void main(String[] args) {
List<String> arguments = new ArrayList<>();
if (args != null) {
arguments.addAll(Arrays.asList(args));
}
// Get the resource bundle
initBundle();
System.out.println(getString("converter.title"));
// Get base dir (from where the exe file is launched)
baseDir = Paths.get(System.getProperty("user.dir"));
ConverterMain converterMain = new ConverterMain();
converterMain.execute(arguments);
}
/**
* <p>execute.</p>
*
* @param arguments a {@link java.util.List} object.
*/
private void execute(List<String> arguments) {
if (arguments.isEmpty() || arguments.contains("/?") || arguments.contains("-?") || arguments.contains("/h") || arguments.contains("-h")) {
System.out.println(getString("converter.help"));
System.exit(0);
}
String command = arguments.remove(0);
Runnable action = null;
switch (command) {
case ContextConverter.COMMAND:
action = new ContextConverter(arguments);
break;
case FilterConverter.COMMAND:
action = new FilterConverter(arguments);
break;
}
if (action == null) {
System.err.println("unknown command " + command);
System.exit(1);
}
action.run();
}
private static void initBundle() {
if (bundle == null)
bundle = ResourceBundle.getBundle("i18n/converter", new UTF8Control());
}
public static String getString(String resourceName, Object... params) {
initBundle();
return MessageFormat.format(bundle.getString(resourceName), params);
}
public static Path getBaseDir() {
return baseDir;
}
private static class UTF8Control extends ResourceBundle.Control {
@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IOException {
// The below is a copy of the default implementation.
String bundleName = toBundleName(baseName, locale);
String resourceName = toResourceName(bundleName, "properties");
ResourceBundle bundle = null;
InputStream stream = null;
if (reload) {
URL url = loader.getResource(resourceName);
if (url != null) {
URLConnection connection = url.openConnection();
if (connection != null) {
connection.setUseCaches(false);
stream = connection.getInputStream();
}
}
} else {
stream = loader.getResourceAsStream(resourceName);
}
if (stream != null) {
try {
// Only this line is changed to make it to read properties files as UTF-8.
bundle = new PropertyResourceBundle(new InputStreamReader(stream, StandardCharsets.UTF_8));
} finally {
stream.close();
}
}
return bundle;
}
}
}
package fr.ifremer.reefdb.converter.context;
/*-
* #%L
* Reef DB :: Converter
* %%
* Copyright (C) 2019 Ifremer
* %%
* This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero 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 Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
import fr.ifremer.reefdb.converter.ConverterMain;
import fr.ifremer.reefdb.dto.CodeOnly;
import fr.ifremer.reefdb.dto.ReefDbBean;
import fr.ifremer.reefdb.dto.configuration.context.ContextDTO;
import fr.ifremer.reefdb.dto.configuration.filter.FilterDTO;
import org.apache.commons.collections4.CollectionUtils;
import java.io.Serializable;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author peck7 on 19/09/2019.
*/
public abstract class AbstractContextConverter<E extends Serializable> implements Runnable {
private final List<String> options;
AbstractContextConverter(List<String> options) {
this.options = options;