Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: 68d34317 by Tony Chemit at 2023-05-11T15:45:12+02:00 update pom - - - - - c6bfd4e0 by Tony Chemit at 2023-05-12T15:38:03+02:00 Dans la consolidation des poids pondérés des cuves-calées, il faut effectuer un filtre sur une liste d'espèces - Closes #2689 - - - - - 5 changed files: - core/persistence/consolidation/src/main/java/fr/ird/observe/consolidation/data/ps/logbook/SampleActivityConsolidateActions.java - core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/logbook/WellActivityImpl.java - core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/logbook/WellImpl.java - model/src/main/models/Observe/persistence/21-data-ps-logbook.model - pom.xml Changes: ===================================== core/persistence/consolidation/src/main/java/fr/ird/observe/consolidation/data/ps/logbook/SampleActivityConsolidateActions.java ===================================== @@ -42,6 +42,25 @@ public enum SampleActivityConsolidateActions implements AtomicConsolidateAction< * Compute {@link SampleActivity#getWeightedWeight()}. */ ComputeWeightedWeight() { + + /** + * Filter on these species to compute any weight on SampleActivitySpecies + */ + public final Set<String> SPECIES_IDS = Set.of( + "fr.ird.referential.common.Species#1239832685474#0.8943253454598569", // YFT + "fr.ird.referential.common.Species#1239832685474#0.975344121171992", // SKJ + "fr.ird.referential.common.Species#1239832685475#0.13349466123905152", // BET + "fr.ird.referential.common.Species#1239832685476#0.5618871286604711", // ALB + "fr.ird.referential.common.Species#1239832685477#0.8024257002747615", // LTA + "fr.ird.referential.common.Species#1239832685477#0.3846921632590058", // FRI + "fr.ird.referential.common.Species#1441287921299#0.016754076421811148", // TUN + "fr.ird.referential.common.Species#1433499265113#0.891799515346065", // TUS + "fr.ird.referential.common.Species#1239832685477#0.2673009297087321", // KAW + "fr.ird.referential.common.Species#1239832685478#0.7676744877900202", // LOT + "fr.ird.referential.common.Species#1239832685477#0.5989181185528589", // FRZ + "fr.ird.referential.common.Species#1239832685476#0.36339915670317835" // BLT + ); + @Override public List<String> fieldNames() { return List.of(SampleActivity.PROPERTY_WEIGHTED_WEIGHT, SampleActivity.PROPERTY_WEIGHTED_WEIGHT_COMPUTED); @@ -61,7 +80,7 @@ public enum SampleActivityConsolidateActions implements AtomicConsolidateAction< // See https://gitlab.com/ultreiaio/ird-observe/-/issues/2053 // Get total weight of the set which is this well - double w1 = context.sumOnTripWell(w -> w.getTotalWeight(activity, Set.of(wellId))); + double w1 = context.sumOnTripWell(w -> w.getTotalWeight(activity, SPECIES_IDS, Set.of(wellId))); if (w1 == 0) { // limit case if the well was not found in trip well plan log.warn("Well {} not found for activity {} in trip well plan.", wellId, activity.getTopiaId()); @@ -70,9 +89,9 @@ public enum SampleActivityConsolidateActions implements AtomicConsolidateAction< return; } // Get total weight of the set which are in well that has been sampled - double w2 = context.sumOnTripWell(w -> w.getTotalWeight(activity, context.getSampledWellIds())); + double w2 = context.sumOnTripWell(w -> w.getTotalWeight(activity, SPECIES_IDS, context.getSampledWellIds())); // Get total weight of the set in any well - double wT = context.sumOnTripWell(w -> w.getTotalWeight(activity)); + double wT = context.sumOnTripWell(w -> w.getTotalWeight(activity, SPECIES_IDS)); // the weighted weight is the formula: weightedWeight = (w1/w2)*wT float weightedWeight = (float) ((w1 / w2) * wT); Float oldWeightedWeight = datum.getWeightedWeight(); ===================================== core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/logbook/WellActivityImpl.java ===================================== @@ -25,17 +25,19 @@ package fr.ird.observe.entities.data.ps.logbook; import io.ultreia.java4all.decoration.Decorator; import io.ultreia.java4all.decoration.DecoratorProvider; +import java.util.Collection; + public class WellActivityImpl extends WellActivityAbstract { private static final long serialVersionUID = 1L; @Override - public double getTotalWeight(Activity activity) { - return getActivity().equals(activity) ? getTotalWeight() : 0; + public double getTotalWeight(Activity activity, Collection<String> speciesIds) { + return getActivity().equals(activity) ? getTotalWeight(speciesIds) : 0; } @Override - public double getTotalWeight() { - return getWellActivitySpecies().stream().mapToDouble(WellActivitySpecies::getWeight).sum(); + public double getTotalWeight(Collection<String> speciesIds) { + return getWellActivitySpecies().stream().filter(was -> speciesIds.contains(was.getSpecies().getId())).mapToDouble(WellActivitySpecies::getWeight).sum(); } @Override ===================================== core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/logbook/WellImpl.java ===================================== @@ -35,12 +35,12 @@ public class WellImpl extends WellAbstract { private static final long serialVersionUID = 1L; @Override - public double getTotalWeight(Activity activity) { - return getWellActivity().stream().mapToDouble(wa -> wa.getTotalWeight(activity)).sum(); + public double getTotalWeight(Activity activity, Collection<String> speciesIds) { + return getWellActivity().stream().mapToDouble(wa -> wa.getTotalWeight(activity, speciesIds)).sum(); } @Override - public double getTotalWeight(Activity activity, Collection<String> wellIds) { - return wellIds.contains(getWell()) ? getTotalWeight(activity) : 0; + public double getTotalWeight(Activity activity, Collection<String> speciesIds, Collection<String> wellIds) { + return wellIds.contains(getWell()) ? getTotalWeight(activity, speciesIds) : 0; } } ===================================== model/src/main/models/Observe/persistence/21-data-ps-logbook.model ===================================== @@ -119,14 +119,14 @@ wellFactory String wellSamplingConformity {*:1} referential.ps.logbook.WellSamplingConformity wellSamplingStatus {*:1} referential.ps.logbook.WellSamplingStatus wellActivity + {0:*} data.ps.logbook.WellActivity -getTotalWeight(activity data.ps.logbook.Activity) double -getTotalWeight(activity data.ps.logbook.Activity, wellIds java.util.Collection<String>) double +getTotalWeight(activity data.ps.logbook.Activity, speciesIds java.util.Collection<String>) double +getTotalWeight(activity data.ps.logbook.Activity, speciesIds java.util.Collection<String>, wellIds java.util.Collection<String>) double data.ps.logbook.WellActivity > data.DataEntity >> fr.ird.observe.dto.data.ps.logbook.ActivityLabelAware activity {*:1} data.ps.logbook.Activity wellActivitySpecies + {0:*} data.ps.logbook.WellActivitySpecies -getTotalWeight() double -getTotalWeight(activity data.ps.logbook.Activity) double +getTotalWeight(speciesIds java.util.Collection<String>) double +getTotalWeight(activity data.ps.logbook.Activity, speciesIds java.util.Collection<String>) double data.ps.logbook.WellActivitySpecies > data.DataEntity species {*:1} referential.common.Species ===================================== pom.xml ===================================== @@ -23,7 +23,7 @@ <parent> <groupId>io.ultreia.maven</groupId> <artifactId>pom</artifactId> - <version>2023.21</version> + <version>2023.22</version> </parent> <groupId>fr.ird.observe</groupId> <artifactId>ird-observe</artifactId> View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/198a38824a2bb62f465cb4154... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/198a38824a2bb62f465cb4154... You're receiving this email because of your account on gitlab.com.