T3-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- 424 discussions
08 Mar '18
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
8179f9e0 by Tony CHEMIT at 2018-03-08T17:45:06Z
update test fixtures for ATL [skip ci]
- - - - -
4 changed files:
- t3-actions/src/main/java/fr/ird/t3/actions/io/input/it/AnalyzeInputSourceActionITSupport.java
- t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/MSAccessTestConfiguration.java
- t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/AtlanticOceanFixtures.java
- t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/it/AnalyzeInputSourceActionAtlanticOceanIT.java
Changes:
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/io/input/it/AnalyzeInputSourceActionITSupport.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/io/input/it/AnalyzeInputSourceActionITSupport.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/io/input/it/AnalyzeInputSourceActionITSupport.java
@@ -113,30 +113,26 @@ public abstract class AnalyzeInputSourceActionITSupport {
if (outputWriter != null) {
outputWriter.flush();
outputWriter.close();
+ log.info(new String(Files.readAllBytes(outputFile.toPath())));
}
}
void testExecute(OceanFixtures fixture) throws Exception {
- testExecute(
- fixture.nbSafe(),
- fixture.nbUnsafe(),
- fixture.nbSafeWithoutWell(),
- fixture.nbUnsafeWithoutWell(),
- TripType.STANDARD,
- false,
- false
- );
+ serviceContext.getMsConfig().setUseWells(false);
+ testExecute(fixture.nbSafe(), fixture.nbUnsafe(), fixture.nbSafeWithoutWell(), fixture.nbUnsafeWithoutWell(), TripType.STANDARD, false, false);
+ serviceContext.getMsConfig().setUseWells(true);
+ testExecute(fixture.nbSafe(), fixture.nbUnsafe(), fixture.nbSafeWithoutWell(), fixture.nbUnsafeWithoutWell(), TripType.STANDARD, false, false);
}
public void testExecute(int nbSafe,
int nbUnsafe,
- int nbSafeWithoutwell,
+ int nbSafeWithoutWell,
int nbUnsafeWithoutWell) throws Exception {
testExecute(
nbSafe,
nbUnsafe,
- nbSafeWithoutwell,
+ nbSafeWithoutWell,
nbUnsafeWithoutWell,
TripType.STANDARD,
false,
@@ -168,13 +164,15 @@ public abstract class AnalyzeInputSourceActionITSupport {
Set<Trip> unsafeTrips = action.getResultAsSet(AnalyzeInputSourceAction.RESULT_UNSAFE_TRIPS, Trip.class);
Assert.assertNotNull(unsafeTrips);
outputWriter.write(String.format("found %d unsafe trip(s).\n", unsafeTrips.size()));
+
+ log.info(String.format("\n[%s](useWells?%b) safe : %d - unsafe : %d\n", msConfig.dbName, msConfig.isUseWells(), safeTrips.size(), unsafeTrips.size()));
+
List<String> messages;
if (log.isWarnEnabled()) {
messages = action.getWarnMessages();
if (CollectionUtils.isNotEmpty(messages)) {
for (String message : messages) {
- log.warn(String.format("[WARNING] %s\n", message));
-// outputWriter.write(String.format("[WARNING] %s\n", message));
+ outputWriter.write(String.format("[WARNING] %s\n", message));
}
}
}
@@ -187,9 +185,6 @@ public abstract class AnalyzeInputSourceActionITSupport {
}
}
- outputWriter.flush();
- log.info(String.format("\n[%s] safe : %d - unsafe : %d\n", msConfig.dbName, safeTrips.size(), unsafeTrips.size()));
- log.info(new String(Files.readAllBytes(outputFile.toPath())));
if (msConfig.isUseWells()) {
Assert.assertEquals(nbSafe, safeTrips.size());
Assert.assertEquals(nbUnsafe, unsafeTrips.size());
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/MSAccessTestConfiguration.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/MSAccessTestConfiguration.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/MSAccessTestConfiguration.java
@@ -188,4 +188,8 @@ public class MSAccessTestConfiguration {
public String getProviderId() {
return providerId;
}
+
+ public void setUseWells(boolean useWells) {
+ this.useWells = useWells;
+ }
}
=====================================
t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/AtlanticOceanFixtures.java
=====================================
--- a/t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/AtlanticOceanFixtures.java
+++ b/t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/AtlanticOceanFixtures.java
@@ -30,73 +30,73 @@ import fr.ird.t3.actions.io.input.test.OceanFixtures;
*/
public enum AtlanticOceanFixtures implements OceanFixtures {
- OA_1960(318, 36, 352, 2),
- OA_1961(298, 63, 361, 0),
- OA_1962(184, 133, 317, 0),
- OA_1963(218, 157, 375, 0),
- OA_1964(121, 61, 182, 0),
- OA_1965(93, 31, 124, 0),
- OA_1966(70, 27, 97, 0),
- OA_1967(53, 27, 80, 0),
- OA_1968(46, 14, 60, 0),
- OA_1969(64, 21, 86, 0),
-
- OA_1970(318, 36, 352, 2),
- OA_1971(298, 63, 361, 0),
- OA_1972(184, 133, 317, 0),
- OA_1973(218, 157, 375, 0),
- OA_1974(121, 61, 182, 0),
- OA_1975(93, 31, 124, 0),
- OA_1976(70, 27, 97, 0),
- OA_1977(53, 27, 80, 0),
- OA_1978(46, 14, 60, 0),
- OA_1979(64, 21, 86, 0),
-
- OA_1980(318, 36, 352, 2),
- OA_1981(298, 63, 361, 0),
- OA_1982(184, 133, 317, 0),
- OA_1983(218, 157, 375, 0),
- OA_1984(121, 61, 182, 0),
- OA_1985(93, 31, 124, 0),
- OA_1986(70, 27, 97, 0),
- OA_1987(53, 27, 80, 0),
- OA_1988(46, 14, 60, 0),
- OA_1989(64, 21, 86, 0),
-
- OA_1990(318, 36, 352, 2),
- OA_1991(298, 63, 361, 0),
- OA_1992(184, 133, 317, 0),
- OA_1993(218, 157, 375, 0),
- OA_1994(121, 61, 182, 0),
- OA_1995(93, 31, 124, 0),
- OA_1996(70, 27, 97, 0),
- OA_1997(53, 27, 80, 0),
- OA_1998(46, 14, 60, 0),
- OA_1999(64, 21, 86, 0),
+ OA_1960(151, 0),
+ OA_1961(159, 0),
+ OA_1962(203, 0),
+ OA_1963(807, 0),
+ OA_1964(709, 0),
+ OA_1965(911, 0),
+ OA_1966(942, 0),
+ OA_1967(993, 0),
+ OA_1968(1339, 0),
+ OA_1969(453, 1179),
+ OA_1970(289, 970),
+ OA_1971(146, 1047),
+ OA_1972(143, 1069),
+ OA_1973(235, 890),
+ OA_1974(254, 948),
+ OA_1975(248, 709),
+ OA_1976(149, 692),
+ OA_1977(40, 761),
+ OA_1978(56, 766),
+ OA_1979(76, 618),
+ OA_1980(324, 299),
+ OA_1981(365, 280),
+ OA_1982(416, 247),
+ OA_1983(343, 257),
+ OA_1984(297, 111),
+ OA_1985(325, 115),
+ OA_1986(214, 121),
+ OA_1987(186, 165),
+ OA_1988(212, 156),
+ OA_1989(192, 154),
+ OA_1990(141, 192),
+ OA_1991(268, 0),
+ OA_1992(250, 0),
+ OA_1993(281, 2),
+ OA_1994(278, 0),
+ OA_1995(243, 3),
+ OA_1996(90, 142),
+ OA_1997(36, 178),
+ OA_1998(205, 2),
+ OA_1999(323, 5),
OA_2000(318, 36, 352, 2),
- OA_2001(298, 63, 361, 0),
- OA_2002(184, 133, 317, 0),
- OA_2003(218, 157, 375, 0),
- OA_2004(121, 61, 182, 0),
+ OA_2001(298, 63, 358, 3),
+ OA_2002(184, 133, 316, 1),
+ OA_2003(218, 157, 369, 6),
+ OA_2004(121, 61, 181, 1),
OA_2005(93, 31, 124, 0),
OA_2006(70, 27, 97, 0),
- OA_2007(53, 27, 80, 0),
+ OA_2007(53, 27, 77, 3),
OA_2008(46, 14, 60, 0),
OA_2009(64, 21, 86, 0),
-
OA_2010(75, 13, 87, 0),
OA_2011(75, 13, 91, 1),
OA_2012(75, 13, 97, 0),
OA_2013(75, 13, 103, 0),
- OA_2014(75, 13, 91, 0),
- OA_2015(75, 13, 80, 8);
+ OA_2014(75, 13, 90, 0),
+ OA_2015(75, 13, 103, 0);
private final int nbSafe;
private final int nbUnsafe;
private final int nbSafeWithoutWell;
private final int nbUnsafeWithoutWell;
+ AtlanticOceanFixtures(int nbSafeWithoutWell, int nbUnsafeWithoutWell) {
+ this(nbSafeWithoutWell, nbUnsafeWithoutWell, nbSafeWithoutWell, nbUnsafeWithoutWell);
+ }
+
AtlanticOceanFixtures(int nbSafe, int nbUnsafe, int nbSafeWithoutWell, int nbUnsafeWithoutWell) {
this.nbSafe = nbSafe;
this.nbUnsafe = nbUnsafe;
=====================================
t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/it/AnalyzeInputSourceActionAtlanticOceanIT.java
=====================================
--- a/t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/it/AnalyzeInputSourceActionAtlanticOceanIT.java
+++ b/t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/it/AnalyzeInputSourceActionAtlanticOceanIT.java
@@ -33,7 +33,6 @@ import org.junit.Test;
* @author Tony Chemit - dev(a)tchemit.fr
* @since 1.0
*/
-@Ignore
public class AnalyzeInputSourceActionAtlanticOceanIT extends AnalyzeInputSourceActionITSupport implements T3AVDTHV35TestAtlanticOcean {
@Test
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/8179f9e0fc8ff6ae190c4d147c345e4f…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/8179f9e0fc8ff6ae190c4d147c345e4f…
You're receiving this email because of your account on gitlab.com.
1
0
[Git][ultreiaio/ird-t3][develop] Marées sans logbooks : gestion de leurs échantillons - ajout de check de…
by Tony CHEMIT 08 Mar '18
by Tony CHEMIT 08 Mar '18
08 Mar '18
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
7674474a by Tony CHEMIT at 2018-03-08T15:56:53Z
Marées sans logbooks : gestion de leurs échantillons - ajout de check de cohérence sur Trip.logbookAvaibility (See #116) + fix typo
- - - - -
30 changed files:
- .gitlab-ci.yml
- t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeRF1Action.java
- t3-actions/src/main/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceAction.java
- t3-actions/src/main/java/fr/ird/t3/actions/io/input/it/AnalyzeInputSourceActionITSupport.java
- t3-actions/src/main/java/fr/ird/t3/actions/io/input/it/ImportInputSourceActionITSupport.java
- t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/AnalyzeInputSourceActionTestSupport.java
- t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/ImportInputSourceActionTestSupport.java
- t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/OceanFixtures.java
- t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level3/Level3Action_en.ftl
- t3-actions/src/main/resources/i18n/t3-actions_en_GB.properties
- t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties
- t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeRF1ActionResumeTest.java
- t3-domain/src/main/java/fr/ird/t3/entities/T3Predicates.java
- t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractTripTopiaDao.java
- t3-domain/src/main/java/fr/ird/t3/entities/data/TripImpl.java
- t3-domain/src/main/java/fr/ird/t3/io/input/T3Input.java
- t3-domain/src/main/java/fr/ird/t3/io/input/access/AbstractT3InputMSAccess.java
- t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AccessDataSource.java
- t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AvdthDataEntityVisitor.java
- t3-domain/src/main/resources/db/migration/V2_3_01_add-Trip-tripType.sql
- t3-domain/src/main/xmi/t3-persistence.zargo
- t3-domain/src/test/java/fr/ird/t3/entities/reference/WeightCategoryTreatmentImplTest.java
- t3-input-avdthv33/src/main/java/fr/ird/t3/io/input/avdth/v33/T3InputAvdth33.java
- t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/AtlanticOceanFixtures.java
- t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/IndianOceanFixtures.java
- t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/it/AnalyzeInputSourceActionAtlanticOceanIT.java
- t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/it/ImportInputSourceActionAtlanticOceanIT.java
- t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/it/T3AVDTHV35TestAtlanticOcean.java
- t3-input-avdthv36/src/main/java/fr/ird/t3/io/input/avdth/v36/T3InputAvdth36.java
- t3-output-balbayav32/src/main/java/fr/ird/t3/io/output/balbaya/v32/BalbayaOperationExecutionTripImpl.java
The diff was not included because it is too large.
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/7674474a553facc7c10d2a9046795c0f…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/7674474a553facc7c10d2a9046795c0f…
You're receiving this email because of your account on gitlab.com.
1
0
[Git][ultreiaio/ird-t3][develop] Marées sans logbooks : gestion de leurs échantillons - ajout de check de…
by Tony CHEMIT 08 Mar '18
by Tony CHEMIT 08 Mar '18
08 Mar '18
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
f5ebfe88 by Tony CHEMIT at 2018-03-08T15:56:05Z
Marées sans logbooks : gestion de leurs échantillons - ajout de check de cohérence sur Trip.logbookAvaibility (See #116) + fix typo
- - - - -
30 changed files:
- .gitlab-ci.yml
- t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeRF1Action.java
- t3-actions/src/main/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceAction.java
- t3-actions/src/main/java/fr/ird/t3/actions/io/input/it/AnalyzeInputSourceActionITSupport.java
- t3-actions/src/main/java/fr/ird/t3/actions/io/input/it/ImportInputSourceActionITSupport.java
- t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/AnalyzeInputSourceActionTestSupport.java
- t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/ImportInputSourceActionTestSupport.java
- t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/OceanFixtures.java
- t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level3/Level3Action_en.ftl
- t3-actions/src/main/resources/i18n/t3-actions_en_GB.properties
- t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties
- t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeRF1ActionResumeTest.java
- t3-domain/src/main/java/fr/ird/t3/entities/T3Predicates.java
- t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractTripTopiaDao.java
- t3-domain/src/main/java/fr/ird/t3/entities/data/TripImpl.java
- t3-domain/src/main/java/fr/ird/t3/io/input/T3Input.java
- t3-domain/src/main/java/fr/ird/t3/io/input/access/AbstractT3InputMSAccess.java
- t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AccessDataSource.java
- t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AvdthDataEntityVisitor.java
- t3-domain/src/main/resources/db/migration/V2_3_01_add-Trip-tripType.sql
- t3-domain/src/main/xmi/t3-persistence.zargo
- t3-domain/src/test/java/fr/ird/t3/entities/reference/WeightCategoryTreatmentImplTest.java
- t3-input-avdthv33/src/main/java/fr/ird/t3/io/input/avdth/v33/T3InputAvdth33.java
- t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/AtlanticOceanFixtures.java
- t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/IndianOceanFixtures.java
- t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/it/AnalyzeInputSourceActionAtlanticOceanIT.java
- t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/it/ImportInputSourceActionAtlanticOceanIT.java
- t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/it/T3AVDTHV35TestAtlanticOcean.java
- t3-input-avdthv36/src/main/java/fr/ird/t3/io/input/avdth/v36/T3InputAvdth36.java
- t3-output-balbayav32/src/main/java/fr/ird/t3/io/output/balbaya/v32/BalbayaOperationExecutionTripImpl.java
The diff was not included because it is too large.
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/f5ebfe889a98afb9c8ac124fe8e2755a…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/f5ebfe889a98afb9c8ac124fe8e2755a…
You're receiving this email because of your account on gitlab.com.
1
0
[Git][ultreiaio/ird-t3][develop] Marées sans logbooks : gestion de leurs échantillons - ajout de check de…
by Tony CHEMIT 08 Mar '18
by Tony CHEMIT 08 Mar '18
08 Mar '18
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
7b035f83 by Tony CHEMIT at 2018-03-08T14:53:16Z
Marées sans logbooks : gestion de leurs échantillons - ajout de check de cohérence sur Trip.logbookAvaibility (See #116) + fix typo
- - - - -
27 changed files:
- .gitlab-ci.yml
- t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeRF1Action.java
- t3-actions/src/main/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceAction.java
- t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level3/Level3Action_en.ftl
- t3-actions/src/main/resources/i18n/t3-actions_en_GB.properties
- t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties
- t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeRF1ActionResumeTest.java
- t3-domain/src/main/java/fr/ird/t3/entities/T3Predicates.java
- t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractTripTopiaDao.java
- t3-domain/src/main/java/fr/ird/t3/entities/data/TripImpl.java
- t3-domain/src/main/java/fr/ird/t3/io/input/T3Input.java
- t3-domain/src/main/java/fr/ird/t3/io/input/access/AbstractT3InputMSAccess.java
- t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AccessDataSource.java
- t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AvdthDataEntityVisitor.java
- t3-domain/src/main/resources/db/migration/V2_3_01_add-Trip-tripType.sql
- t3-domain/src/main/xmi/t3-persistence.zargo
- t3-domain/src/test/java/fr/ird/t3/entities/reference/WeightCategoryTreatmentImplTest.java
- t3-input-avdthv33/src/main/java/fr/ird/t3/io/input/avdth/v33/T3InputAvdth33.java
- t3-input-avdthv36/src/main/java/fr/ird/t3/io/input/avdth/v36/T3InputAvdth36.java
- t3-output-balbayav32/src/main/java/fr/ird/t3/io/output/balbaya/v32/BalbayaOperationExecutionTripImpl.java
- t3-web/src/main/java/fr/ird/t3/web/T3StaticContentLoader.java
- t3-web/src/main/java/fr/ird/t3/web/actions/T3ActionSupport.java
- t3-web/src/main/java/fr/ird/t3/web/actions/io/output/ExportConfigureAction.java
- t3-web/src/main/java/fr/ird/t3/web/actions/json/GetOutputProviderOperationsAction.java
- t3-web/src/main/java/fr/ird/t3/web/actions/json/GetZoneVersionsAction.java
- t3-web/src/main/resources/i18n/t3-web_en_GB.properties
- t3-web/src/main/webapp/WEB-INF/jsp/admin/tripDetail.jsp
Changes:
=====================================
.gitlab-ci.yml
=====================================
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -28,7 +28,13 @@ image: registry.gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/docker:lat
environment:
name: test
script:
- - if [ -n "${BUILD_FOR_RELEASE}" ]; then ultreiaio-maven-execute 'clean verify -U -DperformRelease -Dmaven.javadoc.skip'; fi
+ - if [ -n "${BUILD_FOR_RELEASE}" ]; then ultreiaio-maven-execute 'clean verify -U -DperformRelease -Dmaven.source.skip -Dmaven.javadoc.skip'; fi
+
+.deploy-snapshot: &deploy-snapshot
+ environment:
+ name: snapshot
+ script:
+ - if [ -n "${DEPLOY_SNAPSHOT}" ]; then ultreiaio-maven-execute 'clean deploy -am -rf t3-domain -DperformRelease -Dmaven.source.skip -Dmaven.javadoc.skip'; fi
.publish-site: &publish-site
environment:
@@ -84,6 +90,11 @@ trigger-build-for-release:
<<: *triggers
<<: *build-for-release
+trigger-deploy-snapshot:
+ <<: *stage_release
+ <<: *triggers
+ <<: *deploy-snapshot
+
trigger-deploy-demo:
<<: *stage_test
<<: *triggers
@@ -167,6 +178,13 @@ create-docker:
before_script:
- export CREATE_DOCKER=true
+deploy-snapshot:
+ <<: *stage_release
+ <<: *manual
+ <<: *deploy-snapshot
+ before_script:
+ - export DEPLOY_SNAPSHOT=true
+
make-release:
<<: *stage_release
<<: *manual
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeRF1Action.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeRF1Action.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeRF1Action.java
@@ -50,20 +50,19 @@ import static org.nuiton.i18n.I18n.l;
*/
public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configuration> {
- /** Logger. */
private static final Log log = LogFactory.getLog(ComputeRF1Action.class);
/** total catch weight for trips with rf1 != null. */
- protected float totalCatchWeightRF1;
+ float totalCatchWeightRF1;
/** total landing weight for trips with rf1 != null. */
- protected float totalLandingWeight;
+ float totalLandingWeight;
/** Number of trips rejected (with no logbook). */
- protected int nbRejectedTrips;
+ int nbRejectedTrips;
/** Number of accepted trips (says with a rf1 computation). */
- protected int nbAcceptedTrips;
+ int nbAcceptedTrips;
/** Number of accepted complete trips (says with a rf1 computation). */
- protected int nbCompleteAcceptedTrips;
+ int nbCompleteAcceptedTrips;
/** Number of complete accepted trips (says with a rf1 computation, but not in defined bound). */
- protected int nbCompleteAcceptedTripsWithBadRF1;
+ int nbCompleteAcceptedTripsWithBadRF1;
@InjectDAO(entityType = RF1SpeciesForFleet.class)
private RF1SpeciesForFleetTopiaDao rF1SpecieForFleetDAO;
/** usable trips group by vessel */
@@ -205,7 +204,6 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati
treatCompleteTrip(completeTrip, species, minimumRate, maximumRate);
// complete trip was consumed
completeTrip.removeTrips(tripList);
-// tripList.removeAll(completeTrip);
}
if (CollectionUtils.isNotEmpty(tripList)) {
// still some trips not complete
@@ -289,7 +287,7 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati
for (Trip trip : trips) {
String tripStr = decorate(trip);
Float rf1ToUse = rf1;
- if (trip.getLogBookAvailability() != 1) {
+ if (!trip.isWithLogbook()) {
// means can not apply any rf1 : rf1 must stay at null...
rf1ToUse = null;
addWarningMessage(l(locale, "t3.level0.computeRF1.warning.no.logbook", tripStr));
@@ -309,28 +307,6 @@ public class ComputeRF1Action extends AbstractLevel0Action<ComputeRF1Configurati
decorate(completeTrip.getLandingTrip()), tripTotalCatchWeightRf1, tripTotalLandingWeight));
log.debug(String.format("After trip %s totalCatchWeightRF1 = %s totalLandingWeight = %s",
decorate(completeTrip.getLandingTrip()), totalCatchWeightRF1, totalLandingWeight));
-// for (Trip trip : completeTrip) {
-//
-// float tripTotalCatchWeightRf1 =
-// trip.getElementaryCatchTotalWeightRf1(species);
-// totalCatchWeightRF1 += tripTotalCatchWeightRf1;
-//
-// float tripTotalLandingWeight =
-// trip.getElementaryLandingTotalWeight(species);
-// totalLandingWeight += tripTotalLandingWeight;
-//
-// if (log.isInfoEnabled()) {
-//
-// log.info("After trip " + decorate(trip) +
-// " tripTotalCatchWeightRf1 = " + tripTotalCatchWeightRf1 +
-// " tripTotalLandingWeight = " + tripTotalLandingWeight);
-// }
-// if (log.isDebugEnabled()) {
-// log.debug("After trip " + decorate(trip) +
-// " totalCatchWeightRF1 = " + totalCatchWeightRF1 +
-// " totalLandingWeight = " + totalLandingWeight);
-// }
-// }
}
private float computeRF1ForCompleteTrip(Iterable<Trip> completeTrip, Collection<Species> speciesList) {
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceAction.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceAction.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceAction.java
@@ -82,7 +82,6 @@ public class AnalyzeInputSourceAction extends T3Action<AnalyzeInputSourceConfigu
private T3Input inputPilot;
private boolean safe;
- // Ne pas supprimer, utilisé dans la template de résumé
@SuppressWarnings("unused")
public Trip getTripToReplace(Trip trip) {
Map<Trip, Trip> resultAsMap = getResultAsMap(RESULT_TRIPS_TO_REPLACE);
@@ -117,10 +116,8 @@ public class AnalyzeInputSourceAction extends T3Action<AnalyzeInputSourceConfigu
}
String[] analyzeWarnings = inputPilot.getAnalyzeWarnings();
if (analyzeWarnings != null && analyzeWarnings.length > 0) {
- // some errors on db
- StringBuilder sb = new StringBuilder(
- l(locale, "t3.import.warning.on.analyze", analyzeWarnings.length)
- );
+ // some warnings on db
+ StringBuilder sb = new StringBuilder(l(locale, "t3.import.warning.on.analyze", analyzeWarnings.length));
for (String analyzeWarning : analyzeWarnings) {
sb.append('\n').append(analyzeWarning);
}
@@ -224,7 +221,6 @@ public class AnalyzeInputSourceAction extends T3Action<AnalyzeInputSourceConfigu
}
putResult(RESULT_SAFE_TRIPS, safeTrips);
putResult(RESULT_UNSAFE_TRIPS, unsafeTrips);
-
// while analyzing db, nothing to commit in db
return false;
} finally {
@@ -245,11 +241,9 @@ public class AnalyzeInputSourceAction extends T3Action<AnalyzeInputSourceConfigu
if (!withWell) {
// no well for this trip can remove all missing fk for wells
addWarningMessage(l(locale, "t3.import.warning.no.wellPlan", decorate(trip)));
-
// remove missing keys Sample->Well since there is no well
removeWellMissingForeignKeys(missingForeignKeys, false, SAMPLE_TO_WELL, missingFkToMessage);
-
- // remove missing keys WellPlan->Activity Ssince there is no well
+ // remove missing keys WellPlan->Activity since there is no well
removeWellMissingForeignKeys(missingForeignKeys, true, WELL_PLAN_TO_ACTIVITY, missingFkToMessage);
} else {
// there is some wells for this trip
@@ -282,6 +276,11 @@ public class AnalyzeInputSourceAction extends T3Action<AnalyzeInputSourceConfigu
addInfoMessage(l(locale, "t3.import.message.use.new.vessel.for.trip", decorate(vessel), decorate(trip)));
}
}
+ String tripTypeNotSafeMessage = inputPilot.getTripTypeNotSafeMessage(trip);
+ if (tripTypeNotSafeMessage != null) {
+ tripSafe = false;
+ addInfoMessage(l(locale, "t3.import.error.bad.tripType", decorate(trip), tripTypeNotSafeMessage));
+ }
//TODO Use this when Will have exact list of entities to exclude...
// check we are not using bad references
// tripSafe &= checkReferences(trip, entitiesUsed);
=====================================
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
@@ -30,7 +30,7 @@ Time step: ${configuration.timeStep}
Treatment to apply to catches with samples:
<#if configuration.useAllSamplesOfStratum>
-Apply length structures from the sample statrum
+Apply length structures from the sample stratum
<#else>
Keep their own samples (do nothing)
</#if>
=====================================
t3-actions/src/main/resources/i18n/t3-actions_en_GB.properties
=====================================
--- a/t3-actions/src/main/resources/i18n/t3-actions_en_GB.properties
+++ b/t3-actions/src/main/resources/i18n/t3-actions_en_GB.properties
@@ -3,6 +3,7 @@ t3.admin.deleteTrip=Delete trip %s
t3.admin.deleteTripDatas=Delete data of trip %s
t3.common.rf1.maximumRate.acceptable=Maximum acceptable rf1 rate
t3.common.rf1.minimumRate.acceptable=Minimum acceptable rf1 rate
+t3.import.error.bad.tripType=Trip type is not consistent\: %s
t3.import.error.badReferenceCode=Trip %s uses a reference of type %s with forbidden code %s
t3.import.error.missingForeignKey=It miss on trip %s foreign keys from %s %s to %s %s
t3.import.error.missingForeignKeyInT3=On trip %s, it miss in T3+ referentials, entity %s (natural key\: %s)
=====================================
t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties
=====================================
--- a/t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties
+++ b/t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties
@@ -3,6 +3,7 @@ t3.admin.deleteTrip=Suppresion de la marée %s
t3.admin.deleteTripDatas=Suppresion des données de la marée %s
t3.common.rf1.maximumRate.acceptable=Seuil maximum acceptable du rf1
t3.common.rf1.minimumRate.acceptable=Seuil minimum acceptable du rf1
+t3.import.error.bad.tripType=Le type de la marée %s n'est pas cohérent \: %s
t3.import.error.badReferenceCode=La marée %s utilise un référentiel de type %s avec le code %s
t3.import.error.missingForeignKey=Il manque sur la marée %s des clefs étrangères type %s %s vers %s %s
t3.import.error.missingForeignKeyInT3=Pour la marée %s, il manque dans le référentiel T3+ l'entité %s (clef métier\: %s)
=====================================
t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeRF1ActionResumeTest.java
=====================================
--- a/t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeRF1ActionResumeTest.java
+++ b/t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeRF1ActionResumeTest.java
@@ -63,19 +63,13 @@ public class ComputeRF1ActionResumeTest extends AbstractActionResumeTest<Compute
@Override
protected Map<String, Object> createTemplateParameters() {
-
Map<String, Object> parameters = super.createTemplateParameters();
-
Map<String, String> vesselSimpleTypes = new TreeMap<>();
- putInMap(vesselSimpleTypes,
- fixtures.vesselSimpleTypeCanneur(),
- fixtures.vesselSimpleTypeSenneur());
+ putInMap(vesselSimpleTypes, fixtures.vesselSimpleTypeCanneur(), fixtures.vesselSimpleTypeSenneur());
parameters.put("vesselSimpleTypes", vesselSimpleTypes);
-
Map<String, String> fleets = new TreeMap<>();
putInMap(fleets, fixtures.frenchCountry());
parameters.put("fleets", fleets);
-
return parameters;
}
=====================================
t3-domain/src/main/java/fr/ird/t3/entities/T3Predicates.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/entities/T3Predicates.java
+++ b/t3-domain/src/main/java/fr/ird/t3/entities/T3Predicates.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%
@@ -45,38 +45,6 @@ import java.util.function.Predicate;
*/
public class T3Predicates {
-// /**
-// * Predicates that trip has no data computed.
-// *
-// * @see Trip#isNoDataComputed()
-// * @since 1.1
-// */
-// public static final Predicate<Trip> TRIP_WITH_NO_DATA_COMPUTED = Trip::isNoDataComputed;
-//
-// /**
-// * Predicates that trip has some data computed.
-// *
-// * @see Trip#isSomeDataComputed()
-// * @since 1.1
-// */
-// public static final Predicate<Trip> TRIP_WITH_SOME_DATA_COMPUTED = Trip::isSomeDataComputed;
-//
-// /**
-// * Predicates that trip has all his data computed.
-// *
-// * @see Trip#isAllDataComputed() ()
-// * @since 1.1
-// */
-// public static final Predicate<Trip> TRIP_WITH_ALL_DATA_COMPUTED = Trip::isAllDataComputed;
-
- /**
- * Predicates that trip has a log book.
- *
- * @see Trip#getLogBookAvailability()
- * @since 1.1
- */
- public static final Predicate<Trip> TRIP_WITH_LOG_BOOK = input -> input.getLogBookAvailability() == 1;
-
/**
* Predicates that trip ends a complete trip.
*
@@ -85,21 +53,6 @@ public class T3Predicates {
*/
public static final Predicate<Trip> TRIP_ENDS_A_COMPLETE_TRIP = input -> input.getFishHoldEmpty() == 1;
-
-// /**
-// * Predicates that trip is inside a complete trip (as a simple trip or a
-// * partial complete trip).
-// * <p/>
-// * Notes that a such trip can be used in level 0, and 1.
-// *
-// * @see Trip#getCompletionStatus()
-// * @since 1.2
-// */
-// public static final Predicate<Trip> TRIP_INSIDE_A_COMPLETE_TRIP = input -> {
-// Integer completionStatus = input.getCompletionStatus();
-// return completionStatus != null && completionStatus > 0;
-// };
-
public static final Predicate<Activity> ACTIVITY_WITH_SET_SAMPLE = input -> !input.isSetSpeciesCatWeightEmpty();
public static final Predicate<LengthWeightConversion> LENGTH_WEIGHT_CONVERSION_BY_COEFFICIENT = input -> {
boolean result = true;
@@ -197,9 +150,7 @@ public class T3Predicates {
public static Predicate<Trip> tripUsingOcean(Collection<Ocean> oceans) {
return input -> {
boolean result = false;
-
- if (!input.isActivityEmpty()) {
-
+ if (input.isActivityNotEmpty()) {
Set<Ocean> allOceans = input.getAllOceans();
for (Ocean ocean : allOceans) {
if (oceans.contains(ocean)) {
@@ -273,4 +224,18 @@ public class T3Predicates {
// public static <E extends TopiaEntity> Predicate<E> equalsTopiaEntity(String id) {
// return input -> id.equals(input.getTopiaId());
// }
+
+// /**
+// * Predicates that trip is inside a complete trip (as a simple trip or a partial complete trip).
+// * <p/>
+// * Notes that a such trip can be used in level 0, and 1.
+// *
+// * @see Trip#getCompletionStatus()
+// * @since 1.2
+// */
+// public static final Predicate<Trip> TRIP_INSIDE_A_COMPLETE_TRIP = input -> {
+// Integer completionStatus = input.getCompletionStatus();
+// return completionStatus != null && completionStatus > 0;
+// };
+
}
=====================================
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
@@ -49,6 +49,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
@@ -69,12 +70,57 @@ import java.util.stream.StreamSupport;
public class AbstractTripTopiaDao<E extends Trip> extends GeneratedTripTopiaDao<E> {
public static final Ocean EMPTY_OCEAN = new OceanImpl();
+ private static final int TRIP_WITHOUT_LOGBOOK = 0;
+ private static final int TRIP_WITH_LOGBOOK = 1;
private static final Log log = LogFactory.getLog(AbstractTripTopiaDao.class);
static {
EMPTY_OCEAN.setTopiaId("fr.ird.t3.entities.reference.Ocean#EMPTY#EMPTY");
}
+ /**
+ * Check that a standard trip ({@link TripType#STANDARD}) is consistent with {@code logBookAvailability} flag.
+ *
+ * @param trip trip to check
+ * @param pKey primary key of this trip
+ */
+ public static void checkAndSetStandardTripType(Trip trip, Object[] pKey) {
+ int logBookAvailability = trip.getLogBookAvailability();
+ switch (logBookAvailability) {
+ case TRIP_WITHOUT_LOGBOOK:
+ if (trip.isActivityNotEmpty()) {
+ trip.setTripType(TripType.STANDARD);
+ throw new IllegalStateException(String.format("Trip [%s] has some logBook but logBookAvailability says the opposite, please fix this trip.", Arrays.toString(pKey)));
+ }
+ trip.setTripType(TripType.LOGBOOKMISSING);
+ break;
+ case TRIP_WITH_LOGBOOK:
+ if (trip.isActivityEmpty()) {
+ trip.setTripType(TripType.LOGBOOKMISSING);
+ throw new IllegalStateException(String.format("Trip [%s] has some logBook but logBookAvailability says the opposite, please fix this trip.", Arrays.toString(pKey)));
+ }
+ trip.setTripType(TripType.STANDARD);
+ break;
+ }
+ }
+
+ /**
+ * Check that a standard trip ({@link TripType#LOGBOOKMISSING}) is consistent with {@code logBookAvailability} flag.
+ *
+ * @param trip trip to check
+ * @param pKey primary key of this trip
+ */
+ public static void checkAndSetLogbookMissingTripType(Trip trip, Object[] pKey) {
+ int logBookAvailability = trip.getLogBookAvailability();
+ if (trip.getTripType() == TripType.LOGBOOKMISSING) {
+ if (TRIP_WITH_LOGBOOK == logBookAvailability) {
+ throw new IllegalStateException(String.format("Trip %s has no logBook but logBookAvailability says the opposite, please fix this trip.", Arrays.toString(pKey)));
+ }
+ } else {
+ checkAndSetStandardTripType(trip, pKey);
+ }
+ }
+
public static String getSamplesOnlyFilter(String prefix, Boolean samplesOnly) {
if (samplesOnly == null) {
return "";
@@ -138,7 +184,7 @@ public class AbstractTripTopiaDao<E extends Trip> extends GeneratedTripTopiaDao<
}
public static boolean isTripsAllWithLogBook(Iterable<Trip> trips) {
- return StreamSupport.stream(trips.spliterator(), false).allMatch(T3Predicates.TRIP_WITH_LOG_BOOK);
+ return StreamSupport.stream(trips.spliterator(), false).allMatch(Trip::isWithLogbook);
}
/**
=====================================
t3-domain/src/main/java/fr/ird/t3/entities/data/TripImpl.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/entities/data/TripImpl.java
+++ b/t3-domain/src/main/java/fr/ird/t3/entities/data/TripImpl.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%
@@ -63,8 +63,9 @@ public class TripImpl extends TripAbstract {
}
private transient Boolean level2Computed;
-
private transient Boolean level3Computed;
+ // only used for avdth import
+ private transient int logBookAvailability;
@Override
public boolean isSomeDataComputed() {
@@ -91,6 +92,12 @@ public class TripImpl extends TripAbstract {
return TripType.LOGBOOKMISSING == getTripType();
}
+ @Override
+ public boolean isWithLogbook() {
+ return TripType.STANDARD == getTripType();
+ }
+
+ @SuppressWarnings("WeakerAccess")
public boolean isLevel2Computed() {
if (level2Computed == null) {
level2Computed = false;
@@ -108,6 +115,7 @@ public class TripImpl extends TripAbstract {
return level2Computed;
}
+ @SuppressWarnings("WeakerAccess")
public boolean isLevel3Computed() {
if (level3Computed == null) {
level3Computed = false;
@@ -137,7 +145,19 @@ public class TripImpl extends TripAbstract {
return result;
}
-// /** @return the sum of all activities set duration in hours. */
+ // only used for avdth import
+ @Override
+ public int getLogBookAvailability() {
+ return logBookAvailability;
+ }
+
+ // only used for avdth import
+ @Override
+ public void setLogBookAvailability(int logbookAvaibility) {
+ this.logBookAvailability = logbookAvaibility;
+ }
+
+ // /** @return the sum of all activities set duration in hours. */
// @Override
// public float getTotalSetsDuration() {
// float result = 0;
=====================================
t3-domain/src/main/java/fr/ird/t3/io/input/T3Input.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/io/input/T3Input.java
+++ b/t3-domain/src/main/java/fr/ird/t3/io/input/T3Input.java
@@ -121,6 +121,8 @@ public interface T3Input {
*/
List<MissingForeignKey> getMissingForeignKeys(Trip trip);
+ String getTripTypeNotSafeMessage(Trip trip);
+
/**
* Method to clean input internal states.
* <p/>
=====================================
t3-domain/src/main/java/fr/ird/t3/io/input/access/AbstractT3InputMSAccess.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/io/input/access/AbstractT3InputMSAccess.java
+++ b/t3-domain/src/main/java/fr/ird/t3/io/input/access/AbstractT3InputMSAccess.java
@@ -25,6 +25,7 @@ import fr.ird.t3.entities.ReferenceEntityMap;
import fr.ird.t3.entities.T3EntityEnum;
import fr.ird.t3.entities.T3EntityMap;
import fr.ird.t3.entities.data.Trip;
+import fr.ird.t3.entities.data.TripTopiaDao;
import fr.ird.t3.entities.data.TripType;
import fr.ird.t3.entities.reference.Vessel;
import fr.ird.t3.io.input.MissingForeignKey;
@@ -39,9 +40,11 @@ import org.nuiton.topia.persistence.TopiaException;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -56,13 +59,14 @@ import java.util.stream.Collectors;
public abstract class AbstractT3InputMSAccess implements T3Input {
private static final Log log = LogFactory.getLog(AbstractT3InputMSAccess.class);
- protected T3AccessDataSource dataSource;
- protected T3InputConfiguration configuration;
- protected Map<Integer, Vessel> vessels;
+ private T3InputConfiguration configuration;
+ private Map<Integer, Vessel> vessels;
+ private T3AccessDataSource dataSource;
private ReferenceEntityMap safeReferences;
private Map<Trip, List<MissingForeignKey>> missingFK;
- private String[] errors;
- private String[] warnings;
+ private List<String> errors;
+ private List<String> warnings;
+ private Map<Trip, String> tripTypeNotSafeMessages;
public abstract T3AccessDataSource newDataSource(File inputFile);
@@ -91,27 +95,25 @@ public abstract class AbstractT3InputMSAccess implements T3Input {
T3AccessHitModel hitModel = new T3AccessHitModel();
hitModel.addPropertyChangeListener(new LoadDbPropertyChangeListener(t3DataTypes));
// analyse data source
- if (configuration.getTripType() == TripType.LOGBOOKMISSING) {
- dataSource.analyzeDb(TripType.LOGBOOKMISSING, hitModel);
- } else {
- dataSource.analyzeDb(hitModel);
- }
+ dataSource.analyzeDb(hitModel);
+ errors = new ArrayList<>();
if (dataSource.hasError()) {
- errors = dataSource.getErrors();
+ errors.addAll(Arrays.asList(dataSource.getErrors()));
}
+ warnings = new ArrayList<>();
if (dataSource.hasWarning()) {
- warnings = dataSource.getWarnings();
+ warnings.addAll(Arrays.asList(dataSource.getWarnings()));
}
}
@Override
public String[] getAnalyzeErrors() {
- return errors;
+ return errors.toArray(new String[errors.size()]);
}
@Override
public String[] getAnalyzeWarnings() {
- return warnings;
+ return warnings.toArray(new String[warnings.size()]);
}
@Override
@@ -168,7 +170,7 @@ public abstract class AbstractT3InputMSAccess implements T3Input {
T3EntityEnum constant = T3EntityEnum.valueOf(Trip.class);
T3AccessEntityMeta meta = dataSource.getMeta(constant);
List<Trip> entities = dataSource.loadEntities(meta);
- Map<Trip, T3EntityMap> result = Maps.newLinkedHashMap();
+ Map<Trip, T3EntityMap> result = new LinkedHashMap<>();
missingFK = new HashMap<>();
T3DataEntityVisitor dataVisitor = newDataVisitor(dataSource, safeReferences);
try {
@@ -233,6 +235,18 @@ public abstract class AbstractT3InputMSAccess implements T3Input {
return missingFK.get(trip);
}
+ @Override
+ public String getTripTypeNotSafeMessage(Trip trip) {
+ return tripTypeNotSafeMessages == null ? null : tripTypeNotSafeMessages.get(trip);
+ }
+
+ private void addTripTypeNotSafeMessage(Trip trip, String message) {
+ if (tripTypeNotSafeMessages == null) {
+ tripTypeNotSafeMessages = new LinkedHashMap<>();
+ }
+ tripTypeNotSafeMessages.put(trip, message);
+ }
+
private Trip loadTrip(int vesselCode, Trip trip, T3DataEntityVisitor dataVisitor, TripType tripType, boolean canCreateVessel) {
RemoveProxyEntityVisitor visitor = new RemoveProxyEntityVisitor();
try {
@@ -241,8 +255,29 @@ public abstract class AbstractT3InputMSAccess implements T3Input {
dataVisitor.doVisit(trip, true);
// remove proxy on data
Trip loadedTrip = visitor.doVisit(trip);
- // set tripType flag
- loadedTrip.setTripType(tripType);
+ T3AccessEntity a = (T3AccessEntity) trip;
+ Object[] pKey = a.getPKey();
+ switch (tripType) {
+ case STANDARD:
+ try {
+ TripTopiaDao.checkAndSetStandardTripType(loadedTrip, pKey);
+ } catch (Exception e) {
+ errors.add(e.getMessage());
+ }
+ break;
+ case SAMPLEONLY:
+ // no check
+ loadedTrip.setTripType(TripType.SAMPLEONLY);
+ break;
+ case LOGBOOKMISSING:
+ try {
+ TripTopiaDao.checkAndSetLogbookMissingTripType(loadedTrip, pKey);
+ } catch (Exception e) {
+ errors.add(e.getMessage());
+
+ }
+ break;
+ }
if (trip.getVessel() == null && canCreateVessel) {
// use new created vessel
Vessel vessel = getNewVessels().get(vesselCode);
=====================================
t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AccessDataSource.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AccessDataSource.java
+++ b/t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AccessDataSource.java
@@ -22,7 +22,6 @@ package fr.ird.t3.io.input.access;
import fr.ird.msaccess.importer.AbstractAccessDataSource;
import fr.ird.t3.entities.T3EntityEnum;
-import fr.ird.t3.entities.data.TripType;
import fr.ird.t3.entities.reference.T3ReferenceEntity;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -99,10 +98,6 @@ public class T3AccessDataSource extends AbstractAccessDataSource<T3EntityEnum, T
}
public void analyzeDb(T3AccessHitModel hits) throws Exception {
- analyzeDb(null, hits);
- }
-
- public void analyzeDb(TripType tripType, T3AccessHitModel hits) throws Exception {
// always init the data source
init();
Set<String> tables = getTableNames();
=====================================
t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AvdthDataEntityVisitor.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AvdthDataEntityVisitor.java
+++ b/t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AvdthDataEntityVisitor.java
@@ -78,6 +78,8 @@ public abstract class T3AvdthDataEntityVisitor extends T3DataEntityVisitor {
activity.setSchoolType(Objects.requireNonNull(sampleSet.getActivitySchoolType()));
sampleSet.setActivity(endActivity(activity));
parent.addActivity(activity);
+ // Force tripType, so later we will know that this trip has no logBook
+ parent.setTripType(TripType.LOGBOOKMISSING);
}
};
} else {
=====================================
t3-domain/src/main/resources/db/migration/V2_3_01_add-Trip-tripType.sql
=====================================
--- a/t3-domain/src/main/resources/db/migration/V2_3_01_add-Trip-tripType.sql
+++ b/t3-domain/src/main/resources/db/migration/V2_3_01_add-Trip-tripType.sql
@@ -20,5 +20,8 @@
---
ALTER TABLE Trip ADD COLUMN tripType VARCHAR(255) DEFAULT 'STANDARD' NOT NULL;
UPDATE Trip set tripType = 'SAMPLEONLY' WHERE samplesonly = TRUE;
+UPDATE Trip set tripType = 'STANDARD' WHERE logbookavailability = 1;
+UPDATE Trip set tripType = 'LOGBOOKMISSING' WHERE logbookavailability = 0;
CREATE INDEX idx_trip_tripType ON Trip(tripType);
+ALTER TABLE Trip DROP COLUMN logbookavailability;
ALTER TABLE Trip DROP COLUMN samplesonly;
\ No newline at end of file
=====================================
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/entities/reference/WeightCategoryTreatmentImplTest.java
=====================================
--- a/t3-domain/src/test/java/fr/ird/t3/entities/reference/WeightCategoryTreatmentImplTest.java
+++ b/t3-domain/src/test/java/fr/ird/t3/entities/reference/WeightCategoryTreatmentImplTest.java
@@ -20,7 +20,6 @@
*/
package fr.ird.t3.entities.reference;
-import com.google.common.collect.Maps;
import fr.ird.t3.entities.AbstractDatabaseTest;
import fr.ird.t3.entities.T3TopiaPersistenceContext;
import org.junit.Assert;
@@ -28,6 +27,7 @@ import org.junit.Test;
import java.util.ArrayList;
import java.util.Comparator;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -154,7 +154,7 @@ public class WeightCategoryTreatmentImplTest extends AbstractDatabaseTest {
catUnbound.setMax(null);
Map<WeightCategoryTreatment, Integer> weightCategories =
- Maps.newLinkedHashMap();
+ new LinkedHashMap<>();
weightCategories.put(catBound, 20);
weightCategories.put(catUnbound, Integer.MAX_VALUE);
@@ -208,7 +208,7 @@ public class WeightCategoryTreatmentImplTest extends AbstractDatabaseTest {
catUnbound.setMax(null);
Map<WeightCategoryTreatment, Integer> weightCategories =
- Maps.newLinkedHashMap();
+ new LinkedHashMap<>();
weightCategories.put(catBound, 20);
weightCategories.put(catBound2, 40);
=====================================
t3-input-avdthv33/src/main/java/fr/ird/t3/io/input/avdth/v33/T3InputAvdth33.java
=====================================
--- a/t3-input-avdthv33/src/main/java/fr/ird/t3/io/input/avdth/v33/T3InputAvdth33.java
+++ b/t3-input-avdthv33/src/main/java/fr/ird/t3/io/input/avdth/v33/T3InputAvdth33.java
@@ -82,7 +82,7 @@ public class T3InputAvdth33 extends AbstractT3InputMSAccess {
@Override
public T3DataEntityVisitor newDataVisitor(T3AccessDataSource dataSource, ReferenceEntityMap safeReferences) {
- return new T3DataEntityVisitorAvdth33(dataSource, safeReferences, configuration);
+ return new T3DataEntityVisitorAvdth33(dataSource, safeReferences, getConfiguration());
}
@Override
=====================================
t3-input-avdthv36/src/main/java/fr/ird/t3/io/input/avdth/v36/T3InputAvdth36.java
=====================================
--- a/t3-input-avdthv36/src/main/java/fr/ird/t3/io/input/avdth/v36/T3InputAvdth36.java
+++ b/t3-input-avdthv36/src/main/java/fr/ird/t3/io/input/avdth/v36/T3InputAvdth36.java
@@ -96,7 +96,7 @@ public class T3InputAvdth36 extends AbstractT3InputMSAccess {
@Override
public T3DataEntityVisitor newDataVisitor(T3AccessDataSource dataSource, ReferenceEntityMap safeReferences) {
- return new T3DataEntityVisitorAvdth36(dataSource, safeReferences, configuration);
+ return new T3DataEntityVisitorAvdth36(dataSource, safeReferences, getConfiguration());
}
@Override
=====================================
t3-output-balbayav32/src/main/java/fr/ird/t3/io/output/balbaya/v32/BalbayaOperationExecutionTripImpl.java
=====================================
--- a/t3-output-balbayav32/src/main/java/fr/ird/t3/io/output/balbaya/v32/BalbayaOperationExecutionTripImpl.java
+++ b/t3-output-balbayav32/src/main/java/fr/ird/t3/io/output/balbaya/v32/BalbayaOperationExecutionTripImpl.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%
@@ -39,182 +39,153 @@ import static org.nuiton.i18n.I18n.l;
*/
public class BalbayaOperationExecutionTripImpl extends AbstractBalbayaOperationExecution {
- public BalbayaOperationExecutionTripImpl(Connection connection) {
+ private static final String CHECK_TRIP = "SELECT count(*) FROM maree where c_bat = %1$s AND d_dbq = '%2$s'::date;";
+ /**
+ * To insert a new line into maree table (from Trip entity).
+ * <p/>
+ * c_bat | numeric(4,0) | not null
+ * d_dbq | date | not null
+ * d_depart | date |
+ * c_port_dep | numeric(3,0) | not null
+ * c_port_dbq | numeric(3,0) | not null
+ * c_zone_geo | numeric(4,0) |
+ * v_temps_m | numeric(4,0) | not null
+ * v_temps_p | numeric(4,0) | not null
+ * v_poids_dbq | numeric(7,3) | not null
+ * v_poids_fp | numeric(6,3) | not null
+ * f_enq | numeric(1,0) | not null
+ * f_cal_vid | numeric(1,0) | not null
+ * v_loch | numeric(5,0) |
+ * id_jeu_d | numeric(4,0) | not null
+ * c_pays_d | numeric(3,0) | not null
+ */
+ private static final String INSERT_MAREE = "INSERT INTO maree (" +
+ "c_bat," +
+ "d_dbq," +
+ "d_depart," +
+ "c_port_dep, " +
+ "c_port_dbq," +
+ "v_temps_m," +
+ "v_temps_p," +
+ "v_poids_dbq," +
+ "v_poids_fp," +
+ "f_enq," +
+ "f_cal_vid," +
+ "v_loch," +
+ "id_jeu_d," +
+ "c_pays_d" +
+ ") VALUES (" +
+ "%1$s," +
+ "'%2$s'::date," +
+ "'%3$s'::date," +
+ "%4$s," +
+ "%5$s," +
+ "%6$s," +
+ "%7$s," +
+ "%8$s," +
+ "%9$s," +
+ "%10$s," +
+ "%11$s," +
+ "%12$s," +
+ "%13$s," +
+ "%14$s" +
+ ");";
+ /**
+ * To insert a new line into lot_com table (from ElementaryLanding entity).
+ * <p/>
+ * c_bat | numeric(4,0) | not null
+ * d_dbq | date | not null
+ * n_lot | numeric(4,0) | not null
+ * c_esp | numeric(3,0) | not null
+ * c_cat_c | numeric(2,0) | not null
+ * v_poids_lc | numeric(7,3) | not null
+ */
+ private static final String INSERT_LOT_COM = "INSERT INTO lot_com (" +
+ "c_bat, " +
+ "d_dbq," +
+ "n_lot, " +
+ "c_esp," +
+ "c_cat_c," +
+ "v_poids_lc" +
+ ") VALUES(" +
+ "%1$s," +
+ "'%2$s'::date," +
+ "%3$s," +
+ "%4$s," +
+ "%5$s," +
+ "%6$s" +
+ ");";
+ private int nbTrips;
+ private int nbElementaryLandings;
+
+ BalbayaOperationExecutionTripImpl(Connection connection) {
super(connection, T3OutputOperationBalbayaImpl.TRIP_AND_LANDING);
}
@Override
protected boolean checkDatas(T3OutputBalbayaImpl output, List<Trip> trips) throws SQLException {
-
// check pKeys before all
for (Trip trip : trips) {
-
int tripVesselCode = trip.getVessel().getCode();
Date tripLandingDate = trip.getLandingDate();
-
- boolean exists =
- checkPKey(CHECK_TRIP, tripVesselCode, tripLandingDate);
-
+ boolean exists = checkPKey(CHECK_TRIP, tripVesselCode, tripLandingDate);
if (exists) {
-
// this trip already exists, can not import it, stop operation
Locale locale = output.getLocale();
output.getMessager().addErrorMessage(
- l(locale, "t3.output.balbaya.error.trip.already.exists",
- tripVesselCode, tripLandingDate)
- );
+ l(locale, "t3.output.balbaya.error.trip.already.exists", tripVesselCode, tripLandingDate));
return false;
}
}
return true;
}
- protected int nbTrips;
-
- protected int nbElementaryLandings;
-
@Override
- protected String getSuccessSummary(T3OutputBalbayaImpl output,
- T3OutputBalbayaImpl.TreatmentId id) {
+ protected String getSuccessSummary(T3OutputBalbayaImpl output, T3OutputBalbayaImpl.TreatmentId id) {
Locale locale = output.getLocale();
- return l(locale, "t3.output.balbabya.operation.tripAndLanding.success",
- id.getNumber(), nbTrips, nbElementaryLandings);
+ return l(locale, "t3.output.balbabya.operation.tripAndLanding.success", id.getNumber(), nbTrips, nbElementaryLandings);
}
@Override
- protected void buildRequests(T3OutputBalbayaImpl output,
- T3OutputBalbayaImpl.TreatmentId id,
- List<Trip> trips) {
-
+ protected void buildRequests(T3OutputBalbayaImpl output, T3OutputBalbayaImpl.TreatmentId id, List<Trip> trips) {
nbTrips = nbElementaryLandings = 0;
-
int countryCode = id.getCountryCode();
int treatmentNumber = id.getNumber();
-
for (Trip trip : trips) {
-
int tripVesselCode = trip.getVessel().getCode();
Date tripLandingDate = trip.getLandingDate();
-
// add trip
-
nbTrips++;
addRequest(INSERT_MAREE,
- requests,
- tripVesselCode,
- tripLandingDate,
- trip.getDepartureDate(),
- trip.getDepartureHarbour().getCode(),
- trip.getLandingHarbour().getCode(),
- trip.getTimeAtSea(),
- trip.getFishingTime(),
- trip.getLandingTotalWeight(),
- trip.getFalseFishesWeight(),
- trip.getLogBookAvailability(),
- trip.getFishHoldEmpty(),
- trip.getLoch(),
- treatmentNumber,
- countryCode
- );
+ requests,
+ tripVesselCode,
+ tripLandingDate,
+ trip.getDepartureDate(),
+ trip.getDepartureHarbour().getCode(),
+ trip.getLandingHarbour().getCode(),
+ trip.getTimeAtSea(),
+ trip.getFishingTime(),
+ trip.getLandingTotalWeight(),
+ trip.getFalseFishesWeight(),
+ trip.isWithLogbook() ? 1 : 0,
+ trip.getFishHoldEmpty(),
+ trip.getLoch(),
+ treatmentNumber,
+ countryCode);
if (!trip.isElementaryLandingEmpty()) {
-
// add elementary landing
for (ElementaryLanding elementaryLanding : trip.getElementaryLanding()) {
-
nbElementaryLandings++;
-
addRequest(INSERT_LOT_COM,
- requests,
- tripVesselCode,
- tripLandingDate,
- elementaryLanding.getNumber(),
- elementaryLanding.getWeightCategoryLanding().getSpecies().getCode(),
- elementaryLanding.getWeightCategoryLanding().getCode(),
- elementaryLanding.getWeight()
- );
+ requests,
+ tripVesselCode,
+ tripLandingDate,
+ elementaryLanding.getNumber(),
+ elementaryLanding.getWeightCategoryLanding().getSpecies().getCode(),
+ elementaryLanding.getWeightCategoryLanding().getCode(),
+ elementaryLanding.getWeight());
}
}
}
}
-
- public static final String CHECK_TRIP = "SELECT count(*) FROM maree where " +
- "c_bat = %1$s AND d_dbq = '%2$s'::date;";
-
- /**
- * To insert a new line into maree table (from Trip entity).
- * <p/>
- * c_bat | numeric(4,0) | not null
- * d_dbq | date | not null
- * d_depart | date |
- * c_port_dep | numeric(3,0) | not null
- * c_port_dbq | numeric(3,0) | not null
- * c_zone_geo | numeric(4,0) |
- * v_temps_m | numeric(4,0) | not null
- * v_temps_p | numeric(4,0) | not null
- * v_poids_dbq | numeric(7,3) | not null
- * v_poids_fp | numeric(6,3) | not null
- * f_enq | numeric(1,0) | not null
- * f_cal_vid | numeric(1,0) | not null
- * v_loch | numeric(5,0) |
- * id_jeu_d | numeric(4,0) | not null
- * c_pays_d | numeric(3,0) | not null
- */
- public static final String INSERT_MAREE = "INSERT INTO maree (" +
- "c_bat," +
- "d_dbq," +
- "d_depart," +
- "c_port_dep, " +
- "c_port_dbq," +
- "v_temps_m," +
- "v_temps_p," +
- "v_poids_dbq," +
- "v_poids_fp," +
- "f_enq," +
- "f_cal_vid," +
- "v_loch," +
- "id_jeu_d," +
- "c_pays_d" +
- ") VALUES (" +
- "%1$s," +
- "'%2$s'::date," +
- "'%3$s'::date," +
- "%4$s," +
- "%5$s," +
- "%6$s," +
- "%7$s," +
- "%8$s," +
- "%9$s," +
- "%10$s," +
- "%11$s," +
- "%12$s," +
- "%13$s," +
- "%14$s" +
- ");";
-
-
- /**
- * To insert a new line into lot_com table (from ElementaryLanding entity).
- * <p/>
- * c_bat | numeric(4,0) | not null
- * d_dbq | date | not null
- * n_lot | numeric(4,0) | not null
- * c_esp | numeric(3,0) | not null
- * c_cat_c | numeric(2,0) | not null
- * v_poids_lc | numeric(7,3) | not null
- */
- public static final String INSERT_LOT_COM = "INSERT INTO lot_com (" +
- "c_bat, " +
- "d_dbq," +
- "n_lot, " +
- "c_esp," +
- "c_cat_c," +
- "v_poids_lc" +
- ") VALUES(" +
- "%1$s," +
- "'%2$s'::date," +
- "%3$s," +
- "%4$s," +
- "%5$s," +
- "%6$s" +
- ");";
}
=====================================
t3-web/src/main/java/fr/ird/t3/web/T3StaticContentLoader.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/T3StaticContentLoader.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/T3StaticContentLoader.java
@@ -10,12 +10,12 @@ package fr.ird.t3.web;
* 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%
@@ -35,9 +35,10 @@ import java.io.OutputStream;
import java.util.Calendar;
/**
+ * FIXME See if we still need this ?
* To fix some javascript loading problem.
* <p/>
- * Some javascript files have some strange first caracter (ckeditor for example) +
+ * Some javascript files have some strange first character (ckeditor for example) +
* problem while loading charsets for french translate files.
*
* @author Tony Chemit - dev(a)tchemit.fr
@@ -45,25 +46,18 @@ import java.util.Calendar;
*/
public class T3StaticContentLoader extends DefaultStaticContentLoader {
- /** Logger. */
- private final Logger log =
- LoggerFactory.getLogger(T3StaticContentLoader.class);
+ private final Logger log = LoggerFactory.getLogger(T3StaticContentLoader.class);
@Override
- protected void process(InputStream is,
- String path,
- HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ protected void process(InputStream is, String path, HttpServletRequest request, HttpServletResponse response) throws IOException {
if (is != null) {
Calendar cal = Calendar.getInstance();
-
// check for if-modified-since, prior to any other headers
long ifModifiedSince = 0;
try {
ifModifiedSince = request.getDateHeader("If-Modified-Since");
} catch (Exception e) {
- log.warn("Invalid If-Modified-Since header value: '"
- + request.getHeader("If-Modified-Since") + "', ignoring");
+ log.warn(String.format("Invalid If-Modified-Since header value: '%s', ignoring", request.getHeader("If-Modified-Since")));
}
long lastModifiedMillis = lastModifiedCal.getTimeInMillis();
long now = cal.getTimeInMillis();
@@ -97,34 +91,29 @@ public class T3StaticContentLoader extends DefaultStaticContentLoader {
response.setHeader("Pragma", "no-cache");
response.setHeader("Expires", "-1");
}
-
try {
copy(is, response.getOutputStream(), path);
-
} finally {
is.close();
}
}
}
- protected void copy(InputStream input,
- OutputStream output,
- String path) throws IOException {
+ protected void copy(InputStream input, OutputStream output, String path) throws IOException {
if (path.contains(".js")) {
- String content = IOUtils.toString(input);
+ String content = IOUtils.toString(input, Charsets.UTF_8);
if (content.indexOf("/") == 1) {
- // fix nasty first strange caracter for ckeditor (only on firefox :()
+ // fix nasty first strange character for ckeditor (only on firefox :()
content = content.substring(1);
}
- if (log.isDebugEnabled()) {
- log.debug("Content:\n" + content);
- }
+ log.debug("Content:\n" + content);
// always want to have file in IS0 (even if we serve UTF8 files)
+ //FIXME Why should we serve ISO ?
IOUtils.write(content, output, Charsets.ISO_8859_1);
} else {
- // no special tratment for other files
+ // no special treatment for other files
IOUtils.copy(input, output);
}
}
=====================================
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
@@ -21,7 +21,6 @@
package fr.ird.t3.web.actions;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
@@ -63,6 +62,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
@@ -261,7 +261,7 @@ public class T3ActionSupport extends ActionSupport implements T3TopiaPersistence
}
protected Map<String, String> createTimeSteps() {
- Map<String, String> timeSteps = Maps.newLinkedHashMap();
+ Map<String, String> timeSteps = new LinkedHashMap<>();
for (int i = 1; i < 13; i++) {
timeSteps.put("" + i, "" + i);
}
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/io/output/ExportConfigureAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/io/output/ExportConfigureAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/io/output/ExportConfigureAction.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.web.actions.io.output;
-import com.google.common.collect.Maps;
import fr.ird.t3.actions.io.output.ExportConfiguration;
import fr.ird.t3.entities.T3EntityHelper;
import fr.ird.t3.entities.data.Trip;
@@ -49,6 +48,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -116,14 +116,13 @@ public class ExportConfigureAction extends AbstractConfigureAction<ExportConfigu
// make sur configuration is inited before all
getConfiguration();
- operations = Maps.newLinkedHashMap();
+ operations = new LinkedHashMap<>();
- for (T3OutputOperation operation :
- getT3OutputService().getOperations(configuration.getOutputProviderId())) {
+ for (T3OutputOperation operation : getT3OutputService().getOperations(configuration.getOutputProviderId())) {
operations.put(operation.getId(), operation.getLibelle(getLocale()));
}
- // inject everything needed (daos, ...)
+ // inject everything needed (dao, ...)
injectExcept(InjectDecoratedBeans.class);
boolean configurationInSession = isConfigurationInSession();
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/json/GetOutputProviderOperationsAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/json/GetOutputProviderOperationsAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/json/GetOutputProviderOperationsAction.java
@@ -8,24 +8,24 @@
* 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.web.actions.json;
-import com.google.common.collect.Maps;
import fr.ird.t3.io.output.T3OutputOperation;
import fr.ird.t3.web.actions.T3ActionSupport;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import java.util.LinkedHashMap;
import java.util.Map;
@@ -39,13 +39,10 @@ public class GetOutputProviderOperationsAction extends T3ActionSupport {
private static final long serialVersionUID = 1L;
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(GetOutputProviderOperationsAction.class);
+ private static final Log log = LogFactory.getLog(GetOutputProviderOperationsAction.class);
- protected String outputProviderId;
-
- protected Map<String, String> operations;
+ private String outputProviderId;
+ private Map<String, String> operations;
public void setOutputProviderId(String outputProviderId) {
this.outputProviderId = outputProviderId;
@@ -57,18 +54,11 @@ public class GetOutputProviderOperationsAction extends T3ActionSupport {
@Override
public String execute() {
-
- if (log.isInfoEnabled()) {
- log.info("outputProviderId = " + outputProviderId);
- }
-
- operations = Maps.newLinkedHashMap();
-
- for (T3OutputOperation operation :
- getT3OutputService().getOperations(outputProviderId)) {
+ log.info(String.format("outputProviderId = %s", outputProviderId));
+ operations = new LinkedHashMap<>();
+ for (T3OutputOperation operation : getT3OutputService().getOperations(outputProviderId)) {
operations.put(operation.getId(), operation.getLibelle(getLocale()));
}
-
return SUCCESS;
}
}
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/json/GetZoneVersionsAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/json/GetZoneVersionsAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/json/GetZoneVersionsAction.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.web.actions.json;
-import com.google.common.collect.Maps;
import fr.ird.t3.entities.reference.zone.ZoneStratumAwareMeta;
import fr.ird.t3.entities.reference.zone.ZoneVersion;
import fr.ird.t3.web.actions.T3ActionSupport;
@@ -28,6 +27,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -41,14 +41,11 @@ public class GetZoneVersionsAction extends T3ActionSupport {
private static final long serialVersionUID = 1L;
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(GetZoneVersionsAction.class);
+ private static final Log log = LogFactory.getLog(GetZoneVersionsAction.class);
/** Selected zoneTypeId. */
- protected String zoneTypeId;
-
- protected Map<String, String> zoneVersions;
+ private String zoneTypeId;
+ private Map<String, String> zoneVersions;
public void setZoneTypeId(String zoneTypeId) {
this.zoneTypeId = zoneTypeId;
@@ -60,23 +57,12 @@ public class GetZoneVersionsAction extends T3ActionSupport {
@Override
public String execute() {
-
- if (log.isInfoEnabled()) {
- log.info("zoneTypeId = " + zoneTypeId);
- }
-
- zoneVersions = Maps.newLinkedHashMap();
-
+ log.info(String.format("zoneTypeId = %s", zoneTypeId));
+ zoneVersions = new LinkedHashMap<>();
if (!StringUtils.isEmpty(zoneTypeId)) {
-
- ZoneStratumAwareMeta zoneType =
- getZoneStratumService().getZoneMetaById(zoneTypeId);
-
- List<ZoneVersion> allVersions =
- zoneType.getAllZoneVersions(getT3TopiaPersistenceContext().get());
-
+ ZoneStratumAwareMeta zoneType = getZoneStratumService().getZoneMetaById(zoneTypeId);
+ List<ZoneVersion> allVersions = zoneType.getAllZoneVersions(getT3TopiaPersistenceContext().get());
zoneVersions = sortAndDecorateIdAbles(allVersions);
-
}
return SUCCESS;
}
=====================================
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
@@ -267,7 +267,7 @@ t3.label.data.level3.configuration.samplesToUse=Treatment to apply to catches wi
t3.label.data.level3.configuration.step1=Level 3 configuration step 1
t3.label.data.level3.configuration.step2=Level 3 configuration step 2
t3.label.data.level3.configuration.useAllSamples=Keep their own sample (do nothing)
-t3.label.data.level3.configuration.useCatchSamples=Apply length structures from the sample statrum
+t3.label.data.level3.configuration.useCatchSamples=Apply length structures from the sample stratum
t3.label.data.level3.configuration.useWeightCategories=Use weight categories
t3.label.data.level3.configuration.useWeightCategoriesOrNot=Extrapolation method
t3.label.data.treatment.level0=Level 0 treatment
=====================================
t3-web/src/main/webapp/WEB-INF/jsp/admin/tripDetail.jsp
=====================================
--- a/t3-web/src/main/webapp/WEB-INF/jsp/admin/tripDetail.jsp
+++ b/t3-web/src/main/webapp/WEB-INF/jsp/admin/tripDetail.jsp
@@ -72,9 +72,7 @@
<s:label value='%{loch}'
label="%{getText('t3.common.loch')}"/>
- <s:label value='%{getBoolean(logBookAvailability)}'
- label="%{getText('t3.common.logBookAvailability')}"/>
- <s:label value='%{getText(tripType)}'
+ <s:label value='%{tripType.label}'
label="%{getText('t3.common.tripType')}"/>
<s:label value='%{getBoolean(fishHoldEmpty)}'
label="%{getText('t3.common.fishHoldEmpty')}"/>
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/7b035f837397ea3df73975985a2af305…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/7b035f837397ea3df73975985a2af305…
You're receiving this email because of your account on gitlab.com.
1
0
[Git][ultreiaio/ird-t3][develop] Marées sans logbooks : gestion de leurs échantillons - ajout de check de…
by Tony CHEMIT 08 Mar '18
by Tony CHEMIT 08 Mar '18
08 Mar '18
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
70318fcc by Tony CHEMIT at 2018-03-08T12:55:59Z
Marées sans logbooks : gestion de leurs échantillons - ajout de check de cohérence sur Trip.logbookAvaibility (See #116) + fix typo
- - - - -
11 changed files:
- t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level3/Level3Action_en.ftl
- t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractTripTopiaDao.java
- t3-domain/src/main/java/fr/ird/t3/io/input/access/AbstractT3InputMSAccess.java
- t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AccessDataSource.java
- t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AvdthDataEntityVisitor.java
- t3-domain/src/test/java/fr/ird/t3/entities/reference/WeightCategoryTreatmentImplTest.java
- t3-web/src/main/java/fr/ird/t3/web/actions/T3ActionSupport.java
- t3-web/src/main/java/fr/ird/t3/web/actions/io/output/ExportConfigureAction.java
- t3-web/src/main/java/fr/ird/t3/web/actions/json/GetOutputProviderOperationsAction.java
- t3-web/src/main/java/fr/ird/t3/web/actions/json/GetZoneVersionsAction.java
- t3-web/src/main/resources/i18n/t3-web_en_GB.properties
Changes:
=====================================
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
@@ -30,7 +30,7 @@ Time step: ${configuration.timeStep}
Treatment to apply to catches with samples:
<#if configuration.useAllSamplesOfStratum>
-Apply length structures from the sample statrum
+Apply length structures from the sample stratum
<#else>
Keep their own samples (do nothing)
</#if>
=====================================
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
@@ -49,6 +49,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
@@ -69,12 +70,43 @@ import java.util.stream.StreamSupport;
public class AbstractTripTopiaDao<E extends Trip> extends GeneratedTripTopiaDao<E> {
public static final Ocean EMPTY_OCEAN = new OceanImpl();
+ private static final int TRIP_WITHOUT_LOGBOOK = 0;
+ private static final int TRIP_WITH_LOGBOOK = 1;
private static final Log log = LogFactory.getLog(AbstractTripTopiaDao.class);
static {
EMPTY_OCEAN.setTopiaId("fr.ird.t3.entities.reference.Ocean#EMPTY#EMPTY");
}
+ /**
+ * Check that a standard trip ({@link TripType#STANDARD}) is consistent around {@link Trip#getLogBookAvailability()}.
+ *
+ * @param trip trip to check
+ * @param pKey primary key of this trip
+ */
+ public static void checkStandardTrip(Trip trip, Object[] pKey) {
+ int logBookAvailability = trip.getLogBookAvailability();
+ if (AbstractTripTopiaDao.TRIP_WITHOUT_LOGBOOK == logBookAvailability && trip.isActivityNotEmpty()) {
+ throw new IllegalStateException(String.format("Trip [%s] has some logBook but logBookAvailability says the opposite, please fix this trip..", Arrays.toString(pKey)));
+ }
+ if (AbstractTripTopiaDao.TRIP_WITH_LOGBOOK == logBookAvailability && trip.isActivityEmpty()) {
+ throw new IllegalStateException(String.format("Trip [%s] has some logBook but logBookAvailability says the opposite, please fix this trip..", Arrays.toString(pKey)));
+ }
+ }
+
+ /**
+ * Check that a standard trip ({@link TripType#LOGBOOKMISSING}) is consistent around {@link Trip#getLogBookAvailability()}.
+ *
+ * @param trip trip to check
+ * @param pKey primary key of this trip
+ */
+ public static void checkLogbookMissingTrip(Trip trip, Object[] pKey) {
+ int logBookAvailability = trip.getLogBookAvailability();
+ if (AbstractTripTopiaDao.TRIP_WITH_LOGBOOK == logBookAvailability) {
+ throw new IllegalStateException(String.format("Trip [%s] has no logBook but logBookAvailability says the opposite, please fix this trip.", Arrays.toString(pKey)));
+ }
+ }
+
public static String getSamplesOnlyFilter(String prefix, Boolean samplesOnly) {
if (samplesOnly == null) {
return "";
=====================================
t3-domain/src/main/java/fr/ird/t3/io/input/access/AbstractT3InputMSAccess.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/io/input/access/AbstractT3InputMSAccess.java
+++ b/t3-domain/src/main/java/fr/ird/t3/io/input/access/AbstractT3InputMSAccess.java
@@ -25,6 +25,7 @@ import fr.ird.t3.entities.ReferenceEntityMap;
import fr.ird.t3.entities.T3EntityEnum;
import fr.ird.t3.entities.T3EntityMap;
import fr.ird.t3.entities.data.Trip;
+import fr.ird.t3.entities.data.TripTopiaDao;
import fr.ird.t3.entities.data.TripType;
import fr.ird.t3.entities.reference.Vessel;
import fr.ird.t3.io.input.MissingForeignKey;
@@ -42,6 +43,7 @@ import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -91,11 +93,7 @@ public abstract class AbstractT3InputMSAccess implements T3Input {
T3AccessHitModel hitModel = new T3AccessHitModel();
hitModel.addPropertyChangeListener(new LoadDbPropertyChangeListener(t3DataTypes));
// analyse data source
- if (configuration.getTripType() == TripType.LOGBOOKMISSING) {
- dataSource.analyzeDb(TripType.LOGBOOKMISSING, hitModel);
- } else {
- dataSource.analyzeDb(hitModel);
- }
+ dataSource.analyzeDb(hitModel);
if (dataSource.hasError()) {
errors = dataSource.getErrors();
}
@@ -168,7 +166,7 @@ public abstract class AbstractT3InputMSAccess implements T3Input {
T3EntityEnum constant = T3EntityEnum.valueOf(Trip.class);
T3AccessEntityMeta meta = dataSource.getMeta(constant);
List<Trip> entities = dataSource.loadEntities(meta);
- Map<Trip, T3EntityMap> result = Maps.newLinkedHashMap();
+ Map<Trip, T3EntityMap> result = new LinkedHashMap<>();
missingFK = new HashMap<>();
T3DataEntityVisitor dataVisitor = newDataVisitor(dataSource, safeReferences);
try {
@@ -242,7 +240,29 @@ public abstract class AbstractT3InputMSAccess implements T3Input {
// remove proxy on data
Trip loadedTrip = visitor.doVisit(trip);
// set tripType flag
- loadedTrip.setTripType(tripType);
+ T3AccessEntity a = (T3AccessEntity) trip;
+ int logBookAvailability = loadedTrip.getLogBookAvailability();
+ Object[] pKey = a.getPKey();
+ switch (tripType) {
+ case STANDARD:
+ TripTopiaDao.checkStandardTrip(loadedTrip, pKey);
+ loadedTrip.setTripType(TripType.STANDARD);
+ break;
+ case SAMPLEONLY:
+ // no check
+ loadedTrip.setTripType(TripType.SAMPLEONLY);
+ break;
+ case LOGBOOKMISSING:
+ if (TripType.LOGBOOKMISSING == loadedTrip.getTripType()) {
+ // That trip was marked to be without logbook, check that
+ TripTopiaDao.checkLogbookMissingTrip(loadedTrip, pKey);
+ } else {
+ // standard trip, just check logBookAvailability value is correct
+ TripTopiaDao.checkStandardTrip(loadedTrip, pKey);
+ loadedTrip.setTripType(TripType.STANDARD);
+ }
+ break;
+ }
if (trip.getVessel() == null && canCreateVessel) {
// use new created vessel
Vessel vessel = getNewVessels().get(vesselCode);
=====================================
t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AccessDataSource.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AccessDataSource.java
+++ b/t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AccessDataSource.java
@@ -22,7 +22,6 @@ package fr.ird.t3.io.input.access;
import fr.ird.msaccess.importer.AbstractAccessDataSource;
import fr.ird.t3.entities.T3EntityEnum;
-import fr.ird.t3.entities.data.TripType;
import fr.ird.t3.entities.reference.T3ReferenceEntity;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -99,10 +98,6 @@ public class T3AccessDataSource extends AbstractAccessDataSource<T3EntityEnum, T
}
public void analyzeDb(T3AccessHitModel hits) throws Exception {
- analyzeDb(null, hits);
- }
-
- public void analyzeDb(TripType tripType, T3AccessHitModel hits) throws Exception {
// always init the data source
init();
Set<String> tables = getTableNames();
=====================================
t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AvdthDataEntityVisitor.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AvdthDataEntityVisitor.java
+++ b/t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AvdthDataEntityVisitor.java
@@ -78,6 +78,7 @@ public abstract class T3AvdthDataEntityVisitor extends T3DataEntityVisitor {
activity.setSchoolType(Objects.requireNonNull(sampleSet.getActivitySchoolType()));
sampleSet.setActivity(endActivity(activity));
parent.addActivity(activity);
+ parent.setTripType(TripType.LOGBOOKMISSING);
}
};
} else {
=====================================
t3-domain/src/test/java/fr/ird/t3/entities/reference/WeightCategoryTreatmentImplTest.java
=====================================
--- a/t3-domain/src/test/java/fr/ird/t3/entities/reference/WeightCategoryTreatmentImplTest.java
+++ b/t3-domain/src/test/java/fr/ird/t3/entities/reference/WeightCategoryTreatmentImplTest.java
@@ -20,7 +20,6 @@
*/
package fr.ird.t3.entities.reference;
-import com.google.common.collect.Maps;
import fr.ird.t3.entities.AbstractDatabaseTest;
import fr.ird.t3.entities.T3TopiaPersistenceContext;
import org.junit.Assert;
@@ -28,6 +27,7 @@ import org.junit.Test;
import java.util.ArrayList;
import java.util.Comparator;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -154,7 +154,7 @@ public class WeightCategoryTreatmentImplTest extends AbstractDatabaseTest {
catUnbound.setMax(null);
Map<WeightCategoryTreatment, Integer> weightCategories =
- Maps.newLinkedHashMap();
+ new LinkedHashMap<>();
weightCategories.put(catBound, 20);
weightCategories.put(catUnbound, Integer.MAX_VALUE);
@@ -208,7 +208,7 @@ public class WeightCategoryTreatmentImplTest extends AbstractDatabaseTest {
catUnbound.setMax(null);
Map<WeightCategoryTreatment, Integer> weightCategories =
- Maps.newLinkedHashMap();
+ new LinkedHashMap<>();
weightCategories.put(catBound, 20);
weightCategories.put(catBound2, 40);
=====================================
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
@@ -21,7 +21,6 @@
package fr.ird.t3.web.actions;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
@@ -63,6 +62,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
@@ -261,7 +261,7 @@ public class T3ActionSupport extends ActionSupport implements T3TopiaPersistence
}
protected Map<String, String> createTimeSteps() {
- Map<String, String> timeSteps = Maps.newLinkedHashMap();
+ Map<String, String> timeSteps = new LinkedHashMap<>();
for (int i = 1; i < 13; i++) {
timeSteps.put("" + i, "" + i);
}
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/io/output/ExportConfigureAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/io/output/ExportConfigureAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/io/output/ExportConfigureAction.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.web.actions.io.output;
-import com.google.common.collect.Maps;
import fr.ird.t3.actions.io.output.ExportConfiguration;
import fr.ird.t3.entities.T3EntityHelper;
import fr.ird.t3.entities.data.Trip;
@@ -49,6 +48,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -116,14 +116,13 @@ public class ExportConfigureAction extends AbstractConfigureAction<ExportConfigu
// make sur configuration is inited before all
getConfiguration();
- operations = Maps.newLinkedHashMap();
+ operations = new LinkedHashMap<>();
- for (T3OutputOperation operation :
- getT3OutputService().getOperations(configuration.getOutputProviderId())) {
+ for (T3OutputOperation operation : getT3OutputService().getOperations(configuration.getOutputProviderId())) {
operations.put(operation.getId(), operation.getLibelle(getLocale()));
}
- // inject everything needed (daos, ...)
+ // inject everything needed (dao, ...)
injectExcept(InjectDecoratedBeans.class);
boolean configurationInSession = isConfigurationInSession();
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/json/GetOutputProviderOperationsAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/json/GetOutputProviderOperationsAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/json/GetOutputProviderOperationsAction.java
@@ -8,24 +8,24 @@
* 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.web.actions.json;
-import com.google.common.collect.Maps;
import fr.ird.t3.io.output.T3OutputOperation;
import fr.ird.t3.web.actions.T3ActionSupport;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import java.util.LinkedHashMap;
import java.util.Map;
@@ -39,13 +39,10 @@ public class GetOutputProviderOperationsAction extends T3ActionSupport {
private static final long serialVersionUID = 1L;
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(GetOutputProviderOperationsAction.class);
+ private static final Log log = LogFactory.getLog(GetOutputProviderOperationsAction.class);
- protected String outputProviderId;
-
- protected Map<String, String> operations;
+ private String outputProviderId;
+ private Map<String, String> operations;
public void setOutputProviderId(String outputProviderId) {
this.outputProviderId = outputProviderId;
@@ -57,18 +54,11 @@ public class GetOutputProviderOperationsAction extends T3ActionSupport {
@Override
public String execute() {
-
- if (log.isInfoEnabled()) {
- log.info("outputProviderId = " + outputProviderId);
- }
-
- operations = Maps.newLinkedHashMap();
-
- for (T3OutputOperation operation :
- getT3OutputService().getOperations(outputProviderId)) {
+ log.info(String.format("outputProviderId = %s", outputProviderId));
+ operations = new LinkedHashMap<>();
+ for (T3OutputOperation operation : getT3OutputService().getOperations(outputProviderId)) {
operations.put(operation.getId(), operation.getLibelle(getLocale()));
}
-
return SUCCESS;
}
}
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/json/GetZoneVersionsAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/json/GetZoneVersionsAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/json/GetZoneVersionsAction.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.web.actions.json;
-import com.google.common.collect.Maps;
import fr.ird.t3.entities.reference.zone.ZoneStratumAwareMeta;
import fr.ird.t3.entities.reference.zone.ZoneVersion;
import fr.ird.t3.web.actions.T3ActionSupport;
@@ -28,6 +27,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -41,14 +41,11 @@ public class GetZoneVersionsAction extends T3ActionSupport {
private static final long serialVersionUID = 1L;
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(GetZoneVersionsAction.class);
+ private static final Log log = LogFactory.getLog(GetZoneVersionsAction.class);
/** Selected zoneTypeId. */
- protected String zoneTypeId;
-
- protected Map<String, String> zoneVersions;
+ private String zoneTypeId;
+ private Map<String, String> zoneVersions;
public void setZoneTypeId(String zoneTypeId) {
this.zoneTypeId = zoneTypeId;
@@ -60,23 +57,12 @@ public class GetZoneVersionsAction extends T3ActionSupport {
@Override
public String execute() {
-
- if (log.isInfoEnabled()) {
- log.info("zoneTypeId = " + zoneTypeId);
- }
-
- zoneVersions = Maps.newLinkedHashMap();
-
+ log.info(String.format("zoneTypeId = %s", zoneTypeId));
+ zoneVersions = new LinkedHashMap<>();
if (!StringUtils.isEmpty(zoneTypeId)) {
-
- ZoneStratumAwareMeta zoneType =
- getZoneStratumService().getZoneMetaById(zoneTypeId);
-
- List<ZoneVersion> allVersions =
- zoneType.getAllZoneVersions(getT3TopiaPersistenceContext().get());
-
+ ZoneStratumAwareMeta zoneType = getZoneStratumService().getZoneMetaById(zoneTypeId);
+ List<ZoneVersion> allVersions = zoneType.getAllZoneVersions(getT3TopiaPersistenceContext().get());
zoneVersions = sortAndDecorateIdAbles(allVersions);
-
}
return SUCCESS;
}
=====================================
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
@@ -267,7 +267,7 @@ t3.label.data.level3.configuration.samplesToUse=Treatment to apply to catches wi
t3.label.data.level3.configuration.step1=Level 3 configuration step 1
t3.label.data.level3.configuration.step2=Level 3 configuration step 2
t3.label.data.level3.configuration.useAllSamples=Keep their own sample (do nothing)
-t3.label.data.level3.configuration.useCatchSamples=Apply length structures from the sample statrum
+t3.label.data.level3.configuration.useCatchSamples=Apply length structures from the sample stratum
t3.label.data.level3.configuration.useWeightCategories=Use weight categories
t3.label.data.level3.configuration.useWeightCategoriesOrNot=Extrapolation method
t3.label.data.treatment.level0=Level 0 treatment
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/70318fcc05b803dca6f92b7b2361af59…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/70318fcc05b803dca6f92b7b2361af59…
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:
c88b4ba4 by Tony CHEMIT at 2018-03-08T10:35:13Z
clean code
improve release process
improve test API
- - - - -
430e1a25 by Tony CHEMIT at 2018-03-08T10:35:36Z
[N2][N3] Les calées de type banc indéterminé ne sont pas traitées au N2 et N3 (See #261)
- - - - -
693824d0 by Tony CHEMIT at 2018-03-08T10:35:36Z
[N2][N3] Stockage des niveaux de substitution atteints (See #269)
- - - - -
6b63d54c by Tony CHEMIT at 2018-03-08T10:35:37Z
[N2][N3] Les calées de type banc indéterminé ne sont pas traitées au N2 et N3 (See #261)
- - - - -
30 changed files:
- t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeRF2Action.java
- t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ExtrapolateSampleWeightToSetAction.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/Level2Action.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/Level3Action.java
- t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/FakeT3AvdthServiceContext.java
- t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/MSAccessTestConfiguration.java
- t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level0/ComputeRF2Action.ftl
- t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level0/ComputeRF2Action_en.ftl
- 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-actions/src/main/resources/i18n/t3-actions_en_GB.properties
- t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties
- t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeRF2ActionResumeTest.java
- t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeRF2EmptyConfigurationActionResumeTest.java
- t3-actions/src/test/java/fr/ird/t3/models/LengthCompositionModelHelperTest.java
- t3-actions/src/test/java/fr/ird/t3/models/WeightCompositionModelHelperTest.java
- t3-domain/pom.xml
- t3-domain/src/main/java/fr/ird/t3/actions/stratum/CatchStratum.java
The diff was not included because it is too large.
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/compare/1c26466856a7c12ee3ea44fb9265cec…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/compare/1c26466856a7c12ee3ea44fb9265cec…
You're receiving this email because of your account on gitlab.com.
1
0
[Git][ultreiaio/ird-t3][develop] [N2][N3] Les calées de type banc indéterminé ne sont pas traitées au N2 et N3 (See #261)
by Tony CHEMIT 08 Mar '18
by Tony CHEMIT 08 Mar '18
08 Mar '18
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
1c264668 by Tony CHEMIT at 2018-03-08T10:28:09Z
[N2][N3] Les calées de type banc indéterminé ne sont pas traitées au N2 et N3 (See #261)
- - - - -
3 changed files:
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level3/ConfigureLevel3Step2Action.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
Changes:
=====================================
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
@@ -25,6 +25,7 @@ import fr.ird.t3.actions.stratum.SchoolTypeIndeterminate;
import fr.ird.t3.actions.stratum.StratumMinimumSampleCount;
import fr.ird.t3.entities.reference.Country;
import fr.ird.t3.entities.reference.CountryTopiaDao;
+import fr.ird.t3.entities.reference.SchoolTypeTopiaDao;
import fr.ird.t3.entities.reference.Species;
import fr.ird.t3.services.ioc.InjectDAO;
import fr.ird.t3.services.ioc.InjectDecoratedBeans;
@@ -86,6 +87,8 @@ public class ConfigureLevel3Step2Action extends AbstractConfigureAction<Level3Co
Level3Configuration configuration = getConfiguration();
log.info(String.format("Prepare with configuration %s", configuration));
injectExcept(InjectDecoratedBeans.class);
+ // on level 3, can't treat Indeterminate school type
+ schoolTypeIndeterminate.remove(SchoolTypeTopiaDao.SCHOOL_TYPE_INDETERMINATE_ID);
missingData = false;
Set<Country> sampleFlags = new LinkedHashSet<>();
Set<Country> sampleFleets = new LinkedHashSet<>();
=====================================
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
@@ -25,6 +25,7 @@ import fr.ird.t3.actions.stratum.SchoolTypeIndeterminate;
import fr.ird.t3.actions.stratum.StratumMinimumSampleCount;
import fr.ird.t3.entities.reference.Country;
import fr.ird.t3.entities.reference.Ocean;
+import fr.ird.t3.entities.reference.SchoolTypeTopiaDao;
import fr.ird.t3.entities.reference.Species;
import fr.ird.t3.entities.reference.zone.ZoneStratumAwareMeta;
import fr.ird.t3.entities.reference.zone.ZoneVersion;
@@ -85,10 +86,13 @@ public class Level3ConfigureAction extends AbstractConfigureAction<Level3Configu
log.info(String.format("Prepare with configuration %s", getConfiguration()));
useSamplesOrNot = createLevel3UseSamplesOrNotMap();
useWeightCategoriesOrNot = createLevel3UseWeightCategoriesOrNotMap();
+ useWeightCategoriesInStratumOrNot = createUseWeightCategoriesInStratumOrNot();
// load configuration
getConfiguration();
// load decorated beans
injectOnly(InjectDecoratedBeans.class);
+ // on level 3, can't treat Indeterminate school type
+ schoolTypeIndeterminate.remove(SchoolTypeTopiaDao.SCHOOL_TYPE_INDETERMINATE_ID);
}
@Override
@@ -161,10 +165,12 @@ public class Level3ConfigureAction extends AbstractConfigureAction<Level3Configu
public Map<String, String> getUseWeightCategoriesOrNot() {
return useWeightCategoriesOrNot;
}
+
@SuppressWarnings("unused")
public Map<String, String> getUseWeightCategoriesInStratumOrNot() {
return useWeightCategoriesInStratumOrNot;
}
+
@SuppressWarnings("unused")
public Map<String, String> getSchoolTypeIndeterminate() {
return schoolTypeIndeterminate;
=====================================
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
@@ -26,6 +26,7 @@ import fr.ird.t3.actions.stratum.SchoolTypeIndeterminate;
import fr.ird.t3.actions.stratum.StratumMinimumSampleCount;
import fr.ird.t3.entities.reference.Country;
import fr.ird.t3.entities.reference.Ocean;
+import fr.ird.t3.entities.reference.SchoolTypeTopiaDao;
import fr.ird.t3.entities.reference.Species;
import fr.ird.t3.entities.reference.zone.ZoneStratumAwareMeta;
import fr.ird.t3.entities.reference.zone.ZoneVersion;
@@ -159,6 +160,8 @@ public class Level3RunAction extends AbstractRunAction<Level3Configuration, Leve
useWeightCategoriesOrNot = createLevel3UseWeightCategoriesOrNotMap();
useWeightCategoriesInStratumOrNot = createUseWeightCategoriesInStratumOrNot();
super.prepare();
+ // on level 3, can't treat Indeterminate school type
+ schoolTypeIndeterminate.remove(SchoolTypeTopiaDao.SCHOOL_TYPE_INDETERMINATE_ID);
}
@Override
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/1c26466856a7c12ee3ea44fb9265cecb…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/1c26466856a7c12ee3ea44fb9265cecb…
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:
3ba254f0 by Tony CHEMIT at 2018-03-07T23:56:26Z
use now real private avdth...
- - - - -
1 changed file:
- t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/MSAccessTestConfiguration.java
Changes:
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/MSAccessTestConfiguration.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/MSAccessTestConfiguration.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/MSAccessTestConfiguration.java
@@ -36,7 +36,7 @@ import java.util.regex.Pattern;
*/
public class MSAccessTestConfiguration {
- private static final String DB_PATH = "src:test:access";
+ private static final String DB_PATH = "..:.mvn:cache:avdth";
private static final Log log = LogFactory.getLog(MSAccessTestConfiguration.class);
private static File basedir;
private final Pattern testNamePattern;
@@ -76,10 +76,10 @@ public class MSAccessTestConfiguration {
dbBasedir = new File(dbBasedir, s1);
}
if (!dbBasedir.exists()) {
- log.warn("Db directory [" + dbBasedir + "] does not exist, will skip test.");
+ log.warn(String.format("Db directory [%s] does not exist, will skip test.", dbBasedir));
return false;
}
- log.info("Db directory [" + basedir + "] detected, will do tests.");
+ log.info(String.format("Db directory [%s] detected, will do tests.", dbBasedir));
String s = System.getenv("executeAll");
if (!StringUtils.isEmpty(s)) {
executeAll = Boolean.valueOf(s);
@@ -121,24 +121,24 @@ public class MSAccessTestConfiguration {
return false;
}
if (lastYear == null && exactYear == null && executeOnce && !executeAll) {
- log.debug("Skip test " + testName + " executeAll flag is off");
+ log.debug(String.format("Skip test %s executeAll flag is off", testName));
return false;
}
dbName = String.format(dbPattern, ocean, group);
accessFile = new File(new File(dbBasedir, ocean), dbName);
boolean exists = accessFile.exists();
if (!exists) {
- log.warn("Could not find access file " + accessFile);
+ log.warn(String.format("Could not find access file %s", accessFile));
return false;
}
- log.debug("DbName = " + dbName);
+ log.debug(String.format("DbName = %s", dbName));
execute = true;
return true;
}
public boolean doTest(String testName) {
if (!execute) {
- log.info("will not execute test [" + testName + "]");
+ log.info(String.format("Will not execute test [%s]", testName));
return false;
}
executeOnce = true;
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/3ba254f0a013214b36e9684daca22544…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/3ba254f0a013214b36e9684daca22544…
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:
c515ae7d by Tony CHEMIT at 2018-03-07T19:42:54Z
fix typo
- - - - -
56c80a1a by Tony CHEMIT at 2018-03-07T19:43:35Z
[N2][N3] Les calées de type banc indéterminé ne sont pas traitées au N2 et N3 (See #261)
- - - - -
30 changed files:
- t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeRF2Action.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/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/Level2Action.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/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/Level3Action.java
- t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level0/ComputeRF2Action.ftl
- t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level0/ComputeRF2Action_en.ftl
- 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-actions/src/main/resources/i18n/t3-actions_en_GB.properties
- t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties
- t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeRF2ActionResumeTest.java
- t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeRF2EmptyConfigurationActionResumeTest.java
- t3-domain/src/main/java/fr/ird/t3/actions/stratum/CatchStratum.java
- t3-domain/src/main/java/fr/ird/t3/actions/stratum/SampleStratum.java
- t3-domain/src/main/java/fr/ird/t3/actions/stratum/SchoolTypeIndeterminate.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
- t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractActivityTopiaDao.java
- t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractSchoolTypeTopiaDao.java
- t3-domain/src/main/resources/i18n/t3-domain_en_GB.properties
- t3-domain/src/main/resources/i18n/t3-domain_fr_FR.properties
Changes:
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeRF2Action.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeRF2Action.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ComputeRF2Action.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%
@@ -70,7 +70,7 @@ public class ComputeRF2Action extends AbstractLevel0Action<ComputeRF2Configurati
protected List<Harbour> landingHarbours;
@InjectFromDAO(entityType = Species.class)
protected List<Species> species;
- protected int nbStratums;
+ protected int nbStratum;
protected int nbTripsWithRF2;
@InjectDAO(entityType = RaisingFactor2.class)
private RaisingFactor2TopiaDao raisingFactor2DAO;
@@ -87,8 +87,8 @@ public class ComputeRF2Action extends AbstractLevel0Action<ComputeRF2Configurati
super(Level0Step.COMPUTE_RF2);
}
- public int getNbStratums() {
- return nbStratums;
+ public int getNbStratum() {
+ return nbStratum;
}
@SuppressWarnings("unused")
@@ -155,10 +155,10 @@ public class ComputeRF2Action extends AbstractLevel0Action<ComputeRF2Configurati
log.debug(String.format("found %d months.", tripsByMonth.size()));
for (T3Date month : tripsByMonth.keySet()) {
Collection<CompleteTrip> stratumTrips = tripsByMonth.get(month);
- nbStratums++;
+ nbStratum++;
String message = l(locale, "t3.level0.computeRF2.nbTrips.for.stratum",
stratumTrips.size(),
- nbStratums,
+ nbStratum,
harbourStr,
countryStr,
vesselSimpleTypeStr,
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2CatchStratumLoader.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2CatchStratumLoader.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2CatchStratumLoader.java
@@ -57,7 +57,7 @@ public class L2CatchStratumLoader extends CatchStratumLoader<Level2Configuration
Map<String, Integer> activityIds = activityDAO.findAllActivityIdsForCatchStratum(
configuration.getZoneTableName(),
configuration.getZone().getTopiaId(),
- configuration.getSchoolType().getTopiaId(),
+ configuration.getSchoolTypeIds(),
configuration.getBeginDate(),
configuration.getEndDate());
// ensuite pour chaque activité on récupère sa marée et on conserve
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2SampleStratumLoader.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2SampleStratumLoader.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2SampleStratumLoader.java
@@ -56,7 +56,6 @@ public abstract class L2SampleStratumLoader extends SampleStratumLoader<Level2Co
* @since 1.4
*/
private final float minimumSampleTotalWeight;
-
/**
* The minimum sample count required to obtain the correct
* substitution level.
@@ -75,7 +74,7 @@ public abstract class L2SampleStratumLoader extends SampleStratumLoader<Level2Co
float catchStratumTotalWeight = sampleStratum.getCatchStratumTotalWeight();
float maximumWeightRatio = configuration.getStratumWeightRatio();
minimumSampleTotalWeight = catchStratumTotalWeight / maximumWeightRatio;
- SchoolType schoolType = sampleStratum.getConfiguration().getSampleSchoolType();
+ SchoolType schoolType = sampleStratum.getConfiguration().getSchoolType();
int code = schoolType.getCode();
switch (code) {
case 1:
@@ -103,7 +102,7 @@ public abstract class L2SampleStratumLoader extends SampleStratumLoader<Level2Co
List<String> activityIds = activityDAO.findAllActivityIdsForSampleStratum(
configuration.getZoneTableName(),
zoneId,
- schoolTypeId,
+ configuration.getSchoolTypeIds(),
beginDate,
endDate);
result.addAll(activityIds);
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2SampleStratumLoaderAtlantic.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2SampleStratumLoaderAtlantic.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2SampleStratumLoaderAtlantic.java
@@ -41,7 +41,7 @@ public class L2SampleStratumLoaderAtlantic extends L2SampleStratumLoader {
protected Set<String> findActivityIds(int level) {
StratumConfiguration<Level2Configuration> configuration = getSampleStratum().getConfiguration();
- String schoolTypeId = configuration.getSampleSchoolType().getTopiaId();
+ String schoolTypeId = configuration.getSchoolType().getTopiaId();
String zoneId = configuration.getZone().getTopiaId();
T3Date beginDate = configuration.getBeginDate();
T3Date endDate = configuration.getEndDate();
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2SampleStratumLoaderIndian.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2SampleStratumLoaderIndian.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level2/L2SampleStratumLoaderIndian.java
@@ -41,7 +41,7 @@ public class L2SampleStratumLoaderIndian extends L2SampleStratumLoader {
protected Set<String> findActivityIds(int level) {
StratumConfiguration<Level2Configuration> configuration = getSampleStratum().getConfiguration();
- String schoolTypeId = configuration.getSampleSchoolType().getTopiaId();
+ String schoolTypeId = configuration.getSchoolType().getTopiaId();
String zoneId = configuration.getZone().getTopiaId();
T3Date beginDate = configuration.getBeginDate();
T3Date endDate = configuration.getEndDate();
=====================================
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
@@ -27,7 +27,7 @@ import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Multimap;
import fr.ird.t3.actions.T3Action;
import fr.ird.t3.actions.stratum.OceanContext;
-import fr.ird.t3.actions.stratum.SampleStratum;
+import fr.ird.t3.actions.stratum.SchoolTypeIndeterminate;
import fr.ird.t3.actions.stratum.StratumConfiguration;
import fr.ird.t3.entities.data.Activity;
import fr.ird.t3.entities.data.ActivityTopiaDao;
@@ -122,8 +122,6 @@ public class Level2Action extends T3Action<Level2Configuration> {
private CorrectedElementaryCatchTopiaDao correctedElementaryCatchDAO;
@InjectDAO(entityType = Vessel.class)
private VesselTopiaDao vesselDAO;
- @InjectDAO(entityType = SchoolType.class)
- private SchoolTypeTopiaDao schoolTypeDAO;
private ZoneStratumAwareMeta zoneMeta;
@InjectFromDAO(entityType = SchoolType.class, method = "findAllForStratum")
private Set<SchoolType> schoolTypes;
@@ -140,13 +138,11 @@ public class Level2Action extends T3Action<Level2Configuration> {
private Set<T3Date> startDates;
private Set<Vessel> possibleCatchVessels;
private Set<Vessel> possibleSampleVessels;
- private int nbStratums;
+ private int nbStratum;
private long totalCatchWeightForSpeciesFoFix;
private long totalCatchWeight;
private long totalCatchActivities;
private long totalCatchActivitiesWithSample;
- private SchoolType boSchoolType;
- private SchoolType blSchoolType;
public Level2Action() {
activityCache = CacheBuilder.newBuilder().build(
@@ -163,8 +159,6 @@ public class Level2Action extends T3Action<Level2Configuration> {
@Override
protected void prepareAction() throws Exception {
super.prepareAction();
- this.boSchoolType = schoolTypeDAO.forCodeEquals(1).findUnique();
- this.blSchoolType = schoolTypeDAO.forCodeEquals(2).findUnique();
this.oceanContext.clear();
Level2Configuration configuration = getConfiguration();
configuration.setLocale(getLocale());
@@ -216,13 +210,13 @@ public class Level2Action extends T3Action<Level2Configuration> {
}
private void executeActionWithCategories(Level2Configuration configuration, Set<String> usedActivityIds) throws Exception {
- nbStratums = 0;
+ nbStratum = 0;
for (SchoolType schoolType : schoolTypes) {
List<WeightCategoryTreatment> weightCategories = getWeightCategoryTreatments(schoolType);
Collection<ZoneStratumAware> zones = getZones(schoolType);
- nbStratums += startDates.size() * zones.size() * weightCategories.size();
+ nbStratum += startDates.size() * zones.size() * weightCategories.size();
}
- setNbSteps(3 * nbStratums);
+ setNbSteps(3 * nbStratum);
int timeStep = configuration.getTimeStep();
MutableInt stratumIndex = new MutableInt(1);
for (SchoolType schoolType : schoolTypes) {
@@ -237,12 +231,12 @@ public class Level2Action extends T3Action<Level2Configuration> {
}
private void executeActionWithoutCategories(Level2Configuration configuration, Set<String> usedActivityIds) throws Exception {
- nbStratums = 0;
+ nbStratum = 0;
for (SchoolType schoolType : schoolTypes) {
Collection<ZoneStratumAware> zones = getZones(schoolType);
- nbStratums += startDates.size() * zones.size();
+ nbStratum += startDates.size() * zones.size();
}
- setNbSteps(3 * nbStratums);
+ setNbSteps(3 * nbStratum);
int timeStep = configuration.getTimeStep();
MutableInt stratumIndex = new MutableInt(1);
for (SchoolType schoolType : schoolTypes) {
@@ -254,18 +248,15 @@ public class Level2Action extends T3Action<Level2Configuration> {
}
}
- private List<WeightCategoryTreatment> getWeightCategoryTreatments(SchoolType schoolType) {
- List<WeightCategoryTreatment> weightCategoryTreatments = oceanContext.values().stream().flatMap(o -> o.getWeightCategories(schoolType).stream()).distinct().collect(Collectors.toList());
- WeightCategories.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 {
- SchoolType sampleSchoolType = SampleStratum.getSampleSchoolType(schoolType, configuration.getSchoolTypeIndeterminate(), boSchoolType, blSchoolType);
+ 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 timeStep - 1 to have
// exactly timeStep month from beginDate.toStartDate() to endDate.toEndDate()
@@ -277,7 +268,6 @@ public class Level2Action extends T3Action<Level2Configuration> {
zoneMeta,
zone,
schoolType,
- sampleSchoolType,
weightCategoryTreatment,
startDate,
endDate,
@@ -296,24 +286,34 @@ public class Level2Action extends T3Action<Level2Configuration> {
}
}
- private L2StratumResult doExecuteStratum(
- StratumConfiguration<Level2Configuration> stratumConfiguration,
- List<WeightCategoryTreatment> weightCategories,
- MutableInt stratumIndex,
- Set<String> usedActivityIds) throws Exception {
+ private L2StratumResult doExecuteStratum(StratumConfiguration<Level2Configuration> stratumConfiguration,
+ List<WeightCategoryTreatment> weightCategories,
+ MutableInt stratumIndex,
+ Set<String> usedActivityIds) throws Exception {
incrementsProgression();
String stratumPrefix =
l(locale, "t3.level2.stratumLabel",
- stratumIndex, nbStratums,
+ stratumIndex, nbStratum,
decorate(stratumConfiguration.getSchoolType()),
- decorate(stratumConfiguration.getSampleSchoolType()),
decorate(stratumConfiguration.getZone()),
stratumConfiguration.getBeginDate(),
stratumConfiguration.getEndDate());
L2StratumResult result = new L2StratumResult(stratumConfiguration, stratumPrefix);
String message = l(locale, "t3.level2.message.start.stratum", stratumPrefix);
- if (log.isInfoEnabled()) {
- log.info(message);
+ log.info(message);
+ if (SchoolTypeIndeterminate.IGNORE == getConfiguration().getSchoolTypeIndeterminate()) {
+ // Just report for all activities on School type indeterminate catch weight
+ Set<String> activityIds = activityDAO.findAllActivityIdsForCatchStratum(
+ stratumConfiguration.getZoneTableName(),
+ stratumConfiguration.getZone().getTopiaId(),
+ Collections.singleton(SchoolTypeTopiaDao.SCHOOL_TYPE_INDETERMINATE_ID),
+ stratumConfiguration.getBeginDate(),
+ stratumConfiguration.getEndDate()).keySet();
+ for (String activityId : activityIds) {
+ for (CorrectedElementaryCatch correctedElementaryCatch : activityCache.get(activityId).getCorrectedElementaryCatch()) {
+ correctedElementaryCatch.setCorrectedCatchWeight(correctedElementaryCatch.getCatchWeight());
+ }
+ }
}
addInfoMessage("==============================================================================================");
addInfoMessage(message);
@@ -399,6 +399,16 @@ public class Level2Action extends T3Action<Level2Configuration> {
return result;
}
+ private List<WeightCategoryTreatment> getWeightCategoryTreatments(SchoolType schoolType) {
+ List<WeightCategoryTreatment> weightCategoryTreatments = oceanContext.values().stream().flatMap(o -> o.getWeightCategories(schoolType).stream()).distinct().collect(Collectors.toList());
+ WeightCategories.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 L2CatchStratum newCatchStratum(StratumConfiguration<Level2Configuration> stratumConfiguration,
List<WeightCategoryTreatment> weightCategories) throws Exception {
L2CatchStratum catchStratum = new L2CatchStratum(stratumConfiguration, species);
@@ -645,34 +655,6 @@ public class Level2Action extends T3Action<Level2Configuration> {
catchStratum.addActivityOutputModel(correctedCatchWeightModel);
}
-// private void setZoneMeta(ZoneStratumAwareMeta zoneMeta) {
-// this.zoneMeta = zoneMeta;
-// }
-
-// private void setSchoolTypes(Set<SchoolType> schoolTypes) {
-// this.schoolTypes = schoolTypes;
-// }
-
-// private void setSpecies(Set<Species> species) {
-// this.species = species;
-// }
-
-// private void setStartDates(Set<T3Date> startDates) {
-// this.startDates = startDates;
-// }
-
-// private void setPossibleCatchVessels(Set<Vessel> possibleCatchVessels) {
-// this.possibleCatchVessels = possibleCatchVessels;
-// }
-
-// private void setPossibleSampleVessels(Set<Vessel> possibleSampleVessels) {
-// this.possibleSampleVessels = possibleSampleVessels;
-// }
-
-// private void setZoneVersion(ZoneVersion zoneVersion) {
-// this.zoneVersion = zoneVersion;
-// }
-
// -------------------------------------------------------------------------
// --- Results -------------------------------------------------------------
// -------------------------------------------------------------------------
@@ -683,8 +665,8 @@ public class Level2Action extends T3Action<Level2Configuration> {
}
@SuppressWarnings("unused")
- public int getNbStratums() {
- return nbStratums;
+ public int getNbStratum() {
+ return nbStratum;
}
@SuppressWarnings("unused")
@@ -748,7 +730,7 @@ public class Level2Action extends T3Action<Level2Configuration> {
@SuppressWarnings("unused")
public String getInputCatchStratumLog() {
WeightCompositionAggregateModel inputCatchModelForSpeciesToFix = inputCatchModelForAllSpecies.extractForSpecies(species);
- String title = l(locale, "t3.level2.message.strateInputGlobalComposition.resume");
+ String title = l(locale, "t3.level2.message.stratumInputGlobalComposition.resume");
return WeightCompositionModelHelper.decorateModel(
getDecoratorService(),
title,
@@ -759,7 +741,7 @@ public class Level2Action extends T3Action<Level2Configuration> {
@SuppressWarnings("unused")
public String getOutputCatchStratumLog() {
WeightCompositionAggregateModel outputCatchModelForSpeciesToFix = outputCatchModelForAllSpecies.extractForSpecies(species);
- String title = l(locale, "t3.level2.message.strateOutputGlobalComposition.resume");
+ String title = l(locale, "t3.level2.message.stratumOutputGlobalComposition.resume");
return WeightCompositionModelHelper.decorateModel(
getDecoratorService(),
title,
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3CatchStratumLoader.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3CatchStratumLoader.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3CatchStratumLoader.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%
@@ -54,20 +54,16 @@ public class L3CatchStratumLoader extends CatchStratumLoader<Level3Configuration
// - avec des captures
// - dont la marée n'est pas samplesOnly
// - dont la marée est complète
-
Map<String, Integer> activityIds = activityDAO.findAllActivityIdsForCatchStratum(
configuration.getZoneTableName(),
configuration.getZone().getTopiaId(),
- configuration.getSchoolType().getTopiaId(),
+ configuration.getSchoolTypeIds(),
configuration.getBeginDate(),
- configuration.getEndDate()
- );
-
+ configuration.getEndDate());
// ensuite pour chaque activité on récupère sa marée et on conserve
// l'activité uniquement ssi :
// - maree.bateau de type senneur OK
// - maree.bateau dans la bonne flotte OK
-
return filterActivities(configuration, activityIds);
}
@@ -78,20 +74,15 @@ public class L3CatchStratumLoader extends CatchStratumLoader<Level3Configuration
Map<Activity, Integer> result = new HashMap<>();
if (activityIds != null && activityIds.size() > 0) {
for (Map.Entry<String, Integer> e : activityIds.entrySet()) {
-
String activityId = e.getKey();
-
// get activity
Activity activity = configuration.getActivity(activityId);
-
// get his trip
Trip trip = activity.getTrip();
if (!possibleVessels.contains(trip.getVessel())) {
-
// not a matching boat
continue;
}
-
// recheck activity have some catches.
Preconditions.checkState(!activity.isCorrectedElementaryCatchEmpty(),
String.format("Can not accept an activity (%s) with no catch", activity.getTopiaId()));
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3SampleStratumLoader.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3SampleStratumLoader.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3SampleStratumLoader.java
@@ -92,7 +92,7 @@ public abstract class L3SampleStratumLoader extends SampleStratumLoader<Level3Co
List<String> activityIds = activityDAO.findAllActivityIdsForSampleStratum(
configuration.getZoneTableName(),
zoneId,
- schoolTypeId,
+ schoolTypeId == null ? null : configuration.getSchoolTypeIds(),
beginDate,
endDate);
result.addAll(activityIds);
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3SampleStratumLoaderAtlantic.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3SampleStratumLoaderAtlantic.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3SampleStratumLoaderAtlantic.java
@@ -40,7 +40,7 @@ public class L3SampleStratumLoaderAtlantic extends L3SampleStratumLoader {
@Override
protected Set<String> findActivityIds(int level) {
StratumConfiguration<Level3Configuration> configuration = getSampleStratum().getConfiguration();
- String schoolTypeId = configuration.getSampleSchoolType().getTopiaId();
+ String schoolTypeId = configuration.getSchoolType().getTopiaId();
String zoneId = configuration.getZone().getTopiaId();
T3Date beginDate = configuration.getBeginDate();
T3Date endDate = configuration.getEndDate();
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3SampleStratumLoaderIndian.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3SampleStratumLoaderIndian.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level3/L3SampleStratumLoaderIndian.java
@@ -41,7 +41,7 @@ public class L3SampleStratumLoaderIndian extends L3SampleStratumLoader {
protected Set<String> findActivityIds(int level) {
StratumConfiguration<Level3Configuration> configuration = getSampleStratum().getConfiguration();
- String schoolTypeId = configuration.getSampleSchoolType().getTopiaId();
+ String schoolTypeId = configuration.getSchoolType().getTopiaId();
String zoneId = configuration.getZone().getTopiaId();
T3Date beginDate = configuration.getBeginDate();
T3Date endDate = configuration.getEndDate();
=====================================
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
@@ -30,7 +30,6 @@ 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.SampleStratum;
import fr.ird.t3.actions.stratum.StratumConfiguration;
import fr.ird.t3.actions.stratum.StratumMinimumSampleCount;
import fr.ird.t3.entities.T3Predicates;
@@ -46,7 +45,6 @@ import fr.ird.t3.entities.reference.LengthWeightConversionHelper;
import fr.ird.t3.entities.reference.LengthWeightConversionTopiaDao;
import fr.ird.t3.entities.reference.Ocean;
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.Vessel;
import fr.ird.t3.entities.reference.VesselTopiaDao;
@@ -141,21 +139,11 @@ public class Level3Action extends T3Action<Level3Configuration> {
private LengthWeightConversionTopiaDao lengthWeightConversionDAO;
@InjectDAO(entityType = WeightCategoryTreatment.class)
private WeightCategoryTreatmentTopiaDao weightCategoryTreatmentDAO;
- // @InjectDAO(entityType = SetSpeciesFrequency.class)
-// private SetSpeciesFrequencyTopiaDao setSpeciesFrequencyDAO;
-// @InjectDAO(entityType = SetSpeciesCatWeight.class)
-// private SetSpeciesCatWeightTopiaDao setSpeciesCatWeightDAO;
-// @InjectDAO(entityType = ExtrapolatedAllSetSpeciesFrequency.class)
-// private ExtrapolatedAllSetSpeciesFrequencyTopiaDao extrapolatedAllSetSpeciesFrequencyDAO;
@InjectDAO(entityType = Vessel.class)
private VesselTopiaDao vesselDAO;
- @InjectDAO(entityType = SchoolType.class)
- private SchoolTypeTopiaDao schoolTypeDAO;
private ZoneStratumAwareMeta zoneMeta;
@InjectFromDAO(entityType = SchoolType.class, method = "findAllForStratum")
private Set<SchoolType> schoolTypes;
- // @InjectEntityById(entityType = Ocean.class)
-// private Ocean ocean;
@InjectEntitiesById(entityType = Country.class)
private Set<Country> catchFleets;
@InjectEntitiesById(entityType = Species.class, path = "configuration.speciesIds")
@@ -170,7 +158,7 @@ public class Level3Action extends T3Action<Level3Configuration> {
private Set<Vessel> possibleCatchVessels;
private Set<Vessel> possibleSampleVessels;
private Map<SchoolType, Map<String, Integer>> stratumMinimumSampleCountBySchoolType;
- private int nbStratums;
+ private int nbStratum;
private long nbCatchActivities;
private long nbCatchActivitiesWithSample;
/**
@@ -182,8 +170,6 @@ public class Level3Action extends T3Action<Level3Configuration> {
private String topiaCreateDate;
private int nbQuery;
private StringBuilder queryBuffer = new StringBuilder();
- private SchoolType boSchoolType;
- private SchoolType blSchoolType;
public Level3Action() {
activityCache = CacheBuilder.newBuilder().build(
@@ -202,8 +188,6 @@ public class Level3Action extends T3Action<Level3Configuration> {
@Override
protected void prepareAction() throws Exception {
super.prepareAction();
- this.boSchoolType = schoolTypeDAO.forCodeEquals(1).findUnique();
- this.blSchoolType = schoolTypeDAO.forCodeEquals(2).findUnique();
this.totalFishesCount = new SpeciesCountAggregateModel();
Level3Configuration configuration = getConfiguration();
configuration.setLocale(getLocale());
@@ -249,7 +233,7 @@ public class Level3Action extends T3Action<Level3Configuration> {
}
break;
default:
- throw new IllegalStateException("Can not use the school fish " + code);
+ throw new IllegalStateException(String.format("Can not use the school type %d", code));
}
}
this.stratumMinimumSampleCountBySchoolType = minimumSampleCountBySchoolType;
@@ -283,13 +267,13 @@ public class Level3Action extends T3Action<Level3Configuration> {
}
private void executeActionWithCategories(Level3Configuration configuration, Set<String> usedActivityIds) throws Exception {
- nbStratums = 0;
+ nbStratum = 0;
for (SchoolType schoolType : schoolTypes) {
List<WeightCategoryTreatment> weightCategories = getWeightCategoryTreatments(schoolType);
Collection<ZoneStratumAware> zones = getZones(schoolType);
- nbStratums += startDates.size() * zones.size() * weightCategories.size();
+ nbStratum += startDates.size() * zones.size() * weightCategories.size();
}
- setNbSteps(3 * nbStratums);
+ setNbSteps(3 * nbStratum);
int timeStep = configuration.getTimeStep();
MutableInt stratumIndex = new MutableInt(1);
for (SchoolType schoolType : schoolTypes) {
@@ -305,12 +289,12 @@ public class Level3Action extends T3Action<Level3Configuration> {
}
private void executeActionWithoutCategories(Level3Configuration configuration, Set<String> usedActivityIds) throws Exception {
- nbStratums = 0;
+ nbStratum = 0;
for (SchoolType schoolType : schoolTypes) {
Collection<ZoneStratumAware> zones = getZones(schoolType);
- nbStratums += startDates.size() * zones.size();
+ nbStratum += startDates.size() * zones.size();
}
- setNbSteps(3 * nbStratums);
+ setNbSteps(3 * nbStratum);
int timeStep = configuration.getTimeStep();
MutableInt stratumIndex = new MutableInt(1);
for (SchoolType schoolType : schoolTypes) {
@@ -334,7 +318,6 @@ public class Level3Action extends T3Action<Level3Configuration> {
}
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 {
- SchoolType sampleSchoolType = SampleStratum.getSampleSchoolType(schoolType, configuration.getSchoolTypeIndeterminate(), boSchoolType, blSchoolType);
for (T3Date startDate : startDates) {
// clear query buffer
queryBuffer = new StringBuilder();
@@ -348,7 +331,6 @@ public class Level3Action extends T3Action<Level3Configuration> {
zoneMeta,
zone,
schoolType,
- sampleSchoolType,
weightCategoryTreatment,
startDate,
endDate,
@@ -382,9 +364,8 @@ public class Level3Action extends T3Action<Level3Configuration> {
incrementsProgression();
String stratumPrefix =
l(locale, "t3.level3.stratumLabel",
- stratumIndex, nbStratums,
+ stratumIndex, nbStratum,
decorate(stratumConfiguration.getSchoolType()),
- decorate(stratumConfiguration.getSampleSchoolType()),
decorate(stratumConfiguration.getZone()),
stratumConfiguration.getBeginDate(),
stratumConfiguration.getEndDate());
@@ -394,6 +375,21 @@ public class Level3Action extends T3Action<Level3Configuration> {
addInfoMessage("==============================================================================================");
addInfoMessage(message);
addInfoMessage("==============================================================================================");
+ //FIXME-261 Is there anything to do ?
+// if (SchoolTypeIndeterminate.IGNORE == getConfiguration().getSchoolTypeIndeterminate()) {
+// // Just report for all activities on School type indeterminate catch weight
+// Set<String> activityIds = activityDAO.findAllActivityIdsForCatchStratum(
+// stratumConfiguration.getZoneTableName(),
+// stratumConfiguration.getZone().getTopiaId(),
+// Collections.singleton(SchoolTypeTopiaDao.SCHOOL_TYPE_INDETERMINATE_ID),
+// stratumConfiguration.getBeginDate(),
+// stratumConfiguration.getEndDate()).keySet();
+// for (String activityId : activityIds) {
+// for (CorrectedElementaryCatch correctedElementaryCatch : activityCache.get(activityId).getCorrectedElementaryCatch()) {
+// correctedElementaryCatch.setCorrectedCatchWeight(correctedElementaryCatch.getCatchWeight());
+// }
+// }
+// }
// get the catch stratum
try (L3CatchStratum catchStratum = newCatchStratum(stratumConfiguration, weightCategories)) {
incrementsProgression();
@@ -713,8 +709,8 @@ public class Level3Action extends T3Action<Level3Configuration> {
return nbCatchActivitiesWithSample;
}
- public int getNbStratums() {
- return nbStratums;
+ public int getNbStratum() {
+ return nbStratum;
}
@SuppressWarnings("unused")
=====================================
t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level0/ComputeRF2Action.ftl
=====================================
--- a/t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level0/ComputeRF2Action.ftl
+++ b/t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level0/ComputeRF2Action.ftl
@@ -46,7 +46,7 @@ Date de fin : ${configuration.endDate}
Indicateurs
-----------
-- Nombre de strates : ${action.nbStratums}
+- Nombre de strates : ${action.nbStratum}
- Nombre de marées : ${action.nbTrips}
- Nombre de marées avec calcul du rf2 : ${action.nbTripsWithRF2}
=====================================
t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level0/ComputeRF2Action_en.ftl
=====================================
--- a/t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level0/ComputeRF2Action_en.ftl
+++ b/t3-actions/src/main/resources/ftl/fr/ird/t3/actions/data/level0/ComputeRF2Action_en.ftl
@@ -46,7 +46,7 @@ End date: ${configuration.endDate}
Indicators
----------
-- Number of stratums: ${action.nbStratums}
+- Number of stratums: ${action.nbStratum}
- Number of trips: ${action.nbTrips}
- Number of trips with computed rf2: ${action.nbTripsWithRF2}
=====================================
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
@@ -81,7 +81,7 @@ Qualité des strates échantillons :
Indicateurs
-----------
-- Nombre de strates : ${action.nbStratums}
+- Nombre de strates : ${action.nbStratum}
- Nombre de strates corrigés : ${action.nbStrataFixed}
- Nombre d'activités traités : ${action.totalCatchActivities}
- Nombre d'activités traités (avec échantillon) : ${action.totalCatchActivitiesWithSample}
=====================================
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
@@ -80,7 +80,7 @@ Quality of sample stratum:
Indicators
----------
-- Number of stratums: ${action.nbStratums}
+- Number of stratums: ${action.nbStratum}
- Number of treated stratums: ${action.nbStrataFixed}
- Number of treated sets: ${action.totalCatchActivities}
- Number of treated sets (with samples): ${action.totalCatchActivitiesWithSample}
=====================================
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
@@ -89,7 +89,7 @@ Qualité des strates échantillons :
Indicateurs
-----------
-- Nombre de strates : ${action.nbStratums}
+- Nombre de strates : ${action.nbStratum}
- Nombre de strates corrigés : ${action.nbStrataFixed}
- Nombre d'activités traités : ${action.nbCatchActivities}
- Nombre d'activités traités (avec échantillon) : ${action.nbCatchActivitiesWithSample}
=====================================
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
@@ -89,7 +89,7 @@ Quality of sample stratum:
Indicators
----------
-- Number of stratums: ${action.nbStratums}
+- Number of stratums: ${action.nbStratum}
- Number of treated stratums: ${action.nbStrataFixed}
- Number of treated sets: ${action.nbCatchActivities}
- Number of treated sets (with samples): ${action.nbCatchActivitiesWithSample}
=====================================
t3-actions/src/main/resources/i18n/t3-actions_en_GB.properties
=====================================
--- a/t3-actions/src/main/resources/i18n/t3-actions_en_GB.properties
+++ b/t3-actions/src/main/resources/i18n/t3-actions_en_GB.properties
@@ -115,10 +115,10 @@ t3.level2.message.catchStratum.resume=Stratum Catch (count of sets %s, total wei
t3.level2.message.noCatch.in.stratum=No catches found in this stratum
t3.level2.message.start.activity=Correct activity [%s/%s] \: %s (number of zones\: %s)
t3.level2.message.start.stratum=Treat %s
-t3.level2.message.strateInputGlobalComposition.resume=Global specific composition (before correction)\:
-t3.level2.message.strateOutputGlobalComposition.resume=Global specific composition (after correction)\:
+t3.level2.message.stratumInputGlobalComposition.resume=Global specific composition (before correction)\:
+t3.level2.message.stratumOutputGlobalComposition.resume=Global specific composition (after correction)\:
t3.level2.sampleStratum.resume.for.level=Sample stratum (lvevel %s)\n - Activity count %s\n - Fishes count (for species to fix) %s\n - Total weight (for species to fix) %s
-t3.level2.stratumLabel=Stratum [%s/%s] (%s (sample %s) - zone %s - [start %s - end %s])
+t3.level2.stratumLabel=Stratum [%s/%s] (%s - zone %s - [start %s - end %s])
t3.level2.warning.missing.data.for.stratum=Impossible to compute sample stratum for %s, last substitution level reached.
t3.level3.action=Level 3 Treatment
t3.level3.catchStratum.nbFishesResume.title=Total count of fishes in catch stratum
@@ -136,7 +136,7 @@ t3.level3.nbFishesBeforeLevel3=Before level 3
t3.level3.nbFishesResume.title=Total count of fishes
t3.level3.sampleStratum.resume.for.level=Sample Stratum (level %s)\n - activity count %s\n - Total weight (for species to fix) %s\n - Count of fishes \:
t3.level3.sampleStratum.resume.for.level.and.species=\n Species %s \: %s
-t3.level3.stratumLabel=Stratum [%s/%s] (%s (sample %s) - zone %s - [begin %s - end %s])
+t3.level3.stratumLabel=Stratum [%s/%s] (%s - zone %s - [begin %s - end %s])
t3.level3.warning.missing.data.for.stratum=Impossible de compute sample stratum for stratum %s, last substitution level reached.
t3.level3.warning.missing.sample.species=Stratum %s, it miss a species %s in samples, can not extrapolate.
t3.message.create.new.vessel=Create a new vessel %s and store in db.
=====================================
t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties
=====================================
--- a/t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties
+++ b/t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties
@@ -115,10 +115,10 @@ t3.level2.message.catchStratum.resume=Strate capture (nombre de calées %s, poid
t3.level2.message.noCatch.in.stratum=Aucune capture trouvée dans cette strate
t3.level2.message.start.activity=Correction de l'activité [%s/%s] \: %s (nombre de zones \: %s)
t3.level2.message.start.stratum=Traitement %s
-t3.level2.message.strateInputGlobalComposition.resume=Composition globale des captures avant correction \:
-t3.level2.message.strateOutputGlobalComposition.resume=Composition globale des captures après correction \:
+t3.level2.message.stratumInputGlobalComposition.resume=Composition globale des captures avant correction \:
+t3.level2.message.stratumOutputGlobalComposition.resume=Composition globale des captures après correction \:
t3.level2.sampleStratum.resume.for.level=Strate échantillon (niveau %s)\n - Nombre activités %s\n - Nombre de poissons (pour les espèces à corriger) %s\n - Poids total (pour les espèces à corriger) %s
-t3.level2.stratumLabel=Strate [%s/%s] (%s (échantillon %s) - zone %s - [debut %s - fin %s])
+t3.level2.stratumLabel=Strate [%s/%s] (%s - zone %s - [debut %s - fin %s])
t3.level2.warning.missing.data.for.stratum=Impossible de calculer la strate échantillon pour la strate %s, dernier niveau de substitution atteint.
t3.level3.action=Traitement de niveau 3
t3.level3.catchStratum.nbFishesResume.title=Nombre total de poissons dans la strate capture
@@ -136,7 +136,7 @@ t3.level3.nbFishesBeforeLevel3=Avant niveau 3
t3.level3.nbFishesResume.title=Nombre total de poissons
t3.level3.sampleStratum.resume.for.level=Strate échantillon (niveau %s)\n - Nombre activités %s\n - Poids total (pour les espèces à corriger) %s\n - Nombre de poissons \:
t3.level3.sampleStratum.resume.for.level.and.species=\n Espèce %s \: %s
-t3.level3.stratumLabel=Strate [%s/%s] (%s (échantillon %s) - zone %s - [debut %s - fin %s])
+t3.level3.stratumLabel=Strate [%s/%s] (%s - zone %s - [debut %s - fin %s])
t3.level3.warning.missing.data.for.stratum=Impossible de calculer la strate échantillon pour la strate %s, dernier niveau de substitution atteint.
t3.level3.warning.missing.sample.species=Strate %s, il manque une espèce %s dans les échantillons, extrapolation non possible.
t3.message.create.new.vessel=Création d'un nouveau navire %s et sauvegarde en base
=====================================
t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeRF2ActionResumeTest.java
=====================================
--- a/t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeRF2ActionResumeTest.java
+++ b/t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeRF2ActionResumeTest.java
@@ -57,7 +57,7 @@ public class ComputeRF2ActionResumeTest extends AbstractActionResumeTest<Compute
protected void prepareAction(ComputeRF2Action action, Locale locale) {
super.prepareAction(action, locale);
- action.nbStratums = 100;
+ action.nbStratum = 100;
action.nbTrips = 10;
action.nbTripsWithRF2 = 5;
}
=====================================
t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeRF2EmptyConfigurationActionResumeTest.java
=====================================
--- a/t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeRF2EmptyConfigurationActionResumeTest.java
+++ b/t3-actions/src/test/java/fr/ird/t3/actions/data/level0/ComputeRF2EmptyConfigurationActionResumeTest.java
@@ -53,7 +53,7 @@ public class ComputeRF2EmptyConfigurationActionResumeTest extends AbstractAction
protected void prepareAction(ComputeRF2Action action, Locale locale) {
super.prepareAction(action, locale);
- action.nbStratums = 100;
+ action.nbStratum = 100;
action.nbTrips = 10;
action.nbTripsWithRF2 = 5;
}
=====================================
t3-domain/src/main/java/fr/ird/t3/actions/stratum/CatchStratum.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/actions/stratum/CatchStratum.java
+++ b/t3-domain/src/main/java/fr/ird/t3/actions/stratum/CatchStratum.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%
@@ -40,6 +40,10 @@ import java.util.Map;
*/
public abstract class CatchStratum<C extends LevelConfigurationWithStratum, A extends T3Action<C>> extends Stratum<C, A> {
+ protected CatchStratum(StratumConfiguration<C> configuration, Collection<Species> speciesToFix) {
+ super(configuration, speciesToFix);
+ }
+
/**
* Gets a new loader of catch stratum.
*
@@ -47,21 +51,13 @@ public abstract class CatchStratum<C extends LevelConfigurationWithStratum, A ex
*/
protected abstract CatchStratumLoader<C> newLoader();
- protected CatchStratum(StratumConfiguration<C> configuration, Collection<Species> speciesToFix) {
- super(configuration, speciesToFix);
- }
-
@Override
public void init(T3ServiceContext serviceContext, List<WeightCategoryTreatment> weightCategories, A messager) throws Exception {
-
CatchStratumLoader<C> stratumLoader = newLoader();
-
// inject transaction in loader
stratumLoader.setTransaction(serviceContext.getT3TopiaPersistenceContext());
-
- // inject daos in loader
+ // inject dao in loader
serviceContext.newService(IOCService.class).injectOnly(stratumLoader, InjectDAO.class);
-
// get all catches usable in this stratum grouped by their owing activity
Map<Activity, Integer> activities = stratumLoader.loadData(getConfiguration());
setActivities(activities);
=====================================
t3-domain/src/main/java/fr/ird/t3/actions/stratum/SampleStratum.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/actions/stratum/SampleStratum.java
+++ b/t3-domain/src/main/java/fr/ird/t3/actions/stratum/SampleStratum.java
@@ -22,18 +22,17 @@ package fr.ird.t3.actions.stratum;
import fr.ird.t3.actions.T3Action;
import fr.ird.t3.entities.data.Activity;
-import fr.ird.t3.entities.reference.SchoolType;
import fr.ird.t3.entities.reference.Species;
import fr.ird.t3.entities.reference.WeightCategoryTreatment;
import fr.ird.t3.services.IOCService;
import fr.ird.t3.services.T3ServiceContext;
import fr.ird.t3.services.ioc.InjectDAO;
+import org.nuiton.topia.persistence.TopiaException;
+
import java.util.Collection;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
import java.util.Set;
-import org.nuiton.topia.persistence.TopiaException;
/**
* Base samle stratum.
@@ -61,19 +60,6 @@ public abstract class SampleStratum<C extends LevelConfigurationWithStratum, A e
*/
private Integer substitutionLevel;
- public static SchoolType getSampleSchoolType(SchoolType schoolType,SchoolTypeIndeterminate schoolTypeIndeterminate , SchoolType boSchoolType, SchoolType blSchoolType) {
- if (Objects.requireNonNull(schoolType).getCode() == 3) {
- switch (Objects.requireNonNull(schoolTypeIndeterminate)) {
- case ALL_IN_BO:
- return boSchoolType;
- case ALL_IN_BL:
- return blSchoolType;
- }
- throw new IllegalStateException("Can't deal with " + schoolTypeIndeterminate);
- }
- return schoolType;
- }
-
protected abstract SampleStratumLoader<C, A, S> newLoader();
protected abstract String logSampleStratumLevel(int substitutionLevel,
=====================================
t3-domain/src/main/java/fr/ird/t3/actions/stratum/SchoolTypeIndeterminate.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/actions/stratum/SchoolTypeIndeterminate.java
+++ b/t3-domain/src/main/java/fr/ird/t3/actions/stratum/SchoolTypeIndeterminate.java
@@ -31,7 +31,8 @@ import fr.ird.t3.t3.domain.I18nEnumHelper;
*/
public enum SchoolTypeIndeterminate {
ALL_IN_BO, // consider as BO
- ALL_IN_BL; // consider as BL
+ ALL_IN_BL, // consider as BL
+ IGNORE; // just report incoming data
public String getLabel() {
return I18nEnumHelper.getLabel(this);
=====================================
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
@@ -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%
@@ -46,28 +46,31 @@ 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 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)}.
- */
- private Map<Activity, Integer> activities;
-
- /**
* Stratum configuration of this stratum.
*
* @see StratumConfiguration
*/
private final StratumConfiguration<C> configuration;
-
/**
* Selected set of species to fix.
*
* @since 1.3.1
*/
private final Set<Species> speciesToFix;
+ /**
+ * 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)}.
+ */
+ private Map<Activity, Integer> activities;
+
+ protected Stratum(StratumConfiguration<C> configuration, Collection<Species> speciesToFix) {
+ this.configuration = configuration;
+ this.speciesToFix = ImmutableSet.copyOf(speciesToFix);
+ }
/**
* Initialize the data of the stratum.
@@ -79,16 +82,12 @@ public abstract class Stratum<C extends LevelConfigurationWithStratum, A extends
*/
public abstract void init(T3ServiceContext serviceContext, List<WeightCategoryTreatment> weightCategories, A messager) throws Exception;
+ @SuppressWarnings("NullableProblems")
@Override
public Iterator<Map.Entry<Activity, Integer>> iterator() {
return activities.entrySet().iterator();
}
- protected Stratum(StratumConfiguration<C> configuration, Collection<Species> speciesToFix) {
- this.configuration = configuration;
- this.speciesToFix = ImmutableSet.copyOf(speciesToFix);
- }
-
public final StratumConfiguration<C> getConfiguration() {
return configuration;
}
@@ -102,14 +101,12 @@ public abstract class Stratum<C extends LevelConfigurationWithStratum, A extends
}
/**
- * Obtain the activities selected for this stratum with the number of zones
- * they are involved in.
+ * Obtain the activities selected for this stratum with the number of zones they are involved in.
* <p/>
* The number of zones (see http://forge.codelutin.com/issues/1935) is only
* used for catch stratum, for sample stratum always used a single zone.
* <p/>
- * <strong>Note: </strong> to invoke this method, you need first to invoke
- * the {@link Stratum#init(T3ServiceContext, List, T3Action}
+ * <strong>Note: </strong> to invoke this method, you need first to invoke the {@link #init(T3ServiceContext, List, T3Action)}
*
* @return the set of activities found for this stratum.
*/
=====================================
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
@@ -21,7 +21,9 @@
package fr.ird.t3.actions.stratum;
import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableSet;
import fr.ird.t3.entities.data.Activity;
+import fr.ird.t3.entities.reference.AbstractSchoolTypeTopiaDao;
import fr.ird.t3.entities.reference.SchoolType;
import fr.ird.t3.entities.reference.Vessel;
import fr.ird.t3.entities.reference.WeightCategoryTreatment;
@@ -51,7 +53,6 @@ public class StratumConfiguration<C extends LevelConfigurationWithStratum> {
private final ZoneStratumAwareMeta zoneMeta;
private final ZoneStratumAware zone;
private final SchoolType schoolType;
- private final SchoolType sampleSchoolType;
private final WeightCategoryTreatment weightCategoryTreatment;
private final T3Date beginDate;
private final T3Date endDate;
@@ -65,8 +66,8 @@ public class StratumConfiguration<C extends LevelConfigurationWithStratum> {
ZoneStratumAwareMeta zoneMeta,
ZoneStratumAware zone,
SchoolType schoolType,
- SchoolType sampleSchoolType,
- WeightCategoryTreatment weightCategoryTreatment, T3Date beginDate,
+ WeightCategoryTreatment weightCategoryTreatment,
+ T3Date beginDate,
T3Date endDate,
Collection<ZoneStratumAware> zones,
Set<Vessel> possibleCatchVessels,
@@ -77,7 +78,6 @@ public class StratumConfiguration<C extends LevelConfigurationWithStratum> {
this.zoneMeta = zoneMeta;
this.zone = zone;
this.schoolType = schoolType;
- this.sampleSchoolType = sampleSchoolType;
this.weightCategoryTreatment = weightCategoryTreatment;
this.beginDate = beginDate;
this.endDate = endDate;
@@ -92,27 +92,26 @@ public class StratumConfiguration<C extends LevelConfigurationWithStratum> {
* Obtain a new stratum configuration given all his parameters.
*
* @param <C> type of configuration
- * @param conf the level action configuration
+ * @param configuration 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 sampleSchoolType the school type of the sample 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 useable by the level action which used this stratum (can be used for sample stratum substitution)
+ * @param zones all the zones usable 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,
+ C configuration,
ZoneStratumAwareMeta zoneMeta,
ZoneStratumAware zone,
SchoolType schoolType,
- SchoolType sampleSchoolType,
- WeightCategoryTreatment weightCategoryTreatment, T3Date startDate,
+ WeightCategoryTreatment weightCategoryTreatment,
+ T3Date startDate,
T3Date endDate,
Collection<ZoneStratumAware> zones,
Set<Vessel> possibleCatchVessels,
@@ -121,11 +120,10 @@ public class StratumConfiguration<C extends LevelConfigurationWithStratum> {
LoadingCache<String, Activity> activityCache) {
return new StratumConfiguration<>(
- conf,
+ configuration,
zoneMeta,
zone,
schoolType,
- sampleSchoolType,
weightCategoryTreatment,
startDate,
endDate,
@@ -140,7 +138,7 @@ public class StratumConfiguration<C extends LevelConfigurationWithStratum> {
return configuration;
}
- public ZoneStratumAwareMeta getZoneMeta() {
+ private ZoneStratumAwareMeta getZoneMeta() {
return zoneMeta;
}
@@ -156,8 +154,23 @@ public class StratumConfiguration<C extends LevelConfigurationWithStratum> {
return schoolType;
}
- public SchoolType getSampleSchoolType() {
- return sampleSchoolType;
+ public Set<String> getSchoolTypeIds() {
+ ImmutableSet.Builder<String> builder = ImmutableSet.<String>builder().add(getSchoolType().getTopiaId());
+ switch (configuration.getSchoolTypeIndeterminate()) {
+ case ALL_IN_BO:
+ if (AbstractSchoolTypeTopiaDao.SCHOOL_TYPE_BO_ID.equals(getSchoolType().getTopiaId())) {
+ builder.add(AbstractSchoolTypeTopiaDao.SCHOOL_TYPE_INDETERMINATE_ID);
+ }
+ break;
+ case ALL_IN_BL:
+ if (AbstractSchoolTypeTopiaDao.SCHOOL_TYPE_BL_ID.equals(getSchoolType().getTopiaId())) {
+ builder.add(AbstractSchoolTypeTopiaDao.SCHOOL_TYPE_INDETERMINATE_ID);
+ }
+ break;
+ case IGNORE:
+ break;
+ }
+ return builder.build();
}
public T3Date getBeginDate() {
@@ -211,7 +224,7 @@ public class StratumConfiguration<C extends LevelConfigurationWithStratum> {
@Override
public String toString() {
- return String.format("%s [schoolType: %s, sampleSchoolType: %s, zone: %s, startDate:%s, endDate:%s, weightCategory: %s]", super.toString(), schoolType.getLabel1(), sampleSchoolType.getLabel1(), zone.getTopiaId(), beginDate, endDate, weightCategoryTreatment);
+ return String.format("%s [schoolType: %s, zone: %s, startDate:%s, endDate:%s, weightCategory: %s]", super.toString(), schoolType.getLabel1(), zone.getTopiaId(), beginDate, endDate, weightCategoryTreatment);
}
public void addToActivity(Activity activity, Function<Activity, String> function, BiConsumer<Activity, String> consumer, int level) {
=====================================
t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractActivityTopiaDao.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractActivityTopiaDao.java
+++ b/t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractActivityTopiaDao.java
@@ -31,7 +31,6 @@ import fr.ird.t3.entities.reference.WeightCategoryTreatment;
import fr.ird.t3.entities.type.T3Date;
import fr.ird.t3.models.WeightCompositionAggregateModel;
import org.apache.commons.collections.CollectionUtils;
-import org.nuiton.topia.persistence.TopiaException;
import org.nuiton.topia.persistence.support.TopiaSqlQuery;
import org.nuiton.topia.persistence.support.TopiaSqlSupport;
@@ -187,35 +186,26 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv
return correctedElementaryCatch.stream().map(SpeciesAware::getSpecies).collect(Collectors.toSet());
}
-// public boolean isActivityWithSample(Activity activity) throws TopiaException {
-// SampleSetTopiaDao sampleSetDAO = topiaDaoSupplier.getDao(SampleSet.class, SampleSetTopiaDao.class);
-// List<SampleSet> allByActivity = sampleSetDAO.forActivityEquals(activity).findAll();
-// return CollectionUtils.isNotEmpty(allByActivity);
-// }
-
public Map<String, Integer> findAllActivityIdsForCatchStratum(String zoneTableName,
String zoneId,
- String schoolTypeId,
+ Set<String> schoolTypeIds,
T3Date beginDate,
- T3Date endDate) throws TopiaException {
-
+ T3Date endDate) {
// ---
// Get activities strictly inside the zone
// ---
- TopiaSqlQuery<String> query = new GetActivityIdsInZoneForCatchStratumQuery(zoneTableName, zoneId, schoolTypeId, beginDate, endDate);
+ TopiaSqlQuery<String> query = new GetActivityIdsInZoneForCatchStratumQuery(zoneTableName, zoneId, schoolTypeIds, beginDate, endDate);
List<String> activityIds = topiaSqlSupport.findMultipleResult(query);
Map<String, Integer> result = new HashMap<>();
for (String activityId : activityIds) {
// activity strictly inside a zone are exactly in one zone
result.put(activityId, 1);
}
-
// ---
// Get activities on the border of the zone
// ---
- query = new GetActivityIdsInBorderForCatchStratumQuery(zoneTableName, zoneId, schoolTypeId, beginDate, endDate);
+ query = new GetActivityIdsInBorderForCatchStratumQuery(zoneTableName, zoneId, schoolTypeIds, beginDate, endDate);
activityIds = topiaSqlSupport.findMultipleResult(query);
-
// ---
// Get nb zones of such activities
// ---
@@ -228,117 +218,76 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv
return result;
}
-// public static void fillWeightsFromCorrectedCatchesWeight(Activity activity,
-// Map<WeightCategoryTreatment, Map<Species, Float>> weights,
-// WeightCompositionAggregateModel model) {
-//
-// if (weights == null) {
-// weights = new HashMap<>();
-// }
-// Multimap<WeightCategoryTreatment, CorrectedElementaryCatch> data =
-// ActivityTopiaDao.groupByWeightCategoryTreatment(activity.getCorrectedElementaryCatch());
-//
-// T3IOUtil.fillMapWithDefaultValue(
-// weights, data.keySet(), T3Suppliers.MAP_SPECIES_FLOAT_SUPPLIER);
-//
-// for (WeightCategoryTreatment weightCategory : data.keySet()) {
-//
-// Map<Species, Float> speciesFloatMap = weights.get(weightCategory);
-//
-// Collection<CorrectedElementaryCatch> correctedElementaryCatches = data.get(weightCategory);
-//
-// fillWeights(weightCategory,
-// correctedElementaryCatches,
-// speciesFloatMap,
-// T3Functions.CORRECTED_ELEMENTARY_CATCH_TO_CORRECTED_CATCH_WEIGHT,
-// model
-// );
-// }
-// }
-
public List<String> findAllActivityIdsForSampleStratum(String zoneTableName,
String zoneId,
- String schoolTypeId,
+ Set<String> schoolTypeIds,
T3Date beginDate,
- T3Date endDate) throws TopiaException {
+ T3Date endDate) {
TopiaSqlQuery<String> query;
- if (schoolTypeId == null) {
+ if (schoolTypeIds == null) {
// for any school type
query = new GetActivityIdsForSampleStratumWithAnySchoolTypeQuery(zoneTableName, zoneId, beginDate, endDate);
} else {
// for a specific school type
- query = new GetActivityIdsForSampleStratumQuery(zoneTableName, zoneId, schoolTypeId, beginDate, endDate);
+ query = new GetActivityIdsForSampleStratumQuery(zoneTableName, zoneId, schoolTypeIds, beginDate, endDate);
}
return topiaSqlSupport.findMultipleResult(query);
}
-// public Set<Species> getAllSpeciesFromCorrectedCatches(Activity activity) {
-// Set<Species> result = new HashSet<>();
-// for (CorrectedElementaryCatch aCatch : activity.getCorrectedElementaryCatch()) {
-// result.add(aCatch.getSpecies());
-// }
-// return result;
-// }
-
-// public Set<Species> getAllSpeciesFromSetSpeciesFrequencies(Activity activity) {
-// Set<Species> result = new HashSet<>();
-// for (SetSpeciesFrequency frequency : activity.getSetSpeciesFrequency()) {
-// result.add(frequency.getSpecies());
-// }
-// return result;
-// }
-
/**
* Query to obtain from the given configuration, all the activity ids of a catch stratum.
*
* @since 1.0
*/
+ @SuppressWarnings("SqlResolve")
public static class GetActivityIdsInZoneForCatchStratumQuery extends TopiaSqlQuery<String> {
private final String zoneTableName;
-
private final String zoneId;
-
- private final String schoolTypeId;
-
+ private final Set<String> schoolTypeIds;
private final T3Date beginDate;
-
private final T3Date endDate;
GetActivityIdsInZoneForCatchStratumQuery(String zoneTableName,
String zoneId,
- String schoolTypeId,
+ Set<String> schoolTypeIds,
T3Date beginDate,
T3Date endDate) {
this.zoneTableName = zoneTableName;
this.zoneId = zoneId;
- this.schoolTypeId = schoolTypeId;
+ this.schoolTypeIds = schoolTypeIds;
this.beginDate = beginDate;
this.endDate = endDate;
}
@Override
public PreparedStatement prepareQuery(Connection connection) throws SQLException {
+ StringBuilder schoolTypeParameters = new StringBuilder();
+ for (String ignored : schoolTypeIds) {
+ schoolTypeParameters.append(", ?");
+ }
PreparedStatement ps = connection.prepareStatement(
- "SELECT a.topiaid FROM trip t, activity a, " +
- zoneTableName + " z WHERE " +
- "a.trip = t.topiaId " +
+ "SELECT a.topiaid FROM trip t, activity a, " + zoneTableName + " z " +
+ "WHERE a.trip = t.topiaId " +
"AND t." + Trip.PROPERTY_TRIP_TYPE + " IN (0, 2)" +
"AND t." + Trip.PROPERTY_COMPLETION_STATUS + " IS NOT NULL " +
"AND t." + Trip.PROPERTY_COMPLETION_STATUS + " > 0 " +
"AND ST_WITHIN(a.the_geom, z.the_geom) " +
"AND z.topiaid = ? " +
"AND a.expertflag != 0 " +
- "AND a.schooltype = ? " +
+ "AND a.schooltype IN (" + schoolTypeParameters.substring(2) + ")" +
"AND a.date::date >= ? " +
"AND a.date::date <= ? " +
"AND (SELECT COUNT(*) FROM CorrectedElementaryCatch c WHERE c.activity = a.topiaid) > 0"
);
- ps.setString(1, zoneId);
- ps.setString(2, schoolTypeId);
- ps.setDate(3, beginDate.toBeginSqlDate());
- ps.setDate(4, endDate.toEndSqlDate());
+ int index = 0;
+ ps.setString(++index, zoneId);
+ for (String schoolTypeId : schoolTypeIds) {
+ ps.setString(++index, schoolTypeId);
+ }
+ ps.setDate(++index, beginDate.toBeginSqlDate());
+ ps.setDate(++index, endDate.toEndSqlDate());
return ps;
}
@@ -349,37 +298,37 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv
}
/**
- * Query to obtain from the given configuration, all the activity ids of a
- * catch stratum.
+ * Query to obtain from the given configuration, all the activity ids of a catch stratum.
*
* @since 1.0
*/
+ @SuppressWarnings("SqlResolve")
public static class GetActivityIdsInBorderForCatchStratumQuery extends TopiaSqlQuery<String> {
private final String zoneTableName;
-
private final String zoneId;
-
- private final String schoolTypeId;
-
+ private final Set<String> schoolTypeIds;
private final T3Date beginDate;
-
private final T3Date endDate;
GetActivityIdsInBorderForCatchStratumQuery(String zoneTableName,
String zoneId,
- String schoolTypeId,
+ Set<String> schoolTypeIds,
T3Date beginDate,
T3Date endDate) {
this.zoneTableName = zoneTableName;
this.zoneId = zoneId;
- this.schoolTypeId = schoolTypeId;
+ this.schoolTypeIds = schoolTypeIds;
this.beginDate = beginDate;
this.endDate = endDate;
}
@Override
public PreparedStatement prepareQuery(Connection connection) throws SQLException {
+ StringBuilder schoolTypeParameters = new StringBuilder();
+ for (String ignored : schoolTypeIds) {
+ schoolTypeParameters.append(", ?");
+ }
PreparedStatement ps = connection.prepareStatement(
"SELECT a.topiaid FROM trip t, activity a, " +
zoneTableName + " z WHERE " +
@@ -391,16 +340,18 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv
"AND NOT ST_WITHIN(a.the_geom, z.the_geom) " +
"AND z.topiaid = ? " +
"AND a.expertflag != 0 " +
- "AND a.schooltype = ? " +
+ "AND a.schooltype = IN (" + schoolTypeParameters.substring(2) + ") " +
"AND a.date::date >= ? " +
"AND a.date::date <= ? " +
- "AND (SELECT COUNT(*) FROM CorrectedElementaryCatch c WHERE c.activity = a.topiaid) > 0"
- );
+ "AND (SELECT COUNT(*) FROM CorrectedElementaryCatch c WHERE c.activity = a.topiaid) > 0");
- ps.setString(1, zoneId);
- ps.setString(2, schoolTypeId);
- ps.setDate(3, beginDate.toBeginSqlDate());
- ps.setDate(4, endDate.toEndSqlDate());
+ int index = 0;
+ ps.setString(++index, zoneId);
+ for (String schoolTypeId : schoolTypeIds) {
+ ps.setString(++index, schoolTypeId);
+ }
+ ps.setDate(++index, beginDate.toBeginSqlDate());
+ ps.setDate(++index, endDate.toEndSqlDate());
return ps;
}
@@ -411,37 +362,37 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv
}
/**
- * Query to obtain from the given configuration, all the activity ids of a
- * sample stratum.
+ * Query to obtain from the given configuration, all the activity ids of a sample stratum.
*
* @since 1.0
*/
+ @SuppressWarnings("SqlResolve")
public static class GetActivityIdsForSampleStratumQuery extends TopiaSqlQuery<String> {
private final String zoneTableName;
-
private final String zoneId;
-
- private final String schoolTypeId;
-
+ private final Set<String> schoolTypeIds;
private final T3Date beginDate;
-
private final T3Date endDate;
GetActivityIdsForSampleStratumQuery(String zoneTableName,
String zoneId,
- String schoolTypeId,
+ Set<String> schoolTypeIds,
T3Date beginDate,
T3Date endDate) {
this.zoneTableName = zoneTableName;
this.zoneId = zoneId;
- this.schoolTypeId = schoolTypeId;
+ this.schoolTypeIds = schoolTypeIds;
this.beginDate = beginDate;
this.endDate = endDate;
}
@Override
public PreparedStatement prepareQuery(Connection connection) throws SQLException {
+ StringBuilder schoolTypeParameters = new StringBuilder();
+ for (String ignored : schoolTypeIds) {
+ schoolTypeParameters.append(", ?");
+ }
PreparedStatement ps = connection.prepareStatement(
"SELECT a.topiaid FROM trip t, activity a, " +
zoneTableName + " z WHERE " +
@@ -451,15 +402,17 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv
"AND t." + Trip.PROPERTY_COMPLETION_STATUS + " > 0 ))" +
"AND ST_WITHIN(a.the_geom, z.the_geom) " +
"AND z.topiaid = ? " +
- "AND a.schooltype = ?" +
+ "AND a.schooltype = IN (" + schoolTypeParameters.substring(2) + ")" +
"AND a.date::date >= ? " +
"AND a.date::date <= ? " +
- "AND (SELECT COUNT(*) FROM SetSpeciesCatWeight c WHERE c.activity = a.topiaid) > 0"
- );
- ps.setString(1, zoneId);
- ps.setString(2, schoolTypeId);
- ps.setDate(3, beginDate.toBeginSqlDate());
- ps.setDate(4, endDate.toEndSqlDate());
+ "AND (SELECT COUNT(*) FROM SetSpeciesCatWeight c WHERE c.activity = a.topiaid) > 0");
+ int index = 0;
+ ps.setString(++index, zoneId);
+ for (String schoolTypeId : schoolTypeIds) {
+ ps.setString(++index, schoolTypeId);
+ }
+ ps.setDate(++index, beginDate.toBeginSqlDate());
+ ps.setDate(++index, endDate.toEndSqlDate());
return ps;
}
@@ -471,25 +424,19 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv
/**
* Query to obtain from the given configuration, all the activity ids of a
- * sample stratum for any school type (used by level 3 last substitution
- * level).
+ * sample stratum for any school type (used by level 3 last substitution level).
*
* @since 1.4
*/
+ @SuppressWarnings("SqlResolve")
public static class GetActivityIdsForSampleStratumWithAnySchoolTypeQuery extends TopiaSqlQuery<String> {
private final String zoneTableName;
-
private final String zoneId;
-
private final T3Date beginDate;
-
private final T3Date endDate;
- GetActivityIdsForSampleStratumWithAnySchoolTypeQuery(String zoneTableName,
- String zoneId,
- T3Date beginDate,
- T3Date endDate) {
+ GetActivityIdsForSampleStratumWithAnySchoolTypeQuery(String zoneTableName, String zoneId, T3Date beginDate, T3Date endDate) {
this.zoneTableName = zoneTableName;
this.zoneId = zoneId;
this.beginDate = beginDate;
@@ -524,11 +471,11 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv
}
/**
- * Query to obtain from the given configuration, all the activity ids of a
- * sample stratum.
+ * Query to obtain from the given configuration, all the activity ids of a sample stratum.
*
* @since 1.4
*/
+ @SuppressWarnings("SqlResolve")
public static class GetActivityIdsAndNbZonesQuery extends TopiaSqlQuery<Integer> {
private final String zoneTableName;
@@ -542,12 +489,10 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv
@Override
public PreparedStatement prepareQuery(Connection connection) throws SQLException {
PreparedStatement ps = connection.prepareStatement(
- "SELECT count(*) " +
- "FROM activity a, " + zoneTableName + " z " +
+ "SELECT count(*) FROM activity a, " + zoneTableName + " z " +
"WHERE a.topiaId = ? " +
"AND ST_INTERSECTS(a.the_geom, z.the_geom) " +
- "AND z.schoolType = a.schoolType"
- );
+ "AND z.schoolType = a.schoolType");
ps.setString(1, activityId);
return ps;
}
@@ -557,10 +502,61 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv
return set.getInt(1);
}
- public int getNbZones(TopiaSqlSupport context, String activityId) throws TopiaException {
+ int getNbZones(TopiaSqlSupport context, String activityId) {
this.activityId = activityId;
return context.findSingleResult(this);
}
}
+
+// public boolean isActivityWithSample(Activity activity) {
+// SampleSetTopiaDao sampleSetDAO = topiaDaoSupplier.getDao(SampleSet.class, SampleSetTopiaDao.class);
+// List<SampleSet> allByActivity = sampleSetDAO.forActivityEquals(activity).findAll();
+// return CollectionUtils.isNotEmpty(allByActivity);
+// }
+
+// public static void fillWeightsFromCorrectedCatchesWeight(Activity activity,
+// Map<WeightCategoryTreatment, Map<Species, Float>> weights,
+// WeightCompositionAggregateModel model) {
+//
+// if (weights == null) {
+// weights = new HashMap<>();
+// }
+// Multimap<WeightCategoryTreatment, CorrectedElementaryCatch> data =
+// ActivityTopiaDao.groupByWeightCategoryTreatment(activity.getCorrectedElementaryCatch());
+//
+// T3IOUtil.fillMapWithDefaultValue(
+// weights, data.keySet(), T3Suppliers.MAP_SPECIES_FLOAT_SUPPLIER);
+//
+// for (WeightCategoryTreatment weightCategory : data.keySet()) {
+//
+// Map<Species, Float> speciesFloatMap = weights.get(weightCategory);
+//
+// Collection<CorrectedElementaryCatch> correctedElementaryCatches = data.get(weightCategory);
+//
+// fillWeights(weightCategory,
+// correctedElementaryCatches,
+// speciesFloatMap,
+// T3Functions.CORRECTED_ELEMENTARY_CATCH_TO_CORRECTED_CATCH_WEIGHT,
+// model
+// );
+// }
+// }
+
+// public Set<Species> getAllSpeciesFromCorrectedCatches(Activity activity) {
+// Set<Species> result = new HashSet<>();
+// for (CorrectedElementaryCatch aCatch : activity.getCorrectedElementaryCatch()) {
+// result.add(aCatch.getSpecies());
+// }
+// return result;
+// }
+
+// public Set<Species> getAllSpeciesFromSetSpeciesFrequencies(Activity activity) {
+// Set<Species> result = new HashSet<>();
+// for (SetSpeciesFrequency frequency : activity.getSetSpeciesFrequency()) {
+// result.add(frequency.getSpecies());
+// }
+// return result;
+// }
+
}
=====================================
t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractSchoolTypeTopiaDao.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractSchoolTypeTopiaDao.java
+++ b/t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractSchoolTypeTopiaDao.java
@@ -27,9 +27,13 @@ import java.util.Set;
public class AbstractSchoolTypeTopiaDao<E extends SchoolType> extends GeneratedSchoolTypeTopiaDao<E> {
+ public static final String SCHOOL_TYPE_INDETERMINATE_ID = "fr.ird.t3.entities.reference.SchoolType#1297580528908#0.9747685881931636";
+ public static final String SCHOOL_TYPE_BL_ID = "fr.ird.t3.entities.reference.SchoolType#1297580528908#0.633774803291473";
+ public static final String SCHOOL_TYPE_BO_ID = "fr.ird.t3.entities.reference.SchoolType#1297580528908#0.8923578380543445";
+
/**
- * Obtain the two school types usabel while doing level 2 and 3 : says the
- * free school type (code = 1) and the object school type.
+ * Obtain the two school types usable while doing level 2 and 3 : says the
+ * free school type and the object school type.
*
* @return the two school types
* @throws TopiaException if any problem while loading data form database
@@ -37,9 +41,8 @@ public class AbstractSchoolTypeTopiaDao<E extends SchoolType> extends GeneratedS
@SuppressWarnings("unused")
public Set<E> findAllForStratum() {
Set<E> result = new HashSet<>();
- result.add(forCodeEquals(1).findUnique());
- result.add(forCodeEquals(2).findUnique());
- result.add(forCodeEquals(3).findUnique());
+ result.add(forTopiaIdEquals(SCHOOL_TYPE_BL_ID).findUnique());
+ result.add(forTopiaIdEquals(SCHOOL_TYPE_BO_ID).findUnique());
return result;
}
}
=====================================
t3-domain/src/main/resources/i18n/t3-domain_en_GB.properties
=====================================
--- a/t3-domain/src/main/resources/i18n/t3-domain_en_GB.properties
+++ b/t3-domain/src/main/resources/i18n/t3-domain_en_GB.properties
@@ -164,6 +164,7 @@ t3.config.treatment.working.directory.description=Location of treatment director
t3.config.users.file.description=Application users file
t3.enum.fr.ird.t3.actions.stratum.SchoolTypeIndeterminate.ALL_IN_BL=Use Free school type
t3.enum.fr.ird.t3.actions.stratum.SchoolTypeIndeterminate.ALL_IN_BO=Use Object school type
+t3.enum.fr.ird.t3.actions.stratum.SchoolTypeIndeterminate.IGNORE=Do not process
t3.enum.fr.ird.t3.entities.data.TripType.LOGBOOKMISSING=Without Logbook
t3.enum.fr.ird.t3.entities.data.TripType.SAMPLEONLY=Samples only
t3.enum.fr.ird.t3.entities.data.TripType.STANDARD=Standard
=====================================
t3-domain/src/main/resources/i18n/t3-domain_fr_FR.properties
=====================================
--- a/t3-domain/src/main/resources/i18n/t3-domain_fr_FR.properties
+++ b/t3-domain/src/main/resources/i18n/t3-domain_fr_FR.properties
@@ -164,6 +164,7 @@ t3.config.treatment.working.directory.description=Répertoire de travail
t3.config.users.file.description=Fichier contenant les utilisateurs de l'application
t3.enum.fr.ird.t3.actions.stratum.SchoolTypeIndeterminate.ALL_IN_BL=Traiter comme des Bancs objets
t3.enum.fr.ird.t3.actions.stratum.SchoolTypeIndeterminate.ALL_IN_BO=Traiter comme des Bancs libres
+t3.enum.fr.ird.t3.actions.stratum.SchoolTypeIndeterminate.IGNORE=Ne pas traiter
t3.enum.fr.ird.t3.entities.data.TripType.LOGBOOKMISSING=Sans logbook
t3.enum.fr.ird.t3.entities.data.TripType.SAMPLEONLY=Echantillons uniquement
t3.enum.fr.ird.t3.entities.data.TripType.STANDARD=Standard
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/compare/4da9d0675c8366899e420a487f952b0…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/compare/4da9d0675c8366899e420a487f952b0…
You're receiving this email because of your account on gitlab.com.
1
0
[Git][ultreiaio/ird-t3][develop] 2 commits: [N2][N3] Les calées de type banc indéterminé ne sont pas traitées au N2 et N3 (See #261)
by Tony CHEMIT 07 Mar '18
by Tony CHEMIT 07 Mar '18
07 Mar '18
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
8b1c7688 by Tony CHEMIT at 2018-03-07T17:07:54Z
[N2][N3] Les calées de type banc indéterminé ne sont pas traitées au N2 et N3 (See #261)
- - - - -
4da9d067 by Tony CHEMIT at 2018-03-07T17:46:57Z
[N2][N3] Stockage des niveaux de substitution atteints (See #269)
- - - - -
30 changed files:
- t3-actions/src/main/java/fr/ird/t3/actions/data/level1/ExtrapolateSampleWeightToSetAction.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/Level2Action.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/Level3Action.java
- t3-actions/src/main/resources/i18n/t3-actions_en_GB.properties
- t3-actions/src/main/resources/i18n/t3-actions_fr_FR.properties
- t3-domain/pom.xml
- t3-domain/src/main/java/fr/ird/t3/actions/stratum/LevelConfigurationWithStratum.java
- t3-domain/src/main/java/fr/ird/t3/actions/stratum/SampleStratum.java
- t3-domain/src/main/java/fr/ird/t3/actions/stratum/SampleStratumLoader.java
- + t3-domain/src/main/java/fr/ird/t3/actions/stratum/SchoolTypeIndeterminate.java
- t3-domain/src/main/java/fr/ird/t3/actions/stratum/StratumConfiguration.java
- t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractSchoolTypeTopiaDao.java
- t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractWeightCategoryTreatmentTopiaDao.java
- t3-domain/src/main/java/fr/ird/t3/services/migration/T3MigrationCallbackV2_3.java
- + t3-domain/src/main/resources/db/migration/V_2_3_05_change-Activity-stratum-type.sql
- t3-domain/src/main/resources/i18n/t3-domain_en_GB.properties
- t3-domain/src/main/resources/i18n/t3-domain_fr_FR.properties
- t3-domain/src/main/xmi/t3-persistence.properties
- t3-domain/src/main/xmi/t3-persistence.zargo
- t3-web/src/main/java/fr/ird/t3/web/actions/AbstractConfigureAction.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
The diff was not included because it is too large.
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/compare/905efdb2084a861b9b5155fafe49526…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/compare/905efdb2084a861b9b5155fafe49526…
You're receiving this email because of your account on gitlab.com.
1
0