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

Commits:

3 changed files:

Changes:

  • core/persistence/resources/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,6 +124,7 @@ 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;
    
    ... ... @@ -228,6 +226,7 @@ public class ImportReferentialContext {
    228 226
             objectMaterialHALOG = objectMaterial.get("fr.ird.referential.ps.common.ObjectMaterial#0#0.67");
    
    229 227
             objectMaterialVNLOG = objectMaterial.get("fr.ird.referential.ps.common.ObjectMaterial#0#0.52");
    
    230 228
             objectMaterialAlone = objectMaterial.get("fr.ird.referential.ps.common.ObjectMaterial#1561561977652#0.5876332198776647");
    
    229
    +        objectMaterialBiodegradable = objectMaterial.get("fr.ird.referential.ps.common.ObjectMaterial#0#0.69");
    
    231 230
     
    
    232 231
             // catch
    
    233 232
             catchCategories = new TreeMap<>();
    
    ... ... @@ -333,6 +332,26 @@ public class ImportReferentialContext {
    333 332
             return objectMaterialAFAD;
    
    334 333
         }
    
    335 334
     
    
    335
    +    public ObjectMaterial getObjectMaterialLOG() {
    
    336
    +        return objectMaterialLOG;
    
    337
    +    }
    
    338
    +
    
    339
    +    public ObjectMaterial getObjectMaterialFALOG() {
    
    340
    +        return objectMaterialFALOG;
    
    341
    +    }
    
    342
    +
    
    343
    +    public ObjectMaterial getObjectMaterialHALOG() {
    
    344
    +        return objectMaterialHALOG;
    
    345
    +    }
    
    346
    +
    
    347
    +    public ObjectMaterial getObjectMaterialVNLOG() {
    
    348
    +        return objectMaterialVNLOG;
    
    349
    +    }
    
    350
    +
    
    351
    +    public ObjectMaterial getObjectMaterialBiodegradable() {
    
    352
    +        return objectMaterialBiodegradable;
    
    353
    +    }
    
    354
    +
    
    336 355
         public ObjectMaterial getObjectMaterialAlone() {
    
    337 356
             return objectMaterialAlone;
    
    338 357
         }
    
    ... ... @@ -529,79 +548,29 @@ public class ImportReferentialContext {
    529 548
             entity.addObservedSystem(getObservedSystem("102"));
    
    530 549
         }
    
    531 550
     
    
    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
    -        }
    
    551
    +    public ObjectOperation getObjectOperation(String objectOperationCode) {
    
    537 552
             return objectOperation.get(objectOperationCode);
    
    538 553
         }
    
    539 554
     
    
    540
    -    public TransmittingBuoyOperation getTransmittingBuoyOperationByVesselActivityCode(String vesselActivityCode) {
    
    541
    -        String transmittingBuoyTypeCode = FloatingObjectReader.TRANSMITTING_BUOY_OPERATION_CODE_MAPPING.get(vesselActivityCode);
    
    555
    +    public TransmittingBuoyOperation getTransmittingBuoyOperation(String transmittingBuoyTypeCode) {
    
    542 556
             if (transmittingBuoyTypeCode == null) {
    
    543 557
                 return null;
    
    544 558
             }
    
    545 559
             return transmittingBuoyOperation.get(transmittingBuoyTypeCode);
    
    546 560
         }
    
    547 561
     
    
    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));
    
    562
    +    public TransmittingBuoyType getTransmittingBuoyType(String transmittingBuoyTypeCode) {
    
    563
    +        TransmittingBuoyType result = transmittingBuoyType.get(transmittingBuoyTypeCode);
    
    564
    +        return Objects.requireNonNull(result, String.format("Can't find result with code: %s", transmittingBuoyTypeCode));
    
    555 565
         }
    
    556 566
     
    
    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);
    
    567
    +    public TransmittingBuoyOwnership getTransmittingBuoyOwnership(String transmittingBuoyOwnershipCode) {
    
    562 568
             if (transmittingBuoyOwnershipCode == null) {
    
    563 569
                 return null;
    
    564 570
             }
    
    565 571
             return transmittingBuoyOwnership.get(transmittingBuoyOwnershipCode);
    
    566 572
         }
    
    567 573
     
    
    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 574
         public WeightCategory getWellWeightCategory(String weightCategoryCode) {
    
    606 575
             String categoryCode = "W-" + weightCategoryCode;
    
    607 576
             WeightCategory weightCategory = wellCategories.get(categoryCode);
    
    ... ... @@ -611,4 +580,5 @@ public class ImportReferentialContext {
    611 580
         public VesselActivity getVesselActivity6() {
    
    612 581
             return vesselActivity6;
    
    613 582
         }
    
    583
    +
    
    614 584
     }

  • core/persistence/resources/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;
    
    ... ... @@ -232,54 +233,113 @@ public class FloatingObjectReader extends DataReader<FloatingObject> {
    232 233
         @Override
    
    233 234
         public FloatingObject read(ImportDataContext dataContext, ResultSet resultSet) throws SQLException {
    
    234 235
     
    
    235
    -        String vesselActivityCode = resultSet.getString(13);
    
    236
    -        VesselActivity vesselActivity = dataContext.getVesselActivity(vesselActivityCode);
    
    236
    +        // Get the current activity where to add the optional floating object
    
    237
    +        Activity activity = dataContext.getActivity();
    
    238
    +
    
    239
    +        // Get his vessel activity
    
    240
    +        VesselActivity vesselActivity = activity.getVesselActivity();
    
    241
    +
    
    242
    +        // Avdth observed system codes associated to the current activity (need them to compute ex nihilo floating object)
    
    237 243
             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 244
     
    
    246
    -        FloatingObject entity = newEntity(FloatingObject.SPI);
    
    245
    +        // We need to get the original vessel activity code from AVDTH (to compute some mapping)
    
    246
    +        String vesselActivityCode = resultSet.getString(13);
    
    247 247
     
    
    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);
    
    248
    +        // Is the floating object can be created by the observed systems?
    
    249
    +        boolean floatingObjectCreatedByObservedSystem = observedSystemCodes.stream().anyMatch(OBSERVED_SYTEM_CODES_WITH_DCP::contains);
    
    250
    +
    
    251
    +        // Is the current vessel activity accept to create Floating object?
    
    252
    +        boolean vesselActivityAllowFad = vesselActivity.isAllowFad();
    
    253
    +
    
    254
    +        // Get object type code
    
    253 255
             String objectTypeCode = resultSet.getString(28);
    
    254 256
             if (objectTypeCode == null) {
    
    255
    -            //FIXME should fail ?
    
    257
    +            // If null, then consider it as not found in avdth
    
    256 258
                 objectTypeCode = "999";
    
    257 259
             }
    
    258
    -        //FIXME 29 - F_DCP_ECO
    
    259
    -//        int dcpEcoCode = resultSet.getInt(29);
    
    260
    -        String buoyOwnershipCode = resultSet.getString(30);
    
    260
    +
    
    261
    +        // Is floating object exists in avdth?
    
    262
    +        boolean floatingObjectExistsInAvdth = !objectTypeCode.equals("999");
    
    263
    +
    
    264
    +        //FIXME Improve this condition
    
    265
    +        if (!vesselActivityAllowFad && !floatingObjectCreatedByObservedSystem) {
    
    266
    +            // do not create the floating object
    
    267
    +            reset(dataContext);
    
    268
    +            return null;
    
    269
    +        }
    
    270
    +
    
    271
    +        FloatingObject entity = newEntity(FloatingObject.SPI);
    
    272
    +
    
    273
    +        // Get floating object operation
    
    274
    +        ObjectOperation objectOperation = getObjectOperationByVesselActivityCode(dataContext, vesselActivityCode);
    
    275
    +        entity.setObjectOperation(Objects.requireNonNull(objectOperation, String.format("Can't find objectOperation with ACTIVITE.C_OPERA: %s", vesselActivityCode)));
    
    276
    +
    
    261 277
             String buoyTypeCode = resultSet.getString(31);
    
    262 278
             if (buoyTypeCode == null) {
    
    263
    -            //FIXME should fail?
    
    279
    +            // If null, then consider it as not found in avdth
    
    264 280
                 buoyTypeCode = "999";
    
    265 281
             }
    
    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);
    
    282
    +        // IS buoy exists in avdth?
    
    283
    +        boolean buoyExistsInAvdth = !"999".equals(buoyTypeCode);
    
    284
    +
    
    285
    +        ObservedSystem observedSystem = getObservedSystem(dataContext, objectTypeCode, floatingObjectExistsInAvdth, buoyExistsInAvdth);
    
    273 286
             if (observedSystem != null) {
    
    274
    -            dataContext.getActivity().addObservedSystem(observedSystem);
    
    287
    +            activity.addObservedSystem(observedSystem);
    
    288
    +        }
    
    289
    +
    
    290
    +        boolean addBuoyFromObservedSystem = addFloatingObjectMaterials(dataContext,
    
    291
    +                                                                       resultSet,
    
    292
    +                                                                       vesselActivityCode,
    
    293
    +                                                                       objectTypeCode,
    
    294
    +                                                                       observedSystemCodes,
    
    295
    +                                                                       entity,
    
    296
    +                                                                       floatingObjectExistsInAvdth,
    
    297
    +                                                                       buoyExistsInAvdth);
    
    298
    +
    
    299
    +        TransmittingBuoy transmittingBuoy = null;
    
    300
    +        if (buoyExistsInAvdth) {
    
    301
    +            transmittingBuoy = getBuoyFromAvdthActivity(dataContext, resultSet, buoyTypeCode, vesselActivityCode, objectOperation, activity);
    
    302
    +        } else if (addBuoyFromObservedSystem) {
    
    303
    +            transmittingBuoy = getBuoyFromObservedSystem(dataContext);
    
    275 304
             }
    
    276
    -        // avdth data has a buoy
    
    277
    -        boolean willCreateBuoy = !"999".equals(buoyTypeCode);
    
    305
    +        if (transmittingBuoy != null) {
    
    306
    +            // only add buoy if buoy type known
    
    307
    +            entity.addTransmittingBuoy(transmittingBuoy);
    
    308
    +        }
    
    309
    +        reset(dataContext);
    
    310
    +        return entity;
    
    311
    +    }
    
    312
    +
    
    313
    +    private boolean addFloatingObjectMaterials(ImportDataContext dataContext,
    
    314
    +                                               ResultSet resultSet,
    
    315
    +                                               String vesselActivityCode,
    
    316
    +                                               String objectTypeCode,
    
    317
    +                                               Set<String> observedSystemCodes,
    
    318
    +                                               FloatingObject entity,
    
    319
    +                                               boolean floatingObjectExistsInAvdth,
    
    320
    +                                               boolean buoyExistsInAvdth) throws SQLException {
    
    321
    +        boolean whenArriving = WHEN_ARRIVING_CODE.contains(vesselActivityCode);
    
    322
    +        boolean whenLeaving = WHEN_LEAVING_CODE.contains(vesselActivityCode);
    
    323
    +
    
    278 324
             // to add default material if there is a declared buoy and no object material created by ObservedSystem
    
    279 325
             boolean addDefaultObjectMaterialOnUnknownObjectType = true;
    
    280 326
             // should create a buoy from ObservedSystem
    
    281 327
             boolean addBuoyFromObservedSystem = false;
    
    282 328
             Set<String> objectMaterialUsed = new TreeSet<>();
    
    329
    +
    
    330
    +        if (floatingObjectExistsInAvdth) {
    
    331
    +            String dcpWeight = resultSet.getString(33);
    
    332
    +            if (dcpWeight != null) {
    
    333
    +                //FIXME Check if ok
    
    334
    +                entity.setComment(String.format("ACTIVITE.POIDS_ESTIM_DCP value from avdth: %s", dcpWeight));
    
    335
    +            }
    
    336
    +            Object dcpEcoCode = resultSet.getObject(29);
    
    337
    +            if (dcpEcoCode != null && Objects.equals(2, dcpEcoCode)) {
    
    338
    +                // add material 4-1 (Biodegradable materials)
    
    339
    +                addObjectMaterial(objectMaterialUsed, dataContext.getObjectMaterialBiodegradable(), whenArriving, whenLeaving, entity);
    
    340
    +            }
    
    341
    +        }
    
    342
    +
    
    283 343
             if (observedSystemCodes.contains("20")) {
    
    284 344
                 // add ObjectMaterial FOB
    
    285 345
                 addObjectMaterial(objectMaterialUsed, dataContext.getObjectMaterialFOB(), whenArriving, whenLeaving, entity);
    
    ... ... @@ -309,47 +369,52 @@ public class FloatingObjectReader extends DataReader<FloatingObject> {
    309 369
                 addObjectMaterial(objectMaterialUsed, dataContext.getObjectMaterialAFAD(), whenArriving, whenLeaving, entity);
    
    310 370
                 addDefaultObjectMaterialOnUnknownObjectType = false;
    
    311 371
             }
    
    312
    -        if ("999".equals(objectTypeCode)) {
    
    313
    -            if (willCreateBuoy && addDefaultObjectMaterialOnUnknownObjectType) {
    
    314
    -                // add ObjectMaterial 2-2-4-4
    
    315
    -                addObjectMaterial(objectMaterialUsed, dataContext.getObjectMaterialAlone(), whenArriving, whenLeaving, entity);
    
    372
    +        if (floatingObjectExistsInAvdth) {
    
    373
    +            // simple mapping
    
    374
    +            ObjectMaterial objectMaterial = getObjectMaterialByObjectTypeCode(dataContext, objectTypeCode);
    
    375
    +            if (objectMaterial != null) {
    
    376
    +                addObjectMaterial(objectMaterialUsed, objectMaterial, whenArriving, whenLeaving, entity);
    
    316 377
                 }
    
    317 378
             } else {
    
    318
    -            // simple mapping
    
    319
    -            ObjectMaterial objectMaterial1 = dataContext.getObjectMaterialByObjectTypeCode(objectTypeCode);
    
    320
    -            if (objectMaterial1 != null) {
    
    321
    -                addObjectMaterial(objectMaterialUsed, objectMaterial1, whenArriving, whenLeaving, entity);
    
    379
    +            if (buoyExistsInAvdth && addDefaultObjectMaterialOnUnknownObjectType) {
    
    380
    +                // add ObjectMaterial 2-2-4-4
    
    381
    +                addObjectMaterial(objectMaterialUsed, dataContext.getObjectMaterialAlone(), whenArriving, whenLeaving, entity);
    
    322 382
                 }
    
    323 383
             }
    
    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();
    
    384
    +        return addBuoyFromObservedSystem;
    
    385
    +    }
    
    386
    +
    
    387
    +    private TransmittingBuoy getBuoyFromAvdthActivity(ImportDataContext dataContext, ResultSet resultSet, String buoyTypeCode, String vesselActivityCode, ObjectOperation objectOperation, Activity activity) throws SQLException {
    
    388
    +        boolean addCoordinate = "11".equals(objectOperation.getCode());
    
    389
    +        TransmittingBuoyType transmittingBuoyType = getTransmittingBuoyTypeByBuoyTypeCode(dataContext, buoyTypeCode);
    
    390
    +        TransmittingBuoyOperation transmittingBuoyOperation = getTransmittingBuoyOperationByVesselActivityCode(dataContext, vesselActivityCode);
    
    391
    +        if (transmittingBuoyOperation != null) {
    
    392
    +            String buoyOwnershipCode = resultSet.getString(30);
    
    393
    +            String buoyId = resultSet.getString(32);
    
    345 394
                 TransmittingBuoy transmittingBuoy = newEntity(TransmittingBuoy.SPI, transmittingBuoyCount);
    
    346 395
                 transmittingBuoy.setTransmittingBuoyOperation(transmittingBuoyOperation);
    
    347 396
                 transmittingBuoy.setTransmittingBuoyType(transmittingBuoyType);
    
    348
    -            transmittingBuoy.setCode(null);
    
    349
    -            entity.addTransmittingBuoy(transmittingBuoy);
    
    397
    +            transmittingBuoy.setCode(buoyId);
    
    398
    +            if (addCoordinate) {
    
    399
    +                transmittingBuoy.setLatitude(activity.getLatitude());
    
    400
    +                transmittingBuoy.setLongitude(activity.getLongitude());
    
    401
    +            }
    
    402
    +            TransmittingBuoyOwnership transmittingBuoyOwnership = getTransmittingBuoyOwnership(dataContext, buoyOwnershipCode);
    
    403
    +            transmittingBuoy.setTransmittingBuoyOwnership(transmittingBuoyOwnership);
    
    404
    +            return transmittingBuoy;
    
    350 405
             }
    
    351
    -        reset(dataContext);
    
    352
    -        return entity;
    
    406
    +        return null;
    
    407
    +    }
    
    408
    +
    
    409
    +    private TransmittingBuoy getBuoyFromObservedSystem(ImportDataContext dataContext) {
    
    410
    +        // only add buoy if observed system ask for it (22 and 24)
    
    411
    +        TransmittingBuoyType transmittingBuoyType = dataContext.getTransmittingBuoyType98();
    
    412
    +        TransmittingBuoyOperation transmittingBuoyOperation = dataContext.getTransmittingBuoyOperation1();
    
    413
    +        TransmittingBuoy transmittingBuoy = newEntity(TransmittingBuoy.SPI, transmittingBuoyCount);
    
    414
    +        transmittingBuoy.setTransmittingBuoyOperation(transmittingBuoyOperation);
    
    415
    +        transmittingBuoy.setTransmittingBuoyType(transmittingBuoyType);
    
    416
    +        transmittingBuoy.setCode(null);
    
    417
    +        return transmittingBuoy;
    
    353 418
         }
    
    354 419
     
    
    355 420
         private void reset(ImportDataContext dataContext) {
    
    ... ... @@ -380,4 +445,74 @@ public class FloatingObjectReader extends DataReader<FloatingObject> {
    380 445
             return floatingObjectPartCount.intValue();
    
    381 446
         }
    
    382 447
     
    
    448
    +    private ObjectOperation getObjectOperationByVesselActivityCode(ImportDataContext dataContext, String vesselActivityCode) {
    
    449
    +        String objectOperationCode = DCP_OBJECT_OPERATION_CODE_MAPPING.get(vesselActivityCode);
    
    450
    +        return dataContext.getObjectOperation(Objects.requireNonNull(objectOperationCode, String.format("Can't find objectOperation with ACTIVITE.C_OPERA: %s", vesselActivityCode)));
    
    451
    +    }
    
    452
    +
    
    453
    +    private ObservedSystem getObservedSystem(ImportDataContext dataContext, String objectTypeCode, boolean floatingObjectExistsInAvdth,boolean buoyExistsInAvdth) {
    
    454
    +        if (!floatingObjectExistsInAvdth) {
    
    455
    +            if (!buoyExistsInAvdth) {
    
    456
    +                return dataContext.getObservedSystem0();
    
    457
    +            }
    
    458
    +            return dataContext.getObservedSystem20();
    
    459
    +        }
    
    460
    +        String observedSystemCode = OBSERVED_SYSTEM_CODE_MAPPING.get(objectTypeCode);
    
    461
    +        return dataContext.getObservedSystem(observedSystemCode, false);
    
    462
    +    }
    
    463
    +
    
    464
    +    private TransmittingBuoyOwnership getTransmittingBuoyOwnership(ImportDataContext dataContext, String buoyOwnershipCode) {
    
    465
    +        if (buoyOwnershipCode == null) {
    
    466
    +            return null;
    
    467
    +        }
    
    468
    +        String transmittingBuoyOwnershipCode = TRANSMITTING_BUOY_OWNERSHIP_CODE_MAPPING.get(buoyOwnershipCode);
    
    469
    +        if (transmittingBuoyOwnershipCode == null) {
    
    470
    +            return null;
    
    471
    +        }
    
    472
    +        return dataContext.getTransmittingBuoyOwnership(transmittingBuoyOwnershipCode);
    
    473
    +    }
    
    474
    +
    
    475
    +    private TransmittingBuoyOperation getTransmittingBuoyOperationByVesselActivityCode(ImportDataContext dataContext, String vesselActivityCode) {
    
    476
    +        String transmittingBuoyTypeCode = TRANSMITTING_BUOY_OPERATION_CODE_MAPPING.get(vesselActivityCode);
    
    477
    +        if (transmittingBuoyTypeCode == null) {
    
    478
    +            return null;
    
    479
    +        }
    
    480
    +        return dataContext.getTransmittingBuoyOperation(transmittingBuoyTypeCode);
    
    481
    +    }
    
    482
    +
    
    483
    +
    
    484
    +    private TransmittingBuoyType getTransmittingBuoyTypeByBuoyTypeCode(ImportDataContext dataContext, String buoyTypeCode) {
    
    485
    +        String transmittingBuoyTypeCode = TRANSMITTING_BUOY_TYPE_CODE_MAPPING.get(buoyTypeCode);
    
    486
    +        if (transmittingBuoyTypeCode == null) {
    
    487
    +            transmittingBuoyTypeCode = "999";
    
    488
    +        }
    
    489
    +        TransmittingBuoyType transmittingBuoyType = dataContext.getTransmittingBuoyType(transmittingBuoyTypeCode);
    
    490
    +        return Objects.requireNonNull(transmittingBuoyType, String.format("Can't find transmittingBuoyType with code: %s", buoyTypeCode));
    
    491
    +    }
    
    492
    +
    
    493
    +    /**
    
    494
    +     * To get objectMaterial id associated by a DCP from avdth ACTIVITE.C_TYP_OBJET code.
    
    495
    +     *
    
    496
    +     * @param objectTypeCode ACTIVITE.C_TYP_OBJET
    
    497
    +     * @return material or null
    
    498
    +     */
    
    499
    +    private ObjectMaterial getObjectMaterialByObjectTypeCode(ImportDataContext dataContext, String objectTypeCode) {
    
    500
    +        switch (objectTypeCode) {
    
    501
    +            case "1":
    
    502
    +                return dataContext.getObjectMaterialAFAD();
    
    503
    +            case "2":
    
    504
    +                return dataContext.getObjectMaterialDFAD();
    
    505
    +            case "3":
    
    506
    +                return dataContext.getObjectMaterialLOG();
    
    507
    +            case "9":
    
    508
    +                return dataContext.getObjectMaterialFOB();
    
    509
    +            case "10":
    
    510
    +                return dataContext.getObjectMaterialFALOG();
    
    511
    +            case "11":
    
    512
    +                return dataContext.getObjectMaterialHALOG();
    
    513
    +            case "13":
    
    514
    +                return dataContext.getObjectMaterialVNLOG();
    
    515
    +        }
    
    516
    +        return null;
    
    517
    +    }
    
    383 518
     }

  • src/site/markdown/avdth/logbook.md
    ... ... @@ -46,7 +46,7 @@ La table est déversée dans plusieurs tables :
    46 46
     | ACTIVITE_26 | V_VENT_DIR        | Activity.windDirection                     |               |
    
    47 47
     | ACTIVITE_27 | V_VENT_VIT        | Activity.wind                              | [9](#n_0_9)   | 
    
    48 48
     | ACTIVITE_28 | C_TYP_OBJET       |                                            | [10](#n_0_10) | 
    
    49
    -| ACTIVITE_29 | F_DCP_ECO         | ???                                        |               |
    
    49
    +| ACTIVITE_29 | F_DCP_ECO         | Dcp écologique                             | [10](#n_0_10) |
    
    50 50
     | ACTIVITE_30 | F_PROP_BALISE     | TransmittingBuoy.transmittingBuoyOwnerShip | [10](#n_0_10) |
    
    51 51
     | ACTIVITE_31 | C_TYP_BALISE      |                                            | [10](#n_0_10) |
    
    52 52
     | ACTIVITE_32 | V_ID_BALISE       | TransmittingBuoy.code                      |               |
    
    ... ... @@ -218,6 +218,7 @@ Pour le **simple mapping** on utilise la translation :
    218 218
     | 3                    | fr.ird.referential.ps.common.ObjectMaterial#0#0.50 | 2 LOG    |
    
    219 219
     | 9                    | fr.ird.referential.ps.common.ObjectMaterial#0#1.3  | FOB      |
    
    220 220
     
    
    221
    +Enfin si la valeur du champs **ACTIVITE.F_DCP_ECO** vaut **2**, alors on ajoute le matériel **4-1** (*Matériaux biodégradables*).
    
    221 222
     
    
    222 223
     * ```FloatingObject.transmittingBuoy```
    
    223 224