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
March 2018
- 1 participants
- 153 discussions
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
[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 07 Mar '18
by Tony CHEMIT 07 Mar '18
07 Mar '18
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
905efdb2 by Tony CHEMIT at 2018-03-07T13:36:24Z
[N2][N3] Les calées de type banc indéterminé ne sont pas traitées au N2 et N3 (See #261)
- - - - -
29 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/resources/i18n/t3-domain_en_GB.properties
- t3-domain/src/main/resources/i18n/t3-domain_fr_FR.properties
- 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
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/ConfigureLevel2Step2Action.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/Level2ConfigureAction.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/Level2RunAction.java
The diff was not included because it is too large.
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/905efdb2084a861b9b5155fafe495262…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/905efdb2084a861b9b5155fafe495262…
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 07 Mar '18
by Tony CHEMIT 07 Mar '18
07 Mar '18
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
c3d57275 by Tony CHEMIT at 2018-03-07T13:35:54Z
[N2][N3] Les calées de type banc indéterminé ne sont pas traitées au N2 et N3 (See #261)
- - - - -
29 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/resources/i18n/t3-domain_en_GB.properties
- t3-domain/src/main/resources/i18n/t3-domain_fr_FR.properties
- 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
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/ConfigureLevel2Step2Action.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/Level2ConfigureAction.java
- t3-web/src/main/java/fr/ird/t3/web/actions/data/level2/Level2RunAction.java
The diff was not included because it is too large.
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/c3d572752c219a2d145ac88cbdb4bb5c…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/c3d572752c219a2d145ac88cbdb4bb5c…
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:
121988c6 by Tony CHEMIT at 2018-03-07T12:15:41Z
Improve test API
- - - - -
69e4068c by Tony CHEMIT at 2018-03-07T12:16:19Z
clean and improve code
- - - - -
8ac03c14 by Tony CHEMIT at 2018-03-07T13:28:28Z
[N2][N3] Les calées de type banc indéterminé ne sont pas traitées au N2 et N3 (See #261)
- - - - -
11 changed files:
- t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/FakeT3AvdthServiceContext.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/src/main/java/fr/ird/t3/actions/stratum/SchoolTypeIndeterminate.java
- t3-domain/src/main/java/fr/ird/t3/entities/T3TopiaApplicationContext.java
- t3-domain/src/main/java/fr/ird/t3/models/LengthCompositionModelHelper.java
- t3-domain/src/main/java/fr/ird/t3/services/DecoratorService.java
- t3-domain/src/main/java/fr/ird/t3/services/T3ServiceSupport.java
- t3-domain/src/main/java/fr/ird/t3/services/UserService.java
- t3-domain/src/test/java/fr/ird/t3/entities/reference/WeightCategoryTreatmentImplTest.java
- t3-test/src/main/java/fr/ird/t3/FakeT3ServiceContext.java
Changes:
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/FakeT3AvdthServiceContext.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/FakeT3AvdthServiceContext.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/FakeT3AvdthServiceContext.java
@@ -24,7 +24,6 @@ import fr.ird.t3.T3Config;
import fr.ird.t3.T3ConfigOption;
import fr.ird.t3.T3IOUtil;
import fr.ird.t3.entities.T3EntityHelper;
-import fr.ird.t3.entities.T3JdbcHelper;
import fr.ird.t3.entities.T3TopiaApplicationContext;
import fr.ird.t3.entities.T3TopiaPersistenceContext;
import fr.ird.t3.entities.user.T3Users;
@@ -33,7 +32,6 @@ import fr.ird.t3.services.T3ServiceContext;
import fr.ird.t3.services.T3ServiceFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.junit.Assume;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
import org.mockito.Mockito;
@@ -43,7 +41,6 @@ import org.nuiton.version.Version;
import java.io.Closeable;
import java.io.File;
-import java.nio.file.Path;
import java.util.Date;
import java.util.Locale;
import java.util.Properties;
@@ -63,7 +60,6 @@ public class FakeT3AvdthServiceContext extends TestWatcher implements T3ServiceC
private final boolean injectReferential;
protected T3TopiaPersistenceContext transaction;
private T3TopiaApplicationContext rootContext;
- private T3Users t3Users;
private File testDir;
private T3Config applicationConfiguration;
private Locale locale;
@@ -71,26 +67,15 @@ public class FakeT3AvdthServiceContext extends TestWatcher implements T3ServiceC
private boolean initOk;
private MSAccessTestConfiguration msConfig;
- public FakeT3AvdthServiceContext() {
- this(false);
- }
-
- public FakeT3AvdthServiceContext(boolean injectReferential) {
- this.injectReferential = injectReferential;
- }
-
public FakeT3AvdthServiceContext(boolean injectReferential, MSAccessTestConfiguration msConfig) {
this.injectReferential = injectReferential;
this.msConfig = msConfig;
+ setLocale(Locale.FRANCE);
}
@Override
public T3Users getT3Users() {
- return t3Users;
- }
-
- public void setT3Users(T3Users t3Users) {
- this.t3Users = t3Users;
+ return null;
}
public boolean isInitOk() {
@@ -116,7 +101,7 @@ public class FakeT3AvdthServiceContext extends TestWatcher implements T3ServiceC
return rootContext;
}
- public T3TopiaPersistenceContext newTransaction() throws TopiaException {
+ private T3TopiaPersistenceContext newTransaction() throws TopiaException {
return rootContext.newPersistenceContext();
}
@@ -167,14 +152,12 @@ public class FakeT3AvdthServiceContext extends TestWatcher implements T3ServiceC
protected void starting(Description description) {
super.starting(description);
testName = description.getMethodName();
-
testDir = T3IOUtil.getTestSpecificDirectory(description.getTestClass(), description.getMethodName());
log.info(String.format("Test dir = %s", testDir));
Properties defaultProps = new Properties();
defaultProps.put(T3ConfigOption.DATA_DIRECTORY.getKey(), testDir);
File treatmentDirectory = new File(testDir, "treatment");
FileUtil.createDirectoryIfNecessary(treatmentDirectory);
-
T3Config realConfiguration = new T3Config(defaultProps) {
@Override
public void init() {
@@ -183,14 +166,12 @@ public class FakeT3AvdthServiceContext extends TestWatcher implements T3ServiceC
};
realConfiguration.init();
Version t3DataVersion = realConfiguration.getT3DataVersion();
-
applicationConfiguration = Mockito.mock(T3Config.class);
Mockito.when(applicationConfiguration.getDataDirectory()).thenReturn(testDir);
Mockito.when(applicationConfiguration.getTreatmentWorkingDirectory()).thenReturn(treatmentDirectory);
Mockito.when(applicationConfiguration.getT3DataVersion()).thenReturn(t3DataVersion);
Mockito.when(applicationConfiguration.getTreatmentWorkingDirectory(Mockito.anyString(), Mockito.anyBoolean())).thenCallRealMethod();
Mockito.when(applicationConfiguration.getApplicationVersion()).thenReturn(realConfiguration.getApplicationVersion());
-
if (msConfig != null) {
boolean b = msConfig.beforeClass() && msConfig.setup(testName);
if (!b) {
@@ -199,19 +180,7 @@ public class FakeT3AvdthServiceContext extends TestWatcher implements T3ServiceC
}
}
try {
- // where to put h2 database
- File dbDirectory = new File(testDir, "h2-database");
- if (injectReferential) {
- Path scriptPath = new File(new File("").getAbsolutePath()).getParentFile().toPath().resolve(".mvn").resolve("cache").resolve("test");
- File scriptsDirectory = T3JdbcHelper.getScriptsDirectory(scriptPath.toFile(), "h2", t3DataVersion);
- String[] list = scriptsDirectory.list((dir, name) -> name.endsWith(".sql") && name.contains("-referential"));
- if (list == null || list.length != 1) {
- throw new IllegalStateException(String.format("Can't find h2 referential db from %s", scriptsDirectory));
- }
- rootContext = T3TopiaApplicationContext.newEmbeddedBackupDb(dbDirectory, scriptsDirectory.toPath().resolve(list[0]).toFile());
- } else {
- rootContext = T3TopiaApplicationContext.newEmbeddedDb(dbDirectory);
- }
+ rootContext = T3TopiaApplicationContext.newTestTopiaApplicationContext(testDir, t3DataVersion, injectReferential);
initOk = true;
} catch (Exception e) {
initOk = false;
=====================================
t3-actions/src/test/java/fr/ird/t3/models/LengthCompositionModelHelperTest.java
=====================================
--- a/t3-actions/src/test/java/fr/ird/t3/models/LengthCompositionModelHelperTest.java
+++ b/t3-actions/src/test/java/fr/ird/t3/models/LengthCompositionModelHelperTest.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%
@@ -102,10 +102,9 @@ public class LengthCompositionModelHelperTest {
models.put(species2, model);
+ DecoratorService decoratorService = serviceContext.newService(DecoratorService.class);
- String s = LengthCompositionModelHelper.decorateModel(
- serviceContext.newService(DecoratorService.class),
- "Mon titre", "Value titre", models);
+ String s = LengthCompositionModelHelper.decorateModel(decoratorService, "Mon titre", "Value titre", models);
if (log.isInfoEnabled()) {
log.info("Result :\n" + s);
}
=====================================
t3-actions/src/test/java/fr/ird/t3/models/WeightCompositionModelHelperTest.java
=====================================
--- a/t3-actions/src/test/java/fr/ird/t3/models/WeightCompositionModelHelperTest.java
+++ b/t3-actions/src/test/java/fr/ird/t3/models/WeightCompositionModelHelperTest.java
@@ -20,7 +20,6 @@
*/
package fr.ird.t3.models;
-import com.google.common.collect.Sets;
import fr.ird.t3.FakeT3ServiceContext;
import fr.ird.t3.T3ActionFixtures;
import fr.ird.t3.entities.reference.Species;
@@ -32,7 +31,6 @@ import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
/**
* To test {@link WeightCompositionModelHelper}.
@@ -54,9 +52,6 @@ public class WeightCompositionModelHelperTest {
Species species1 = fixtures.species1();
Species species2 = fixtures.species2();
- Species species3 = fixtures.species3();
-
- Set<Species> species = Sets.newHashSet(species1, species2, species3);
WeightCompositionAggregateModel model = new WeightCompositionAggregateModel();
WeightCompositionModel model1 = new WeightCompositionModel(fixtures.weightCategoryTreatment1());
@@ -80,9 +75,7 @@ public class WeightCompositionModelHelperTest {
model3.addWeights(weights);
model.addModel(model3);
- String s = WeightCompositionModelHelper.decorateModel(
- serviceContext.newService(DecoratorService.class),
- "Mon titre", model);
+ String s = WeightCompositionModelHelper.decorateModel(serviceContext.newService(DecoratorService.class), "Mon titre", model);
log.info("Result :\n" + s);
}
}
=====================================
t3-domain/src/main/java/fr/ird/t3/actions/stratum/SchoolTypeIndeterminate.java
=====================================
--- /dev/null
+++ b/t3-domain/src/main/java/fr/ird/t3/actions/stratum/SchoolTypeIndeterminate.java
@@ -0,0 +1,9 @@
+package fr.ird.t3.actions.stratum;
+
+/**
+ * Created by tchemit on 07/03/2018.
+ *
+ * @author Tony Chemit - dev(a)tchemit.fr
+ */
+public enum SchoolTypeIndeterminate {
+}
=====================================
t3-domain/src/main/java/fr/ird/t3/entities/T3TopiaApplicationContext.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/entities/T3TopiaApplicationContext.java
+++ b/t3-domain/src/main/java/fr/ird/t3/entities/T3TopiaApplicationContext.java
@@ -10,12 +10,12 @@ package fr.ird.t3.entities;
* 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%
@@ -32,12 +32,14 @@ import org.nuiton.topia.persistence.TopiaConfiguration;
import org.nuiton.topia.persistence.TopiaConfigurationBuilder;
import org.nuiton.topia.persistence.TopiaException;
import org.nuiton.util.RecursiveProperties;
+import org.nuiton.version.Version;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
+import java.nio.file.Path;
import java.util.Objects;
import java.util.Properties;
@@ -47,6 +49,10 @@ public class T3TopiaApplicationContext extends AbstractT3TopiaApplicationContext
private static final String T3_USER_DB_PROPERTIES = "/t3-datadb.properties";
private static final Log log = LogFactory.getLog(T3TopiaApplicationContext.class);
+ private T3TopiaApplicationContext(TopiaConfiguration topiaConfiguration) {
+ super(topiaConfiguration);
+ }
+
/**
* Open a new topia root context from the given jdbc configuration.
*
@@ -83,7 +89,6 @@ public class T3TopiaApplicationContext extends AbstractT3TopiaApplicationContext
return new T3TopiaApplicationContext(topiaConfiguration);
}
-
/**
* Open a new topia root context for the user t3 db using a embedded db (this should be a h2 db).
* <p/>
@@ -110,6 +115,21 @@ public class T3TopiaApplicationContext extends AbstractT3TopiaApplicationContext
return new T3TopiaApplicationContext(topiaConfiguration);
}
+ public static T3TopiaApplicationContext newTestTopiaApplicationContext(File testDir, Version t3DataVersion, boolean injectReferential) throws IOException {
+ File dbDirectory = new File(testDir, "h2-database");
+ if (injectReferential) {
+ Path scriptPath = new File(new File("").getAbsolutePath()).getParentFile().toPath().resolve(".mvn").resolve("cache").resolve("test");
+ File scriptsDirectory = T3JdbcHelper.getScriptsDirectory(scriptPath.toFile(), "h2", t3DataVersion);
+ String[] list = scriptsDirectory.list((dir, name) -> name.endsWith(".sql") && name.contains("-referential"));
+ if (list == null || list.length != 1) {
+ throw new IllegalStateException(String.format("Can't find h2 referential db from %s", scriptsDirectory));
+ }
+ return newEmbeddedBackupDb(dbDirectory, scriptsDirectory.toPath().resolve(list[0]).toFile());
+ } else {
+ return newEmbeddedDb(dbDirectory);
+ }
+ }
+
/**
* Open a new topia root context for the user t3 db using a embedded db (this should be a h2 db).
* <p/>
@@ -119,7 +139,7 @@ public class T3TopiaApplicationContext extends AbstractT3TopiaApplicationContext
* @param backupFile backup file to load in db
* @return the new fresh root context of the db
*/
- public static T3TopiaApplicationContext newEmbeddedBackupDb(File dbLocation, File backupFile) {
+ private static T3TopiaApplicationContext newEmbeddedBackupDb(File dbLocation, File backupFile) {
Properties configuration = new Properties();
@@ -143,8 +163,4 @@ public class T3TopiaApplicationContext extends AbstractT3TopiaApplicationContext
return new T3JdbcHelper(getConfiguration());
}
- private T3TopiaApplicationContext(TopiaConfiguration topiaConfiguration) {
- super(topiaConfiguration);
- }
-
}
=====================================
t3-domain/src/main/java/fr/ird/t3/models/LengthCompositionModelHelper.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/models/LengthCompositionModelHelper.java
+++ b/t3-domain/src/main/java/fr/ird/t3/models/LengthCompositionModelHelper.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%
@@ -21,13 +21,13 @@
package fr.ird.t3.models;
import com.google.common.base.Strings;
-import com.google.common.collect.Lists;
import fr.ird.t3.entities.reference.Species;
+import fr.ird.t3.entities.reference.WeightCategories;
import fr.ird.t3.entities.reference.WeightCategoryTreatment;
-import fr.ird.t3.entities.reference.WeightCategoryTreatmentTopiaDao;
import fr.ird.t3.services.DecoratorService;
import org.nuiton.decorator.Decorator;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -43,7 +43,7 @@ import static org.nuiton.i18n.I18n.l;
* @author Tony Chemit - dev(a)tchemit.fr
* @since 1.3.1
*/
-public class LengthCompositionModelHelper {
+public final class LengthCompositionModelHelper {
private static final Comparator<Species> SPECIES_COMPARATOR = Comparator.comparingInt(Species::getCode);
@@ -55,96 +55,64 @@ public class LengthCompositionModelHelper {
String title,
String valueTitle,
Map<Species, LengthCompositionAggregateModel> models) {
-
StringBuilder inResume = new StringBuilder();
-
Locale locale = decoratorService.getLocale();
-
String lengthClassLabel = l(locale, "t3.common.lengthClass");
-
int lengthClassColumnLength = lengthClassLabel.length();
int valueColumnLength = 15;
int rateColumnLength = 15;
-
- Decorator<Species> decorator =
- decoratorService.getDecorator(locale, Species.class, null);
-
+ Decorator<Species> decorator = decoratorService.getDecorator(locale, Species.class, null);
Decorator<WeightCategoryTreatment> decorator2 =
decoratorService.getDecorator(locale, WeightCategoryTreatment.class, null);
-
- List<Species> speciesList = Lists.newArrayList(models.keySet());
+ List<Species> speciesList = new ArrayList<>(models.keySet());
speciesList.sort(SPECIES_COMPARATOR);
int origMaxLength = 10 + (lengthClassColumnLength) + (valueColumnLength + rateColumnLength);
int maxLength = origMaxLength;
-
maxLength = Math.max(maxLength, l(locale, "t3.common.forAllWeightCategories").length() + 4);
-
for (Species species : speciesList) {
int l = decorator.toString(species).length() + 4;
maxLength = Math.max(maxLength, l);
LengthCompositionAggregateModel model = models.get(species);
-
Set<WeightCategoryTreatment> weightCategories = model.getWeightCategories();
for (WeightCategoryTreatment weightCategory : weightCategories) {
int l2 = l(locale, "t3.common.weightCategory", decorator2.toString(weightCategory)).length() + 4;
maxLength = Math.max(maxLength, l2);
}
}
-
if (maxLength > origMaxLength) {
lengthClassColumnLength += maxLength - origMaxLength;
}
-
CompositionTableModel header = new CompositionTableModel();
String lineFormat = "| %1$-" + lengthClassColumnLength + "s | %2$-" + valueColumnLength + "s - %3$-" + rateColumnLength + "s |\n";
-
header.setLineFormat(lineFormat);
header.setHeader(
String.format("| %1$-" + lengthClassColumnLength + "s | %2$-" + (valueColumnLength + rateColumnLength + 3) + "s |\n", lengthClassLabel, valueTitle));
-
header.setSeparatorFormat3(
Strings.padEnd("|", lengthClassColumnLength + 3, '-') +
Strings.padEnd("|", (valueColumnLength + rateColumnLength + 6), '-') + "|\n");
-
header.setCategoryFormat("| %1$-" + (maxLength - 4) + "s |\n");
header.setSeparatorFormat(Strings.padEnd("|", maxLength - 1, '-') + "|\n");
header.setSeparatorFormat2(Strings.padEnd("|", maxLength - 1, '=') + "|\n");
header.setTopSeparatorFormat(Strings.padEnd("=", maxLength, '=') + "\n");
header.setBottomSeparatorFormat(Strings.padEnd("=", maxLength, '=') + "\n");
-
inResume.append(title).append('\n');
inResume.append(header.getTopSeparatorFormat());
inResume.append(header.getHeader());
-
for (Species species : speciesList) {
-
inResume.append(header.getSeparatorFormat2());
- inResume.append(String.format(header.getCategoryFormat(),
- decorator.toString(species)));
-
+ inResume.append(String.format(header.getCategoryFormat(), decorator.toString(species)));
LengthCompositionAggregateModel model = models.get(species);
-
- List<WeightCategoryTreatment> weightCategories = Lists.newArrayList(model.getWeightCategories());
- weightCategories.sort(WeightCategoryTreatmentTopiaDao.newComparator());
-
+ List<WeightCategoryTreatment> weightCategories = new ArrayList<>(model.getWeightCategories());
+ WeightCategories.sort(weightCategories);
for (WeightCategoryTreatment weightCategory : weightCategories) {
LengthCompositionModel lengthCompositionModel = model.getModel(weightCategory);
if (!lengthCompositionModel.isEmpty()) {
inResume.append(header.getSeparatorFormat());
- decorateModel(
- header,
- decoratorService,
- model,
- weightCategory,
- inResume
- );
+ decorateModel(header, decoratorService, model, weightCategory, inResume);
}
-
}
}
-
inResume.append(header.getBottomSeparatorFormat());
-
return inResume.toString();
}
@@ -153,78 +121,43 @@ public class LengthCompositionModelHelper {
LengthCompositionAggregateModel model,
WeightCategoryTreatment weightCategory,
StringBuilder inResume) {
-
Decorator<WeightCategoryTreatment> decorator2 =
decoratorService.getDecorator(decoratorService.getLocale(), WeightCategoryTreatment.class, null);
-
- LengthCompositionModel m;
-
- String categoryLibelle;
-
Locale locale = decoratorService.getLocale();
-
- String totalLibelle = l(locale, "t3.common.total");
- String averageLengthLibelle = l(locale, "t3.common.averageLength");
-
+ String totalLabel = l(locale, "t3.common.total");
+ String averageLengthLabel = l(locale, "t3.common.averageLength");
+ LengthCompositionModel m;
+ String categoryLabel;
if (weightCategory == null) {
-
m = model.getTotalModel();
- categoryLibelle = l(locale, "t3.common.forAllWeightCategories");
+ categoryLabel = l(locale, "t3.common.forAllWeightCategories");
} else {
m = model.getModel(weightCategory);
-
- categoryLibelle =
- l(locale, "t3.common.weightCategory",
- decorator2.toString(weightCategory));
+ categoryLabel = l(locale, "t3.common.weightCategory", decorator2.toString(weightCategory));
}
-
if (!m.isEmpty()) {
-
- inResume.append(String.format(header.getCategoryFormat(), categoryLibelle));
+ inResume.append(String.format(header.getCategoryFormat(), categoryLabel));
inResume.append(header.getSeparatorFormat());
-
String lineFormat = header.getLineFormat();
-
- List<Integer> lengthClasses = Lists.newArrayList(m.getLengthClasses());
+ List<Integer> lengthClasses = new ArrayList<>(m.getLengthClasses());
Collections.sort(lengthClasses);
-
float totalRate = 0;
float totalCount = 0;
-
float totalLength = 0;
-
for (Integer lengthClass : lengthClasses) {
-
float weightRate1 = m.getRate(lengthClass);
totalRate += weightRate1;
float value = m.getValue(lengthClass);
- inResume.append(String.format(
- lineFormat,
- lengthClass,
- value,
- (100 * weightRate1) + "%"));
+ inResume.append(String.format(lineFormat, lengthClass, value, (100 * weightRate1) + "%"));
totalCount += value;
totalLength += lengthClass * value;
}
-
float averageLength = totalLength / totalCount;
-
inResume.append(header.getSeparatorFormat3());
-
- inResume.append(String.format(
- lineFormat,
- totalLibelle,
- totalCount,
- (100 * totalRate) + "%"));
-
+ inResume.append(String.format(lineFormat, totalLabel, totalCount, (100 * totalRate) + "%"));
if (weightCategory != null) {
- inResume.append(String.format(
- lineFormat,
- averageLengthLibelle,
- averageLength,
- "-"));
+ inResume.append(String.format(lineFormat, averageLengthLabel, averageLength, "-"));
}
-
}
}
}
=====================================
t3-domain/src/main/java/fr/ird/t3/services/DecoratorService.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/services/DecoratorService.java
+++ b/t3-domain/src/main/java/fr/ird/t3/services/DecoratorService.java
@@ -8,21 +8,19 @@
* 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.services;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
+import fr.ird.t3.actions.stratum.SchoolTypeIndeterminate;
import fr.ird.t3.entities.data.Activity;
import fr.ird.t3.entities.data.CompleteTrip;
import fr.ird.t3.entities.data.Route;
@@ -58,11 +56,14 @@ import org.nuiton.decorator.JXPathDecorator;
import org.nuiton.topia.persistence.TopiaEntity;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Objects;
import static org.nuiton.i18n.I18n.l;
@@ -75,85 +76,60 @@ import static org.nuiton.i18n.I18n.l;
public class DecoratorService extends T3ServiceSupport implements T3ServiceSingleton {
public static final String WITH_ID = "withId";
-
+ private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd/MM/yyyy");
private final DecoratorMulti18nProvider decoratorProvider;
- private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd/MM/yyyy");
+ public DecoratorService() {
+ decoratorProvider = new T3DecoratorProvider();
+ }
public static String formatDate(Date date) {
return DATE_FORMAT.format(date);
}
- public DecoratorService() {
- decoratorProvider = new T3DecoratorProvider();
- }
-
- public <O> Decorator<O> getDecorator(Locale locale,
- Class<O> type,
- String context) {
- Preconditions.checkNotNull(type, "Decorator type can not be null!");
- Decorator<O> decorator = decoratorProvider.getDecoratorByType(locale, type, context);
- Preconditions.checkNotNull(
- decorator,
- "Could not find decorator for type " + type +
- " and context " + context
- );
- return decorator;
+ public <O> Decorator<O> getDecorator(Locale locale, Class<O> type, String context) {
+ Decorator<O> decorator = decoratorProvider.getDecoratorByType(Objects.requireNonNull(locale), Objects.requireNonNull(type), context);
+ return Objects.requireNonNull(decorator,
+ String.format("Could not find decorator for type %s and context %s", type, context));
}
public String decorate(Locale locale, Object o, String context) {
- Decorator<?> decorator = getDecorator(locale, o.getClass(), context);
+ Decorator<?> decorator = getDecorator(locale, Objects.requireNonNull(o).getClass(), context);
return decorator.toString(o);
}
public <O> List<O> sortToList(Locale locale, Collection<O> beans, String context) {
- Preconditions.checkNotNull(beans);
- List<O> list = Lists.newArrayList(beans);
+ List<O> list = new ArrayList<>(Objects.requireNonNull(beans));
getDecoratorAndSort(locale, context, list);
return list;
}
- public <E extends TopiaEntity> Map<String, String> sortAndDecorate(Locale locale,
- Collection<E> beans,
- String context) {
- Preconditions.checkNotNull(beans);
- List<E> list = Lists.newArrayList(beans);
-
+ public <E extends TopiaEntity> Map<String, String> sortAndDecorate(Locale locale, Collection<E> beans, String context) {
+ List<E> list = new ArrayList<>(Objects.requireNonNull(beans));
Decorator<E> decorator = getDecoratorAndSort(locale, context, list);
- Map<String, String> result = Maps.newLinkedHashMap();
+ Map<String, String> result = new LinkedHashMap<>();
for (E bean : list) {
result.put(bean.getTopiaId(), decorator.toString(bean));
}
return result;
}
- public <E extends Idable> Map<String, String> sortAndDecorateIdAbles(Locale locale,
- Collection<E> beans,
- String context) {
-
- Preconditions.checkNotNull(beans);
- List<E> list = Lists.newArrayList(beans);
-
+ public <E extends Idable> Map<String, String> sortAndDecorateIdAbles(Locale locale, Collection<E> beans, String context) {
+ List<E> list = new ArrayList<>(Objects.requireNonNull(beans));
Decorator<E> decorator = getDecoratorAndSort(locale, context, list);
- Map<String, String> result = Maps.newLinkedHashMap();
+ Map<String, String> result = new LinkedHashMap<>();
for (E bean : list) {
result.put(bean.getId(), decorator.toString(bean));
}
return result;
}
- protected <O> Decorator<O> getDecoratorAndSort(Locale locale,
- String context,
- List<O> list) {
+ private <O> Decorator<O> getDecoratorAndSort(Locale locale, String context, List<O> list) {
Decorator<O> decorator = null;
if (CollectionUtils.isNotEmpty(list)) {
- O object = list.get(0);
- Preconditions.checkNotNull(object);
- decorator = decoratorProvider.getDecorator(locale, object, context);
- Preconditions.checkNotNull(
- decorator,
- "Could not find decorator for type " + object.getClass() +
- " and context " + context
+ O object = Objects.requireNonNull(list.get(0));
+ decorator = Objects.requireNonNull(decoratorProvider.getDecorator(locale, object, context),
+ String.format("Could not find decorator for type %s and context %s", object.getClass(), context)
);
DecoratorUtil.sort((JXPathDecorator<O>) decorator, list, 0);
}
@@ -171,6 +147,9 @@ public class DecoratorService extends T3ServiceSupport implements T3ServiceSingl
// trip type decorator
registerJXPathDecorator(locale, TripType.class, "${label}$s");
+ // SchoolTypeIndeterminate decorator
+ registerJXPathDecorator(locale, SchoolTypeIndeterminate.class, "${label}$s");
+
// route decorator
registerJXPathDecorator(locale, Route.class, "${trip/vesselLabel}$s - ${trip/landingDate}$td/%2$tm/%2$tY - ${date}$td/%3$tm/%3$tY");
@@ -259,20 +238,17 @@ public class DecoratorService extends T3ServiceSupport implements T3ServiceSingl
private static class ZoneStratumAwareMetaJXPathDecorator extends JXPathDecorator<ZoneStratumAwareMeta> {
private static final long serialVersionUID = 1L;
-
private final Locale locale;
- public ZoneStratumAwareMetaJXPathDecorator(String expression,
- Context<ZoneStratumAwareMeta> context,
- Locale locale) throws IllegalArgumentException, NullPointerException {
+ ZoneStratumAwareMetaJXPathDecorator(String expression, Context<ZoneStratumAwareMeta> context, Locale locale) {
super(ZoneStratumAwareMeta.class, expression, context);
this.locale = locale;
}
@SuppressWarnings({"RawUseOfParameterizedType", "RedundantCast", "unchecked"})
@Override
- protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) {
- Comparable tokenValue = super.getTokenValue(jxcontext, token);
+ protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxContext, String token) {
+ Comparable tokenValue = super.getTokenValue(jxContext, token);
return (Comparable) l(locale, (String) tokenValue);
}
}
=====================================
t3-domain/src/main/java/fr/ird/t3/services/T3ServiceSupport.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/services/T3ServiceSupport.java
+++ b/t3-domain/src/main/java/fr/ird/t3/services/T3ServiceSupport.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%
@@ -22,14 +22,13 @@ package fr.ird.t3.services;
import fr.ird.t3.T3Config;
import fr.ird.t3.entities.T3TopiaPersistenceContext;
-
-import java.util.Locale;
-import java.util.function.Supplier;
-
import fr.ird.t3.entities.user.T3Users;
import org.nuiton.topia.persistence.TopiaException;
import org.nuiton.util.TimeLog;
+import java.util.Locale;
+import java.util.function.Supplier;
+
/**
* Service support.
*
@@ -38,16 +37,15 @@ import org.nuiton.util.TimeLog;
*/
public class T3ServiceSupport implements T3Service {
- protected TimeLog timeLog;
-
protected T3ServiceContext serviceContext;
+ private TimeLog timeLog;
@Override
public void setServiceContext(T3ServiceContext serviceContext) {
this.serviceContext = serviceContext;
}
- public T3Users getT3UserStorage() {
+ public T3Users getT3Users() {
return serviceContext.getT3Users();
}
@@ -71,20 +69,10 @@ public class T3ServiceSupport implements T3Service {
return serviceContext.newService(clazz);
}
- protected void flushTransaction(String message) throws TopiaException {
+ protected void flushTransaction(String classifier) throws TopiaException {
long s0 = TimeLog.getTime();
-
getT3TopiaPersistenceContext().get().getHibernateSupport().getHibernateSession().flush();
-
- getTimeLog().log(s0, message);
- }
-
- protected void flushTransaction(String message, String classifier) throws TopiaException {
- long s0 = TimeLog.getTime();
-
- getT3TopiaPersistenceContext().get().getHibernateSupport().getHibernateSession().flush();
-
- getTimeLog().log(s0, message, classifier);
+ getTimeLog().log(s0, "Flush transaction for trip", classifier);
}
protected TimeLog getTimeLog() {
=====================================
t3-domain/src/main/java/fr/ird/t3/services/UserService.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/services/UserService.java
+++ b/t3-domain/src/main/java/fr/ird/t3/services/UserService.java
@@ -41,15 +41,15 @@ import java.util.UUID;
public class UserService extends T3ServiceSupport implements T3ServiceInjectable {
public Optional<T3User> getUserByLogin(String login) {
- return getT3UserStorage().usersStream().whereLogin().isEquals(login).filter().findFirst();
+ return getT3Users().usersStream().whereLogin().isEquals(login).filter().findFirst();
}
public T3User getUserById(String userId) throws TopiaNotFoundException {
- return getT3UserStorage().usersStream().whereId().isEquals(userId).filter().findFirst().orElseThrow(() -> new TopiaNotFoundException(userId));
+ return getT3Users().usersStream().whereId().isEquals(userId).filter().findFirst().orElseThrow(() -> new TopiaNotFoundException(userId));
}
public List<T3User> getUsers() {
- return getT3UserStorage().getUsers();
+ return getT3Users().getUsers();
}
public void createUser(T3User user) {
@@ -61,7 +61,7 @@ public class UserService extends T3ServiceSupport implements T3ServiceInjectable
.login(user.getLogin())
.password(newPassword)
.build();
- getT3UserStorage().getUsers().add(userToSave);
+ getT3Users().getUsers().add(userToSave);
user.setId(userToSave.getId());
commit();
}
@@ -82,7 +82,7 @@ public class UserService extends T3ServiceSupport implements T3ServiceInjectable
public void deleteUser(String userId) {
T3User user = getUserById(userId);
- getT3UserStorage().getUsers().remove(user);
+ getT3Users().getUsers().remove(user);
commit();
}
@@ -139,11 +139,11 @@ public class UserService extends T3ServiceSupport implements T3ServiceInjectable
}
public UserDatabase getUserInputDatabase(String dbConfigurationId) {
- return getT3UserStorage().getInput(dbConfigurationId);
+ return getT3Users().getInput(dbConfigurationId);
}
public UserDatabase getUserOutputDatabase(String dbConfigurationId) {
- return getT3UserStorage().getOutput(dbConfigurationId);
+ return getT3Users().getOutput(dbConfigurationId);
}
public boolean checkPassword(T3User user, String password) {
@@ -162,7 +162,7 @@ public class UserService extends T3ServiceSupport implements T3ServiceInjectable
}
private void commit() {
- getT3UserStorage().save();
+ getT3Users().save();
}
}
=====================================
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
@@ -76,7 +76,7 @@ public class WeightCategoryTreatmentImplTest extends AbstractDatabaseTest {
list.add(catInconnu);
list.add(catBound);
- WeightCategoryTreatmentTopiaDao.sortWeightCategoryTreatments(list);
+ WeightCategories.sort(list);
Assert.assertEquals(list.get(0), catBound);
Assert.assertEquals(list.get(1), catUnbound);
@@ -113,8 +113,7 @@ public class WeightCategoryTreatmentImplTest extends AbstractDatabaseTest {
list.add(catInconnu);
list.add(catBound);
- Comparator<WeightCategoryTreatment> comparator =
- WeightCategoryTreatmentTopiaDao.newComparator();
+ Comparator<WeightCategory> comparator =WeightCategories.newComparator();
int compare;
@@ -127,7 +126,7 @@ public class WeightCategoryTreatmentImplTest extends AbstractDatabaseTest {
compare = comparator.compare(catBound2, catUnbound);
Assert.assertTrue(compare < 0);
- WeightCategoryTreatmentTopiaDao.sortWeightCategoryTreatments(list);
+ WeightCategories.sort(list);
Assert.assertEquals(list.get(0), catBound);
Assert.assertEquals(list.get(1), catBound2);
=====================================
t3-test/src/main/java/fr/ird/t3/FakeT3ServiceContext.java
=====================================
--- a/t3-test/src/main/java/fr/ird/t3/FakeT3ServiceContext.java
+++ b/t3-test/src/main/java/fr/ird/t3/FakeT3ServiceContext.java
@@ -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%
@@ -21,7 +21,6 @@
package fr.ird.t3;
import fr.ird.t3.entities.T3EntityHelper;
-import fr.ird.t3.entities.T3JdbcHelper;
import fr.ird.t3.entities.T3TopiaApplicationContext;
import fr.ird.t3.entities.T3TopiaPersistenceContext;
import fr.ird.t3.entities.user.T3Users;
@@ -39,7 +38,6 @@ import org.nuiton.version.Version;
import java.io.Closeable;
import java.io.File;
-import java.nio.file.Path;
import java.util.Date;
import java.util.Locale;
import java.util.Properties;
@@ -59,11 +57,9 @@ public class FakeT3ServiceContext extends TestWatcher implements T3ServiceContex
private final boolean injectReferential;
protected T3TopiaPersistenceContext transaction;
private T3TopiaApplicationContext rootContext;
- private T3Users t3Users;
private File testDir;
private T3Config applicationConfiguration;
private Locale locale;
- private String testName;
private boolean initOk;
public FakeT3ServiceContext() {
@@ -72,15 +68,12 @@ public class FakeT3ServiceContext extends TestWatcher implements T3ServiceContex
public FakeT3ServiceContext(boolean injectReferential) {
this.injectReferential = injectReferential;
+ setLocale(Locale.FRANCE);
}
@Override
public T3Users getT3Users() {
- return t3Users;
- }
-
- public void setT3Users(T3Users t3Users) {
- this.t3Users = t3Users;
+ return null;
}
public boolean isInitOk() {
@@ -148,25 +141,15 @@ public class FakeT3ServiceContext extends TestWatcher implements T3ServiceContex
return testDir;
}
- public String getTestName() {
- return testName;
- }
-
@Override
protected void starting(Description description) {
super.starting(description);
- testName = description.getMethodName();
-
testDir = T3IOUtil.getTestSpecificDirectory(description.getTestClass(), description.getMethodName());
- if (log.isInfoEnabled()) {
- log.info("Test dir = " + testDir);
- }
-
+ log.info(String.format("Test dir = %s", testDir));
Properties defaultProps = new Properties();
defaultProps.put(T3ConfigOption.DATA_DIRECTORY.getKey(), testDir);
File treatmentDirectory = new File(testDir, "treatment");
FileUtil.createDirectoryIfNecessary(treatmentDirectory);
-
T3Config realConfiguration = new T3Config(defaultProps) {
@Override
public void init() {
@@ -175,37 +158,15 @@ public class FakeT3ServiceContext extends TestWatcher implements T3ServiceContex
};
realConfiguration.init();
Version t3DataVersion = realConfiguration.getT3DataVersion();
-
applicationConfiguration = Mockito.mock(T3Config.class);
Mockito.when(applicationConfiguration.getDataDirectory()).thenReturn(testDir);
Mockito.when(applicationConfiguration.getTreatmentWorkingDirectory()).thenReturn(treatmentDirectory);
Mockito.when(applicationConfiguration.getT3DataVersion()).thenReturn(t3DataVersion);
Mockito.when(applicationConfiguration.getTreatmentWorkingDirectory(Mockito.anyString(), Mockito.anyBoolean())).thenCallRealMethod();
Mockito.when(applicationConfiguration.getApplicationVersion()).thenReturn(realConfiguration.getApplicationVersion());
-
try {
-
- // where to put h2 database
- File dbDirectory = new File(testDir, "h2-database");
-
- if (injectReferential) {
- Path scriptPath = new File(new File("").getAbsolutePath()).getParentFile().toPath().resolve(".mvn").resolve("cache").resolve("test");
- File scriptsDirectory = T3JdbcHelper.getScriptsDirectory(scriptPath.toFile(), "h2", t3DataVersion);
-
- String[] list = scriptsDirectory.list((dir, name) -> name.endsWith(".sql") && name.contains("-referential"));
- if (list == null || list.length != 1) {
- throw new IllegalStateException(String.format("Can't find h2 referential db from %s", scriptsDirectory));
- }
- rootContext = T3TopiaApplicationContext.newEmbeddedBackupDb(dbDirectory, scriptsDirectory.toPath().resolve(list[0]).toFile());
- } else {
- rootContext = T3TopiaApplicationContext.newEmbeddedDb(dbDirectory);
- }
-// if (injectReferential) {
-// // inject in db the referentiel
-// T3SqlScriptsImporter.importReferential(new File(""), this, T3SqlScriptsImporter.SKIP_SPECIES_LENGTH_STEP_FILE);
-// }
+ rootContext = T3TopiaApplicationContext.newTestTopiaApplicationContext(testDir, t3DataVersion, injectReferential);
initOk = true;
-
} catch (Exception e) {
initOk = false;
throw new IllegalStateException("Could not start db", e);
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/compare/f6fbda7f307045941f679ac7b5cc91d…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/compare/f6fbda7f307045941f679ac7b5cc91d…
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:
5957afdd by Tony CHEMIT at 2018-03-07T09:47:46Z
clean code
- - - - -
f6fbda7f by Tony CHEMIT at 2018-03-07T09:48:01Z
improve release process (now use ultreia.io magic)
- - - - -
7 changed files:
- t3-domain/src/main/java/fr/ird/t3/io/input/access/T3ReferentielEntityVisitor.java
- + t3-installer/.mvn/add-build-number
- + t3-installer/.mvn/application-assembly
- t3-installer/pom.xml
- t3-installer/src/main/assembly/bin.xml
- + t3-installer/src/main/assembly/i18n.xml
- t3/pom.xml
Changes:
=====================================
t3-domain/src/main/java/fr/ird/t3/io/input/access/T3ReferentielEntityVisitor.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/io/input/access/T3ReferentielEntityVisitor.java
+++ b/t3-domain/src/main/java/fr/ird/t3/io/input/access/T3ReferentielEntityVisitor.java
@@ -39,128 +39,75 @@ import org.nuiton.topia.persistence.TopiaEntity;
*/
public class T3ReferentielEntityVisitor extends AbstractT3EntityVisitor {
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(T3ReferentielEntityVisitor.class);
+ private static final Log log = LogFactory.getLog(T3ReferentielEntityVisitor.class);
- public T3ReferentielEntityVisitor(T3AccessDataSource dataSource, ReferenceEntityMap referentiel) {
+ T3ReferentielEntityVisitor(T3AccessDataSource dataSource, ReferenceEntityMap referentiel) {
super(dataSource, referentiel);
}
@Override
- public void onVisitSimpleProperty(String propertyName,
- Class<?> type,
- T3AccessEntity entity, T3AccessEntityMeta meta) {
+ public void onVisitSimpleProperty(String propertyName, Class<?> type, T3AccessEntity entity, T3AccessEntityMeta meta) {
// just set the property into the entity
-
if (!deepVisit) {
if (!propertyName.equals(meta.getTopiaNaturalId())) {
-
// not a deep visit and not a pKey property name, skip visit
return;
}
}
-
Serializable newValue = getProperty(propertyName, meta, row);
-
if (newValue != null) {
if (log.isDebugEnabled()) {
String colName = meta.getPropertyColumnName(propertyName);
- log.debug("get property [" + propertyName + "] (type:" +
- type.getName() + ") (dbcol:" + colName + ") = " +
- newValue);
+ log.debug(String.format("get property [%s] (type:%s) (dbcol:%s) = %s", propertyName, type.getName(), colName, newValue));
}
entity.setProperty(propertyName, newValue);
}
}
@Override
- public void onVisitComposition(String propertyName,
- Class<?> type,
- T3AccessEntity entity,
- T3AccessEntityMeta meta) {
-
+ public void onVisitComposition(String propertyName, Class<?> type, T3AccessEntity entity, T3AccessEntityMeta meta) {
if (!deepVisit) {
return;
}
-
// find the reference entity to add as composition
Serializable newValue = getProperty(propertyName, meta, row);
if (newValue == null) {
-
// rien a faire si la composition est nulle
return;
}
-
- AbstractAccessEntityMeta.PropertyMapping mapping =
- meta.getPropertyMapping(propertyName);
+ AbstractAccessEntityMeta.PropertyMapping mapping = meta.getPropertyMapping(propertyName);
Class<?> compositionType = mapping.getType();
-
- T3AccessEntityMeta compoMeta;
-
- T3AccessEntityMeta[] compoMetas =
- dataSource.getMetaForType(compositionType);
-
+ T3AccessEntityMeta[] compoMetas = dataSource.getMetaForType(compositionType);
if (compoMetas.length == 0) {
- if (log.isWarnEnabled()) {
- log.warn("Skip composition [" + meta.getType() + " - " +
- propertyName + "], meta of type [" + compositionType +
- "] not found...");
- }
+ log.warn(String.format("Skip composition [%s - %s], meta of type [%s] not found...", meta.getType(), propertyName, compositionType));
return;
}
-
if (compoMetas.length > 1) {
-
- // on n'autorise pas d'avoir plusieurs méta à traiter
- // il s'agit d'une reférence sur un référentiel
+ // on n'autorise pas d'avoir plusieurs méta à traiter - il s'agit d'une reférence sur un référentiel
throw new IllegalStateException(
- "Found more than one meta for referentiel type [" +
- compositionType + "] : " + Arrays.toString(compoMetas));
+ String.format("Found more than one meta for referentiel type [%s] : %s", compositionType, Arrays.toString(compoMetas)));
}
-
- compoMeta = compoMetas[0];
-
+ T3AccessEntityMeta compoMeta = compoMetas[0];
TopiaEntity compoEntity = getReferenceEntity(compoMeta, newValue);
-
if (compoEntity == null) {
-
// could not find the correct composition entity
throw new IllegalStateException(
- "Could not find reference entity of type [" +
- compoMeta.getType() + "] with pKey [" + newValue + "]");
+ String.format("Could not find reference entity of type [%s] with pKey [%s]", compoMeta.getType(), newValue));
}
-
-// // find the correct entity
-// T3AccessEntity toSave = (T3AccessEntity) compoEntity;
-//
-// if (log.isDebugEnabled()) {
-// log.debug("Will add composition [" + propertyName +
-// ":" + toSave + "] to " + entity);
-// }
// then affect it to this entity for the given property
entity.setProperty(propertyName, compoEntity);
}
@Override
- public void onVisitAssociation(String propertyName,
- Class<?> type,
- T3AccessEntity entity,
- T3AccessEntityMeta meta) {
+ public void onVisitAssociation(String propertyName, Class<?> type, T3AccessEntity entity, T3AccessEntityMeta meta) {
// no used for reference entity
- throw new IllegalStateException(
- "Can not visit an association for a reference entity " +
- entity);
+ throw new IllegalStateException(String.format("Can not visit an association for a reference entity %s", entity));
}
@Override
- public void onVisitReverseAssociation(String propertyName,
- T3AccessEntity entity,
- T3AccessEntityMeta meta) {
+ public void onVisitReverseAssociation(String propertyName, T3AccessEntity entity, T3AccessEntityMeta meta) {
// no used for reference entity
- throw new IllegalStateException(
- "Can not visit a reverse association for a reference entity " +
- entity);
+ throw new IllegalStateException(String.format("Can not visit a reverse association for a reference entity %s", entity));
}
}
=====================================
t3-installer/.mvn/add-build-number
=====================================
--- /dev/null
+++ b/t3-installer/.mvn/add-build-number
=====================================
t3-installer/.mvn/application-assembly
=====================================
--- /dev/null
+++ b/t3-installer/.mvn/application-assembly
=====================================
t3-installer/pom.xml
=====================================
--- a/t3-installer/pom.xml
+++ b/t3-installer/pom.xml
@@ -140,48 +140,10 @@
<build>
- <plugins>
-
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <phase>process-classes</phase>
- <configuration>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>true</overWriteSnapshots>
- <overWriteIfNewer>true</overWriteIfNewer>
- <outputDirectory>${project.build.directory}/lib</outputDirectory>
- <silent>true</silent>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
-
<pluginManagement>
<plugins>
<plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <useUniqueVersions>true</useUniqueVersions>
- <addClasspath>true</addClasspath>
- <classpathPrefix>./lib/</classpathPrefix>
- <mainClass>${maven.jar.main.class}</mainClass>
- </manifest>
- </archive>
- </configuration>
- </plugin>
-
- <plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Xms512m -Xmx1512m</argLine>
@@ -291,39 +253,6 @@
</profile>
<profile>
- <id>assembly-profile</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
- <build>
- <defaultGoal>package</defaultGoal>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <descriptors>
- <descriptor>src/main/assembly/bin.xml</descriptor>
- </descriptors>
- <attach>true</attach>
- </configuration>
- <executions>
- <execution>
- <id>create-assemblies</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
<id>run-reference-tools-its</id>
<activation>
<property>
=====================================
t3-installer/src/main/assembly/bin.xml
=====================================
--- a/t3-installer/src/main/assembly/bin.xml
+++ b/t3-installer/src/main/assembly/bin.xml
@@ -28,20 +28,12 @@
<fileSets>
<fileSet>
- <directory>${project.build.directory}/lib</directory>
- <outputDirectory>lib</outputDirectory>
- <fileMode>0755</fileMode>
- <includes>
- <include>*.jar</include>
- </includes>
- </fileSet>
-
- <fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory/>
<fileMode>0755</fileMode>
<includes>
<include>${project.build.finalName}.jar</include>
+ <include>${project.build.finalName}.exe</include>
</includes>
</fileSet>
@@ -55,7 +47,7 @@
</fileSet>
<fileSet>
- <directory>${installer.cache}/t3-data-ddl-${t3-data.version}</directory>
+ <directory>${installer.cache.dir}/t3-data-ddl-${t3-data.version}</directory>
<outputDirectory>scripts/ddl</outputDirectory>
<includes>
<include>**/*</include>
@@ -63,7 +55,7 @@
</fileSet>
<fileSet>
- <directory>${installer.cache}/t3-data-referential-${t3-data.version}</directory>
+ <directory>${installer.cache.dir}/t3-data-referential-${t3-data.version}</directory>
<outputDirectory>scripts/referential</outputDirectory>
<includes>
<include>**/*</include>
@@ -71,7 +63,7 @@
</fileSet>
<fileSet>
- <directory>${installer.cache}/t3-data-zones-${t3-data.version}</directory>
+ <directory>${installer.cache.dir}/t3-data-zones-${t3-data.version}</directory>
<outputDirectory>scripts/zones</outputDirectory>
<includes>
<include>**/*</include>
@@ -79,7 +71,7 @@
</fileSet>
<fileSet>
- <directory>${installer.cache}/t3-data-h2-${t3-data.version}</directory>
+ <directory>${installer.cache.dir}/t3-data-h2-${t3-data.version}</directory>
<outputDirectory>scripts/h2</outputDirectory>
<includes>
<include>**/*</include>
@@ -106,6 +98,7 @@
<includes>
<include>**/*.sh</include>
<include>**/*.bat</include>
+ <include>**/*.exe</include>
</includes>
</fileSet>
</fileSets>
=====================================
t3-installer/src/main/assembly/i18n.xml
=====================================
--- /dev/null
+++ b/t3-installer/src/main/assembly/i18n.xml
@@ -0,0 +1,36 @@
+<!--
+ #%L
+ T3 :: Installer
+ %%
+ Copyright (C) 2010 - 2018 IRD, Code Lutin, Ultreia.io
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ -->
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
+ <id>i18n</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <fileSets>
+ <fileSet>
+ <directory>target/classes/META-INF</directory>
+ <outputDirectory/>
+ <includes>
+ <include>t3-i18n*</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</assembly>
=====================================
t3/pom.xml
=====================================
--- a/t3/pom.xml
+++ b/t3/pom.xml
@@ -76,7 +76,6 @@
<artifactId>t3-installer</artifactId>
<version>${project.version}</version>
<type>zip</type>
- <classifier>bin</classifier>
</artifactItem>
</artifactItems>
</configuration>
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/compare/9b358873bc52532b61c1b78c480f645…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/compare/9b358873bc52532b61c1b78c480f645…
You're receiving this email because of your account on gitlab.com.
1
0
[Git][ultreiaio/ird-t3][develop] [N0.3] Conversion des catégories logbook - rendre générique la codification des…
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:
9b358873 by Tony CHEMIT at 2018-03-07T08:33:00Z
[N0.3] Conversion des catégories logbook - rendre générique la codification des catégories inconnues (Closes ultreiaio/ird-t3#287)
- - - - -
7 changed files:
- t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ConvertCatchesWeightCategoriesAction.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/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConverter.java
- t3-domain/src/main/java/fr/ird/t3/services/migration/T3MigrationCallbackV2_3.java
- + t3-domain/src/main/resources/db/migration/V_2_3_04-add-WeightCategoryLogbook-unknown.sql
- t3-domain/src/main/xmi/t3-persistence.zargo
Changes:
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ConvertCatchesWeightCategoriesAction.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ConvertCatchesWeightCategoriesAction.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/data/level0/ConvertCatchesWeightCategoriesAction.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%
@@ -109,74 +109,49 @@ public class ConvertCatchesWeightCategoriesAction extends AbstractLevel0Action<C
}
private boolean executeForTrip(Trip trip) throws TopiaException {
-
incrementsProgression();
-
String tripStr = decorate(trip);
-
String message = l(locale, "t3.level0.convertCatchesWeightCategories.treat.trip", tripStr);
log.info(message);
addInfoMessage(message);
-
Map<Species, CatchWeightResult> tripResult = new HashMap<>();
-
- if (!trip.isActivityEmpty()) {
-
+ if (trip.isActivityNotEmpty()) {
// must remove previous corrected elementary catches
for (Activity activity : trip.getActivity()) {
activity.clearCorrectedElementaryCatch();
}
-
for (Activity activity : trip.getActivity()) {
if (activity.isElementaryCatchEmpty()) {
// no catches
continue;
}
-
log.info(String.format("Treat activity %s with %d", activity.getDate(), activity.sizeElementaryCatch()));
Ocean currentOcean = activity.getOcean();
SchoolType schoolType = activity.getSchoolType();
-
// get converter for this ocean and school type
WeightCategoryLogBookConverter converter = converterProvider.getConverter(currentOcean, schoolType);
-
if (converter == null) {
-
// can not redistribute if no weight categories found
- message = l(locale, "t3.level0.convertCatchesWeightCategories.warning.noconverter.found",
+ message = l(locale, "t3.level0.convertCatchesWeightCategories.warning.no.converter.found",
currentOcean.getLabel1(), schoolType.getLabel1());
- if (log.isWarnEnabled()) {
- log.warn(message);
- }
+ log.warn(message);
addWarningMessage(message);
continue;
}
-
// split catches by species
Multimap<Species, ElementaryCatch> catchesBySpecie = SpeciesTopiaDao.groupBySpecies(activity.getElementaryCatch());
-
for (Species species : catchesBySpecie.keySet()) {
-
CatchWeightResult catchWeightResult = getCatchWeightResult(tripResult, species);
-
Collection<ElementaryCatch> catches = catchesBySpecie.get(species);
-
catchWeightResult.addLogBookWeight(catches);
-
log.info(String.format("Treat species %d with %d catches", species.getCode(), catches.size()));
-
// converts to weight category treatment for this species
-
Map<WeightCategoryTreatment, Float> distribution = converter.distribute(species, catches);
-
if (MapUtils.isEmpty(distribution)) {
-
// nothing to create
continue;
}
-
Collection<CorrectedElementaryCatch> newCatches = new ArrayList<>();
-
// create new catches
for (Map.Entry<WeightCategoryTreatment, Float> e2 : distribution.entrySet()) {
WeightCategoryTreatment weightCategoryTreatment = e2.getKey();
@@ -193,10 +168,7 @@ public class ConvertCatchesWeightCategoriesAction extends AbstractLevel0Action<C
}
}
}
-
- addInfoMessage(l(locale, "t3.level0.convertCatchesWeightCategories.resume.for.trip",
- tripStr, tripResult.size()));
-
+ addInfoMessage(l(locale, "t3.level0.convertCatchesWeightCategories.resume.for.trip", tripStr, tripResult.size()));
for (Map.Entry<Species, CatchWeightResult> e : tripResult.entrySet()) {
Species species = e.getKey();
CatchWeightResult r = e.getValue();
=====================================
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
@@ -49,7 +49,7 @@ t3.level0.computeWellPlanWeightCategoriesProportions.well.withWellPlan=Well (%s)
t3.level0.convertCatchesWeightCategories.resume.for.species=Species %s < logBook total weight \= %s , converted total weight \= %s>
t3.level0.convertCatchesWeightCategories.resume.for.trip=Trip %s converted for %s species
t3.level0.convertCatchesWeightCategories.treat.trip=Will treat trip %s
-t3.level0.convertCatchesWeightCategories.warning.noconverter.found=No converter found for ocean %s and schoolType %s
+t3.level0.convertCatchesWeightCategories.warning.no.converter.found=No converter found for ocean %s and schoolType %s
t3.level0.step.computeRf1=Compute RF1
t3.level0.step.computeRf2=Compute RF2
t3.level0.step.computeSetDurationAndPositiveSetCount=Compute Set Duration and positive set count
=====================================
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
@@ -49,7 +49,7 @@ t3.level0.computeWellPlanWeightCategoriesProportions.well.withWellPlan=Cuve avec
t3.level0.convertCatchesWeightCategories.resume.for.species=Espèce %s < poids total des captures du livre de bord \= %s , poids total converti \= %s>
t3.level0.convertCatchesWeightCategories.resume.for.trip=Marée %s convertie pour %s espèce(s)
t3.level0.convertCatchesWeightCategories.treat.trip=Traitement de la marée %s
-t3.level0.convertCatchesWeightCategories.warning.noconverter.found=Pas de converteur trouvé pour l'océan %s et le type de banc %s
+t3.level0.convertCatchesWeightCategories.warning.no.converter.found=Pas de converteur trouvé pour l'océan %s et le type de banc %s
t3.level0.step.computeRf1=Calcul du rf1
t3.level0.step.computeRf2=Calcul du rf2
t3.level0.step.computeSetDurationAndPositiveSetCount=Calcul de la durée d'une calée et de positive Set count
=====================================
t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConverter.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConverter.java
+++ b/t3-domain/src/main/java/fr/ird/t3/entities/conversion/WeightCategoryLogBookConverter.java
@@ -24,6 +24,7 @@ import fr.ird.t3.entities.data.ElementaryCatch;
import fr.ird.t3.entities.reference.Ocean;
import fr.ird.t3.entities.reference.SchoolType;
import fr.ird.t3.entities.reference.Species;
+import fr.ird.t3.entities.reference.WeightCategoryLogBook;
import fr.ird.t3.entities.reference.WeightCategoryTreatment;
import org.apache.commons.collections.CollectionUtils;
@@ -40,16 +41,17 @@ import java.util.Map;
public interface WeightCategoryLogBookConverter {
/**
- * Obtains the total weight of given {@code catches} which are in {@code unknown} weight category (with a code 9).
+ * Obtains the total weight of given {@code catches} which are in {@code unknown} weight category.
*
* @param catches catches to use
* @return the total weight of given catches which uses the unknown weight category
+ * @see WeightCategoryLogBook#isUnknown()
*/
static float getUnknownWeight(Collection<ElementaryCatch> catches) {
float result = 0;
if (CollectionUtils.isNotEmpty(catches)) {
for (ElementaryCatch aCatch : catches) {
- if (aCatch.getWeightCategoryLogBook().getCode() == 9) {
+ if (aCatch.getWeightCategoryLogBook().isUnknown()) {
result += aCatch.getCatchWeightRf2();
}
}
=====================================
t3-domain/src/main/java/fr/ird/t3/services/migration/T3MigrationCallbackV2_3.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/services/migration/T3MigrationCallbackV2_3.java
+++ b/t3-domain/src/main/java/fr/ird/t3/services/migration/T3MigrationCallbackV2_3.java
@@ -48,7 +48,9 @@ public class T3MigrationCallbackV2_3 extends T3MigrationCallbackSupport {
@Override
protected void prepareMigrationScript(TopiaSqlSupport sqlSupport, List<String> queries, boolean showSql, boolean showProgression) throws TopiaException {
addScript("01", "add-Trip-tripType", queries);
+ addScript("02", "add-VesselActivity-row", queries);
addScript("03", "spatialize-ocean", queries);
+ addScript("04", "add-WeightCategoryLogbook-unknown", queries);
}
}
=====================================
t3-domain/src/main/resources/db/migration/V_2_3_04-add-WeightCategoryLogbook-unknown.sql
=====================================
--- /dev/null
+++ b/t3-domain/src/main/resources/db/migration/V_2_3_04-add-WeightCategoryLogbook-unknown.sql
@@ -0,0 +1,22 @@
+---
+-- #%L
+-- T3 :: Domain
+-- %%
+-- Copyright (C) 2010 - 2018 IRD, Code Lutin, Ultreia.io
+-- %%
+-- This program is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU Affero General Public License as published by
+-- the Free Software Foundation, either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU Affero General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+-- #L%
+---
+ALTER TABLE WeightCategoryLogbook ADD COLUMN unknown BOOLEAN DEFAULT FALSE NOT NULL;
+UPDATE WeightCategoryLogbook SET unknown = TRUE WHERE code=9;
\ 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
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/9b358873bc52532b61c1b78c480f6453…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/9b358873bc52532b61c1b78c480f6453…
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:
dde509c3 by Tony CHEMIT at 2018-03-06T23:57:37Z
optimize dependencies
- - - - -
1 changed file:
- t3-actions/pom.xml
Changes:
=====================================
t3-actions/pom.xml
=====================================
--- a/t3-actions/pom.xml
+++ b/t3-actions/pom.xml
@@ -97,6 +97,10 @@
<groupId>org.nuiton.topia</groupId>
<artifactId>topia-persistence</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ </dependency>
<dependency>
<groupId>org.freemarker</groupId>
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/dde509c383690aa48c07fc4592bf5436…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/dde509c383690aa48c07fc4592bf5436…
You're receiving this email because of your account on gitlab.com.
1
0
06 Mar '18
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
e40de480 by Tony CHEMIT at 2018-03-06T23:39:50Z
Spatialiser la table Ocean (See #288)
Marées sans logbooks : gestion de leurs échantillons (remplissage de l'ocean après import) (See #116)
- - - - -
8 changed files:
- t3-actions/src/main/java/fr/ird/t3/actions/io/input/ImportInputSourceAction.java
- t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractOceanTopiaDao.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/java/fr/ird/t3/services/migration/T3MigrationCallbackV2_3.java
- + t3-domain/src/main/resources/db/migration/V_2_3_03-spatialize-ocean.sql
- t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionTest.java
- t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionTest.java
Changes:
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/io/input/ImportInputSourceAction.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/io/input/ImportInputSourceAction.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/io/input/ImportInputSourceAction.java
@@ -8,12 +8,12 @@
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
@@ -24,9 +24,14 @@ import fr.ird.t3.actions.T3Action;
import fr.ird.t3.entities.T3EntityEnum;
import fr.ird.t3.entities.T3TopiaApplicationContext;
import fr.ird.t3.entities.T3TopiaPersistenceContext;
+import fr.ird.t3.entities.data.Activity;
+import fr.ird.t3.entities.data.ActivityTopiaDao;
import fr.ird.t3.entities.data.T3DataEntity;
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.Ocean;
+import fr.ird.t3.entities.reference.OceanTopiaDao;
import fr.ird.t3.entities.reference.Vessel;
import fr.ird.t3.entities.reference.VesselTopiaDao;
import fr.ird.t3.services.ioc.InjectDAO;
@@ -58,12 +63,16 @@ public class ImportInputSourceAction extends T3Action<ImportInputSourceConfigura
// public static final String PARAM_TRIPS_TO_IMPORT = "tripsToImport";
// public static final String PARAM_TRIPS_TO_DELETE = "tripsToDelete";
private static final Log log = LogFactory.getLog(ImportInputSourceAction.class);
- protected Set<Trip> trips;
@InjectDAO(entityType = Trip.class)
- protected TripTopiaDao tripDAO;
- private Set<Trip> tripToDelete;
+ private TripTopiaDao tripDAO;
@InjectDAO(entityType = Vessel.class)
private VesselTopiaDao vesselDAO;
+ @InjectDAO(entityType = Activity.class)
+ private ActivityTopiaDao activityDAO;
+ @InjectDAO(entityType = Ocean.class)
+ private OceanTopiaDao oceanDAO;
+ private Set<Trip> tripToDelete;
+ private Set<Trip> trips;
@Override
protected void prepareAction() throws Exception {
@@ -109,7 +118,7 @@ public class ImportInputSourceAction extends T3Action<ImportInputSourceConfigura
addInfoMessage(message);
}
}
-
+ boolean logbookMissing = TripType.LOGBOOKMISSING == getConfiguration().getTripType();
boolean createVirtualVessel = getConfiguration().isCreateVirtualVessel();
BuildVisitor builder = new BuildVisitor(getActionContext().getApplicationContext(), getT3TopiaPersistenceContext().get());
for (Trip trip : trips) {
@@ -130,6 +139,9 @@ public class ImportInputSourceAction extends T3Action<ImportInputSourceConfigura
String message = l(locale, "t3.message.trip.was.imported", tripLabel);
addInfoMessage(message);
+ if (logbookMissing) {
+ fillActivityOcean(builder.activitiesWithNoOcean);
+ }
// clean the builder after each entity (since each entity is
// standalone and does not share data with other trips)
builder.clear();
@@ -138,13 +150,26 @@ public class ImportInputSourceAction extends T3Action<ImportInputSourceConfigura
return true;
}
+ private void fillActivityOcean(Set<Activity> ids) {
+
+ // Need to flush as we are going to query new data
+ getT3TopiaPersistenceContext().get().getHibernateSupport().getHibernateSession().flush();
+
+ String prefix = Activity.class.getName() + "#";
+ for (Activity activity : ids) {
+ Ocean ocean = oceanDAO.findOceanByActivity(activity);
+ activity.setOcean(ocean);
+ }
+ }
+
protected static class BuildVisitor implements TopiaEntityVisitor {
+ protected final Set<String> ids = new HashSet<>();
+ final Set<Activity> activitiesWithNoOcean = new HashSet<>();
final T3TopiaPersistenceContext tx;
final T3TopiaApplicationContext rootTx;
- protected final Set<String> ids = new HashSet<>();
- protected TopiaEntity current;
final Stack<TopiaEntity> stack = new Stack<>();
+ protected TopiaEntity current;
BuildVisitor(T3TopiaApplicationContext rootTx, T3TopiaPersistenceContext tx) {
this.tx = tx;
@@ -189,6 +214,12 @@ public class ImportInputSourceAction extends T3Action<ImportInputSourceConfigura
@SuppressWarnings("unchecked")
TopiaDao<TopiaEntity> dao = tx.getDao(T3EntityEnum.getContractClass((Class) entity.getClass()));
dao.update(entity);
+ if (entity instanceof Activity) {
+ Activity activity = (Activity) entity;
+ if (activity.getOcean() == null) {
+ activitiesWithNoOcean.add(activity);
+ }
+ }
} catch (TopiaException e) {
throw new IllegalStateException("Could not get dao for entity " + entity, e);
}
@@ -224,6 +255,7 @@ public class ImportInputSourceAction extends T3Action<ImportInputSourceConfigura
@Override
public void clear() {
ids.clear();
+ activitiesWithNoOcean.clear();
}
}
=====================================
t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractOceanTopiaDao.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractOceanTopiaDao.java
+++ b/t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractOceanTopiaDao.java
@@ -20,8 +20,14 @@
*/
package fr.ird.t3.entities.reference;
+import fr.ird.t3.entities.data.Activity;
import fr.ird.t3.entities.data.Trip;
+import org.nuiton.topia.persistence.support.TopiaSqlQuery;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@@ -51,4 +57,33 @@ public class AbstractOceanTopiaDao<E extends Ocean> extends GeneratedOceanTopiaD
String hql = "SELECT DISTINCT(o) FROM OceanImpl o, ActivityImpl a WHERE a.ocean = o.id";
return new HashSet<>(findAll(hql));
}
+
+ public E findOceanByActivity(Activity activity) {
+ GetOceanIdByActivityCoordinateQuery query = new GetOceanIdByActivityCoordinateQuery(activity.getTopiaId());
+ String oceanId = topiaSqlSupport.findSingleResult(query);
+ return forTopiaIdEquals(oceanId).findUnique();
+ }
+
+ private static class GetOceanIdByActivityCoordinateQuery extends TopiaSqlQuery<String> {
+
+ private final String activity;
+
+ GetOceanIdByActivityCoordinateQuery(String activity) {
+ this.activity = activity;
+ }
+
+ @Override
+ public PreparedStatement prepareQuery(Connection connection) throws SQLException {
+ @SuppressWarnings("SqlResolve")
+ PreparedStatement ps = connection.prepareStatement(
+ "SELECT o.topiaid FROM activity a, ocean o WHERE a.topiaId = ? AND ST_Contains(o.the_geom, a.the_geom)");
+ ps.setString(1, activity);
+ return ps;
+ }
+
+ @Override
+ public String prepareResult(ResultSet set) throws SQLException {
+ return set.getString(1);
+ }
+ }
}
=====================================
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
@@ -144,14 +144,6 @@ public class T3AccessDataSource extends AbstractAccessDataSource<T3EntityEnum, T
// on ne veut charger que les données observateurs, pas le referentiel
continue;
}
- if (TripType.LOGBOOKMISSING == tripType && meta.getType() == T3EntityEnum.Activity) {
- //FIXME-116 Just to test remove this ASAP
- cache.put(meta, new Map[]{});
- }
- if (TripType.LOGBOOKMISSING == tripType && meta.getType() == T3EntityEnum.WellPlan) {
- //FIXME-116 Just to test remove this ASAP
- cache.put(meta, new Map[]{});
- }
Map<String, Object>[] data = getTableData(meta);
if (hits != null) {
long hit = hits.getHit(meta.getType());
=====================================
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
@@ -76,10 +76,6 @@ public abstract class T3AvdthDataEntityVisitor extends T3DataEntityVisitor {
activity.setLatitude(Objects.requireNonNull(sampleSet.getActivityLatitude()));
activity.setLongitude(Objects.requireNonNull(sampleSet.getActivityLongitude()));
activity.setSchoolType(Objects.requireNonNull(sampleSet.getActivitySchoolType()));
-
- //FIXME-116 Get ocean from coordinates
- activity.setOcean(parent.getDepartureHarbour().getOcean());
-
sampleSet.setActivity(endActivity(activity));
parent.addActivity(activity);
}
=====================================
t3-domain/src/main/java/fr/ird/t3/services/migration/T3MigrationCallbackV2_3.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/services/migration/T3MigrationCallbackV2_3.java
+++ b/t3-domain/src/main/java/fr/ird/t3/services/migration/T3MigrationCallbackV2_3.java
@@ -48,6 +48,7 @@ public class T3MigrationCallbackV2_3 extends T3MigrationCallbackSupport {
@Override
protected void prepareMigrationScript(TopiaSqlSupport sqlSupport, List<String> queries, boolean showSql, boolean showProgression) throws TopiaException {
addScript("01", "add-Trip-tripType", queries);
+ addScript("03", "spatialize-ocean", queries);
}
}
=====================================
t3-domain/src/main/resources/db/migration/V_2_3_03-spatialize-ocean.sql
=====================================
The diff for this file was not included because it is too large.
=====================================
t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionTest.java
=====================================
--- a/t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionTest.java
+++ b/t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionTest.java
@@ -10,12 +10,12 @@ package fr.ird.t3.actions.io.input;
* 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,7 +40,6 @@ public class AnalyzeInputSourceActionTest extends AnalyzeInputSourceActionTestSu
return new MSAccessTestConfiguration("testExecute_([^_]*)_(\\d+)(_.+)*", "%s_%s_V35.mdb", T3InputProviderAvdth35.ID);
}
- @Ignore
@Test
public void testExecute_OA_2000() throws Exception {
testExecute(AtlanticOceanFixtures.OA_2000);
@@ -51,16 +50,4 @@ public class AnalyzeInputSourceActionTest extends AnalyzeInputSourceActionTestSu
testExecute(IndianOceanFixtures.OI_2000);
}
- @Ignore
- @Test
- public void testExecute_OA_2000_withoutLogbook() throws Exception {
- testExecute(AtlanticOceanFixtures.OA_2000, TripType.LOGBOOKMISSING);
- }
-
- @Ignore
- @Test
- public void testExecute_OI_2002_withoutLogbook() throws Exception {
- testExecute(IndianOceanFixtures.OI_2002,TripType.LOGBOOKMISSING);
- }
-
}
=====================================
t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionTest.java
=====================================
--- a/t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionTest.java
+++ b/t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionTest.java
@@ -23,9 +23,7 @@ package fr.ird.t3.actions.io.input;
import fr.ird.t3.actions.io.input.test.ImportInputSourceActionTestSupport;
import fr.ird.t3.actions.io.input.test.MSAccessTestConfiguration;
-import fr.ird.t3.entities.data.TripType;
import fr.ird.t3.io.input.avdth.v35.T3InputProviderAvdth35;
-import org.junit.Ignore;
import org.junit.Test;
/**
@@ -50,16 +48,4 @@ public class ImportInputSourceActionTest extends ImportInputSourceActionTestSupp
testExecute(IndianOceanFixtures.OI_2000);
}
- @Ignore
- @Test
- public void testExecute_OA_2000_withoutLogbook() throws Exception {
- testExecute(AtlanticOceanFixtures.OA_2000, TripType.LOGBOOKMISSING);
- }
-
- @Ignore
- @Test
- public void testExecute_OI_2002_withoutLogbook() throws Exception {
- testExecute(IndianOceanFixtures.OI_2002, TripType.LOGBOOKMISSING);
- }
-
}
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/e40de48024b18af42224187d0c3bb0f1…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/e40de48024b18af42224187d0c3bb0f1…
You're receiving this email because of your account on gitlab.com.
1
0
[Git][ultreiaio/ird-t3][develop] Renommage des valeurs de TripType (See #116)
by Tony CHEMIT 06 Mar '18
by Tony CHEMIT 06 Mar '18
06 Mar '18
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
05a4f53b by Tony CHEMIT at 2018-03-06T16:25:58Z
Renommage des valeurs de TripType (See #116)
- - - - -
23 changed files:
- 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/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionResumeTest.java
- t3-actions/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionResumeTest.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/entities/data/TripType.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/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.zargo
- t3-domain/src/test/java/fr/ird/t3/entities/data/TripTopiaDaoTest.java
- t3-input-avdthv33/src/test/java/fr/ird/t3/actions/io/input/it/AnalyzeInputSourceActionIT.java
- t3-input-avdthv33/src/test/java/fr/ird/t3/actions/io/input/it/ImportInputSourceActionIT.java
- t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionTest.java
- t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionTest.java
- t3-web/src/main/java/fr/ird/t3/web/actions/io/input/ConfigureImportDataAction.java
Changes:
=====================================
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
@@ -160,7 +160,7 @@ public class AnalyzeInputSourceAction extends T3Action<AnalyzeInputSourceConfigu
LoadingTripHitModel hitModel = new LoadingTripHitModel();
hitModel.addPropertyChangeListener(LoadingTripHitModel.NB_TRIP_LOADED, evt -> incrementsProgression());
TripType tripType = getConfiguration().getTripType();
- boolean samplesOnly = tripType == TripType.SAMPLES_ONLY;
+ boolean samplesOnly = tripType == TripType.SAMPLEONLY;
tripsLoaded = inputPilot.loadTrips(hitModel);
boolean createVessel = getConfiguration().isCanCreateVessel();
Map<Integer, Vessel> vessels = null;
=====================================
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
@@ -120,7 +120,7 @@ public abstract class AnalyzeInputSourceActionITSupport {
fixture.nbUnsafe(),
fixture.nbSafeWithoutWell(),
fixture.nbUnsafeWithoutwell(),
- TripType.NORMAL,
+ TripType.STANDARD,
false,
false
);
@@ -136,7 +136,7 @@ public abstract class AnalyzeInputSourceActionITSupport {
nbUnsafe,
nbSafeWithoutwell,
nbUnsafeWithoutWell,
- TripType.NORMAL,
+ TripType.STANDARD,
false,
false
);
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/io/input/it/ImportInputSourceActionITSupport.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/io/input/it/ImportInputSourceActionITSupport.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/io/input/it/ImportInputSourceActionITSupport.java
@@ -89,11 +89,11 @@ public abstract class ImportInputSourceActionITSupport {
}
public void testExecute(OceanFixtures fixtures) throws Exception {
- testExecute(fixtures.nbSafeWithoutWell(), fixtures.nbUnsafeWithoutwell(), TripType.NORMAL, false, false);
+ testExecute(fixtures.nbSafeWithoutWell(), fixtures.nbUnsafeWithoutwell(), TripType.STANDARD, false, false);
}
public void testExecute(int nbSafe, int nbUnsafe) throws Exception {
- testExecute(nbSafe, nbUnsafe, TripType.NORMAL, false, false);
+ testExecute(nbSafe, nbUnsafe, TripType.STANDARD, false, false);
}
public void testExecute(int nbSafe, int nbUnsafe,
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/AnalyzeInputSourceActionTestSupport.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/AnalyzeInputSourceActionTestSupport.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/AnalyzeInputSourceActionTestSupport.java
@@ -91,7 +91,7 @@ public abstract class AnalyzeInputSourceActionTestSupport {
}
protected void testExecute(OceanFixtures fixture) throws Exception {
- testExecute(fixture, TripType.NORMAL);
+ testExecute(fixture, TripType.STANDARD);
}
protected void testExecute(OceanFixtures fixture, TripType tripType) throws Exception {
=====================================
t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/ImportInputSourceActionTestSupport.java
=====================================
--- a/t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/ImportInputSourceActionTestSupport.java
+++ b/t3-actions/src/main/java/fr/ird/t3/actions/io/input/test/ImportInputSourceActionTestSupport.java
@@ -81,7 +81,7 @@ public abstract class ImportInputSourceActionTestSupport {
}
protected void testExecute(OceanFixtures fixture) throws Exception {
- testExecute(fixture, TripType.NORMAL);
+ testExecute(fixture, TripType.STANDARD);
}
protected void testExecute(OceanFixtures fixture, TripType tripType) throws Exception {
=====================================
t3-actions/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionResumeTest.java
=====================================
--- a/t3-actions/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionResumeTest.java
+++ b/t3-actions/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionResumeTest.java
@@ -50,7 +50,7 @@ public class AnalyzeInputSourceActionResumeTest extends AbstractActionResumeTest
protected void prepareConfiguration(AnalyzeInputSourceConfiguration conf) {
configuration.setInputFile(new File("inputSource"));
configuration.setUseWells(true);
- configuration.setTripType(TripType.NORMAL);
+ configuration.setTripType(TripType.STANDARD);
configuration.setInputProvider(serviceContext.newService(T3InputService.class).getProviders()[0]);
configuration.setCanCreateVessel(true);
configuration.setCreateVirtualVessel(true);
=====================================
t3-actions/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionResumeTest.java
=====================================
--- a/t3-actions/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionResumeTest.java
+++ b/t3-actions/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionResumeTest.java
@@ -48,7 +48,7 @@ public class ImportInputSourceActionResumeTest extends AbstractActionResumeTest<
protected void prepareConfiguration(ImportInputSourceConfiguration conf) {
configuration.setInputFile(new File("inputSource"));
configuration.setUseWells(true);
- configuration.setTripType(TripType.NORMAL);
+ configuration.setTripType(TripType.STANDARD);
configuration.setInputProvider(serviceContext.newService(T3InputService.class).getProviders()[0]);
configuration.setCanCreateVessel(true);
configuration.setCreateVirtualVessel(true);
=====================================
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
@@ -80,9 +80,9 @@ public class AbstractTripTopiaDao<E extends Trip> extends GeneratedTripTopiaDao<
return "";
}
if (samplesOnly) {
- return " " + prefix + " t.tripType = 'SAMPLES_ONLY'";
+ return " " + prefix + " t.tripType = 'SAMPLEONLY'";
}
- return " " + prefix + " t.tripType != 'SAMPLES_ONLY'";
+ return " " + prefix + " t.tripType != 'SAMPLEONLY'";
}
public static <E extends Trip> Collection<E> getAllTripsWithNoDataComputed(Collection<E> trips) {
=====================================
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
@@ -83,12 +83,12 @@ public class TripImpl extends TripAbstract {
@Override
public boolean isSamplesOnly() {
- return TripType.SAMPLES_ONLY == getTripType();
+ return TripType.SAMPLEONLY == getTripType();
}
@Override
public boolean isWithoutLogbook() {
- return TripType.WITHOUT_LOGBOOK == getTripType();
+ return TripType.LOGBOOKMISSING == getTripType();
}
public boolean isLevel2Computed() {
=====================================
t3-domain/src/main/java/fr/ird/t3/entities/data/TripType.java
=====================================
--- a/t3-domain/src/main/java/fr/ird/t3/entities/data/TripType.java
+++ b/t3-domain/src/main/java/fr/ird/t3/entities/data/TripType.java
@@ -26,9 +26,9 @@ import fr.ird.t3.t3.domain.I18nEnumHelper;
import static org.nuiton.i18n.I18n.t;
public enum TripType {
- NORMAL,
- SAMPLES_ONLY,
- WITHOUT_LOGBOOK;
+ STANDARD,
+ SAMPLEONLY,
+ LOGBOOKMISSING;
public String getLabel() {
return I18nEnumHelper.getLabel(this);
=====================================
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
@@ -91,8 +91,8 @@ public abstract class AbstractT3InputMSAccess implements T3Input {
T3AccessHitModel hitModel = new T3AccessHitModel();
hitModel.addPropertyChangeListener(new LoadDbPropertyChangeListener(t3DataTypes));
// analyse data source
- if (configuration.getTripType() == TripType.WITHOUT_LOGBOOK) {
- dataSource.analyzeDb(TripType.WITHOUT_LOGBOOK, hitModel);
+ if (configuration.getTripType() == TripType.LOGBOOKMISSING) {
+ dataSource.analyzeDb(TripType.LOGBOOKMISSING, hitModel);
} else {
dataSource.analyzeDb(hitModel);
}
=====================================
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
@@ -144,11 +144,11 @@ public class T3AccessDataSource extends AbstractAccessDataSource<T3EntityEnum, T
// on ne veut charger que les données observateurs, pas le referentiel
continue;
}
- if (TripType.WITHOUT_LOGBOOK == tripType && meta.getType() == T3EntityEnum.Activity) {
+ if (TripType.LOGBOOKMISSING == tripType && meta.getType() == T3EntityEnum.Activity) {
//FIXME-116 Just to test remove this ASAP
cache.put(meta, new Map[]{});
}
- if (TripType.WITHOUT_LOGBOOK == tripType && meta.getType() == T3EntityEnum.WellPlan) {
+ if (TripType.LOGBOOKMISSING == tripType && meta.getType() == T3EntityEnum.WellPlan) {
//FIXME-116 Just to test remove this ASAP
cache.put(meta, new Map[]{});
}
=====================================
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
@@ -63,7 +63,7 @@ public abstract class T3AvdthDataEntityVisitor extends T3DataEntityVisitor {
super(dataSource, referentiel);
wellPlanReverse = newReverseAssociationGetter(Trip.class, WellPlan.class, Activity.class, Trip.PROPERTY_ACTIVITY, WellPlan.PROPERTY_ACTIVITY);
sampleReverse = newReverseAssociationGetter(Trip.class, Sample.class, Well.class, Trip.PROPERTY_WELL, Sample.PROPERTY_WELL);
- if (TripType.WITHOUT_LOGBOOK == configuration.getTripType()) {
+ if (TripType.LOGBOOKMISSING == configuration.getTripType()) {
sampleSetReverse = new ReverseAssociationGetter<Trip, SampleSet, Activity>(Trip.class, SampleSet.class, Activity.class, Trip.PROPERTY_ACTIVITY, SampleSet.PROPERTY_ACTIVITY) {
@Override
void onReverseNotFound(Trip parent, T3AccessEntity entity, Object[] pKey) {
=====================================
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
@@ -18,7 +18,7 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
-- #L%
---
-ALTER TABLE Trip ADD COLUMN tripType VARCHAR(255) DEFAULT 'NORMAL' NOT NULL;
-UPDATE Trip set tripType = 'SAMPLES_ONLY' WHERE samplesonly = TRUE;
+ALTER TABLE Trip ADD COLUMN tripType VARCHAR(255) DEFAULT 'STANDARD' NOT NULL;
+UPDATE Trip set tripType = 'SAMPLEONLY' WHERE samplesonly = TRUE;
CREATE INDEX idx_trip_tripType ON Trip(tripType);
ALTER TABLE Trip DROP COLUMN samplesonly;
\ No newline at end of file
=====================================
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
@@ -162,9 +162,9 @@ t3.config.rfTot.maximum.description=Default maximum acceptable for rfTot
t3.config.stratum.weightRatio.description=Default weight ratio to accept while building level 2 or 3 stratum
t3.config.treatment.working.directory.description=Location of treatment directory
t3.config.users.file.description=Application users file
-t3.enum.fr.ird.t3.entities.data.TripType.NORMAL=Normal
-t3.enum.fr.ird.t3.entities.data.TripType.SAMPLES_ONLY=Samples only
-t3.enum.fr.ird.t3.entities.data.TripType.WITHOUT_LOGBOOK=Without Logbook
+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.output.operations=Operations
t3.output.outputProvider=Output Pilot
t3.user.log.directory.description=Location of directory where to store user logs
=====================================
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
@@ -162,9 +162,9 @@ t3.config.rfTot.maximum.description=Seuil maximum acceptable pour le calcul du r
t3.config.stratum.weightRatio.description=Ratio du poids capturé / celui échantillonné acceptable dans une strate échantillon
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.entities.data.TripType.NORMAL=Normal
-t3.enum.fr.ird.t3.entities.data.TripType.SAMPLES_ONLY=Echantillons uniquement
-t3.enum.fr.ird.t3.entities.data.TripType.WITHOUT_LOGBOOK=Sans logbook
+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
t3.output.operations=Opérations
t3.output.outputProvider=Pilote de sortie
t3.user.log.directory.description=Répertoire où sont conservés les logs des utilisateurs
=====================================
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/data/TripTopiaDaoTest.java
=====================================
--- a/t3-domain/src/test/java/fr/ird/t3/entities/data/TripTopiaDaoTest.java
+++ b/t3-domain/src/test/java/fr/ird/t3/entities/data/TripTopiaDaoTest.java
@@ -59,8 +59,8 @@ public class TripTopiaDaoTest extends AbstractDatabaseTest {
T3Date startDate = T3Date.newDate(1, 2010);
T3Date endDate = T3Date.newDate(1, 2011);
- Trip trip = T3PersistenceFixtures.newTrip(tx, 0, startDate.toBeginDate(), TripType.NORMAL);
- Trip trip1 = T3PersistenceFixtures.newTrip(tx, 1, endDate.toBeginDate(), TripType.SAMPLES_ONLY);
+ Trip trip = T3PersistenceFixtures.newTrip(tx, 0, startDate.toBeginDate(), TripType.STANDARD);
+ Trip trip1 = T3PersistenceFixtures.newTrip(tx, 1, endDate.toBeginDate(), TripType.SAMPLEONLY);
List<Trip> result;
=====================================
t3-input-avdthv33/src/test/java/fr/ird/t3/actions/io/input/it/AnalyzeInputSourceActionIT.java
=====================================
--- a/t3-input-avdthv33/src/test/java/fr/ird/t3/actions/io/input/it/AnalyzeInputSourceActionIT.java
+++ b/t3-input-avdthv33/src/test/java/fr/ird/t3/actions/io/input/it/AnalyzeInputSourceActionIT.java
@@ -131,7 +131,7 @@ public class AnalyzeInputSourceActionIT implements T3AVDTHV33Test {
nbUnsafe,
nbSafeWithoutWell,
nbUnsafeWithoutWell,
- TripType.NORMAL,
+ TripType.STANDARD,
false,
false
);
@@ -355,30 +355,30 @@ public class AnalyzeInputSourceActionIT implements T3AVDTHV33Test {
@Test
@Override
public void testExecute_ESATL_2006() throws Exception {
- testExecute(70, 27, 97, 0, TripType.SAMPLES_ONLY, true, true);
+ testExecute(70, 27, 97, 0, TripType.SAMPLEONLY, true, true);
}
@Test
@Override
public void testExecute_ESATL_2007() throws Exception {
- testExecute(273, 27, 238, 0, TripType.SAMPLES_ONLY, true, true);
+ testExecute(273, 27, 238, 0, TripType.SAMPLEONLY, true, true);
}
@Test
@Override
public void testExecute_ESATL_2008() throws Exception {
- testExecute(46, 14, 60, 0, TripType.SAMPLES_ONLY, true, true);
+ testExecute(46, 14, 60, 0, TripType.SAMPLEONLY, true, true);
}
@Test
@Override
public void testExecute_ESATL_2009() throws Exception {
- testExecute(64, 21, 85, 0, TripType.SAMPLES_ONLY, true, true);
+ testExecute(64, 21, 85, 0, TripType.SAMPLEONLY, true, true);
}
@Test
@Override
public void testExecute_ESATL_2010() throws Exception {
- testExecute(75, 13, 80, 8, TripType.SAMPLES_ONLY, true, true);
+ testExecute(75, 13, 80, 8, TripType.SAMPLEONLY, true, true);
}
}
=====================================
t3-input-avdthv33/src/test/java/fr/ird/t3/actions/io/input/it/ImportInputSourceActionIT.java
=====================================
--- a/t3-input-avdthv33/src/test/java/fr/ird/t3/actions/io/input/it/ImportInputSourceActionIT.java
+++ b/t3-input-avdthv33/src/test/java/fr/ird/t3/actions/io/input/it/ImportInputSourceActionIT.java
@@ -104,7 +104,7 @@ public class ImportInputSourceActionIT implements T3AVDTHV33Test {
}
public void testExecute(int nbSafe, int nbUnsafe) throws Exception {
- testExecute(nbSafe, nbUnsafe, TripType.NORMAL, false, false);
+ testExecute(nbSafe, nbUnsafe, TripType.STANDARD, false, false);
}
public void testExecute(int nbSafe, int nbUnsafe,
@@ -314,30 +314,30 @@ public class ImportInputSourceActionIT implements T3AVDTHV33Test {
@Test
@Override
public void testExecute_ESATL_2006() throws Exception {
- testExecute(70, 27, TripType.SAMPLES_ONLY, true, true);
+ testExecute(70, 27, TripType.SAMPLEONLY, true, true);
}
@Test
@Override
public void testExecute_ESATL_2007() throws Exception {
- testExecute(53, 27, TripType.SAMPLES_ONLY, true, true);
+ testExecute(53, 27, TripType.SAMPLEONLY, true, true);
}
@Test
@Override
public void testExecute_ESATL_2008() throws Exception {
- testExecute(46, 14, TripType.SAMPLES_ONLY, true, true);
+ testExecute(46, 14, TripType.SAMPLEONLY, true, true);
}
@Test
@Override
public void testExecute_ESATL_2009() throws Exception {
- testExecute(64, 21, TripType.SAMPLES_ONLY, true, true);
+ testExecute(64, 21, TripType.SAMPLEONLY, true, true);
}
@Test
@Override
public void testExecute_ESATL_2010() throws Exception {
- testExecute(75, 13, TripType.SAMPLES_ONLY, true, true);
+ testExecute(75, 13, TripType.SAMPLEONLY, true, true);
}
}
=====================================
t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionTest.java
=====================================
--- a/t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionTest.java
+++ b/t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceActionTest.java
@@ -54,13 +54,13 @@ public class AnalyzeInputSourceActionTest extends AnalyzeInputSourceActionTestSu
@Ignore
@Test
public void testExecute_OA_2000_withoutLogbook() throws Exception {
- testExecute(AtlanticOceanFixtures.OA_2000, TripType.WITHOUT_LOGBOOK);
+ testExecute(AtlanticOceanFixtures.OA_2000, TripType.LOGBOOKMISSING);
}
@Ignore
@Test
public void testExecute_OI_2002_withoutLogbook() throws Exception {
- testExecute(IndianOceanFixtures.OI_2002,TripType.WITHOUT_LOGBOOK);
+ testExecute(IndianOceanFixtures.OI_2002,TripType.LOGBOOKMISSING);
}
}
=====================================
t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionTest.java
=====================================
--- a/t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionTest.java
+++ b/t3-input-avdthv35/src/test/java/fr/ird/t3/actions/io/input/ImportInputSourceActionTest.java
@@ -53,13 +53,13 @@ public class ImportInputSourceActionTest extends ImportInputSourceActionTestSupp
@Ignore
@Test
public void testExecute_OA_2000_withoutLogbook() throws Exception {
- testExecute(AtlanticOceanFixtures.OA_2000, TripType.WITHOUT_LOGBOOK);
+ testExecute(AtlanticOceanFixtures.OA_2000, TripType.LOGBOOKMISSING);
}
@Ignore
@Test
public void testExecute_OI_2002_withoutLogbook() throws Exception {
- testExecute(IndianOceanFixtures.OI_2002, TripType.WITHOUT_LOGBOOK);
+ testExecute(IndianOceanFixtures.OI_2002, TripType.LOGBOOKMISSING);
}
}
=====================================
t3-web/src/main/java/fr/ird/t3/web/actions/io/input/ConfigureImportDataAction.java
=====================================
--- a/t3-web/src/main/java/fr/ird/t3/web/actions/io/input/ConfigureImportDataAction.java
+++ b/t3-web/src/main/java/fr/ird/t3/web/actions/io/input/ConfigureImportDataAction.java
@@ -70,7 +70,7 @@ public class ConfigureImportDataAction extends AbstractConfigureAction<AnalyzeIn
*
* @since 2.3
*/
- private TripType tripType = TripType.NORMAL;
+ private TripType tripType = TripType.STANDARD;
/**
* flag to authorize creation of missing vessels.
*
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/05a4f53bb05e1119c94269d545a9a97e…
---
View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/05a4f53bb05e1119c94269d545a9a97e…
You're receiving this email because of your account on gitlab.com.
1
0