T3-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- 424 discussions
[Git][ultreiaio/ird-t3][develop] 2 commits: [N0.3] Rendre la conversion des catégories de poids AVDTH->T3 générique (Mise en…
by Tony CHEMIT 23 Feb '18
by Tony CHEMIT 23 Feb '18
23 Feb '18
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(a)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/a47953868daef6f68a03c362b86e11a…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/compare/a47953868daef6f68a03c362b86e11a…
You're receiving this email because of your account on gitlab.com.
1
0
[Git][ultreiaio/ird-t3][develop] [N0.3] Rendre la conversion des catégories de poids AVDTH->T3 générique (Mise en…
by Tony CHEMIT 22 Feb '18
by Tony CHEMIT 22 Feb '18
22 Feb '18
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
a4795386 by Tony CHEMIT at 2018-02-22T21:50:48+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)
- - - - -
15 changed files:
- t3-domain/pom.xml
- 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
Changes:
=====================================
t3-domain/pom.xml
=====================================
--- a/t3-domain/pom.xml
+++ b/t3-domain/pom.xml
@@ -107,6 +107,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/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 weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#00', 1, '2018-02-22 21:36:22.566000', '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 weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#01', 1, '2018-02-22 21:36:22.636000', '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 weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#02', 1, '2018-02-22 21:36:22.637000', '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 weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#03', 1, '2018-02-22 21:36:22.638000', '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 weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#04', 1, '2018-02-22 21:36:22.638000', '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 weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#05', 1, '2018-02-22 21:36:22.639000', '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 weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#06', 1, '2018-02-22 21:36:22.642000', '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 weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#07', 1, '2018-02-22 21:36:22.645000', '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 weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#08', 1, '2018-02-22 21:36:22.645000', '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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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_
@@ -34,6 +33,13 @@ 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.WeightCategoryLogBookConversion.attribute.distributions.stereotype=ordered
+fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies.attribute.distribution.tagValue.sqlType=text
+fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies.attribute.species.stereotype=unique
+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
@@ -122,6 +128,21 @@ fr.ird.t3.entities.reference.LengthWeightConversion.attribute.sexe.tagValue.notN
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.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.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
+
+fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies.attribute.distribution.tagValue.notNull=true
+fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies.attribute.parent.tagValue.notNull=true
+fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies.class.tagValue.naturalIdMutable=false
+fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies.attribute.parent.tagValue.naturalId=true
+
###############################################################################
### Natural id for data ######################################################
###############################################################################
=====================================
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);
+ }
}
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/a47953868daef6f68a03c362b86e11a1…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/a47953868daef6f68a03c362b86e11a1…
You're receiving this email because of your account on gitlab.com.
1
0
22 Feb '18
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
dc65837f by Tony CHEMIT at 2018-02-22T15:32:40+01:00
improve test config
- - - - -
16b45393 by Tony CHEMIT at 2018-02-22T21:49:04+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)
- - - - -
16 changed files:
- pom.xml
- t3-domain/pom.xml
- 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
Changes:
=====================================
pom.xml
=====================================
--- a/pom.xml
+++ b/pom.xml
@@ -431,6 +431,10 @@
<file>
<exists>.mvn/load-test-data</exists>
</file>
+ <property>
+ <name>skipTests</name>
+ <value>!true</value>
+ </property>
</activation>
<build>
=====================================
t3-domain/pom.xml
=====================================
--- a/t3-domain/pom.xml
+++ b/t3-domain/pom.xml
@@ -107,6 +107,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/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 weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#00', 1, '2018-02-22 21:36:22.566000', '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 weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#01', 1, '2018-02-22 21:36:22.636000', '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 weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#02', 1, '2018-02-22 21:36:22.637000', '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 weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#03', 1, '2018-02-22 21:36:22.638000', '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 weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#04', 1, '2018-02-22 21:36:22.638000', '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 weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#05', 1, '2018-02-22 21:36:22.639000', '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 weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#06', 1, '2018-02-22 21:36:22.642000', '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 weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#07', 1, '2018-02-22 21:36:22.645000', '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 weightcategorylogbookconversion (topiaid, topiaversion, topiacreatedate, ocean, schooltype, version, begindate, enddate) VALUES ('fr.ird.t3.entities.reference.WeightCategoryLogBookConversion#1519311532526#08', 1, '2018-02-22 21:36:22.645000', '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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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_
@@ -34,6 +33,13 @@ 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.WeightCategoryLogBookConversion.attribute.distributions.stereotype=ordered
+fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies.attribute.distribution.tagValue.sqlType=text
+fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies.attribute.species.stereotype=unique
+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
@@ -122,6 +128,21 @@ fr.ird.t3.entities.reference.LengthWeightConversion.attribute.sexe.tagValue.notN
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.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.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
+
+fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies.attribute.distribution.tagValue.notNull=true
+fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies.attribute.parent.tagValue.notNull=true
+fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies.class.tagValue.naturalIdMutable=false
+fr.ird.t3.entities.reference.WeightCategoryLogBookConversionSpecies.attribute.parent.tagValue.naturalId=true
+
###############################################################################
### Natural id for data ######################################################
###############################################################################
=====================================
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);
+ }
}
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/compare/ea4a2e79d10126ad158b77d01c53793…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/compare/ea4a2e79d10126ad158b77d01c53793…
You're receiving this email because of your account on gitlab.com.
1
0
[Git][ultreiaio/ird-t3][develop] [N2][N3] Gestion des catégories de poids -10/+10kg dans la stratification N2 et…
by Tony CHEMIT 21 Feb '18
by Tony CHEMIT 21 Feb '18
21 Feb '18
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
ea4a2e79 by Tony CHEMIT at 2018-02-21T20:14:49+01:00
[N2][N3] Gestion des catégories de poids -10/+10kg dans la stratification N2 et N3 (Mise en place du lancement d'une action (reste à gerer ça au sein des strates) (See #263)
- - - - -
8 changed files:
- t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2CatchStratum.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2SampleStratum.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level2/Level2Action.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3CatchStratum.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3SampleStratum.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level3/Level3Action.java
- t3-domain/src/main/java/fr/ird/t3/actions/stratum/Stratum.java
- t3-domain/src/main/java/fr/ird/t3/actions/stratum/StratumConfiguration.java
Changes:
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2CatchStratum.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2CatchStratum.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2CatchStratum.java
@@ -133,9 +133,7 @@ public class L2CatchStratum extends CatchStratum<Level2Configuration, Level2Acti
Integer nbZones = e.getValue();
if (!activity.isCorrectedElementaryCatchEmpty()) {
- for (CorrectedElementaryCatch aCatch :
- activity.getCorrectedElementaryCatch()) {
-
+ for (CorrectedElementaryCatch aCatch : activity.getCorrectedElementaryCatch()) {
weightCategoriesForSpecies.put(aCatch.getWeightCategoryTreatment(), aCatch.getSpecies());
}
}
@@ -155,8 +153,7 @@ public class L2CatchStratum extends CatchStratum<Level2Configuration, Level2Acti
}
}
- inputModelForSpeciesToFix =
- inputModelForAllSpecies.extractForSpecies(getSpeciesToFix());
+ inputModelForSpeciesToFix = inputModelForAllSpecies.extractForSpecies(getSpeciesToFix());
}
public int getNbActivitiesWithSample() {
@@ -225,12 +222,10 @@ public class L2CatchStratum extends CatchStratum<Level2Configuration, Level2Acti
}
public void mergeGlobalCompositionModels(WeightCompositionAggregateModel inputModel, WeightCompositionAggregateModel outputModel) {
-
inputModel.addModel(inputModelForAllSpecies);
outputModel.addModel(outputModelForAllSpecies);
}
-
@Override
protected CatchStratumLoader<Level2Configuration> newLoader() {
return new L2CatchStratumLoader();
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2SampleStratum.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2SampleStratum.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2SampleStratum.java
@@ -145,8 +145,7 @@ public class L2SampleStratum extends SampleStratum<Level2Configuration, Level2Ac
ActivityTopiaDao.fillWeightsFromSetSpeciesCatWeight(activity, weights, null);
// obtain the set species frequencies for the current activity
- Collection<SetSpeciesFrequency> setSpeciesFrequencies =
- activity.getSetSpeciesFrequency();
+ Collection<SetSpeciesFrequency> setSpeciesFrequencies = activity.getSetSpeciesFrequency();
if (CollectionUtils.isNotEmpty(setSpeciesFrequencies)) {
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level2/Level2Action.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level2/Level2Action.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level2/Level2Action.java
@@ -25,7 +25,6 @@ import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Multimap;
-import com.google.common.collect.Sets;
import fr.ird.t3.actions.T3Action;
import fr.ird.t3.actions.stratum.OceanContext;
import fr.ird.t3.actions.stratum.StratumConfiguration;
@@ -54,6 +53,7 @@ import fr.ird.t3.services.ioc.InjectDAO;
import fr.ird.t3.services.ioc.InjectEntitiesById;
import fr.ird.t3.services.ioc.InjectFromDAO;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.mutable.MutableInt;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.persistence.TopiaException;
@@ -82,7 +82,6 @@ import static org.nuiton.i18n.I18n.l;
*/
public class Level2Action extends T3Action<Level2Configuration> {
- // public static final String PARAM_LEVEL_CONFIGURATION = "levelConfiguration";
private static final Log log = LogFactory.getLog(Level2Action.class);
/**
* Cache of activity (to avoid to reload them for catch and sample stratum).
@@ -211,72 +210,119 @@ public class Level2Action extends T3Action<Level2Configuration> {
Level2Configuration configuration = getConfiguration();
- // get time step
- int timeStep = configuration.getTimeStep();
+ // keep a track of already used activity ids (to remove previous level 2 data)
+ Set<String> usedActivityIds = new HashSet<>();
+
+ boolean useWeightCategoriesInStratum = configuration.isUseWeightCategoriesInStratum();
-// nbStratums = zoneBySchoolType.size() * startDates.size();
- nbStratums = oceanContext.values().stream().mapToInt(OceanContext::sizeZones).sum() * startDates.size();
+ if (useWeightCategoriesInStratum) {
+ executeActionWithCategories(configuration, usedActivityIds);
+ } else {
+ executeActionWithoutCategories(configuration, usedActivityIds);
+ }
+ return true;
+ }
+
+ private void executeActionWithCategories(Level2Configuration configuration, Set<String> usedActivityIds) throws Exception {
+
+ nbStratums = 0;
+ for (SchoolType schoolType : schoolTypes) {
+ List<WeightCategoryTreatment> weightCategories = getWeightCategoryTreatments(schoolType);
+ Collection<ZoneStratumAware> zones = getZones(schoolType);
+ nbStratums += startDates.size() * zones.size() * weightCategories.size();
+ }
setNbSteps(3 * nbStratums);
- // keep a track of alreay used activity ids (to remove previous level 2 data)
- Set<String> usedActivityIds = new HashSet<>();
+ int timeStep = configuration.getTimeStep();
- int stratumIndex = 1;
+ MutableInt stratumIndex = new MutableInt(1);
for (SchoolType schoolType : schoolTypes) {
+ List<WeightCategoryTreatment> weightCategories = getWeightCategoryTreatments(schoolType);
+ Collection<ZoneStratumAware> zones = getZones(schoolType);
+ for (ZoneStratumAware zone : zones) {
+ for (WeightCategoryTreatment weightCategory : weightCategories) {
+ doIterateOnDates(timeStep, configuration, schoolType, zones, zone, weightCategories, weightCategory, usedActivityIds, stratumIndex);
+ }
+ }
+ }
+ }
+
+
+ private void executeActionWithoutCategories(Level2Configuration configuration, Set<String> usedActivityIds) throws Exception {
- // get all weight categories for this school type
-// List<WeightCategoryTreatment> weightCategories = Lists.newArrayList(weightCategoriesBySchoolType.get(schoolType));
- List<WeightCategoryTreatment> weightCategories = oceanContext.values().stream().flatMap(o -> o.getWeightCategories(schoolType).stream()).distinct().collect(Collectors.toList());
- weightCategoryTreatmentDAO.sort(weightCategories);
+ nbStratums = 0;
+ for (SchoolType schoolType : schoolTypes) {
+ Collection<ZoneStratumAware> zones = getZones(schoolType);
+ nbStratums += startDates.size() * zones.size();
+ }
+ setNbSteps(3 * nbStratums);
- // get all zones for this school type
-// Collection<ZoneStratumAware> zones = zoneBySchoolType.get(schoolType);
- Collection<ZoneStratumAware> zones = oceanContext.values().stream().flatMap(o -> o.getZones(schoolType).stream()).distinct().collect(Collectors.toList());
+ int timeStep = configuration.getTimeStep();
+ MutableInt stratumIndex = new MutableInt(1);
+ for (SchoolType schoolType : schoolTypes) {
+ List<WeightCategoryTreatment> weightCategories = getWeightCategoryTreatments(schoolType);
+ Collection<ZoneStratumAware> zones = getZones(schoolType);
for (ZoneStratumAware zone : zones) {
+ doIterateOnDates(timeStep, configuration, schoolType, zones, zone, weightCategories, null, usedActivityIds, stratumIndex);
+ }
+ }
- for (T3Date startDate : startDates) {
-
- // get end date (only increments on timseStep - 1 to have
- // exactly timstep month from beginDate.toStartDate() to
- // endDate.toEndDate()
- T3Date endDate = startDate.incrementsMonths(timeStep - 1);
-
- StratumConfiguration<Level2Configuration>
- stratumConfiguration =
- StratumConfiguration.newStratumConfiguration(
- configuration,
- zoneMeta,
- zone,
- schoolType,
- startDate,
- endDate,
- zones,
- possibleCatchVessels,
- possibleSampleVessels,
- null,
- activityCache
- );
-
- try {
- L2StratumResult result = doExecuteStratum(stratumConfiguration, weightCategories, stratumIndex, usedActivityIds);
-
- stratumsResult.add(result);
- } finally {
- flushTransaction("After stratum " + stratumIndex);
- }
+ }
- stratumIndex++;
- }
+ private List<WeightCategoryTreatment> getWeightCategoryTreatments(SchoolType schoolType) {
+ List<WeightCategoryTreatment> weightCategoryTreatments = oceanContext.values().stream().flatMap(o -> o.getWeightCategories(schoolType).stream()).distinct().collect(Collectors.toList());
+ weightCategoryTreatmentDAO.sort(weightCategoryTreatments);
+ return weightCategoryTreatments;
+ }
+
+ private Collection<ZoneStratumAware> getZones(SchoolType schoolType) {
+ return oceanContext.values().stream().flatMap(o -> o.getZones(schoolType).stream()).distinct().collect(Collectors.toList());
+ }
+
+ private void doIterateOnDates(int timeStep, Level2Configuration configuration, SchoolType schoolType, Collection<ZoneStratumAware> zones, ZoneStratumAware zone, List<WeightCategoryTreatment> weightCategories, WeightCategoryTreatment weightCategoryTreatment, Set<String> usedActivityIds, MutableInt stratumIndex) throws Exception {
+
+ for (T3Date startDate : startDates) {
+
+ // get end date (only increments on timseStep - 1 to have
+ // exactly timstep month from beginDate.toStartDate() to
+ // endDate.toEndDate()
+ T3Date endDate = startDate.incrementsMonths(timeStep - 1);
+
+ StratumConfiguration<Level2Configuration>
+ stratumConfiguration =
+ StratumConfiguration.newStratumConfiguration(
+ configuration,
+ zoneMeta,
+ zone,
+ schoolType,
+ weightCategoryTreatment,
+ startDate,
+ endDate,
+ zones,
+ possibleCatchVessels,
+ possibleSampleVessels,
+ null,
+ activityCache
+ );
+
+ try {
+ L2StratumResult result = doExecuteStratum(stratumConfiguration, weightCategories, stratumIndex, usedActivityIds);
+
+ stratumsResult.add(result);
+ } finally {
+ flushTransaction("After stratum " + stratumIndex);
}
+
+ stratumIndex.increment();
}
- return true;
+
}
- protected L2StratumResult doExecuteStratum(
+ private L2StratumResult doExecuteStratum(
StratumConfiguration<Level2Configuration> stratumConfiguration,
List<WeightCategoryTreatment> weightCategories,
- int stratumIndex,
+ MutableInt stratumIndex,
Set<String> usedActivityIds) throws Exception {
incrementsProgression();
@@ -353,7 +399,7 @@ public class Level2Action extends T3Action<Level2Configuration> {
// Fill back CorrectedElementaryCatch.CatchWeight to CorrectedElementaryCatch.CorrectedCatchWeight
int activityIndex = 1;
- int nbActivites = catchStratum.getNbActivities();
+ int nbActivities = catchStratum.getNbActivities();
for (Map.Entry<Activity, Integer> e : catchStratum) {
Activity activity = e.getKey();
@@ -366,7 +412,7 @@ public class Level2Action extends T3Action<Level2Configuration> {
doExecuteActivityInCatchStratum(catchStratum,
activity,
activityIndex++,
- nbActivites,
+ nbActivities,
newActivity);
// keep the stratum substitution level in the activity
@@ -380,7 +426,7 @@ public class Level2Action extends T3Action<Level2Configuration> {
// can use this sampleStratum
int activityIndex = 1;
- int nbActivites = catchStratum.getNbActivities();
+ int nbActivities = catchStratum.getNbActivities();
for (Map.Entry<Activity, Integer> e : catchStratum) {
Activity activity = e.getKey();
@@ -395,7 +441,7 @@ public class Level2Action extends T3Action<Level2Configuration> {
activity,
nbZones,
activityIndex++,
- nbActivites,
+ nbActivities,
newActivity);
// keep the stratum substitution level in the activity
@@ -432,8 +478,8 @@ public class Level2Action extends T3Action<Level2Configuration> {
return result;
}
- protected L2CatchStratum newCatchStratum(StratumConfiguration<Level2Configuration> stratumConfiguration,
- List<WeightCategoryTreatment> weightCategories) throws Exception {
+ private L2CatchStratum newCatchStratum(StratumConfiguration<Level2Configuration> stratumConfiguration,
+ List<WeightCategoryTreatment> weightCategories) throws Exception {
L2CatchStratum catchStratum = new L2CatchStratum(stratumConfiguration, species);
catchStratum.init(serviceContext, weightCategories, this);
@@ -463,26 +509,25 @@ public class Level2Action extends T3Action<Level2Configuration> {
return catchStratum;
}
- protected L2SampleStratum newSampleStratum(StratumConfiguration<Level2Configuration> stratumConfiguration,
- List<WeightCategoryTreatment> weightCategories,
- float totalCatchWeight) throws Exception {
+ private L2SampleStratum newSampleStratum(StratumConfiguration<Level2Configuration> stratumConfiguration,
+ List<WeightCategoryTreatment> weightCategories,
+ float totalCatchWeight) throws Exception {
L2SampleStratum sampleStratum = new L2SampleStratum(stratumConfiguration, species, totalCatchWeight);
sampleStratum.init(serviceContext, weightCategories, this);
return sampleStratum;
}
- protected void doExecuteActivityInCatchStratum(L2CatchStratum catchStratum,
- L2SampleStratum sampleStratum,
- Activity activity,
- int nbZones,
- int activityIndex,
- int nbActivites,
- boolean deleteOldData) throws TopiaException, IOException {
+ private void doExecuteActivityInCatchStratum(L2CatchStratum catchStratum,
+ L2SampleStratum sampleStratum,
+ Activity activity,
+ int nbZones,
+ int activityIndex,
+ int nbActivities,
+ boolean deleteOldData) throws TopiaException, IOException {
- String activityStr = String.format("%s (%s)", decorate(activity), decorate(activity.getTrip(),
- DecoratorService.WITH_ID));
+ String activityStr = String.format("%s (%s)", decorate(activity), decorate(activity.getTrip(), DecoratorService.WITH_ID));
- String message = l(locale, "t3.level2.message.start.activity", activityIndex, nbActivites, activityStr, nbZones);
+ String message = l(locale, "t3.level2.message.start.activity", activityIndex, nbActivities, activityStr, nbZones);
if (log.isInfoEnabled()) {
log.info(message);
}
@@ -503,7 +548,6 @@ public class Level2Action extends T3Action<Level2Configuration> {
WeightCompositionAggregateModel catchWeightModelForSpeciesToFix = catchWeightModelForAllSpecies.extractForSpecies(species);
-
// log catches weight
message = logCatchWeight(getDecoratorService(), catchWeightModelForAllSpecies, catchWeightModelForSpeciesToFix);
if (log.isInfoEnabled()) {
@@ -571,15 +615,15 @@ public class Level2Action extends T3Action<Level2Configuration> {
}
- protected void doExecuteActivityInCatchStratum(L2CatchStratum catchStratum,
- Activity activity,
- int activityIndex,
- int nbActivites,
- boolean deleteOldData) throws TopiaException, IOException {
+ private void doExecuteActivityInCatchStratum(L2CatchStratum catchStratum,
+ Activity activity,
+ int activityIndex,
+ int nbActivities,
+ boolean deleteOldData) throws TopiaException, IOException {
String activityStr = String.format("%s (%s)", decorate(activity), decorate(activity.getTrip(), DecoratorService.WITH_ID));
- String message = l(locale, "t3.level2.message.start.activity", activityIndex, nbActivites, activityStr, 1);
+ String message = l(locale, "t3.level2.message.start.activity", activityIndex, nbActivities, activityStr, 1);
if (log.isInfoEnabled()) {
log.info(message);
}
@@ -631,7 +675,7 @@ public class Level2Action extends T3Action<Level2Configuration> {
compositionModel.close();
}
- protected void applySampleSpecificComposition(L2CatchStratum catchStratum, Activity activity) throws TopiaException {
+ private void applySampleSpecificComposition(L2CatchStratum catchStratum, Activity activity) throws TopiaException {
WeightCompositionAggregateModel correctedCatchWeightModel = new WeightCompositionAggregateModel();
@@ -675,11 +719,11 @@ public class Level2Action extends T3Action<Level2Configuration> {
}
- protected void applySampleSpecificComposition(L2CatchStratum catchStratum,
- Activity activity,
- int nbZones,
- WeightCompositionAggregateModel sampleCompositionModel,
- WeightCompositionAggregateModel correctedCatchesForSpeciesToFix) throws TopiaException {
+ private void applySampleSpecificComposition(L2CatchStratum catchStratum,
+ Activity activity,
+ int nbZones,
+ WeightCompositionAggregateModel sampleCompositionModel,
+ WeightCompositionAggregateModel correctedCatchesForSpeciesToFix) throws TopiaException {
WeightCompositionAggregateModel correctedCatchWeightModel = new WeightCompositionAggregateModel();
@@ -692,8 +736,7 @@ public class Level2Action extends T3Action<Level2Configuration> {
Map<Species, Float> weights = new HashMap<>();
// get composition model to use
- WeightCompositionModel model =
- sampleCompositionModel.getModel(weightCategory);
+ WeightCompositionModel model = sampleCompositionModel.getModel(weightCategory);
// set of species still to fix
Set<Species> speciesToFix;
@@ -721,10 +764,9 @@ public class Level2Action extends T3Action<Level2Configuration> {
speciesToFix = model.getSpecies();
- speciesStillToFix = Sets.newHashSet(speciesToFix);
+ speciesStillToFix = new HashSet<>(speciesToFix);
- totalWeight = correctedCatchesForSpeciesToFix.getModel(
- weightCategory).getTotalWeight();
+ totalWeight = correctedCatchesForSpeciesToFix.getModel(weightCategory).getTotalWeight();
}
// divide the total weight to used by the number of zones of this
@@ -734,8 +776,7 @@ public class Level2Action extends T3Action<Level2Configuration> {
// Apply on all existing corrected catch weight
- for (CorrectedElementaryCatch aCatch :
- correctedElementaryCatches.get(weightCategory)) {
+ for (CorrectedElementaryCatch aCatch : correctedElementaryCatches.get(weightCategory)) {
Species speciesToUse = aCatch.getSpecies();
@@ -789,8 +830,7 @@ public class Level2Action extends T3Action<Level2Configuration> {
float correctedCatchWeight = totalWeight * weightRate;
// create new record
- CorrectedElementaryCatch aCatch =
- correctedElementaryCatchDAO.create();
+ CorrectedElementaryCatch aCatch = correctedElementaryCatchDAO.create();
aCatch.setSpecies(speciesToUse);
aCatch.setWeightCategoryTreatment(weightCategory);
aCatch.setCatchWeight(0f);
@@ -809,8 +849,7 @@ public class Level2Action extends T3Action<Level2Configuration> {
}
// log corrected catches weight
- String message = logCorrectedCatchWeight(correctedCatchWeightModel,
- getDecoratorService());
+ String message = logCorrectedCatchWeight(correctedCatchWeightModel, getDecoratorService());
if (log.isInfoEnabled()) {
log.info(message);
}
@@ -828,10 +867,6 @@ public class Level2Action extends T3Action<Level2Configuration> {
this.schoolTypes = schoolTypes;
}
-// public void setZoneBySchoolType(Multimap<SchoolType, ZoneStratumAware> zoneBySchoolType) {
-// this.zoneBySchoolType = zoneBySchoolType;
-// }
-
public void setSpecies(Set<Species> species) {
this.species = species;
}
@@ -840,10 +875,6 @@ public class Level2Action extends T3Action<Level2Configuration> {
this.startDates = startDates;
}
-// public void setWeightCategoriesBySchoolType(Multimap<SchoolType, WeightCategoryTreatment> weightCategoriesBySchoolType) {
-// this.weightCategoriesBySchoolType = weightCategoriesBySchoolType;
-// }
-
public void setPossibleCatchVessels(Set<Vessel> possibleCatchVessels) {
this.possibleCatchVessels = possibleCatchVessels;
}
@@ -921,8 +952,7 @@ public class Level2Action extends T3Action<Level2Configuration> {
public String getInputCatchStratumLog() {
- WeightCompositionAggregateModel inputCatchModelForSpeciesToFix =
- inputCatchModelForAllSpecies.extractForSpecies(species);
+ WeightCompositionAggregateModel inputCatchModelForSpeciesToFix = inputCatchModelForAllSpecies.extractForSpecies(species);
String title =
l(locale, "t3.level2.message.strateInputGlobalComposition.resume");
@@ -936,8 +966,7 @@ public class Level2Action extends T3Action<Level2Configuration> {
public String getOutputCatchStratumLog() {
- WeightCompositionAggregateModel outputCatchModelForSpeciesToFix =
- outputCatchModelForAllSpecies.extractForSpecies(species);
+ WeightCompositionAggregateModel outputCatchModelForSpeciesToFix = outputCatchModelForAllSpecies.extractForSpecies(species);
String title = l(locale, "t3.level2.message.strateOutputGlobalComposition.resume");
@@ -959,10 +988,6 @@ public class Level2Action extends T3Action<Level2Configuration> {
protected String logCatchWeight(DecoratorService decoratorService,
WeightCompositionAggregateModel modelForAllSpecies,
WeightCompositionAggregateModel modelForSpeciesToFix) {
-//
-// WeightCompositionAggregateModel modelForAllSpecies = catchesWeightForAllSpecies.get(activity);
-// WeightCompositionAggregateModel modelForSpeciesToFix =
-// getCatchesWeightForSpeciesToFix(activity);
String title = l(locale, "t3.level2.message.activityCatchWeight.resume",
modelForAllSpecies.getTotalModel().getTotalWeight(),
@@ -978,8 +1003,7 @@ public class Level2Action extends T3Action<Level2Configuration> {
public String logCorrectedCatchWeight(WeightCompositionAggregateModel correctedCatchWeightModel,
DecoratorService decoratorService) {
- WeightCompositionAggregateModel modelForSpeciesToFix =
- correctedCatchWeightModel.extractForSpecies(species);
+ WeightCompositionAggregateModel modelForSpeciesToFix = correctedCatchWeightModel.extractForSpecies(species);
String title = l(locale, "t3.level2.message.activityCorrectedCatchWeight.resume",
@@ -997,11 +1021,6 @@ public class Level2Action extends T3Action<Level2Configuration> {
WeightCompositionAggregateModel modelForSpeciestoFix,
DecoratorService decoratorService) {
-// WeightCompositionAggregateModel modelForAllSpecies = specificActivityForAllSpeciesModels.get(activity);
-//
-// WeightCompositionAggregateModel modelForSpeciestoFix =
-// getSpecificCompositionForSpeciesToFix(activity);
-
String title = l(locale, "t3.level2.message.activityComposition.resume",
modelForAllSpecies.getTotalModel().getTotalWeight(),
modelForSpeciestoFix.getTotalModel().getTotalWeight());
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3CatchStratum.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3CatchStratum.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3CatchStratum.java
@@ -53,7 +53,7 @@ public class L3CatchStratum extends CatchStratum<Level3Configuration, Level3Acti
*
* @since 1.3.1
*/
- private float totalCatchtWeight;
+ private float totalCatchWeight;
/**
* Predicate to filter only species selected in configuration.
@@ -85,7 +85,7 @@ public class L3CatchStratum extends CatchStratum<Level3Configuration, Level3Acti
int nbZones = e.getValue();
// compute total catch weight of the activity (only for species to fix)
- totalCatchtWeight +=
+ totalCatchWeight +=
T3EntityHelper.getTotal(
activity.getCorrectedElementaryCatch(),
T3Functions.CORRECTED_ELEMENTARY_CATCH_TO_CORRECTED_CATCH_WEIGHT,
@@ -118,7 +118,7 @@ public class L3CatchStratum extends CatchStratum<Level3Configuration, Level3Acti
* @return total catch weight of selected catches for this stratum.
*/
public float getTotalCatchWeight() {
- return totalCatchtWeight;
+ return totalCatchWeight;
}
}
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3SampleStratum.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3SampleStratum.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3SampleStratum.java
@@ -24,7 +24,6 @@ import com.google.common.base.Predicate;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
-import com.google.common.collect.Sets;
import fr.ird.t3.T3IOUtil;
import fr.ird.t3.actions.stratum.SampleStratum;
import fr.ird.t3.actions.stratum.StratumConfiguration;
@@ -48,6 +47,7 @@ import org.nuiton.topia.persistence.TopiaException;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -182,7 +182,7 @@ public class L3SampleStratum extends SampleStratum<Level3Configuration, Level3Ac
Multimaps.index(activity.getSetSpeciesFrequency(), T3Functions.SPECIES_AWARE_BY_SPECIES);
// get species found (and only the one to use)
- Set<Species> speciesFound = Sets.newHashSet(setSpeciesFrequenciesBySpecies.keySet());
+ Set<Species> speciesFound = new HashSet<>(setSpeciesFrequenciesBySpecies.keySet());
speciesFound.retainAll(getSpeciesToFix());
// add missing empty model
@@ -220,8 +220,7 @@ public class L3SampleStratum extends SampleStratum<Level3Configuration, Level3Ac
allSetSpeciesFrequenciesBySpecies,
compositionModel,
weightCategories,
- conversionHelper
- );
+ conversionHelper);
}
public float getCatchStratumTotalWeight() {
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level3/Level3Action.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level3/Level3Action.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level3/Level3Action.java
@@ -72,6 +72,7 @@ import fr.ird.t3.services.ioc.InjectEntitiesById;
import fr.ird.t3.services.ioc.InjectEntityById;
import fr.ird.t3.services.ioc.InjectFromDAO;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.mutable.MutableInt;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.persistence.TopiaException;
@@ -85,6 +86,7 @@ import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -207,32 +209,13 @@ public class Level3Action extends T3Action<Level3Configuration> {
configuration.setLocale(getLocale());
// get zones type meta to use
- setZoneMeta(
- newService(ZoneStratumService.class).getZoneMetaById(configuration.getZoneTypeId()));
+ setZoneMeta(newService(ZoneStratumService.class).getZoneMetaById(configuration.getZoneTypeId()));
setZoneVersion(zoneMeta.getZoneVersion(configuration.getZoneVersionId(), getT3TopiaPersistenceContext().get()));
-// // get all zones by ocean and shcool types
-// setZoneBySchoolType(
-// zoneMeta.getZones(
-// ocean,
-// schoolTypes,
-// zoneVersion,
-// getT3TopiaPersistenceContext().get()
-// )
-// );
-
// get start dates to use
setStartDates(T3Date.getStartDates(configuration.getBeginDate(), configuration.getEndDate(), configuration.getTimeStep()));
-// // get weight categories to use (group by school type)
-// setWeightCategoriesBySchoolType(
-// weightCategoryTreatmentDAO.getWeightCategories(
-// ocean,
-// schoolTypes
-// )
-// );
-
Date toBeginDate = configuration.getBeginDate().toBeginDate();
for (Ocean ocean : oceans) {
oceanContext.put(ocean.getTopiaId(), new OceanContext(
@@ -251,9 +234,7 @@ public class Level3Action extends T3Action<Level3Configuration> {
// get possible vessels for sample stratum
setPossibleSampleVessels(vesselDAO.getPossibleSampleVessels(sampleFleets, sampleFlags));
-// conversionHelper = lengthWeightConversionDAO.newConversionHelper(ocean, 0, toBeginDate);
-
- stratumsResult = Sets.newLinkedHashSet();
+ stratumsResult = new LinkedHashSet<>();
topiaCreateDate = new SimpleDateFormat("yyyy-MM-dd").format(serviceContext.getCurrentDate());
@@ -306,8 +287,6 @@ public class Level3Action extends T3Action<Level3Configuration> {
super.finalizeAction();
}
-// Map<String, Integer> hitActivities = new TreeMap<>();
-
@Override
protected boolean executeAction() throws Exception {
@@ -315,88 +294,133 @@ public class Level3Action extends T3Action<Level3Configuration> {
Level3Configuration configuration = getConfiguration();
- // get time step
- int timeStep = configuration.getTimeStep();
+ // keep a track of already used activity ids (to remove previous level 2 data)
+ Set<String> usedActivityIds = new HashSet<>();
-// nbStratums = zoneBySchoolType.size() * startDates.size();
- nbStratums = oceanContext.values().stream().mapToInt(OceanContext::sizeZones).sum() * startDates.size();
+ boolean useWeightCategoriesInStratum = configuration.isUseWeightCategoriesInStratum();
+
+ if (useWeightCategoriesInStratum) {
+ executeActionWithCategories(configuration, usedActivityIds);
+ } else {
+ executeActionWithoutCategories(configuration, usedActivityIds);
+ }
+ return true;
+ }
+
+ private void executeActionWithCategories(Level3Configuration configuration, Set<String> usedActivityIds) throws Exception {
+
+ nbStratums = 0;
+ for (SchoolType schoolType : schoolTypes) {
+ List<WeightCategoryTreatment> weightCategories = getWeightCategoryTreatments(schoolType);
+ Collection<ZoneStratumAware> zones = getZones(schoolType);
+ nbStratums += startDates.size() * zones.size() * weightCategories.size();
+ }
setNbSteps(3 * nbStratums);
- // keep a track of alreay used activity ids (to remove previous level 3 data)
- Set<String> usedActivityIds = new HashSet<>();
+ int timeStep = configuration.getTimeStep();
- int stratumIndex = 0;
+ MutableInt stratumIndex = new MutableInt(1);
for (SchoolType schoolType : schoolTypes) {
+ Map<String, Integer> stratumMinimumCountBySpecie = stratumMinimumSampleCountBySchoolType.get(schoolType);
+ List<WeightCategoryTreatment> weightCategories = getWeightCategoryTreatments(schoolType);
+ Collection<ZoneStratumAware> zones = getZones(schoolType);
+ for (ZoneStratumAware zone : zones) {
+ for (WeightCategoryTreatment weightCategory : weightCategories) {
+ doIterateOnDates(timeStep, configuration, schoolType, zones, zone, weightCategories, weightCategory, usedActivityIds, stratumIndex, stratumMinimumCountBySpecie);
+ }
+ }
+ }
+ }
- // get all weight categories for this school type
-// List<WeightCategoryTreatment> weightCategories = Lists.newArrayList(weightCategoriesBySchoolType.get(schoolType));
- List<WeightCategoryTreatment> weightCategories = oceanContext.values().stream().flatMap(o -> o.getWeightCategories(schoolType).stream()).distinct().collect(Collectors.toList());
- weightCategoryTreatmentDAO.sort(weightCategories);
+ private void executeActionWithoutCategories(Level3Configuration configuration, Set<String> usedActivityIds) throws Exception {
- // get all zones for this school type
-// Collection<ZoneStratumAware> zones = zoneBySchoolType.get(schoolType);
- List<ZoneStratumAware> zones = oceanContext.values().stream().flatMap(o -> o.getZones(schoolType).stream()).distinct().collect(Collectors.toList());
+ nbStratums = 0;
+ for (SchoolType schoolType : schoolTypes) {
+ Collection<ZoneStratumAware> zones = getZones(schoolType);
+ nbStratums += startDates.size() * zones.size();
+ }
+ setNbSteps(3 * nbStratums);
- // get minimum stratum count by species
- Map<String, Integer> stratumMinimumCountBySpecie = stratumMinimumSampleCountBySchoolType.get(schoolType);
+ int timeStep = configuration.getTimeStep();
+ MutableInt stratumIndex = new MutableInt(1);
+ for (SchoolType schoolType : schoolTypes) {
+ Map<String, Integer> stratumMinimumCountBySpecie = stratumMinimumSampleCountBySchoolType.get(schoolType);
+ List<WeightCategoryTreatment> weightCategories = getWeightCategoryTreatments(schoolType);
+ Collection<ZoneStratumAware> zones = getZones(schoolType);
for (ZoneStratumAware zone : zones) {
+ doIterateOnDates(timeStep, configuration, schoolType, zones, zone, weightCategories, null, usedActivityIds, stratumIndex, stratumMinimumCountBySpecie);
+ }
+ }
+ }
- for (T3Date startDate : startDates) {
-
- // get end date (only increments on timseStep - 1 to have
- // exactly timstep month from beginDate.toStartDate() to
- // endDate.toEndDate()
- T3Date endDate = startDate.incrementsMonths(timeStep - 1);
-
- // clear query buffer
- queryBuffer = new StringBuilder();
- nbQuery = 0;
-
- StratumConfiguration<Level3Configuration>
- stratumConfiguration =
- StratumConfiguration.newStratumConfiguration(
- configuration,
- zoneMeta,
- zone,
- schoolType,
- startDate,
- endDate,
- zones,
- possibleCatchVessels,
- possibleSampleVessels,
- stratumMinimumCountBySpecie,
- activityCache);
-
- try {
- L3StratumResult result = doExecuteStratum(stratumConfiguration, weightCategories, stratumIndex, usedActivityIds);
- stratumsResult.add(result);
- } finally {
-
- // first flush delete previous level 3 data
- flushTransaction("Flush delete level 3 data.");
-
- // flush then new data
- long s0 = TimeLog.getTime();
- if (nbQuery > 0) {
- if (log.isInfoEnabled()) {
- log.info(String.format("Will flush %d queries.", nbQuery));
- }
- getT3TopiaPersistenceContext().get().getSqlSupport().executeSql(queryBuffer.toString());
- }
- getTimeLog().log(s0, "Execute queries");
+ private List<WeightCategoryTreatment> getWeightCategoryTreatments(SchoolType schoolType) {
+ List<WeightCategoryTreatment> weightCategoryTreatments = oceanContext.values().stream().flatMap(o -> o.getWeightCategories(schoolType).stream()).distinct().collect(Collectors.toList());
+ weightCategoryTreatmentDAO.sort(weightCategoryTreatments);
+ return weightCategoryTreatments;
+ }
+
+ private Collection<ZoneStratumAware> getZones(SchoolType schoolType) {
+ return oceanContext.values().stream().flatMap(o -> o.getZones(schoolType).stream()).distinct().collect(Collectors.toList());
+ }
+
+ private void doIterateOnDates(int timeStep, Level3Configuration configuration, SchoolType schoolType, Collection<ZoneStratumAware> zones, ZoneStratumAware zone, List<WeightCategoryTreatment> weightCategories, WeightCategoryTreatment weightCategoryTreatment, Set<String> usedActivityIds, MutableInt stratumIndex, Map<String, Integer> stratumMinimumCountBySpecie) throws Exception {
+
+ for (T3Date startDate : startDates) {
+
+ // clear query buffer
+ queryBuffer = new StringBuilder();
+ nbQuery = 0;
+
+ // get end date (only increments on timeStep - 1 to have
+ // exactly timeStep month from beginDate.toStartDate() to endDate.toEndDate()
+ T3Date endDate = startDate.incrementsMonths(timeStep - 1);
+
+ StratumConfiguration<Level3Configuration>
+ stratumConfiguration =
+ StratumConfiguration.newStratumConfiguration(
+ configuration,
+ zoneMeta,
+ zone,
+ schoolType,
+ weightCategoryTreatment,
+ startDate,
+ endDate,
+ zones,
+ possibleCatchVessels,
+ possibleSampleVessels,
+ stratumMinimumCountBySpecie,
+ activityCache
+ );
+
+ try {
+ L3StratumResult result = doExecuteStratum(stratumConfiguration, weightCategories, stratumIndex, usedActivityIds);
+ stratumsResult.add(result);
+ } finally {
+
+ // first flush delete previous level 3 data
+ flushTransaction("Flush delete level 3 data.");
+
+ // flush then new data
+ long s0 = TimeLog.getTime();
+ if (nbQuery > 0) {
+ if (log.isInfoEnabled()) {
+ log.info(String.format("Will flush %d queries.", nbQuery));
}
- stratumIndex++;
+ getT3TopiaPersistenceContext().get().getSqlSupport().executeSql(queryBuffer.toString());
}
+ getTimeLog().log(s0, "Execute queries");
}
+
+ stratumIndex.increment();
}
- return true;
+
}
- protected L3StratumResult doExecuteStratum(StratumConfiguration<Level3Configuration> conf,
- List<WeightCategoryTreatment> weightCategories,
- int stratumIndex,
- Set<String> usedActivityIds) throws Exception {
+ private L3StratumResult doExecuteStratum(StratumConfiguration<Level3Configuration> conf,
+ List<WeightCategoryTreatment> weightCategories,
+ MutableInt stratumIndex,
+ Set<String> usedActivityIds) throws Exception {
incrementsProgression();
@@ -488,7 +512,7 @@ public class Level3Action extends T3Action<Level3Configuration> {
addInfoMessage(message);
int activityIndex = 1;
- int nbActivites = catchStratum.getNbActivities();
+ int nbActivities = catchStratum.getNbActivities();
for (Map.Entry<Activity, Integer> e : catchStratum) {
Activity activity = e.getKey();
@@ -499,13 +523,6 @@ public class Level3Action extends T3Action<Level3Configuration> {
boolean newActivity = usedActivityIds.add(activity.getTopiaId());
if (!newActivity) {
Preconditions.checkState(nbZones > 1, "Only a multi-zone activity can be seen more tha once!, problem with activity: " + activity.getTopiaId());
-
-// // mark it
-// Integer nb = hitActivities.get(activity.getTopiaId());
-// if (nb == null) {
-// nb = 0;
-// }
-// hitActivities.put(activity.getTopiaId(), nb + 1);
}
OceanContext oceanContext = this.oceanContext.get(activity.getOcean().getTopiaId());
@@ -518,10 +535,9 @@ public class Level3Action extends T3Action<Level3Configuration> {
nbZones,
activityIndex++,
weightCategories,
- nbActivites,
+ nbActivities,
newActivity,
- result.getTotalFishesCount()
- );
+ result.getTotalFishesCount());
// keep the stratum substitution level in the activity
activity.setStratumLevelN3(level);
@@ -554,8 +570,7 @@ public class Level3Action extends T3Action<Level3Configuration> {
l(locale, "t3.level3.catchStratum.nbFishesResume.title"),
totalFishesCountModel.extractForSpecies(species),
BEFORE_LEVEL3,
- AFTER_LEVEL3
- );
+ AFTER_LEVEL3);
if (log.isInfoEnabled()) {
log.info(message);
@@ -584,42 +599,32 @@ public class Level3Action extends T3Action<Level3Configuration> {
totalFishesCountModel.addValues(AFTER_LEVEL3, activity.getExtrapolatedAllSetSpeciesFrequency());
}
- protected void doExecuteActivityInCatchStratum(L3CatchStratum catchStratum,
- L3SampleStratum sampleStratum,
- Activity activity,
- OceanContext oceanContext,
- int nbZones,
- int activityIndex,
- List<WeightCategoryTreatment> weightCategories,
- int nbActivites,
- boolean deleteOldData,
- SpeciesCountAggregateModel totalFishesCount) throws TopiaException {
+ private void doExecuteActivityInCatchStratum(L3CatchStratum catchStratum,
+ L3SampleStratum sampleStratum,
+ Activity activity,
+ OceanContext oceanContext,
+ int nbZones,
+ int activityIndex,
+ List<WeightCategoryTreatment> weightCategories,
+ int nbActivities,
+ boolean deleteOldData,
+ SpeciesCountAggregateModel totalFishesCount) throws TopiaException {
String activityStr = String.format("%s (%s)", decorate(activity), decorate(activity.getTrip(), DecoratorService.WITH_ID));
- String message = l(locale, "t3.level3.message.start.activity", activityIndex, nbActivites, activityStr, nbZones);
+ String message = l(locale, "t3.level3.message.start.activity", activityIndex, nbActivities, activityStr, nbZones);
if (log.isInfoEnabled()) {
log.info(message);
}
addInfoMessage(message);
- // to deal with muli-zone activities (must keep a track of what was
- // already odne)
+ // to deal with multiple-zone activities (must keep a track of what was already done)
Map<String, String> previousValues;
boolean activityMultiZone = nbZones > 1;
if (activityMultiZone) {
-
- // get previous values
- previousValues = activityWithMultiZones.get(activity.getTopiaId());
-
- if (previousValues == null) {
-
- // create previous values
- activityWithMultiZones.put(activity.getTopiaId(), previousValues = new HashMap<>());
- }
-
+ previousValues = activityWithMultiZones.computeIfAbsent(activity.getTopiaId(), k -> new HashMap<>());
} else {
previousValues = null;
}
@@ -630,7 +635,6 @@ public class Level3Action extends T3Action<Level3Configuration> {
if (log.isDebugEnabled()) {
log.debug(String.format("Delete previous level3 data of %s :: %d", activity.getTopiaId(), activity.sizeExtrapolatedAllSetSpeciesFrequency()));
}
-// addDeleteQuery(activity);
activity.deleteComputedDataLevel3();
}
@@ -673,7 +677,6 @@ public class Level3Action extends T3Action<Level3Configuration> {
message = l(locale, "t3.level3.message.activity.with.no.sample.useSampleStratum.composition", activityStr);
}
-
if (log.isInfoEnabled()) {
log.info(message);
}
@@ -766,13 +769,13 @@ public class Level3Action extends T3Action<Level3Configuration> {
}
}
- protected void generateFrequencies(Activity activity,
- Species aSpecies,
- Map<String, String> previousValues,
- LengthCompositionModel model,
- float totalWeight,
- SpeciesCountModel speciesCountModel,
- LengthWeightConversion conversions) {
+ private void generateFrequencies(Activity activity,
+ Species aSpecies,
+ Map<String, String> previousValues,
+ LengthCompositionModel model,
+ float totalWeight,
+ SpeciesCountModel speciesCountModel,
+ LengthWeightConversion conversions) {
// get all length classes involved
Set<Integer> lengthClasses = model.getLengthClasses();
@@ -803,8 +806,8 @@ public class Level3Action extends T3Action<Level3Configuration> {
}
- protected L3CatchStratum newCatchStratum(StratumConfiguration<Level3Configuration> stratumConfiguration,
- List<WeightCategoryTreatment> weightCategories) throws Exception {
+ private L3CatchStratum newCatchStratum(StratumConfiguration<Level3Configuration> stratumConfiguration,
+ List<WeightCategoryTreatment> weightCategories) throws Exception {
L3CatchStratum catchStratum = new L3CatchStratum(stratumConfiguration, species, speciesToFixFilter);
catchStratum.init(serviceContext, weightCategories, this);
// get the total weight of the catch stratum
@@ -833,10 +836,10 @@ public class Level3Action extends T3Action<Level3Configuration> {
return catchStratum;
}
- protected L3SampleStratum newSampleStratum(StratumConfiguration<Level3Configuration> stratumConfiguration,
- List<WeightCategoryTreatment> weightCategories,
- float totalCatchWeight,
- LengthWeightConversionHelper conversionHelper) throws Exception {
+ private L3SampleStratum newSampleStratum(StratumConfiguration<Level3Configuration> stratumConfiguration,
+ List<WeightCategoryTreatment> weightCategories,
+ float totalCatchWeight,
+ LengthWeightConversionHelper conversionHelper) throws Exception {
L3SampleStratum sampleStratum =
new L3SampleStratum(stratumConfiguration,
species,
@@ -847,26 +850,13 @@ public class Level3Action extends T3Action<Level3Configuration> {
return sampleStratum;
}
- protected void addInsertOrUpdateQuery(Activity activity,
- Map<String, String> previousValues,
- Species species,
- int lengthClass,
- float number,
- SpeciesCountModel speciesCountModel) {
+ private void addInsertOrUpdateQuery(Activity activity, Map<String, String> previousValues, Species species, int lengthClass, float number, SpeciesCountModel speciesCountModel) {
String key = species.getTopiaId() + "__" + lengthClass;
String oldId = previousValues == null ? null : previousValues.get(key);
String query;
if (oldId == null) {
- // check unique key
- String uniqueKey = activity.getTopiaId() + "__" + key;
-
-// if (!insertCache.add(uniqueKey)) {
-//
-// // key already used!!!
-// throw new IllegalStateException("Tuple (" + uniqueKey + ") already used!");
-// }
// insert query
TopiaIdFactory topiaIdFactory = getActionContext().getApplicationContext().getConfiguration().getTopiaIdFactory();
String newId = topiaIdFactory.newTopiaId(ExtrapolatedAllSetSpeciesFrequency.class, "" + System.nanoTime());
@@ -906,10 +896,6 @@ public class Level3Action extends T3Action<Level3Configuration> {
this.schoolTypes = schoolTypes;
}
-// public void setZoneBySchoolType(Multimap<SchoolType, ZoneStratumAware> zoneBySchoolType) {
-// this.zoneBySchoolType = zoneBySchoolType;
-// }
-
public void setSpecies(Set<Species> species) {
this.species = species;
}
@@ -918,10 +904,6 @@ public class Level3Action extends T3Action<Level3Configuration> {
this.startDates = startDates;
}
-// public void setWeightCategoriesBySchoolType(Multimap<SchoolType, WeightCategoryTreatment> weightCategoriesBySchoolType) {
-// this.weightCategoriesBySchoolType = weightCategoriesBySchoolType;
-// }
-
public void setPossibleCatchVessels(Set<Vessel> possibleCatchVessels) {
this.possibleCatchVessels = possibleCatchVessels;
}
=====================================
t3-domain/src/main/java/fr/ird/t3/actions/stratum/Stratum.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/actions/stratum/Stratum.java
+++ b/t3-domain/src/main/java/fr/ird/t3/actions/stratum/Stratum.java
@@ -46,13 +46,12 @@ import java.util.Set;
public abstract class Stratum<C extends LevelConfigurationWithStratum, A extends T3Action<C>> implements Closeable, Iterable<Map.Entry<Activity, Integer>> {
/**
- * All activities selected for this stratum, with for catch satratum the
- * number of zones where the activty should be used.
+ * All activities selected for this stratum, with for catch stratum the number of zones where the activity should be used.
* <p/>
* see http://forge.codelutin.com/issues/1935
* <p/>
* <strong>Note:</strong> This data are available after invocation of method
- * {@link Stratum#init(T3ServiceContext, List, T3Action}.
+ * {@link Stratum#init(T3ServiceContext, List, T3Action)}.
*/
private Map<Activity, Integer> activities;
@@ -85,8 +84,7 @@ public abstract class Stratum<C extends LevelConfigurationWithStratum, A extends
return activities.entrySet().iterator();
}
- protected Stratum(StratumConfiguration<C> configuration,
- Collection<Species> speciesToFix) {
+ protected Stratum(StratumConfiguration<C> configuration, Collection<Species> speciesToFix) {
this.configuration = configuration;
this.speciesToFix = ImmutableSet.copyOf(speciesToFix);
}
@@ -130,9 +128,7 @@ public abstract class Stratum<C extends LevelConfigurationWithStratum, A extends
protected void checkInitMethodInvoked(Object data) {
if (data == null) {
- throw new IllegalStateException(
- "You must invoke the #init(tx) method before accessing " +
- "stratum data.");
+ throw new IllegalStateException("You must invoke the #init(tx) method before accessing stratum data.");
}
}
}
=====================================
t3-domain/src/main/java/fr/ird/t3/actions/stratum/StratumConfiguration.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/actions/stratum/StratumConfiguration.java
+++ b/t3-domain/src/main/java/fr/ird/t3/actions/stratum/StratumConfiguration.java
@@ -8,12 +8,12 @@
* 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%
@@ -24,9 +24,11 @@ import com.google.common.cache.LoadingCache;
import fr.ird.t3.entities.data.Activity;
import fr.ird.t3.entities.reference.SchoolType;
import fr.ird.t3.entities.reference.Vessel;
+import fr.ird.t3.entities.reference.WeightCategoryTreatment;
import fr.ird.t3.entities.reference.zone.ZoneStratumAware;
import fr.ird.t3.entities.reference.zone.ZoneStratumAwareMeta;
import fr.ird.t3.entities.type.T3Date;
+
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
@@ -41,33 +43,68 @@ import java.util.concurrent.ExecutionException;
*/
public class StratumConfiguration<C extends LevelConfigurationWithStratum> {
+ private final C configuration;
+ private final Collection<ZoneStratumAware> zones;
+ private final ZoneStratumAwareMeta zoneMeta;
+ private final ZoneStratumAware zone;
+ private final SchoolType schoolType;
+ private final WeightCategoryTreatment weightCategoryTreatment;
+ private final T3Date beginDate;
+ private final T3Date endDate;
+ private final Set<Vessel> possibleCatchVessels;
+ private final Set<Vessel> possibleSampleVessels;
+ private final Map<String, Integer> stratumMinimumCountBySpecie;
+ private final LoadingCache<String, Activity> activityCache;
+ private String[] zoneIds;
+
+ protected StratumConfiguration(C configuration,
+ ZoneStratumAwareMeta zoneMeta,
+ ZoneStratumAware zone,
+ SchoolType schoolType,
+ WeightCategoryTreatment weightCategoryTreatment, T3Date beginDate,
+ T3Date endDate,
+ Collection<ZoneStratumAware> zones,
+ Set<Vessel> possibleCatchVessels,
+ Set<Vessel> possibleSampleVessels,
+ Map<String, Integer> stratumMinimumCountBySpecie,
+ LoadingCache<String, Activity> activityCache) {
+ this.configuration = configuration;
+ this.zoneMeta = zoneMeta;
+ this.zone = zone;
+ this.schoolType = schoolType;
+ this.weightCategoryTreatment = weightCategoryTreatment;
+ this.beginDate = beginDate;
+ this.endDate = endDate;
+ this.zones = zones;
+ this.possibleCatchVessels = possibleCatchVessels;
+ this.possibleSampleVessels = possibleSampleVessels;
+ this.stratumMinimumCountBySpecie = stratumMinimumCountBySpecie;
+ this.activityCache = activityCache;
+ }
+
/**
* Obtain a new stratum configuration given all his parameters.
*
+ * @param <C> type of configuration
* @param conf the level action configuration
* @param zoneMeta type of zone to use
* @param zone the zone of the stratum
* @param schoolType the school type of the stratum
+ * @param weightCategoryTreatment the weight category of the stratum (not nul only if {@link LevelConfigurationWithStratum#isUseWeightCategoriesInStratum()} is {@code true}.
* @param startDate the start date of the stratum
* @param endDate the end date of the stratum
- * @param zones all the zones useables by the level
- * action which used this stratum (can
- * be used for sample stratum substitution)
- * @param possibleCatchVessels set of possible vessels to use when
- * selecting data in the catch stratum
- * @param possibleSampleVessels set of possible vessels to use when
- * selecting data in the sample stratum
- * @param stratumMinimumCountBySpecie minimum sample count needed by species
- * for sample stratum substitution
- * @param <C> type of configuration
- * @return the new instanciated stratum configuration
+ * @param zones all the zones useable by the level action which used this stratum (can be used for sample stratum substitution)
+ * @param possibleCatchVessels set of possible vessels to use when selecting data in the catch stratum
+ * @param possibleSampleVessels set of possible vessels to use when selecting data in the sample stratum
+ * @param stratumMinimumCountBySpecie minimum sample count needed by species for sample stratum substitution
+ * @return the new instantiated stratum configuration
*/
public static <C extends LevelConfigurationWithStratum> StratumConfiguration<C> newStratumConfiguration(
C conf,
ZoneStratumAwareMeta zoneMeta,
ZoneStratumAware zone,
SchoolType schoolType,
- T3Date startDate,
+ WeightCategoryTreatment weightCategoryTreatment, T3Date startDate,
T3Date endDate,
Collection<ZoneStratumAware> zones,
Set<Vessel> possibleCatchVessels,
@@ -75,11 +112,12 @@ public class StratumConfiguration<C extends LevelConfigurationWithStratum> {
Map<String, Integer> stratumMinimumCountBySpecie,
LoadingCache<String, Activity> activityCache) {
- return new StratumConfiguration<C>(
+ return new StratumConfiguration<>(
conf,
zoneMeta,
zone,
schoolType,
+ weightCategoryTreatment,
startDate,
endDate,
zones,
@@ -89,54 +127,6 @@ public class StratumConfiguration<C extends LevelConfigurationWithStratum> {
activityCache);
}
- private final C configuration;
-
- private final ZoneStratumAwareMeta zoneMeta;
-
- private final ZoneStratumAware zone;
-
- private final Collection<ZoneStratumAware> zones;
-
- private String[] zoneIds;
-
- private final SchoolType schoolType;
-
- private final T3Date beginDate;
-
- private final T3Date endDate;
-
- private final Set<Vessel> possibleCatchVessels;
-
- private final Set<Vessel> possibleSampleVessels;
-
- private final Map<String, Integer> stratumMinimumCountBySpecie;
-
- private final LoadingCache<String, Activity> activityCache;
-
- protected StratumConfiguration(C configuration,
- ZoneStratumAwareMeta zoneMeta,
- ZoneStratumAware zone,
- SchoolType schoolType,
- T3Date beginDate,
- T3Date endDate,
- Collection<ZoneStratumAware> zones,
- Set<Vessel> possibleCatchVessels,
- Set<Vessel> possibleSampleVessels,
- Map<String, Integer> stratumMinimumCountBySpecie,
- LoadingCache<String, Activity> activityCache) {
- this.configuration = configuration;
- this.zoneMeta = zoneMeta;
- this.zone = zone;
- this.schoolType = schoolType;
- this.beginDate = beginDate;
- this.endDate = endDate;
- this.zones = zones;
- this.possibleCatchVessels = possibleCatchVessels;
- this.possibleSampleVessels = possibleSampleVessels;
- this.stratumMinimumCountBySpecie = stratumMinimumCountBySpecie;
- this.activityCache = activityCache;
- }
-
public C getConfiguration() {
return configuration;
}
@@ -181,6 +171,10 @@ public class StratumConfiguration<C extends LevelConfigurationWithStratum> {
return stratumMinimumCountBySpecie;
}
+ public WeightCategoryTreatment getWeightCategoryTreatment() {
+ return weightCategoryTreatment;
+ }
+
public String[] getZoneIds() {
if (zoneIds == null) {
Collection<ZoneStratumAware> allZones = getZones();
@@ -204,8 +198,6 @@ public class StratumConfiguration<C extends LevelConfigurationWithStratum> {
@Override
public String toString() {
- return super.toString() + " [schooltype: " + schoolType.getLabel1() +
- ", zone: " + zone.getTopiaId() + ", startDate:" +
- beginDate + ", endDate:" + endDate + "]";
+ return String.format("%s [schoolType: %s, zone: %s, startDate:%s, endDate:%s, weightCategory: %s]", super.toString(), schoolType.getLabel1(), zone.getTopiaId(), beginDate, endDate, weightCategoryTreatment);
}
}
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/ea4a2e79d10126ad158b77d01c537933…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/ea4a2e79d10126ad158b77d01c537933…
You're receiving this email because of your account on gitlab.com.
1
0
21 Feb '18
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
0ea4c85e by Tony CHEMIT at 2018-02-21T17:02:36+01:00
fix level 2 and 3 config code
- - - - -
5b34b3ef by Tony CHEMIT at 2018-02-21T17:05:13+01:00
[N2][N3] Gestion des catégories de poids -10/+10kg dans la stratification N2 et N3 (Mise en place de la configuration) (See #263)
- - - - -
13 changed files:
- t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level2/Level2Action.ftl
- t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level2/Level2Action_en.ftl
- t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level3/Level3Action.ftl
- t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level3/Level3Action_en.ftl
- t3-domain/src/main/java/fr/ird/t3/actions/stratum/LevelConfigurationWithStratum.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/ConfigureLevel2Step2Action.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level3/ConfigureLevel3Step2Action.java
- t3-web/src/main/resources/i18n/t3-web_en_GB.properties
- t3-web/src/main/resources/i18n/t3-web_fr_FR.properties
- t3-web/src/main/webapp/WEB-INF/jsp/data/level2/level2ConfigurationResume.jsp
- t3-web/src/main/webapp/WEB-INF/jsp/data/level2/level2ConfigurationStep2.jsp
- t3-web/src/main/webapp/WEB-INF/jsp/data/level3/level3ConfigurationResume.jsp
- t3-web/src/main/webapp/WEB-INF/jsp/data/level3/level3ConfigurationStep2.jsp
Changes:
=====================================
t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level2/Level2Action.ftl
=====================================
--- a/t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level2/Level2Action.ftl
+++ b/t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level2/Level2Action.ftl
@@ -35,6 +35,12 @@ Corriger avec les échantillons de leur strate échantillon
Corriger avec leur propre échantillon
</#if>
+<#if configuration.useWeightCategoriesInStratum>
+Utilisation des catégories de poids +10/-10 dans la stratification.
+<#else>
+Catégories de poids +10/-10 non utilisés dans la stratification.
+</#if>
+
<#list oceans?values as ocean>
Océan sélectionné : ${ocean}
</#list>
@@ -63,6 +69,7 @@ Flotte d'échantillon sélectionnée : ${sampleFleet}
Pavillon d'échantillon sélectionnée : ${sampleFlag}
</#list>
+
Qualité des strates échantillons :
- Nombre minimum d'effectif dans les échantillons :
=====================================
t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level2/Level2Action_en.ftl
=====================================
--- a/t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level2/Level2Action_en.ftl
+++ b/t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level2/Level2Action_en.ftl
@@ -35,6 +35,12 @@ Fix with the stratum sample
Fix with their own sample
</#if>
+<#if configuration.useWeightCategoriesInStratum>
+Use weight categories +10/-10 in stratification.
+<#else>
+Do not use weight categories +10/-10 in stratification.
+</#if>
+
<#list oceans?values as ocean>
Selected ocean: ${ocean}
</#list>
=====================================
t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level3/Level3Action.ftl
=====================================
--- a/t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level3/Level3Action.ftl
+++ b/t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level3/Level3Action.ftl
@@ -35,6 +35,12 @@ Appliquer les structures de tailles de la strate échantillons
Conserver leurs échantillons en l'état
</#if>
+<#if configuration.useWeightCategoriesInStratum>
+Utilisation des catégories de poids +10/-10 dans la stratification.
+<#else>
+Catégories de poids +10/-10 non utilisés dans la stratification.
+</#if>
+
<#if configuration.useWeightCategories>
Générer les structures de tailles par catégories de poids
<#else>
=====================================
t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level3/Level3Action_en.ftl
=====================================
--- a/t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level3/Level3Action_en.ftl
+++ b/t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level3/Level3Action_en.ftl
@@ -35,6 +35,12 @@ Apply length structures from the sample statrum
Keep their own samples (do nothing)
</#if>
+<#if configuration.useWeightCategoriesInStratum>
+Use weight categories +10/-10 in stratification.
+<#else>
+Do not use weight categories +10/-10 in stratification.
+</#if>
+
<#if configuration.useWeightCategories>
Generate length structures by weight category
<#else>
=====================================
t3-domain/src/main/java/fr/ird/t3/actions/stratum/LevelConfigurationWithStratum.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/actions/stratum/LevelConfigurationWithStratum.java
+++ b/t3-domain/src/main/java/fr/ird/t3/actions/stratum/LevelConfigurationWithStratum.java
@@ -111,6 +111,10 @@ public abstract class LevelConfigurationWithStratum implements T3ActionConfigura
* The first step is the general configuration.
*/
private boolean validStep1;
+ /**
+ * Flag to add weight categories as a component of the stratum hierarchy.
+ */
+ private boolean useWeightCategoriesInStratum;
/**
* Flag to validate the step two of configuration.
@@ -307,4 +311,12 @@ public abstract class LevelConfigurationWithStratum implements T3ActionConfigura
public void setLocale(Locale locale) {
this.locale = locale;
}
+
+ public boolean isUseWeightCategoriesInStratum() {
+ return useWeightCategoriesInStratum;
+ }
+
+ public void setUseWeightCategoriesInStratum(boolean useWeightCategoriesInStratum) {
+ this.useWeightCategoriesInStratum= useWeightCategoriesInStratum;
+ }
}
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/ConfigureLevel2Step2Action.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/ConfigureLevel2Step2Action.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/ConfigureLevel2Step2Action.java
@@ -33,8 +33,9 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import java.util.LinkedHashSet;
import java.util.Map;
-import java.util.TreeSet;
+import java.util.Set;
/**
* To manager the step 2 of a level 2 treatment configuration.
@@ -83,8 +84,8 @@ public class ConfigureLevel2Step2Action extends AbstractConfigureAction<Level2Co
missingDatas = false;
- TreeSet<Country> sampleFlags = new TreeSet<>();
- TreeSet<Country> sampleFleets = new TreeSet<>();
+ Set<Country> sampleFlags = new LinkedHashSet<>();
+ Set<Country> sampleFleets = new LinkedHashSet<>();
for (String oceanId : configuration.getOceanIds()) {
sampleFlags.addAll(countryDAO.findAllFlagUsedInSample(oceanId));
sampleFleets.addAll(countryDAO.findAllFleetUsedInSample(oceanId));
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/data/level3/ConfigureLevel3Step2Action.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/data/level3/ConfigureLevel3Step2Action.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/data/level3/ConfigureLevel3Step2Action.java
@@ -34,8 +34,9 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.interceptor.ParameterAware;
+import java.util.LinkedHashSet;
import java.util.Map;
-import java.util.TreeSet;
+import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -51,24 +52,24 @@ public class ConfigureLevel3Step2Action extends AbstractConfigureAction<Level3Co
public static final Pattern BL_STRATUM_MINIMUM_COUNT_PATTERN = Pattern.compile("BL:(.*)?");
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(ConfigureLevel3Step2Action.class);
- protected final Map<String, String> timeSteps = createTimeSteps();
+ private final Map<String, String> timeSteps = createTimeSteps();
@InjectDAO(entityType = Country.class)
- protected transient CountryTopiaDao countryDAO;
+ private transient CountryTopiaDao countryDAO;
@InjectDecoratedBeans(beanType = Country.class)
- protected Map<String, String> sampleFleets;
+ private Map<String, String> sampleFleets;
@InjectDecoratedBeans(beanType = Country.class)
- protected Map<String, String> sampleFlags;
+ private Map<String, String> sampleFlags;
@InjectDecoratedBeans(beanType = Species.class, filterById = true, pathIds = "speciesIds")
- protected Map<String, String> species;
- protected Map<String, String> useSamplesOrNot;
- protected Map<String, String> useWeightCategoriesOrNot;
+ private Map<String, String> species;
+ private Map<String, String> useSamplesOrNot;
+ private Map<String, String> useWeightCategoriesOrNot;
/**
* Flag to know if some data are missings.
* <p/>
* This flag is setted in the {@link #prepare()} method while
* loading possibles data.
*/
- protected boolean missingDatas;
+ private boolean missingDatas;
public ConfigureLevel3Step2Action() {
super(Level3Configuration.class);
@@ -88,8 +89,8 @@ public class ConfigureLevel3Step2Action extends AbstractConfigureAction<Level3Co
missingDatas = false;
- TreeSet<Country> sampleFlags = new TreeSet<>();
- TreeSet<Country> sampleFleets = new TreeSet<>();
+ Set<Country> sampleFlags = new LinkedHashSet<>();
+ Set<Country> sampleFleets = new LinkedHashSet<>();
for (String oceanId : configuration.getOceanIds()) {
sampleFlags.addAll(countryDAO.findAllFlagUsedInSample(oceanId));
sampleFleets.addAll(countryDAO.findAllFleetUsedInSample(oceanId));
=====================================
t3-web/src/main/resources/i18n/t3-web_en_GB.properties
=====================================
--- a/t3-web/src/main/resources/i18n/t3-web_en_GB.properties
+++ b/t3-web/src/main/resources/i18n/t3-web_en_GB.properties
@@ -118,6 +118,7 @@ t3.common.uploaded.source=Input file uploaded
t3.common.usable.trips=Marées utilisables
t3.common.useReplacementVessel=Use a replacement vessel
t3.common.useSamplesOnly=Database 'Samples only'
+t3.common.useWeightCategoriesInStratum=Use Weight categories -10/+10 in stratum
t3.common.useWells=Use wells
t3.common.user.outputDatabases=List of configured target databases
t3.common.user.t3Databases=List of configured working databases
=====================================
t3-web/src/main/resources/i18n/t3-web_fr_FR.properties
=====================================
--- a/t3-web/src/main/resources/i18n/t3-web_fr_FR.properties
+++ b/t3-web/src/main/resources/i18n/t3-web_fr_FR.properties
@@ -118,6 +118,7 @@ t3.common.uploaded.source=Source téléchargé
t3.common.usable.trips=Marées utilisables
t3.common.useReplacementVessel=Utiliser un navire de remplacement
t3.common.useSamplesOnly=Base échantillon seulement
+t3.common.useWeightCategoriesInStratum=Utiliser les catégories de poids -10/+10Kg dans la stratification
t3.common.useWells=Utilisation des plans de cuve
t3.common.user.outputDatabases=Liste des configurations de bases de sortie
t3.common.user.t3Databases=Liste des configurations de bases de travail
=====================================
t3-web/src/main/webapp/WEB-INF/jsp/data/level2/level2ConfigurationResume.jsp
=====================================
--- a/t3-web/src/main/webapp/WEB-INF/jsp/data/level2/level2ConfigurationResume.jsp
+++ b/t3-web/src/main/webapp/WEB-INF/jsp/data/level2/level2ConfigurationResume.jsp
@@ -41,7 +41,7 @@
list="zoneVersions" label='%{getText("t3.common.zoneVersion")}'/>
<%-- selected catch fleet --%>
- <s:select key="configuration.catchFleetId" list="catchFleets" disabled="true"
+ <s:select key="configuration.catchFleetIds" list="catchFleets" disabled="true"
label='%{getText("t3.common.catchFleet")}'/>
<%-- selected time step --%>
@@ -90,6 +90,11 @@
label="%{getText('t3.common.stratumMinimumSampleCountFreeSchoolType')}"/>
<div class="formSeparator"></div>
+
+ <%--use weight categories in stratum--%>
+ <s:checkbox key="configuration.useWeightCategoriesInStratum" disabled="true"
+ label='%{getText("t3.common.useWeightCategoriesInStratum")}'/>
+
<%-- use all samples --%>
<s:radio key="configuration.useAllSamplesOfStratum" list="useSamplesOrNot" disabled="true"
label='%{getText("t3.label.data.level2.configuration.samplesToUse")}'/>
=====================================
t3-web/src/main/webapp/WEB-INF/jsp/data/level2/level2ConfigurationStep2.jsp
=====================================
--- a/t3-web/src/main/webapp/WEB-INF/jsp/data/level2/level2ConfigurationStep2.jsp
+++ b/t3-web/src/main/webapp/WEB-INF/jsp/data/level2/level2ConfigurationStep2.jsp
@@ -68,6 +68,10 @@
<s:radio key="configuration.useAllSamplesOfStratum" requiredLabel="true" list="useSamplesOrNot"
label='%{getText("t3.label.data.level2.configuration.samplesToUse")}'/>
+ <%--use weight categories in stratum--%>
+ <s:checkbox key="configuration.useWeightCategoriesInStratum" label='%{getText("t3.common.useWeightCategoriesInStratum")}'/>
+
+
</fieldset>
<br/>
=====================================
t3-web/src/main/webapp/WEB-INF/jsp/data/level3/level3ConfigurationResume.jsp
=====================================
--- a/t3-web/src/main/webapp/WEB-INF/jsp/data/level3/level3ConfigurationResume.jsp
+++ b/t3-web/src/main/webapp/WEB-INF/jsp/data/level3/level3ConfigurationResume.jsp
@@ -38,7 +38,7 @@
label='%{getText("t3.common.zoneType")}'/>
<%-- selected catch fleet --%>
- <s:select key="configuration.catchFleetId" disabled="true"
+ <s:select key="configuration.catchFleetIds" disabled="true"
list="catchFleets" label='%{getText("t3.common.catchFleet")}'/>
<%-- selected time step --%>
@@ -74,6 +74,10 @@
<s:radio key="configuration.useAllSamplesOfStratum" list="useSamplesOrNot" disabled="true"
label='%{getText("t3.label.data.level3.configuration.samplesToUse")}'/>
+ <%--use weight categories in stratum--%>
+ <s:checkbox key="configuration.useWeightCategoriesInStratum" disabled="true"
+ label='%{getText("t3.common.useWeightCategoriesInStratum")}'/>
+
<%-- use weight categories --%>
<s:radio key="configuration.useWeightCategories" list="useWeightCategoriesOrNot" disabled="true"
label='%{getText("t3.label.data.level3.configuration.useWeightCategoriesOrNot")}'/>
=====================================
t3-web/src/main/webapp/WEB-INF/jsp/data/level3/level3ConfigurationStep2.jsp
=====================================
--- a/t3-web/src/main/webapp/WEB-INF/jsp/data/level3/level3ConfigurationStep2.jsp
+++ b/t3-web/src/main/webapp/WEB-INF/jsp/data/level3/level3ConfigurationStep2.jsp
@@ -63,6 +63,10 @@
<%-- use weight categories --%>
<s:radio key="configuration.useWeightCategories" requiredLabel="true" list="useWeightCategoriesOrNot"
label='%{getText("t3.label.data.level3.configuration.useWeightCategoriesOrNot")}'/>
+
+ <%--use weight categories in stratum--%>
+ <s:checkbox key="configuration.useWeightCategoriesInStratum" label='%{getText("t3.common.useWeightCategoriesInStratum")}'/>
+
<br/>
<table class="cleanBoth">
<tr>
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/compare/19e6e2e502638a48564ef16caeac794…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/compare/19e6e2e502638a48564ef16caeac794…
You're receiving this email because of your account on gitlab.com.
1
0
21 Feb '18
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
19e6e2e5 by Tony CHEMIT at 2018-02-21T16:15:01+01:00
Fix loading trips with no ocean
- - - - -
3 changed files:
- t3-web/src/main/java/fr/ird/t3/web/actions/T3ActionSupport.java
- t3-web/src/main/java/fr/ird/t3/web/actions/admin/TripListAction.java
- t3-web/src/main/java/fr/ird/t3/web/actions/json/GetTripsAction.java
Changes:
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/T3ActionSupport.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/T3ActionSupport.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/T3ActionSupport.java
@@ -32,7 +32,6 @@ import fr.ird.t3.entities.T3UserTopiaPersistenceContext;
import fr.ird.t3.entities.data.TripTopiaDao;
import fr.ird.t3.entities.reference.Idable;
import fr.ird.t3.entities.reference.Ocean;
-import fr.ird.t3.entities.reference.OceanImpl;
import fr.ird.t3.services.DecoratorService;
import fr.ird.t3.services.DefaultT3ServiceContext;
import fr.ird.t3.services.FreeMarkerService;
@@ -343,6 +342,8 @@ public class T3ActionSupport extends ActionSupport implements T3TopiaPersistence
protected TripListModel loadTripListModel(TripTopiaDao tripDAO) throws TopiaException {
+ TripTopiaDao.EMPTY_OCEAN.setLabel1(t("t3.common.nullOcean"));
+
long t0 = TimeLog.getTime();
if (log.isInfoEnabled()) {
log.info("Loading tripListModel...");
@@ -357,24 +358,7 @@ public class T3ActionSupport extends ActionSupport implements T3TopiaPersistence
List<Ocean> allOceans = new ArrayList<>(allByOcean.keySet());
- if (allOceans.contains(TripTopiaDao.EMPTY_OCEAN)) {
-
- // there is some trips with no oceans
- Ocean nullOcean = new OceanImpl();
- nullOcean.setLabel1(t("t3.common.nullOcean"));
- nullOcean.setTopiaId("null");
-
- Collection<String> ids = allByOcean.get(TripTopiaDao.EMPTY_OCEAN);
- if (log.isInfoEnabled()) {
- log.info(String.format("Add a nullOcean : %s for %d trip(s).", nullOcean.getLabel1(), ids.size()));
- }
- allOceans.remove(null);
- allOceans.add(nullOcean);
-
- allByOcean.putAll(nullOcean, ids);
- allByOcean.removeAll(TripTopiaDao.EMPTY_OCEAN);
- }
- TIME_LOG.log(t0, String.format("loadTripListModel for %d trips.", result.getNbTrips()));
+ TIME_LOG.log(t0, String.format("loadTripListModel for %d trip(s) (%d ocean(s)).", result.getNbTrips(), allOceans.size()));
allOceans = sortToList(allOceans);
result.setOceans(allOceans);
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/admin/TripListAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/admin/TripListAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/admin/TripListAction.java
@@ -41,38 +41,38 @@ import org.apache.commons.logging.LogFactory;
*/
public class TripListAction extends T3ActionSupport {
- protected static final Log log = LogFactory.getLog(TripListAction.class);
+ private static final Log log = LogFactory.getLog(TripListAction.class);
private static final long serialVersionUID = 1L;
@InjectDAO(entityType = Trip.class)
- protected transient TripTopiaDao tripDAO;
+ private transient TripTopiaDao tripDAO;
@InjectFromDAO(entityType = Trip.class, method = "findAllYearsUsedInTrip")
- protected Collection<Integer> allYears;
+ private Collection<Integer> allYears;
@InjectFromDAO(entityType = Country.class, method = "findAllFleetUsedInTrip")
- protected Collection<Country> allFleets;
+ private Collection<Country> allFleets;
@InjectFromDAO(entityType = Country.class, method = "findAllFlagUsedInTrip")
- protected Collection<Country> allFlags;
+ private Collection<Country> allFlags;
@InjectFromDAO(entityType = Vessel.class, method = "findAllUsedInTrip")
- protected Collection<Vessel> allVessels;
+ private Collection<Vessel> allVessels;
- protected Map<String, String> years;
+ private Map<String, String> years;
- protected Map<String, String> oceans;
+ private Map<String, String> oceans;
- protected Map<String, String> fleets;
+ private Map<String, String> fleets;
- protected Map<String, String> flags;
+ private Map<String, String> flags;
- protected Map<String, String> vessels;
+ private Map<String, String> vessels;
- protected TripListModel tripListModel;
+ private TripListModel tripListModel;
- protected boolean back;
+ private boolean back;
public Map<String, String> getYears() {
return years;
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/json/GetTripsAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/json/GetTripsAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/json/GetTripsAction.java
@@ -20,7 +20,6 @@
*/
package fr.ird.t3.web.actions.json;
-import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import fr.ird.t3.entities.data.Trip;
import fr.ird.t3.entities.data.TripDTO;
@@ -33,18 +32,18 @@ import fr.ird.t3.entities.reference.Vessel;
import fr.ird.t3.entities.reference.VesselTopiaDao;
import fr.ird.t3.services.ioc.InjectDAO;
import fr.ird.t3.web.actions.admin.TripListModel;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.persistence.TopiaDao;
import org.nuiton.topia.persistence.TopiaEntity;
-import org.nuiton.topia.persistence.TopiaException;
import org.nuiton.util.PagerBeanUtil;
import org.nuiton.util.TimeLog;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
/**
* Obtains a list of trips.
*
@@ -54,32 +53,25 @@ import org.nuiton.util.TimeLog;
public class GetTripsAction extends AbstractJSONPaginedAction {
private static final long serialVersionUID = 1L;
-
- /** Logger. */
private static final Log log = LogFactory.getLog(GetTripsAction.class);
-
private static final TimeLog TIME_LOG = new TimeLog(GetTripsAction.class);
@InjectDAO(entityType = Trip.class)
- protected transient TripTopiaDao tripDAO;
-
+ private transient TripTopiaDao tripDAO;
@InjectDAO(entityType = Ocean.class)
- protected transient OceanTopiaDao oceanDAO;
-
+ private transient OceanTopiaDao oceanDAO;
@InjectDAO(entityType = Country.class)
- protected transient CountryTopiaDao countryDAO;
-
+ private transient CountryTopiaDao countryDAO;
@InjectDAO(entityType = Vessel.class)
- protected transient VesselTopiaDao vesselDAO;
+ private transient VesselTopiaDao vesselDAO;
- protected List<TripDTO> trips;
+ private TripListModel model;
+ private List<TripDTO> trips;
public List<TripDTO> getTrips() {
return trips;
}
- protected TripListModel model;
-
@Override
public String execute() throws Exception {
@@ -102,17 +94,17 @@ public class GetTripsAction extends AbstractJSONPaginedAction {
List<String> oceanIds = model.getOceanIds();
- allTripIds = Lists.newArrayList();
+ allTripIds = new ArrayList<>();
if (CollectionUtils.isNotEmpty(oceanIds)) {
for (String oceanId : oceanIds) {
Ocean ocean;
- if ("null".equals(oceanId)) {
- ocean = null;
+ if (TripTopiaDao.EMPTY_OCEAN.getTopiaId().equals(oceanId)) {
+ ocean = TripTopiaDao.EMPTY_OCEAN;
} else {
- ocean = oceanDAO.findByTopiaId(oceanId);
+ ocean = oceanDAO.forTopiaIdEquals(oceanId).findUnique();
}
Collection<String> allByOcean = tripsByOcean.get(ocean);
allTripIds.addAll(allByOcean);
@@ -120,7 +112,7 @@ public class GetTripsAction extends AbstractJSONPaginedAction {
}
} else {
- allTripIds = Lists.newArrayList(tripsByOcean.values());
+ allTripIds = new ArrayList<>(tripsByOcean.values());
}
if (log.isInfoEnabled()) {
@@ -130,7 +122,7 @@ public class GetTripsAction extends AbstractJSONPaginedAction {
t0 = TimeLog.getTime();
if (CollectionUtils.isEmpty(allTripIds)) {
- allTrips = Lists.newArrayList();
+ allTrips = new ArrayList<>();
} else {
allTrips = tripDAO.findAllByIds(allTripIds);
}
@@ -142,20 +134,15 @@ public class GetTripsAction extends AbstractJSONPaginedAction {
filterYears(allTrips);
}
if (log.isInfoEnabled()) {
- log.info("Nb total trips (after year filter) " + allTrips.size());
+ log.info(String.format("Nb total trips (after year filter) %d", allTrips.size()));
}
- if (CollectionUtils.isNotEmpty(allTrips) &&
- model.isVesselFilter() ||
- model.isFlagFilter() ||
- model.isFleetFilter()) {
-
+ if (CollectionUtils.isNotEmpty(allTrips) && model.isVesselFilter() || model.isFlagFilter() || model.isFleetFilter()) {
filterVessels(allTrips);
}
if (log.isInfoEnabled()) {
- log.info("Nb total trips (after vessel / flag / fleet filter) " +
- allTrips.size());
+ log.info(String.format("Nb total trips (after vessel / flag / fleet filter) %d", allTrips.size()));
}
TIME_LOG.log(t0, "all filter");
@@ -192,7 +179,7 @@ public class GetTripsAction extends AbstractJSONPaginedAction {
}
}
- private void filterVessels(List<Trip> allTrips) throws TopiaException {
+ private void filterVessels(List<Trip> allTrips) {
Collection<Vessel> vessels = VesselTopiaDao.getAllVessels(allTrips);
@@ -270,9 +257,8 @@ public class GetTripsAction extends AbstractJSONPaginedAction {
return pager.getRecords();
}
- protected <E extends TopiaEntity> Collection<E> loadEntities(TopiaDao<E> dao,
- Iterable<String> ids) throws TopiaException {
- Collection<E> result = Lists.newArrayList();
+ protected <E extends TopiaEntity> Collection<E> loadEntities(TopiaDao<E> dao, Iterable<String> ids) {
+ Collection<E> result = new ArrayList<>();
for (String id : ids) {
E e = dao.forTopiaIdEquals(id).findUnique();
result.add(e);
@@ -281,11 +267,8 @@ public class GetTripsAction extends AbstractJSONPaginedAction {
}
protected <E> List<E> getPageFromList(List<E> elements) {
-
PagerBeanUtil.computeRecordIndexesAndPagesNumber(pager);
List<E> subList = PagerBeanUtil.getPage(elements, pager.getPageIndex(), pager.getPageSize());
- List<E> result = new ArrayList<E>(subList);
-
- return result;
+ return new ArrayList<>(subList);
}
}
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/19e6e2e502638a48564ef16caeac7941…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/19e6e2e502638a48564ef16caeac7941…
You're receiving this email because of your account on gitlab.com.
1
0
21 Feb '18
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
b1ffee7e by Tony CHEMIT at 2018-02-21T14:06:48+01:00
Revert removed method
- - - - -
89e03ab7 by Tony CHEMIT at 2018-02-21T15:48:15+01:00
Sur la page 'Gérer les marées', la mise en page déborde de l'écran à droite. Voir la PJ. Cela génère un ascenseur horizontal, pourtant inutile. (Closes #232)
- - - - -
5ce68d04 by Tony CHEMIT at 2018-02-21T15:50:10+01:00
[UI][N2][N3] Changer la sélection de la flotte d'une sélection unique vers une sélection multiple (Closes #243)
- - - - -
16 changed files:
- t3-actions/src/main/java/fr/ird/t3/actions/data/level2/Level2Action.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level3/Level3Action.java
- t3-domain/src/main/java/fr/ird/t3/actions/stratum/LevelConfigurationWithStratum.java
- t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractTripTopiaDao.java
- t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractCountryTopiaDao.java
- t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractVesselTopiaDao.java
- t3-web/src/main/java/fr/ird/t3/web/actions/T3ActionSupport.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/ConfigureLevel2Step1Action.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/Level2ConfigureAction.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/Level2RunAction.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level3/ConfigureLevel3Step1Action.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level3/Level3ConfigureAction.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level3/Level3RunAction.java
- t3-web/src/main/webapp/WEB-INF/jsp/admin/tripList.jsp
- t3-web/src/main/webapp/WEB-INF/jsp/data/level2/level2ConfigurationStep1.jsp
- t3-web/src/main/webapp/WEB-INF/jsp/data/level3/level3ConfigurationStep1.jsp
Changes:
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level2/Level2Action.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level2/Level2Action.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level2/Level2Action.java
@@ -52,7 +52,6 @@ import fr.ird.t3.services.DecoratorService;
import fr.ird.t3.services.ZoneStratumService;
import fr.ird.t3.services.ioc.InjectDAO;
import fr.ird.t3.services.ioc.InjectEntitiesById;
-import fr.ird.t3.services.ioc.InjectEntityById;
import fr.ird.t3.services.ioc.InjectFromDAO;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
@@ -83,8 +82,7 @@ import static org.nuiton.i18n.I18n.l;
*/
public class Level2Action extends T3Action<Level2Configuration> {
- public static final String PARAM_LEVEL_CONFIGURATION = "levelConfiguration";
- /** Logger. */
+ // public static final String PARAM_LEVEL_CONFIGURATION = "levelConfiguration";
private static final Log log = LogFactory.getLog(Level2Action.class);
/**
* Cache of activity (to avoid to reload them for catch and sample stratum).
@@ -93,6 +91,28 @@ public class Level2Action extends T3Action<Level2Configuration> {
*/
private final LoadingCache<String, Activity> activityCache;
private final Map<String, OceanContext> oceanContext;
+ /**
+ * Input Weight composition
+ * (based on {@link CorrectedElementaryCatch#getCatchWeight()}) for all
+ * species found in catches.
+ *
+ * @since 1.3
+ */
+ WeightCompositionAggregateModel inputCatchModelForAllSpecies;
+ /**
+ * Output Weight composition
+ * (based on {@link CorrectedElementaryCatch#getCorrectedCatchWeight()}) for all
+ * species found in catches.
+ *
+ * @since 1.3
+ */
+ WeightCompositionAggregateModel outputCatchModelForAllSpecies;
+ /**
+ * For each stratum gets his result.
+ *
+ * @since 1.3
+ */
+ Collection<L2StratumResult> stratumsResult;
@InjectDAO(entityType = Activity.class)
private ActivityTopiaDao activityDAO;
@InjectDAO(entityType = WeightCategoryTreatment.class)
@@ -105,8 +125,8 @@ public class Level2Action extends T3Action<Level2Configuration> {
private ZoneVersion zoneVersion;
@InjectFromDAO(entityType = SchoolType.class, method = "findAllForStratum")
private Set<SchoolType> schoolTypes;
- @InjectEntityById(entityType = Country.class)
- private Country catchFleet;
+ @InjectEntitiesById(entityType = Country.class)
+ private Set<Country> catchFleets;
@InjectEntitiesById(entityType = Ocean.class)
private Set<Ocean> oceans;
@InjectEntitiesById(entityType = Species.class, path = "configuration.speciesIds")
@@ -116,8 +136,6 @@ public class Level2Action extends T3Action<Level2Configuration> {
@InjectEntitiesById(entityType = Country.class)
private Collection<Country> sampleFlags;
private Set<T3Date> startDates;
- // private Multimap<SchoolType, WeightCategoryTreatment> weightCategoriesBySchoolType;
-// private Multimap<SchoolType, ZoneStratumAware> zoneBySchoolType;
private Set<Vessel> possibleCatchVessels;
private Set<Vessel> possibleSampleVessels;
private int nbStratums;
@@ -125,28 +143,6 @@ public class Level2Action extends T3Action<Level2Configuration> {
private long totalCatchWeight;
private long totalCatchActivities;
private long totalCatchActivitiesWithSample;
- /**
- * Input Weight composition
- * (based on {@link CorrectedElementaryCatch#getCatchWeight()}) for all
- * species found in catches.
- *
- * @since 1.3
- */
- WeightCompositionAggregateModel inputCatchModelForAllSpecies;
- /**
- * Output Weight composition
- * (based on {@link CorrectedElementaryCatch#getCorrectedCatchWeight()}) for all
- * species found in catches.
- *
- * @since 1.3
- */
- WeightCompositionAggregateModel outputCatchModelForAllSpecies;
- /**
- * For each stratum gets his result.
- *
- * @since 1.3
- */
- Collection<L2StratumResult> stratumsResult;
public Level2Action() {
activityCache = CacheBuilder.newBuilder().build(
@@ -189,7 +185,7 @@ public class Level2Action extends T3Action<Level2Configuration> {
setStartDates(T3Date.getStartDates(configuration.getBeginDate(), configuration.getEndDate(), configuration.getTimeStep()));
// get possible vessels for catch stratum
- setPossibleCatchVessels(vesselDAO.getPossibleCatchVessels(catchFleet));
+ setPossibleCatchVessels(vesselDAO.getPossibleCatchVessels(catchFleets));
// get possible vessels for sample stratum
setPossibleSampleVessels(vesselDAO.getPossibleSampleVessels(sampleFleets, sampleFlags));
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level3/Level3Action.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level3/Level3Action.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level3/Level3Action.java
@@ -102,13 +102,12 @@ import static org.nuiton.i18n.I18n.n;
*/
public class Level3Action extends T3Action<Level3Configuration> {
- public static final String BEFORE_LEVEL3 = n("t3.level3.nbFishesBeforeLevel3");
- public static final String AFTER_LEVEL3 = n("t3.level3.nbFishesAfterLevel3");
- public static final String INSERT_QUERY =
+ private static final String BEFORE_LEVEL3 = n("t3.level3.nbFishesBeforeLevel3");
+ private static final String AFTER_LEVEL3 = n("t3.level3.nbFishesAfterLevel3");
+ private static final String INSERT_QUERY =
"INSERT INTO ExtrapolatedAllSetSpeciesFrequency(TOPIAID, TOPIAVERSION, TOPIACREATEDATE, ACTIVITY, SPECIES, LFLENGTHCLASS, NUMBER) VALUES ('%s', 0, TIMESTAMP '%s 00:00:00.0', '%s','%s', %s, %s);\n";
- public static final String UPDATE_QUERY =
+ private static final String UPDATE_QUERY =
"UPDATE ExtrapolatedAllSetSpeciesFrequency SET NUMBER = NUMBER + %s WHERE TOPIAID = '%s';\n";
- /** Logger. */
private static final Log log = LogFactory.getLog(Level3Action.class);
/**
* Cache of activity (to avoid to reload them for catch and smaple stratum).
@@ -117,7 +116,25 @@ public class Level3Action extends T3Action<Level3Configuration> {
*/
private final LoadingCache<String, Activity> activityCache;
private final Map<String, OceanContext> oceanContext;
- Map<String, Map<String, String>> activityWithMultiZones = new TreeMap<>();
+ /**
+ * Global total fishes count for all stratums.
+ * <p/>
+ * We store two count here :
+ * <ul>
+ * <li>{@link #BEFORE_LEVEL3} : total fishes count before level 3</li>
+ * <li>{@link #AFTER_LEVEL3} : total fishes count after level 3</li>
+ * </ul>
+ *
+ * @since 1.3.1
+ */
+ SpeciesCountAggregateModel totalFishesCount;
+ /**
+ * For each stratum gets his result.
+ *
+ * @since 1.3.1
+ */
+ Collection<L3StratumResult> stratumsResult;
+ private Map<String, Map<String, String>> activityWithMultiZones;
@InjectDAO(entityType = Activity.class)
private ActivityTopiaDao activityDAO;
@InjectDAO(entityType = LengthWeightConversion.class)
@@ -136,12 +153,10 @@ public class Level3Action extends T3Action<Level3Configuration> {
private ZoneVersion zoneVersion;
@InjectFromDAO(entityType = SchoolType.class, method = "findAllForStratum")
private Set<SchoolType> schoolTypes;
- // private Multimap<SchoolType, ZoneStratumAware> zoneBySchoolType;
@InjectEntityById(entityType = Ocean.class)
private Ocean ocean;
- @InjectEntityById(entityType = Country.class)
- private Country catchFleet;
- // private Multimap<SchoolType, WeightCategoryTreatment> weightCategoriesBySchoolType;
+ @InjectEntitiesById(entityType = Country.class)
+ private Set<Country> catchFleets;
@InjectEntitiesById(entityType = Species.class, path = "configuration.speciesIds")
private Collection<Species> species;
@InjectEntitiesById(entityType = Country.class)
@@ -153,30 +168,11 @@ public class Level3Action extends T3Action<Level3Configuration> {
private Set<T3Date> startDates;
private Set<Vessel> possibleCatchVessels;
private Set<Vessel> possibleSampleVessels;
- // private LengthWeightConversionHelper conversionHelper;
private Map<SchoolType, Map<String, Integer>> stratumMinimumSampleCountBySchoolType;
private int nbStratums;
private long nbCatchActivities;
private long nbCatchActivitiesWithSample;
/**
- * Global total fishes count for all stratums.
- * <p/>
- * We store two count here :
- * <ul>
- * <li>{@link #BEFORE_LEVEL3} : total fishes count before level 3</li>
- * <li>{@link #AFTER_LEVEL3} : total fishes count after level 3</li>
- * </ul>
- *
- * @since 1.3.1
- */
- SpeciesCountAggregateModel totalFishesCount;
- /**
- * For each stratum gets his result.
- *
- * @since 1.3.1
- */
- Collection<L3StratumResult> stratumsResult;
- /**
* Predicate to filter only species selected in configuration.
*
* @since 1.4
@@ -196,6 +192,7 @@ public class Level3Action extends T3Action<Level3Configuration> {
}
);
oceanContext = new TreeMap<>();
+ activityWithMultiZones = new TreeMap<>();
}
@Override
@@ -249,7 +246,7 @@ public class Level3Action extends T3Action<Level3Configuration> {
}
// get possible vessels for catch stratum
- setPossibleCatchVessels(vesselDAO.getPossibleCatchVessels(catchFleet));
+ setPossibleCatchVessels(vesselDAO.getPossibleCatchVessels(catchFleets));
// get possible vessels for sample stratum
setPossibleSampleVessels(vesselDAO.getPossibleSampleVessels(sampleFleets, sampleFlags));
=====================================
t3-domain/src/main/java/fr/ird/t3/actions/stratum/LevelConfigurationWithStratum.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/actions/stratum/LevelConfigurationWithStratum.java
+++ b/t3-domain/src/main/java/fr/ird/t3/actions/stratum/LevelConfigurationWithStratum.java
@@ -51,8 +51,8 @@ public abstract class LevelConfigurationWithStratum implements T3ActionConfigura
/** Id of selected version of ZoneImpl. */
private String zoneVersionId;
- /** Selected fleet id (for catch filtering). */
- private String catchFleetId;
+ /** Selected fleet ids (for catch filtering). */
+ private Set<String> catchFleetIds;
/** Number of months to define a stratus. */
private int timeStep;
@@ -172,12 +172,12 @@ public abstract class LevelConfigurationWithStratum implements T3ActionConfigura
this.endDate = endDate;
}
- public String getCatchFleetId() {
- return catchFleetId;
+ public Set<String> getCatchFleetIds() {
+ return catchFleetIds == null ? catchFleetIds = new LinkedHashSet<>() : catchFleetIds;
}
- public void setCatchFleetId(String catchFleetId) {
- this.catchFleetId = catchFleetId;
+ public void setCatchFleetIds(Set<String> catchFleetIds) {
+ this.catchFleetIds = catchFleetIds;
}
public Set<String> getSampleFleetIds() {
=====================================
t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractTripTopiaDao.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractTripTopiaDao.java
+++ b/t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractTripTopiaDao.java
@@ -143,6 +143,9 @@ public class AbstractTripTopiaDao<E extends Trip> extends GeneratedTripTopiaDao<
}
public static final Ocean EMPTY_OCEAN = new OceanImpl();
+ static {
+ EMPTY_OCEAN.setTopiaId("fr.ird.t3.entities.reference.Ocean#EMPTY#EMPTY");
+ }
public Multimap<Ocean, String> findAllIdsByOcean() throws TopiaException {
=====================================
t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractCountryTopiaDao.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractCountryTopiaDao.java
+++ b/t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractCountryTopiaDao.java
@@ -60,6 +60,11 @@ public class AbstractCountryTopiaDao<E extends Country> extends GeneratedCountry
// return T3EntityHelper.querytoSet(hql, this);
}
+ public Set<E> findAllFleetUsedInTrip() throws TopiaException {
+ return findAllFleetUsedInTrip(null);
+ }
+
+
/**
* Obtains all countries used as flag for any trip in the database.
*
=====================================
t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractVesselTopiaDao.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractVesselTopiaDao.java
+++ b/t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractVesselTopiaDao.java
@@ -28,12 +28,12 @@ import com.google.common.collect.Sets;
import fr.ird.t3.entities.T3Functions;
import fr.ird.t3.entities.T3Predicates;
import fr.ird.t3.entities.data.Trip;
-import java.util.Arrays;
+import org.nuiton.topia.persistence.TopiaException;
+
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.nuiton.topia.persistence.TopiaException;
/**
* {@link Vessel} user dao operations.
@@ -62,8 +62,7 @@ public class AbstractVesselTopiaDao<E extends Vessel> extends GeneratedVesselTop
}
/**
- * Obtain the set of possible vessels usable from the configuration to
- * obtain catches of the catch stratum.
+ * Obtain the set of possible vessels usable from the configuration to obtain catches of the catch stratum.
* <p/>
* Vessels must verifiy two conditions :
* <ul>
@@ -71,23 +70,19 @@ public class AbstractVesselTopiaDao<E extends Vessel> extends GeneratedVesselTop
* <li>Be in the selected fleet (from the configuration)</li>
* </ul>
*
- * @param country level 2 configuration
- * @return set of possible vessels usable for activity (so trips) of the
- * catch stratum
+ * @param countries selected countries
+ * @return set of possible vessels usable for activity (so trips) of the catch stratum
* @throws TopiaException if any problem while loading data
*/
- public Set<E> getPossibleCatchVessels(Country country) throws TopiaException {
+ public Set<E> getPossibleCatchVessels(Collection<Country> countries) throws TopiaException {
List<E> vessels = forProperties(
Vessel.PROPERTY_VESSEL_TYPE + "." +
VesselType.PROPERTY_VESSEL_SIMPLE_TYPE + "." +
VesselSimpleType.PROPERTY_CODE, 1).findAll();
- Predicate<Vessel> predicate =
- T3Predicates.vesselUsingFleetCountry(Arrays.asList(country));
-
- return Sets.newHashSet(
- Collections2.filter(vessels, predicate));
+ Predicate<Vessel> predicate = T3Predicates.vesselUsingFleetCountry(countries);
+ return Sets.newHashSet(Collections2.filter(vessels, predicate));
}
/**
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/T3ActionSupport.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/T3ActionSupport.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/T3ActionSupport.java
@@ -51,24 +51,26 @@ import fr.ird.t3.web.T3InternalTransactionFilter;
import fr.ird.t3.web.T3Session;
import fr.ird.t3.web.T3UserTransactionFilter;
import fr.ird.t3.web.actions.admin.TripListModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts2.StrutsStatics;
+import org.nuiton.decorator.Decorator;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.TopiaException;
+import org.nuiton.util.TimeLog;
+
+import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
-import javax.servlet.http.HttpServletRequest;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.struts2.StrutsStatics;
-import org.nuiton.decorator.Decorator;
-import org.nuiton.topia.persistence.TopiaEntity;
-import org.nuiton.topia.persistence.TopiaException;
-import org.nuiton.util.TimeLog;
@@ -353,29 +355,26 @@ public class T3ActionSupport extends ActionSupport implements T3TopiaPersistence
result.setTripIdsByOcean(allByOcean);
getT3Session().setTripListModel(result);
- List<Ocean> allOceans = Lists.newArrayList(allByOcean.keySet());
+ List<Ocean> allOceans = new ArrayList<>(allByOcean.keySet());
- if (allOceans.contains(null)) {
+ if (allOceans.contains(TripTopiaDao.EMPTY_OCEAN)) {
// there is some trips with no oceans
Ocean nullOcean = new OceanImpl();
nullOcean.setLabel1(t("t3.common.nullOcean"));
nullOcean.setTopiaId("null");
+ Collection<String> ids = allByOcean.get(TripTopiaDao.EMPTY_OCEAN);
if (log.isInfoEnabled()) {
- log.info("Add a nullOcean : " + nullOcean.getLabel1() +
- " for " + allByOcean.get(null).size() +
- " trip(s).");
+ log.info(String.format("Add a nullOcean : %s for %d trip(s).", nullOcean.getLabel1(), ids.size()));
}
allOceans.remove(null);
allOceans.add(nullOcean);
- Collection<String> ids = allByOcean.get(null);
allByOcean.putAll(nullOcean, ids);
- allByOcean.removeAll(null);
+ allByOcean.removeAll(TripTopiaDao.EMPTY_OCEAN);
}
- TIME_LOG.log(t0, "loadTripListModel for " + result.getNbTrips() +
- " trips.");
+ TIME_LOG.log(t0, String.format("loadTripListModel for %d trips.", result.getNbTrips()));
allOceans = sortToList(allOceans);
result.setOceans(allOceans);
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/ConfigureLevel2Step1Action.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/ConfigureLevel2Step1Action.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/ConfigureLevel2Step1Action.java
@@ -139,7 +139,7 @@ public class ConfigureLevel2Step1Action extends AbstractConfigureAction<Level2Co
injectOnly(InjectDecoratedBeans.class);
if (CollectionUtils.isEmpty(conf.getCatchFleets())) {
- addFieldError("configuration.catchFleetId", t("t3.error.no.catch.fleet.found"));
+ addFieldError("configuration.catchFleetIds", t("t3.error.no.catch.fleet.found"));
missingDatas = true;
}
@@ -188,7 +188,7 @@ public class ConfigureLevel2Step1Action extends AbstractConfigureAction<Level2Co
if (log.isInfoEnabled()) {
log.info("Selected species : " + conf.getSpeciesIds());
- log.info("Selected catch fleet country : " + conf.getCatchFleetId());
+ log.info("Selected catch fleets : " + conf.getCatchFleetIds());
log.info("Selected ocean : " + conf.getOceanIds());
log.info("Selected begin date : " + conf.getBeginDate());
log.info("Selected end date : " + conf.getEndDate());
@@ -217,8 +217,8 @@ public class ConfigureLevel2Step1Action extends AbstractConfigureAction<Level2Co
addFieldError("zoneVersionId", t("t3.error.no.zoneVersion.selected"));
}
- if (StringUtils.isEmpty(config.getCatchFleetId())) {
- addFieldError("configuration.catchFleetId", t("t3.error.no.catch.fleet.selected"));
+ if (CollectionUtils.isEmpty(config.getCatchFleetIds())) {
+ addFieldError("configuration.catchFleetIds", t("t3.error.no.catch.fleet.selected"));
}
boolean speciesOk = true;
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/Level2ConfigureAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/Level2ConfigureAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/Level2ConfigureAction.java
@@ -43,15 +43,15 @@ public class Level2ConfigureAction extends AbstractConfigureAction<Level2Configu
private final Map<String, String> timeSteps = createTimeSteps();
- @InjectDecoratedBeans(beanType = Country.class, filterById = true, filterBySingleId = true)
- private Map<String, String> catchFleets;
-
@InjectDecoratedBeans(beanType = ZoneStratumAwareMeta.class)
private Map<String, String> zoneTypes;
@InjectDecoratedBeans(beanType = ZoneVersion.class)
private Map<String, String> zoneVersions;
+ @InjectDecoratedBeans(beanType = Country.class, filterById = true)
+ private Map<String, String> catchFleets;
+
@InjectDecoratedBeans(beanType = Ocean.class, filterById = true)
private Map<String, String> oceans;
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/Level2RunAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/Level2RunAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/Level2RunAction.java
@@ -45,15 +45,15 @@ public class Level2RunAction extends AbstractRunAction<Level2Configuration, Leve
private final Map<String, String> timeSteps = createTimeSteps();
- @InjectDecoratedBeans(beanType = Country.class, filterById = true, filterBySingleId = true)
- private Map<String, String> catchFleets;
-
@InjectDecoratedBeans(beanType = ZoneStratumAwareMeta.class)
private Map<String, String> zoneTypes;
@InjectDecoratedBeans(beanType = ZoneVersion.class)
private Map<String, String> zoneVersions;
+ @InjectDecoratedBeans(beanType = Country.class, filterById = true)
+ private Map<String, String> catchFleets;
+
@InjectDecoratedBeans(beanType = Ocean.class, filterById = true)
private Map<String, String> oceans;
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/data/level3/ConfigureLevel3Step1Action.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/data/level3/ConfigureLevel3Step1Action.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/data/level3/ConfigureLevel3Step1Action.java
@@ -141,7 +141,7 @@ public class ConfigureLevel3Step1Action extends AbstractConfigureAction<Level3Co
injectOnly(InjectDecoratedBeans.class);
if (CollectionUtils.isEmpty(conf.getCatchFleets())) {
- addFieldError("configuration.catchFleetId", t("t3.error.no.catch.fleet.found"));
+ addFieldError("configuration.catchFleetIds", t("t3.error.no.catch.fleet.found"));
missingDatas = true;
}
@@ -187,13 +187,13 @@ public class ConfigureLevel3Step1Action extends AbstractConfigureAction<Level3Co
if (log.isInfoEnabled()) {
log.info("Selected species : " + conf.getSpeciesIds());
- log.info("Selected catch fleet country : " + conf.getCatchFleetId());
+ log.info("Selected catch fleets : " + conf.getCatchFleetIds());
log.info("Selected ocean : " + conf.getOceanIds());
log.info("Selected begin date : " + conf.getBeginDate());
log.info("Selected end date : " + conf.getEndDate());
log.info("Selected time step : " + conf.getTimeStep());
log.info("Selected zone type : " + conf.getZoneTypeId());
- log.info("Selected zone version : " + conf.getZoneVersionId());
+ log.info("Selected zone version : " + conf.getZoneVersionId());
}
}
@@ -217,8 +217,8 @@ public class ConfigureLevel3Step1Action extends AbstractConfigureAction<Level3Co
addFieldError("zoneVersionId", t("t3.error.no.zoneVersion.selected"));
}
- if (StringUtils.isEmpty(config.getCatchFleetId())) {
- addFieldError("configuration.catchFleetId", t("t3.error.no.catch.fleet.selected"));
+ if (CollectionUtils.isEmpty(config.getCatchFleetIds())) {
+ addFieldError("configuration.catchFleetIds", t("t3.error.no.catch.fleet.selected"));
}
T3Date beginDate = config.getBeginDate();
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/data/level3/Level3ConfigureAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/data/level3/Level3ConfigureAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/data/level3/Level3ConfigureAction.java
@@ -48,10 +48,6 @@ public class Level3ConfigureAction extends AbstractConfigureAction<Level3Configu
private final Map<String, String> timeSteps = createTimeSteps();
- /** all fleet Countries. */
- @InjectDecoratedBeans(beanType = Country.class, filterById = true, filterBySingleId = true)
- private Map<String, String> catchFleets;
-
/** all zoneTypes. */
@InjectDecoratedBeans(beanType = ZoneStratumAwareMeta.class)
private Map<String, String> zoneTypes;
@@ -60,6 +56,10 @@ public class Level3ConfigureAction extends AbstractConfigureAction<Level3Configu
@InjectDecoratedBeans(beanType = ZoneVersion.class)
private Map<String, String> zoneVersions;
+ /** all fleet Countries. */
+ @InjectDecoratedBeans(beanType = Country.class, filterById = true)
+ private Map<String, String> catchFleets;
+
/** all oceans. */
@InjectDecoratedBeans(beanType = Ocean.class, filterById = true)
private Map<String, String> oceans;
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/data/level3/Level3RunAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/data/level3/Level3RunAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/data/level3/Level3RunAction.java
@@ -47,10 +47,6 @@ public class Level3RunAction extends AbstractRunAction<Level3Configuration, Leve
private final Map<String, String> timeSteps = createTimeSteps();
- /** all fleet Countries. */
- @InjectDecoratedBeans(beanType = Country.class, filterById = true, filterBySingleId = true)
- private Map<String, String> catchFleets;
-
/** all zoneTypes. */
@InjectDecoratedBeans(beanType = ZoneStratumAwareMeta.class)
private Map<String, String> zoneTypes;
@@ -59,8 +55,12 @@ public class Level3RunAction extends AbstractRunAction<Level3Configuration, Leve
@InjectDecoratedBeans(beanType = ZoneVersion.class)
private Map<String, String> zoneVersions;
+ /** all fleet Countries. */
+ @InjectDecoratedBeans(beanType = Country.class, filterById = true)
+ private Map<String, String> catchFleets;
+
/** all oceans. */
- @InjectDecoratedBeans(beanType = Ocean.class, filterById = true, filterBySingleId = true)
+ @InjectDecoratedBeans(beanType = Ocean.class, filterById = true)
private Map<String, String> oceans;
/** all species. */
=====================================
t3-web/src/main/webapp/WEB-INF/jsp/admin/tripList.jsp
=====================================
--- a/t3-web/src/main/webapp/WEB-INF/jsp/admin/tripList.jsp
+++ b/t3-web/src/main/webapp/WEB-INF/jsp/admin/tripList.jsp
@@ -26,6 +26,18 @@
<title><s:text name="t3.label.admin.trip.list"/></title>
<s:set var="userIsAdmin" value="%{#session.t3Session.user.admin}"/>
+<style type="text/css">
+ .wwlbl {
+ width: auto;
+ }
+ .wwgrp {
+ width: auto;
+ }
+ .filterClass {
+ width:150px;
+ }
+</style>
+
<script type="text/javascript">
jQuery(document).ready(function () {
=====================================
t3-web/src/main/webapp/WEB-INF/jsp/data/level2/level2ConfigurationStep1.jsp
=====================================
--- a/t3-web/src/main/webapp/WEB-INF/jsp/data/level2/level2ConfigurationStep1.jsp
+++ b/t3-web/src/main/webapp/WEB-INF/jsp/data/level2/level2ConfigurationStep1.jsp
@@ -84,10 +84,10 @@
<sj:select key="zoneVersionId" list="zoneVersions" href="%{jsonUrl}"
label='%{getText("t3.common.zoneVersion")}' requiredLabel="true"/>
- <%-- selected catch fleet --%>
- <s:select key="configuration.catchFleetId" list="catchFleets" headerKey=""
- headerValue="" label='%{getText("t3.common.catchFleet")}'
- requiredLabel="true"/>
+ <%-- selected catch fleets --%>
+ <s:checkboxlist key="configuration.catchFleetIds" list="catchFleets"
+ label='%{getText("t3.common.catchFleet")}' requiredLabel="true"
+ template="mycheckboxlist"/>
<%-- selected time step --%>
<s:select key="configuration.timeStep" list="timeSteps"
=====================================
t3-web/src/main/webapp/WEB-INF/jsp/data/level3/level3ConfigurationStep1.jsp
=====================================
--- a/t3-web/src/main/webapp/WEB-INF/jsp/data/level3/level3ConfigurationStep1.jsp
+++ b/t3-web/src/main/webapp/WEB-INF/jsp/data/level3/level3ConfigurationStep1.jsp
@@ -84,10 +84,10 @@
<sj:select key="zoneVersionId" list="zoneVersions" href="%{jsonUrl}"
label='%{getText("t3.common.zoneVersion")}' requiredLabel="true"/>
- <%-- selected catch fleet --%>
- <s:select key="configuration.catchFleetId" list="catchFleets" headerKey=""
- headerValue="" label='%{getText("t3.common.catchFleet")}'
- requiredLabel="true"/>
+ <%-- selected catch fleets --%>
+ <s:checkboxlist key="configuration.catchFleetIds" list="catchFleets"
+ label='%{getText("t3.common.catchFleet")}' requiredLabel="true"
+ template="mycheckboxlist"/>
<%-- selected time step --%>
<s:select key="configuration.timeStep" list="timeSteps"
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/compare/b2092129c7170996af5c03ce4e4d8ad…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/compare/b2092129c7170996af5c03ce4e4d8ad…
You're receiving this email because of your account on gitlab.com.
1
0
[Git][ultreiaio/ird-t3][develop] [N1][N2][N3] Permettre la sélection mutliple d'océans (See #260) N2 and N3 done…
by Tony CHEMIT 21 Feb '18
by Tony CHEMIT 21 Feb '18
21 Feb '18
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
b2092129 by Tony CHEMIT at 2018-02-21T13:41:45+01:00
[N1][N2][N3] Permettre la sélection mutliple d'océans (See #260) N2 and N3 done (plus reformat and clean codes and those levels)
- - - - -
28 changed files:
- t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2CatchStratum.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2CatchStratumLoader.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2SampleStratum.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2SampleStratumLoader.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2SampleStratumLoaderAtlantic.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2SampleStratumLoaderIndian.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2StratumResult.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level2/Level2Action.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level2/Level2Configuration.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3CatchStratum.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3CatchStratumLoader.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3SampleStratum.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3SampleStratumLoader.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3SampleStratumLoaderAtlantic.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3SampleStratumLoaderIndian.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3StratumResult.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level3/Level3Action.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level3/Level3Configuration.java
- t3-actions/src/test/java/fr/ird/t3/actions/data/level2/Level2ActionResumeTest.java
- t3-actions/src/test/java/fr/ird/t3/actions/data/level3/Level3ActionResumeTest.java
- t3-domain/src/main/java/fr/ird/t3/actions/stratum/CatchStratum.java
- t3-domain/src/main/java/fr/ird/t3/actions/stratum/LevelConfigurationWithStratum.java
- + t3-domain/src/main/java/fr/ird/t3/actions/stratum/OceanContext.java
- t3-domain/src/main/java/fr/ird/t3/actions/stratum/Stratum.java
- t3-domain/src/main/java/fr/ird/t3/actions/stratum/StratumResult.java
- t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractRouteTopiaDao.java
- t3-domain/src/main/java/fr/ird/t3/entities/data/RouteImpl.java
- t3-domain/src/test/java/fr/ird/t3/entities/T3PersistenceFixtures.java
The diff was not included because it is too large.
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/b2092129c7170996af5c03ce4e4d8ad6…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/b2092129c7170996af5c03ce4e4d8ad6…
You're receiving this email because of your account on gitlab.com.
1
0
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
92a44e1e by Tony CHEMIT at 2018-02-21T10:50:58+01:00
up data version
- - - - -
1 changed file:
- pom.xml
Changes:
=====================================
pom.xml
=====================================
--- a/pom.xml
+++ b/pom.xml
@@ -99,7 +99,7 @@
<organizationId>ultreiaio</organizationId>
<projectId>ird-t3</projectId>
<applicationName>t3</applicationName>
- <t3-data.version>1.2</t3-data.version>
+ <t3-data.version>1.3-SNAPSHOT</t3-data.version>
<env>dev</env>
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/92a44e1e1e6c3b4941de795902469eb3…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/92a44e1e1e6c3b4941de795902469eb3…
You're receiving this email because of your account on gitlab.com.
1
0
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
c6cd77c4 by Tony CHEMIT at 2018-02-21T10:50:19+01:00
Fill Harbour.ocean (See #260)
- - - - -
2 changed files:
- t3-domain/src/main/java/fr/ird/t3/services/migration/T3MigrationCallbackV2_1.java
- + t3-domain/src/main/resources/db/migration/V2_1_09_fill-Harbour-ocean.sql
Changes:
=====================================
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
@@ -122,6 +122,7 @@ public class T3MigrationCallbackV2_1 extends T3MigrationCallbackSupport {
}
addScript("08", "remove-Trip-fields", queries);
+ addScript("09", "fill-Harbour-ocean.sql", queries);
}
=====================================
t3-domain/src/main/resources/db/migration/V2_1_09_fill-Harbour-ocean.sql
=====================================
--- /dev/null
+++ b/t3-domain/src/main/resources/db/migration/V2_1_09_fill-Harbour-ocean.sql
@@ -0,0 +1,55 @@
+---
+-- #%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%
+---
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528928#0.7684791138625932';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528928#0.7462510491346072';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528931#0.7340362909206456';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528929#0.700537735794819';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528929#0.07144864561003117';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528928#0.20978380101744742';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528933#0.3131099550330918';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528929#0.1831238826180489';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528930#0.27388207197386405';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1460000000000#0.17';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1460000000000#0.11';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1460000000000#0.10';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1460000000000#0.9';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1334600123513#0.12332082367823705';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1460000000000#0.18';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528931#0.5663867925551074';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1460000000000#0.16';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528929#0.23557122752694926';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528928#0.715358107654525';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528928#0.00830660499375091';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528929#0.030809936588289455';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1460000000000#0.1';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528929#0.04293415202169404';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528933#0.6009126144931943';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.4917298410119624' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528931#0.40837275149448937';
+
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.02462443299831396' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1460000000000#0.15';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.02462443299831396' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528932#0.863042372573947';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.02462443299831396' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528932#0.9991925653944878';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.02462443299831396' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528932#0.7711735854917587';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.02462443299831396' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528933#0.7511645427969551';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.02462443299831396' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528933#0.17468417015421167';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.02462443299831396' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528933#0.4894751387384305';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.02462443299831396' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528934#0.17822915599428157';
+UPDATE Harbour SET ocean='fr.ird.t3.entities.reference.Ocean#1297580528924#0.02462443299831396' WHERE topiaId = 'fr.ird.t3.entities.reference.Harbour#1297580528932#0.21164070994041773';
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/c6cd77c4cec9558d262813ed641bbd23…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/c6cd77c4cec9558d262813ed641bbd23…
You're receiving this email because of your account on gitlab.com.
1
0