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
February 2018
- 1 participants
- 74 discussions
[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
[Git][ultreiaio/ird-t3][develop] [N1][N2][N3] Permettre la sélection mutliple d'océans (See #260) N1 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:
676b259b by Tony CHEMIT at 2018-02-21T09:17:30+01:00
[N1][N2][N3] Permettre la sélection mutliple d'océans (See #260) N1 done
- - - - -
29 changed files:
- t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeSetDurationAndPositiveSetCountAction.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level1/AbstractLevel1Action.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ComputeWeightOfCategoriesForSetAction.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ConvertSampleSetSpeciesFrequencyToWeightAction.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ConvertSetSpeciesFrequencyToWeightAction.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ExtrapolateSampleCountedAndMeasuredAction.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ExtrapolateSampleWeightToSetAction.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level1/Level1Configuration.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level1/RedistributeSampleNumberToSetAction.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level1/StandardizeSampleMeasuresAction.java
- t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeSetDurationAndPositiveSetCountActionResumeTest.java
- t3-actions/src/test/java/fr/ird/t3/actions/data/level1/ComputeWeightOfCategoriesForSetActionResumeTest.java
- t3-actions/src/test/java/fr/ird/t3/actions/data/level1/ConvertSampleSetSpeciesFrequencyToWeightActionResumeTest.java
- t3-actions/src/test/java/fr/ird/t3/actions/data/level1/ConvertSetSpeciesFrequencyToWeightActionResumeTest.java
- t3-actions/src/test/java/fr/ird/t3/actions/data/level1/ExtrapolateSampleWeightToSetActionResumeTest.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/AbstractLevel1ConfigureAction.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/AbstractLevel1RunAction.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ComputeWeightOfCategoriesForSetRunAction.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ConvertSampleSetSpeciesFrequencyToWeightRunAction.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ConvertSetSpeciesFrequencyToWeightRunAction.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ExtrapolateSampleCountedAndMeasuredRunAction.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ExtrapolateSampleWeightToSetRunAction.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ManageLevel1ConfigurationAction.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/RedistributeSampleNumberToSetRunAction.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/StandardizeSampleMeasuresRunAction.java
- t3-web/src/main/resources/fr/ird/t3/web/actions/data/level1/ManageLevel1ConfigurationAction-validateLevel1Configuration-validation.xml
- t3-web/src/main/resources/fr/ird/t3/web/actions/data/level1/ManageLevel1ConfigurationAction-validation.xml
- t3-web/src/main/webapp/WEB-INF/jsp/data/level1/level1Configuration.jsp
- t3-web/src/main/webapp/WEB-INF/jsp/data/level1/level1ConfigurationResume.jsp
Changes:
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeSetDurationAndPositiveSetCountAction.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeSetDurationAndPositiveSetCountAction.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeSetDurationAndPositiveSetCountAction.java
@@ -59,9 +59,9 @@ public class ComputeSetDurationAndPositiveSetCountAction extends AbstractLevel0A
@InjectDAO(entityType = SetDuration.class)
private SetDurationTopiaDao setDurationDAO;
/** Count of treated activities. */
- private int nbActivities;
+ int nbActivities;
/** Count of positive activities found. */
- private int nbPositiveActivities;
+ int nbPositiveActivities;
/** Count of set (sum(a.setCount) on each activity trip). */
private int nbSet;
/**
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level1/AbstractLevel1Action.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level1/AbstractLevel1Action.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level1/AbstractLevel1Action.java
@@ -28,20 +28,17 @@ import fr.ird.t3.entities.data.N1ResultState;
import fr.ird.t3.entities.data.Sample;
import fr.ird.t3.entities.data.Trip;
import fr.ird.t3.entities.data.TripTopiaDao;
-import fr.ird.t3.entities.reference.Ocean;
import fr.ird.t3.services.DecoratorService;
import fr.ird.t3.services.ioc.InjectDAO;
-import fr.ird.t3.services.ioc.InjectEntityById;
+import org.apache.commons.collections.CollectionUtils;
+import org.nuiton.topia.persistence.TopiaException;
+
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
-import org.apache.commons.collections.CollectionUtils;
-import org.nuiton.topia.persistence.TopiaException;
-
-
import static org.nuiton.i18n.I18n.l;
/**
@@ -56,15 +53,12 @@ public abstract class AbstractLevel1Action extends T3Action<Level1Configuration>
.<Trip, Integer>comparing(t -> t.getVessel().getCode())
.thenComparing(Comparator.comparing(Trip::getLandingDate));
- protected final Level1Step step;
-
- protected final Set<Level1Step> higherSteps;
-
@InjectDAO(entityType = Trip.class)
protected TripTopiaDao tripDAO;
- @InjectEntityById(entityType = Ocean.class)
- protected Ocean ocean;
+ protected final Level1Step step;
+
+ protected final Set<Level1Step> higherSteps;
/** For a trip, selected samples to treat. */
protected Multimap<Trip, Sample> samplesByTrip;
@@ -77,10 +71,6 @@ public abstract class AbstractLevel1Action extends T3Action<Level1Configuration>
higherSteps = Level1Step.allAfter(step);
}
- public Ocean getOcean() {
- return ocean;
- }
-
public Multimap<Trip, Sample> getSamplesByTrip() {
return samplesByTrip;
}
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ComputeWeightOfCategoriesForSetAction.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ComputeWeightOfCategoriesForSetAction.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ComputeWeightOfCategoriesForSetAction.java
@@ -27,9 +27,9 @@ import fr.ird.t3.entities.data.Trip;
import fr.ird.t3.entities.data.WellSetAllSpecies;
import fr.ird.t3.entities.data.WellSetAllSpeciesTopiaDao;
import fr.ird.t3.services.ioc.InjectDAO;
-import java.util.Collection;
import org.nuiton.topia.persistence.TopiaException;
+import java.util.Collection;
import static org.nuiton.i18n.I18n.l;
@@ -127,9 +127,7 @@ public class ComputeWeightOfCategoriesForSetAction extends AbstractLevel1Action
// can not compute propMinus10Weight and propPlus10Weight
- String message =
- l(locale, "t3.level1.computeWeightOfCategoriesForSet.sample.noComputePropWeight"
- );
+ String message = l(locale, "t3.level1.computeWeightOfCategoriesForSet.sample.noComputePropWeight");
addInfoMessage(message);
} else {
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ConvertSampleSetSpeciesFrequencyToWeightAction.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ConvertSampleSetSpeciesFrequencyToWeightAction.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ConvertSampleSetSpeciesFrequencyToWeightAction.java
@@ -21,12 +21,10 @@ package fr.ird.t3.actions.data.level1;
* #L%
*/
-import com.google.common.base.Preconditions;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
-import com.google.common.collect.Sets;
import fr.ird.t3.T3IOUtil;
import fr.ird.t3.entities.CountAndWeight;
import fr.ird.t3.entities.T3Suppliers;
@@ -51,16 +49,17 @@ import fr.ird.t3.entities.reference.WeightCategorySample;
import fr.ird.t3.entities.reference.WeightCategorySampleTopiaDao;
import fr.ird.t3.services.DecoratorService;
import fr.ird.t3.services.ioc.InjectDAO;
+import org.nuiton.topia.persistence.TopiaException;
+import org.nuiton.util.TimeLog;
+
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
-import org.nuiton.topia.persistence.TopiaException;
-import org.nuiton.util.TimeLog;
-
import static org.nuiton.i18n.I18n.l;
@@ -72,38 +71,27 @@ import static org.nuiton.i18n.I18n.l;
*/
public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLevel1Action {
+ private final Map<String, List<WeightCategorySample>> weightCategoryCache;
@InjectDAO(entityType = LengthWeightConversion.class)
- protected LengthWeightConversionTopiaDao lengthWeightConversionDAO;
-
+ private LengthWeightConversionTopiaDao lengthWeightConversionDAO;
@InjectDAO(entityType = SampleSetSpeciesCatWeight.class)
- protected SampleSetSpeciesCatWeightTopiaDao sampleSetSpeciesCatWeightDAO;
-
+ private SampleSetSpeciesCatWeightTopiaDao sampleSetSpeciesCatWeightDAO;
@InjectDAO(entityType = WeightCategorySample.class)
- protected WeightCategorySampleTopiaDao weightCategorySampleDAO;
-
- protected LengthWeightConversionHelper conversionHelper;
-
- protected final Map<String, List<WeightCategorySample>> weightCategoryCache;
+ private WeightCategorySampleTopiaDao weightCategorySampleDAO;
+ private LengthWeightConversionHelper conversionHelper;
protected List<WeightCategorySample> getWeightCategories(SampleSet sampleSet) throws TopiaException {
-
Activity activity = sampleSet.getActivity();
- Ocean ocean1 = activity.getOcean();
+ Ocean ocean = activity.getOcean();
SchoolType schoolType = activity.getSchoolType();
- String key = ocean1.getTopiaId() + "-" + schoolType.getTopiaId();
+ String key = ocean.getTopiaId() + "-" + schoolType.getTopiaId();
List<WeightCategorySample> result = weightCategoryCache.get(key);
-
if (result == null) {
-
- result = weightCategorySampleDAO.forOceanEquals(ocean1).findAll();
+ result = weightCategorySampleDAO.forOceanEquals(ocean).findAll();
WeightCategories.sort(result);
weightCategoryCache.put(key, result);
}
-
- Preconditions.checkNotNull(
- result,
- "Could not find any weight categories for ocean " + ocean.getLabel1() );
- return result;
+ return Objects.requireNonNull(result, "Could not find any weight categories for ocean " + ocean.getLabel1());
}
public ConvertSampleSetSpeciesFrequencyToWeightAction() {
@@ -141,21 +129,18 @@ public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLeve
String tripStr = decorate(trip, DecoratorService.WITH_ID);
- getTimeLog().log(s0, "treat trip " + tripStr);
+ getTimeLog().log(s0, String.format("treat trip %s", tripStr));
// flush transaction otherwise too much data in memory
- flushTransaction("Flush transaction for " + tripStr);
+ flushTransaction(String.format("Flush transaction for %s", tripStr));
}
return true;
}
- protected void doExecuteTrip(Trip trip,
- Collection<Sample> samples) throws TopiaException {
+ protected void doExecuteTrip(Trip trip, Collection<Sample> samples) throws TopiaException {
incrementsProgression();
- Set<Activity> tripActivities = Sets.newHashSet();
-
// extrapolate for each sample set number to set
for (Sample sample : samples) {
@@ -173,16 +158,14 @@ public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLeve
// found a new activity to convert
convertFrequenciesToCatWeight(sampleSet);
- getTimeLog().log(s1,
- "convertSampleSetSpeciesFrequencyToWeight for " +
- tripActivities.size() + " sets.");
+ getTimeLog().log(s1, String.format("convertSampleSetSpeciesFrequencyToWeight for %d sets.", sample.sizeSampleSet()));
}
// mark sample as treated for this step of level 1 treatment
markAsTreated(sample);
- getTimeLog().log(s0, "treat sample " + sampleStr);
+ getTimeLog().log(s0, String.format("treat sample %s", sampleStr));
}
// mar trip as treated for this level 1 step
@@ -191,8 +174,7 @@ public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLeve
protected void convertFrequenciesToCatWeight(SampleSet sampleSet) throws TopiaException {
- Collection<SampleSetSpeciesFrequency> frequencies =
- sampleSet.getSampleSetSpeciesFrequency();
+ Collection<SampleSetSpeciesFrequency> frequencies = sampleSet.getSampleSetSpeciesFrequency();
Activity activity = sampleSet.getActivity();
@@ -200,15 +182,12 @@ public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLeve
Ocean activityOcean = activity.getOcean();
// group frequencies by species
- Multimap<Species, SampleSetSpeciesFrequency> frequenciesBySpecies =
- SpeciesTopiaDao.groupBySpecies(frequencies);
+ Multimap<Species, SampleSetSpeciesFrequency> frequenciesBySpecies = SpeciesTopiaDao.groupBySpecies(frequencies);
- Multimap<Species, Integer> lengthClassesBySpecies =
- ArrayListMultimap.create();
+ Multimap<Species, Integer> lengthClassesBySpecies = ArrayListMultimap.create();
// collect all length classes by species
- SampleSetSpeciesFrequencyTopiaDao.collectLengthClasses(
- frequenciesBySpecies, lengthClassesBySpecies);
+ SampleSetSpeciesFrequencyTopiaDao.collectLengthClasses(frequenciesBySpecies, lengthClassesBySpecies);
// get all available weight categories
List<WeightCategorySample> weightCategories = getWeightCategories(sampleSet);
@@ -216,19 +195,11 @@ public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLeve
for (Species species : frequenciesBySpecies.keySet()) {
// get conversion for species
- LengthWeightConversion conversion =
- conversionHelper.getConversions(
- species,
- activityOcean,
- 0,
- date
- );
-
- Collection<SampleSetSpeciesFrequency> frequenciesForSpecies =
- frequenciesBySpecies.get(species);
-
- List<Integer> lengthClasses =
- Lists.newArrayList(lengthClassesBySpecies.get(species));
+ LengthWeightConversion conversion = conversionHelper.getConversions(species, activityOcean, 0, date);
+
+ Collection<SampleSetSpeciesFrequency> frequenciesForSpecies = frequenciesBySpecies.get(species);
+
+ List<Integer> lengthClasses = Lists.newArrayList(lengthClassesBySpecies.get(species));
Collections.sort(lengthClasses);
Map<WeightCategorySample, CountAndWeight> countAndWeightsByCategories =
@@ -238,9 +209,7 @@ public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLeve
frequenciesForSpecies,
lengthClasses);
- // now we can build for the given activity and species the entries
- // in SetWeight
-
+ // now we can build for the given activity and species the entries in SetWeight
fill(sampleSet, species, countAndWeightsByCategories);
}
}
@@ -250,17 +219,12 @@ public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLeve
Collection<SampleSetSpeciesFrequency> frequencies,
List<Integer> lengthClasses) throws TopiaException {
- Map<Integer, WeightCategorySample> weightCategorie =
- conversionHelper.getWeightCategoriesDistribution(
- conversion,
- weightCategories,
- lengthClasses);
+ Map<Integer, WeightCategorySample> weightCategoryMap =
+ conversionHelper.getWeightCategoriesDistribution(conversion, weightCategories, lengthClasses);
Map<WeightCategorySample, CountAndWeight> result = new HashMap<>();
- T3IOUtil.fillMapWithDefaultValue(result,
- weightCategorie.values(),
- T3Suppliers.COUNT_AND_WEIGHT_DEFAULT_VALUE);
+ T3IOUtil.fillMapWithDefaultValue(result, weightCategoryMap.values(), T3Suppliers.COUNT_AND_WEIGHT_DEFAULT_VALUE);
for (SampleSetSpeciesFrequency setSize : frequencies) {
@@ -268,7 +232,7 @@ public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLeve
int lfLengthClass = setSize.getLfLengthClass();
// find the correct category for this length class
- WeightCategorySample weightCategory = weightCategorie.get(lfLengthClass);
+ WeightCategorySample weightCategory = weightCategoryMap.get(lfLengthClass);
CountAndWeight countAndWeight = result.get(weightCategory);
@@ -276,8 +240,7 @@ public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLeve
countAndWeight.addCount(number);
// convert to weight from lf length class
- countAndWeight.addWeight(number *
- conversion.computeWeightFromLFLengthClass(lfLengthClass));
+ countAndWeight.addWeight(number * conversion.computeWeightFromLFLengthClass(lfLengthClass));
}
@@ -295,7 +258,7 @@ public class ConvertSampleSetSpeciesFrequencyToWeightAction extends AbstractLeve
CountAndWeight countAndWeight = e2.getValue();
float count = countAndWeight.getCount();
- // weight must be stored in tons but are in kilogramms
+ // weight must be stored in tons but are in kilograms
Float weight = countAndWeight.getWeight() / 1000;
SampleSetSpeciesCatWeight setSpeciesCatWeight = sampleSetSpeciesCatWeightDAO.create(
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ConvertSetSpeciesFrequencyToWeightAction.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ConvertSetSpeciesFrequencyToWeightAction.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ConvertSetSpeciesFrequencyToWeightAction.java
@@ -8,19 +8,18 @@
* 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%
*/
package fr.ird.t3.actions.data.level1;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@@ -49,16 +48,17 @@ import fr.ird.t3.entities.reference.WeightCategorySample;
import fr.ird.t3.entities.reference.WeightCategorySampleTopiaDao;
import fr.ird.t3.services.DecoratorService;
import fr.ird.t3.services.ioc.InjectDAO;
+import org.nuiton.topia.persistence.TopiaException;
+import org.nuiton.util.TimeLog;
+
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
-import org.nuiton.topia.persistence.TopiaException;
-import org.nuiton.util.TimeLog;
-
import static org.nuiton.i18n.I18n.l;
@@ -70,48 +70,34 @@ import static org.nuiton.i18n.I18n.l;
*/
public class ConvertSetSpeciesFrequencyToWeightAction extends AbstractLevel1Action {
+ protected final Map<String, List<WeightCategorySample>> weightCategoryCache;
@InjectDAO(entityType = LengthWeightConversion.class)
protected LengthWeightConversionTopiaDao lengthWeightConversionDAO;
-
@InjectDAO(entityType = SetSpeciesCatWeight.class)
protected SetSpeciesCatWeightTopiaDao setSpeciesCatWeightDAO;
-
@InjectDAO(entityType = WeightCategorySample.class)
protected WeightCategorySampleTopiaDao weightCategorySampleDAO;
-
protected int nbTreatedSets;
-
protected float nbTreatedFishesInSamples;
-
protected float nbCreatedFishesInSetSpeciesFrequency;
-
protected LengthWeightConversionHelper conversionHelper;
- protected final Map<String, List<WeightCategorySample>> weightCategoryCache;
+ public ConvertSetSpeciesFrequencyToWeightAction() {
+ super(Level1Step.CONVERT_SET_SPECIES_FREQUENCY_TO_WEIGHT);
+ weightCategoryCache = Maps.newTreeMap();
+ }
protected List<WeightCategorySample> getWeightCategories(Activity activity) throws TopiaException {
-
- Ocean ocean1 = activity.getOcean();
+ Ocean ocean = activity.getOcean();
SchoolType schoolType = activity.getSchoolType();
- String key = ocean1.getTopiaId() + "-" + schoolType.getTopiaId();
+ String key = ocean.getTopiaId() + "-" + schoolType.getTopiaId();
List<WeightCategorySample> result = weightCategoryCache.get(key);
-
if (result == null) {
-
- result = weightCategorySampleDAO.findAllByOcean(ocean1);
+ result = weightCategorySampleDAO.forOceanEquals(ocean).findAll();
WeightCategories.sort(result);
weightCategoryCache.put(key, result);
}
-
- Preconditions.checkNotNull(
- result,
- "Could not find any weight categories for ocean " + ocean.getLabel1());
- return result;
- }
-
- public ConvertSetSpeciesFrequencyToWeightAction() {
- super(Level1Step.CONVERT_SET_SPECIES_FREQUENCY_TO_WEIGHT);
- weightCategoryCache = Maps.newTreeMap();
+ return Objects.requireNonNull(result, "Could not find any weight categories for ocean " + ocean.getLabel1());
}
public int getNbTreatedSets() {
@@ -140,7 +126,7 @@ public class ConvertSetSpeciesFrequencyToWeightAction extends AbstractLevel1Acti
}
@Override
- protected boolean executeAction() throws Exception {
+ protected boolean executeAction() {
Set<Trip> trips = samplesByTrip.keySet();
setNbSteps(samplesByTrip.size() + trips.size());
@@ -164,8 +150,7 @@ public class ConvertSetSpeciesFrequencyToWeightAction extends AbstractLevel1Acti
return true;
}
- protected void doExecuteTrip(Trip trip,
- Collection<Sample> samples) throws TopiaException {
+ protected void doExecuteTrip(Trip trip, Collection<Sample> samples) throws TopiaException {
incrementsProgression();
@@ -184,8 +169,7 @@ public class ConvertSetSpeciesFrequencyToWeightAction extends AbstractLevel1Acti
float nb = sample.getTotalStandardiseSampleSpeciesFrequencyNumber();
addInfoMessage(
- l(locale, "t3.level1.convertSetSpeciesFrequencyToWeight.sample.nbFishes",
- sampleStr, nb));
+ l(locale, "t3.level1.convertSetSpeciesFrequencyToWeight.sample.nbFishes", sampleStr, nb));
nbTreatedFishesInSamples += nb;
for (SampleSet sampleSet : sample.getSampleSet()) {
@@ -200,17 +184,14 @@ public class ConvertSetSpeciesFrequencyToWeightAction extends AbstractLevel1Acti
// found a new activity to convert
convertFrequenciesToCatWeight(activity);
- getTimeLog().log(
- s1,
- "convertSetSpeciesFrequencyToWeight for " +
- tripActivities.size() + " sets.");
+ getTimeLog().log(s1, String.format("convertSetSpeciesFrequencyToWeight for %d sets.", tripActivities.size()));
}
}
// mark sample as treated for this step of level 1 treatment
markAsTreated(sample);
- getTimeLog().log(s0, "treat sample " + sampleStr);
+ getTimeLog().log(s0, String.format("treat sample %s", sampleStr));
}
nbTreatedSets += tripActivities.size();
@@ -226,50 +207,32 @@ public class ConvertSetSpeciesFrequencyToWeightAction extends AbstractLevel1Acti
Date date = activity.getDate();
Ocean activityOcean = activity.getOcean();
-
// group frequencies by species
Multimap<Species, SetSpeciesFrequency> setSpeciesFrequencyBySpecies =
SpeciesTopiaDao.groupBySpecies(frequencies);
- Multimap<Species, Integer> lengthClassesBySpecies =
- ArrayListMultimap.create();
+ Multimap<Species, Integer> lengthClassesBySpecies = ArrayListMultimap.create();
// collect all length classes by species
- SetSpeciesFrequencyTopiaDao.collectLengthClasses(
- setSpeciesFrequencyBySpecies, lengthClassesBySpecies);
+ SetSpeciesFrequencyTopiaDao.collectLengthClasses(setSpeciesFrequencyBySpecies, lengthClassesBySpecies);
// get all available weight categories
- List<WeightCategorySample> weightCategories =
- getWeightCategories(activity);
+ List<WeightCategorySample> weightCategories = getWeightCategories(activity);
for (Species species : setSpeciesFrequencyBySpecies.keySet()) {
// get conversion for species
- LengthWeightConversion conversion =
- conversionHelper.getConversions(
- species,
- activityOcean,
- 0,
- date
- );
-
- Collection<SetSpeciesFrequency> setSizes =
- setSpeciesFrequencyBySpecies.get(species);
-
- List<Integer> lengthClasses =
- Lists.newArrayList(lengthClassesBySpecies.get(species));
+ LengthWeightConversion conversion = conversionHelper.getConversions(species, activityOcean, 0, date);
+
+ Collection<SetSpeciesFrequency> setSizes = setSpeciesFrequencyBySpecies.get(species);
+
+ List<Integer> lengthClasses = Lists.newArrayList(lengthClassesBySpecies.get(species));
Collections.sort(lengthClasses);
Map<WeightCategorySample, CountAndWeight> countAndWeightsByCategories =
- convertForSpecies(
- weightCategories,
- conversion,
- setSizes,
- lengthClasses);
-
- // now we can build for the given activity and species the entries
- // in SetWeight
+ convertForSpecies(weightCategories, conversion, setSizes, lengthClasses);
+ // now we can build for the given activity and species the entries in SetWeight
fill(activity, species, countAndWeightsByCategories);
}
}
@@ -279,7 +242,7 @@ public class ConvertSetSpeciesFrequencyToWeightAction extends AbstractLevel1Acti
Collection<SetSpeciesFrequency> setSizes,
List<Integer> lengthClasses) throws TopiaException {
- Map<Integer, WeightCategorySample> weightCategorie = conversionHelper.getWeightCategoriesDistribution(
+ Map<Integer, WeightCategorySample> weightCategoryMap = conversionHelper.getWeightCategoriesDistribution(
conversion,
weightCategories,
lengthClasses
@@ -287,9 +250,7 @@ public class ConvertSetSpeciesFrequencyToWeightAction extends AbstractLevel1Acti
Map<WeightCategorySample, CountAndWeight> result = new HashMap<>();
- T3IOUtil.fillMapWithDefaultValue(result,
- weightCategorie.values(),
- T3Suppliers.COUNT_AND_WEIGHT_DEFAULT_VALUE);
+ T3IOUtil.fillMapWithDefaultValue(result, weightCategoryMap.values(), T3Suppliers.COUNT_AND_WEIGHT_DEFAULT_VALUE);
for (SetSpeciesFrequency setSize : setSizes) {
@@ -297,8 +258,7 @@ public class ConvertSetSpeciesFrequencyToWeightAction extends AbstractLevel1Acti
int lfLengthClass = setSize.getLfLengthClass();
// find the correct category for this length class
- WeightCategorySample weightCategory =
- weightCategorie.get(lfLengthClass);
+ WeightCategorySample weightCategory = weightCategoryMap.get(lfLengthClass);
CountAndWeight countAndWeight = result.get(weightCategory);
@@ -313,12 +273,9 @@ public class ConvertSetSpeciesFrequencyToWeightAction extends AbstractLevel1Acti
return result;
}
- private void fill(Activity activity,
- Species species,
- Map<WeightCategorySample, CountAndWeight> countAndWeightsByCategories) throws TopiaException {
+ private void fill(Activity activity, Species species, Map<WeightCategorySample, CountAndWeight> countAndWeightsByCategories) throws TopiaException {
- for (Map.Entry<WeightCategorySample, CountAndWeight> e2 :
- countAndWeightsByCategories.entrySet()) {
+ for (Map.Entry<WeightCategorySample, CountAndWeight> e2 : countAndWeightsByCategories.entrySet()) {
WeightCategorySample categorySample = e2.getKey();
CountAndWeight countAndWeight = e2.getValue();
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ExtrapolateSampleCountedAndMeasuredAction.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ExtrapolateSampleCountedAndMeasuredAction.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ExtrapolateSampleCountedAndMeasuredAction.java
@@ -28,11 +28,11 @@ import fr.ird.t3.entities.data.SampleSpecies;
import fr.ird.t3.entities.data.Trip;
import fr.ird.t3.entities.reference.Species;
import fr.ird.t3.entities.reference.SpeciesTopiaDao;
+
import java.util.Collection;
import java.util.List;
import java.util.Map;
-
import static org.nuiton.i18n.I18n.l;
/**
@@ -50,9 +50,7 @@ public class ExtrapolateSampleCountedAndMeasuredAction extends AbstractLevel1Act
}
public List<SpeciesCountAndMeasuredModel> getResultSpeciesModel() {
- List<SpeciesCountAndMeasuredModel> result =
- getResultAsList(RESULT_SPECIES_MODEL, SpeciesCountAndMeasuredModel.class);
- return result;
+ return getResultAsList(RESULT_SPECIES_MODEL, SpeciesCountAndMeasuredModel.class);
}
public SpeciesCountAndMeasuredModel getTotalSpeciesModel() {
@@ -81,7 +79,7 @@ public class ExtrapolateSampleCountedAndMeasuredAction extends AbstractLevel1Act
}
@Override
- protected boolean executeAction() throws Exception {
+ protected boolean executeAction() {
Map<Species, SpeciesCountAndMeasuredModel> model = Maps.newHashMap();
@@ -110,8 +108,7 @@ public class ExtrapolateSampleCountedAndMeasuredAction extends AbstractLevel1Act
return true;
}
- protected void doExecuteSample(Sample sample,
- Map<Species, SpeciesCountAndMeasuredModel> model) {
+ protected void doExecuteSample(Sample sample, Map<Species, SpeciesCountAndMeasuredModel> model) {
incrementsProgression();
@@ -120,7 +117,6 @@ public class ExtrapolateSampleCountedAndMeasuredAction extends AbstractLevel1Act
sample.getSampleNumber()));
if (sample.isSampleSpeciesEmpty()) {
-
// no sample species, nothing to do...
return;
}
@@ -145,9 +141,7 @@ public class ExtrapolateSampleCountedAndMeasuredAction extends AbstractLevel1Act
float measuredCount = 0;
for (SampleSpecies aSampleSpecies : sampleSpecies) {
totalCount += aSampleSpecies.getTotalCount();
-
- measuredCount +=
- aSampleSpecies.getTotalSampleSpeciesFrequencyNumber();
+ measuredCount += aSampleSpecies.getTotalSampleSpeciesFrequencyNumber();
}
float rf0 = totalCount / measuredCount;
@@ -161,7 +155,6 @@ public class ExtrapolateSampleCountedAndMeasuredAction extends AbstractLevel1Act
// apply rf0 on each sample
for (SampleSpecies sampleSpecie : sampleSpecies) {
-
sampleSpecie.applyRf0(rf0);
}
}
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ExtrapolateSampleWeightToSetAction.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ExtrapolateSampleWeightToSetAction.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ExtrapolateSampleWeightToSetAction.java
@@ -20,9 +20,7 @@
*/
package fr.ird.t3.actions.data.level1;
-import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
-import com.google.common.collect.Sets;
import fr.ird.t3.entities.data.Activity;
import fr.ird.t3.entities.data.RfUsageStatus;
import fr.ird.t3.entities.data.Sample;
@@ -45,14 +43,16 @@ import fr.ird.t3.entities.reference.WeightCategoryWellPlan;
import fr.ird.t3.entities.reference.WeightCategoryWellPlanTopiaDao;
import fr.ird.t3.services.DecoratorService;
import fr.ird.t3.services.ioc.InjectDAO;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.persistence.TopiaException;
import org.nuiton.util.TimeLog;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import static org.nuiton.i18n.I18n.l;
@@ -125,7 +125,7 @@ public class ExtrapolateSampleWeightToSetAction extends AbstractLevel1Action {
}
@Override
- protected boolean executeAction() throws Exception {
+ protected boolean executeAction() {
Set<Trip> trips = samplesByTrip.keySet();
setNbSteps(samplesByTrip.size() + trips.size());
@@ -153,11 +153,11 @@ public class ExtrapolateSampleWeightToSetAction extends AbstractLevel1Action {
incrementsProgression();
+ //FIXME I replace ocean by trip.departureHarbour.ocean, check this is ok (See #260)
// get the length class +10kg limit
- Map<Species, Integer> limitLengthClassBySpecie =
- getThredHoldPlus10ForSpecies(trip, samples, ocean);
+ Map<Species, Integer> limitLengthClassBySpecie = getThredHoldPlus10ForSpecies(trip, samples, trip.getDepartureHarbour().getOcean());
- Set<Activity> tripActivities = Sets.newHashSet();
+ Set<Activity> tripActivities = new HashSet<>();
// extrapolate for each sample set number to set
for (Sample sample : samples) {
@@ -187,11 +187,7 @@ public class ExtrapolateSampleWeightToSetAction extends AbstractLevel1Action {
activity.clearSetSpeciesCatWeight();
}
- doExecuteSampleWell(
- activity,
- sampleSet,
- sampleStr,
- limitLengthClassBySpecie);
+ doExecuteSampleWell(activity, sampleSet, sampleStr, limitLengthClassBySpecie);
}
@@ -244,11 +240,7 @@ public class ExtrapolateSampleWeightToSetAction extends AbstractLevel1Action {
sampleSet.setRfTot(rfContext.getRfTot());
// fill the SetSpecieFrequency table
- fillSetSpeciesFrequency(
- activity,
- limitLengthClassBySpecie,
- sampleSet,
- rfContext);
+ fillSetSpeciesFrequency(activity, limitLengthClassBySpecie, sampleSet, rfContext);
}
@@ -330,9 +322,7 @@ public class ExtrapolateSampleWeightToSetAction extends AbstractLevel1Action {
* @throws TopiaException if any pb while finding convertors
* @see SampleWellSampleWeight
*/
- protected SampleWellSetWeight computeSampleWellSetWeight(
- String sampleWellStr,
- SampleSet sampleSet) throws TopiaException {
+ protected SampleWellSetWeight computeSampleWellSetWeight(String sampleWellStr, SampleSet sampleSet) throws TopiaException {
float pondt = sampleSet.getWeightedWeight();
Float pondm = sampleSet.getWeightedWeightMinus10();
@@ -489,11 +479,7 @@ public class ExtrapolateSampleWeightToSetAction extends AbstractLevel1Action {
return rfContext;
}
- public void fillSetSpeciesFrequency(
- Activity activity,
- Map<Species, Integer> limitLengthClassBySpecies,
- SampleSet sampleSet,
- RFContext rfContext) throws TopiaException {
+ public void fillSetSpeciesFrequency(Activity activity, Map<Species, Integer> limitLengthClassBySpecies, SampleSet sampleSet, RFContext rfContext) throws TopiaException {
// group sample set frequencies by species
Multimap<Species, SampleSetSpeciesFrequency> sampleSetSpeciesFrequencyBySpecies =
@@ -542,18 +528,15 @@ public class ExtrapolateSampleWeightToSetAction extends AbstractLevel1Action {
* @param trip the trip where samples are done
* @param samples the sample to scan
* @param ocean ocean where trip happens
- * @return the universe of legnth class limits computed indexed by species
+ * @return the universe of length class limits computed indexed by species
* @throws TopiaException if any db problems while requesting
*/
- public Map<Species, Integer> getThredHoldPlus10ForSpecies(Trip trip,
- Collection<Sample> samples,
- Ocean ocean) throws TopiaException {
+ public Map<Species, Integer> getThredHoldPlus10ForSpecies(Trip trip, Collection<Sample> samples, Ocean ocean) throws TopiaException {
Set<Species> species = SpeciesTopiaDao.getAllSpeciesFromSampleSpecies(samples);
- // for each of those species, found the length class wich matches a
- // weight > 10Kg
- Map<Species, Integer> result = Maps.newHashMap();
+ // for each of those species, found the length class which matches a weight > 10Kg
+ Map<Species, Integer> result = new HashMap<>();
for (Species specie : species) {
LengthWeightConversion conversion = conversionHelper.getConversions(
@@ -577,8 +560,7 @@ public class ExtrapolateSampleWeightToSetAction extends AbstractLevel1Action {
if (log.isDebugEnabled()) {
for (Map.Entry<Species, Integer> entry : result.entrySet()) {
- log.debug("Species " + entry.getKey().getCode() +
- " - limit 10Kg length class : " + entry.getValue());
+ log.debug(String.format("Species %d - limit 10Kg length class : %d", entry.getKey().getCode(), entry.getValue()));
}
}
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level1/Level1Configuration.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level1/Level1Configuration.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level1/Level1Configuration.java
@@ -20,9 +20,7 @@
*/
package fr.ird.t3.actions.data.level1;
-import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
@@ -44,13 +42,13 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.decorator.Decorator;
-import java.util.Arrays;
import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import java.util.stream.Collectors;
import static org.nuiton.i18n.I18n.l;
@@ -84,11 +82,12 @@ public class Level1Configuration implements T3ActionConfiguration {
/** Ids of fleet countries to use. */
protected List<String> fleetIds;
+ /** Ids of ocean to use. */
+ protected List<String> oceanIds;
+
/** Ids of trips to use. */
protected Multimap<String, String> sampleIdsByTripId;
- /** Id of selected ocean. */
- protected String oceanId;
/** begin date to use. */
protected T3Date beginDate;
@@ -150,12 +149,12 @@ public class Level1Configuration implements T3ActionConfiguration {
getExecutedSteps().add(step);
}
- public String getOceanId() {
- return oceanId;
+ public List<String> getOceanIds() {
+ return oceanIds;
}
- public void setOceanId(String oceanId) {
- this.oceanId = oceanId;
+ public void setOceanIds(List<String> oceanIds) {
+ this.oceanIds = oceanIds;
}
public Multimap<String, String> getSampleIdsByTripId() {
@@ -306,32 +305,23 @@ public class Level1Configuration implements T3ActionConfiguration {
Multimap<String, String> result = TreeMultimap.create();
- if (oceanId == null) {
+ if (oceanIds == null) {
// no matching trips (so no matching trip
return result;
}
- Preconditions.checkNotNull(oceanId);
-
- Ocean ocean =
- Iterables.find(oceans, T3Predicates.equalsTopiaEntity(oceanId));
- Preconditions.checkNotNull(ocean);
+ Set<Ocean> usableOceans = oceans.stream().filter(o -> oceanIds.contains(o.getTopiaId())).collect(Collectors.toSet());
- Predicate<Trip> tripPredicate =
- T3Predicates.tripUsingOcean(Arrays.asList(ocean));
+ Predicate<Trip> tripPredicate = T3Predicates.tripUsingOcean(usableOceans);
- Decorator<Trip> tripDecorator =
- decoratorService.getDecorator(locale, Trip.class, DecoratorService.WITH_ID);
+ Decorator<Trip> tripDecorator = decoratorService.getDecorator(locale, Trip.class, DecoratorService.WITH_ID);
- Decorator<Sample> sampleDecorator =
- decoratorService.getDecorator(locale, Sample.class, DecoratorService.WITH_ID);
+ Decorator<Sample> sampleDecorator = decoratorService.getDecorator(locale, Sample.class, DecoratorService.WITH_ID);
- String sampleWellEmptyReason =
- l(locale, "t3.level1.notSelectedSample.sampleWellEmpty");
+ String sampleWellEmptyReason = l(locale, "t3.level1.notSelectedSample.sampleWellEmpty");
- String sampleNoMatchingActivityReason =
- l(locale, "t3.level1.notSelectedSample.sampleNoMatchingActivity");
+ String sampleNoMatchingActivityReason = l(locale, "t3.level1.notSelectedSample.sampleNoMatchingActivity");
Decorator<SampleQuality> sampleQualityDecorator = decoratorService.getDecorator(locale, SampleQuality.class, null);
Decorator<SampleType> sampleTypeDecorator = decoratorService.getDecorator(locale, SampleType.class, null);
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level1/RedistributeSampleNumberToSetAction.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level1/RedistributeSampleNumberToSetAction.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level1/RedistributeSampleNumberToSetAction.java
@@ -31,11 +31,11 @@ import fr.ird.t3.entities.data.Trip;
import fr.ird.t3.entities.reference.Species;
import fr.ird.t3.entities.reference.SpeciesTopiaDao;
import fr.ird.t3.services.ioc.InjectDAO;
+import org.nuiton.topia.persistence.TopiaException;
+
import java.util.Collection;
import java.util.Map;
import java.util.Set;
-import org.nuiton.topia.persistence.TopiaException;
-
import static org.nuiton.i18n.I18n.l;
@@ -55,9 +55,7 @@ public class RedistributeSampleNumberToSetAction extends AbstractLevel1Action {
}
public Set<Species> getSpeciesOfSample(Sample sample) {
- Set<Species> result = SpeciesTopiaDao.getAllSpecies(
- sample.getStandardiseSampleSpecies());
- return result;
+ return SpeciesTopiaDao.getAllSpecies(sample.getStandardiseSampleSpecies());
}
public SpeciesModel getResultSpeciesModel(Sample sample, Species species) {
@@ -88,7 +86,7 @@ public class RedistributeSampleNumberToSetAction extends AbstractLevel1Action {
}
@Override
- protected boolean executeAction() throws Exception {
+ protected boolean executeAction() {
setNbSteps(2 * samplesByTrip.size());
@@ -125,8 +123,8 @@ public class RedistributeSampleNumberToSetAction extends AbstractLevel1Action {
}
incrementsProgression();
- long sampleTotalNumber = 0l;
- long sampleWellTotalNumber = 0l;
+ long sampleTotalNumber = 0L;
+ long sampleWellTotalNumber = 0L;
for (StandardiseSampleSpecies sampleSpecies :
sample.getStandardiseSampleSpecies()) {
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level1/StandardizeSampleMeasuresAction.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level1/StandardizeSampleMeasuresAction.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level1/StandardizeSampleMeasuresAction.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%
@@ -36,14 +36,15 @@ import fr.ird.t3.entities.reference.SpeciesLengthStep;
import fr.ird.t3.entities.reference.SpeciesLengthStepTopiaDao;
import fr.ird.t3.entities.reference.SpeciesTopiaDao;
import fr.ird.t3.services.ioc.InjectDAO;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.persistence.TopiaException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
import static org.nuiton.i18n.I18n.l;
@@ -61,29 +62,22 @@ import static org.nuiton.i18n.I18n.l;
*/
public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
+ public static final String RESULT_SPECIES_MODEL = "speciesModel";
/** Logger. */
- private static final Log log =
- LogFactory.getLog(StandardizeSampleMeasuresAction.class);
-
+ private static final Log log = LogFactory.getLog(StandardizeSampleMeasuresAction.class);
@InjectDAO(entityType = StandardiseSampleSpecies.class)
- protected StandardiseSampleSpeciesTopiaDao standardiseSampleSpeciesDAO;
-
+ private StandardiseSampleSpeciesTopiaDao standardiseSampleSpeciesDAO;
@InjectDAO(entityType = StandardiseSampleSpeciesFrequency.class)
- protected StandardiseSampleSpeciesFrequencyTopiaDao standardiseSampleSpeciesFrequencyDAO;
-
+ private StandardiseSampleSpeciesFrequencyTopiaDao standardiseSampleSpeciesFrequencyDAO;
@InjectDAO(entityType = SpeciesLengthStep.class)
- protected SpeciesLengthStepTopiaDao speciesLengthStepDAO;
-
- public static final String RESULT_SPECIES_MODEL = "speciesModel";
+ private SpeciesLengthStepTopiaDao speciesLengthStepDAO;
public StandardizeSampleMeasuresAction() {
super(Level1Step.STANDARDIZE_SAMPLE_MEASURE);
}
public List<StandardizeSpeciesCountModel> getResultSpeciesModel() {
- List<StandardizeSpeciesCountModel> result =
- getResultAsList(RESULT_SPECIES_MODEL, StandardizeSpeciesCountModel.class);
- return result;
+ return getResultAsList(RESULT_SPECIES_MODEL, StandardizeSpeciesCountModel.class);
}
public StandardizeSpeciesCountModel getTotalSpeciesModel() {
@@ -101,7 +95,7 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
}
@Override
- protected boolean executeAction() throws Exception {
+ protected boolean executeAction() {
Map<Species, StandardizeSpeciesCountModel> model = Maps.newHashMap();
@@ -114,11 +108,7 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
for (Sample sample : samples) {
- doExecuteSample(
- trip,
- sample,
- model
- );
+ doExecuteSample(trip, sample, model);
// mark sample as treated for this step of level 1 treatment
markAsTreated(sample);
@@ -135,23 +125,20 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
return true;
}
- protected void doExecuteSample(Trip trip,
- Sample sample,
- Map<Species, StandardizeSpeciesCountModel> model) throws TopiaException {
+ private void doExecuteSample(Trip trip, Sample sample, Map<Species, StandardizeSpeciesCountModel> model) throws TopiaException {
incrementsProgression();
String tripStr = decorate(trip);
- addInfoMessage(l(locale, "t3.level1.standardizeSampleMeasures.treat.sample",
- tripStr, sample.getSampleNumber()));
+ addInfoMessage(l(locale, "t3.level1.standardizeSampleMeasures.treat.sample", tripStr, sample.getSampleNumber()));
if (!sample.isStandardiseSampleSpeciesEmpty()) {
// was already computed, remove previous data
addInfoMessage(
l(locale, "t3.level1.standardizeSampleMeasures.treat.remove.previously.treated.data",
- sample.sizeStandardiseSampleSpecies()));
+ sample.sizeStandardiseSampleSpecies()));
sample.clearStandardiseSampleSpecies();
}
@@ -162,8 +149,7 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
}
// split sample species by species
- Multimap<Species, SampleSpecies> sampleSpeciesBySpecies =
- SpeciesTopiaDao.groupBySpecies(sample.getSampleSpecies());
+ Multimap<Species, SampleSpecies> sampleSpeciesBySpecies = SpeciesTopiaDao.groupBySpecies(sample.getSampleSpecies());
for (Species species : sampleSpeciesBySpecies.keySet()) {
@@ -175,22 +161,14 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
}
// get sample species for this species
- Collection<SampleSpecies> sampleSpecies =
- sampleSpeciesBySpecies.get(species);
+ Collection<SampleSpecies> sampleSpecies = sampleSpeciesBySpecies.get(species);
- // obtain once for all the length classes for this species on
- // this ocean
+ //FIXME I replace ocean by trip.departureHarbour.ocean, check this is ok (See #260)
+ // obtain once for all the length classes for this species on this ocean
Multimap<Integer, SpeciesLengthStep> proportionsForSpecies =
- speciesLengthStepDAO.findAllByOceanAndSpeciesGroupByLd1Class(
- ocean,
- species);
-
- doExecuteSampleSpecies(species,
- sampleSpecies,
- sample,
- speciesCountModel,
- proportionsForSpecies
- );
+ speciesLengthStepDAO.findAllByOceanAndSpeciesGroupByLd1Class(trip.getDepartureHarbour().getOcean(), species);
+
+ doExecuteSampleSpecies(species, sampleSpecies, sample, speciesCountModel, proportionsForSpecies);
}
}
@@ -204,23 +182,16 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
// each species will give exactly one entry in StandardiseSampleSpecies table
StandardiseSampleSpecies standardiseSampleSpecies =
- standardiseSampleSpeciesDAO.create(
- StandardiseSampleSpecies.PROPERTY_SPECIES, species
- );
+ standardiseSampleSpeciesDAO.create(StandardiseSampleSpecies.PROPERTY_SPECIES, species);
- // contains for each lflengthclass, the number of fishes
+ // contains for each lfLengthClass, the number of fishes
Map<Integer, Float> frequencies = Maps.newTreeMap();
float measuredCount = 0;
float totalCount = 0;
for (SampleSpecies sampleSpecie : sampleSpecies) {
measuredCount += sampleSpecie.getMeasuredCount();
totalCount += sampleSpecie.getTotalCount();
-
- collectSampleSpeciesFrequencies(
- proportionsForSpecies,
- sampleSpecie,
- frequencies
- );
+ collectSampleSpeciesFrequencies(proportionsForSpecies, sampleSpecie, frequencies);
}
// set the total measured count computed
@@ -238,13 +209,12 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
// must recode length classes
- finalFrequencies = Maps.newTreeMap();
+ finalFrequencies = new TreeMap<>();
for (Map.Entry<Integer, Float> ee : frequencies.entrySet()) {
Integer lfLengthClass = ee.getKey();
Float numberExtrapolated = ee.getValue();
- int finalLengthClass = lfLengthClass -
- lfLengthClass % lfLengthClassStep;
+ int finalLengthClass = lfLengthClass - lfLengthClass % lfLengthClassStep;
Float finalNumber = finalFrequencies.get(finalLengthClass);
if (finalNumber == null) {
@@ -277,10 +247,7 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
// attach to sample new data
sample.addStandardiseSampleSpecies(standardiseSampleSpecies);
addInfoMessage(l(locale, "t3.level1.standardizeSampleMeasures.treat.resume.for.species",
- decorate(species),
- oldCOunt,
- newCount
- ));
+ decorate(species), oldCOunt, newCount));
}
protected void collectSampleSpeciesFrequencies(Multimap<Integer, SpeciesLengthStep> proportionsForSpecies,
@@ -304,16 +271,14 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
// ld1 length class is in cm in sample, but in milimeter in SpeciesLengthStep table
int ld1LengthClass = sampleSpeciesFrequency.getLengthClass() * 10;
- Collection<SpeciesLengthStep> proportions =
- proportionsForSpecies.get(ld1LengthClass);
+ Collection<SpeciesLengthStep> proportions = proportionsForSpecies.get(ld1LengthClass);
if (CollectionUtils.isEmpty(proportions)) {
//TODO This should be an error ?
String message = l(locale, "t3.level1.standardizeSampleMeasures.warning.lfConversion.not.found",
- decorate(ocean),
- decorate(species),
- ld1LengthClass);
+ decorate(species),
+ ld1LengthClass);
if (log.isWarnEnabled()) {
log.warn(message);
}
@@ -336,14 +301,8 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
// just add lf frequencies
- for (SampleSpeciesFrequency sampleSpecyFrequency :
- sampleSpecies.getSampleSpeciesFrequency()) {
-
- addLFFrequency(
- sampleSpecyFrequency.getLengthClass(),
- sampleSpecyFrequency.getNumberExtrapolated(),
- frequencies
- );
+ for (SampleSpeciesFrequency sampleSpecyFrequency : sampleSpecies.getSampleSpeciesFrequency()) {
+ addLFFrequency(sampleSpecyFrequency.getLengthClass(), sampleSpecyFrequency.getNumberExtrapolated(), frequencies);
}
}
}
@@ -352,12 +311,7 @@ public class StandardizeSampleMeasuresAction extends AbstractLevel1Action {
float number,
Map<Integer, Float> frequencies) throws TopiaException {
- Float standardiseSampleSpecieFrequency = frequencies.get(lengthClass);
- if (standardiseSampleSpecieFrequency == null) {
-
- standardiseSampleSpecieFrequency = 0.f;
- frequencies.put(lengthClass, standardiseSampleSpecieFrequency);
- }
+ Float standardiseSampleSpecieFrequency = frequencies.computeIfAbsent(lengthClass, k -> 0.f);
standardiseSampleSpecieFrequency += number;
=====================================
t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeSetDurationAndPositiveSetCountActionResumeTest.java
=====================================
--- a/t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeSetDurationAndPositiveSetCountActionResumeTest.java
+++ b/t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeSetDurationAndPositiveSetCountActionResumeTest.java
@@ -60,13 +60,11 @@ public class ComputeSetDurationAndPositiveSetCountActionResumeTest extends Abstr
Map<String, Object> parameters = super.createTemplateParameters();
- Map<String, String> vesselSimpleTypes = new TreeMap<String, String>();
- putInMap(vesselSimpleTypes,
- fixtures.vesselSimpleTypeCanneur(),
- fixtures.vesselSimpleTypeSenneur());
+ Map<String, String> vesselSimpleTypes = new TreeMap<>();
+ putInMap(vesselSimpleTypes, fixtures.vesselSimpleTypeCanneur(), fixtures.vesselSimpleTypeSenneur());
parameters.put("vesselSimpleTypes", vesselSimpleTypes);
- Map<String, String> fleets = new TreeMap<String, String>();
+ Map<String, String> fleets = new TreeMap<>();
putInMap(fleets, fixtures.frenchCountry());
parameters.put("fleets", fleets);
=====================================
t3-actions/src/test/java/fr/ird/t3/actions/data/level1/ComputeWeightOfCategoriesForSetActionResumeTest.java
=====================================
--- a/t3-actions/src/test/java/fr/ird/t3/actions/data/level1/ComputeWeightOfCategoriesForSetActionResumeTest.java
+++ b/t3-actions/src/test/java/fr/ird/t3/actions/data/level1/ComputeWeightOfCategoriesForSetActionResumeTest.java
@@ -23,7 +23,6 @@ package fr.ird.t3.actions.data.level1;
import org.junit.Test;
import java.util.Locale;
-import java.util.Map;
/**
* To test the resume generation of action
@@ -44,13 +43,13 @@ public class ComputeWeightOfCategoriesForSetActionResumeTest extends AbstractLev
action.nbSampleWithoutWell = 1;
}
- @Override
- protected Map<String, Object> createTemplateParameters() {
-
- Map<String, Object> parameters = super.createTemplateParameters();
-
- return parameters;
- }
+// @Override
+// protected Map<String, Object> createTemplateParameters() {
+//
+// Map<String, Object> parameters = super.createTemplateParameters();
+//
+// return parameters;
+// }
@Test
public void testRender() throws Exception {
=====================================
t3-actions/src/test/java/fr/ird/t3/actions/data/level1/ConvertSampleSetSpeciesFrequencyToWeightActionResumeTest.java
=====================================
--- a/t3-actions/src/test/java/fr/ird/t3/actions/data/level1/ConvertSampleSetSpeciesFrequencyToWeightActionResumeTest.java
+++ b/t3-actions/src/test/java/fr/ird/t3/actions/data/level1/ConvertSampleSetSpeciesFrequencyToWeightActionResumeTest.java
@@ -24,7 +24,6 @@ package fr.ird.t3.actions.data.level1;
import org.junit.Test;
import java.util.Locale;
-import java.util.Map;
/**
* Tests the {@link ConvertSampleSetSpeciesFrequencyToWeightAction}.
@@ -43,13 +42,13 @@ public class ConvertSampleSetSpeciesFrequencyToWeightActionResumeTest extends Ab
super.prepareAction(action, locale);
}
- @Override
- protected Map<String, Object> createTemplateParameters() {
-
- Map<String, Object> parameters = super.createTemplateParameters();
-
- return parameters;
- }
+// @Override
+// protected Map<String, Object> createTemplateParameters() {
+//
+// Map<String, Object> parameters = super.createTemplateParameters();
+//
+// return parameters;
+// }
@Test
public void testRender() throws Exception {
=====================================
t3-actions/src/test/java/fr/ird/t3/actions/data/level1/ConvertSetSpeciesFrequencyToWeightActionResumeTest.java
=====================================
--- a/t3-actions/src/test/java/fr/ird/t3/actions/data/level1/ConvertSetSpeciesFrequencyToWeightActionResumeTest.java
+++ b/t3-actions/src/test/java/fr/ird/t3/actions/data/level1/ConvertSetSpeciesFrequencyToWeightActionResumeTest.java
@@ -23,7 +23,6 @@ package fr.ird.t3.actions.data.level1;
import org.junit.Test;
import java.util.Locale;
-import java.util.Map;
/**
* Tests the {@link ConvertSetSpeciesFrequencyToWeightAction}.
@@ -45,13 +44,13 @@ public class ConvertSetSpeciesFrequencyToWeightActionResumeTest extends Abstract
action.nbCreatedFishesInSetSpeciesFrequency = 102;
}
- @Override
- protected Map<String, Object> createTemplateParameters() {
-
- Map<String, Object> parameters = super.createTemplateParameters();
-
- return parameters;
- }
+// @Override
+// protected Map<String, Object> createTemplateParameters() {
+//
+// Map<String, Object> parameters = super.createTemplateParameters();
+//
+// return parameters;
+// }
@Test
public void testRender() throws Exception {
=====================================
t3-actions/src/test/java/fr/ird/t3/actions/data/level1/ExtrapolateSampleWeightToSetActionResumeTest.java
=====================================
--- a/t3-actions/src/test/java/fr/ird/t3/actions/data/level1/ExtrapolateSampleWeightToSetActionResumeTest.java
+++ b/t3-actions/src/test/java/fr/ird/t3/actions/data/level1/ExtrapolateSampleWeightToSetActionResumeTest.java
@@ -23,7 +23,6 @@ package fr.ird.t3.actions.data.level1;
import org.junit.Test;
import java.util.Locale;
-import java.util.Map;
/**
* To test the resume generation of action
@@ -46,13 +45,13 @@ public class ExtrapolateSampleWeightToSetActionResumeTest extends AbstractLevel1
action.nbCreatedFishesInSetSpeciesFrequency = 102;
}
- @Override
- protected Map<String, Object> createTemplateParameters() {
-
- Map<String, Object> parameters = super.createTemplateParameters();
-
- return parameters;
- }
+// @Override
+// protected Map<String, Object> createTemplateParameters() {
+//
+// Map<String, Object> parameters = super.createTemplateParameters();
+//
+// return parameters;
+// }
@Test
public void testRender() throws Exception {
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/AbstractLevel1ConfigureAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/AbstractLevel1ConfigureAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/AbstractLevel1ConfigureAction.java
@@ -33,15 +33,16 @@ import fr.ird.t3.entities.reference.SampleType;
import fr.ird.t3.services.ioc.InjectDAO;
import fr.ird.t3.services.ioc.InjectDecoratedBeans;
import fr.ird.t3.web.actions.AbstractConfigureAction;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import org.apache.commons.collections.MapUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
/**
* Abstract run action for all level1 actions.
@@ -57,26 +58,26 @@ public class AbstractLevel1ConfigureAction extends AbstractConfigureAction<Level
private static final long serialVersionUID = 1L;
- protected final Level1Step[] requiredSteps;
+ private final Level1Step[] requiredSteps;
- protected final Level1Step currentStep;
+ private final Level1Step currentStep;
@InjectDAO(entityType = Sample.class)
- protected transient SampleTopiaDao sampleDAO;
+ private transient SampleTopiaDao sampleDAO;
@InjectDecoratedBeans(beanType = SampleQuality.class, filterById = true, pathIds = "sampleQualityIds")
- protected Map<String, String> sampleQualities;
+ private Map<String, String> sampleQualities;
@InjectDecoratedBeans(beanType = SampleType.class, filterById = true)
- protected Map<String, String> sampleTypes;
+ private Map<String, String> sampleTypes;
@InjectDecoratedBeans(beanType = Country.class)
- protected Map<String, String> fleets;
+ private Map<String, String> fleets;
- @InjectDecoratedBeans(beanType = Ocean.class)
- protected Map<String, String> oceans;
+ @InjectDecoratedBeans(beanType = Ocean.class, filterById = true)
+ private Map<String, String> oceans;
- protected Map<String, String> useRfMinus10AndRfPlus10OrNot;
+ private Map<String, String> useRfMinus10AndRfPlus10OrNot;
public AbstractLevel1ConfigureAction(Level1Step currentStep) {
super(Level1Configuration.class);
@@ -110,7 +111,7 @@ public class AbstractLevel1ConfigureAction extends AbstractConfigureAction<Level
log.info("Selected fleet countries : " + configuration.getFleetIds());
log.info("Selected sample qualities : " + configuration.getSampleQualityIds());
log.info("Selected sample types : " + configuration.getSampleTypeIds());
- log.info("Selected ocean : " + configuration.getOceanId());
+ log.info("Selected oceans : " + configuration.getOceanIds());
log.info("Selected begin date : " + configuration.getBeginDate());
log.info("Selected end date : " + configuration.getEndDate());
log.info("Executed steps : " + configuration.getExecutedSteps());
@@ -118,12 +119,12 @@ public class AbstractLevel1ConfigureAction extends AbstractConfigureAction<Level
}
@Override
- public String input() throws Exception {
+ public String input() {
return INPUT;
}
@Override
- public String execute() throws Exception {
+ public String execute() {
prepareActionContext();
return SUCCESS;
@@ -136,14 +137,12 @@ public class AbstractLevel1ConfigureAction extends AbstractConfigureAction<Level
// all required step already executed with this configuration
if (log.isInfoEnabled()) {
- log.info("Current configuration already treats all required step " +
- Arrays.toString(requiredSteps));
+ log.info(String.format("Current configuration already treats all required step %s", Arrays.toString(requiredSteps)));
}
} else {
- // check on each selected sample of the configuration which steps
- // are missing
+ // check on each selected sample of the configuration which steps are missing
Multimap<Level1Step, Sample> missingSteps =
getMissingRequiredStepsExecutedOnSample();
@@ -152,10 +151,7 @@ public class AbstractLevel1ConfigureAction extends AbstractConfigureAction<Level
// ok every steps were previously executed on selected sample
if (log.isInfoEnabled()) {
- log.info("All required steps " +
- Arrays.toString(requiredSteps) +
- "were already executed on selected samples " +
- "of current configuration.");
+ log.info(String.format("All required steps %s were already executed on selected samples of current configuration.", Arrays.toString(requiredSteps)));
}
} else {
@@ -209,8 +205,7 @@ public class AbstractLevel1ConfigureAction extends AbstractConfigureAction<Level
}
public Multimap<String, String> getTripIds() {
- Multimap<String, String> ids = getConfiguration().getSampleIdsByTripId();
- return ids;
+ return getConfiguration().getSampleIdsByTripId();
}
/**
@@ -228,7 +223,7 @@ public class AbstractLevel1ConfigureAction extends AbstractConfigureAction<Level
if (!executedSteps.contains(requiredStep)) {
if (log.isWarnEnabled()) {
- log.warn("A required step [" + requiredStep + "] was still not executed with this configuration ");
+ log.warn(String.format("A required step [%s] was still not executed with this configuration ", requiredStep));
}
return false;
}
@@ -249,19 +244,17 @@ public class AbstractLevel1ConfigureAction extends AbstractConfigureAction<Level
Collection<String> sampleIds = getTripIds().values();
- Multimap<Level1Step, Sample> missingStates =
- HashMultimap.create();
+ Multimap<Level1Step, Sample> missingStates = HashMultimap.create();
for (String sampleId : sampleIds) {
- Sample sample = sampleDAO.findByTopiaId(sampleId);
+ Sample sample = sampleDAO.forTopiaIdEquals(sampleId).findUnique();
for (Level1Step requiredStep : requiredSteps) {
boolean sampleState = requiredStep.getState(sample);
if (!sampleState) {
if (log.isWarnEnabled()) {
- log.warn("Required step " + requiredStep +
- " is missing for sample " + sampleId);
+ log.warn(String.format("Required step %s is missing for sample %s", requiredStep, sampleId));
}
missingStates.put(requiredStep, sample);
}
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/AbstractLevel1RunAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/AbstractLevel1RunAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/AbstractLevel1RunAction.java
@@ -34,7 +34,6 @@ import org.apache.commons.collections.MapUtils;
import java.util.Collection;
import java.util.Date;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -48,24 +47,18 @@ public abstract class AbstractLevel1RunAction<A extends AbstractLevel1Action> ex
private static final long serialVersionUID = 1L;
- protected final Level1Step currentStep;
-
+ private final Level1Step currentStep;
@InjectDecoratedBeans(beanType = SampleQuality.class, filterById = true, pathIds = "sampleQualityIds")
- protected Map<String, String> sampleQualities;
-
+ private Map<String, String> sampleQualities;
@InjectDecoratedBeans(beanType = SampleType.class, filterById = true)
- protected Map<String, String> sampleTypes;
-
+ private Map<String, String> sampleTypes;
@InjectDecoratedBeans(beanType = Country.class, filterById = true)
- protected Map<String, String> fleets;
+ private Map<String, String> fleets;
+ @InjectDecoratedBeans(beanType = Ocean.class, filterById = true)
+ private Map<String, String> oceans;
+ private Map<String, String> useRfMinus10AndRfPlus10OrNot;
- @InjectDecoratedBeans(beanType = Ocean.class, filterById = true, filterBySingleId = true)
- protected Map<String, String> oceans;
-
- protected Map<String, String> useRfMinus10AndRfPlus10OrNot;
-
- protected AbstractLevel1RunAction(Class<A> actionType,
- Level1Step currentStep) {
+ AbstractLevel1RunAction(Class<A> actionType, Level1Step currentStep) {
super(actionType);
this.currentStep = currentStep;
}
@@ -73,21 +66,13 @@ public abstract class AbstractLevel1RunAction<A extends AbstractLevel1Action> ex
@Override
protected void executeAction(A action) throws Exception {
- // when beginning a step, remove from executed one all the step with
- // higher ranks...
+ // when beginning a step, remove from executed one all the step with higher ranks...
Level1Configuration configuration = getConfiguration();
- Set<Level1Step> executedSteps =
- configuration.getExecutedSteps();
+ Set<Level1Step> executedSteps = configuration.getExecutedSteps();
int ordinal = currentStep.ordinal();
- Iterator<Level1Step> itr = executedSteps.iterator();
- while (itr.hasNext()) {
- Level1Step step = itr.next();
- if (step.ordinal() >= ordinal) {
- itr.remove();
- }
- }
+ executedSteps.removeIf(step -> step.ordinal() >= ordinal);
super.executeAction(action);
@@ -134,8 +119,7 @@ public abstract class AbstractLevel1RunAction<A extends AbstractLevel1Action> ex
}
public Multimap<String, String> getTripIds() {
- Multimap<String, String> ids = getConfiguration().getSampleIdsByTripId();
- return ids;
+ return getConfiguration().getSampleIdsByTripId();
}
public Map<String, String> getUseRfMinus10AndRfPlus10OrNot() {
@@ -143,14 +127,8 @@ public abstract class AbstractLevel1RunAction<A extends AbstractLevel1Action> ex
}
@Override
- protected Map<String, Object> prepareResumeParameters(A action,
- Exception error,
- Date startDate,
- Date endDate) {
- Map<String, Object> map = super.prepareResumeParameters(action,
- error,
- startDate,
- endDate);
+ protected Map<String, Object> prepareResumeParameters(A action, Exception error, Date startDate, Date endDate) {
+ Map<String, Object> map = super.prepareResumeParameters(action, error, startDate, endDate);
map.put("oceans", oceans);
map.put("sampleQualities", sampleQualities);
map.put("sampleTypes", sampleTypes);
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ComputeWeightOfCategoriesForSetRunAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ComputeWeightOfCategoriesForSetRunAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ComputeWeightOfCategoriesForSetRunAction.java
@@ -34,7 +34,6 @@ public class ComputeWeightOfCategoriesForSetRunAction extends AbstractLevel1RunA
private static final long serialVersionUID = 1L;
public ComputeWeightOfCategoriesForSetRunAction() {
- super(ComputeWeightOfCategoriesForSetAction.class,
- Level1Step.COMPUTE_WEIGHT_OF_CATEGORIES_FOR_SET);
+ super(ComputeWeightOfCategoriesForSetAction.class, Level1Step.COMPUTE_WEIGHT_OF_CATEGORIES_FOR_SET);
}
}
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ConvertSampleSetSpeciesFrequencyToWeightRunAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ConvertSampleSetSpeciesFrequencyToWeightRunAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ConvertSampleSetSpeciesFrequencyToWeightRunAction.java
@@ -35,7 +35,6 @@ public class ConvertSampleSetSpeciesFrequencyToWeightRunAction extends AbstractL
private static final long serialVersionUID = 1L;
public ConvertSampleSetSpeciesFrequencyToWeightRunAction() {
- super(ConvertSampleSetSpeciesFrequencyToWeightAction.class,
- Level1Step.CONVERT_SAMPLE_SET_SPECIES_FREQUENCY_TO_WEIGHT);
+ super(ConvertSampleSetSpeciesFrequencyToWeightAction.class, Level1Step.CONVERT_SAMPLE_SET_SPECIES_FREQUENCY_TO_WEIGHT);
}
}
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ConvertSetSpeciesFrequencyToWeightRunAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ConvertSetSpeciesFrequencyToWeightRunAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ConvertSetSpeciesFrequencyToWeightRunAction.java
@@ -34,7 +34,6 @@ public class ConvertSetSpeciesFrequencyToWeightRunAction extends AbstractLevel1R
private static final long serialVersionUID = 1L;
public ConvertSetSpeciesFrequencyToWeightRunAction() {
- super(ConvertSetSpeciesFrequencyToWeightAction.class,
- Level1Step.CONVERT_SET_SPECIES_FREQUENCY_TO_WEIGHT);
+ super(ConvertSetSpeciesFrequencyToWeightAction.class, Level1Step.CONVERT_SET_SPECIES_FREQUENCY_TO_WEIGHT);
}
}
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ExtrapolateSampleCountedAndMeasuredRunAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ExtrapolateSampleCountedAndMeasuredRunAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ExtrapolateSampleCountedAndMeasuredRunAction.java
@@ -38,24 +38,13 @@ public class ExtrapolateSampleCountedAndMeasuredRunAction extends AbstractLevel1
private static final long serialVersionUID = 1L;
public ExtrapolateSampleCountedAndMeasuredRunAction() {
- super(ExtrapolateSampleCountedAndMeasuredAction.class,
- Level1Step.EXTRAPOLATE_SAMPLE_COUNTED_AND_MEASURED);
+ super(ExtrapolateSampleCountedAndMeasuredAction.class, Level1Step.EXTRAPOLATE_SAMPLE_COUNTED_AND_MEASURED);
}
@Override
- protected Map<String, Object> prepareResumeParameters(
- ExtrapolateSampleCountedAndMeasuredAction action,
- Exception error,
- Date startDate,
- Date endDate) {
- Map<String, Object> parameters =
- super.prepareResumeParameters(action,
- error,
- startDate,
- endDate
- );
+ protected Map<String, Object> prepareResumeParameters(ExtrapolateSampleCountedAndMeasuredAction action, Exception error, Date startDate, Date endDate) {
+ Map<String, Object> parameters = super.prepareResumeParameters(action, error, startDate, endDate);
parameters.put("speciesDecorator", getDecorator(Species.class));
-
return parameters;
}
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ExtrapolateSampleWeightToSetRunAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ExtrapolateSampleWeightToSetRunAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ExtrapolateSampleWeightToSetRunAction.java
@@ -34,7 +34,6 @@ public class ExtrapolateSampleWeightToSetRunAction extends AbstractLevel1RunActi
private static final long serialVersionUID = 1L;
public ExtrapolateSampleWeightToSetRunAction() {
- super(ExtrapolateSampleWeightToSetAction.class,
- Level1Step.EXTRAPOLATE_SAMPLE_WEIGHT_TO_SET);
+ super(ExtrapolateSampleWeightToSetAction.class, Level1Step.EXTRAPOLATE_SAMPLE_WEIGHT_TO_SET);
}
}
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ManageLevel1ConfigurationAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ManageLevel1ConfigurationAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/ManageLevel1ConfigurationAction.java
@@ -35,22 +35,21 @@ import fr.ird.t3.entities.reference.SampleType;
import fr.ird.t3.entities.reference.SampleTypeTopiaDao;
import fr.ird.t3.entities.type.T3Date;
import fr.ird.t3.services.DecoratorService;
-import fr.ird.t3.services.ioc.InjectDAO;
import fr.ird.t3.services.ioc.InjectDecoratedBeans;
import fr.ird.t3.services.ioc.InjectFromDAO;
import fr.ird.t3.web.actions.AbstractConfigureAction;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.MutablePair;
import org.apache.struts2.interceptor.validation.SkipValidation;
import org.nuiton.decorator.Decorator;
import org.nuiton.topia.persistence.util.TopiaEntityHelper;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
/**
* Action to manage the configuration of level 1.
*
@@ -62,26 +61,23 @@ public class ManageLevel1ConfigurationAction extends AbstractConfigureAction<Lev
private static final long serialVersionUID = 1L;
@InjectDecoratedBeans(beanType = SampleQuality.class)
- protected Map<String, String> sampleQualities;
+ private Map<String, String> sampleQualities;
@InjectDecoratedBeans(beanType = SampleType.class)
- protected Map<String, String> sampleTypes;
+ private Map<String, String> sampleTypes;
@InjectDecoratedBeans(beanType = Country.class)
- protected Map<String, String> fleets;
+ private Map<String, String> fleets;
@InjectDecoratedBeans(beanType = Ocean.class)
- protected Map<String, String> oceans;
+ private Map<String, String> oceans;
@InjectFromDAO(entityType = Trip.class, method = "findAllForLevel1")
- protected Collection<Trip> trips;
+ private Collection<Trip> trips;
- @InjectDAO(entityType = Ocean.class)
- protected transient OceanTopiaDao oceanDAO;
+ private Map<String, Trip> tripByTopiaIds;
- protected Map<String, Trip> tripByTopiaIds;
-
- protected Map<String, String> useRfMinus10AndRfPlus10OrNot;
+ private Map<String, String> useRfMinus10AndRfPlus10OrNot;
public ManageLevel1ConfigurationAction() {
super(Level1Configuration.class);
@@ -124,18 +120,17 @@ public class ManageLevel1ConfigurationAction extends AbstractConfigureAction<Lev
conf.setSampleTypes(sortToList(SampleTypeTopiaDao.getAllSampleTypes(trips)));
conf.setFleets(sortToList(CountryTopiaDao.getAllFleetCountries(trips)));
conf.setOceans(sortToList(OceanTopiaDao.getAllOcean(trips)));
- if (StringUtils.isEmpty(conf.getOceanId()) &&
- CollectionUtils.isNotEmpty(conf.getOceans())) {
- conf.setOceanId(conf.getOceans().get(0).getTopiaId());
- }
+// if (StringUtils.isEmpty(conf.getOceanId()) &&
+// CollectionUtils.isNotEmpty(conf.getOceans())) {
+// conf.setOceanId(conf.getOceans().get(0).getTopiaId());
+// }
// set ids list to empty lists
List<String> ids;
// use default sample qualities
ids = T3EntityHelper.selectIdsByCodes(conf.getSampleQualities(), 1, 2, 3, 9);
- conf.setSampleQualityIds(
- ids);
+ conf.setSampleQualityIds(ids);
// use default sample types
ids = T3EntityHelper.selectIdsByCodes(conf.getSampleTypes(), 1, 2, 3, 9);
@@ -165,8 +160,7 @@ public class ManageLevel1ConfigurationAction extends AbstractConfigureAction<Lev
injectOnly(InjectDecoratedBeans.class);
DecoratorService decoratorService = newService(DecoratorService.class);
- Multimap<String, String> matchingTrips = conf.getMatchingTrips(
- trips, getLocale(), decoratorService);
+ Multimap<String, String> matchingTrips = conf.getMatchingTrips(trips, getLocale(), decoratorService);
conf.setSampleIdsByTripId(matchingTrips);
}
@@ -179,7 +173,7 @@ public class ManageLevel1ConfigurationAction extends AbstractConfigureAction<Lev
}
}
- public final String prepareConfiguration() throws Exception {
+ public final String prepareConfiguration() {
if (!isConfigurationInSession() && !hasFieldErrors()) {
@@ -189,7 +183,7 @@ public class ManageLevel1ConfigurationAction extends AbstractConfigureAction<Lev
return INPUT;
}
- public String saveConfiguration() throws Exception {
+ public String saveConfiguration() {
Level1Configuration config = getConfiguration();
// each time configuration is modified, reset executed steps for
@@ -205,7 +199,7 @@ public class ManageLevel1ConfigurationAction extends AbstractConfigureAction<Lev
}
@SkipValidation
- public String removeConfiguration() throws Exception {
+ public String removeConfiguration() {
boolean saved = isConfigurationInSession();
if (saved) {
@@ -238,9 +232,7 @@ public class ManageLevel1ConfigurationAction extends AbstractConfigureAction<Lev
}
public Map<String, Collection<String>> getTripIds() {
- Map<String, Collection<String>> ids =
- getConfiguration().getSampleIdsByTripId().asMap();
- return ids;
+ return getConfiguration().getSampleIdsByTripId().asMap();
}
public Map<String, String> getSampleQualities() {
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/RedistributeSampleNumberToSetRunAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/RedistributeSampleNumberToSetRunAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/RedistributeSampleNumberToSetRunAction.java
@@ -41,23 +41,12 @@ public class RedistributeSampleNumberToSetRunAction extends AbstractLevel1RunAct
private static final long serialVersionUID = 1L;
public RedistributeSampleNumberToSetRunAction() {
- super(RedistributeSampleNumberToSetAction.class,
- Level1Step.REDISTRIBUTE_SAMPLE_SET_TO_SET);
+ super(RedistributeSampleNumberToSetAction.class, Level1Step.REDISTRIBUTE_SAMPLE_SET_TO_SET);
}
@Override
- protected Map<String, Object> prepareResumeParameters(
- RedistributeSampleNumberToSetAction action,
- Exception error,
- Date startDate,
- Date endDate) {
- Map<String, Object> parameters = super.prepareResumeParameters(
- action,
- error,
- startDate,
- endDate
- );
-
+ protected Map<String, Object> prepareResumeParameters(RedistributeSampleNumberToSetAction action, Exception error, Date startDate, Date endDate) {
+ Map<String, Object> parameters = super.prepareResumeParameters(action, error, startDate, endDate);
parameters.put("speciesDecorator", getDecorator(Species.class));
parameters.put("tripDecorator", getDecorator(Trip.class, DecoratorService.WITH_ID));
parameters.put("activityDecorator", getDecorator(Activity.class));
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/StandardizeSampleMeasuresRunAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/StandardizeSampleMeasuresRunAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/data/level1/StandardizeSampleMeasuresRunAction.java
@@ -38,24 +38,13 @@ public class StandardizeSampleMeasuresRunAction extends AbstractLevel1RunAction<
private static final long serialVersionUID = 1L;
public StandardizeSampleMeasuresRunAction() {
- super(StandardizeSampleMeasuresAction.class,
- Level1Step.STANDARDIZE_SAMPLE_MEASURE);
+ super(StandardizeSampleMeasuresAction.class, Level1Step.STANDARDIZE_SAMPLE_MEASURE);
}
@Override
- protected Map<String, Object> prepareResumeParameters(
- StandardizeSampleMeasuresAction action,
- Exception error,
- Date startDate,
- Date endDate) {
- Map<String, Object> parameters =
- super.prepareResumeParameters(action,
- error,
- startDate,
- endDate
- );
+ protected Map<String, Object> prepareResumeParameters(StandardizeSampleMeasuresAction action, Exception error, Date startDate, Date endDate) {
+ Map<String, Object> parameters = super.prepareResumeParameters(action, error, startDate, endDate);
parameters.put("speciesDecorator", getDecorator(Species.class));
-
return parameters;
}
}
=====================================
t3-web/src/main/resources/fr/ird/t3/web/actions/data/level1/ManageLevel1ConfigurationAction-validateLevel1Configuration-validation.xml
=====================================
--- a/t3-web/src/main/resources/fr/ird/t3/web/actions/data/level1/ManageLevel1ConfigurationAction-validateLevel1Configuration-validation.xml
+++ b/t3-web/src/main/resources/fr/ird/t3/web/actions/data/level1/ManageLevel1ConfigurationAction-validateLevel1Configuration-validation.xml
@@ -48,9 +48,10 @@
</field>
- <field name="configuration.oceanId">
+ <field name="configuration.oceanIds">
- <field-validator type="requiredstring">
+ <field-validator type="fieldexpression">
+ <param name="expression">!configuration.oceanIds.empty</param>
<message key="t3.error.no.ocean.selected"/>
</field-validator>
=====================================
t3-web/src/main/resources/fr/ird/t3/web/actions/data/level1/ManageLevel1ConfigurationAction-validation.xml
=====================================
--- a/t3-web/src/main/resources/fr/ird/t3/web/actions/data/level1/ManageLevel1ConfigurationAction-validation.xml
+++ b/t3-web/src/main/resources/fr/ird/t3/web/actions/data/level1/ManageLevel1ConfigurationAction-validation.xml
@@ -48,7 +48,7 @@
</field>
- <field name="configuration.oceanId">
+ <field name="configuration.oceanIds">
<field-validator type="fieldexpression">
<param name="expression">!configuration.oceans.empty</param>
=====================================
t3-web/src/main/webapp/WEB-INF/jsp/data/level1/level1Configuration.jsp
=====================================
--- a/t3-web/src/main/webapp/WEB-INF/jsp/data/level1/level1Configuration.jsp
+++ b/t3-web/src/main/webapp/WEB-INF/jsp/data/level1/level1Configuration.jsp
@@ -56,8 +56,9 @@
list="fleets" template="mycheckboxlist"/>
<%-- selected ocean --%>
- <s:select key="configuration.oceanId" list="oceans" requiredLabel="true"
- label='%{getText("t3.common.ocean")}'/>
+ <s:checkboxlist key="configuration.oceanIds" requiredLabel="true"
+ label='%{getText("t3.common.ocean")}'
+ list="oceans" template="mycheckboxlist"/>
<%-- selected begin date --%>
<sj:datepicker key="configuration.beginDate" requiredLabel="true"
=====================================
t3-web/src/main/webapp/WEB-INF/jsp/data/level1/level1ConfigurationResume.jsp
=====================================
--- a/t3-web/src/main/webapp/WEB-INF/jsp/data/level1/level1ConfigurationResume.jsp
+++ b/t3-web/src/main/webapp/WEB-INF/jsp/data/level1/level1ConfigurationResume.jsp
@@ -45,8 +45,9 @@
label='%{getText("t3.common.fleetCountry")}'/>
<%-- selected ocean --%>
- <s:select key="configuration.oceanId" disabled="true" list="oceans"
- label='%{getText("t3.common.ocean")}'/>
+ <s:checkboxlist key="configuration.oceanIds" disabled="true"
+ list="oceans" template="mycheckboxlist"
+ label='%{getText("t3.common.ocean")}'/>
<%-- selected begin date --%>
<s:textfield key="configuration.beginDate" disabled="true"
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/676b259b7752246d14e8951bff15b48a…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/676b259b7752246d14e8951bff15b48a…
You're receiving this email because of your account on gitlab.com.
1
0