Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
3682dc3f
by Tony Chemit at 2023-01-14T17:34:05+01:00
7 changed files:
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/common/TripConsolidateEngine.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/common/TripSpi.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/logbook/ActivityImpl.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/observation/ActivityImpl.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/observation/SetSpi.java
- model/src/main/models/Observe/persistence/20-data-ps-observation.model
- model/src/main/models/Observe/persistence/21-data-ps-logbook.model
Changes:
| ... | ... | @@ -242,7 +242,7 @@ public class TripConsolidateEngine { |
| 242 | 242 | return;
|
| 243 | 243 | }
|
| 244 | 244 | fr.ird.observe.entities.referential.ps.common.SchoolType oldSchoolType = set.getSchoolType();
|
| 245 | - String newSchoolTypeId = activity.getSchoolTypeId();
|
|
| 245 | + String newSchoolTypeId = activity.computeSchoolTypeId();
|
|
| 246 | 246 | if (oldSchoolType == null || !oldSchoolType.getTopiaId().equals(newSchoolTypeId)) {
|
| 247 | 247 | // le type de banc a changé, on doit sauver l'activité
|
| 248 | 248 | SchoolType newSchoolType = SchoolType.loadEntity(context, newSchoolTypeId);
|
| ... | ... | @@ -43,14 +43,12 @@ import fr.ird.observe.entities.referential.common.Person; |
| 43 | 43 | import fr.ird.observe.entities.referential.common.Species;
|
| 44 | 44 | import fr.ird.observe.entities.referential.common.SpeciesList;
|
| 45 | 45 | import fr.ird.observe.entities.referential.ps.common.AcquisitionStatus;
|
| 46 | -import fr.ird.observe.entities.referential.ps.common.ObservedSystem;
|
|
| 47 | 46 | import fr.ird.observe.entities.referential.ps.common.Program;
|
| 48 | 47 | import fr.ird.observe.entities.referential.ps.logbook.WellContentStatus;
|
| 49 | 48 | import fr.ird.observe.spi.service.ServiceContext;
|
| 50 | 49 | import io.ultreia.java4all.util.Dates;
|
| 51 | 50 | import io.ultreia.java4all.util.sql.SqlScriptWriter;
|
| 52 | 51 | |
| 53 | -import java.util.Collection;
|
|
| 54 | 52 | import java.util.Date;
|
| 55 | 53 | import java.util.LinkedHashSet;
|
| 56 | 54 | import java.util.List;
|
| ... | ... | @@ -58,7 +56,6 @@ import java.util.Map; |
| 58 | 56 | import java.util.Objects;
|
| 59 | 57 | import java.util.Set;
|
| 60 | 58 | import java.util.function.Function;
|
| 61 | -import java.util.function.Supplier;
|
|
| 62 | 59 | import java.util.stream.Collectors;
|
| 63 | 60 | import java.util.stream.Stream;
|
| 64 | 61 | |
| ... | ... | @@ -68,45 +65,8 @@ import java.util.stream.Stream; |
| 68 | 65 | * @author Tony Chemit - dev@tchemit.fr
|
| 69 | 66 | * @since 9.0.0
|
| 70 | 67 | */
|
| 71 | -@SuppressWarnings("SpellCheckingInspection")
|
|
| 72 | 68 | public class TripSpi extends GeneratedTripSpi {
|
| 73 | 69 | |
| 74 | - /**
|
|
| 75 | - * Calcule le type de banc d'une activité.
|
|
| 76 | - * <p>
|
|
| 77 | - * par défaut, on considère la caléee sur BL.
|
|
| 78 | - * <p>
|
|
| 79 | - * Si l'activité possède au moins un système observe de type BO alors la caléee est de type BO.
|
|
| 80 | - *
|
|
| 81 | - * @param floatingObjectEmpty y a til des dcp
|
|
| 82 | - * @param getObservedSystem pour obtenir les systèmes observés
|
|
| 83 | - * @return le type de banc a appliquer
|
|
| 84 | - * @since 1.5
|
|
| 85 | - */
|
|
| 86 | - public static String computeSchoolTypeId(Supplier<Boolean> floatingObjectEmpty, Supplier<Collection<ObservedSystem>> getObservedSystem) {
|
|
| 87 | - |
|
| 88 | - String schoolTypeId;
|
|
| 89 | - |
|
| 90 | - if (floatingObjectEmpty.get()) {
|
|
| 91 | - // see https://gitlab.com/ultreiaio/ird-observe/issues/938
|
|
| 92 | - return ProtectedIdsPs.PS_COMMON_SCHOOL_TYPE_OBJECT_ID;
|
|
| 93 | - }
|
|
| 94 | - |
|
| 95 | - // par defaut, on suppose que la set est sur BL
|
|
| 96 | - schoolTypeId = ProtectedIdsPs.PS_COMMON_SCHOOL_TYPE_FREE_ID;
|
|
| 97 | - |
|
| 98 | - // des systèmes observés sont connus, si un des système est sur banc objet, alors la set est considérée sur BO
|
|
| 99 | - for (ObservedSystem s : getObservedSystem.get()) {
|
|
| 100 | - if (ProtectedIdsPs.PS_COMMON_SCHOOL_TYPE_OBJECT_ID.equals(s.getSchoolType().getTopiaId())) {
|
|
| 101 | - |
|
| 102 | - // set sur BO
|
|
| 103 | - schoolTypeId = ProtectedIdsPs.PS_COMMON_SCHOOL_TYPE_OBJECT_ID;
|
|
| 104 | - break;
|
|
| 105 | - }
|
|
| 106 | - }
|
|
| 107 | - return schoolTypeId;
|
|
| 108 | - }
|
|
| 109 | - |
|
| 110 | 70 | public static void updateTrip(SqlScriptWriter writer, Set<Class<? extends DataEntity>> lastUpdateDates, String oldId, String newId, String now) {
|
| 111 | 71 | writer.writeSql(updateTripVersion(oldId, now));
|
| 112 | 72 | writer.writeSql(updateTripVersion(newId, now));
|
| ... | ... | @@ -23,7 +23,6 @@ package fr.ird.observe.entities.data.ps.logbook; |
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | 25 | import fr.ird.observe.dto.referential.ps.common.VesselActivityReference;
|
| 26 | -import fr.ird.observe.entities.data.ps.common.TripSpi;
|
|
| 27 | 26 | import io.ultreia.java4all.util.Dates;
|
| 28 | 27 | |
| 29 | 28 | import java.util.Date;
|
| ... | ... | @@ -43,11 +42,6 @@ public class ActivityImpl extends ActivityAbstract { |
| 43 | 42 | return VesselActivityReference.isSetOperation(getVesselActivity()) ? 1 : 0;
|
| 44 | 43 | }
|
| 45 | 44 | |
| 46 | - @Override
|
|
| 47 | - public String getSchoolTypeId() {
|
|
| 48 | - return TripSpi.computeSchoolTypeId(this::isFloatingObjectNotEmpty, this::getObservedSystem);
|
|
| 49 | - }
|
|
| 50 | - |
|
| 51 | 45 | @Override
|
| 52 | 46 | public Date getDate() {
|
| 53 | 47 | return getTime() == null ? null : Dates.getDay(getTime());
|
| ... | ... | @@ -21,8 +21,9 @@ |
| 21 | 21 | */
|
| 22 | 22 | package fr.ird.observe.entities.data.ps.observation;
|
| 23 | 23 | |
| 24 | +import fr.ird.observe.dto.ProtectedIdsPs;
|
|
| 24 | 25 | import fr.ird.observe.dto.referential.ps.common.VesselActivityReference;
|
| 25 | -import fr.ird.observe.entities.data.ps.common.TripSpi;
|
|
| 26 | +import fr.ird.observe.entities.referential.ps.common.ObservedSystem;
|
|
| 26 | 27 | import io.ultreia.java4all.util.Dates;
|
| 27 | 28 | |
| 28 | 29 | import java.util.Date;
|
| ... | ... | @@ -39,9 +40,25 @@ public class ActivityImpl extends ActivityAbstract { |
| 39 | 40 | return VesselActivityReference.isEndOfSearchingOperation(vesselActivity);
|
| 40 | 41 | }
|
| 41 | 42 | |
| 43 | + /**
|
|
| 44 | + * Compute {@link Set#getSchoolType()}.
|
|
| 45 | + * <p>
|
|
| 46 | + * If activity contains at least one observed system with {@code Object school type} then return it,
|
|
| 47 | + * otherwise use {@code Free school type}.
|
|
| 48 | + *
|
|
| 49 | + * @return computed school type
|
|
| 50 | + * @since 1.5
|
|
| 51 | + */
|
|
| 42 | 52 | @Override
|
| 43 | - public String getSchoolTypeId() {
|
|
| 44 | - return TripSpi.computeSchoolTypeId(this::isFloatingObjectNotEmpty, this::getObservedSystem);
|
|
| 53 | + public String computeSchoolTypeId() {
|
|
| 54 | + for (ObservedSystem s : getObservedSystem()) {
|
|
| 55 | + if (ProtectedIdsPs.PS_COMMON_SCHOOL_TYPE_OBJECT_ID.equals(s.getSchoolType().getTopiaId())) {
|
|
| 56 | + // set on object school type
|
|
| 57 | + return ProtectedIdsPs.PS_COMMON_SCHOOL_TYPE_OBJECT_ID;
|
|
| 58 | + }
|
|
| 59 | + }
|
|
| 60 | + // if no observed system on object school type, use free school type.
|
|
| 61 | + return ProtectedIdsPs.PS_COMMON_SCHOOL_TYPE_FREE_ID;
|
|
| 45 | 62 | }
|
| 46 | 63 | |
| 47 | 64 | @Override
|
| ... | ... | @@ -22,6 +22,7 @@ package fr.ird.observe.entities.data.ps.observation; |
| 22 | 22 | * #L%
|
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | +import fr.ird.observe.dto.ProtectedIdsPs;
|
|
| 25 | 26 | import fr.ird.observe.dto.data.ps.observation.SetDto;
|
| 26 | 27 | import fr.ird.observe.dto.form.Form;
|
| 27 | 28 | import fr.ird.observe.dto.referential.ReferentialLocale;
|
| ... | ... | @@ -57,9 +58,9 @@ public class SetSpi extends GeneratedSetSpi { |
| 57 | 58 | // pour les dates de fin on utilise la date de la route
|
| 58 | 59 | preCreated.setEndTimeStamp(Dates.getDateAndTime(routeDate, date, false, false));
|
| 59 | 60 | preCreated.setHaulingEndTimeStamp(Dates.getDateAndTime(routeDate, date, false, false));
|
| 60 | - // recuperation du type de set a partir de l'activité
|
|
| 61 | - String schoolTypeId = parent.getSchoolTypeId();
|
|
| 62 | - SchoolType schoolType = SchoolType.loadEntity(context, schoolTypeId);
|
|
| 61 | + // by default, school type is undefined, and only computed by consolidation action
|
|
| 62 | + // See https://gitlab.com/ultreiaio/ird-observe/-/issues/2573
|
|
| 63 | + SchoolType schoolType = SchoolType.loadEntity(context, ProtectedIdsPs.PS_COMMON_SCHOOL_TYPE_UNDEFINED_ID);
|
|
| 63 | 64 | preCreated.setSchoolType(schoolType);
|
| 64 | 65 | Form<SetDto> form = super.preCreate(context, parent, preCreated);
|
| 65 | 66 | form.getObject().setStartSetDate(routeDate);
|
| ... | ... | @@ -31,7 +31,7 @@ currentFpaZone {*:0..1} referential.common.FpaZone |
| 31 | 31 | previousFpaZone {*:0..1} referential.common.FpaZone
|
| 32 | 32 | nextFpaZone {*:0..1} referential.common.FpaZone
|
| 33 | 33 | dataQuality {*:0..1} referential.common.DataQuality
|
| 34 | -getSchoolTypeId() String
|
|
| 34 | +computeSchoolTypeId() String
|
|
| 35 | 35 | isActivityEndOfSearching() boolean
|
| 36 | 36 | getDate() Date
|
| 37 | 37 |
| ... | ... | @@ -30,7 +30,6 @@ informationSource {*:0..1} referential.ps.logbook.InformationSource |
| 30 | 30 | reasonForNoFishing {*:0..1} referential.ps.common.ReasonForNoFishing
|
| 31 | 31 | setSuccessStatus {*:0..1} referential.ps.logbook.SetSuccessStatus
|
| 32 | 32 | reasonForNullSet {*:0..1} referential.ps.common.ReasonForNullSet
|
| 33 | -getSchoolTypeId() String
|
|
| 34 | 33 | getDate() Date
|
| 35 | 34 | |
| 36 | 35 | data.ps.logbook.Catch > data.DataEntity >> fr.ird.observe.dto.data.WellIdAware
|