Tony CHEMIT pushed to branch feature/issue_2575 at ultreiaio / ird-observe

Commits:

14 changed files:

Changes:

  • core/api/services/src/main/java/fr/ird/observe/services/service/data/ps/AvdthDataImportResult.java
    ... ... @@ -87,6 +87,10 @@ public class AvdthDataImportResult implements ObserveDto {
    87 87
             this.notReadResult = notReadResult;
    
    88 88
             this.exportResult = exportResult;
    
    89 89
             this.sqlResultPath = sqlResultPath;
    
    90
    +        // Used for debugging...
    
    91
    +//        if (!exportResult.isEmpty()) {
    
    92
    +//            System.out.println(exportResult.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining("\n")));
    
    93
    +//        }
    
    90 94
         }
    
    91 95
     
    
    92 96
         public Path getMessageFile() {
    

  • core/persistence/avdth/src/main/java/fr/ird/observe/persistence/avdth/data/DataReader.java
    ... ... @@ -93,5 +93,9 @@ public abstract class DataReader<E extends DataEntity> {
    93 93
         protected final AvdthDataImportConfiguration getContext() {
    
    94 94
             return context.getConfiguration();
    
    95 95
         }
    
    96
    +
    
    97
    +    protected final void addMessage(String message) {
    
    98
    +        context.addMessage(message);
    
    99
    +    }
    
    96 100
     }
    
    97 101
     

  • core/persistence/avdth/src/main/java/fr/ird/observe/persistence/avdth/data/ImportReferentialContext.java
    ... ... @@ -58,7 +58,6 @@ import fr.ird.observe.entities.referential.ps.logbook.SetSuccessStatus;
    58 58
     import fr.ird.observe.entities.referential.ps.logbook.WellContentStatus;
    
    59 59
     import fr.ird.observe.entities.referential.ps.logbook.WellSamplingConformity;
    
    60 60
     import fr.ird.observe.entities.referential.ps.logbook.WellSamplingStatus;
    
    61
    -import fr.ird.observe.persistence.avdth.data.logbook.FloatingObjectReader;
    
    62 61
     import fr.ird.observe.persistence.avdth.data.logbook.WellPlanReader;
    
    63 62
     import fr.ird.observe.persistence.avdth.referential.AvdthReferentialImportResult;
    
    64 63
     import fr.ird.observe.persistence.avdth.referential.SpeciesCache;
    
    ... ... @@ -80,10 +79,8 @@ import java.util.function.Consumer;
    80 79
      * @author Tony Chemit - dev@tchemit.fr
    
    81 80
      * @since 9.0.0
    
    82 81
      */
    
    83
    -@SuppressWarnings("SpellCheckingInspection")
    
    84 82
     public class ImportReferentialContext {
    
    85 83
     
    
    86
    -
    
    87 84
         private Map<String, WeightCategory> landingCategories;
    
    88 85
         private Map<String, Destination> destinations;
    
    89 86
         private Map<String, WeightCategory> wellCategories;
    
    ... ... @@ -127,9 +124,11 @@ public class ImportReferentialContext {
    127 124
         private ObjectMaterial objectMaterialDFAD;
    
    128 125
         private ObjectMaterial objectMaterialALOG;
    
    129 126
         private ObjectMaterial objectMaterialAFAD;
    
    127
    +    private ObjectMaterial objectMaterialBiodegradable;
    
    130 128
         private ObjectMaterial objectMaterialAlone;
    
    131 129
         private ObjectMaterial objectMaterialLOG;
    
    132 130
         private ObjectMaterial objectMaterialFALOG;
    
    131
    +    private ObjectMaterial objectMaterialANLOG;
    
    133 132
         private ObjectMaterial objectMaterialHALOG;
    
    134 133
         private ObjectMaterial objectMaterialVNLOG;
    
    135 134
         private ObservedSystem observedSystem0;
    
    ... ... @@ -226,8 +225,10 @@ public class ImportReferentialContext {
    226 225
             objectMaterialLOG = objectMaterial.get("fr.ird.referential.ps.common.ObjectMaterial#0#0.50");
    
    227 226
             objectMaterialFALOG = objectMaterial.get("fr.ird.referential.ps.common.ObjectMaterial#0#0.63");
    
    228 227
             objectMaterialHALOG = objectMaterial.get("fr.ird.referential.ps.common.ObjectMaterial#0#0.67");
    
    228
    +        objectMaterialANLOG = objectMaterial.get("fr.ird.referential.ps.common.ObjectMaterial#0#0.56");
    
    229 229
             objectMaterialVNLOG = objectMaterial.get("fr.ird.referential.ps.common.ObjectMaterial#0#0.52");
    
    230 230
             objectMaterialAlone = objectMaterial.get("fr.ird.referential.ps.common.ObjectMaterial#1561561977652#0.5876332198776647");
    
    231
    +        objectMaterialBiodegradable = objectMaterial.get("fr.ird.referential.ps.common.ObjectMaterial#0#0.69");
    
    231 232
     
    
    232 233
             // catch
    
    233 234
             catchCategories = new TreeMap<>();
    
    ... ... @@ -333,10 +334,34 @@ public class ImportReferentialContext {
    333 334
             return objectMaterialAFAD;
    
    334 335
         }
    
    335 336
     
    
    337
    +    public ObjectMaterial getObjectMaterialLOG() {
    
    338
    +        return objectMaterialLOG;
    
    339
    +    }
    
    340
    +
    
    341
    +    public ObjectMaterial getObjectMaterialFALOG() {
    
    342
    +        return objectMaterialFALOG;
    
    343
    +    }
    
    344
    +
    
    345
    +    public ObjectMaterial getObjectMaterialHALOG() {
    
    346
    +        return objectMaterialHALOG;
    
    347
    +    }
    
    348
    +
    
    349
    +    public ObjectMaterial getObjectMaterialVNLOG() {
    
    350
    +        return objectMaterialVNLOG;
    
    351
    +    }
    
    352
    +
    
    353
    +    public ObjectMaterial getObjectMaterialBiodegradable() {
    
    354
    +        return objectMaterialBiodegradable;
    
    355
    +    }
    
    356
    +
    
    336 357
         public ObjectMaterial getObjectMaterialAlone() {
    
    337 358
             return objectMaterialAlone;
    
    338 359
         }
    
    339 360
     
    
    361
    +    public ObjectMaterial getObjectMaterialANLOG() {
    
    362
    +        return objectMaterialANLOG;
    
    363
    +    }
    
    364
    +
    
    340 365
         public SampleType getLocalmarketSampleType() {
    
    341 366
             return localmarketSampleType;
    
    342 367
         }
    
    ... ... @@ -529,86 +554,37 @@ public class ImportReferentialContext {
    529 554
             entity.addObservedSystem(getObservedSystem("102"));
    
    530 555
         }
    
    531 556
     
    
    532
    -    public ObjectOperation getObjectOperationByVesselActivityCode(String vesselActivityCode) {
    
    533
    -        String objectOperationCode = FloatingObjectReader.DCP_OBJECT_OPERATION_CODE_MAPPING.get(vesselActivityCode);
    
    534
    -        if (objectOperationCode == null) {
    
    535
    -            return null;
    
    536
    -        }
    
    557
    +    public ObjectOperation getObjectOperation(String objectOperationCode) {
    
    537 558
             return objectOperation.get(objectOperationCode);
    
    538 559
         }
    
    539 560
     
    
    540
    -    public TransmittingBuoyOperation getTransmittingBuoyOperationByVesselActivityCode(String vesselActivityCode) {
    
    541
    -        String transmittingBuoyTypeCode = FloatingObjectReader.TRANSMITTING_BUOY_OPERATION_CODE_MAPPING.get(vesselActivityCode);
    
    561
    +    public TransmittingBuoyOperation getTransmittingBuoyOperation(String transmittingBuoyTypeCode) {
    
    542 562
             if (transmittingBuoyTypeCode == null) {
    
    543 563
                 return null;
    
    544 564
             }
    
    545 565
             return transmittingBuoyOperation.get(transmittingBuoyTypeCode);
    
    546 566
         }
    
    547 567
     
    
    548
    -    public TransmittingBuoyType getTransmittingBuoyTypeByBuoyTypeCode(String buoyTypeCode) {
    
    549
    -        String transmittingBuoyTypeCode = FloatingObjectReader.TRANSMITTING_BUOY_TYPE_CODE_MAPPING.get(buoyTypeCode);
    
    550
    -        if (transmittingBuoyTypeCode == null) {
    
    551
    -            transmittingBuoyTypeCode = "999";
    
    552
    -        }
    
    553
    -        TransmittingBuoyType transmittingBuoyType = this.transmittingBuoyType.get(transmittingBuoyTypeCode);
    
    554
    -        return Objects.requireNonNull(transmittingBuoyType, String.format("Can't find transmittingBuoyType with code: %s", buoyTypeCode));
    
    568
    +    public TransmittingBuoyType getTransmittingBuoyType(String transmittingBuoyTypeCode) {
    
    569
    +        TransmittingBuoyType result = transmittingBuoyType.get(transmittingBuoyTypeCode);
    
    570
    +        return Objects.requireNonNull(result, String.format("Can't find TransmittingBuoyType with code: %s", transmittingBuoyTypeCode));
    
    555 571
         }
    
    556 572
     
    
    557
    -    public TransmittingBuoyOwnership getTransmittingBuoyOwnership(String buoyOwnershipCode) {
    
    558
    -        if (buoyOwnershipCode == null) {
    
    559
    -            return null;
    
    560
    -        }
    
    561
    -        String transmittingBuoyOwnershipCode = FloatingObjectReader.TRANSMITTING_BUOY_OWNERSHIP_CODE_MAPPING.get(buoyOwnershipCode);
    
    573
    +    public TransmittingBuoyOwnership getTransmittingBuoyOwnership(String transmittingBuoyOwnershipCode) {
    
    562 574
             if (transmittingBuoyOwnershipCode == null) {
    
    563 575
                 return null;
    
    564 576
             }
    
    565 577
             return transmittingBuoyOwnership.get(transmittingBuoyOwnershipCode);
    
    566 578
         }
    
    567 579
     
    
    568
    -    public ObservedSystem getObservedSystem(String objectTypeCode, String buoyTypeCode) {
    
    569
    -        if (objectTypeCode.equals("999")) {
    
    570
    -            if (buoyTypeCode.equals("999")) {
    
    571
    -                return getObservedSystem0();
    
    572
    -            }
    
    573
    -            return getObservedSystem20();
    
    574
    -        }
    
    575
    -        String observedSystemCode = FloatingObjectReader.OBSERVED_SYSTEM_CODE_MAPPING.get(objectTypeCode);
    
    576
    -        return getObservedSystem(observedSystemCode, false);
    
    577
    -    }
    
    578
    -
    
    579
    -    /**
    
    580
    -     * To get objectMaterial id associated by a DCP from avdth ACTIVITE.C_TYP_OBJET code.
    
    581
    -     *
    
    582
    -     * @param objectTypeCode ACTIVITE.C_TYP_OBJET
    
    583
    -     * @return material or null
    
    584
    -     */
    
    585
    -    public ObjectMaterial getObjectMaterialByObjectTypeCode(String objectTypeCode) {
    
    586
    -        switch (objectTypeCode) {
    
    587
    -            case "1":
    
    588
    -                return objectMaterialAFAD;
    
    589
    -            case "2":
    
    590
    -                return objectMaterialDFAD;
    
    591
    -            case "3":
    
    592
    -                return objectMaterialLOG;
    
    593
    -            case "9":
    
    594
    -                return objectMaterialFOB;
    
    595
    -            case "10":
    
    596
    -                return objectMaterialFALOG;
    
    597
    -            case "11":
    
    598
    -                return objectMaterialHALOG;
    
    599
    -            case "13":
    
    600
    -                return objectMaterialVNLOG;
    
    601
    -        }
    
    602
    -        return null;
    
    603
    -    }
    
    604
    -
    
    605 580
         public WeightCategory getWellWeightCategory(String weightCategoryCode) {
    
    606 581
             String categoryCode = "W-" + weightCategoryCode;
    
    607 582
             WeightCategory weightCategory = wellCategories.get(categoryCode);
    
    608
    -        return Objects.requireNonNull(weightCategory, "Can't find weight category for code: " + categoryCode);
    
    583
    +        return Objects.requireNonNull(weightCategory, String.format("Can't find weight category for code: %s", categoryCode));
    
    609 584
         }
    
    610 585
     
    
    611 586
         public VesselActivity getVesselActivity6() {
    
    612 587
             return vesselActivity6;
    
    613 588
         }
    
    589
    +
    
    614 590
     }

  • core/persistence/avdth/src/main/java/fr/ird/observe/persistence/avdth/data/logbook/FloatingObjectReader.java
    ... ... @@ -23,6 +23,7 @@ package fr.ird.observe.persistence.avdth.data.logbook;
    23 23
      */
    
    24 24
     
    
    25 25
     import com.google.common.collect.ImmutableMap;
    
    26
    +import fr.ird.observe.entities.data.ps.logbook.Activity;
    
    26 27
     import fr.ird.observe.entities.data.ps.logbook.FloatingObject;
    
    27 28
     import fr.ird.observe.entities.data.ps.logbook.FloatingObjectPart;
    
    28 29
     import fr.ird.observe.entities.data.ps.logbook.TransmittingBuoy;
    
    ... ... @@ -33,16 +34,21 @@ import fr.ird.observe.entities.referential.ps.common.TransmittingBuoyOperation;
    33 34
     import fr.ird.observe.entities.referential.ps.common.TransmittingBuoyOwnership;
    
    34 35
     import fr.ird.observe.entities.referential.ps.common.TransmittingBuoyType;
    
    35 36
     import fr.ird.observe.entities.referential.ps.common.VesselActivity;
    
    37
    +import fr.ird.observe.persistence.avdth.Query;
    
    36 38
     import fr.ird.observe.persistence.avdth.data.DataReader;
    
    37 39
     import fr.ird.observe.persistence.avdth.data.ImportDataContext;
    
    38 40
     import fr.ird.observe.persistence.avdth.data.ImportEngine;
    
    39 41
     import org.apache.commons.lang3.mutable.MutableInt;
    
    42
    +import org.apache.logging.log4j.LogManager;
    
    43
    +import org.apache.logging.log4j.Logger;
    
    40 44
     
    
    41 45
     import java.sql.ResultSet;
    
    42 46
     import java.sql.SQLException;
    
    47
    +import java.util.List;
    
    43 48
     import java.util.Map;
    
    44 49
     import java.util.Objects;
    
    45 50
     import java.util.Set;
    
    51
    +import java.util.TreeMap;
    
    46 52
     import java.util.TreeSet;
    
    47 53
     
    
    48 54
     /**
    
    ... ... @@ -53,6 +59,7 @@ import java.util.TreeSet;
    53 59
      */
    
    54 60
     @SuppressWarnings("SpellCheckingInspection")
    
    55 61
     public class FloatingObjectReader extends DataReader<FloatingObject> {
    
    62
    +    private static final Logger log = LogManager.getLogger(FloatingObjectReader.class);
    
    56 63
         /**
    
    57 64
          * To get FloatingObject.objectOperation code from avdth ACTIVITE.C_OPERA.
    
    58 65
          */
    
    ... ... @@ -66,7 +73,10 @@ public class FloatingObjectReader extends DataReader<FloatingObject> {
    66 73
                 .put("14", "99")
    
    67 74
                 .put("7", "99")
    
    68 75
                 .put("8", "99")
    
    76
    +            .put("9", "99")
    
    77
    +            .put("12", "99")
    
    69 78
                 .put("13", "99")
    
    79
    +            .put("15", "99")
    
    70 80
     
    
    71 81
                 .put("5", "1")
    
    72 82
                 .put("6", "4")
    
    ... ... @@ -87,32 +97,23 @@ public class FloatingObjectReader extends DataReader<FloatingObject> {
    87 97
                 .build();
    
    88 98
         /**
    
    89 99
          * To get TransmittingBuoy.TransmittingBuoyOperation code from avdth ACTIVITE.C_OPERA code.
    
    100
    +     * <p>
    
    101
    +     * If for a given {@code ACTIVITE.C_OPERA}, no value is found here, this means that there is no buoy to create.
    
    90 102
          */
    
    91 103
         public static final Map<String, String> TRANSMITTING_BUOY_OPERATION_CODE_MAPPING = ImmutableMap.<String, String>builder()
    
    92
    -            .put("0", "1") // Visite          | 99 inconnu               | W_ARRIVING    |
    
    93
    -            .put("1", "1") // Visite          | 99 inconnu               | W_ARRIVING    |
    
    94
    -            .put("2", "1") // Visite          | 99 inconnu               | W_ARRIVING    |
    
    95
    -            .put("3", "1") // Visite          | 99 inconnu               | W_ARRIVING    |
    
    96
    -            .put("4", "1") // Visite          | 99 inconnu               | W_ARRIVING    |
    
    97
    -            .put("10", "1")// Visite          | 99 inconnu               | W_ARRIVING    |
    
    98
    -            .put("14", "1")// Visite          | 99 inconnu               | W_ARRIVING    |
    
    99
    -            .put("7", "1") // Visite          | 99 inconnu               | W_ARRIVING    |
    
    100
    -            .put("8", "1") // Visite          | 99 inconnu               | W_ARRIVING    |
    
    101
    -            .put("13", "1")// Visite          | 99 inconnu               | W_ARRIVING    |
    
    102
    -
    
    103
    -            .put("5", "3")  // Mise à l'eau    | null ou 3 Mise à l'eau | W_LEAVING     | Selon présence infos balise dans AVDTH
    
    104
    -            .put("6", "2")  // Retrait         | null ou 2 Récupération | W_ARRIVING    | Selon présence infos balise dans AVDTH
    
    105
    -            .put("23", "3") // Mise à l'eau    | 3 Mise à l'eau         | W_LEAVING     |
    
    106
    -            .put("24", "2") // Retrait         | 2 Récupération         | W_ARRIVING    |
    
    107
    -            .put("25", "3") // Visite          | 3 Mise à l'eau         | W_ARRIVING    |
    
    108
    -            .put("26", "2") // Visite          | 2 Récupération         | W_ARRIVING    |
    
    109
    -            .put("29", "1") // Visite          | 1 Visite               | W_ARRIVING    |
    
    110
    -            .put("32", "3") // Modif ou renfor | 3 Mise à l'eau         | W_ARR + W_LEA |
    
    111
    -            .put("33", "4") // Perte           | 4 Perte signal         | W_ARRIVING    | codes 11 et 4 à créer ; matériaux sur W_ARRIVING par convention, comme pour Visite
    
    112
    -            .put("34", "2") // Retrait         | 2 Récupération         | W_ARRIVING    | rattacher cette balise à un FOB de type '2-2-4-4 Bouée émettrice seule'
    
    104
    +            .put("5", "3")  // Mise à l'eau    | null ou 3 Mise à l'eau
    
    105
    +            .put("6", "2")  // Retrait         | null ou 2 Récupération
    
    106
    +            .put("23", "3") // Mise à l'eau    | 3 Mise à l'eau
    
    107
    +            .put("24", "2") // Retrait         | 2 Récupération
    
    108
    +            .put("25", "3") // Visite          | 3 Mise à l'eau
    
    109
    +            .put("26", "2") // Visite          | 2 Récupération
    
    110
    +            .put("29", "1") // Visite          | 1 Visite
    
    111
    +            .put("32", "3") // Modif ou renfor | 3 Mise à l'eau
    
    112
    +            .put("33", "4") // Perte           | 4 Perte signal
    
    113
    +            .put("34", "2") // Retrait         | 2 Récupération
    
    113 114
                 // See https://gitlab.com/ultreiaio/ird-observe/-/issues/2568
    
    114
    -            .put("40", "4") // Perte           | 4 Perte signal         | W_ARRIVING    | rattacher cette balise à un FOB de type '1-1 DFAD'
    
    115
    -            .put("41", "5") // Arret commandé de la transmission  | 5 Fin d'utilisation | W_ARRIVING    | rattacher cette balise à un FOB de type '1-1 DFAD'
    
    115
    +            .put("40", "4") // Perte           | 4 Perte signal
    
    116
    +            .put("41", "5") // Arret commandé de la transmission  | 5 Fin d'utilisation
    
    116 117
                 .build();
    
    117 118
         /**
    
    118 119
          * Is floatingObjectPart on leaving from avdth ACTIVITE.C_OPERA.
    
    ... ... @@ -127,8 +128,11 @@ public class FloatingObjectReader extends DataReader<FloatingObject> {
    127 128
                 "2",
    
    128 129
                 "3",
    
    129 130
                 "4",
    
    131
    +            "9",
    
    130 132
                 "10",
    
    133
    +            "12",
    
    131 134
                 "14",
    
    135
    +            "15",
    
    132 136
                 "7",
    
    133 137
                 "8",
    
    134 138
                 "13",
    
    ... ... @@ -214,6 +218,7 @@ public class FloatingObjectReader extends DataReader<FloatingObject> {
    214 218
                 .put("9", "20")
    
    215 219
                 .put("10", "20")
    
    216 220
                 .put("11", "20")
    
    221
    +            .put("12", "20")
    
    217 222
                 .put("13", "20")
    
    218 223
                 .build();
    
    219 224
         public static final Set<String> OBSERVED_SYTEM_CODES_WITH_DCP = Set.of("20", "21", "22", "23", "24", "25");
    
    ... ... @@ -225,6 +230,8 @@ public class FloatingObjectReader extends DataReader<FloatingObject> {
    225 230
         private final MutableInt floatingObjectPartCount = new MutableInt();
    
    226 231
         private final MutableInt transmittingBuoyCount = new MutableInt();
    
    227 232
     
    
    233
    +    private final Map<String, MutableInt> badVesselActivityCodes = new TreeMap<>();
    
    234
    +
    
    228 235
         public FloatingObjectReader(ImportEngine context) {
    
    229 236
             super(context);
    
    230 237
         }
    
    ... ... @@ -232,124 +239,202 @@ public class FloatingObjectReader extends DataReader<FloatingObject> {
    232 239
         @Override
    
    233 240
         public FloatingObject read(ImportDataContext dataContext, ResultSet resultSet) throws SQLException {
    
    234 241
     
    
    235
    -        String vesselActivityCode = resultSet.getString(13);
    
    236
    -        VesselActivity vesselActivity = dataContext.getVesselActivity(vesselActivityCode);
    
    242
    +        // Get the current activity where to add the optional floating object
    
    243
    +        Activity activity = dataContext.getActivity();
    
    244
    +
    
    245
    +        // Get his vessel activity
    
    246
    +        VesselActivity vesselActivity = activity.getVesselActivity();
    
    247
    +
    
    248
    +        // Avdth observed system codes associated to the current activity (need them to compute ex nihilo floating object)
    
    237 249
             Set<String> observedSystemCodes = dataContext.getObservedSystemCodes();
    
    238
    -        if (!Objects.equals(vesselActivity.getCode(), "13")) {
    
    239
    -            boolean noDcpInObservedSystems = observedSystemCodes.stream().noneMatch(OBSERVED_SYTEM_CODES_WITH_DCP::contains);
    
    240
    -            if (noDcpInObservedSystems) {
    
    241
    -                reset(dataContext);
    
    242
    -                return null;
    
    243
    -            }
    
    244
    -        }
    
    245 250
     
    
    246
    -        FloatingObject entity = newEntity(FloatingObject.SPI);
    
    251
    +        // We need to get the original vessel activity code from AVDTH (to compute some mapping)
    
    252
    +        String vesselActivityCode = resultSet.getString(13);
    
    247 253
     
    
    248
    -        ObjectOperation objectOperation = dataContext.getObjectOperationByVesselActivityCode(vesselActivityCode);
    
    249
    -        entity.setObjectOperation(Objects.requireNonNull(objectOperation, String.format("Can't find objectOperation with code: %s", vesselActivityCode)));
    
    250
    -        boolean addCoordinate = "11".equals(objectOperation.getCode());
    
    251
    -        boolean whenArriving = WHEN_ARRIVING_CODE.contains(vesselActivityCode);
    
    252
    -        boolean whenLeaving = WHEN_LEAVING_CODE.contains(vesselActivityCode);
    
    254
    +        // Is the floating object can be created by the observed systems?
    
    255
    +        boolean floatingObjectCreatedByObservedSystem = observedSystemCodes.stream().anyMatch(OBSERVED_SYTEM_CODES_WITH_DCP::contains);
    
    256
    +
    
    257
    +        // Is the current vessel activity accept to create Floating object?
    
    258
    +        boolean vesselActivityAllowFad = vesselActivity.isAllowFad();
    
    259
    +
    
    260
    +        // Get object type code
    
    253 261
             String objectTypeCode = resultSet.getString(28);
    
    254 262
             if (objectTypeCode == null) {
    
    255
    -            //FIXME should fail ?
    
    263
    +            // If null, then consider it as not found in avdth
    
    256 264
                 objectTypeCode = "999";
    
    257 265
             }
    
    258
    -        //FIXME 29 - F_DCP_ECO
    
    259
    -//        int dcpEcoCode = resultSet.getInt(29);
    
    260
    -        String buoyOwnershipCode = resultSet.getString(30);
    
    266
    +
    
    267
    +        // Is floating object exists in avdth?
    
    268
    +        boolean floatingObjectExistsInAvdth = !objectTypeCode.equals("999");
    
    269
    +
    
    270
    +        if (!floatingObjectExistsInAvdth && !floatingObjectCreatedByObservedSystem) {
    
    271
    +            // If Floating object does not exist in avdth, neither need to be created by observed system,
    
    272
    +            // Do not create the floating object (no log is required here)
    
    273
    +            reset(dataContext);
    
    274
    +            return null;
    
    275
    +        }
    
    276
    +
    
    277
    +        if (!vesselActivityAllowFad) {
    
    278
    +            // If ObServe veseel activity does not support Floating object, reject import
    
    279
    +            List<Object> activityPrimaryKey = ActivityReader.getActivityPk(resultSet);
    
    280
    +            String activityPk = Query.primaryKeyString(activityPrimaryKey);
    
    281
    +            String message = String.format("On activity %s (ACTIVITE.C_OPERA %s), can not add Floating object since ObServe Vessel activity with code : %s does not allow FAD (floatingObjectExistsInAvdth? %b, floatingObjectCreatedByObservedSystem? %b).",
    
    282
    +                                           activityPk,
    
    283
    +                                           vesselActivityCode,
    
    284
    +                                           vesselActivity.getCode(),
    
    285
    +                                           floatingObjectExistsInAvdth,
    
    286
    +                                           floatingObjectCreatedByObservedSystem);
    
    287
    +            log.warn(message);
    
    288
    +            badVesselActivityCodes.computeIfAbsent(vesselActivityCode, MutableInt::new).increment();
    
    289
    +
    
    290
    +//            // do not create the floating object
    
    291
    +//            reset(dataContext);
    
    292
    +//            return null;
    
    293
    +        }
    
    294
    +
    
    295
    +        FloatingObject entity = newEntity(FloatingObject.SPI);
    
    296
    +
    
    297
    +        // Get floating object operation
    
    298
    +        ObjectOperation objectOperation = getObjectOperationByVesselActivityCode(dataContext, vesselActivityCode);
    
    299
    +        entity.setObjectOperation(Objects.requireNonNull(objectOperation, String.format("No mapping for FloatingObject.objectOperation from ACTIVITE.C_OPERA: %s", vesselActivityCode)));
    
    300
    +
    
    261 301
             String buoyTypeCode = resultSet.getString(31);
    
    262 302
             if (buoyTypeCode == null) {
    
    263
    -            //FIXME should fail?
    
    303
    +            // If null, then consider it as not found in avdth
    
    264 304
                 buoyTypeCode = "999";
    
    265 305
             }
    
    266
    -        String buoyId = resultSet.getString(32);
    
    267
    -        String dcpWeight = resultSet.getString(33);
    
    268
    -        if (dcpWeight != null) {
    
    269
    -            //FIXME Check if ok
    
    270
    -            entity.setComment(String.format("ACTIVITE.POIDS_ESTIM_DCP value from avdth: %s", dcpWeight));
    
    271
    -        }
    
    272
    -        ObservedSystem observedSystem = dataContext.getObservedSystem(objectTypeCode, buoyTypeCode);
    
    306
    +        // IS buoy exists in avdth?
    
    307
    +        boolean buoyExistsInAvdth = !"999".equals(buoyTypeCode);
    
    308
    +
    
    309
    +        ObservedSystem observedSystem = getObservedSystem(dataContext, objectTypeCode, floatingObjectExistsInAvdth, buoyExistsInAvdth);
    
    273 310
             if (observedSystem != null) {
    
    274
    -            dataContext.getActivity().addObservedSystem(observedSystem);
    
    311
    +            activity.addObservedSystem(observedSystem);
    
    275 312
             }
    
    276
    -        // avdth data has a buoy
    
    277
    -        boolean willCreateBuoy = !"999".equals(buoyTypeCode);
    
    278
    -        // to add default material if there is a declared buoy and no object material created by ObservedSystem
    
    313
    +
    
    314
    +        boolean addBuoyFromObservedSystem = addFloatingObjectMaterials(dataContext,
    
    315
    +                                                                       resultSet,
    
    316
    +                                                                       vesselActivityCode,
    
    317
    +                                                                       objectTypeCode,
    
    318
    +                                                                       observedSystemCodes,
    
    319
    +                                                                       entity,
    
    320
    +                                                                       floatingObjectExistsInAvdth,
    
    321
    +                                                                       buoyExistsInAvdth);
    
    322
    +
    
    323
    +        TransmittingBuoy transmittingBuoy = null;
    
    324
    +        if (buoyExistsInAvdth) {
    
    325
    +            transmittingBuoy = getBuoyFromAvdthActivity(dataContext, resultSet, buoyTypeCode, vesselActivityCode, objectOperation, activity);
    
    326
    +        } else if (addBuoyFromObservedSystem) {
    
    327
    +            transmittingBuoy = getBuoyFromObservedSystem(dataContext);
    
    328
    +        }
    
    329
    +        if (transmittingBuoy != null) {
    
    330
    +            // only add buoy if buoy type known
    
    331
    +            entity.addTransmittingBuoy(transmittingBuoy);
    
    332
    +        }
    
    333
    +        reset(dataContext);
    
    334
    +        return entity;
    
    335
    +    }
    
    336
    +
    
    337
    +    private boolean addFloatingObjectMaterials(ImportDataContext dataContext,
    
    338
    +                                               ResultSet resultSet,
    
    339
    +                                               String vesselActivityCode,
    
    340
    +                                               String objectTypeCode,
    
    341
    +                                               Set<String> observedSystemCodes,
    
    342
    +                                               FloatingObject entity,
    
    343
    +                                               boolean floatingObjectExistsInAvdth,
    
    344
    +                                               boolean buoyExistsInAvdth) throws SQLException {
    
    345
    +        boolean whenArriving = WHEN_ARRIVING_CODE.contains(vesselActivityCode);
    
    346
    +        boolean whenLeaving = WHEN_LEAVING_CODE.contains(vesselActivityCode);
    
    347
    +
    
    348
    +        // to add default material if there is a declared buoy (but no floating object declared)
    
    349
    +        // and no object material created by ObservedSystem, we will then add a standalone buoy
    
    279 350
             boolean addDefaultObjectMaterialOnUnknownObjectType = true;
    
    280 351
             // should create a buoy from ObservedSystem
    
    281 352
             boolean addBuoyFromObservedSystem = false;
    
    282 353
             Set<String> objectMaterialUsed = new TreeSet<>();
    
    354
    +
    
    355
    +        if (floatingObjectExistsInAvdth) {
    
    356
    +            Object dcpEcoCode = resultSet.getObject(29);
    
    357
    +            if (dcpEcoCode != null && Objects.equals(2, dcpEcoCode)) {
    
    358
    +                // add material 4-1 (Biodegradable materials)
    
    359
    +                addObjectMaterial(vesselActivityCode, objectMaterialUsed, dataContext.getObjectMaterialBiodegradable(), whenArriving, whenLeaving, entity);
    
    360
    +            }
    
    361
    +        }
    
    362
    +
    
    283 363
             if (observedSystemCodes.contains("20")) {
    
    284 364
                 // add ObjectMaterial FOB
    
    285
    -            addObjectMaterial(objectMaterialUsed, dataContext.getObjectMaterialFOB(), whenArriving, whenLeaving, entity);
    
    365
    +            addObjectMaterial(vesselActivityCode, objectMaterialUsed, dataContext.getObjectMaterialFOB(), whenArriving, whenLeaving, entity);
    
    286 366
                 addDefaultObjectMaterialOnUnknownObjectType = false;
    
    287 367
             } else if (observedSystemCodes.contains("21")) {
    
    288 368
                 // add ObjectMaterial 2-1 NLOG
    
    289
    -            addObjectMaterial(objectMaterialUsed, dataContext.getObjectMaterialNLOG(), whenArriving, whenLeaving, entity);
    
    369
    +            addObjectMaterial(vesselActivityCode, objectMaterialUsed, dataContext.getObjectMaterialNLOG(), whenArriving, whenLeaving, entity);
    
    290 370
                 addDefaultObjectMaterialOnUnknownObjectType = false;
    
    291 371
             } else if (observedSystemCodes.contains("22")) {
    
    292 372
                 // add ObjectMaterial 2-1 NLOG + 1-1 DFAD
    
    293
    -            addObjectMaterial(objectMaterialUsed, dataContext.getObjectMaterialNLOG(), whenArriving, whenLeaving, entity);
    
    294
    -            addObjectMaterial(objectMaterialUsed, dataContext.getObjectMaterialDFAD(), whenArriving, whenLeaving, entity);
    
    373
    +            addObjectMaterial(vesselActivityCode, objectMaterialUsed, dataContext.getObjectMaterialNLOG(), whenArriving, whenLeaving, entity);
    
    374
    +            addObjectMaterial(vesselActivityCode, objectMaterialUsed, dataContext.getObjectMaterialDFAD(), whenArriving, whenLeaving, entity);
    
    295 375
                 addDefaultObjectMaterialOnUnknownObjectType = false;
    
    296 376
                 addBuoyFromObservedSystem = true;
    
    297 377
             } else if (observedSystemCodes.contains("23")) {
    
    298 378
                 // add ObjectMaterial 2-2 ALOG
    
    299
    -            addObjectMaterial(objectMaterialUsed, dataContext.getObjectMaterialALOG(), whenArriving, whenLeaving, entity);
    
    379
    +            addObjectMaterial(vesselActivityCode, objectMaterialUsed, dataContext.getObjectMaterialALOG(), whenArriving, whenLeaving, entity);
    
    300 380
                 addDefaultObjectMaterialOnUnknownObjectType = false;
    
    301 381
             } else if (observedSystemCodes.contains("24")) {
    
    302 382
                 // add ObjectMaterial 2-2 ALOG + 1-1 DFAD
    
    303
    -            addObjectMaterial(objectMaterialUsed, dataContext.getObjectMaterialALOG(), whenArriving, whenLeaving, entity);
    
    304
    -            addObjectMaterial(objectMaterialUsed, dataContext.getObjectMaterialDFAD(), whenArriving, whenLeaving, entity);
    
    383
    +            addObjectMaterial(vesselActivityCode, objectMaterialUsed, dataContext.getObjectMaterialALOG(), whenArriving, whenLeaving, entity);
    
    384
    +            addObjectMaterial(vesselActivityCode, objectMaterialUsed, dataContext.getObjectMaterialDFAD(), whenArriving, whenLeaving, entity);
    
    305 385
                 addDefaultObjectMaterialOnUnknownObjectType = false;
    
    306 386
                 addBuoyFromObservedSystem = true;
    
    307 387
             } else if (observedSystemCodes.contains("25")) {
    
    308 388
                 // add ObjectMaterial 1-2 AFAD
    
    309
    -            addObjectMaterial(objectMaterialUsed, dataContext.getObjectMaterialAFAD(), whenArriving, whenLeaving, entity);
    
    389
    +            addObjectMaterial(vesselActivityCode, objectMaterialUsed, dataContext.getObjectMaterialAFAD(), whenArriving, whenLeaving, entity);
    
    310 390
                 addDefaultObjectMaterialOnUnknownObjectType = false;
    
    311 391
             }
    
    312
    -        if ("999".equals(objectTypeCode)) {
    
    313
    -            if (willCreateBuoy && addDefaultObjectMaterialOnUnknownObjectType) {
    
    314
    -                // add ObjectMaterial 2-2-4-4
    
    315
    -                addObjectMaterial(objectMaterialUsed, dataContext.getObjectMaterialAlone(), whenArriving, whenLeaving, entity);
    
    392
    +        if (floatingObjectExistsInAvdth) {
    
    393
    +            // simple mapping
    
    394
    +            ObjectMaterial objectMaterial = getObjectMaterialByObjectTypeCode(dataContext, objectTypeCode);
    
    395
    +            if (objectMaterial != null) {
    
    396
    +                addObjectMaterial(vesselActivityCode, objectMaterialUsed, objectMaterial, whenArriving, whenLeaving, entity);
    
    316 397
                 }
    
    317 398
             } else {
    
    318
    -            // simple mapping
    
    319
    -            ObjectMaterial objectMaterial1 = dataContext.getObjectMaterialByObjectTypeCode(objectTypeCode);
    
    320
    -            if (objectMaterial1 != null) {
    
    321
    -                addObjectMaterial(objectMaterialUsed, objectMaterial1, whenArriving, whenLeaving, entity);
    
    399
    +            if (buoyExistsInAvdth && addDefaultObjectMaterialOnUnknownObjectType) {
    
    400
    +                // add ObjectMaterial 2-2-4-4
    
    401
    +                addObjectMaterial(vesselActivityCode, objectMaterialUsed, dataContext.getObjectMaterialAlone(), whenArriving, whenLeaving, entity);
    
    322 402
                 }
    
    323 403
             }
    
    324
    -        if (willCreateBuoy) {
    
    325
    -            // only add buoy if buoy type known
    
    326
    -            TransmittingBuoyType transmittingBuoyType = dataContext.getTransmittingBuoyTypeByBuoyTypeCode(buoyTypeCode);
    
    327
    -            TransmittingBuoyOperation transmittingBuoyOperation = dataContext.getTransmittingBuoyOperationByVesselActivityCode(vesselActivityCode);
    
    328
    -            if (transmittingBuoyOperation != null) {
    
    329
    -                TransmittingBuoy transmittingBuoy = newEntity(TransmittingBuoy.SPI, transmittingBuoyCount);
    
    330
    -                transmittingBuoy.setTransmittingBuoyOperation(transmittingBuoyOperation);
    
    331
    -                transmittingBuoy.setTransmittingBuoyType(transmittingBuoyType);
    
    332
    -                transmittingBuoy.setCode(buoyId);
    
    333
    -                if (addCoordinate) {
    
    334
    -                    transmittingBuoy.setLatitude(dataContext.getActivity().getLatitude());
    
    335
    -                    transmittingBuoy.setLongitude(dataContext.getActivity().getLongitude());
    
    336
    -                }
    
    337
    -                TransmittingBuoyOwnership transmittingBuoyOwnership = dataContext.getTransmittingBuoyOwnership(buoyOwnershipCode);
    
    338
    -                transmittingBuoy.setTransmittingBuoyOwnership(transmittingBuoyOwnership);
    
    339
    -                entity.addTransmittingBuoy(transmittingBuoy);
    
    340
    -            }
    
    341
    -        } else if (addBuoyFromObservedSystem) {
    
    342
    -            // only add buoy if observed system ask for it (22 and 24)
    
    343
    -            TransmittingBuoyType transmittingBuoyType = dataContext.getTransmittingBuoyType98();
    
    344
    -            TransmittingBuoyOperation transmittingBuoyOperation = dataContext.getTransmittingBuoyOperation1();
    
    404
    +        return addBuoyFromObservedSystem;
    
    405
    +    }
    
    406
    +
    
    407
    +    private TransmittingBuoy getBuoyFromAvdthActivity(ImportDataContext dataContext, ResultSet resultSet, String buoyTypeCode, String vesselActivityCode, ObjectOperation objectOperation, Activity activity) throws SQLException {
    
    408
    +        boolean addCoordinate = "11".equals(objectOperation.getCode());
    
    409
    +        TransmittingBuoyType transmittingBuoyType = getTransmittingBuoyTypeByBuoyTypeCode(dataContext, buoyTypeCode);
    
    410
    +        TransmittingBuoyOperation transmittingBuoyOperation = getTransmittingBuoyOperationByVesselActivityCode(dataContext, vesselActivityCode);
    
    411
    +        if (transmittingBuoyOperation != null) {
    
    412
    +            String buoyOwnershipCode = resultSet.getString(30);
    
    413
    +            String buoyId = resultSet.getString(32);
    
    345 414
                 TransmittingBuoy transmittingBuoy = newEntity(TransmittingBuoy.SPI, transmittingBuoyCount);
    
    346 415
                 transmittingBuoy.setTransmittingBuoyOperation(transmittingBuoyOperation);
    
    347 416
                 transmittingBuoy.setTransmittingBuoyType(transmittingBuoyType);
    
    348
    -            transmittingBuoy.setCode(null);
    
    349
    -            entity.addTransmittingBuoy(transmittingBuoy);
    
    417
    +            transmittingBuoy.setCode(buoyId);
    
    418
    +            if (addCoordinate) {
    
    419
    +                transmittingBuoy.setLatitude(activity.getLatitude());
    
    420
    +                transmittingBuoy.setLongitude(activity.getLongitude());
    
    421
    +            }
    
    422
    +            TransmittingBuoyOwnership transmittingBuoyOwnership = getTransmittingBuoyOwnership(dataContext, buoyOwnershipCode);
    
    423
    +            transmittingBuoy.setTransmittingBuoyOwnership(transmittingBuoyOwnership);
    
    424
    +            return transmittingBuoy;
    
    350 425
             }
    
    351
    -        reset(dataContext);
    
    352
    -        return entity;
    
    426
    +        return null;
    
    427
    +    }
    
    428
    +
    
    429
    +    private TransmittingBuoy getBuoyFromObservedSystem(ImportDataContext dataContext) {
    
    430
    +        // only add buoy if observed system ask for it (22 and 24)
    
    431
    +        TransmittingBuoyType transmittingBuoyType = dataContext.getTransmittingBuoyType98();
    
    432
    +        TransmittingBuoyOperation transmittingBuoyOperation = dataContext.getTransmittingBuoyOperation1();
    
    433
    +        TransmittingBuoy transmittingBuoy = newEntity(TransmittingBuoy.SPI, transmittingBuoyCount);
    
    434
    +        transmittingBuoy.setTransmittingBuoyOperation(transmittingBuoyOperation);
    
    435
    +        transmittingBuoy.setTransmittingBuoyType(transmittingBuoyType);
    
    436
    +        transmittingBuoy.setCode(null);
    
    437
    +        return transmittingBuoy;
    
    353 438
         }
    
    354 439
     
    
    355 440
         private void reset(ImportDataContext dataContext) {
    
    ... ... @@ -357,9 +442,9 @@ public class FloatingObjectReader extends DataReader<FloatingObject> {
    357 442
             dataContext.setObservedSystemCodes(null);
    
    358 443
         }
    
    359 444
     
    
    360
    -    private void addObjectMaterial(Set<String> objectMaterialUsed, ObjectMaterial objectMaterial, boolean whenArriving, boolean whenLeaving, FloatingObject floatingObject) {
    
    445
    +    private void addObjectMaterial(String vesselActivityCode, Set<String> objectMaterialUsed, ObjectMaterial objectMaterial, boolean whenArriving, boolean whenLeaving, FloatingObject floatingObject) {
    
    361 446
             if (!whenArriving && !whenLeaving) {
    
    362
    -            throw new IllegalStateException("Can't have not whenArriving and not whenLeaving ");
    
    447
    +            throw new IllegalStateException(String.format("Can't have not whenArriving and not whenLeaving from ACTIVITE.C_OPERA: %s", vesselActivityCode));
    
    363 448
             }
    
    364 449
             if (!objectMaterialUsed.add(objectMaterial.getTopiaId())) {
    
    365 450
                 // already used
    
    ... ... @@ -380,4 +465,80 @@ public class FloatingObjectReader extends DataReader<FloatingObject> {
    380 465
             return floatingObjectPartCount.intValue();
    
    381 466
         }
    
    382 467
     
    
    468
    +    public Map<String, MutableInt> getBadVesselActivityCodes() {
    
    469
    +        return badVesselActivityCodes;
    
    470
    +    }
    
    471
    +
    
    472
    +    private ObjectOperation getObjectOperationByVesselActivityCode(ImportDataContext dataContext, String vesselActivityCode) {
    
    473
    +        String objectOperationCode = DCP_OBJECT_OPERATION_CODE_MAPPING.get(vesselActivityCode);
    
    474
    +        return dataContext.getObjectOperation(Objects.requireNonNull(objectOperationCode, String.format("Can't find objectOperation with ACTIVITE.C_OPERA: %s", vesselActivityCode)));
    
    475
    +    }
    
    476
    +
    
    477
    +    private ObservedSystem getObservedSystem(ImportDataContext dataContext, String objectTypeCode, boolean floatingObjectExistsInAvdth,boolean buoyExistsInAvdth) {
    
    478
    +        if (!floatingObjectExistsInAvdth) {
    
    479
    +            if (!buoyExistsInAvdth) {
    
    480
    +                return dataContext.getObservedSystem0();
    
    481
    +            }
    
    482
    +            return dataContext.getObservedSystem20();
    
    483
    +        }
    
    484
    +        String observedSystemCode = OBSERVED_SYSTEM_CODE_MAPPING.get(objectTypeCode);
    
    485
    +        return dataContext.getObservedSystem(observedSystemCode, false);
    
    486
    +    }
    
    487
    +
    
    488
    +    private TransmittingBuoyOwnership getTransmittingBuoyOwnership(ImportDataContext dataContext, String buoyOwnershipCode) {
    
    489
    +        if (buoyOwnershipCode == null) {
    
    490
    +            return null;
    
    491
    +        }
    
    492
    +        String transmittingBuoyOwnershipCode = TRANSMITTING_BUOY_OWNERSHIP_CODE_MAPPING.get(buoyOwnershipCode);
    
    493
    +        if (transmittingBuoyOwnershipCode == null) {
    
    494
    +            return null;
    
    495
    +        }
    
    496
    +        return dataContext.getTransmittingBuoyOwnership(transmittingBuoyOwnershipCode);
    
    497
    +    }
    
    498
    +
    
    499
    +    private TransmittingBuoyOperation getTransmittingBuoyOperationByVesselActivityCode(ImportDataContext dataContext, String vesselActivityCode) {
    
    500
    +        String transmittingBuoyTypeCode = TRANSMITTING_BUOY_OPERATION_CODE_MAPPING.get(vesselActivityCode);
    
    501
    +        if (transmittingBuoyTypeCode == null) {
    
    502
    +            return null;
    
    503
    +        }
    
    504
    +        return dataContext.getTransmittingBuoyOperation(transmittingBuoyTypeCode);
    
    505
    +    }
    
    506
    +
    
    507
    +
    
    508
    +    private TransmittingBuoyType getTransmittingBuoyTypeByBuoyTypeCode(ImportDataContext dataContext, String buoyTypeCode) {
    
    509
    +        String transmittingBuoyTypeCode = TRANSMITTING_BUOY_TYPE_CODE_MAPPING.get(buoyTypeCode);
    
    510
    +        if (transmittingBuoyTypeCode == null) {
    
    511
    +            transmittingBuoyTypeCode = "999";
    
    512
    +        }
    
    513
    +        TransmittingBuoyType transmittingBuoyType = dataContext.getTransmittingBuoyType(transmittingBuoyTypeCode);
    
    514
    +        return Objects.requireNonNull(transmittingBuoyType, String.format("Can't find transmittingBuoyType with code: %s", buoyTypeCode));
    
    515
    +    }
    
    516
    +
    
    517
    +    /**
    
    518
    +     * To get objectMaterial associated by a DCP (or null) from avdth ACTIVITE.C_TYP_OBJET code.
    
    519
    +     *
    
    520
    +     * @param objectTypeCode ACTIVITE.C_TYP_OBJET
    
    521
    +     * @return material or null
    
    522
    +     */
    
    523
    +    private ObjectMaterial getObjectMaterialByObjectTypeCode(ImportDataContext dataContext, String objectTypeCode) {
    
    524
    +        switch (objectTypeCode) {
    
    525
    +            case "1":
    
    526
    +                return dataContext.getObjectMaterialAFAD();
    
    527
    +            case "2":
    
    528
    +                return dataContext.getObjectMaterialDFAD();
    
    529
    +            case "3":
    
    530
    +                return dataContext.getObjectMaterialLOG();
    
    531
    +            case "9":
    
    532
    +                return dataContext.getObjectMaterialFOB();
    
    533
    +            case "10":
    
    534
    +                return dataContext.getObjectMaterialFALOG();
    
    535
    +            case "11":
    
    536
    +                return dataContext.getObjectMaterialHALOG();
    
    537
    +            case "12":
    
    538
    +                return dataContext.getObjectMaterialANLOG();
    
    539
    +            case "13":
    
    540
    +                return dataContext.getObjectMaterialVNLOG();
    
    541
    +        }
    
    542
    +        return null;
    
    543
    +    }
    
    383 544
     }

  • core/persistence/avdth/src/main/java/fr/ird/observe/persistence/avdth/data/logbook/FloatingObjectWriter.java
    ... ... @@ -192,6 +192,9 @@ public class FloatingObjectWriter extends DataWriter<FloatingObject, FloatingObj
    192 192
             super.toResult(resultBuilder);
    
    193 193
             toResult(resultBuilder, FloatingObjectPart.class, getReader().getFloatingObjectPartCount());
    
    194 194
             toResult(resultBuilder, TransmittingBuoy.class, getReader().getTransmittingBuoyCount());
    
    195
    +//        getReader().getBadVesselActivityCodes().forEach((k,v)-> {
    
    196
    +//            resultBuilder.put(String.format("Bad Vessel activity used to build FAD from ACTIVITY.C_OPERA %s used but ObServe not allow fad.", k), v.getValue());
    
    197
    +//        });
    
    195 198
         }
    
    196 199
     }
    
    197 200
     

  • core/persistence/avdth/src/main/java/fr/ird/observe/persistence/avdth/data/logbook/SampleActivityReader.java
    ... ... @@ -133,7 +133,7 @@ public class SampleActivityReader extends DataReader<SampleActivity> {
    133 133
                 if (!dataContext.isCanCreateActivity()) {
    
    134 134
                     String message = String.format("Sample [%20s], not allowed to create missing activity and could not find Activity [%20s]", samplePk, activityPk);
    
    135 135
                     log.debug(message);
    
    136
    -                context().addMessage(message);
    
    136
    +                addMessage(message);
    
    137 137
                     return null;
    
    138 138
                 }
    
    139 139
                 // only on this case we can create missing route and activity (See #2070)
    

  • core/persistence/avdth/src/main/java/fr/ird/observe/persistence/avdth/data/logbook/WellPlanReader.java
    ... ... @@ -254,7 +254,7 @@ public class WellPlanReader extends DataReader<WellPlan> {
    254 254
                 String wellSetPk = Query.primaryKeyString(Query.getPrimaryKey(resultSet, 1, 3));
    
    255 255
                 String message = String.format("WellPlan [%20s], not allowed to create missing activity and could not find Activity [%20s]", wellSetPk, activityPk);
    
    256 256
                 log.debug(message);
    
    257
    -            context().addMessage(message);
    
    257
    +            addMessage(message);
    
    258 258
                 return null;
    
    259 259
             } else {
    
    260 260
                 activity = new ActivityImpl();
    

  • core/persistence/test/pom.xml
    ... ... @@ -30,6 +30,7 @@
    30 30
       <description>ObServe Core Persistence Test module</description>
    
    31 31
       <properties>
    
    32 32
         <test_forceImport>false</test_forceImport>
    
    33
    +    <test_forcePrepare>false</test_forcePrepare>
    
    33 34
         <test_allYears>false</test_allYears>
    
    34 35
       </properties>
    
    35 36
       <dependencies>
    
    ... ... @@ -109,6 +110,7 @@
    109 110
                 <systemPropertyVariables>
    
    110 111
                   <test_forceImport>${test_forceImport}</test_forceImport>
    
    111 112
                   <test_allYears>${test_allYears}</test_allYears>
    
    113
    +              <test_forcePrepare>${test_forcePrepare}</test_forcePrepare>
    
    112 114
                 </systemPropertyVariables>
    
    113 115
               </configuration>
    
    114 116
             </plugin>
    

  • core/persistence/test/src/test/java/fr/ird/observe/persistence/avdth/data/AvdthAtlanticDataBuilderByYearLatestTest.java
    1
    +package fr.ird.observe.persistence.avdth.data;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe Core :: Persistence :: Test
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2023 IRD, Ultreia.io
    
    8
    + * %%
    
    9
    + * This program is free software: you can redistribute it and/or modify
    
    10
    + * it under the terms of the GNU General Public License as
    
    11
    + * published by the Free Software Foundation, either version 3 of the
    
    12
    + * License, or (at your option) any later version.
    
    13
    + *
    
    14
    + * This program is distributed in the hope that it will be useful,
    
    15
    + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    + * GNU General Public License for more details.
    
    18
    + *
    
    19
    + * You should have received a copy of the GNU General Public
    
    20
    + * License along with this program.  If not, see
    
    21
    + * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    + * #L%
    
    23
    + */
    
    24
    +
    
    25
    +import fr.ird.observe.dto.ProtectedIdsCommon;
    
    26
    +import org.junit.runners.Parameterized;
    
    27
    +
    
    28
    +import java.nio.file.Path;
    
    29
    +
    
    30
    +/**
    
    31
    + * Created on 19/01/2023.
    
    32
    + *
    
    33
    + * @author Tony Chemit - dev@tchemit.fr
    
    34
    + * @since 9.0.24
    
    35
    + */
    
    36
    +public class AvdthAtlanticDataBuilderByYearLatestTest extends AvdthDataBuilderByYearTestSupport {
    
    37
    +
    
    38
    +    public static final Path ROOT_PATH = getPath("OA").resolve("latest");
    
    39
    +
    
    40
    +    @Parameterized.Parameters(name = "{index}: {0}")
    
    41
    +    public static Iterable<?> data() {
    
    42
    +        return getDatabases(ROOT_PATH);
    
    43
    +    }
    
    44
    +
    
    45
    +    @Override
    
    46
    +    protected Path getRootPath() {
    
    47
    +        return ROOT_PATH;
    
    48
    +    }
    
    49
    +
    
    50
    +    @Override
    
    51
    +    protected String getOceanId() {
    
    52
    +        return ProtectedIdsCommon.COMMON_OCEAN_ATLANTIC;
    
    53
    +    }
    
    54
    +}

  • core/persistence/test/src/test/java/fr/ird/observe/persistence/avdth/data/AvdthDataBuilderByYearTestSupport.java
    ... ... @@ -37,7 +37,7 @@ public abstract class AvdthDataBuilderByYearTestSupport extends AvdthDataBuilder
    37 37
     
    
    38 38
         public static List<String> getDatabases(Path path) {
    
    39 39
             List<String> databases = allDatabases(path);
    
    40
    -        return AvdthFixtures.IMPORT_ALL_YEARS ? databases : databases.subList(0, 3);
    
    40
    +        return AvdthFixtures.IMPORT_ALL_YEARS || databases.size() < 3 ? databases : databases.subList(0, 3);
    
    41 41
         }
    
    42 42
     
    
    43 43
         @Override
    

  • core/persistence/test/src/test/java/fr/ird/observe/persistence/avdth/data/AvdthDataBuilderTestSupport.java
    ... ... @@ -169,7 +169,15 @@ public abstract class AvdthDataBuilderTestSupport extends PersistenceTestSupport
    169 169
         }
    
    170 170
     
    
    171 171
         protected void checkNotValidResult(AvdthDataImportResult result) {
    
    172
    -        Assume.assumeTrue(result.getNotReadResult() + "", forceImport());
    
    172
    +        Map<String, Integer> notReadResult = result.getNotReadResult();
    
    173
    +        String message;
    
    174
    +        if (notReadResult.isEmpty()) {
    
    175
    +            message = result.getMessages() + "";
    
    176
    +        } else {
    
    177
    +            message = notReadResult + "";
    
    178
    +            return;
    
    179
    +        }
    
    180
    +        Assume.assumeTrue(message, forceImport());
    
    173 181
         }
    
    174 182
     
    
    175 183
         protected long count() {
    

  • core/persistence/test/src/test/java/fr/ird/observe/persistence/avdth/data/AvdthIndianDataBuilderByYearLatestTest.java
    1
    +package fr.ird.observe.persistence.avdth.data;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe Core :: Persistence :: Test
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2023 IRD, Ultreia.io
    
    8
    + * %%
    
    9
    + * This program is free software: you can redistribute it and/or modify
    
    10
    + * it under the terms of the GNU General Public License as
    
    11
    + * published by the Free Software Foundation, either version 3 of the
    
    12
    + * License, or (at your option) any later version.
    
    13
    + *
    
    14
    + * This program is distributed in the hope that it will be useful,
    
    15
    + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    + * GNU General Public License for more details.
    
    18
    + *
    
    19
    + * You should have received a copy of the GNU General Public
    
    20
    + * License along with this program.  If not, see
    
    21
    + * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    + * #L%
    
    23
    + */
    
    24
    +
    
    25
    +import fr.ird.observe.dto.ProtectedIdsCommon;
    
    26
    +import org.junit.runners.Parameterized;
    
    27
    +
    
    28
    +import java.nio.file.Path;
    
    29
    +
    
    30
    +/**
    
    31
    + * Created on 19/01/2023.
    
    32
    + *
    
    33
    + * @author Tony Chemit - dev@tchemit.fr
    
    34
    + * @since 9.0.24
    
    35
    + */
    
    36
    +public class AvdthIndianDataBuilderByYearLatestTest extends AvdthDataBuilderByYearTestSupport {
    
    37
    +
    
    38
    +    public static final Path ROOT_PATH = getPath("OI").resolve("latest");
    
    39
    +
    
    40
    +    @Parameterized.Parameters(name = "{index}: {0}")
    
    41
    +    public static Iterable<?> data() {
    
    42
    +        return getDatabases(ROOT_PATH);
    
    43
    +    }
    
    44
    +
    
    45
    +    @Override
    
    46
    +    protected Path getRootPath() {
    
    47
    +        return ROOT_PATH;
    
    48
    +    }
    
    49
    +
    
    50
    +    @Override
    
    51
    +    protected String getOceanId() {
    
    52
    +        return ProtectedIdsCommon.COMMON_OCEAN_INDIAN;
    
    53
    +    }
    
    54
    +}

  • pom.xml
    ... ... @@ -127,6 +127,8 @@
    127 127
         <!-- FIXME   <lib.version.jaxb-runtime>4.0.0</lib.version.jaxb-runtime>-->
    
    128 128
         <lib.version.jts>1.16.1</lib.version.jts>
    
    129 129
         <!-- FIXME   <lib.version.jts>1.18.2</lib.version.jts>-->
    
    130
    +    <lib.version.hsqldb>2.7.0</lib.version.hsqldb>
    
    131
    +    <!-- FIXME   <lib.version.hsqldb>2.7.1</lib.version.hsqldb>-->
    
    130 132
         <!-- license header configuration -->
    
    131 133
         <license.licenseName>gpl_v3</license.licenseName>
    
    132 134
         <license.organizationName>IRD, Ultreia.io</license.organizationName>
    

  • src/site/markdown/avdth/logbook.md
    ... ... @@ -97,7 +97,7 @@ Voir ajout d'un DCP
    97 97
     
    
    98 98
     * Note 11
    
    99 99
     ### <a name="n_0_11"></a>
    
    100
    -Donnée non persistée dans ObServe, on la conserve dans le commentaire du DCP
    
    100
    +Donnée non persistée dans ObServe, (voir https://gitlab.com/ultreiaio/ird-observe/-/issues/2575#note_1247253501).
    
    101 101
     
    
    102 102
     * Note 12
    
    103 103
     ### <a name="n_0_12"></a>