Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
68d34317
by Tony Chemit at 2023-05-11T15:45:12+02:00
-
c6bfd4e0
by Tony Chemit at 2023-05-12T15:38:03+02:00
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:
| ... | ... | @@ -42,6 +42,25 @@ public enum SampleActivityConsolidateActions implements AtomicConsolidateAction< |
| 42 | 42 | * Compute {@link SampleActivity#getWeightedWeight()}.
|
| 43 | 43 | */
|
| 44 | 44 | ComputeWeightedWeight() {
|
| 45 | + |
|
| 46 | + /**
|
|
| 47 | + * Filter on these species to compute any weight on SampleActivitySpecies
|
|
| 48 | + */
|
|
| 49 | + public final Set<String> SPECIES_IDS = Set.of(
|
|
| 50 | + "fr.ird.referential.common.Species#1239832685474#0.8943253454598569", // YFT
|
|
| 51 | + "fr.ird.referential.common.Species#1239832685474#0.975344121171992", // SKJ
|
|
| 52 | + "fr.ird.referential.common.Species#1239832685475#0.13349466123905152", // BET
|
|
| 53 | + "fr.ird.referential.common.Species#1239832685476#0.5618871286604711", // ALB
|
|
| 54 | + "fr.ird.referential.common.Species#1239832685477#0.8024257002747615", // LTA
|
|
| 55 | + "fr.ird.referential.common.Species#1239832685477#0.3846921632590058", // FRI
|
|
| 56 | + "fr.ird.referential.common.Species#1441287921299#0.016754076421811148", // TUN
|
|
| 57 | + "fr.ird.referential.common.Species#1433499265113#0.891799515346065", // TUS
|
|
| 58 | + "fr.ird.referential.common.Species#1239832685477#0.2673009297087321", // KAW
|
|
| 59 | + "fr.ird.referential.common.Species#1239832685478#0.7676744877900202", // LOT
|
|
| 60 | + "fr.ird.referential.common.Species#1239832685477#0.5989181185528589", // FRZ
|
|
| 61 | + "fr.ird.referential.common.Species#1239832685476#0.36339915670317835" // BLT
|
|
| 62 | + );
|
|
| 63 | + |
|
| 45 | 64 | @Override
|
| 46 | 65 | public List<String> fieldNames() {
|
| 47 | 66 | return List.of(SampleActivity.PROPERTY_WEIGHTED_WEIGHT, SampleActivity.PROPERTY_WEIGHTED_WEIGHT_COMPUTED);
|
| ... | ... | @@ -61,7 +80,7 @@ public enum SampleActivityConsolidateActions implements AtomicConsolidateAction< |
| 61 | 80 | // See https://gitlab.com/ultreiaio/ird-observe/-/issues/2053
|
| 62 | 81 | |
| 63 | 82 | // Get total weight of the set which is this well
|
| 64 | - double w1 = context.sumOnTripWell(w -> w.getTotalWeight(activity, Set.of(wellId)));
|
|
| 83 | + double w1 = context.sumOnTripWell(w -> w.getTotalWeight(activity, SPECIES_IDS, Set.of(wellId)));
|
|
| 65 | 84 | if (w1 == 0) {
|
| 66 | 85 | // limit case if the well was not found in trip well plan
|
| 67 | 86 | log.warn("Well {} not found for activity {} in trip well plan.", wellId, activity.getTopiaId());
|
| ... | ... | @@ -70,9 +89,9 @@ public enum SampleActivityConsolidateActions implements AtomicConsolidateAction< |
| 70 | 89 | return;
|
| 71 | 90 | }
|
| 72 | 91 | // Get total weight of the set which are in well that has been sampled
|
| 73 | - double w2 = context.sumOnTripWell(w -> w.getTotalWeight(activity, context.getSampledWellIds()));
|
|
| 92 | + double w2 = context.sumOnTripWell(w -> w.getTotalWeight(activity, SPECIES_IDS, context.getSampledWellIds()));
|
|
| 74 | 93 | // Get total weight of the set in any well
|
| 75 | - double wT = context.sumOnTripWell(w -> w.getTotalWeight(activity));
|
|
| 94 | + double wT = context.sumOnTripWell(w -> w.getTotalWeight(activity, SPECIES_IDS));
|
|
| 76 | 95 | // the weighted weight is the formula: weightedWeight = (w1/w2)*wT
|
| 77 | 96 | float weightedWeight = (float) ((w1 / w2) * wT);
|
| 78 | 97 | Float oldWeightedWeight = datum.getWeightedWeight();
|
| ... | ... | @@ -25,17 +25,19 @@ package fr.ird.observe.entities.data.ps.logbook; |
| 25 | 25 | import io.ultreia.java4all.decoration.Decorator;
|
| 26 | 26 | import io.ultreia.java4all.decoration.DecoratorProvider;
|
| 27 | 27 | |
| 28 | +import java.util.Collection;
|
|
| 29 | + |
|
| 28 | 30 | public class WellActivityImpl extends WellActivityAbstract {
|
| 29 | 31 | private static final long serialVersionUID = 1L;
|
| 30 | 32 | |
| 31 | 33 | @Override
|
| 32 | - public double getTotalWeight(Activity activity) {
|
|
| 33 | - return getActivity().equals(activity) ? getTotalWeight() : 0;
|
|
| 34 | + public double getTotalWeight(Activity activity, Collection<String> speciesIds) {
|
|
| 35 | + return getActivity().equals(activity) ? getTotalWeight(speciesIds) : 0;
|
|
| 34 | 36 | }
|
| 35 | 37 | |
| 36 | 38 | @Override
|
| 37 | - public double getTotalWeight() {
|
|
| 38 | - return getWellActivitySpecies().stream().mapToDouble(WellActivitySpecies::getWeight).sum();
|
|
| 39 | + public double getTotalWeight(Collection<String> speciesIds) {
|
|
| 40 | + return getWellActivitySpecies().stream().filter(was -> speciesIds.contains(was.getSpecies().getId())).mapToDouble(WellActivitySpecies::getWeight).sum();
|
|
| 39 | 41 | }
|
| 40 | 42 | |
| 41 | 43 | @Override
|
| ... | ... | @@ -35,12 +35,12 @@ public class WellImpl extends WellAbstract { |
| 35 | 35 | private static final long serialVersionUID = 1L;
|
| 36 | 36 | |
| 37 | 37 | @Override
|
| 38 | - public double getTotalWeight(Activity activity) {
|
|
| 39 | - return getWellActivity().stream().mapToDouble(wa -> wa.getTotalWeight(activity)).sum();
|
|
| 38 | + public double getTotalWeight(Activity activity, Collection<String> speciesIds) {
|
|
| 39 | + return getWellActivity().stream().mapToDouble(wa -> wa.getTotalWeight(activity, speciesIds)).sum();
|
|
| 40 | 40 | }
|
| 41 | 41 | |
| 42 | 42 | @Override
|
| 43 | - public double getTotalWeight(Activity activity, Collection<String> wellIds) {
|
|
| 44 | - return wellIds.contains(getWell()) ? getTotalWeight(activity) : 0;
|
|
| 43 | + public double getTotalWeight(Activity activity, Collection<String> speciesIds, Collection<String> wellIds) {
|
|
| 44 | + return wellIds.contains(getWell()) ? getTotalWeight(activity, speciesIds) : 0;
|
|
| 45 | 45 | }
|
| 46 | 46 | } |
| ... | ... | @@ -119,14 +119,14 @@ wellFactory String |
| 119 | 119 | wellSamplingConformity {*:1} referential.ps.logbook.WellSamplingConformity
|
| 120 | 120 | wellSamplingStatus {*:1} referential.ps.logbook.WellSamplingStatus
|
| 121 | 121 | wellActivity + {0:*} data.ps.logbook.WellActivity
|
| 122 | -getTotalWeight(activity data.ps.logbook.Activity) double
|
|
| 123 | -getTotalWeight(activity data.ps.logbook.Activity, wellIds java.util.Collection<String>) double
|
|
| 122 | +getTotalWeight(activity data.ps.logbook.Activity, speciesIds java.util.Collection<String>) double
|
|
| 123 | +getTotalWeight(activity data.ps.logbook.Activity, speciesIds java.util.Collection<String>, wellIds java.util.Collection<String>) double
|
|
| 124 | 124 | |
| 125 | 125 | data.ps.logbook.WellActivity > data.DataEntity >> fr.ird.observe.dto.data.ps.logbook.ActivityLabelAware
|
| 126 | 126 | activity {*:1} data.ps.logbook.Activity
|
| 127 | 127 | wellActivitySpecies + {0:*} data.ps.logbook.WellActivitySpecies
|
| 128 | -getTotalWeight() double
|
|
| 129 | -getTotalWeight(activity data.ps.logbook.Activity) double
|
|
| 128 | +getTotalWeight(speciesIds java.util.Collection<String>) double
|
|
| 129 | +getTotalWeight(activity data.ps.logbook.Activity, speciesIds java.util.Collection<String>) double
|
|
| 130 | 130 | |
| 131 | 131 | data.ps.logbook.WellActivitySpecies > data.DataEntity
|
| 132 | 132 | species {*:1} referential.common.Species
|
| ... | ... | @@ -23,7 +23,7 @@ |
| 23 | 23 | <parent>
|
| 24 | 24 | <groupId>io.ultreia.maven</groupId>
|
| 25 | 25 | <artifactId>pom</artifactId>
|
| 26 | - <version>2023.21</version>
|
|
| 26 | + <version>2023.22</version>
|
|
| 27 | 27 | </parent>
|
| 28 | 28 | <groupId>fr.ird.observe</groupId>
|
| 29 | 29 | <artifactId>ird-observe</artifactId>
|