Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3 Commits: 3e1ae6d6 by Tony CHEMIT at 2018-02-22T22:04:44+01:00 [N0.3] Rendre la conversion des catégories de poids AVDTH->T3 générique (Mise en place de la persistence) (See #244) - - - - - 4f2c864f by Tony CHEMIT at 2018-02-23T03:28:15+01:00 Ajouter un nouveau package avec des bases h2 (vide et avec le référentiel) (closes #285) - - - - - 25 changed files: - + .mvn/deploy - pom.xml - + t3-domain/.mvn/deploy - t3-domain/pom.xml - t3-domain/src/main/java/fr/ird/t3/entities/T3JdbcHelper.java - t3-domain/src/main/java/fr/ird/t3/entities/T3TopiaApplicationContext.java - t3-domain/src/main/java/fr/ird/t3/entities/conversion/AbstractWeightCategoryLogBookConvertor.java - t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertor.java - t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OABI.java - t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OIBI.java - t3-domain/src/main/java/fr/ird/t3/entities/reference/LengthWeightConversionImpl.java - + t3-domain/src/main/java/fr/ird/t3/entities/reference/WeightCategoryLogBookConversionImpl.java - + t3-domain/src/main/java/fr/ird/t3/entities/reference/WeightCategoryLogBookConversionSpeciesImpl.java - t3-domain/src/main/java/fr/ird/t3/services/migration/T3MigrationCallbackV2_1.java - + t3-domain/src/main/resources/db/migration/V2_1_10_add-WeightCategoryLogBookConversion-table.sql - + t3-domain/src/main/resources/db/migration/V2_1_11_fill-WeightCategoryLogBookConversion-table.sql - t3-domain/src/main/resources/t3-datadb.properties - t3-domain/src/main/xmi/t3-persistence.properties - t3-domain/src/main/xmi/t3-persistence.zargo - t3-domain/src/test/java/fr/ird/t3/services/migration/T3MigrationTest.java - t3-installer/pom.xml - t3-installer/src/main/assembly/bin.xml - t3-test/src/main/java/fr/ird/t3/FakeT3ServiceContext.java - t3-test/src/main/resources/t3-TopiaContextImpl.properties - + t3/.mvn/deploy Changes: ===================================== .mvn/deploy ===================================== --- /dev/null +++ b/.mvn/deploy ===================================== pom.xml ===================================== --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>io.ultreia.maven</groupId> <artifactId>pom</artifactId> - <version>2018.20</version> + <version>2018.21</version> </parent> <groupId>fr.ird.t3</groupId> @@ -132,9 +132,6 @@ <gitlab.changesAuthorEmail>dev@tchemit.fr</gitlab.changesAuthorEmail> <gitlab.trackers>Anomalie,Evolution,Tâche</gitlab.trackers> - <!-- deploy nothing --> - <maven.deploy.skip>true</maven.deploy.skip> - </properties> <dependencyManagement> @@ -461,7 +458,7 @@ <artifactId>wagon-maven-plugin</artifactId> <executions> <execution> - <id>get-referential-files</id> + <id>get-h2-files</id> <phase>test-compile</phase> <goals> <goal>download-single</goal> @@ -469,7 +466,7 @@ <configuration> <serverId>doc.ultreia.io</serverId> <url>scpexe://ultreia.io/var/www/t3/private</url> - <fromFile>t3-data-${t3-data.version}-referential.zip</fromFile> + <fromFile>t3-data-${t3-data.version}-h2.zip</fromFile> <toDir>${project.build.directory}</toDir> </configuration> </execution> ===================================== t3-domain/.mvn/deploy ===================================== --- /dev/null +++ b/t3-domain/.mvn/deploy ===================================== t3-domain/pom.xml ===================================== --- a/t3-domain/pom.xml +++ b/t3-domain/pom.xml @@ -37,6 +37,11 @@ <config.generatePropertyChangeSupport>true</config.generatePropertyChangeSupport> <config.packageName>fr.ird.t3</config.packageName> <config.useNuitonI18n>true</config.useNuitonI18n> + + <maven.deploy.skip>false</maven.deploy.skip> + <maven.javadoc.skip>false</maven.javadoc.skip> + <maven.source.skip>false</maven.source.skip> + <maven.javadoc.failOnError>false</maven.javadoc.failOnError> </properties> <dependencies> @@ -107,6 +112,10 @@ <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </dependency> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + </dependency> <dependency> <groupId>com.google.auto.service</groupId> ===================================== t3-domain/src/main/java/fr/ird/t3/entities/T3JdbcHelper.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/T3JdbcHelper.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/T3JdbcHelper.java @@ -21,6 +21,17 @@ package fr.ird.t3.entities; * #L% */ +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.topia.persistence.jdbc.JdbcConfiguration; +import org.nuiton.topia.persistence.jdbc.JdbcHelper; +import org.nuiton.util.ZipUtil; +import org.nuiton.util.sql.SqlFileReader; +import org.nuiton.version.Version; + import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -29,12 +40,12 @@ import java.io.InputStreamReader; import java.io.Reader; import java.nio.charset.StandardCharsets; import java.nio.file.Files; +import java.nio.file.Paths; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; -import org.nuiton.topia.persistence.jdbc.JdbcConfiguration; -import org.nuiton.topia.persistence.jdbc.JdbcHelper; -import org.nuiton.util.sql.SqlFileReader; +import java.util.Collections; +import java.util.List; /** * Created by tchemit on 03/04/17. @@ -43,7 +54,9 @@ import org.nuiton.util.sql.SqlFileReader; */ public class T3JdbcHelper extends JdbcHelper { - public static final int BUZZER_SIZE = 100; + private static final Log log = LogFactory.getLog(T3JdbcHelper.class); + + private static final int BUZZER_SIZE = 100; T3JdbcHelper(JdbcConfiguration jdbcConfiguration) { super(jdbcConfiguration); @@ -120,4 +133,49 @@ public class T3JdbcHelper extends JdbcHelper { runSelectOnString("SCRIPT TO '" + file.getAbsolutePath() + "'" + options); } + public static File getScriptsDirectory(File buildRootDirectory, String classifier, Version version) throws IOException { + + File scriptsZip = Paths.get(buildRootDirectory.getAbsolutePath()) + .resolve("target") + .resolve(String.format("t3-data-%s-%s.zip", version, classifier)) + .toFile(); + ZipUtil.uncompress(scriptsZip, scriptsZip.getParentFile()); + + File target = Paths.get(buildRootDirectory.getAbsolutePath()) + .resolve("target") + .resolve(String.format("t3-data-%s-%s", classifier, version)) + .toFile(); + Preconditions.checkState(target.exists(), "Could not find script directory: " + target); + if (log.isInfoEnabled()) { + log.info(String.format("Scripts directory: %s", target)); + } + return target; + } + + public static void importReferential(File buildRootDirectory, Version t3DataVersion, T3JdbcHelper jdbcH2Helper) throws IOException { + + File scriptsDirectory = getScriptsDirectory(buildRootDirectory, "referential", t3DataVersion); + + String[] list = scriptsDirectory.list((dir, name) -> name.endsWith(".sql")); + ImmutableSet.Builder<File> filesBuilder = ImmutableSet.builder(); + if (list != null) { + List<String> scriptsName = Lists.newArrayList(list); + Collections.sort(scriptsName); + for (String ddlScriptName : scriptsName) { + filesBuilder.add(new File(scriptsDirectory, ddlScriptName)); + } + } + ImmutableSet<File> scriptsFile = filesBuilder.build(); + + if (log.isInfoEnabled()) { + log.info("Will load referentiel in h2 database "); + } + + for (File file : scriptsFile) { + if (log.isInfoEnabled()) { + log.info(" o Loading sql script ...(" + file.getName() + ")"); + } + jdbcH2Helper.executeSql(file); + } + } } ===================================== t3-domain/src/main/java/fr/ird/t3/entities/T3TopiaApplicationContext.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/T3TopiaApplicationContext.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/T3TopiaApplicationContext.java @@ -24,12 +24,8 @@ package fr.ird.t3.entities; import com.google.common.base.Charsets; import fr.ird.t3.T3IOUtil; import fr.ird.t3.entities.user.JdbcConfiguration; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.util.Properties; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.nuiton.topia.persistence.BeanTopiaConfiguration; import org.nuiton.topia.persistence.HibernateAvailableSettings; import org.nuiton.topia.persistence.TopiaConfiguration; @@ -37,11 +33,19 @@ import org.nuiton.topia.persistence.TopiaConfigurationBuilder; import org.nuiton.topia.persistence.TopiaException; import org.nuiton.util.RecursiveProperties; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.Objects; +import java.util.Properties; + public class T3TopiaApplicationContext extends AbstractT3TopiaApplicationContext { private static final String T3_EMBEDDED_DB_PROPERTIES = "/t3-TopiaContextImpl.properties"; - private static final String T3_USER_DB_PROPERTIES = "/t3-datadb.properties"; + private static final Log log = LogFactory.getLog(T3TopiaApplicationContext.class); /** * Open a new topia root context from the given jdbc configuration. @@ -81,8 +85,7 @@ public class T3TopiaApplicationContext extends AbstractT3TopiaApplicationContext /** - * Open a new topia root context for the user t3 db using a embedded db ( - * this should be a h2 db). + * Open a new topia root context for the user t3 db using a embedded db (this should be a h2 db). * <p/> * This is mainly used by tests. * @@ -107,6 +110,35 @@ public class T3TopiaApplicationContext extends AbstractT3TopiaApplicationContext return new T3TopiaApplicationContext(topiaConfiguration); } + /** + * Open a new topia root context for the user t3 db using a embedded db (this should be a h2 db). + * <p/> + * This is mainly used by tests. + * + * @param dbLocation file where to store the db. + * @param backupFile backup file to load in db + * @return the new fresh root context of the db + */ + public static T3TopiaApplicationContext newEmbeddedBackupDb(File dbLocation, File backupFile) { + + Properties configuration = new Properties(); + + try (InputStream stream = T3TopiaApplicationContext.class.getResourceAsStream(T3_EMBEDDED_DB_PROPERTIES)) { + configuration.load(stream); + } catch (IOException e) { + throw new TopiaException("Could not load input file " + T3_EMBEDDED_DB_PROPERTIES, e); + } + + configuration.put(HibernateAvailableSettings.URL, "jdbc:h2:file:" + dbLocation); + BeanTopiaConfiguration topiaConfiguration = new TopiaConfigurationBuilder().readProperties(configuration); + topiaConfiguration.setValidateSchema(false); + topiaConfiguration.setInitSchema(false); + T3TopiaApplicationContext topiaApplicationContext = new T3TopiaApplicationContext(topiaConfiguration); + log.info("Laoding database from a backup: " + backupFile); + topiaApplicationContext.newJdbcHelper().executeSql(Objects.requireNonNull(backupFile)); + return topiaApplicationContext; + } + public T3JdbcHelper newJdbcHelper() { return new T3JdbcHelper(getConfiguration()); } ===================================== t3-domain/src/main/java/fr/ird/t3/entities/conversion/AbstractWeightCategoryLogBookConvertor.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/conversion/AbstractWeightCategoryLogBookConvertor.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/conversion/AbstractWeightCategoryLogBookConvertor.java @@ -20,14 +20,16 @@ */ package fr.ird.t3.entities.conversion; -import com.google.common.collect.Maps; import fr.ird.t3.entities.data.ElementaryCatch; import fr.ird.t3.entities.reference.Ocean; import fr.ird.t3.entities.reference.SchoolType; import fr.ird.t3.entities.reference.WeightCategoryTreatment; +import org.apache.commons.collections.CollectionUtils; + import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; -import org.apache.commons.collections.CollectionUtils; /** * Abstract log book convertor. @@ -122,8 +124,7 @@ public abstract class AbstractWeightCategoryLogBookConvertor implements WeightCa if (CollectionUtils.isNotEmpty(catches)) { for (ElementaryCatch aCatch : catches) { - Integer weightCategoryCode = - aCatch.getWeightCategoryLogBook().getCode(); + Integer weightCategoryCode = aCatch.getWeightCategoryLogBook().getCode(); Float ratio = distribution.get(weightCategoryCode); if (ratio != null) { result += ratio * aCatch.getCatchWeightRf2(); @@ -141,6 +142,7 @@ public abstract class AbstractWeightCategoryLogBookConvertor implements WeightCa * * @return the distributions */ + @Override public Map<WeightCategoryTreatment, Map<Integer, Float>> getDistributions() { if (distributions == null) { distributions = buildDistributions(); @@ -149,6 +151,20 @@ public abstract class AbstractWeightCategoryLogBookConvertor implements WeightCa } @Override + public Map<String, Map<Integer, Float>> getDistributionsByIds() { + Map<String, Map<Integer, Float>> distributionsToSave = new LinkedHashMap<>(); + for (Map.Entry<WeightCategoryTreatment, Map<Integer, Float>> e : getDistributions().entrySet()) { + distributionsToSave.put(e.getKey().getTopiaId(), e.getValue()); + } + return distributionsToSave; + } + + @Override + public Map<Integer, Float> getDistributions(WeightCategoryTreatment treatment) { + return getDistributions().get(treatment); + } + + @Override public final WeightCategoryTreatment getMinus10Category() { return minus10Category; } @@ -165,12 +181,11 @@ public abstract class AbstractWeightCategoryLogBookConvertor implements WeightCa Map<WeightCategoryTreatment, Map<Integer, Float>> distributions, float unknownWeight) { - Map<WeightCategoryTreatment, Float> unknownResult = Maps.newHashMap(); + Map<WeightCategoryTreatment, Float> unknownResult = new HashMap<>(); float totalWeight = 0f; - for (Map.Entry<WeightCategoryTreatment, Map<Integer, Float>> e : - distributions.entrySet()) { + for (Map.Entry<WeightCategoryTreatment, Map<Integer, Float>> e : distributions.entrySet()) { WeightCategoryTreatment category = e.getKey(); @@ -193,7 +208,7 @@ public abstract class AbstractWeightCategoryLogBookConvertor implements WeightCa } else { // there is some unknown weight to redistribute - result = Maps.newHashMap(); + result = new HashMap<>(); if (totalWeight == 0) { @@ -224,9 +239,9 @@ public abstract class AbstractWeightCategoryLogBookConvertor implements WeightCa protected final Map<WeightCategoryTreatment, Float> defaultDistributeForSpecie2( float totalWeight) { - Map<WeightCategoryTreatment, Float> result = Maps.newHashMap(); + Map<WeightCategoryTreatment, Float> result = new HashMap<>(); - // for species SKJ (code 2) : all goes to -10 kg categorie + // for species SKJ (code 2) : all goes to -10 kg category result.put(getMinus10Category(), totalWeight); return result; } @@ -234,9 +249,9 @@ public abstract class AbstractWeightCategoryLogBookConvertor implements WeightCa protected final Map<WeightCategoryTreatment, Float> defaultDistributeForOtherSpecie( float unknownWeight) { - Map<WeightCategoryTreatment, Float> result = Maps.newHashMap(); + Map<WeightCategoryTreatment, Float> result = new HashMap<>(); - // only keep unknown categorie weight + // only keep unknown category weight result.put(getUnkownCategory(), unknownWeight); return result; } ===================================== t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertor.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertor.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertor.java @@ -25,6 +25,7 @@ import fr.ird.t3.entities.reference.Ocean; import fr.ird.t3.entities.reference.SchoolType; import fr.ird.t3.entities.reference.Species; import fr.ird.t3.entities.reference.WeightCategoryTreatment; + import java.util.Collection; import java.util.Map; @@ -39,8 +40,13 @@ public interface WeightCategoryLogBookConvertor { boolean accept(Ocean ocean, SchoolType schoolType); - Map<WeightCategoryTreatment, Float> distribute(Species species, - Collection<ElementaryCatch> catches); + Map<WeightCategoryTreatment, Float> distribute(Species species, Collection<ElementaryCatch> catches); + + Map<String, Map<Integer, Float>> getDistributionsByIds() ; + + Map<WeightCategoryTreatment, Map<Integer, Float>> getDistributions(); + + Map<Integer, Float> getDistributions(WeightCategoryTreatment treatment); WeightCategoryTreatment getMinus10Category(); ===================================== t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OABI.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OABI.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OABI.java @@ -20,12 +20,14 @@ */ package fr.ird.t3.entities.conversion; -import com.google.common.collect.Maps; import fr.ird.t3.entities.data.ElementaryCatch; import fr.ird.t3.entities.reference.Species; import fr.ird.t3.entities.reference.WeightCategoryTreatment; + import java.util.Collection; +import java.util.HashMap; import java.util.Map; +import java.util.TreeMap; /** * To convert weight categories for Atlantic ocean and undetermined school type. @@ -45,19 +47,16 @@ public class WeightCategoryLogBookConvertorFOR_OABI extends AbstractWeightCatego WeightCategoryTreatment plus10Category, WeightCategoryTreatment plus30Category) { - super(WeightCategoryLogBookConvertorProvider.OA, - WeightCategoryLogBookConvertorProvider.BI, - minus10Category, unknownCategory); + super(WeightCategoryLogBookConvertorProvider.OA, WeightCategoryLogBookConvertorProvider.BI, minus10Category, unknownCategory); this.plus10Category = plus10Category; this.plus30Category = plus30Category; } @Override protected Map<WeightCategoryTreatment, Map<Integer, Float>> buildDistributions() { - Map<WeightCategoryTreatment, Map<Integer, Float>> result = - Maps.newHashMap(); + Map<WeightCategoryTreatment, Map<Integer, Float>> result = new HashMap<>(); - Map<Integer, Float> distributionMinus10 = Maps.newTreeMap(); + Map<Integer, Float> distributionMinus10 = new TreeMap<>(); // 1 + 2 + 4*(0.2) + 10 distributionMinus10.put(1, 1f); @@ -68,7 +67,7 @@ public class WeightCategoryLogBookConvertorFOR_OABI extends AbstractWeightCatego result.put(minus10Category, distributionMinus10); // 3 + 4*(0.8) + 6*(0.5) + 11*(0.1) + 12 - Map<Integer, Float> distributionPlus10 = Maps.newTreeMap(); + Map<Integer, Float> distributionPlus10 = new TreeMap<>(); distributionPlus10.put(3, 1f); distributionPlus10.put(4, 0.8f); distributionPlus10.put(6, 0.5f); @@ -78,7 +77,7 @@ public class WeightCategoryLogBookConvertorFOR_OABI extends AbstractWeightCatego result.put(plus10Category, distributionPlus10); // 5 + 6*(0.5) + 7 + 8 + 11*(0.9) + 13 - Map<Integer, Float> distributionPlus30 = Maps.newTreeMap(); + Map<Integer, Float> distributionPlus30 = new TreeMap<>(); distributionPlus30.put(5, 1f); distributionPlus30.put(6, 0.5f); distributionPlus30.put(7, 1f); @@ -92,14 +91,13 @@ public class WeightCategoryLogBookConvertorFOR_OABI extends AbstractWeightCatego } @Override - public final Map<WeightCategoryTreatment, Float> distribute(Species species, - Collection<ElementaryCatch> catches) { + public final Map<WeightCategoryTreatment, Float> distribute(Species species, Collection<ElementaryCatch> catches) { float totalWeight = getTotalWeight(catches); if (totalWeight == 0) { // this means no catches - return Maps.newHashMap(); + return new HashMap<>(); } Map<WeightCategoryTreatment, Float> result; @@ -111,20 +109,22 @@ public class WeightCategoryLogBookConvertorFOR_OABI extends AbstractWeightCatego float unknownWeight = getUnknownWeight(catches); - result = defaultDistributeForSpecie1or3or4(catches, - getDistributions(), - unknownWeight - ); + result = defaultDistributeForSpecie1or3or4(catches, getDistributions(), unknownWeight); break; case 2: - - result = defaultDistributeForSpecie2(totalWeight); - +// result = defaultDistributeForSpecie2(totalWeight); + result = new HashMap<>(); + // for species SKJ (code 2) : all goes to -10 kg category + result.put(getMinus10Category(), totalWeight); break; default: - result = defaultDistributeForOtherSpecie(totalWeight); +// result = defaultDistributeForOtherSpecie(totalWeight); + result = new HashMap<>(); + + // only keep unknown category weight + result.put(getUnkownCategory(), totalWeight); } return result; } ===================================== t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OIBI.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OIBI.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConvertorFOR_OIBI.java @@ -20,12 +20,14 @@ */ package fr.ird.t3.entities.conversion; -import com.google.common.collect.Maps; import fr.ird.t3.entities.data.ElementaryCatch; import fr.ird.t3.entities.reference.Species; import fr.ird.t3.entities.reference.WeightCategoryTreatment; + import java.util.Collection; +import java.util.HashMap; import java.util.Map; +import java.util.TreeMap; /** * To convert weight categories for Indian ocean and undetermined school type. @@ -50,11 +52,10 @@ public class WeightCategoryLogBookConvertorFOR_OIBI extends AbstractWeightCatego @Override protected Map<WeightCategoryTreatment, Map<Integer, Float>> buildDistributions() { - Map<WeightCategoryTreatment, Map<Integer, Float>> result = - Maps.newHashMap(); + Map<WeightCategoryTreatment, Map<Integer, Float>> result = new HashMap<>(); // 1 + 2 + 4*(0.2) + 10 - Map<Integer, Float> distributionMinus10 = Maps.newTreeMap(); + Map<Integer, Float> distributionMinus10 = new TreeMap<>(); distributionMinus10.put(1, 1f); distributionMinus10.put(2, 1f); distributionMinus10.put(4, 0.2f); @@ -63,7 +64,7 @@ public class WeightCategoryLogBookConvertorFOR_OIBI extends AbstractWeightCatego result.put(minus10Category, distributionMinus10); // 3 + 4*(0.8) + 5 + 6 + 7 + 8 + 11 + 12 + 13 - Map<Integer, Float> distributionPlus10 = Maps.newTreeMap(); + Map<Integer, Float> distributionPlus10 = new TreeMap<>(); distributionPlus10.put(3, 1f); distributionPlus10.put(4, 0.8f); distributionPlus10.put(5, 1f); @@ -79,14 +80,13 @@ public class WeightCategoryLogBookConvertorFOR_OIBI extends AbstractWeightCatego } @Override - public final Map<WeightCategoryTreatment, Float> distribute(Species species, - Collection<ElementaryCatch> catches) { + public final Map<WeightCategoryTreatment, Float> distribute(Species species, Collection<ElementaryCatch> catches) { float totalWeight = getTotalWeight(catches); if (totalWeight == 0) { // this means no catches - return Maps.newHashMap(); + return new HashMap<>(); } Map<WeightCategoryTreatment, Float> result; @@ -95,22 +95,13 @@ public class WeightCategoryLogBookConvertorFOR_OIBI extends AbstractWeightCatego case 1: case 3: case 4: - float unknownWeight = getUnknownWeight(catches); - - result = defaultDistributeForSpecie1or3or4(catches, - getDistributions(), - unknownWeight - ); - + result = defaultDistributeForSpecie1or3or4(catches, getDistributions(), unknownWeight); break; case 2: - result = defaultDistributeForSpecie2(totalWeight); - break; default: - result = defaultDistributeForOtherSpecie(totalWeight); } return result; ===================================== t3-domain/src/main/java/fr/ird/t3/entities/reference/LengthWeightConversionImpl.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/reference/LengthWeightConversionImpl.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/reference/LengthWeightConversionImpl.java @@ -20,29 +20,22 @@ */ package fr.ird.t3.entities.reference; -import com.google.common.collect.Maps; import fr.ird.t3.entities.LengthWeightConversionHelper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import java.util.Map; +import java.util.TreeMap; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; public class LengthWeightConversionImpl extends LengthWeightConversionAbstract { - /** Logger. */ - private static final Log log = - LogFactory.getLog(LengthWeightConversionImpl.class); - + private static final Log log = LogFactory.getLog(LengthWeightConversionImpl.class); private static final long serialVersionUID = 1L; - - - private static final Pattern COEFFICIENTS_PATTERN = - Pattern.compile("(.+)=(.+)"); - + private static final Pattern COEFFICIENTS_PATTERN = Pattern.compile("(.+)=(.+)"); /** variable poids à utiliser dans la relation taille */ public static final String VARIABLE_POIDS = "P"; - /** variable taille à utiliser dans la relation poids */ public static final String VARIABLE_TAILLE = "L"; @@ -59,19 +52,19 @@ public class LengthWeightConversionImpl extends LengthWeightConversionAbstract { } @Override - public float computeWeight(float longueur) { + public Float computeWeight(float longueur) { return LengthWeightConversionHelper.computeWeight(this, longueur); } @Override - public float computeWeightFromLFLengthClass(int lengthClass) { + public Float computeWeightFromLFLengthClass(int lengthClass) { Integer lfLengthClassStep = species.getLfLengthClassStep(); float longueur = lengthClass + lfLengthClassStep / 2f; return LengthWeightConversionHelper.computeWeight(this, longueur); } @Override - public float computeLength(float poids) { + public Float computeLength(float poids) { return LengthWeightConversionHelper.computeLength(this, poids); } @@ -92,31 +85,27 @@ public class LengthWeightConversionImpl extends LengthWeightConversionAbstract { @Override public Map<String, Double> getCoefficientValues() { - Map<String, Double> result = Maps.newTreeMap(); + Map<String, Double> result = new TreeMap<>(); String coefficients = getCoefficients(); if (coefficients != null) { for (String coefficientDef : coefficients.split(":")) { - Matcher matcher = - COEFFICIENTS_PATTERN.matcher(coefficientDef.trim()); + Matcher matcher = COEFFICIENTS_PATTERN.matcher(coefficientDef.trim()); if (log.isDebugEnabled()) { - log.debug("constant to test = " + coefficientDef); + log.debug(String.format("constant to test = %s", coefficientDef)); } if (matcher.matches()) { - String key = matcher.group(1); String val = matcher.group(2); try { Double d = Double.valueOf(val); result.put(key, d); if (log.isDebugEnabled()) { - log.debug("detets coefficient " + key + '=' + - val); + log.debug(String.format("detect coefficient %s=%s", key, val)); } } catch (NumberFormatException e) { // pas pu recupere le nombre... if (log.isWarnEnabled()) { - log.warn("could not parse double " + val + - " for coefficient " + key); + log.warn(String.format("could not parse double %s for coefficient %s", val, key)); } } } ===================================== t3-domain/src/main/java/fr/ird/t3/entities/reference/WeightCategoryLogBookConversionImpl.java ===================================== --- /dev/null +++ b/t3-domain/src/main/java/fr/ird/t3/entities/reference/WeightCategoryLogBookConversionImpl.java @@ -0,0 +1,49 @@ +package fr.ird.t3.entities.reference; + +/*- + * #%L + * T3 :: Domain + * %% + * Copyright (C) 2010 - 2018 IRD, Code Lutin, Ultreia.io + * %% + * 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 java.util.Date; + +public class WeightCategoryLogBookConversionImpl extends WeightCategoryLogBookConversionAbstract { + + private static final long serialVersionUID = 1L; + + @Override + public int getCode() { + return 0; + } + + @Override + public String getLabel1() { + return null; + } + + @Override + public boolean isStatus() { + return true; + } + + @Override + public boolean acceptDate(Date date) { + return !date.before(getBeginDate()) && (getEndDate() == null || !date.after(getEndDate())); + } +} ===================================== t3-domain/src/main/java/fr/ird/t3/entities/reference/WeightCategoryLogBookConversionSpeciesImpl.java ===================================== --- /dev/null +++ b/t3-domain/src/main/java/fr/ird/t3/entities/reference/WeightCategoryLogBookConversionSpeciesImpl.java @@ -0,0 +1,59 @@ +package fr.ird.t3.entities.reference; + +/*- + * #%L + * T3 :: Domain + * %% + * Copyright (C) 2010 - 2018 IRD, Code Lutin, Ultreia.io + * %% + * 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 com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +import java.util.Map; + +public class WeightCategoryLogBookConversionSpeciesImpl extends WeightCategoryLogBookConversionSpeciesAbstract { + + private static final long serialVersionUID = 1L; + + private static final Gson gson = new GsonBuilder().setPrettyPrinting().create(); + + public static String toString(Map<String, Map<Integer, Float>> distributions) { + return gson.toJson(distributions); + } + + @Override + public int getCode() { + return 0; + } + + @Override + public String getLabel1() { + return null; + } + + @Override + public boolean isStatus() { + return true; + } + + @SuppressWarnings("unchecked") + @Override + public Map<String, Map<Integer, Float>> getDistributions2() { + return gson.fromJson(getDistribution(), Map.class); + } +} ===================================== t3-domain/src/main/java/fr/ird/t3/services/migration/T3MigrationCallbackV2_1.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/services/migration/T3MigrationCallbackV2_1.java +++ b/t3-domain/src/main/java/fr/ird/t3/services/migration/T3MigrationCallbackV2_1.java @@ -123,6 +123,8 @@ public class T3MigrationCallbackV2_1 extends T3MigrationCallbackSupport { addScript("08", "remove-Trip-fields", queries); addScript("09", "fill-Harbour-ocean.sql", queries); + addScript("10", "add-WeightCategoryLogBookConversion-table.sql", queries); + addScript("11", "fill-WeightCategoryLogBookConversion-table.sql", queries); } ===================================== t3-domain/src/main/resources/db/migration/V2_1_10_add-WeightCategoryLogBookConversion-table.sql ===================================== --- /dev/null +++ b/t3-domain/src/main/resources/db/migration/V2_1_10_add-WeightCategoryLogBookConversion-table.sql @@ -0,0 +1,39 @@ +--- +-- #%L +-- T3 :: Domain +-- %% +-- Copyright (C) 2010 - 2018 IRD, Code Lutin, Ultreia.io +-- %% +-- 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% +--- +-- drop TABLE IF EXISTS weightcategorylogbookconversion CASCADE ; +-- drop TABLE IF EXISTS weightcategorylogbookconversionspecies CASCADE ; +-- drop TABLE IF EXISTS weightcategorylogbookconversionspecies_species CASCADE ; + +CREATE TABLE WeightCategoryLogBookConversion( topiaid VARCHAR(255) PRIMARY KEY NOT NULL, topiaversion BIGINT NOT NULL, topiacreatedate TIMESTAMP NOT NULL, ocean VARCHAR(255) NOT NULL, schoolType VARCHAR(255) NOT NULL, version VARCHAR(255) NOT NULL, beginDate DATE NOT NULL, endDate DATE); +CREATE UNIQUE INDEX uk_WeightCategoryLogBookConversion ON WeightCategoryLogBookConversion(version, ocean, schoolType, beginDate); +ALTER TABLE WeightCategoryLogBookConversion ADD CONSTRAINT fk_WeightCategoryLogBookConversion_ocean FOREIGN KEY (ocean) REFERENCES Ocean(topiaid); +ALTER TABLE WeightCategoryLogBookConversion ADD CONSTRAINT fk_WeightCategoryLogBookConversion_schoolType FOREIGN KEY (schoolType) REFERENCES SchoolType(topiaid); +CREATE INDEX idx_WeightCategoryLogBookConversion_ocean ON WeightCategoryLogBookConversion(ocean); +CREATE INDEX idx_WeightCategoryLogBookConversion_schoolType ON WeightCategoryLogBookConversion(schoolType); + +CREATE TABLE WeightCategoryLogBookConversionSpecies( topiaid VARCHAR(255) PRIMARY KEY NOT NULL, topiaversion BIGINT NOT NULL, topiacreatedate TIMESTAMP NOT NULL, parent VARCHAR(255) NOT NULL, parent_idx int, distribution TEXT NOT NULL); +ALTER TABLE WeightCategoryLogBookConversionSpecies ADD CONSTRAINT fk_WeightCategoryLogBookConversionSpecies_parent FOREIGN KEY (parent) REFERENCES WeightCategoryLogBookConversion(topiaid); +CREATE INDEX idx_WeightCategoryLogBookConversion_parent ON WeightCategoryLogBookConversionSpecies(parent); + +CREATE TABLE WeightCategoryLogBookConversionSpecies_Species(weightCategoryLogBookConversionSpecies VARCHAR(255) NOT NULL, species VARCHAR(255) NOT NULL); +ALTER TABLE WeightCategoryLogBookConversionSpecies_Species ADD CONSTRAINT pk_WeightCategoryLogBookConversionS PRIMARY KEY (weightCategoryLogBookConversionSpecies,species); +ALTER TABLE WeightCategoryLogBookConversionSpecies_Species ADD CONSTRAINT fk_WeightCategoryLogBookConversionS_w FOREIGN KEY (weightCategoryLogBookConversionSpecies) REFERENCES WeightCategoryLogBookConversionSpecies(topiaid); +ALTER TABLE WeightCategoryLogBookConversionSpecies_Species ADD CONSTRAINT fk_WeightCategoryLogBookConversionS_s FOREIGN KEY (species) REFERENCES Species(topiaid); \ No newline at end of file ===================================== t3-domain/src/main/resources/db/migration/V2_1_11_fill-WeightCategoryLogBookConversion-table.sql ===================================== --- /dev/null +++ b/t3-domain/src/main/resources/db/migration/V2_1_11_fill-WeightCategoryLogBookConversion-table.sql @@ -0,0 +1,300 @@ +--- +-- #%L +-- T3 :: Domain +-- %% +-- Copyright (C) 2010 - 2018 IRD, Code Lutin, Ultreia.io +-- %% +-- 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% +--- +INSERT INTO public.weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#00', 1, '2018-02-22 21:43:17.612000', 'fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624', 'fr.ird.t3.entities.reference.SchoolType#1297580528908#0.9747685881931636', '1.0', '1970-01-01', null); +INSERT INTO public.weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#01', 1, '2018-02-22 21:43:17.676000', 'fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624', 'fr.ird.t3.entities.reference.SchoolType#1297580528908#0.8923578380543445', '1.0', '1970-01-01', null); +INSERT INTO public.weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#02', 1, '2018-02-22 21:43:17.677000', 'fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624', 'fr.ird.t3.entities.reference.SchoolType#1297580528908#0.633774803291473', '1.0', '1970-01-01', null); +INSERT INTO public.weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#03', 1, '2018-02-22 21:43:17.677000', 'fr.ird.t3.entities.reference.Ocean#1297580528924#0.02462443299831396', 'fr.ird.t3.entities.reference.SchoolType#1297580528908#0.9747685881931636', '1.0', '1970-01-01', null); +INSERT INTO public.weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#04', 1, '2018-02-22 21:43:17.680000', 'fr.ird.t3.entities.reference.Ocean#1297580528924#0.02462443299831396', 'fr.ird.t3.entities.reference.SchoolType#1297580528908#0.8923578380543445', '1.0', '1970-01-01', null); +INSERT INTO public.weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#05', 1, '2018-02-22 21:43:17.681000', 'fr.ird.t3.entities.reference.Ocean#1297580528924#0.02462443299831396', 'fr.ird.t3.entities.reference.SchoolType#1297580528908#0.633774803291473', '1.0', '1970-01-01', null); +INSERT INTO public.weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#06', 1, '2018-02-22 21:43:17.685000', 'fr.ird.t3.entities.reference.Ocean#1297580528925#0.868563686958073', 'fr.ird.t3.entities.reference.SchoolType#1297580528908#0.9747685881931636', '1.0', '1970-01-01', null); +INSERT INTO public.weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#07', 1, '2018-02-22 21:43:17.689000', 'fr.ird.t3.entities.reference.Ocean#1297580528925#0.868563686958073', 'fr.ird.t3.entities.reference.SchoolType#1297580528908#0.8923578380543445', '1.0', '1970-01-01', null); +INSERT INTO public.weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#08', 1, '2018-02-22 21:43:17.690000', 'fr.ird.t3.entities.reference.Ocean#1297580528925#0.868563686958073', 'fr.ird.t3.entities.reference.SchoolType#1297580528908#0.633774803291473', '1.0', '1970-01-01', null); + +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#00', 1, '2018-02-22 21:43:17.758000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#00', 0, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830509#0.5499777108807193": {} +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#01', 1, '2018-02-22 21:43:17.790000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#00', 1, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830509#0.44386731073429053": {} +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#02', 1, '2018-02-22 21:43:17.808000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#00', 2, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830509#0.5237318856431237": { + "3": 1.0, + "4": 0.8, + "6": 0.5, + "11": 0.1, + "12": 1.0 + }, + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830509#0.5499777108807192": { + "5": 1.0, + "6": 0.5, + "7": 1.0, + "8": 1.0, + "11": 0.9, + "13": 1.0 + }, + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830509#0.44386731073429053": { + "1": 1.0, + "2": 1.0, + "4": 0.2, + "10": 1.0 + } +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#03', 1, '2018-02-22 21:43:17.811000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#01', 0, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830505#0.988038536400382": {} +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#04', 1, '2018-02-22 21:43:17.821000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#01', 1, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830500#0.6310700924396421": {} +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#05', 1, '2018-02-22 21:43:17.826000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#01', 2, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830505#0.988038536400381": { + "3": 1.0, + "4": 0.8, + "5": 1.0, + "6": 1.0, + "7": 1.0, + "8": 1.0, + "11": 1.0, + "12": 1.0, + "13": 1.0 + }, + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830500#0.6310700924396421": { + "1": 1.0, + "2": 1.0, + "4": 0.2, + "10": 1.0 + } +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#06', 1, '2018-02-22 21:43:17.840000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#02', 0, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830506#0.5499777108807193": {} +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#07', 1, '2018-02-22 21:43:17.843000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#02', 1, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830505#0.44386731073429053": {} +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#08', 1, '2018-02-22 21:43:17.855000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#02', 2, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830506#0.5237318856431237": { + "3": 1.0, + "4": 0.8, + "6": 0.5, + "11": 0.1, + "12": 1.0 + }, + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830506#0.5499777108807192": { + "5": 1.0, + "6": 0.5, + "7": 1.0, + "8": 1.0, + "11": 0.9, + "13": 1.0 + }, + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830505#0.44386731073429053": { + "1": 1.0, + "2": 1.0, + "4": 0.2, + "10": 1.0 + } +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#017', 1, '2018-02-22 21:43:17.943000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#02', 3, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830508#0.8969775036221255": { + "3": 1.0, + "4": 0.8, + "5": 1.0, + "6": 1.0, + "7": 1.0, + "8": 1.0, + "11": 1.0, + "12": 1.0, + "13": 1.0 + }, + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830507#0.6434841998774135": { + "1": 1.0, + "2": 1.0, + "4": 0.2, + "10": 1.0 + } +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#09', 1, '2018-02-22 21:43:17.858000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#03', 0, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830510#0.8969775036221247": {} +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#010', 1, '2018-02-22 21:43:17.875000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#03', 1, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830510#0.6434841998774145": {} +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#011', 1, '2018-02-22 21:43:17.891000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#03', 2, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830510#0.8969775036221246": { + "3": 1.0, + "4": 0.8, + "5": 1.0, + "6": 1.0, + "7": 1.0, + "8": 1.0, + "11": 1.0, + "12": 1.0, + "13": 1.0 + }, + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830510#0.6434841998774145": { + "1": 1.0, + "2": 1.0, + "4": 0.2, + "10": 1.0 + } +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#012', 1, '2018-02-22 21:43:17.897000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#04', 0, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830507#0.14752652961660063": {} +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#013', 1, '2018-02-22 21:43:17.903000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#04', 1, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830506#0.4807760142660965": {} +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#014', 1, '2018-02-22 21:43:17.920000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#04', 2, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830507#0.14752652961660062": { + "3": 1.0, + "4": 0.8, + "5": 1.0, + "6": 1.0, + "7": 1.0, + "8": 1.0, + "11": 1.0, + "12": 1.0, + "13": 1.0 + }, + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830506#0.4807760142660965": { + "1": 1.0, + "2": 1.0, + "4": 0.2, + "10": 1.0 + } +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#015', 1, '2018-02-22 21:43:17.929000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#05', 0, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830508#0.8969775036221256": {} +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#016', 1, '2018-02-22 21:43:17.939000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#05', 1, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#1308925830507#0.6434841998774135": {} +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#018', 1, '2018-02-22 21:43:17.951000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#06', 0, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#2308925830510#0.8969775036221247": {} +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#019', 1, '2018-02-22 21:43:17.956000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#06', 1, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#2308925830510#0.6434841998774145": {} +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#020', 1, '2018-02-22 21:43:17.961000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#06', 2, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#2308925830510#0.8969775036221246": { + "3": 1.0, + "4": 0.8, + "5": 1.0, + "6": 1.0, + "7": 1.0, + "8": 1.0, + "11": 1.0, + "12": 1.0, + "13": 1.0 + }, + "fr.ird.t3.entities.reference.WeightCategoryTreatment#2308925830510#0.6434841998774145": { + "1": 1.0, + "2": 1.0, + "4": 0.2, + "10": 1.0 + } +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#021', 1, '2018-02-22 21:43:17.970000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#07', 0, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#2308925830507#0.14752652961660063": {} +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#022', 1, '2018-02-22 21:43:17.975000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#07', 1, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#2308925830506#0.4807760142660965": {} +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#023', 1, '2018-02-22 21:43:17.988000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#07', 2, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#2308925830507#0.14752652961660062": { + "3": 1.0, + "4": 0.8, + "5": 1.0, + "6": 1.0, + "7": 1.0, + "8": 1.0, + "11": 1.0, + "12": 1.0, + "13": 1.0 + }, + "fr.ird.t3.entities.reference.WeightCategoryTreatment#2308925830506#0.4807760142660965": { + "1": 1.0, + "2": 1.0, + "4": 0.2, + "10": 1.0 + } +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#024', 1, '2018-02-22 21:43:17.991000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#08', 0, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#2308925830508#0.8969775036221256": {} +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#025', 1, '2018-02-22 21:43:17.994000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#08', 1, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#2308925830507#0.6434841998774135": {} +}'); +INSERT INTO public.weightcategorylogbookconversionspecies (topiaid, topiaversion, topiacreatedate, parent, parent_idx, distribution) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#026', 1, '2018-02-22 21:43:18.006000', 'fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#08', 2, '{ + "fr.ird.t3.entities.reference.WeightCategoryTreatment#2308925830508#0.8969775036221255": { + "3": 1.0, + "4": 0.8, + "5": 1.0, + "6": 1.0, + "7": 1.0, + "8": 1.0, + "11": 1.0, + "12": 1.0, + "13": 1.0 + }, + "fr.ird.t3.entities.reference.WeightCategoryTreatment#2308925830507#0.6434841998774135": { + "1": 1.0, + "2": 1.0, + "4": 0.2, + "10": 1.0 + } +}'); + +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#01', 'fr.ird.t3.entities.reference.Species#1297580528889#0.21694502845340558'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#02', 'fr.ird.t3.entities.reference.Species#1297580528889#0.5520768903332204'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#02', 'fr.ird.t3.entities.reference.Species#1297580528889#0.44612689800927063'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#02', 'fr.ird.t3.entities.reference.Species#1297580528889#0.7537605030704515'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#04', 'fr.ird.t3.entities.reference.Species#1297580528889#0.21694502845340558'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#05', 'fr.ird.t3.entities.reference.Species#1297580528889#0.5520768903332204'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#05', 'fr.ird.t3.entities.reference.Species#1297580528889#0.44612689800927063'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#05', 'fr.ird.t3.entities.reference.Species#1297580528889#0.7537605030704515'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#07', 'fr.ird.t3.entities.reference.Species#1297580528889#0.21694502845340558'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#08', 'fr.ird.t3.entities.reference.Species#1297580528889#0.5520768903332204'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#08', 'fr.ird.t3.entities.reference.Species#1297580528889#0.44612689800927063'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#08', 'fr.ird.t3.entities.reference.Species#1297580528889#0.7537605030704515'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#010', 'fr.ird.t3.entities.reference.Species#1297580528889#0.21694502845340558'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#011', 'fr.ird.t3.entities.reference.Species#1297580528889#0.5520768903332204'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#011', 'fr.ird.t3.entities.reference.Species#1297580528889#0.44612689800927063'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#011', 'fr.ird.t3.entities.reference.Species#1297580528889#0.7537605030704515'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#013', 'fr.ird.t3.entities.reference.Species#1297580528889#0.21694502845340558'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#014', 'fr.ird.t3.entities.reference.Species#1297580528889#0.5520768903332204'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#014', 'fr.ird.t3.entities.reference.Species#1297580528889#0.44612689800927063'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#014', 'fr.ird.t3.entities.reference.Species#1297580528889#0.7537605030704515'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#016', 'fr.ird.t3.entities.reference.Species#1297580528889#0.21694502845340558'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#017', 'fr.ird.t3.entities.reference.Species#1297580528889#0.5520768903332204'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#017', 'fr.ird.t3.entities.reference.Species#1297580528889#0.44612689800927063'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#017', 'fr.ird.t3.entities.reference.Species#1297580528889#0.7537605030704515'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#019', 'fr.ird.t3.entities.reference.Species#1297580528889#0.21694502845340558'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#020', 'fr.ird.t3.entities.reference.Species#1297580528889#0.5520768903332204'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#020', 'fr.ird.t3.entities.reference.Species#1297580528889#0.44612689800927063'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#020', 'fr.ird.t3.entities.reference.Species#1297580528889#0.7537605030704515'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#022', 'fr.ird.t3.entities.reference.Species#1297580528889#0.21694502845340558'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#023', 'fr.ird.t3.entities.reference.Species#1297580528889#0.5520768903332204'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#023', 'fr.ird.t3.entities.reference.Species#1297580528889#0.44612689800927063'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#023', 'fr.ird.t3.entities.reference.Species#1297580528889#0.7537605030704515'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#025', 'fr.ird.t3.entities.reference.Species#1297580528889#0.21694502845340558'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#026', 'fr.ird.t3.entities.reference.Species#1297580528889#0.5520768903332204'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#026', 'fr.ird.t3.entities.reference.Species#1297580528889#0.44612689800927063'); +INSERT INTO weightcategorylogbookconversionspecies_species (weightcategorylogbookconversionspecies, species) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies#1519311532526#026', 'fr.ird.t3.entities.reference.Species#1297580528889#0.7537605030704515'); ===================================== t3-domain/src/main/resources/t3-datadb.properties ===================================== --- a/t3-domain/src/main/resources/t3-datadb.properties +++ b/t3-domain/src/main/resources/t3-datadb.properties @@ -38,4 +38,5 @@ topia.service.migration=org.nuiton.topia.migration.TopiaMigrationEngine topia.service.migration.callback=fr.ird.t3.services.migration.T3MigrationCallback topia.service.migration.showSql=true topia.service.migration.showProgression=true +topia.persistence.topiaIdFactoryClassName=org.nuiton.topia.persistence.internal.LegacyTopiaIdFactory ===================================== t3-domain/src/main/xmi/t3-persistence.properties ===================================== --- a/t3-domain/src/main/xmi/t3-persistence.properties +++ b/t3-domain/src/main/xmi/t3-persistence.properties @@ -18,7 +18,6 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # #L% ### -#model.tagValue.i18n=t3.common. model.tagValue.notGenerateToString=true model.tagValue.generateOperatorForDAOHelper=true model.tagValue.constantPrefix=PROPERTY_ @@ -27,6 +26,7 @@ model.tagValue.indexForeignKeys=true fr.ird.t3.entities.data.Trip.attribute.route.stereotype=ordered fr.ird.t3.entities.data.Route.attribute.activity.stereotype=ordered +fr.ird.t3.entities.reference.WeightCategoryLogBookConversion.attribute.distributions.stereotype=ordered fr.ird.t3.entities.data.Trip.attribute.route.tagvalue.orderBy=date fr.ird.t3.entities.data.Route.attribute.activity.tagvalue.orderBy=date @@ -34,6 +34,11 @@ fr.ird.t3.entities.data.Route.attribute.activity.tagvalue.orderBy=date fr.ird.t3.entities.data.Route.attribute.date.tagvalue.hibernateAttributeType.java.util.Date=date fr.ird.t3.entities.data.Activity.attribute.time.tagvalue.hibernateAttributeType.java.util.Date=time +fr.ird.t3.entities.reference.WeightCategoryLogBookConversion.attribute.beginDate.tagValue.hibernateAttributeType.java.util.Date=date +fr.ird.t3.entities.reference.WeightCategoryLogBookConversion.attribute.endDate.tagValue.hibernateAttributeType.java.util.Date=date +fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies.attribute.distribution.tagValue.hibernateAttributeType.java.lang.String=text +fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies.attribute.species.tagvalue.manyToManyTableName=WeightCategoryLogBookConversionSpecies_Species + fr.ird.t3.entities.data.Activity.attribute.comment.tagvalue.sqlType=text fr.ird.t3.entities.data.LocalMarketBatch.attribute.origin.tagvalue.sqlType=text fr.ird.t3.entities.data.LocalMarketBatch.attribute.comment.tagvalue.sqlType=text @@ -50,6 +55,7 @@ fr.ird.t3.entities.reference.Vessel.attribute.vesselSizeCategory.tagvalue.lazy=f fr.ird.t3.entities.reference.WeightCategoryLanding.attribute.species.tagvalue.lazy=false fr.ird.t3.entities.reference.WeightCategoryLogBook.attribute.species.tagvalue.lazy=false +fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies.attribute.species.tagValue.lazy=false fr.ird.t3.entities.reference.WeightCategoryTreatment.attribute.ocean.tagvalue.lazy=false fr.ird.t3.entities.reference.WeightCategoryTreatment.attribute.schoolType.tagvalue.lazy=false @@ -74,6 +80,7 @@ fr.ird.t3.entities.reference.VesselActivity.attribute.code.stereotype=unique fr.ird.t3.entities.reference.VesselSizeCategory.attribute.code.stereotype=unique fr.ird.t3.entities.reference.VesselType.attribute.code.stereotype=unique #fr.ird.t3.entities.reference.WeightCategoryLanding.attribute.code.stereotype=unique +fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies.attribute.species.stereotype=unique fr.ird.t3.entities.reference.WellDestiny.attribute.code.stereotype=unique fr.ird.t3.entities.reference.Species.attribute.faoId.stereotype=unique fr.ird.t3.entities.reference.Species.attribute.wormsId.stereotype=unique @@ -87,40 +94,66 @@ fr.ird.t3.entities.reference.ElementaryCatchFate.attribute.code.stereotype=uniqu fr.ird.t3.entities.reference.Company.attribute.code.stereotype=unique ############################################################################### +### Not null for references ################################################### +############################################################################### + +fr.ird.t3.entities.reference.WeightCategoryLanding.attribute.code.tagValue.notNull=true +fr.ird.t3.entities.reference.WeightCategoryLanding.attribute.species.tagValue.notNull=true +fr.ird.t3.entities.reference.WeightCategoryLogBook.attribute.code.tagValue.notNull=true +fr.ird.t3.entities.reference.WeightCategoryLogBook.attribute.species.tagValue.notNull=true +fr.ird.t3.entities.reference.WeightCategoryTreatment.attribute.ocean.tagValue.notNull=true +fr.ird.t3.entities.reference.WeightCategoryTreatment.attribute.schoolType.tagValue.notNull=true +fr.ird.t3.entities.reference.WeightCategoryTreatment.attribute.min.tagValue.notNull=false +fr.ird.t3.entities.reference.WeightCategoryTreatment.attribute.max.tagValue.notNull=false +fr.ird.t3.entities.reference.LengthWeightConversion.attribute.species.tagValue.notNull=true +fr.ird.t3.entities.reference.LengthWeightConversion.attribute.ocean.tagValue.notNull=false +fr.ird.t3.entities.reference.LengthWeightConversion.attribute.sexe.tagValue.notNull=false +fr.ird.t3.entities.reference.LengthWeightConversion.attribute.beginDate.tagValue.notNull=true +fr.ird.t3.entities.reference.WeightCategoryLogBookConversion.attribute.ocean.tagValue.notNull=true +fr.ird.t3.entities.reference.WeightCategoryLogBookConversion.attribute.schoolType.tagValue.notNull=true +fr.ird.t3.entities.reference.WeightCategoryLogBookConversion.attribute.beginDate.tagValue.notNull=true +fr.ird.t3.entities.reference.WeightCategoryLogBookConversion.attribute.version.tagValue.notNull=true +fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies.attribute.distribution.tagValue.notNull=true +fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies.attribute.parent.tagValue.notNull=true + +############################################################################### ### Natural id for references ################################################ ############################################################################### fr.ird.t3.entities.reference.WeightCategoryLanding.class.tagValue.naturalIdMutable=false fr.ird.t3.entities.reference.WeightCategoryLanding.attribute.code.tagValue.naturalId=true -fr.ird.t3.entities.reference.WeightCategoryLanding.attribute.code.tagValue.notNull=true fr.ird.t3.entities.reference.WeightCategoryLanding.attribute.species.tagValue.naturalId=true -fr.ird.t3.entities.reference.WeightCategoryLanding.attribute.species.tagValue.notNull=true + fr.ird.t3.entities.reference.WeightCategoryLogBook.class.tagValue.naturalIdMutable=false fr.ird.t3.entities.reference.WeightCategoryLogBook.attribute.code.tagValue.naturalId=true -fr.ird.t3.entities.reference.WeightCategoryLogBook.attribute.code.tagValue.notNull=true fr.ird.t3.entities.reference.WeightCategoryLogBook.attribute.species.tagValue.naturalId=true -fr.ird.t3.entities.reference.WeightCategoryLogBook.attribute.species.tagValue.notNull=true fr.ird.t3.entities.reference.WeightCategoryTreatment.class.tagValue.naturalIdMutable=false fr.ird.t3.entities.reference.WeightCategoryTreatment.attribute.ocean.tagValue.naturalId=true -fr.ird.t3.entities.reference.WeightCategoryTreatment.attribute.ocean.tagValue.notNull=true fr.ird.t3.entities.reference.WeightCategoryTreatment.attribute.schoolType.tagValue.naturalId=true -fr.ird.t3.entities.reference.WeightCategoryTreatment.attribute.schoolType.tagValue.notNull=true fr.ird.t3.entities.reference.WeightCategoryTreatment.attribute.min.tagValue.naturalId=true -fr.ird.t3.entities.reference.WeightCategoryTreatment.attribute.min.tagValue.notNull=false fr.ird.t3.entities.reference.WeightCategoryTreatment.attribute.max.tagValue.naturalId=true -fr.ird.t3.entities.reference.WeightCategoryTreatment.attribute.max.tagValue.notNull=false fr.ird.t3.entities.reference.LengthWeightConversion.class.tagValue.naturalIdMutable=true fr.ird.t3.entities.reference.LengthWeightConversion.attribute.species.tagValue.naturalId=true -fr.ird.t3.entities.reference.LengthWeightConversion.attribute.species.tagValue.notNull=true fr.ird.t3.entities.reference.LengthWeightConversion.attribute.ocean.tagValue.naturalId=true -fr.ird.t3.entities.reference.LengthWeightConversion.attribute.ocean.tagValue.notNull=false fr.ird.t3.entities.reference.LengthWeightConversion.attribute.sexe.tagValue.naturalId=true -fr.ird.t3.entities.reference.LengthWeightConversion.attribute.sexe.tagValue.notNull=false fr.ird.t3.entities.reference.LengthWeightConversion.attribute.beginDate.tagValue.naturalId=true -fr.ird.t3.entities.reference.LengthWeightConversion.attribute.beginDate.tagValue.notNull=true + +fr.ird.t3.entities.reference.WeightCategoryLogBookConversion.class.tagValue.naturalIdMutable=false +fr.ird.t3.entities.reference.WeightCategoryLogBookConversion.attribute.ocean.tagValue.naturalId=true +fr.ird.t3.entities.reference.WeightCategoryLogBookConversion.attribute.schoolType.tagValue.naturalId=true +fr.ird.t3.entities.reference.WeightCategoryLogBookConversion.attribute.beginDate.tagValue.naturalId=true +fr.ird.t3.entities.reference.WeightCategoryLogBookConversion.attribute.version.tagValue.naturalId=true + +############################################################################### +### Not null for data ######################################################### +############################################################################### + +fr.ird.t3.entities.data.ExtrapolatedAllSetSpeciesFrequency.attribute.activity.tagValue.notNull=true +fr.ird.t3.entities.data.ExtrapolatedAllSetSpeciesFrequency.attribute.species.tagValue.notNull=true +fr.ird.t3.entities.data.ExtrapolatedAllSetSpeciesFrequency.attribute.lfLengthClass.tagValue.notNull=true ############################################################################### ### Natural id for data ###################################################### @@ -128,8 +161,5 @@ fr.ird.t3.entities.reference.LengthWeightConversion.attribute.beginDate.tagValue fr.ird.t3.entities.data.ExtrapolatedAllSetSpeciesFrequency.class.tagValue.naturalIdMutable=false fr.ird.t3.entities.data.ExtrapolatedAllSetSpeciesFrequency.attribute.activity.tagValue.naturalId=true -fr.ird.t3.entities.data.ExtrapolatedAllSetSpeciesFrequency.attribute.activity.tagValue.notNull=true fr.ird.t3.entities.data.ExtrapolatedAllSetSpeciesFrequency.attribute.species.tagValue.naturalId=true -fr.ird.t3.entities.data.ExtrapolatedAllSetSpeciesFrequency.attribute.species.tagValue.notNull=true fr.ird.t3.entities.data.ExtrapolatedAllSetSpeciesFrequency.attribute.lfLengthClass.tagValue.naturalId=true -fr.ird.t3.entities.data.ExtrapolatedAllSetSpeciesFrequency.attribute.lfLengthClass.tagValue.notNull=true ===================================== t3-domain/src/main/xmi/t3-persistence.zargo ===================================== Binary files a/t3-domain/src/main/xmi/t3-persistence.zargo and b/t3-domain/src/main/xmi/t3-persistence.zargo differ ===================================== t3-domain/src/test/java/fr/ird/t3/services/migration/T3MigrationTest.java ===================================== --- a/t3-domain/src/test/java/fr/ird/t3/services/migration/T3MigrationTest.java +++ b/t3-domain/src/test/java/fr/ird/t3/services/migration/T3MigrationTest.java @@ -22,11 +22,49 @@ package fr.ird.t3.services.migration; */ import fr.ird.t3.entities.T3TopiaApplicationContext; +import fr.ird.t3.entities.T3TopiaPersistenceContext; +import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertor; +import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorFOR_OABI; +import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorFOR_OABL; +import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorFOR_OABO; +import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorFOR_OIBI; +import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorFOR_OIBL; +import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorFOR_OIBO; +import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorFOR_OPBI; +import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorFOR_OPBL; +import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorFOR_OPBO; +import fr.ird.t3.entities.conversion.WeightCategoryLogBookConvertorProvider; +import fr.ird.t3.entities.reference.Ocean; +import fr.ird.t3.entities.reference.OceanTopiaDao; +import fr.ird.t3.entities.reference.SchoolType; +import fr.ird.t3.entities.reference.SchoolTypeTopiaDao; +import fr.ird.t3.entities.reference.Species; +import fr.ird.t3.entities.reference.SpeciesTopiaDao; +import fr.ird.t3.entities.reference.WeightCategoryLogBookConversion; +import fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies; +import fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpeciesImpl; +import fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpeciesTopiaDao; +import fr.ird.t3.entities.reference.WeightCategoryLogBookConversionTopiaDao; +import fr.ird.t3.entities.reference.WeightCategoryTreatment; +import fr.ird.t3.entities.reference.WeightCategoryTreatmentTopiaDao; import fr.ird.t3.entities.user.JdbcConfiguration; import fr.ird.t3.entities.user.JdbcConfigurationHelper; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; +import org.nuiton.topia.persistence.BeanTopiaConfiguration; +import org.nuiton.topia.persistence.TopiaEntity; +import org.nuiton.topia.persistence.internal.LegacyTopiaIdFactory; +import org.nuiton.util.DateUtil; + +import java.util.Collections; +import java.util.Date; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; /** * Created by tchemit on 20/02/2018. @@ -36,6 +74,11 @@ import org.junit.Test; @Ignore public class T3MigrationTest { + private int count = 0; + private SpeciesTopiaDao speciesDao; + private WeightCategoryLogBookConversionTopiaDao weightCategoryLogBookConversionDao; + private WeightCategoryLogBookConversionSpeciesTopiaDao weightCategoryLogBookConversionSpeciesDao; + @Test public void migratePostgres() { @@ -52,4 +95,159 @@ public class T3MigrationTest { } } + + @Test + public void generateWeightCategoryLogBookConversions() { + + String url = "jdbc:postgresql:t3"; + String login = "t3-admin"; + String password = "a"; + + JdbcConfiguration jdbcConfiguration = JdbcConfigurationHelper.newJdbcConfiguration(); + jdbcConfiguration.setUrl(url); + jdbcConfiguration.setLogin(login); + jdbcConfiguration.setPassword(password); + try (T3TopiaApplicationContext rootContext = T3TopiaApplicationContext.newDb(jdbcConfiguration)) { + + ((BeanTopiaConfiguration) rootContext.getConfiguration()).setTopiaIdFactory(new LegacyTopiaIdFactory() { + + @Override + public <E extends TopiaEntity> String newTopiaId(Class<E> entityClass, TopiaEntity topiaEntity) { + return entityClass.getName() + "#1519311532526#0" + count++; + } + }); + + try (T3TopiaPersistenceContext persistenceContext = rootContext.newPersistenceContext()) { + + WeightCategoryLogBookConvertorProvider convertorProvider = WeightCategoryLogBookConvertorProvider.newInstance(persistenceContext); + + OceanTopiaDao oceanDao = persistenceContext.getOceanDao(); + speciesDao = persistenceContext.getSpeciesDao(); + SchoolTypeTopiaDao schoolTypeDao = persistenceContext.getSchoolTypeDao(); + WeightCategoryTreatmentTopiaDao weightCategoryTreatmentDao = persistenceContext.getWeightCategoryTreatmentDao(); + weightCategoryLogBookConversionDao = persistenceContext.getWeightCategoryLogBookConversionDao(); + weightCategoryLogBookConversionSpeciesDao = persistenceContext.getWeightCategoryLogBookConversionSpeciesDao(); + + weightCategoryLogBookConversionDao.deleteAll(weightCategoryLogBookConversionDao.findAll()); + persistenceContext.getHibernateSupport().getHibernateSession().flush(); + + Date beginDate = DateUtil.createDate(1, 1, 1970); + + Ocean oceanA = oceanDao.forCodeEquals(1).findUnique(); + Ocean oceanI = oceanDao.forCodeEquals(2).findUnique(); + Ocean oceanP = oceanDao.forCodeEquals(5).findUnique(); + SchoolType schoolTypeBo = schoolTypeDao.forCodeEquals(1).findUnique(); + SchoolType schoolTypeBl = schoolTypeDao.forCodeEquals(2).findUnique(); + SchoolType schoolTypeBi = schoolTypeDao.forCodeEquals(3).findUnique(); + + String version = "1.0"; + + this.count = 0; + + // OA + WeightCategoryLogBookConversion oaBi = addConversion(version, beginDate, oceanA, schoolTypeBi); + WeightCategoryLogBookConversion oaBo = addConversion(version, beginDate, oceanA, schoolTypeBo); + WeightCategoryLogBookConversion oaBl = addConversion(version, beginDate, oceanA, schoolTypeBl); + + // OI + WeightCategoryLogBookConversion oiBi = addConversion(version, beginDate, oceanI, schoolTypeBi); + WeightCategoryLogBookConversion oiBo = addConversion(version, beginDate, oceanI, schoolTypeBo); + WeightCategoryLogBookConversion oiBl = addConversion(version, beginDate, oceanI, schoolTypeBl); + + // OP + WeightCategoryLogBookConversion opBi = addConversion(version, beginDate, oceanP, schoolTypeBi); + WeightCategoryLogBookConversion opBo = addConversion(version, beginDate, oceanP, schoolTypeBo); + WeightCategoryLogBookConversion opBl = addConversion(version, beginDate, oceanP, schoolTypeBl); + + persistenceContext.commit(); + + this.count = 0; + + //OA + { + WeightCategoryLogBookConvertorFOR_OABI convertor = getConvertor(convertorProvider, oaBi, WeightCategoryLogBookConvertorFOR_OABI.class); + addEmptyConversionSpecies(oaBi, convertor.getUnkownCategory()); + addEmptyConversionSpecies(oaBi, convertor.getMinus10Category(), 2); + addConversionSpecies(oaBi, convertor, 1, 3, 4); + } + { + WeightCategoryLogBookConvertorFOR_OABO convertor = getConvertor(convertorProvider, oaBo, WeightCategoryLogBookConvertorFOR_OABO.class); + addEmptyConversionSpecies(oaBo, convertor.getUnkownCategory()); + addEmptyConversionSpecies(oaBo, convertor.getMinus10Category(), 2); + addConversionSpecies(oaBo, convertor, 1, 3, 4); + } + { + WeightCategoryLogBookConvertorFOR_OABL convertor = getConvertor(convertorProvider, oaBl, WeightCategoryLogBookConvertorFOR_OABL.class); + addEmptyConversionSpecies(oaBl, convertor.getUnkownCategory()); + addEmptyConversionSpecies(oaBl, convertor.getMinus10Category(), 2); + addConversionSpecies(oaBl, convertor, 1, 3, 4); + } + //OI + { + WeightCategoryLogBookConvertorFOR_OIBI convertor = getConvertor(convertorProvider, oiBi, WeightCategoryLogBookConvertorFOR_OIBI.class); + addEmptyConversionSpecies(oiBi, convertor.getUnkownCategory()); + addEmptyConversionSpecies(oiBi, convertor.getMinus10Category(), 2); + addConversionSpecies(oiBi, convertor, 1, 3, 4); + } + { + WeightCategoryLogBookConvertorFOR_OIBO convertor = getConvertor(convertorProvider, oiBo, WeightCategoryLogBookConvertorFOR_OIBO.class); + addEmptyConversionSpecies(oiBo, convertor.getUnkownCategory()); + addEmptyConversionSpecies(oiBo, convertor.getMinus10Category(), 2); + addConversionSpecies(oiBo, convertor, 1, 3, 4); + } + { + WeightCategoryLogBookConvertorFOR_OIBL convertor = getConvertor(convertorProvider, oiBl, WeightCategoryLogBookConvertorFOR_OIBL.class); + addEmptyConversionSpecies(oiBl, convertor.getUnkownCategory()); + addEmptyConversionSpecies(oiBl, convertor.getMinus10Category(), 2); + addConversionSpecies(oaBl, convertor, 1, 3, 4); + } + //OP + { + WeightCategoryLogBookConvertorFOR_OPBI convertor = getConvertor(convertorProvider, opBi, WeightCategoryLogBookConvertorFOR_OPBI.class); + addEmptyConversionSpecies(opBi, convertor.getUnkownCategory()); + addEmptyConversionSpecies(opBi, convertor.getMinus10Category(), 2); + addConversionSpecies(opBi, convertor, 1, 3, 4); + } + { + WeightCategoryLogBookConvertorFOR_OPBO convertor = getConvertor(convertorProvider, opBo, WeightCategoryLogBookConvertorFOR_OPBO.class); + addEmptyConversionSpecies(opBo, convertor.getUnkownCategory()); + addEmptyConversionSpecies(opBo, convertor.getMinus10Category(), 2); + addConversionSpecies(opBo, convertor, 1, 3, 4); + } + { + WeightCategoryLogBookConvertorFOR_OPBL convertor = getConvertor(convertorProvider, opBl, WeightCategoryLogBookConvertorFOR_OPBL.class); + addEmptyConversionSpecies(opBl, convertor.getUnkownCategory()); + addEmptyConversionSpecies(opBl, convertor.getMinus10Category(), 2); + addConversionSpecies(opBl, convertor, 1, 3, 4); + } + persistenceContext.commit(); + } + } + } + + private void addConversionSpecies(WeightCategoryLogBookConversion conversion, WeightCategoryLogBookConvertor convertor, Integer... speciesCode) { + List<Species> species = speciesDao.forCodeIn(Stream.of(speciesCode).collect(Collectors.toSet())).findAll(); + Map<String, Map<Integer, Float>> distributionsToSave = convertor.getDistributionsByIds(); + WeightCategoryLogBookConversionSpecies conversionSpecies = weightCategoryLogBookConversionSpeciesDao.createByNotNull(WeightCategoryLogBookConversionSpeciesImpl.toString(distributionsToSave), conversion); + conversionSpecies.setSpecies(new HashSet<>(species)); + conversion.addDistributions(conversionSpecies); + } + + private void addEmptyConversionSpecies(WeightCategoryLogBookConversion conversion, WeightCategoryTreatment weightCategoryTreatment, Integer... speciesCode) { + List<Species> species = speciesDao.forCodeIn(Stream.of(speciesCode).collect(Collectors.toSet())).findAll(); + Map<String, Map<Integer, Float>> distributionsToSave = new LinkedHashMap<>(); + distributionsToSave.put(weightCategoryTreatment.getTopiaId(), Collections.emptyMap()); + WeightCategoryLogBookConversionSpecies conversionSpecies = weightCategoryLogBookConversionSpeciesDao.createByNotNull(WeightCategoryLogBookConversionSpeciesImpl.toString(distributionsToSave), conversion); + conversionSpecies.setSpecies(new HashSet<>(species)); + conversion.addDistributions(conversionSpecies); + } + + + private <C extends WeightCategoryLogBookConvertor> C getConvertor(WeightCategoryLogBookConvertorProvider convertorProvider, WeightCategoryLogBookConversion conversion, Class<C> convertorType) { + return convertorType.cast(convertorProvider.getConvertor(conversion.getOcean(), conversion.getSchoolType())); + } + + private WeightCategoryLogBookConversion addConversion(String version, Date beginDate, Ocean ocean, SchoolType schoolType) { + return weightCategoryLogBookConversionDao.createByNotNull(version, beginDate, ocean, schoolType); + } } ===================================== t3-installer/pom.xml ===================================== --- a/t3-installer/pom.xml +++ b/t3-installer/pom.xml @@ -258,6 +258,16 @@ <fromFile>t3-data-${t3-data.version}-zones.zip</fromFile> </configuration> </execution> + <execution> + <id>get-h2-files</id> + <phase>prepare-package</phase> + <goals> + <goal>download-single</goal> + </goals> + <configuration> + <fromFile>t3-data-${t3-data.version}-h2.zip</fromFile> + </configuration> + </execution> </executions> </plugin> @@ -272,6 +282,7 @@ <unzip src="${explodedDataDirection}/t3-data-${t3-data.version}-ddl.zip" dest="${explodedDataDirection}" /> <unzip src="${explodedDataDirection}/t3-data-${t3-data.version}-referential.zip" dest="${explodedDataDirection}" /> <unzip src="${explodedDataDirection}/t3-data-${t3-data.version}-zones.zip" dest="${explodedDataDirection}" /> + <unzip src="${explodedDataDirection}/t3-data-${t3-data.version}-h2.zip" dest="${explodedDataDirection}" /> </tasks> </configuration> <goals> ===================================== t3-installer/src/main/assembly/bin.xml ===================================== --- a/t3-installer/src/main/assembly/bin.xml +++ b/t3-installer/src/main/assembly/bin.xml @@ -82,6 +82,14 @@ </fileSet> <fileSet> + <directory>${explodedDataDirection}/t3-data-h2-${t3-data.version}</directory> + <outputDirectory>scripts/h2</outputDirectory> + <includes> + <include>**/*</include> + </includes> + </fileSet> + + <fileSet> <directory>src/main/assembly/dist</directory> <outputDirectory/> <includes> ===================================== t3-test/src/main/java/fr/ird/t3/FakeT3ServiceContext.java ===================================== --- a/t3-test/src/main/java/fr/ird/t3/FakeT3ServiceContext.java +++ b/t3-test/src/main/java/fr/ird/t3/FakeT3ServiceContext.java @@ -21,6 +21,7 @@ package fr.ird.t3; import fr.ird.t3.entities.T3EntityHelper; +import fr.ird.t3.entities.T3JdbcHelper; import fr.ird.t3.entities.T3TopiaApplicationContext; import fr.ird.t3.entities.T3TopiaPersistenceContext; import fr.ird.t3.entities.T3UserTopiaApplicationContext; @@ -28,13 +29,6 @@ import fr.ird.t3.entities.T3UserTopiaPersistenceContext; import fr.ird.t3.services.T3Service; import fr.ird.t3.services.T3ServiceContext; import fr.ird.t3.services.T3ServiceFactory; -import java.io.Closeable; -import java.io.File; -import java.io.IOException; -import java.util.Date; -import java.util.Locale; -import java.util.Properties; -import java.util.function.Supplier; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.rules.TestWatcher; @@ -44,6 +38,13 @@ import org.nuiton.topia.persistence.TopiaException; import org.nuiton.util.FileUtil; import org.nuiton.version.Version; +import java.io.Closeable; +import java.io.File; +import java.util.Date; +import java.util.Locale; +import java.util.Properties; +import java.util.function.Supplier; + /** * TODO * @@ -91,26 +92,6 @@ public class FakeT3ServiceContext extends TestWatcher implements T3ServiceContex Properties defaultProps = new Properties(); defaultProps.put(T3ConfigOption.DATA_DIRECTORY.getKey(), testDir); -// applicationConfiguration = new T3Config(defaultProps); -// try { -// -// // where to put h2 database -// File dbDirectory = new File(testDir, "h2-database"); -// -// rootContext = T3TopiaApplicationContext.newEmbeddedDb(dbDirectory); -// -// initOk = true; -// } catch (Exception e) { -// initOk = false; -// throw new IllegalStateException("Could not strat db", e); -// } -// -// testDir = T3IOUtil.getTestSpecificDirectory(description.getTestClass(), -// description.getMethodName()); -// if (log.isInfoEnabled()) { -// log.info("Test dir = " + testDir); -// } -// File treatmentDirectory = new File(testDir, "treatment"); FileUtil.createDirectoryIfNecessary(treatmentDirectory); @@ -128,19 +109,28 @@ public class FakeT3ServiceContext extends TestWatcher implements T3ServiceContex Mockito.when(applicationConfiguration.getTreatmentWorkingDirectory()).thenReturn(treatmentDirectory); Mockito.when(applicationConfiguration.getT3DataVersion()).thenReturn(t3DataVersion); Mockito.when(applicationConfiguration.getTreatmentWorkingDirectory(Mockito.anyString(), Mockito.anyBoolean())).thenCallRealMethod(); + Mockito.when(applicationConfiguration.getApplicationVersion()).thenReturn(realConfiguration.getApplicationVersion()); try { // where to put h2 database File dbDirectory = new File(testDir, "h2-database"); - rootContext = T3TopiaApplicationContext.newEmbeddedDb(dbDirectory); - if (injectReferential) { - // inject in db the referentiel - T3SqlScriptsImporter.importReferential(new File(""), this, T3SqlScriptsImporter.SKIP_SPECIES_LENGTH_STEP_FILE); - + File scriptsDirectory = T3JdbcHelper.getScriptsDirectory(new File(""), "h2", t3DataVersion); + + String[] list = scriptsDirectory.list((dir, name) -> name.endsWith(".sql") && name.contains("-referential")); + if (list == null || list.length != 1) { + throw new IllegalStateException(String.format("Can't find h2 referential db from %s", scriptsDirectory)); + } + rootContext = T3TopiaApplicationContext.newEmbeddedBackupDb(dbDirectory, scriptsDirectory.toPath().resolve(list[0]).toFile()); + } else { + rootContext = T3TopiaApplicationContext.newEmbeddedDb(dbDirectory); } +// if (injectReferential) { +// // inject in db the referentiel +// T3SqlScriptsImporter.importReferential(new File(""), this, T3SqlScriptsImporter.SKIP_SPECIES_LENGTH_STEP_FILE); +// } initOk = true; } catch (Exception e) { @@ -233,7 +223,7 @@ public class FakeT3ServiceContext extends TestWatcher implements T3ServiceContex } @Override - public void close() throws IOException { + public void close() { if (transaction != null) { transaction.close(); } ===================================== t3-test/src/main/resources/t3-TopiaContextImpl.properties ===================================== --- a/t3-test/src/main/resources/t3-TopiaContextImpl.properties +++ b/t3-test/src/main/resources/t3-TopiaContextImpl.properties @@ -19,12 +19,23 @@ # #L% ### -# Proprietes par defaut pour une base de donnees de type H2 +# DB configuration +#hibernate.dialect=org.hibernate.dialect.H2Dialect +hibernate.connection.driver_class=org.h2.Driver +hibernate.connection.provider_class=org.hibernate.hikaricp.internal.HikariCPConnectionProvider hibernate.show_sql=false - -hibernate.dialect=org.hibernate.dialect.H2Dialect +hibernate.format_sql=false +hibernate.use_sql_comments=false hibernate.connection.username=sa -hibernate.connection.password= -hibernate.connection.driver_class=org.h2.Driver -# tchemit 2010-11-28 : comment this line, each test must define his own db path -#hibernate.connection.url=jdbc:h2:file:target/surefire-workdir/h2data +hibernate.connection.password=sa +hibernate.hikari.minimumIdle=2 +hibernate.hikari.maximumPoolSize=20 +hibernate.hikari.autoCommit=false +hibernate.hikari.registerMbeans=true + +# Migration configuration +#topia.service.migration=org.nuiton.topia.migration.TopiaMigrationEngine +#topia.service.migration.callback=fr.ird.t3.services.migration.T3MigrationCallback +#topia.service.migration.showSql=true +#topia.service.migration.showProgression=true +#topia.persistence.topiaIdFactoryClassName=org.nuiton.topia.persistence.internal.LegacyTopiaIdFactory ===================================== t3/.mvn/deploy ===================================== --- /dev/null +++ b/t3/.mvn/deploy View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/compare/a47953868daef6f68a03c362b86e11a1... --- View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/compare/a47953868daef6f68a03c362b86e11a1... You're receiving this email because of your account on gitlab.com.