Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
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:
| ... | ... | @@ -8,12 +8,12 @@ |
| 8 | 8 |
* it under the terms of the GNU Affero General Public License as published by
|
| 9 | 9 |
* the Free Software Foundation, either version 3 of the License, or
|
| 10 | 10 |
* (at your option) any later version.
|
| 11 |
- *
|
|
| 11 |
+ *
|
|
| 12 | 12 |
* This program is distributed in the hope that it will be useful,
|
| 13 | 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 | 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 | 15 |
* GNU General Public License for more details.
|
| 16 |
- *
|
|
| 16 |
+ *
|
|
| 17 | 17 |
* You should have received a copy of the GNU Affero General Public License
|
| 18 | 18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 19 | 19 |
* #L%
|
| ... | ... | @@ -70,7 +70,7 @@ public class ComputeRF2Action extends AbstractLevel0Action<ComputeRF2Configurati |
| 70 | 70 |
protected List<Harbour> landingHarbours;
|
| 71 | 71 |
@InjectFromDAO(entityType = Species.class)
|
| 72 | 72 |
protected List<Species> species;
|
| 73 |
- protected int nbStratums;
|
|
| 73 |
+ protected int nbStratum;
|
|
| 74 | 74 |
protected int nbTripsWithRF2;
|
| 75 | 75 |
@InjectDAO(entityType = RaisingFactor2.class)
|
| 76 | 76 |
private RaisingFactor2TopiaDao raisingFactor2DAO;
|
| ... | ... | @@ -87,8 +87,8 @@ public class ComputeRF2Action extends AbstractLevel0Action<ComputeRF2Configurati |
| 87 | 87 |
super(Level0Step.COMPUTE_RF2);
|
| 88 | 88 |
}
|
| 89 | 89 |
|
| 90 |
- public int getNbStratums() {
|
|
| 91 |
- return nbStratums;
|
|
| 90 |
+ public int getNbStratum() {
|
|
| 91 |
+ return nbStratum;
|
|
| 92 | 92 |
}
|
| 93 | 93 |
|
| 94 | 94 |
@SuppressWarnings("unused")
|
| ... | ... | @@ -155,10 +155,10 @@ public class ComputeRF2Action extends AbstractLevel0Action<ComputeRF2Configurati |
| 155 | 155 |
log.debug(String.format("found %d months.", tripsByMonth.size()));
|
| 156 | 156 |
for (T3Date month : tripsByMonth.keySet()) {
|
| 157 | 157 |
Collection<CompleteTrip> stratumTrips = tripsByMonth.get(month);
|
| 158 |
- nbStratums++;
|
|
| 158 |
+ nbStratum++;
|
|
| 159 | 159 |
String message = l(locale, "t3.level0.computeRF2.nbTrips.for.stratum",
|
| 160 | 160 |
stratumTrips.size(),
|
| 161 |
- nbStratums,
|
|
| 161 |
+ nbStratum,
|
|
| 162 | 162 |
harbourStr,
|
| 163 | 163 |
countryStr,
|
| 164 | 164 |
vesselSimpleTypeStr,
|
| ... | ... | @@ -57,7 +57,7 @@ public class L2CatchStratumLoader extends CatchStratumLoader<Level2Configuration |
| 57 | 57 |
Map<String, Integer> activityIds = activityDAO.findAllActivityIdsForCatchStratum(
|
| 58 | 58 |
configuration.getZoneTableName(),
|
| 59 | 59 |
configuration.getZone().getTopiaId(),
|
| 60 |
- configuration.getSchoolType().getTopiaId(),
|
|
| 60 |
+ configuration.getSchoolTypeIds(),
|
|
| 61 | 61 |
configuration.getBeginDate(),
|
| 62 | 62 |
configuration.getEndDate());
|
| 63 | 63 |
// ensuite pour chaque activité on récupère sa marée et on conserve
|
| ... | ... | @@ -56,7 +56,6 @@ public abstract class L2SampleStratumLoader extends SampleStratumLoader<Level2Co |
| 56 | 56 |
* @since 1.4
|
| 57 | 57 |
*/
|
| 58 | 58 |
private final float minimumSampleTotalWeight;
|
| 59 |
- |
|
| 60 | 59 |
/**
|
| 61 | 60 |
* The minimum sample count required to obtain the correct
|
| 62 | 61 |
* substitution level.
|
| ... | ... | @@ -75,7 +74,7 @@ public abstract class L2SampleStratumLoader extends SampleStratumLoader<Level2Co |
| 75 | 74 |
float catchStratumTotalWeight = sampleStratum.getCatchStratumTotalWeight();
|
| 76 | 75 |
float maximumWeightRatio = configuration.getStratumWeightRatio();
|
| 77 | 76 |
minimumSampleTotalWeight = catchStratumTotalWeight / maximumWeightRatio;
|
| 78 |
- SchoolType schoolType = sampleStratum.getConfiguration().getSampleSchoolType();
|
|
| 77 |
+ SchoolType schoolType = sampleStratum.getConfiguration().getSchoolType();
|
|
| 79 | 78 |
int code = schoolType.getCode();
|
| 80 | 79 |
switch (code) {
|
| 81 | 80 |
case 1:
|
| ... | ... | @@ -103,7 +102,7 @@ public abstract class L2SampleStratumLoader extends SampleStratumLoader<Level2Co |
| 103 | 102 |
List<String> activityIds = activityDAO.findAllActivityIdsForSampleStratum(
|
| 104 | 103 |
configuration.getZoneTableName(),
|
| 105 | 104 |
zoneId,
|
| 106 |
- schoolTypeId,
|
|
| 105 |
+ configuration.getSchoolTypeIds(),
|
|
| 107 | 106 |
beginDate,
|
| 108 | 107 |
endDate);
|
| 109 | 108 |
result.addAll(activityIds);
|
| ... | ... | @@ -41,7 +41,7 @@ public class L2SampleStratumLoaderAtlantic extends L2SampleStratumLoader { |
| 41 | 41 |
protected Set<String> findActivityIds(int level) {
|
| 42 | 42 |
|
| 43 | 43 |
StratumConfiguration<Level2Configuration> configuration = getSampleStratum().getConfiguration();
|
| 44 |
- String schoolTypeId = configuration.getSampleSchoolType().getTopiaId();
|
|
| 44 |
+ String schoolTypeId = configuration.getSchoolType().getTopiaId();
|
|
| 45 | 45 |
String zoneId = configuration.getZone().getTopiaId();
|
| 46 | 46 |
T3Date beginDate = configuration.getBeginDate();
|
| 47 | 47 |
T3Date endDate = configuration.getEndDate();
|
| ... | ... | @@ -41,7 +41,7 @@ public class L2SampleStratumLoaderIndian extends L2SampleStratumLoader { |
| 41 | 41 |
protected Set<String> findActivityIds(int level) {
|
| 42 | 42 |
|
| 43 | 43 |
StratumConfiguration<Level2Configuration> configuration = getSampleStratum().getConfiguration();
|
| 44 |
- String schoolTypeId = configuration.getSampleSchoolType().getTopiaId();
|
|
| 44 |
+ String schoolTypeId = configuration.getSchoolType().getTopiaId();
|
|
| 45 | 45 |
String zoneId = configuration.getZone().getTopiaId();
|
| 46 | 46 |
T3Date beginDate = configuration.getBeginDate();
|
| 47 | 47 |
T3Date endDate = configuration.getEndDate();
|
| ... | ... | @@ -27,7 +27,7 @@ import com.google.common.collect.LinkedHashMultimap; |
| 27 | 27 |
import com.google.common.collect.Multimap;
|
| 28 | 28 |
import fr.ird.t3.actions.T3Action;
|
| 29 | 29 |
import fr.ird.t3.actions.stratum.OceanContext;
|
| 30 |
-import fr.ird.t3.actions.stratum.SampleStratum;
|
|
| 30 |
+import fr.ird.t3.actions.stratum.SchoolTypeIndeterminate;
|
|
| 31 | 31 |
import fr.ird.t3.actions.stratum.StratumConfiguration;
|
| 32 | 32 |
import fr.ird.t3.entities.data.Activity;
|
| 33 | 33 |
import fr.ird.t3.entities.data.ActivityTopiaDao;
|
| ... | ... | @@ -122,8 +122,6 @@ public class Level2Action extends T3Action<Level2Configuration> { |
| 122 | 122 |
private CorrectedElementaryCatchTopiaDao correctedElementaryCatchDAO;
|
| 123 | 123 |
@InjectDAO(entityType = Vessel.class)
|
| 124 | 124 |
private VesselTopiaDao vesselDAO;
|
| 125 |
- @InjectDAO(entityType = SchoolType.class)
|
|
| 126 |
- private SchoolTypeTopiaDao schoolTypeDAO;
|
|
| 127 | 125 |
private ZoneStratumAwareMeta zoneMeta;
|
| 128 | 126 |
@InjectFromDAO(entityType = SchoolType.class, method = "findAllForStratum")
|
| 129 | 127 |
private Set<SchoolType> schoolTypes;
|
| ... | ... | @@ -140,13 +138,11 @@ public class Level2Action extends T3Action<Level2Configuration> { |
| 140 | 138 |
private Set<T3Date> startDates;
|
| 141 | 139 |
private Set<Vessel> possibleCatchVessels;
|
| 142 | 140 |
private Set<Vessel> possibleSampleVessels;
|
| 143 |
- private int nbStratums;
|
|
| 141 |
+ private int nbStratum;
|
|
| 144 | 142 |
private long totalCatchWeightForSpeciesFoFix;
|
| 145 | 143 |
private long totalCatchWeight;
|
| 146 | 144 |
private long totalCatchActivities;
|
| 147 | 145 |
private long totalCatchActivitiesWithSample;
|
| 148 |
- private SchoolType boSchoolType;
|
|
| 149 |
- private SchoolType blSchoolType;
|
|
| 150 | 146 |
|
| 151 | 147 |
public Level2Action() {
|
| 152 | 148 |
activityCache = CacheBuilder.newBuilder().build(
|
| ... | ... | @@ -163,8 +159,6 @@ public class Level2Action extends T3Action<Level2Configuration> { |
| 163 | 159 |
@Override
|
| 164 | 160 |
protected void prepareAction() throws Exception {
|
| 165 | 161 |
super.prepareAction();
|
| 166 |
- this.boSchoolType = schoolTypeDAO.forCodeEquals(1).findUnique();
|
|
| 167 |
- this.blSchoolType = schoolTypeDAO.forCodeEquals(2).findUnique();
|
|
| 168 | 162 |
this.oceanContext.clear();
|
| 169 | 163 |
Level2Configuration configuration = getConfiguration();
|
| 170 | 164 |
configuration.setLocale(getLocale());
|
| ... | ... | @@ -216,13 +210,13 @@ public class Level2Action extends T3Action<Level2Configuration> { |
| 216 | 210 |
}
|
| 217 | 211 |
|
| 218 | 212 |
private void executeActionWithCategories(Level2Configuration configuration, Set<String> usedActivityIds) throws Exception {
|
| 219 |
- nbStratums = 0;
|
|
| 213 |
+ nbStratum = 0;
|
|
| 220 | 214 |
for (SchoolType schoolType : schoolTypes) {
|
| 221 | 215 |
List<WeightCategoryTreatment> weightCategories = getWeightCategoryTreatments(schoolType);
|
| 222 | 216 |
Collection<ZoneStratumAware> zones = getZones(schoolType);
|
| 223 |
- nbStratums += startDates.size() * zones.size() * weightCategories.size();
|
|
| 217 |
+ nbStratum += startDates.size() * zones.size() * weightCategories.size();
|
|
| 224 | 218 |
}
|
| 225 |
- setNbSteps(3 * nbStratums);
|
|
| 219 |
+ setNbSteps(3 * nbStratum);
|
|
| 226 | 220 |
int timeStep = configuration.getTimeStep();
|
| 227 | 221 |
MutableInt stratumIndex = new MutableInt(1);
|
| 228 | 222 |
for (SchoolType schoolType : schoolTypes) {
|
| ... | ... | @@ -237,12 +231,12 @@ public class Level2Action extends T3Action<Level2Configuration> { |
| 237 | 231 |
}
|
| 238 | 232 |
|
| 239 | 233 |
private void executeActionWithoutCategories(Level2Configuration configuration, Set<String> usedActivityIds) throws Exception {
|
| 240 |
- nbStratums = 0;
|
|
| 234 |
+ nbStratum = 0;
|
|
| 241 | 235 |
for (SchoolType schoolType : schoolTypes) {
|
| 242 | 236 |
Collection<ZoneStratumAware> zones = getZones(schoolType);
|
| 243 |
- nbStratums += startDates.size() * zones.size();
|
|
| 237 |
+ nbStratum += startDates.size() * zones.size();
|
|
| 244 | 238 |
}
|
| 245 |
- setNbSteps(3 * nbStratums);
|
|
| 239 |
+ setNbSteps(3 * nbStratum);
|
|
| 246 | 240 |
int timeStep = configuration.getTimeStep();
|
| 247 | 241 |
MutableInt stratumIndex = new MutableInt(1);
|
| 248 | 242 |
for (SchoolType schoolType : schoolTypes) {
|
| ... | ... | @@ -254,18 +248,15 @@ public class Level2Action extends T3Action<Level2Configuration> { |
| 254 | 248 |
}
|
| 255 | 249 |
}
|
| 256 | 250 |
|
| 257 |
- private List<WeightCategoryTreatment> getWeightCategoryTreatments(SchoolType schoolType) {
|
|
| 258 |
- List<WeightCategoryTreatment> weightCategoryTreatments = oceanContext.values().stream().flatMap(o -> o.getWeightCategories(schoolType).stream()).distinct().collect(Collectors.toList());
|
|
| 259 |
- WeightCategories.sort(weightCategoryTreatments);
|
|
| 260 |
- return weightCategoryTreatments;
|
|
| 261 |
- }
|
|
| 262 |
- |
|
| 263 |
- private Collection<ZoneStratumAware> getZones(SchoolType schoolType) {
|
|
| 264 |
- return oceanContext.values().stream().flatMap(o -> o.getZones(schoolType).stream()).distinct().collect(Collectors.toList());
|
|
| 265 |
- }
|
|
| 266 |
- |
|
| 267 |
- 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 {
|
|
| 268 |
- SchoolType sampleSchoolType = SampleStratum.getSampleSchoolType(schoolType, configuration.getSchoolTypeIndeterminate(), boSchoolType, blSchoolType);
|
|
| 251 |
+ private void doIterateOnDates(int timeStep,
|
|
| 252 |
+ Level2Configuration configuration,
|
|
| 253 |
+ SchoolType schoolType,
|
|
| 254 |
+ Collection<ZoneStratumAware> zones,
|
|
| 255 |
+ ZoneStratumAware zone,
|
|
| 256 |
+ List<WeightCategoryTreatment> weightCategories,
|
|
| 257 |
+ WeightCategoryTreatment weightCategoryTreatment,
|
|
| 258 |
+ Set<String> usedActivityIds,
|
|
| 259 |
+ MutableInt stratumIndex) throws Exception {
|
|
| 269 | 260 |
for (T3Date startDate : startDates) {
|
| 270 | 261 |
// get end date (only increments on timeStep - 1 to have
|
| 271 | 262 |
// exactly timeStep month from beginDate.toStartDate() to endDate.toEndDate()
|
| ... | ... | @@ -277,7 +268,6 @@ public class Level2Action extends T3Action<Level2Configuration> { |
| 277 | 268 |
zoneMeta,
|
| 278 | 269 |
zone,
|
| 279 | 270 |
schoolType,
|
| 280 |
- sampleSchoolType,
|
|
| 281 | 271 |
weightCategoryTreatment,
|
| 282 | 272 |
startDate,
|
| 283 | 273 |
endDate,
|
| ... | ... | @@ -296,24 +286,34 @@ public class Level2Action extends T3Action<Level2Configuration> { |
| 296 | 286 |
}
|
| 297 | 287 |
}
|
| 298 | 288 |
|
| 299 |
- private L2StratumResult doExecuteStratum(
|
|
| 300 |
- StratumConfiguration<Level2Configuration> stratumConfiguration,
|
|
| 301 |
- List<WeightCategoryTreatment> weightCategories,
|
|
| 302 |
- MutableInt stratumIndex,
|
|
| 303 |
- Set<String> usedActivityIds) throws Exception {
|
|
| 289 |
+ private L2StratumResult doExecuteStratum(StratumConfiguration<Level2Configuration> stratumConfiguration,
|
|
| 290 |
+ List<WeightCategoryTreatment> weightCategories,
|
|
| 291 |
+ MutableInt stratumIndex,
|
|
| 292 |
+ Set<String> usedActivityIds) throws Exception {
|
|
| 304 | 293 |
incrementsProgression();
|
| 305 | 294 |
String stratumPrefix =
|
| 306 | 295 |
l(locale, "t3.level2.stratumLabel",
|
| 307 |
- stratumIndex, nbStratums,
|
|
| 296 |
+ stratumIndex, nbStratum,
|
|
| 308 | 297 |
decorate(stratumConfiguration.getSchoolType()),
|
| 309 |
- decorate(stratumConfiguration.getSampleSchoolType()),
|
|
| 310 | 298 |
decorate(stratumConfiguration.getZone()),
|
| 311 | 299 |
stratumConfiguration.getBeginDate(),
|
| 312 | 300 |
stratumConfiguration.getEndDate());
|
| 313 | 301 |
L2StratumResult result = new L2StratumResult(stratumConfiguration, stratumPrefix);
|
| 314 | 302 |
String message = l(locale, "t3.level2.message.start.stratum", stratumPrefix);
|
| 315 |
- if (log.isInfoEnabled()) {
|
|
| 316 |
- log.info(message);
|
|
| 303 |
+ log.info(message);
|
|
| 304 |
+ if (SchoolTypeIndeterminate.IGNORE == getConfiguration().getSchoolTypeIndeterminate()) {
|
|
| 305 |
+ // Just report for all activities on School type indeterminate catch weight
|
|
| 306 |
+ Set<String> activityIds = activityDAO.findAllActivityIdsForCatchStratum(
|
|
| 307 |
+ stratumConfiguration.getZoneTableName(),
|
|
| 308 |
+ stratumConfiguration.getZone().getTopiaId(),
|
|
| 309 |
+ Collections.singleton(SchoolTypeTopiaDao.SCHOOL_TYPE_INDETERMINATE_ID),
|
|
| 310 |
+ stratumConfiguration.getBeginDate(),
|
|
| 311 |
+ stratumConfiguration.getEndDate()).keySet();
|
|
| 312 |
+ for (String activityId : activityIds) {
|
|
| 313 |
+ for (CorrectedElementaryCatch correctedElementaryCatch : activityCache.get(activityId).getCorrectedElementaryCatch()) {
|
|
| 314 |
+ correctedElementaryCatch.setCorrectedCatchWeight(correctedElementaryCatch.getCatchWeight());
|
|
| 315 |
+ }
|
|
| 316 |
+ }
|
|
| 317 | 317 |
}
|
| 318 | 318 |
addInfoMessage("==============================================================================================");
|
| 319 | 319 |
addInfoMessage(message);
|
| ... | ... | @@ -399,6 +399,16 @@ public class Level2Action extends T3Action<Level2Configuration> { |
| 399 | 399 |
return result;
|
| 400 | 400 |
}
|
| 401 | 401 |
|
| 402 |
+ private List<WeightCategoryTreatment> getWeightCategoryTreatments(SchoolType schoolType) {
|
|
| 403 |
+ List<WeightCategoryTreatment> weightCategoryTreatments = oceanContext.values().stream().flatMap(o -> o.getWeightCategories(schoolType).stream()).distinct().collect(Collectors.toList());
|
|
| 404 |
+ WeightCategories.sort(weightCategoryTreatments);
|
|
| 405 |
+ return weightCategoryTreatments;
|
|
| 406 |
+ }
|
|
| 407 |
+ |
|
| 408 |
+ private Collection<ZoneStratumAware> getZones(SchoolType schoolType) {
|
|
| 409 |
+ return oceanContext.values().stream().flatMap(o -> o.getZones(schoolType).stream()).distinct().collect(Collectors.toList());
|
|
| 410 |
+ }
|
|
| 411 |
+ |
|
| 402 | 412 |
private L2CatchStratum newCatchStratum(StratumConfiguration<Level2Configuration> stratumConfiguration,
|
| 403 | 413 |
List<WeightCategoryTreatment> weightCategories) throws Exception {
|
| 404 | 414 |
L2CatchStratum catchStratum = new L2CatchStratum(stratumConfiguration, species);
|
| ... | ... | @@ -645,34 +655,6 @@ public class Level2Action extends T3Action<Level2Configuration> { |
| 645 | 655 |
catchStratum.addActivityOutputModel(correctedCatchWeightModel);
|
| 646 | 656 |
}
|
| 647 | 657 |
|
| 648 |
-// private void setZoneMeta(ZoneStratumAwareMeta zoneMeta) {
|
|
| 649 |
-// this.zoneMeta = zoneMeta;
|
|
| 650 |
-// }
|
|
| 651 |
- |
|
| 652 |
-// private void setSchoolTypes(Set<SchoolType> schoolTypes) {
|
|
| 653 |
-// this.schoolTypes = schoolTypes;
|
|
| 654 |
-// }
|
|
| 655 |
- |
|
| 656 |
-// private void setSpecies(Set<Species> species) {
|
|
| 657 |
-// this.species = species;
|
|
| 658 |
-// }
|
|
| 659 |
- |
|
| 660 |
-// private void setStartDates(Set<T3Date> startDates) {
|
|
| 661 |
-// this.startDates = startDates;
|
|
| 662 |
-// }
|
|
| 663 |
- |
|
| 664 |
-// private void setPossibleCatchVessels(Set<Vessel> possibleCatchVessels) {
|
|
| 665 |
-// this.possibleCatchVessels = possibleCatchVessels;
|
|
| 666 |
-// }
|
|
| 667 |
- |
|
| 668 |
-// private void setPossibleSampleVessels(Set<Vessel> possibleSampleVessels) {
|
|
| 669 |
-// this.possibleSampleVessels = possibleSampleVessels;
|
|
| 670 |
-// }
|
|
| 671 |
- |
|
| 672 |
-// private void setZoneVersion(ZoneVersion zoneVersion) {
|
|
| 673 |
-// this.zoneVersion = zoneVersion;
|
|
| 674 |
-// }
|
|
| 675 |
- |
|
| 676 | 658 |
// -------------------------------------------------------------------------
|
| 677 | 659 |
// --- Results -------------------------------------------------------------
|
| 678 | 660 |
// -------------------------------------------------------------------------
|
| ... | ... | @@ -683,8 +665,8 @@ public class Level2Action extends T3Action<Level2Configuration> { |
| 683 | 665 |
}
|
| 684 | 666 |
|
| 685 | 667 |
@SuppressWarnings("unused")
|
| 686 |
- public int getNbStratums() {
|
|
| 687 |
- return nbStratums;
|
|
| 668 |
+ public int getNbStratum() {
|
|
| 669 |
+ return nbStratum;
|
|
| 688 | 670 |
}
|
| 689 | 671 |
|
| 690 | 672 |
@SuppressWarnings("unused")
|
| ... | ... | @@ -748,7 +730,7 @@ public class Level2Action extends T3Action<Level2Configuration> { |
| 748 | 730 |
@SuppressWarnings("unused")
|
| 749 | 731 |
public String getInputCatchStratumLog() {
|
| 750 | 732 |
WeightCompositionAggregateModel inputCatchModelForSpeciesToFix = inputCatchModelForAllSpecies.extractForSpecies(species);
|
| 751 |
- String title = l(locale, "t3.level2.message.strateInputGlobalComposition.resume");
|
|
| 733 |
+ String title = l(locale, "t3.level2.message.stratumInputGlobalComposition.resume");
|
|
| 752 | 734 |
return WeightCompositionModelHelper.decorateModel(
|
| 753 | 735 |
getDecoratorService(),
|
| 754 | 736 |
title,
|
| ... | ... | @@ -759,7 +741,7 @@ public class Level2Action extends T3Action<Level2Configuration> { |
| 759 | 741 |
@SuppressWarnings("unused")
|
| 760 | 742 |
public String getOutputCatchStratumLog() {
|
| 761 | 743 |
WeightCompositionAggregateModel outputCatchModelForSpeciesToFix = outputCatchModelForAllSpecies.extractForSpecies(species);
|
| 762 |
- String title = l(locale, "t3.level2.message.strateOutputGlobalComposition.resume");
|
|
| 744 |
+ String title = l(locale, "t3.level2.message.stratumOutputGlobalComposition.resume");
|
|
| 763 | 745 |
return WeightCompositionModelHelper.decorateModel(
|
| 764 | 746 |
getDecoratorService(),
|
| 765 | 747 |
title,
|
| ... | ... | @@ -8,12 +8,12 @@ |
| 8 | 8 |
* it under the terms of the GNU Affero General Public License as published by
|
| 9 | 9 |
* the Free Software Foundation, either version 3 of the License, or
|
| 10 | 10 |
* (at your option) any later version.
|
| 11 |
- *
|
|
| 11 |
+ *
|
|
| 12 | 12 |
* This program is distributed in the hope that it will be useful,
|
| 13 | 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 | 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 | 15 |
* GNU General Public License for more details.
|
| 16 |
- *
|
|
| 16 |
+ *
|
|
| 17 | 17 |
* You should have received a copy of the GNU Affero General Public License
|
| 18 | 18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 19 | 19 |
* #L%
|
| ... | ... | @@ -54,20 +54,16 @@ public class L3CatchStratumLoader extends CatchStratumLoader<Level3Configuration |
| 54 | 54 |
// - avec des captures
|
| 55 | 55 |
// - dont la marée n'est pas samplesOnly
|
| 56 | 56 |
// - dont la marée est complète
|
| 57 |
- |
|
| 58 | 57 |
Map<String, Integer> activityIds = activityDAO.findAllActivityIdsForCatchStratum(
|
| 59 | 58 |
configuration.getZoneTableName(),
|
| 60 | 59 |
configuration.getZone().getTopiaId(),
|
| 61 |
- configuration.getSchoolType().getTopiaId(),
|
|
| 60 |
+ configuration.getSchoolTypeIds(),
|
|
| 62 | 61 |
configuration.getBeginDate(),
|
| 63 |
- configuration.getEndDate()
|
|
| 64 |
- );
|
|
| 65 |
- |
|
| 62 |
+ configuration.getEndDate());
|
|
| 66 | 63 |
// ensuite pour chaque activité on récupère sa marée et on conserve
|
| 67 | 64 |
// l'activité uniquement ssi :
|
| 68 | 65 |
// - maree.bateau de type senneur OK
|
| 69 | 66 |
// - maree.bateau dans la bonne flotte OK
|
| 70 |
- |
|
| 71 | 67 |
return filterActivities(configuration, activityIds);
|
| 72 | 68 |
}
|
| 73 | 69 |
|
| ... | ... | @@ -78,20 +74,15 @@ public class L3CatchStratumLoader extends CatchStratumLoader<Level3Configuration |
| 78 | 74 |
Map<Activity, Integer> result = new HashMap<>();
|
| 79 | 75 |
if (activityIds != null && activityIds.size() > 0) {
|
| 80 | 76 |
for (Map.Entry<String, Integer> e : activityIds.entrySet()) {
|
| 81 |
- |
|
| 82 | 77 |
String activityId = e.getKey();
|
| 83 |
- |
|
| 84 | 78 |
// get activity
|
| 85 | 79 |
Activity activity = configuration.getActivity(activityId);
|
| 86 |
- |
|
| 87 | 80 |
// get his trip
|
| 88 | 81 |
Trip trip = activity.getTrip();
|
| 89 | 82 |
if (!possibleVessels.contains(trip.getVessel())) {
|
| 90 |
- |
|
| 91 | 83 |
// not a matching boat
|
| 92 | 84 |
continue;
|
| 93 | 85 |
}
|
| 94 |
- |
|
| 95 | 86 |
// recheck activity have some catches.
|
| 96 | 87 |
Preconditions.checkState(!activity.isCorrectedElementaryCatchEmpty(),
|
| 97 | 88 |
String.format("Can not accept an activity (%s) with no catch", activity.getTopiaId()));
|
| ... | ... | @@ -92,7 +92,7 @@ public abstract class L3SampleStratumLoader extends SampleStratumLoader<Level3Co |
| 92 | 92 |
List<String> activityIds = activityDAO.findAllActivityIdsForSampleStratum(
|
| 93 | 93 |
configuration.getZoneTableName(),
|
| 94 | 94 |
zoneId,
|
| 95 |
- schoolTypeId,
|
|
| 95 |
+ schoolTypeId == null ? null : configuration.getSchoolTypeIds(),
|
|
| 96 | 96 |
beginDate,
|
| 97 | 97 |
endDate);
|
| 98 | 98 |
result.addAll(activityIds);
|
| ... | ... | @@ -40,7 +40,7 @@ public class L3SampleStratumLoaderAtlantic extends L3SampleStratumLoader { |
| 40 | 40 |
@Override
|
| 41 | 41 |
protected Set<String> findActivityIds(int level) {
|
| 42 | 42 |
StratumConfiguration<Level3Configuration> configuration = getSampleStratum().getConfiguration();
|
| 43 |
- String schoolTypeId = configuration.getSampleSchoolType().getTopiaId();
|
|
| 43 |
+ String schoolTypeId = configuration.getSchoolType().getTopiaId();
|
|
| 44 | 44 |
String zoneId = configuration.getZone().getTopiaId();
|
| 45 | 45 |
T3Date beginDate = configuration.getBeginDate();
|
| 46 | 46 |
T3Date endDate = configuration.getEndDate();
|
| ... | ... | @@ -41,7 +41,7 @@ public class L3SampleStratumLoaderIndian extends L3SampleStratumLoader { |
| 41 | 41 |
protected Set<String> findActivityIds(int level) {
|
| 42 | 42 |
|
| 43 | 43 |
StratumConfiguration<Level3Configuration> configuration = getSampleStratum().getConfiguration();
|
| 44 |
- String schoolTypeId = configuration.getSampleSchoolType().getTopiaId();
|
|
| 44 |
+ String schoolTypeId = configuration.getSchoolType().getTopiaId();
|
|
| 45 | 45 |
String zoneId = configuration.getZone().getTopiaId();
|
| 46 | 46 |
T3Date beginDate = configuration.getBeginDate();
|
| 47 | 47 |
T3Date endDate = configuration.getEndDate();
|
| ... | ... | @@ -30,7 +30,6 @@ import com.google.common.collect.Multimap; |
| 30 | 30 |
import com.google.common.collect.Sets;
|
| 31 | 31 |
import fr.ird.t3.actions.T3Action;
|
| 32 | 32 |
import fr.ird.t3.actions.stratum.OceanContext;
|
| 33 |
-import fr.ird.t3.actions.stratum.SampleStratum;
|
|
| 34 | 33 |
import fr.ird.t3.actions.stratum.StratumConfiguration;
|
| 35 | 34 |
import fr.ird.t3.actions.stratum.StratumMinimumSampleCount;
|
| 36 | 35 |
import fr.ird.t3.entities.T3Predicates;
|
| ... | ... | @@ -46,7 +45,6 @@ import fr.ird.t3.entities.reference.LengthWeightConversionHelper; |
| 46 | 45 |
import fr.ird.t3.entities.reference.LengthWeightConversionTopiaDao;
|
| 47 | 46 |
import fr.ird.t3.entities.reference.Ocean;
|
| 48 | 47 |
import fr.ird.t3.entities.reference.SchoolType;
|
| 49 |
-import fr.ird.t3.entities.reference.SchoolTypeTopiaDao;
|
|
| 50 | 48 |
import fr.ird.t3.entities.reference.Species;
|
| 51 | 49 |
import fr.ird.t3.entities.reference.Vessel;
|
| 52 | 50 |
import fr.ird.t3.entities.reference.VesselTopiaDao;
|
| ... | ... | @@ -141,21 +139,11 @@ public class Level3Action extends T3Action<Level3Configuration> { |
| 141 | 139 |
private LengthWeightConversionTopiaDao lengthWeightConversionDAO;
|
| 142 | 140 |
@InjectDAO(entityType = WeightCategoryTreatment.class)
|
| 143 | 141 |
private WeightCategoryTreatmentTopiaDao weightCategoryTreatmentDAO;
|
| 144 |
- // @InjectDAO(entityType = SetSpeciesFrequency.class)
|
|
| 145 |
-// private SetSpeciesFrequencyTopiaDao setSpeciesFrequencyDAO;
|
|
| 146 |
-// @InjectDAO(entityType = SetSpeciesCatWeight.class)
|
|
| 147 |
-// private SetSpeciesCatWeightTopiaDao setSpeciesCatWeightDAO;
|
|
| 148 |
-// @InjectDAO(entityType = ExtrapolatedAllSetSpeciesFrequency.class)
|
|
| 149 |
-// private ExtrapolatedAllSetSpeciesFrequencyTopiaDao extrapolatedAllSetSpeciesFrequencyDAO;
|
|
| 150 | 142 |
@InjectDAO(entityType = Vessel.class)
|
| 151 | 143 |
private VesselTopiaDao vesselDAO;
|
| 152 |
- @InjectDAO(entityType = SchoolType.class)
|
|
| 153 |
- private SchoolTypeTopiaDao schoolTypeDAO;
|
|
| 154 | 144 |
private ZoneStratumAwareMeta zoneMeta;
|
| 155 | 145 |
@InjectFromDAO(entityType = SchoolType.class, method = "findAllForStratum")
|
| 156 | 146 |
private Set<SchoolType> schoolTypes;
|
| 157 |
- // @InjectEntityById(entityType = Ocean.class)
|
|
| 158 |
-// private Ocean ocean;
|
|
| 159 | 147 |
@InjectEntitiesById(entityType = Country.class)
|
| 160 | 148 |
private Set<Country> catchFleets;
|
| 161 | 149 |
@InjectEntitiesById(entityType = Species.class, path = "configuration.speciesIds")
|
| ... | ... | @@ -170,7 +158,7 @@ public class Level3Action extends T3Action<Level3Configuration> { |
| 170 | 158 |
private Set<Vessel> possibleCatchVessels;
|
| 171 | 159 |
private Set<Vessel> possibleSampleVessels;
|
| 172 | 160 |
private Map<SchoolType, Map<String, Integer>> stratumMinimumSampleCountBySchoolType;
|
| 173 |
- private int nbStratums;
|
|
| 161 |
+ private int nbStratum;
|
|
| 174 | 162 |
private long nbCatchActivities;
|
| 175 | 163 |
private long nbCatchActivitiesWithSample;
|
| 176 | 164 |
/**
|
| ... | ... | @@ -182,8 +170,6 @@ public class Level3Action extends T3Action<Level3Configuration> { |
| 182 | 170 |
private String topiaCreateDate;
|
| 183 | 171 |
private int nbQuery;
|
| 184 | 172 |
private StringBuilder queryBuffer = new StringBuilder();
|
| 185 |
- private SchoolType boSchoolType;
|
|
| 186 |
- private SchoolType blSchoolType;
|
|
| 187 | 173 |
|
| 188 | 174 |
public Level3Action() {
|
| 189 | 175 |
activityCache = CacheBuilder.newBuilder().build(
|
| ... | ... | @@ -202,8 +188,6 @@ public class Level3Action extends T3Action<Level3Configuration> { |
| 202 | 188 |
@Override
|
| 203 | 189 |
protected void prepareAction() throws Exception {
|
| 204 | 190 |
super.prepareAction();
|
| 205 |
- this.boSchoolType = schoolTypeDAO.forCodeEquals(1).findUnique();
|
|
| 206 |
- this.blSchoolType = schoolTypeDAO.forCodeEquals(2).findUnique();
|
|
| 207 | 191 |
this.totalFishesCount = new SpeciesCountAggregateModel();
|
| 208 | 192 |
Level3Configuration configuration = getConfiguration();
|
| 209 | 193 |
configuration.setLocale(getLocale());
|
| ... | ... | @@ -249,7 +233,7 @@ public class Level3Action extends T3Action<Level3Configuration> { |
| 249 | 233 |
}
|
| 250 | 234 |
break;
|
| 251 | 235 |
default:
|
| 252 |
- throw new IllegalStateException("Can not use the school fish " + code);
|
|
| 236 |
+ throw new IllegalStateException(String.format("Can not use the school type %d", code));
|
|
| 253 | 237 |
}
|
| 254 | 238 |
}
|
| 255 | 239 |
this.stratumMinimumSampleCountBySchoolType = minimumSampleCountBySchoolType;
|
| ... | ... | @@ -283,13 +267,13 @@ public class Level3Action extends T3Action<Level3Configuration> { |
| 283 | 267 |
}
|
| 284 | 268 |
|
| 285 | 269 |
private void executeActionWithCategories(Level3Configuration configuration, Set<String> usedActivityIds) throws Exception {
|
| 286 |
- nbStratums = 0;
|
|
| 270 |
+ nbStratum = 0;
|
|
| 287 | 271 |
for (SchoolType schoolType : schoolTypes) {
|
| 288 | 272 |
List<WeightCategoryTreatment> weightCategories = getWeightCategoryTreatments(schoolType);
|
| 289 | 273 |
Collection<ZoneStratumAware> zones = getZones(schoolType);
|
| 290 |
- nbStratums += startDates.size() * zones.size() * weightCategories.size();
|
|
| 274 |
+ nbStratum += startDates.size() * zones.size() * weightCategories.size();
|
|
| 291 | 275 |
}
|
| 292 |
- setNbSteps(3 * nbStratums);
|
|
| 276 |
+ setNbSteps(3 * nbStratum);
|
|
| 293 | 277 |
int timeStep = configuration.getTimeStep();
|
| 294 | 278 |
MutableInt stratumIndex = new MutableInt(1);
|
| 295 | 279 |
for (SchoolType schoolType : schoolTypes) {
|
| ... | ... | @@ -305,12 +289,12 @@ public class Level3Action extends T3Action<Level3Configuration> { |
| 305 | 289 |
}
|
| 306 | 290 |
|
| 307 | 291 |
private void executeActionWithoutCategories(Level3Configuration configuration, Set<String> usedActivityIds) throws Exception {
|
| 308 |
- nbStratums = 0;
|
|
| 292 |
+ nbStratum = 0;
|
|
| 309 | 293 |
for (SchoolType schoolType : schoolTypes) {
|
| 310 | 294 |
Collection<ZoneStratumAware> zones = getZones(schoolType);
|
| 311 |
- nbStratums += startDates.size() * zones.size();
|
|
| 295 |
+ nbStratum += startDates.size() * zones.size();
|
|
| 312 | 296 |
}
|
| 313 |
- setNbSteps(3 * nbStratums);
|
|
| 297 |
+ setNbSteps(3 * nbStratum);
|
|
| 314 | 298 |
int timeStep = configuration.getTimeStep();
|
| 315 | 299 |
MutableInt stratumIndex = new MutableInt(1);
|
| 316 | 300 |
for (SchoolType schoolType : schoolTypes) {
|
| ... | ... | @@ -334,7 +318,6 @@ public class Level3Action extends T3Action<Level3Configuration> { |
| 334 | 318 |
}
|
| 335 | 319 |
|
| 336 | 320 |
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 {
|
| 337 |
- SchoolType sampleSchoolType = SampleStratum.getSampleSchoolType(schoolType, configuration.getSchoolTypeIndeterminate(), boSchoolType, blSchoolType);
|
|
| 338 | 321 |
for (T3Date startDate : startDates) {
|
| 339 | 322 |
// clear query buffer
|
| 340 | 323 |
queryBuffer = new StringBuilder();
|
| ... | ... | @@ -348,7 +331,6 @@ public class Level3Action extends T3Action<Level3Configuration> { |
| 348 | 331 |
zoneMeta,
|
| 349 | 332 |
zone,
|
| 350 | 333 |
schoolType,
|
| 351 |
- sampleSchoolType,
|
|
| 352 | 334 |
weightCategoryTreatment,
|
| 353 | 335 |
startDate,
|
| 354 | 336 |
endDate,
|
| ... | ... | @@ -382,9 +364,8 @@ public class Level3Action extends T3Action<Level3Configuration> { |
| 382 | 364 |
incrementsProgression();
|
| 383 | 365 |
String stratumPrefix =
|
| 384 | 366 |
l(locale, "t3.level3.stratumLabel",
|
| 385 |
- stratumIndex, nbStratums,
|
|
| 367 |
+ stratumIndex, nbStratum,
|
|
| 386 | 368 |
decorate(stratumConfiguration.getSchoolType()),
|
| 387 |
- decorate(stratumConfiguration.getSampleSchoolType()),
|
|
| 388 | 369 |
decorate(stratumConfiguration.getZone()),
|
| 389 | 370 |
stratumConfiguration.getBeginDate(),
|
| 390 | 371 |
stratumConfiguration.getEndDate());
|
| ... | ... | @@ -394,6 +375,21 @@ public class Level3Action extends T3Action<Level3Configuration> { |
| 394 | 375 |
addInfoMessage("==============================================================================================");
|
| 395 | 376 |
addInfoMessage(message);
|
| 396 | 377 |
addInfoMessage("==============================================================================================");
|
| 378 |
+ //FIXME-261 Is there anything to do ?
|
|
| 379 |
+// if (SchoolTypeIndeterminate.IGNORE == getConfiguration().getSchoolTypeIndeterminate()) {
|
|
| 380 |
+// // Just report for all activities on School type indeterminate catch weight
|
|
| 381 |
+// Set<String> activityIds = activityDAO.findAllActivityIdsForCatchStratum(
|
|
| 382 |
+// stratumConfiguration.getZoneTableName(),
|
|
| 383 |
+// stratumConfiguration.getZone().getTopiaId(),
|
|
| 384 |
+// Collections.singleton(SchoolTypeTopiaDao.SCHOOL_TYPE_INDETERMINATE_ID),
|
|
| 385 |
+// stratumConfiguration.getBeginDate(),
|
|
| 386 |
+// stratumConfiguration.getEndDate()).keySet();
|
|
| 387 |
+// for (String activityId : activityIds) {
|
|
| 388 |
+// for (CorrectedElementaryCatch correctedElementaryCatch : activityCache.get(activityId).getCorrectedElementaryCatch()) {
|
|
| 389 |
+// correctedElementaryCatch.setCorrectedCatchWeight(correctedElementaryCatch.getCatchWeight());
|
|
| 390 |
+// }
|
|
| 391 |
+// }
|
|
| 392 |
+// }
|
|
| 397 | 393 |
// get the catch stratum
|
| 398 | 394 |
try (L3CatchStratum catchStratum = newCatchStratum(stratumConfiguration, weightCategories)) {
|
| 399 | 395 |
incrementsProgression();
|
| ... | ... | @@ -713,8 +709,8 @@ public class Level3Action extends T3Action<Level3Configuration> { |
| 713 | 709 |
return nbCatchActivitiesWithSample;
|
| 714 | 710 |
}
|
| 715 | 711 |
|
| 716 |
- public int getNbStratums() {
|
|
| 717 |
- return nbStratums;
|
|
| 712 |
+ public int getNbStratum() {
|
|
| 713 |
+ return nbStratum;
|
|
| 718 | 714 |
}
|
| 719 | 715 |
|
| 720 | 716 |
@SuppressWarnings("unused")
|
| ... | ... | @@ -46,7 +46,7 @@ Date de fin : ${configuration.endDate} |
| 46 | 46 |
Indicateurs
|
| 47 | 47 |
-----------
|
| 48 | 48 |
|
| 49 |
-- Nombre de strates : ${action.nbStratums}
|
|
| 49 |
+- Nombre de strates : ${action.nbStratum}
|
|
| 50 | 50 |
- Nombre de marées : ${action.nbTrips}
|
| 51 | 51 |
- Nombre de marées avec calcul du rf2 : ${action.nbTripsWithRF2}
|
| 52 | 52 |
|
| ... | ... | @@ -46,7 +46,7 @@ End date: ${configuration.endDate} |
| 46 | 46 |
Indicators
|
| 47 | 47 |
----------
|
| 48 | 48 |
|
| 49 |
-- Number of stratums: ${action.nbStratums}
|
|
| 49 |
+- Number of stratums: ${action.nbStratum}
|
|
| 50 | 50 |
- Number of trips: ${action.nbTrips}
|
| 51 | 51 |
- Number of trips with computed rf2: ${action.nbTripsWithRF2}
|
| 52 | 52 |
|
| ... | ... | @@ -81,7 +81,7 @@ Qualité des strates échantillons : |
| 81 | 81 |
Indicateurs
|
| 82 | 82 |
-----------
|
| 83 | 83 |
|
| 84 |
-- Nombre de strates : ${action.nbStratums}
|
|
| 84 |
+- Nombre de strates : ${action.nbStratum}
|
|
| 85 | 85 |
- Nombre de strates corrigés : ${action.nbStrataFixed}
|
| 86 | 86 |
- Nombre d'activités traités : ${action.totalCatchActivities}
|
| 87 | 87 |
- Nombre d'activités traités (avec échantillon) : ${action.totalCatchActivitiesWithSample}
|
| ... | ... | @@ -80,7 +80,7 @@ Quality of sample stratum: |
| 80 | 80 |
Indicators
|
| 81 | 81 |
----------
|
| 82 | 82 |
|
| 83 |
-- Number of stratums: ${action.nbStratums}
|
|
| 83 |
+- Number of stratums: ${action.nbStratum}
|
|
| 84 | 84 |
- Number of treated stratums: ${action.nbStrataFixed}
|
| 85 | 85 |
- Number of treated sets: ${action.totalCatchActivities}
|
| 86 | 86 |
- Number of treated sets (with samples): ${action.totalCatchActivitiesWithSample}
|
| ... | ... | @@ -89,7 +89,7 @@ Qualité des strates échantillons : |
| 89 | 89 |
Indicateurs
|
| 90 | 90 |
-----------
|
| 91 | 91 |
|
| 92 |
-- Nombre de strates : ${action.nbStratums}
|
|
| 92 |
+- Nombre de strates : ${action.nbStratum}
|
|
| 93 | 93 |
- Nombre de strates corrigés : ${action.nbStrataFixed}
|
| 94 | 94 |
- Nombre d'activités traités : ${action.nbCatchActivities}
|
| 95 | 95 |
- Nombre d'activités traités (avec échantillon) : ${action.nbCatchActivitiesWithSample}
|
| ... | ... | @@ -89,7 +89,7 @@ Quality of sample stratum: |
| 89 | 89 |
Indicators
|
| 90 | 90 |
----------
|
| 91 | 91 |
|
| 92 |
-- Number of stratums: ${action.nbStratums}
|
|
| 92 |
+- Number of stratums: ${action.nbStratum}
|
|
| 93 | 93 |
- Number of treated stratums: ${action.nbStrataFixed}
|
| 94 | 94 |
- Number of treated sets: ${action.nbCatchActivities}
|
| 95 | 95 |
- Number of treated sets (with samples): ${action.nbCatchActivitiesWithSample}
|
| ... | ... | @@ -115,10 +115,10 @@ t3.level2.message.catchStratum.resume=Stratum Catch (count of sets %s, total wei |
| 115 | 115 |
t3.level2.message.noCatch.in.stratum=No catches found in this stratum
|
| 116 | 116 |
t3.level2.message.start.activity=Correct activity [%s/%s] \: %s (number of zones\: %s)
|
| 117 | 117 |
t3.level2.message.start.stratum=Treat %s
|
| 118 |
-t3.level2.message.strateInputGlobalComposition.resume=Global specific composition (before correction)\:
|
|
| 119 |
-t3.level2.message.strateOutputGlobalComposition.resume=Global specific composition (after correction)\:
|
|
| 118 |
+t3.level2.message.stratumInputGlobalComposition.resume=Global specific composition (before correction)\:
|
|
| 119 |
+t3.level2.message.stratumOutputGlobalComposition.resume=Global specific composition (after correction)\:
|
|
| 120 | 120 |
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
|
| 121 |
-t3.level2.stratumLabel=Stratum [%s/%s] (%s (sample %s) - zone %s - [start %s - end %s])
|
|
| 121 |
+t3.level2.stratumLabel=Stratum [%s/%s] (%s - zone %s - [start %s - end %s])
|
|
| 122 | 122 |
t3.level2.warning.missing.data.for.stratum=Impossible to compute sample stratum for %s, last substitution level reached.
|
| 123 | 123 |
t3.level3.action=Level 3 Treatment
|
| 124 | 124 |
t3.level3.catchStratum.nbFishesResume.title=Total count of fishes in catch stratum
|
| ... | ... | @@ -136,7 +136,7 @@ t3.level3.nbFishesBeforeLevel3=Before level 3 |
| 136 | 136 |
t3.level3.nbFishesResume.title=Total count of fishes
|
| 137 | 137 |
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 \:
|
| 138 | 138 |
t3.level3.sampleStratum.resume.for.level.and.species=\n Species %s \: %s
|
| 139 |
-t3.level3.stratumLabel=Stratum [%s/%s] (%s (sample %s) - zone %s - [begin %s - end %s])
|
|
| 139 |
+t3.level3.stratumLabel=Stratum [%s/%s] (%s - zone %s - [begin %s - end %s])
|
|
| 140 | 140 |
t3.level3.warning.missing.data.for.stratum=Impossible de compute sample stratum for stratum %s, last substitution level reached.
|
| 141 | 141 |
t3.level3.warning.missing.sample.species=Stratum %s, it miss a species %s in samples, can not extrapolate.
|
| 142 | 142 |
t3.message.create.new.vessel=Create a new vessel %s and store in db.
|
| ... | ... | @@ -115,10 +115,10 @@ t3.level2.message.catchStratum.resume=Strate capture (nombre de calées %s, poid |
| 115 | 115 |
t3.level2.message.noCatch.in.stratum=Aucune capture trouvée dans cette strate
|
| 116 | 116 |
t3.level2.message.start.activity=Correction de l'activité [%s/%s] \: %s (nombre de zones \: %s)
|
| 117 | 117 |
t3.level2.message.start.stratum=Traitement %s
|
| 118 |
-t3.level2.message.strateInputGlobalComposition.resume=Composition globale des captures avant correction \:
|
|
| 119 |
-t3.level2.message.strateOutputGlobalComposition.resume=Composition globale des captures après correction \:
|
|
| 118 |
+t3.level2.message.stratumInputGlobalComposition.resume=Composition globale des captures avant correction \:
|
|
| 119 |
+t3.level2.message.stratumOutputGlobalComposition.resume=Composition globale des captures après correction \:
|
|
| 120 | 120 |
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
|
| 121 |
-t3.level2.stratumLabel=Strate [%s/%s] (%s (échantillon %s) - zone %s - [debut %s - fin %s])
|
|
| 121 |
+t3.level2.stratumLabel=Strate [%s/%s] (%s - zone %s - [debut %s - fin %s])
|
|
| 122 | 122 |
t3.level2.warning.missing.data.for.stratum=Impossible de calculer la strate échantillon pour la strate %s, dernier niveau de substitution atteint.
|
| 123 | 123 |
t3.level3.action=Traitement de niveau 3
|
| 124 | 124 |
t3.level3.catchStratum.nbFishesResume.title=Nombre total de poissons dans la strate capture
|
| ... | ... | @@ -136,7 +136,7 @@ t3.level3.nbFishesBeforeLevel3=Avant niveau 3 |
| 136 | 136 |
t3.level3.nbFishesResume.title=Nombre total de poissons
|
| 137 | 137 |
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 \:
|
| 138 | 138 |
t3.level3.sampleStratum.resume.for.level.and.species=\n Espèce %s \: %s
|
| 139 |
-t3.level3.stratumLabel=Strate [%s/%s] (%s (échantillon %s) - zone %s - [debut %s - fin %s])
|
|
| 139 |
+t3.level3.stratumLabel=Strate [%s/%s] (%s - zone %s - [debut %s - fin %s])
|
|
| 140 | 140 |
t3.level3.warning.missing.data.for.stratum=Impossible de calculer la strate échantillon pour la strate %s, dernier niveau de substitution atteint.
|
| 141 | 141 |
t3.level3.warning.missing.sample.species=Strate %s, il manque une espèce %s dans les échantillons, extrapolation non possible.
|
| 142 | 142 |
t3.message.create.new.vessel=Création d'un nouveau navire %s et sauvegarde en base
|
| ... | ... | @@ -57,7 +57,7 @@ public class ComputeRF2ActionResumeTest extends AbstractActionResumeTest<Compute |
| 57 | 57 |
protected void prepareAction(ComputeRF2Action action, Locale locale) {
|
| 58 | 58 |
super.prepareAction(action, locale);
|
| 59 | 59 |
|
| 60 |
- action.nbStratums = 100;
|
|
| 60 |
+ action.nbStratum = 100;
|
|
| 61 | 61 |
action.nbTrips = 10;
|
| 62 | 62 |
action.nbTripsWithRF2 = 5;
|
| 63 | 63 |
}
|
| ... | ... | @@ -53,7 +53,7 @@ public class ComputeRF2EmptyConfigurationActionResumeTest extends AbstractAction |
| 53 | 53 |
protected void prepareAction(ComputeRF2Action action, Locale locale) {
|
| 54 | 54 |
super.prepareAction(action, locale);
|
| 55 | 55 |
|
| 56 |
- action.nbStratums = 100;
|
|
| 56 |
+ action.nbStratum = 100;
|
|
| 57 | 57 |
action.nbTrips = 10;
|
| 58 | 58 |
action.nbTripsWithRF2 = 5;
|
| 59 | 59 |
}
|
| ... | ... | @@ -8,12 +8,12 @@ |
| 8 | 8 |
* it under the terms of the GNU Affero General Public License as published by
|
| 9 | 9 |
* the Free Software Foundation, either version 3 of the License, or
|
| 10 | 10 |
* (at your option) any later version.
|
| 11 |
- *
|
|
| 11 |
+ *
|
|
| 12 | 12 |
* This program is distributed in the hope that it will be useful,
|
| 13 | 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 | 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 | 15 |
* GNU General Public License for more details.
|
| 16 |
- *
|
|
| 16 |
+ *
|
|
| 17 | 17 |
* You should have received a copy of the GNU Affero General Public License
|
| 18 | 18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 19 | 19 |
* #L%
|
| ... | ... | @@ -40,6 +40,10 @@ import java.util.Map; |
| 40 | 40 |
*/
|
| 41 | 41 |
public abstract class CatchStratum<C extends LevelConfigurationWithStratum, A extends T3Action<C>> extends Stratum<C, A> {
|
| 42 | 42 |
|
| 43 |
+ protected CatchStratum(StratumConfiguration<C> configuration, Collection<Species> speciesToFix) {
|
|
| 44 |
+ super(configuration, speciesToFix);
|
|
| 45 |
+ }
|
|
| 46 |
+ |
|
| 43 | 47 |
/**
|
| 44 | 48 |
* Gets a new loader of catch stratum.
|
| 45 | 49 |
*
|
| ... | ... | @@ -47,21 +51,13 @@ public abstract class CatchStratum<C extends LevelConfigurationWithStratum, A ex |
| 47 | 51 |
*/
|
| 48 | 52 |
protected abstract CatchStratumLoader<C> newLoader();
|
| 49 | 53 |
|
| 50 |
- protected CatchStratum(StratumConfiguration<C> configuration, Collection<Species> speciesToFix) {
|
|
| 51 |
- super(configuration, speciesToFix);
|
|
| 52 |
- }
|
|
| 53 |
- |
|
| 54 | 54 |
@Override
|
| 55 | 55 |
public void init(T3ServiceContext serviceContext, List<WeightCategoryTreatment> weightCategories, A messager) throws Exception {
|
| 56 |
- |
|
| 57 | 56 |
CatchStratumLoader<C> stratumLoader = newLoader();
|
| 58 |
- |
|
| 59 | 57 |
// inject transaction in loader
|
| 60 | 58 |
stratumLoader.setTransaction(serviceContext.getT3TopiaPersistenceContext());
|
| 61 |
- |
|
| 62 |
- // inject daos in loader
|
|
| 59 |
+ // inject dao in loader
|
|
| 63 | 60 |
serviceContext.newService(IOCService.class).injectOnly(stratumLoader, InjectDAO.class);
|
| 64 |
- |
|
| 65 | 61 |
// get all catches usable in this stratum grouped by their owing activity
|
| 66 | 62 |
Map<Activity, Integer> activities = stratumLoader.loadData(getConfiguration());
|
| 67 | 63 |
setActivities(activities);
|
| ... | ... | @@ -22,18 +22,17 @@ package fr.ird.t3.actions.stratum; |
| 22 | 22 |
|
| 23 | 23 |
import fr.ird.t3.actions.T3Action;
|
| 24 | 24 |
import fr.ird.t3.entities.data.Activity;
|
| 25 |
-import fr.ird.t3.entities.reference.SchoolType;
|
|
| 26 | 25 |
import fr.ird.t3.entities.reference.Species;
|
| 27 | 26 |
import fr.ird.t3.entities.reference.WeightCategoryTreatment;
|
| 28 | 27 |
import fr.ird.t3.services.IOCService;
|
| 29 | 28 |
import fr.ird.t3.services.T3ServiceContext;
|
| 30 | 29 |
import fr.ird.t3.services.ioc.InjectDAO;
|
| 30 |
+import org.nuiton.topia.persistence.TopiaException;
|
|
| 31 |
+ |
|
| 31 | 32 |
import java.util.Collection;
|
| 32 | 33 |
import java.util.List;
|
| 33 | 34 |
import java.util.Map;
|
| 34 |
-import java.util.Objects;
|
|
| 35 | 35 |
import java.util.Set;
|
| 36 |
-import org.nuiton.topia.persistence.TopiaException;
|
|
| 37 | 36 |
|
| 38 | 37 |
/**
|
| 39 | 38 |
* Base samle stratum.
|
| ... | ... | @@ -61,19 +60,6 @@ public abstract class SampleStratum<C extends LevelConfigurationWithStratum, A e |
| 61 | 60 |
*/
|
| 62 | 61 |
private Integer substitutionLevel;
|
| 63 | 62 |
|
| 64 |
- public static SchoolType getSampleSchoolType(SchoolType schoolType,SchoolTypeIndeterminate schoolTypeIndeterminate , SchoolType boSchoolType, SchoolType blSchoolType) {
|
|
| 65 |
- if (Objects.requireNonNull(schoolType).getCode() == 3) {
|
|
| 66 |
- switch (Objects.requireNonNull(schoolTypeIndeterminate)) {
|
|
| 67 |
- case ALL_IN_BO:
|
|
| 68 |
- return boSchoolType;
|
|
| 69 |
- case ALL_IN_BL:
|
|
| 70 |
- return blSchoolType;
|
|
| 71 |
- }
|
|
| 72 |
- throw new IllegalStateException("Can't deal with " + schoolTypeIndeterminate);
|
|
| 73 |
- }
|
|
| 74 |
- return schoolType;
|
|
| 75 |
- }
|
|
| 76 |
- |
|
| 77 | 63 |
protected abstract SampleStratumLoader<C, A, S> newLoader();
|
| 78 | 64 |
|
| 79 | 65 |
protected abstract String logSampleStratumLevel(int substitutionLevel,
|
| ... | ... | @@ -31,7 +31,8 @@ import fr.ird.t3.t3.domain.I18nEnumHelper; |
| 31 | 31 |
*/
|
| 32 | 32 |
public enum SchoolTypeIndeterminate {
|
| 33 | 33 |
ALL_IN_BO, // consider as BO
|
| 34 |
- ALL_IN_BL; // consider as BL
|
|
| 34 |
+ ALL_IN_BL, // consider as BL
|
|
| 35 |
+ IGNORE; // just report incoming data
|
|
| 35 | 36 |
|
| 36 | 37 |
public String getLabel() {
|
| 37 | 38 |
return I18nEnumHelper.getLabel(this);
|
| ... | ... | @@ -8,12 +8,12 @@ |
| 8 | 8 |
* it under the terms of the GNU Affero General Public License as published by
|
| 9 | 9 |
* the Free Software Foundation, either version 3 of the License, or
|
| 10 | 10 |
* (at your option) any later version.
|
| 11 |
- *
|
|
| 11 |
+ *
|
|
| 12 | 12 |
* This program is distributed in the hope that it will be useful,
|
| 13 | 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 | 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 | 15 |
* GNU General Public License for more details.
|
| 16 |
- *
|
|
| 16 |
+ *
|
|
| 17 | 17 |
* You should have received a copy of the GNU Affero General Public License
|
| 18 | 18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 19 | 19 |
* #L%
|
| ... | ... | @@ -46,28 +46,31 @@ import java.util.Set; |
| 46 | 46 |
public abstract class Stratum<C extends LevelConfigurationWithStratum, A extends T3Action<C>> implements Closeable, Iterable<Map.Entry<Activity, Integer>> {
|
| 47 | 47 |
|
| 48 | 48 |
/**
|
| 49 |
- * All activities selected for this stratum, with for catch stratum the number of zones where the activity should be used.
|
|
| 50 |
- * <p/>
|
|
| 51 |
- * see http://forge.codelutin.com/issues/1935
|
|
| 52 |
- * <p/>
|
|
| 53 |
- * <strong>Note:</strong> This data are available after invocation of method
|
|
| 54 |
- * {@link Stratum#init(T3ServiceContext, List, T3Action)}.
|
|
| 55 |
- */
|
|
| 56 |
- private Map<Activity, Integer> activities;
|
|
| 57 |
- |
|
| 58 |
- /**
|
|
| 59 | 49 |
* Stratum configuration of this stratum.
|
| 60 | 50 |
*
|
| 61 | 51 |
* @see StratumConfiguration
|
| 62 | 52 |
*/
|
| 63 | 53 |
private final StratumConfiguration<C> configuration;
|
| 64 |
- |
|
| 65 | 54 |
/**
|
| 66 | 55 |
* Selected set of species to fix.
|
| 67 | 56 |
*
|
| 68 | 57 |
* @since 1.3.1
|
| 69 | 58 |
*/
|
| 70 | 59 |
private final Set<Species> speciesToFix;
|
| 60 |
+ /**
|
|
| 61 |
+ * All activities selected for this stratum, with for catch stratum the number of zones where the activity should be used.
|
|
| 62 |
+ * <p/>
|
|
| 63 |
+ * see http://forge.codelutin.com/issues/1935
|
|
| 64 |
+ * <p/>
|
|
| 65 |
+ * <strong>Note:</strong> This data are available after invocation of method
|
|
| 66 |
+ * {@link Stratum#init(T3ServiceContext, List, T3Action)}.
|
|
| 67 |
+ */
|
|
| 68 |
+ private Map<Activity, Integer> activities;
|
|
| 69 |
+ |
|
| 70 |
+ protected Stratum(StratumConfiguration<C> configuration, Collection<Species> speciesToFix) {
|
|
| 71 |
+ this.configuration = configuration;
|
|
| 72 |
+ this.speciesToFix = ImmutableSet.copyOf(speciesToFix);
|
|
| 73 |
+ }
|
|
| 71 | 74 |
|
| 72 | 75 |
/**
|
| 73 | 76 |
* Initialize the data of the stratum.
|
| ... | ... | @@ -79,16 +82,12 @@ public abstract class Stratum<C extends LevelConfigurationWithStratum, A extends |
| 79 | 82 |
*/
|
| 80 | 83 |
public abstract void init(T3ServiceContext serviceContext, List<WeightCategoryTreatment> weightCategories, A messager) throws Exception;
|
| 81 | 84 |
|
| 85 |
+ @SuppressWarnings("NullableProblems")
|
|
| 82 | 86 |
@Override
|
| 83 | 87 |
public Iterator<Map.Entry<Activity, Integer>> iterator() {
|
| 84 | 88 |
return activities.entrySet().iterator();
|
| 85 | 89 |
}
|
| 86 | 90 |
|
| 87 |
- protected Stratum(StratumConfiguration<C> configuration, Collection<Species> speciesToFix) {
|
|
| 88 |
- this.configuration = configuration;
|
|
| 89 |
- this.speciesToFix = ImmutableSet.copyOf(speciesToFix);
|
|
| 90 |
- }
|
|
| 91 |
- |
|
| 92 | 91 |
public final StratumConfiguration<C> getConfiguration() {
|
| 93 | 92 |
return configuration;
|
| 94 | 93 |
}
|
| ... | ... | @@ -102,14 +101,12 @@ public abstract class Stratum<C extends LevelConfigurationWithStratum, A extends |
| 102 | 101 |
}
|
| 103 | 102 |
|
| 104 | 103 |
/**
|
| 105 |
- * Obtain the activities selected for this stratum with the number of zones
|
|
| 106 |
- * they are involved in.
|
|
| 104 |
+ * Obtain the activities selected for this stratum with the number of zones they are involved in.
|
|
| 107 | 105 |
* <p/>
|
| 108 | 106 |
* The number of zones (see http://forge.codelutin.com/issues/1935) is only
|
| 109 | 107 |
* used for catch stratum, for sample stratum always used a single zone.
|
| 110 | 108 |
* <p/>
|
| 111 |
- * <strong>Note: </strong> to invoke this method, you need first to invoke
|
|
| 112 |
- * the {@link Stratum#init(T3ServiceContext, List, T3Action}
|
|
| 109 |
+ * <strong>Note: </strong> to invoke this method, you need first to invoke the {@link #init(T3ServiceContext, List, T3Action)}
|
|
| 113 | 110 |
*
|
| 114 | 111 |
* @return the set of activities found for this stratum.
|
| 115 | 112 |
*/
|
| ... | ... | @@ -21,7 +21,9 @@ |
| 21 | 21 |
package fr.ird.t3.actions.stratum;
|
| 22 | 22 |
|
| 23 | 23 |
import com.google.common.cache.LoadingCache;
|
| 24 |
+import com.google.common.collect.ImmutableSet;
|
|
| 24 | 25 |
import fr.ird.t3.entities.data.Activity;
|
| 26 |
+import fr.ird.t3.entities.reference.AbstractSchoolTypeTopiaDao;
|
|
| 25 | 27 |
import fr.ird.t3.entities.reference.SchoolType;
|
| 26 | 28 |
import fr.ird.t3.entities.reference.Vessel;
|
| 27 | 29 |
import fr.ird.t3.entities.reference.WeightCategoryTreatment;
|
| ... | ... | @@ -51,7 +53,6 @@ public class StratumConfiguration<C extends LevelConfigurationWithStratum> { |
| 51 | 53 |
private final ZoneStratumAwareMeta zoneMeta;
|
| 52 | 54 |
private final ZoneStratumAware zone;
|
| 53 | 55 |
private final SchoolType schoolType;
|
| 54 |
- private final SchoolType sampleSchoolType;
|
|
| 55 | 56 |
private final WeightCategoryTreatment weightCategoryTreatment;
|
| 56 | 57 |
private final T3Date beginDate;
|
| 57 | 58 |
private final T3Date endDate;
|
| ... | ... | @@ -65,8 +66,8 @@ public class StratumConfiguration<C extends LevelConfigurationWithStratum> { |
| 65 | 66 |
ZoneStratumAwareMeta zoneMeta,
|
| 66 | 67 |
ZoneStratumAware zone,
|
| 67 | 68 |
SchoolType schoolType,
|
| 68 |
- SchoolType sampleSchoolType,
|
|
| 69 |
- WeightCategoryTreatment weightCategoryTreatment, T3Date beginDate,
|
|
| 69 |
+ WeightCategoryTreatment weightCategoryTreatment,
|
|
| 70 |
+ T3Date beginDate,
|
|
| 70 | 71 |
T3Date endDate,
|
| 71 | 72 |
Collection<ZoneStratumAware> zones,
|
| 72 | 73 |
Set<Vessel> possibleCatchVessels,
|
| ... | ... | @@ -77,7 +78,6 @@ public class StratumConfiguration<C extends LevelConfigurationWithStratum> { |
| 77 | 78 |
this.zoneMeta = zoneMeta;
|
| 78 | 79 |
this.zone = zone;
|
| 79 | 80 |
this.schoolType = schoolType;
|
| 80 |
- this.sampleSchoolType = sampleSchoolType;
|
|
| 81 | 81 |
this.weightCategoryTreatment = weightCategoryTreatment;
|
| 82 | 82 |
this.beginDate = beginDate;
|
| 83 | 83 |
this.endDate = endDate;
|
| ... | ... | @@ -92,27 +92,26 @@ public class StratumConfiguration<C extends LevelConfigurationWithStratum> { |
| 92 | 92 |
* Obtain a new stratum configuration given all his parameters.
|
| 93 | 93 |
*
|
| 94 | 94 |
* @param <C> type of configuration
|
| 95 |
- * @param conf the level action configuration
|
|
| 95 |
+ * @param configuration the level action configuration
|
|
| 96 | 96 |
* @param zoneMeta type of zone to use
|
| 97 | 97 |
* @param zone the zone of the stratum
|
| 98 | 98 |
* @param schoolType the school type of the stratum
|
| 99 |
- * @param sampleSchoolType the school type of the sample stratum
|
|
| 100 | 99 |
* @param weightCategoryTreatment the weight category of the stratum (not nul only if {@link LevelConfigurationWithStratum#isUseWeightCategoriesInStratum()} is {@code true}.
|
| 101 | 100 |
* @param startDate the start date of the stratum
|
| 102 | 101 |
* @param endDate the end date of the stratum
|
| 103 |
- * @param zones all the zones useable by the level action which used this stratum (can be used for sample stratum substitution)
|
|
| 102 |
+ * @param zones all the zones usable by the level action which used this stratum (can be used for sample stratum substitution)
|
|
| 104 | 103 |
* @param possibleCatchVessels set of possible vessels to use when selecting data in the catch stratum
|
| 105 | 104 |
* @param possibleSampleVessels set of possible vessels to use when selecting data in the sample stratum
|
| 106 | 105 |
* @param stratumMinimumCountBySpecie minimum sample count needed by species for sample stratum substitution
|
| 107 | 106 |
* @return the new instantiated stratum configuration
|
| 108 | 107 |
*/
|
| 109 | 108 |
public static <C extends LevelConfigurationWithStratum> StratumConfiguration<C> newStratumConfiguration(
|
| 110 |
- C conf,
|
|
| 109 |
+ C configuration,
|
|
| 111 | 110 |
ZoneStratumAwareMeta zoneMeta,
|
| 112 | 111 |
ZoneStratumAware zone,
|
| 113 | 112 |
SchoolType schoolType,
|
| 114 |
- SchoolType sampleSchoolType,
|
|
| 115 |
- WeightCategoryTreatment weightCategoryTreatment, T3Date startDate,
|
|
| 113 |
+ WeightCategoryTreatment weightCategoryTreatment,
|
|
| 114 |
+ T3Date startDate,
|
|
| 116 | 115 |
T3Date endDate,
|
| 117 | 116 |
Collection<ZoneStratumAware> zones,
|
| 118 | 117 |
Set<Vessel> possibleCatchVessels,
|
| ... | ... | @@ -121,11 +120,10 @@ public class StratumConfiguration<C extends LevelConfigurationWithStratum> { |
| 121 | 120 |
LoadingCache<String, Activity> activityCache) {
|
| 122 | 121 |
|
| 123 | 122 |
return new StratumConfiguration<>(
|
| 124 |
- conf,
|
|
| 123 |
+ configuration,
|
|
| 125 | 124 |
zoneMeta,
|
| 126 | 125 |
zone,
|
| 127 | 126 |
schoolType,
|
| 128 |
- sampleSchoolType,
|
|
| 129 | 127 |
weightCategoryTreatment,
|
| 130 | 128 |
startDate,
|
| 131 | 129 |
endDate,
|
| ... | ... | @@ -140,7 +138,7 @@ public class StratumConfiguration<C extends LevelConfigurationWithStratum> { |
| 140 | 138 |
return configuration;
|
| 141 | 139 |
}
|
| 142 | 140 |
|
| 143 |
- public ZoneStratumAwareMeta getZoneMeta() {
|
|
| 141 |
+ private ZoneStratumAwareMeta getZoneMeta() {
|
|
| 144 | 142 |
return zoneMeta;
|
| 145 | 143 |
}
|
| 146 | 144 |
|
| ... | ... | @@ -156,8 +154,23 @@ public class StratumConfiguration<C extends LevelConfigurationWithStratum> { |
| 156 | 154 |
return schoolType;
|
| 157 | 155 |
}
|
| 158 | 156 |
|
| 159 |
- public SchoolType getSampleSchoolType() {
|
|
| 160 |
- return sampleSchoolType;
|
|
| 157 |
+ public Set<String> getSchoolTypeIds() {
|
|
| 158 |
+ ImmutableSet.Builder<String> builder = ImmutableSet.<String>builder().add(getSchoolType().getTopiaId());
|
|
| 159 |
+ switch (configuration.getSchoolTypeIndeterminate()) {
|
|
| 160 |
+ case ALL_IN_BO:
|
|
| 161 |
+ if (AbstractSchoolTypeTopiaDao.SCHOOL_TYPE_BO_ID.equals(getSchoolType().getTopiaId())) {
|
|
| 162 |
+ builder.add(AbstractSchoolTypeTopiaDao.SCHOOL_TYPE_INDETERMINATE_ID);
|
|
| 163 |
+ }
|
|
| 164 |
+ break;
|
|
| 165 |
+ case ALL_IN_BL:
|
|
| 166 |
+ if (AbstractSchoolTypeTopiaDao.SCHOOL_TYPE_BL_ID.equals(getSchoolType().getTopiaId())) {
|
|
| 167 |
+ builder.add(AbstractSchoolTypeTopiaDao.SCHOOL_TYPE_INDETERMINATE_ID);
|
|
| 168 |
+ }
|
|
| 169 |
+ break;
|
|
| 170 |
+ case IGNORE:
|
|
| 171 |
+ break;
|
|
| 172 |
+ }
|
|
| 173 |
+ return builder.build();
|
|
| 161 | 174 |
}
|
| 162 | 175 |
|
| 163 | 176 |
public T3Date getBeginDate() {
|
| ... | ... | @@ -211,7 +224,7 @@ public class StratumConfiguration<C extends LevelConfigurationWithStratum> { |
| 211 | 224 |
|
| 212 | 225 |
@Override
|
| 213 | 226 |
public String toString() {
|
| 214 |
- 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);
|
|
| 227 |
+ return String.format("%s [schoolType: %s, zone: %s, startDate:%s, endDate:%s, weightCategory: %s]", super.toString(), schoolType.getLabel1(), zone.getTopiaId(), beginDate, endDate, weightCategoryTreatment);
|
|
| 215 | 228 |
}
|
| 216 | 229 |
|
| 217 | 230 |
public void addToActivity(Activity activity, Function<Activity, String> function, BiConsumer<Activity, String> consumer, int level) {
|
| ... | ... | @@ -31,7 +31,6 @@ import fr.ird.t3.entities.reference.WeightCategoryTreatment; |
| 31 | 31 |
import fr.ird.t3.entities.type.T3Date;
|
| 32 | 32 |
import fr.ird.t3.models.WeightCompositionAggregateModel;
|
| 33 | 33 |
import org.apache.commons.collections.CollectionUtils;
|
| 34 |
-import org.nuiton.topia.persistence.TopiaException;
|
|
| 35 | 34 |
import org.nuiton.topia.persistence.support.TopiaSqlQuery;
|
| 36 | 35 |
import org.nuiton.topia.persistence.support.TopiaSqlSupport;
|
| 37 | 36 |
|
| ... | ... | @@ -187,35 +186,26 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv |
| 187 | 186 |
return correctedElementaryCatch.stream().map(SpeciesAware::getSpecies).collect(Collectors.toSet());
|
| 188 | 187 |
}
|
| 189 | 188 |
|
| 190 |
-// public boolean isActivityWithSample(Activity activity) throws TopiaException {
|
|
| 191 |
-// SampleSetTopiaDao sampleSetDAO = topiaDaoSupplier.getDao(SampleSet.class, SampleSetTopiaDao.class);
|
|
| 192 |
-// List<SampleSet> allByActivity = sampleSetDAO.forActivityEquals(activity).findAll();
|
|
| 193 |
-// return CollectionUtils.isNotEmpty(allByActivity);
|
|
| 194 |
-// }
|
|
| 195 |
- |
|
| 196 | 189 |
public Map<String, Integer> findAllActivityIdsForCatchStratum(String zoneTableName,
|
| 197 | 190 |
String zoneId,
|
| 198 |
- String schoolTypeId,
|
|
| 191 |
+ Set<String> schoolTypeIds,
|
|
| 199 | 192 |
T3Date beginDate,
|
| 200 |
- T3Date endDate) throws TopiaException {
|
|
| 201 |
- |
|
| 193 |
+ T3Date endDate) {
|
|
| 202 | 194 |
// ---
|
| 203 | 195 |
// Get activities strictly inside the zone
|
| 204 | 196 |
// ---
|
| 205 |
- TopiaSqlQuery<String> query = new GetActivityIdsInZoneForCatchStratumQuery(zoneTableName, zoneId, schoolTypeId, beginDate, endDate);
|
|
| 197 |
+ TopiaSqlQuery<String> query = new GetActivityIdsInZoneForCatchStratumQuery(zoneTableName, zoneId, schoolTypeIds, beginDate, endDate);
|
|
| 206 | 198 |
List<String> activityIds = topiaSqlSupport.findMultipleResult(query);
|
| 207 | 199 |
Map<String, Integer> result = new HashMap<>();
|
| 208 | 200 |
for (String activityId : activityIds) {
|
| 209 | 201 |
// activity strictly inside a zone are exactly in one zone
|
| 210 | 202 |
result.put(activityId, 1);
|
| 211 | 203 |
}
|
| 212 |
- |
|
| 213 | 204 |
// ---
|
| 214 | 205 |
// Get activities on the border of the zone
|
| 215 | 206 |
// ---
|
| 216 |
- query = new GetActivityIdsInBorderForCatchStratumQuery(zoneTableName, zoneId, schoolTypeId, beginDate, endDate);
|
|
| 207 |
+ query = new GetActivityIdsInBorderForCatchStratumQuery(zoneTableName, zoneId, schoolTypeIds, beginDate, endDate);
|
|
| 217 | 208 |
activityIds = topiaSqlSupport.findMultipleResult(query);
|
| 218 |
- |
|
| 219 | 209 |
// ---
|
| 220 | 210 |
// Get nb zones of such activities
|
| 221 | 211 |
// ---
|
| ... | ... | @@ -228,117 +218,76 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv |
| 228 | 218 |
return result;
|
| 229 | 219 |
}
|
| 230 | 220 |
|
| 231 |
-// public static void fillWeightsFromCorrectedCatchesWeight(Activity activity,
|
|
| 232 |
-// Map<WeightCategoryTreatment, Map<Species, Float>> weights,
|
|
| 233 |
-// WeightCompositionAggregateModel model) {
|
|
| 234 |
-//
|
|
| 235 |
-// if (weights == null) {
|
|
| 236 |
-// weights = new HashMap<>();
|
|
| 237 |
-// }
|
|
| 238 |
-// Multimap<WeightCategoryTreatment, CorrectedElementaryCatch> data =
|
|
| 239 |
-// ActivityTopiaDao.groupByWeightCategoryTreatment(activity.getCorrectedElementaryCatch());
|
|
| 240 |
-//
|
|
| 241 |
-// T3IOUtil.fillMapWithDefaultValue(
|
|
| 242 |
-// weights, data.keySet(), T3Suppliers.MAP_SPECIES_FLOAT_SUPPLIER);
|
|
| 243 |
-//
|
|
| 244 |
-// for (WeightCategoryTreatment weightCategory : data.keySet()) {
|
|
| 245 |
-//
|
|
| 246 |
-// Map<Species, Float> speciesFloatMap = weights.get(weightCategory);
|
|
| 247 |
-//
|
|
| 248 |
-// Collection<CorrectedElementaryCatch> correctedElementaryCatches = data.get(weightCategory);
|
|
| 249 |
-//
|
|
| 250 |
-// fillWeights(weightCategory,
|
|
| 251 |
-// correctedElementaryCatches,
|
|
| 252 |
-// speciesFloatMap,
|
|
| 253 |
-// T3Functions.CORRECTED_ELEMENTARY_CATCH_TO_CORRECTED_CATCH_WEIGHT,
|
|
| 254 |
-// model
|
|
| 255 |
-// );
|
|
| 256 |
-// }
|
|
| 257 |
-// }
|
|
| 258 |
- |
|
| 259 | 221 |
public List<String> findAllActivityIdsForSampleStratum(String zoneTableName,
|
| 260 | 222 |
String zoneId,
|
| 261 |
- String schoolTypeId,
|
|
| 223 |
+ Set<String> schoolTypeIds,
|
|
| 262 | 224 |
T3Date beginDate,
|
| 263 |
- T3Date endDate) throws TopiaException {
|
|
| 225 |
+ T3Date endDate) {
|
|
| 264 | 226 |
TopiaSqlQuery<String> query;
|
| 265 |
- if (schoolTypeId == null) {
|
|
| 227 |
+ if (schoolTypeIds == null) {
|
|
| 266 | 228 |
// for any school type
|
| 267 | 229 |
query = new GetActivityIdsForSampleStratumWithAnySchoolTypeQuery(zoneTableName, zoneId, beginDate, endDate);
|
| 268 | 230 |
} else {
|
| 269 | 231 |
// for a specific school type
|
| 270 |
- query = new GetActivityIdsForSampleStratumQuery(zoneTableName, zoneId, schoolTypeId, beginDate, endDate);
|
|
| 232 |
+ query = new GetActivityIdsForSampleStratumQuery(zoneTableName, zoneId, schoolTypeIds, beginDate, endDate);
|
|
| 271 | 233 |
}
|
| 272 | 234 |
return topiaSqlSupport.findMultipleResult(query);
|
| 273 | 235 |
}
|
| 274 | 236 |
|
| 275 |
-// public Set<Species> getAllSpeciesFromCorrectedCatches(Activity activity) {
|
|
| 276 |
-// Set<Species> result = new HashSet<>();
|
|
| 277 |
-// for (CorrectedElementaryCatch aCatch : activity.getCorrectedElementaryCatch()) {
|
|
| 278 |
-// result.add(aCatch.getSpecies());
|
|
| 279 |
-// }
|
|
| 280 |
-// return result;
|
|
| 281 |
-// }
|
|
| 282 |
- |
|
| 283 |
-// public Set<Species> getAllSpeciesFromSetSpeciesFrequencies(Activity activity) {
|
|
| 284 |
-// Set<Species> result = new HashSet<>();
|
|
| 285 |
-// for (SetSpeciesFrequency frequency : activity.getSetSpeciesFrequency()) {
|
|
| 286 |
-// result.add(frequency.getSpecies());
|
|
| 287 |
-// }
|
|
| 288 |
-// return result;
|
|
| 289 |
-// }
|
|
| 290 |
- |
|
| 291 | 237 |
/**
|
| 292 | 238 |
* Query to obtain from the given configuration, all the activity ids of a catch stratum.
|
| 293 | 239 |
*
|
| 294 | 240 |
* @since 1.0
|
| 295 | 241 |
*/
|
| 242 |
+ @SuppressWarnings("SqlResolve")
|
|
| 296 | 243 |
public static class GetActivityIdsInZoneForCatchStratumQuery extends TopiaSqlQuery<String> {
|
| 297 | 244 |
|
| 298 | 245 |
private final String zoneTableName;
|
| 299 |
- |
|
| 300 | 246 |
private final String zoneId;
|
| 301 |
- |
|
| 302 |
- private final String schoolTypeId;
|
|
| 303 |
- |
|
| 247 |
+ private final Set<String> schoolTypeIds;
|
|
| 304 | 248 |
private final T3Date beginDate;
|
| 305 |
- |
|
| 306 | 249 |
private final T3Date endDate;
|
| 307 | 250 |
|
| 308 | 251 |
GetActivityIdsInZoneForCatchStratumQuery(String zoneTableName,
|
| 309 | 252 |
String zoneId,
|
| 310 |
- String schoolTypeId,
|
|
| 253 |
+ Set<String> schoolTypeIds,
|
|
| 311 | 254 |
T3Date beginDate,
|
| 312 | 255 |
T3Date endDate) {
|
| 313 | 256 |
this.zoneTableName = zoneTableName;
|
| 314 | 257 |
this.zoneId = zoneId;
|
| 315 |
- this.schoolTypeId = schoolTypeId;
|
|
| 258 |
+ this.schoolTypeIds = schoolTypeIds;
|
|
| 316 | 259 |
this.beginDate = beginDate;
|
| 317 | 260 |
this.endDate = endDate;
|
| 318 | 261 |
}
|
| 319 | 262 |
|
| 320 | 263 |
@Override
|
| 321 | 264 |
public PreparedStatement prepareQuery(Connection connection) throws SQLException {
|
| 265 |
+ StringBuilder schoolTypeParameters = new StringBuilder();
|
|
| 266 |
+ for (String ignored : schoolTypeIds) {
|
|
| 267 |
+ schoolTypeParameters.append(", ?");
|
|
| 268 |
+ }
|
|
| 322 | 269 |
PreparedStatement ps = connection.prepareStatement(
|
| 323 |
- "SELECT a.topiaid FROM trip t, activity a, " +
|
|
| 324 |
- zoneTableName + " z WHERE " +
|
|
| 325 |
- "a.trip = t.topiaId " +
|
|
| 270 |
+ "SELECT a.topiaid FROM trip t, activity a, " + zoneTableName + " z " +
|
|
| 271 |
+ "WHERE a.trip = t.topiaId " +
|
|
| 326 | 272 |
"AND t." + Trip.PROPERTY_TRIP_TYPE + " IN (0, 2)" +
|
| 327 | 273 |
"AND t." + Trip.PROPERTY_COMPLETION_STATUS + " IS NOT NULL " +
|
| 328 | 274 |
"AND t." + Trip.PROPERTY_COMPLETION_STATUS + " > 0 " +
|
| 329 | 275 |
"AND ST_WITHIN(a.the_geom, z.the_geom) " +
|
| 330 | 276 |
"AND z.topiaid = ? " +
|
| 331 | 277 |
"AND a.expertflag != 0 " +
|
| 332 |
- "AND a.schooltype = ? " +
|
|
| 278 |
+ "AND a.schooltype IN (" + schoolTypeParameters.substring(2) + ")" +
|
|
| 333 | 279 |
"AND a.date::date >= ? " +
|
| 334 | 280 |
"AND a.date::date <= ? " +
|
| 335 | 281 |
"AND (SELECT COUNT(*) FROM CorrectedElementaryCatch c WHERE c.activity = a.topiaid) > 0"
|
| 336 | 282 |
);
|
| 337 | 283 |
|
| 338 |
- ps.setString(1, zoneId);
|
|
| 339 |
- ps.setString(2, schoolTypeId);
|
|
| 340 |
- ps.setDate(3, beginDate.toBeginSqlDate());
|
|
| 341 |
- ps.setDate(4, endDate.toEndSqlDate());
|
|
| 284 |
+ int index = 0;
|
|
| 285 |
+ ps.setString(++index, zoneId);
|
|
| 286 |
+ for (String schoolTypeId : schoolTypeIds) {
|
|
| 287 |
+ ps.setString(++index, schoolTypeId);
|
|
| 288 |
+ }
|
|
| 289 |
+ ps.setDate(++index, beginDate.toBeginSqlDate());
|
|
| 290 |
+ ps.setDate(++index, endDate.toEndSqlDate());
|
|
| 342 | 291 |
return ps;
|
| 343 | 292 |
}
|
| 344 | 293 |
|
| ... | ... | @@ -349,37 +298,37 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv |
| 349 | 298 |
}
|
| 350 | 299 |
|
| 351 | 300 |
/**
|
| 352 |
- * Query to obtain from the given configuration, all the activity ids of a
|
|
| 353 |
- * catch stratum.
|
|
| 301 |
+ * Query to obtain from the given configuration, all the activity ids of a catch stratum.
|
|
| 354 | 302 |
*
|
| 355 | 303 |
* @since 1.0
|
| 356 | 304 |
*/
|
| 305 |
+ @SuppressWarnings("SqlResolve")
|
|
| 357 | 306 |
public static class GetActivityIdsInBorderForCatchStratumQuery extends TopiaSqlQuery<String> {
|
| 358 | 307 |
|
| 359 | 308 |
private final String zoneTableName;
|
| 360 |
- |
|
| 361 | 309 |
private final String zoneId;
|
| 362 |
- |
|
| 363 |
- private final String schoolTypeId;
|
|
| 364 |
- |
|
| 310 |
+ private final Set<String> schoolTypeIds;
|
|
| 365 | 311 |
private final T3Date beginDate;
|
| 366 |
- |
|
| 367 | 312 |
private final T3Date endDate;
|
| 368 | 313 |
|
| 369 | 314 |
GetActivityIdsInBorderForCatchStratumQuery(String zoneTableName,
|
| 370 | 315 |
String zoneId,
|
| 371 |
- String schoolTypeId,
|
|
| 316 |
+ Set<String> schoolTypeIds,
|
|
| 372 | 317 |
T3Date beginDate,
|
| 373 | 318 |
T3Date endDate) {
|
| 374 | 319 |
this.zoneTableName = zoneTableName;
|
| 375 | 320 |
this.zoneId = zoneId;
|
| 376 |
- this.schoolTypeId = schoolTypeId;
|
|
| 321 |
+ this.schoolTypeIds = schoolTypeIds;
|
|
| 377 | 322 |
this.beginDate = beginDate;
|
| 378 | 323 |
this.endDate = endDate;
|
| 379 | 324 |
}
|
| 380 | 325 |
|
| 381 | 326 |
@Override
|
| 382 | 327 |
public PreparedStatement prepareQuery(Connection connection) throws SQLException {
|
| 328 |
+ StringBuilder schoolTypeParameters = new StringBuilder();
|
|
| 329 |
+ for (String ignored : schoolTypeIds) {
|
|
| 330 |
+ schoolTypeParameters.append(", ?");
|
|
| 331 |
+ }
|
|
| 383 | 332 |
PreparedStatement ps = connection.prepareStatement(
|
| 384 | 333 |
"SELECT a.topiaid FROM trip t, activity a, " +
|
| 385 | 334 |
zoneTableName + " z WHERE " +
|
| ... | ... | @@ -391,16 +340,18 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv |
| 391 | 340 |
"AND NOT ST_WITHIN(a.the_geom, z.the_geom) " +
|
| 392 | 341 |
"AND z.topiaid = ? " +
|
| 393 | 342 |
"AND a.expertflag != 0 " +
|
| 394 |
- "AND a.schooltype = ? " +
|
|
| 343 |
+ "AND a.schooltype = IN (" + schoolTypeParameters.substring(2) + ") " +
|
|
| 395 | 344 |
"AND a.date::date >= ? " +
|
| 396 | 345 |
"AND a.date::date <= ? " +
|
| 397 |
- "AND (SELECT COUNT(*) FROM CorrectedElementaryCatch c WHERE c.activity = a.topiaid) > 0"
|
|
| 398 |
- );
|
|
| 346 |
+ "AND (SELECT COUNT(*) FROM CorrectedElementaryCatch c WHERE c.activity = a.topiaid) > 0");
|
|
| 399 | 347 |
|
| 400 |
- ps.setString(1, zoneId);
|
|
| 401 |
- ps.setString(2, schoolTypeId);
|
|
| 402 |
- ps.setDate(3, beginDate.toBeginSqlDate());
|
|
| 403 |
- ps.setDate(4, endDate.toEndSqlDate());
|
|
| 348 |
+ int index = 0;
|
|
| 349 |
+ ps.setString(++index, zoneId);
|
|
| 350 |
+ for (String schoolTypeId : schoolTypeIds) {
|
|
| 351 |
+ ps.setString(++index, schoolTypeId);
|
|
| 352 |
+ }
|
|
| 353 |
+ ps.setDate(++index, beginDate.toBeginSqlDate());
|
|
| 354 |
+ ps.setDate(++index, endDate.toEndSqlDate());
|
|
| 404 | 355 |
return ps;
|
| 405 | 356 |
}
|
| 406 | 357 |
|
| ... | ... | @@ -411,37 +362,37 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv |
| 411 | 362 |
}
|
| 412 | 363 |
|
| 413 | 364 |
/**
|
| 414 |
- * Query to obtain from the given configuration, all the activity ids of a
|
|
| 415 |
- * sample stratum.
|
|
| 365 |
+ * Query to obtain from the given configuration, all the activity ids of a sample stratum.
|
|
| 416 | 366 |
*
|
| 417 | 367 |
* @since 1.0
|
| 418 | 368 |
*/
|
| 369 |
+ @SuppressWarnings("SqlResolve")
|
|
| 419 | 370 |
public static class GetActivityIdsForSampleStratumQuery extends TopiaSqlQuery<String> {
|
| 420 | 371 |
|
| 421 | 372 |
private final String zoneTableName;
|
| 422 |
- |
|
| 423 | 373 |
private final String zoneId;
|
| 424 |
- |
|
| 425 |
- private final String schoolTypeId;
|
|
| 426 |
- |
|
| 374 |
+ private final Set<String> schoolTypeIds;
|
|
| 427 | 375 |
private final T3Date beginDate;
|
| 428 |
- |
|
| 429 | 376 |
private final T3Date endDate;
|
| 430 | 377 |
|
| 431 | 378 |
GetActivityIdsForSampleStratumQuery(String zoneTableName,
|
| 432 | 379 |
String zoneId,
|
| 433 |
- String schoolTypeId,
|
|
| 380 |
+ Set<String> schoolTypeIds,
|
|
| 434 | 381 |
T3Date beginDate,
|
| 435 | 382 |
T3Date endDate) {
|
| 436 | 383 |
this.zoneTableName = zoneTableName;
|
| 437 | 384 |
this.zoneId = zoneId;
|
| 438 |
- this.schoolTypeId = schoolTypeId;
|
|
| 385 |
+ this.schoolTypeIds = schoolTypeIds;
|
|
| 439 | 386 |
this.beginDate = beginDate;
|
| 440 | 387 |
this.endDate = endDate;
|
| 441 | 388 |
}
|
| 442 | 389 |
|
| 443 | 390 |
@Override
|
| 444 | 391 |
public PreparedStatement prepareQuery(Connection connection) throws SQLException {
|
| 392 |
+ StringBuilder schoolTypeParameters = new StringBuilder();
|
|
| 393 |
+ for (String ignored : schoolTypeIds) {
|
|
| 394 |
+ schoolTypeParameters.append(", ?");
|
|
| 395 |
+ }
|
|
| 445 | 396 |
PreparedStatement ps = connection.prepareStatement(
|
| 446 | 397 |
"SELECT a.topiaid FROM trip t, activity a, " +
|
| 447 | 398 |
zoneTableName + " z WHERE " +
|
| ... | ... | @@ -451,15 +402,17 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv |
| 451 | 402 |
"AND t." + Trip.PROPERTY_COMPLETION_STATUS + " > 0 ))" +
|
| 452 | 403 |
"AND ST_WITHIN(a.the_geom, z.the_geom) " +
|
| 453 | 404 |
"AND z.topiaid = ? " +
|
| 454 |
- "AND a.schooltype = ?" +
|
|
| 405 |
+ "AND a.schooltype = IN (" + schoolTypeParameters.substring(2) + ")" +
|
|
| 455 | 406 |
"AND a.date::date >= ? " +
|
| 456 | 407 |
"AND a.date::date <= ? " +
|
| 457 |
- "AND (SELECT COUNT(*) FROM SetSpeciesCatWeight c WHERE c.activity = a.topiaid) > 0"
|
|
| 458 |
- );
|
|
| 459 |
- ps.setString(1, zoneId);
|
|
| 460 |
- ps.setString(2, schoolTypeId);
|
|
| 461 |
- ps.setDate(3, beginDate.toBeginSqlDate());
|
|
| 462 |
- ps.setDate(4, endDate.toEndSqlDate());
|
|
| 408 |
+ "AND (SELECT COUNT(*) FROM SetSpeciesCatWeight c WHERE c.activity = a.topiaid) > 0");
|
|
| 409 |
+ int index = 0;
|
|
| 410 |
+ ps.setString(++index, zoneId);
|
|
| 411 |
+ for (String schoolTypeId : schoolTypeIds) {
|
|
| 412 |
+ ps.setString(++index, schoolTypeId);
|
|
| 413 |
+ }
|
|
| 414 |
+ ps.setDate(++index, beginDate.toBeginSqlDate());
|
|
| 415 |
+ ps.setDate(++index, endDate.toEndSqlDate());
|
|
| 463 | 416 |
return ps;
|
| 464 | 417 |
}
|
| 465 | 418 |
|
| ... | ... | @@ -471,25 +424,19 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv |
| 471 | 424 |
|
| 472 | 425 |
/**
|
| 473 | 426 |
* Query to obtain from the given configuration, all the activity ids of a
|
| 474 |
- * sample stratum for any school type (used by level 3 last substitution
|
|
| 475 |
- * level).
|
|
| 427 |
+ * sample stratum for any school type (used by level 3 last substitution level).
|
|
| 476 | 428 |
*
|
| 477 | 429 |
* @since 1.4
|
| 478 | 430 |
*/
|
| 431 |
+ @SuppressWarnings("SqlResolve")
|
|
| 479 | 432 |
public static class GetActivityIdsForSampleStratumWithAnySchoolTypeQuery extends TopiaSqlQuery<String> {
|
| 480 | 433 |
|
| 481 | 434 |
private final String zoneTableName;
|
| 482 |
- |
|
| 483 | 435 |
private final String zoneId;
|
| 484 |
- |
|
| 485 | 436 |
private final T3Date beginDate;
|
| 486 |
- |
|
| 487 | 437 |
private final T3Date endDate;
|
| 488 | 438 |
|
| 489 |
- GetActivityIdsForSampleStratumWithAnySchoolTypeQuery(String zoneTableName,
|
|
| 490 |
- String zoneId,
|
|
| 491 |
- T3Date beginDate,
|
|
| 492 |
- T3Date endDate) {
|
|
| 439 |
+ GetActivityIdsForSampleStratumWithAnySchoolTypeQuery(String zoneTableName, String zoneId, T3Date beginDate, T3Date endDate) {
|
|
| 493 | 440 |
this.zoneTableName = zoneTableName;
|
| 494 | 441 |
this.zoneId = zoneId;
|
| 495 | 442 |
this.beginDate = beginDate;
|
| ... | ... | @@ -524,11 +471,11 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv |
| 524 | 471 |
}
|
| 525 | 472 |
|
| 526 | 473 |
/**
|
| 527 |
- * Query to obtain from the given configuration, all the activity ids of a
|
|
| 528 |
- * sample stratum.
|
|
| 474 |
+ * Query to obtain from the given configuration, all the activity ids of a sample stratum.
|
|
| 529 | 475 |
*
|
| 530 | 476 |
* @since 1.4
|
| 531 | 477 |
*/
|
| 478 |
+ @SuppressWarnings("SqlResolve")
|
|
| 532 | 479 |
public static class GetActivityIdsAndNbZonesQuery extends TopiaSqlQuery<Integer> {
|
| 533 | 480 |
|
| 534 | 481 |
private final String zoneTableName;
|
| ... | ... | @@ -542,12 +489,10 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv |
| 542 | 489 |
@Override
|
| 543 | 490 |
public PreparedStatement prepareQuery(Connection connection) throws SQLException {
|
| 544 | 491 |
PreparedStatement ps = connection.prepareStatement(
|
| 545 |
- "SELECT count(*) " +
|
|
| 546 |
- "FROM activity a, " + zoneTableName + " z " +
|
|
| 492 |
+ "SELECT count(*) FROM activity a, " + zoneTableName + " z " +
|
|
| 547 | 493 |
"WHERE a.topiaId = ? " +
|
| 548 | 494 |
"AND ST_INTERSECTS(a.the_geom, z.the_geom) " +
|
| 549 |
- "AND z.schoolType = a.schoolType"
|
|
| 550 |
- );
|
|
| 495 |
+ "AND z.schoolType = a.schoolType");
|
|
| 551 | 496 |
ps.setString(1, activityId);
|
| 552 | 497 |
return ps;
|
| 553 | 498 |
}
|
| ... | ... | @@ -557,10 +502,61 @@ public class AbstractActivityTopiaDao<E extends Activity> extends GeneratedActiv |
| 557 | 502 |
return set.getInt(1);
|
| 558 | 503 |
}
|
| 559 | 504 |
|
| 560 |
- public int getNbZones(TopiaSqlSupport context, String activityId) throws TopiaException {
|
|
| 505 |
+ int getNbZones(TopiaSqlSupport context, String activityId) {
|
|
| 561 | 506 |
this.activityId = activityId;
|
| 562 | 507 |
return context.findSingleResult(this);
|
| 563 | 508 |
}
|
| 564 | 509 |
|
| 565 | 510 |
}
|
| 511 |
+ |
|
| 512 |
+// public boolean isActivityWithSample(Activity activity) {
|
|
| 513 |
+// SampleSetTopiaDao sampleSetDAO = topiaDaoSupplier.getDao(SampleSet.class, SampleSetTopiaDao.class);
|
|
| 514 |
+// List<SampleSet> allByActivity = sampleSetDAO.forActivityEquals(activity).findAll();
|
|
| 515 |
+// return CollectionUtils.isNotEmpty(allByActivity);
|
|
| 516 |
+// }
|
|
| 517 |
+ |
|
| 518 |
+// public static void fillWeightsFromCorrectedCatchesWeight(Activity activity,
|
|
| 519 |
+// Map<WeightCategoryTreatment, Map<Species, Float>> weights,
|
|
| 520 |
+// WeightCompositionAggregateModel model) {
|
|
| 521 |
+//
|
|
| 522 |
+// if (weights == null) {
|
|
| 523 |
+// weights = new HashMap<>();
|
|
| 524 |
+// }
|
|
| 525 |
+// Multimap<WeightCategoryTreatment, CorrectedElementaryCatch> data =
|
|
| 526 |
+// ActivityTopiaDao.groupByWeightCategoryTreatment(activity.getCorrectedElementaryCatch());
|
|
| 527 |
+//
|
|
| 528 |
+// T3IOUtil.fillMapWithDefaultValue(
|
|
| 529 |
+// weights, data.keySet(), T3Suppliers.MAP_SPECIES_FLOAT_SUPPLIER);
|
|
| 530 |
+//
|
|
| 531 |
+// for (WeightCategoryTreatment weightCategory : data.keySet()) {
|
|
| 532 |
+//
|
|
| 533 |
+// Map<Species, Float> speciesFloatMap = weights.get(weightCategory);
|
|
| 534 |
+//
|
|
| 535 |
+// Collection<CorrectedElementaryCatch> correctedElementaryCatches = data.get(weightCategory);
|
|
| 536 |
+//
|
|
| 537 |
+// fillWeights(weightCategory,
|
|
| 538 |
+// correctedElementaryCatches,
|
|
| 539 |
+// speciesFloatMap,
|
|
| 540 |
+// T3Functions.CORRECTED_ELEMENTARY_CATCH_TO_CORRECTED_CATCH_WEIGHT,
|
|
| 541 |
+// model
|
|
| 542 |
+// );
|
|
| 543 |
+// }
|
|
| 544 |
+// }
|
|
| 545 |
+ |
|
| 546 |
+// public Set<Species> getAllSpeciesFromCorrectedCatches(Activity activity) {
|
|
| 547 |
+// Set<Species> result = new HashSet<>();
|
|
| 548 |
+// for (CorrectedElementaryCatch aCatch : activity.getCorrectedElementaryCatch()) {
|
|
| 549 |
+// result.add(aCatch.getSpecies());
|
|
| 550 |
+// }
|
|
| 551 |
+// return result;
|
|
| 552 |
+// }
|
|
| 553 |
+ |
|
| 554 |
+// public Set<Species> getAllSpeciesFromSetSpeciesFrequencies(Activity activity) {
|
|
| 555 |
+// Set<Species> result = new HashSet<>();
|
|
| 556 |
+// for (SetSpeciesFrequency frequency : activity.getSetSpeciesFrequency()) {
|
|
| 557 |
+// result.add(frequency.getSpecies());
|
|
| 558 |
+// }
|
|
| 559 |
+// return result;
|
|
| 560 |
+// }
|
|
| 561 |
+ |
|
| 566 | 562 |
}
|
| ... | ... | @@ -27,9 +27,13 @@ import java.util.Set; |
| 27 | 27 |
|
| 28 | 28 |
public class AbstractSchoolTypeTopiaDao<E extends SchoolType> extends GeneratedSchoolTypeTopiaDao<E> {
|
| 29 | 29 |
|
| 30 |
+ public static final String SCHOOL_TYPE_INDETERMINATE_ID = "fr.ird.t3.entities.reference.SchoolType#1297580528908#0.9747685881931636";
|
|
| 31 |
+ public static final String SCHOOL_TYPE_BL_ID = "fr.ird.t3.entities.reference.SchoolType#1297580528908#0.633774803291473";
|
|
| 32 |
+ public static final String SCHOOL_TYPE_BO_ID = "fr.ird.t3.entities.reference.SchoolType#1297580528908#0.8923578380543445";
|
|
| 33 |
+ |
|
| 30 | 34 |
/**
|
| 31 |
- * Obtain the two school types usabel while doing level 2 and 3 : says the
|
|
| 32 |
- * free school type (code = 1) and the object school type.
|
|
| 35 |
+ * Obtain the two school types usable while doing level 2 and 3 : says the
|
|
| 36 |
+ * free school type and the object school type.
|
|
| 33 | 37 |
*
|
| 34 | 38 |
* @return the two school types
|
| 35 | 39 |
* @throws TopiaException if any problem while loading data form database
|
| ... | ... | @@ -37,9 +41,8 @@ public class AbstractSchoolTypeTopiaDao<E extends SchoolType> extends GeneratedS |
| 37 | 41 |
@SuppressWarnings("unused")
|
| 38 | 42 |
public Set<E> findAllForStratum() {
|
| 39 | 43 |
Set<E> result = new HashSet<>();
|
| 40 |
- result.add(forCodeEquals(1).findUnique());
|
|
| 41 |
- result.add(forCodeEquals(2).findUnique());
|
|
| 42 |
- result.add(forCodeEquals(3).findUnique());
|
|
| 44 |
+ result.add(forTopiaIdEquals(SCHOOL_TYPE_BL_ID).findUnique());
|
|
| 45 |
+ result.add(forTopiaIdEquals(SCHOOL_TYPE_BO_ID).findUnique());
|
|
| 43 | 46 |
return result;
|
| 44 | 47 |
}
|
| 45 | 48 |
}
|
| ... | ... | @@ -164,6 +164,7 @@ t3.config.treatment.working.directory.description=Location of treatment director |
| 164 | 164 |
t3.config.users.file.description=Application users file
|
| 165 | 165 |
t3.enum.fr.ird.t3.actions.stratum.SchoolTypeIndeterminate.ALL_IN_BL=Use Free school type
|
| 166 | 166 |
t3.enum.fr.ird.t3.actions.stratum.SchoolTypeIndeterminate.ALL_IN_BO=Use Object school type
|
| 167 |
+t3.enum.fr.ird.t3.actions.stratum.SchoolTypeIndeterminate.IGNORE=Do not process
|
|
| 167 | 168 |
t3.enum.fr.ird.t3.entities.data.TripType.LOGBOOKMISSING=Without Logbook
|
| 168 | 169 |
t3.enum.fr.ird.t3.entities.data.TripType.SAMPLEONLY=Samples only
|
| 169 | 170 |
t3.enum.fr.ird.t3.entities.data.TripType.STANDARD=Standard
|
| ... | ... | @@ -164,6 +164,7 @@ t3.config.treatment.working.directory.description=Répertoire de travail |
| 164 | 164 |
t3.config.users.file.description=Fichier contenant les utilisateurs de l'application
|
| 165 | 165 |
t3.enum.fr.ird.t3.actions.stratum.SchoolTypeIndeterminate.ALL_IN_BL=Traiter comme des Bancs objets
|
| 166 | 166 |
t3.enum.fr.ird.t3.actions.stratum.SchoolTypeIndeterminate.ALL_IN_BO=Traiter comme des Bancs libres
|
| 167 |
+t3.enum.fr.ird.t3.actions.stratum.SchoolTypeIndeterminate.IGNORE=Ne pas traiter
|
|
| 167 | 168 |
t3.enum.fr.ird.t3.entities.data.TripType.LOGBOOKMISSING=Sans logbook
|
| 168 | 169 |
t3.enum.fr.ird.t3.entities.data.TripType.SAMPLEONLY=Echantillons uniquement
|
| 169 | 170 |
t3.enum.fr.ird.t3.entities.data.TripType.STANDARD=Standard
|