diff --git a/application/pom.xml b/application/pom.xml
index 1955d06a9..8270275ec 100644
--- a/application/pom.xml
+++ b/application/pom.xml
@@ -129,6 +129,12 @@
config-model
+
+
+ se.havochvatten.efr
+ efr-api-model-only
+
+
org.projectlombok
diff --git a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/bean/EfrMessageSaver.java b/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/bean/EfrMessageSaver.java
index 3ec0e8714..2312436df 100644
--- a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/bean/EfrMessageSaver.java
+++ b/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/bean/EfrMessageSaver.java
@@ -13,9 +13,9 @@ This file is part of the Integrated Fisheries Data Management (IFDM) Suite. The
import eu.europa.ec.fisheries.uvms.activity.fa.entities.FluxFaReportMessageEntity;
import eu.europa.ec.fisheries.uvms.activity.message.producer.ExchangeProducerBean;
import eu.europa.ec.fisheries.uvms.activity.service.FluxMessageService;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.FishingReport;
import eu.europa.ec.fisheries.uvms.activity.service.mapper.EfrToFluxMapper;
import lombok.extern.slf4j.Slf4j;
+import se.havochvatten.efr.efropenapi.model.FishingReport;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
diff --git a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/AbstractModelObject.java b/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/AbstractModelObject.java
deleted file mode 100644
index b0996f95a..000000000
--- a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/AbstractModelObject.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend;
-
-import javax.validation.constraints.NotNull;
-import java.time.Instant;
-
-/**
- * Copied from the EFR Backend project, these DTO classes are how it sends the
- * reports of completed fishing trips to this module
- */
-public abstract class AbstractModelObject {
-
- @NotNull(message = "Created at missing")
- private Instant clientCreatedAt;
-
- @NotNull(message = "Updated at missing")
- private Instant clientUpdatedAt;
-
- private Instant serverCreatedAt;
- private Instant serverUpdatedAt;
-
- // Suppress warnings about our NotNull instants not being set. This has to
- // be done by jsonb when deserializing the incoming DTOs, we don't want to
- // risk setting incorrect timestamps that give a false impression
- @SuppressWarnings("squid:S2637")
- public AbstractModelObject() {}
-
- public Instant getClientCreatedAt() {
- return clientCreatedAt;
- }
-
- public void setClientCreatedAt(Instant clientCreatedAt) {
- this.clientCreatedAt = clientCreatedAt;
- }
-
- public Instant getClientUpdatedAt() {
- return clientUpdatedAt;
- }
-
- public void setClientUpdatedAt(Instant clientUpdatedAt) {
- this.clientUpdatedAt = clientUpdatedAt;
- }
-
- public Instant getServerCreatedAt() {
- return serverCreatedAt;
- }
-
- public void setServerCreatedAt(Instant serverCreatedAt) {
- this.serverCreatedAt = serverCreatedAt;
- }
-
- public Instant getServerUpdatedAt() {
- return serverUpdatedAt;
- }
-
- public void setServerUpdatedAt(Instant serverUpdatedAt) {
- this.serverUpdatedAt = serverUpdatedAt;
- }
-
- @Override
- public String toString() {
- return "AbstractModelObject{" +
- "clientCreatedAt=" + clientCreatedAt +
- ", clientUpdatedAt=" + clientUpdatedAt +
- ", serverCreatedAt=" + serverCreatedAt +
- ", serverUpdatedAt=" + serverUpdatedAt +
- '}';
- }
-}
diff --git a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/ArrivalLocation.java b/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/ArrivalLocation.java
deleted file mode 100644
index a81e6e9f9..000000000
--- a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/ArrivalLocation.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend;
-
-import javax.validation.Valid;
-
-/**
- * Copied from the EFR Backend project, these DTO classes are how it sends the
- * reports of completed fishing trips to this module
- */
-public class ArrivalLocation {
-
- @Valid
- private UserSpecifiedLocation userSpecifiedLocation;
- private String portCode;
-
- public UserSpecifiedLocation getUserSpecifiedLocation() {
- return userSpecifiedLocation;
- }
-
- public void setUserSpecifiedLocation(UserSpecifiedLocation userSpecifiedLocation) {
- this.userSpecifiedLocation = userSpecifiedLocation;
- }
-
- public String getPortCode() {
- return portCode;
- }
-
- public void setPortCode(String portCode) {
- this.portCode = portCode;
- }
-}
diff --git a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/CatchGearSettings.java b/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/CatchGearSettings.java
deleted file mode 100644
index 09e9da5fb..000000000
--- a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/CatchGearSettings.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend;
-
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Positive;
-import java.time.Instant;
-
-/**
- * Copied from the EFR Backend project, these DTO classes are how it sends the
- * reports of completed fishing trips to this module
- */
-public class CatchGearSettings extends AbstractModelObject {
-
- @Positive
- private Integer meshSizeInMillimeter;
-
- @Positive
- @NotNull
- private Integer quantity;
-
- @NotNull
- private Instant deployedPeriodStartDate;
-
- @NotNull
- private Instant deployedPeriodEndDate;
-
- @NotNull
- private UserSpecifiedLocation gearLocation;
-
- public Integer getMeshSizeInMillimeter() {
- return meshSizeInMillimeter;
- }
-
- public void setMeshSizeInMillimeter(Integer meshSizeInMillimeter) {
- this.meshSizeInMillimeter = meshSizeInMillimeter;
- }
-
- public Integer getQuantity() {
- return quantity;
- }
-
- public void setQuantity(Integer quantity) {
- this.quantity = quantity;
- }
-
- public Instant getDeployedPeriodStartDate() {
- return deployedPeriodStartDate;
- }
-
- public void setDeployedPeriodStartDate(Instant deployedPeriodStartDate) {
- this.deployedPeriodStartDate = deployedPeriodStartDate;
- }
-
- public Instant getDeployedPeriodEndDate() {
- return deployedPeriodEndDate;
- }
-
- public void setDeployedPeriodEndDate(Instant deployedPeriodEndDate) {
- this.deployedPeriodEndDate = deployedPeriodEndDate;
- }
-
- public UserSpecifiedLocation getGearLocation() {
- return gearLocation;
- }
-
- public void setGearLocation(UserSpecifiedLocation gearLocation) {
- this.gearLocation = gearLocation;
- }
-}
diff --git a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/CatchSpecies.java b/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/CatchSpecies.java
deleted file mode 100644
index 4f42023c9..000000000
--- a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/CatchSpecies.java
+++ /dev/null
@@ -1,127 +0,0 @@
-package eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend;
-
-import javax.validation.constraints.NotEmpty;
-
-/**
- * Copied from the EFR Backend project, these DTO classes are how it sends the
- * reports of completed fishing trips to this module
- */
-public class CatchSpecies extends AbstractModelObject {
-
- @NotEmpty
- private String code;
-
- @NotEmpty
- private String variant;
-
- private Double lscWeightInKg;
- private Integer lscQuantity;
-
- private Double bmsWeightInKg;
- private Integer bmsQuantity;
-
- private Double disWeightInKg;
- private Integer disQuantity;
-
- private Double dimWeightInKg;
- private Integer dimQuantity;
-
- private Double rovWeightInKg;
- private Integer rovQuantity;
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public String getVariant() {
- return variant;
- }
-
- public void setVariant(String variant) {
- this.variant = variant;
- }
-
- public Double getLscWeightInKg() {
- return lscWeightInKg;
- }
-
- public void setLscWeightInKg(Double lscWeightInKg) {
- this.lscWeightInKg = lscWeightInKg;
- }
-
- public Integer getLscQuantity() {
- return lscQuantity;
- }
-
- public void setLscQuantity(Integer lscQuantity) {
- this.lscQuantity = lscQuantity;
- }
-
- public Double getBmsWeightInKg() {
- return bmsWeightInKg;
- }
-
- public void setBmsWeightInKg(Double bmsWeightInKg) {
- this.bmsWeightInKg = bmsWeightInKg;
- }
-
- public Integer getBmsQuantity() {
- return bmsQuantity;
- }
-
- public void setBmsQuantity(Integer bmsQuantity) {
- this.bmsQuantity = bmsQuantity;
- }
-
- public Double getDisWeightInKg() {
- return disWeightInKg;
- }
-
- public void setDisWeightInKg(Double disWeightInKg) {
- this.disWeightInKg = disWeightInKg;
- }
-
- public Integer getDisQuantity() {
- return disQuantity;
- }
-
- public void setDisQuantity(Integer disQuantity) {
- this.disQuantity = disQuantity;
- }
-
- public Double getDimWeightInKg() {
- return dimWeightInKg;
- }
-
- public void setDimWeightInKg(Double dimWeightInKg) {
- this.dimWeightInKg = dimWeightInKg;
- }
-
- public Integer getDimQuantity() {
- return dimQuantity;
- }
-
- public void setDimQuantity(Integer dimQuantity) {
- this.dimQuantity = dimQuantity;
- }
-
- public Double getRovWeightInKg() {
- return rovWeightInKg;
- }
-
- public void setRovWeightInKg(Double rovWeightInKg) {
- this.rovWeightInKg = rovWeightInKg;
- }
-
- public Integer getRovQuantity() {
- return rovQuantity;
- }
-
- public void setRovQuantity(Integer rovQuantity) {
- this.rovQuantity = rovQuantity;
- }
-}
diff --git a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/FishingCatch.java b/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/FishingCatch.java
deleted file mode 100644
index 87f9f05d3..000000000
--- a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/FishingCatch.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend;
-
-import javax.validation.constraints.NotEmpty;
-import javax.validation.constraints.NotNull;
-import java.util.List;
-import java.util.UUID;
-
-/**
- * Copied from the EFR Backend project, these DTO classes are how it sends the
- * reports of completed fishing trips to this module
- */
-public class FishingCatch extends AbstractModelObject {
-
- @NotNull
- private UUID id;
-
- @NotEmpty
- private String gearCode;
- private CatchGearSettings catchGearSettings;
-
- private boolean emptyCatch;
- private List species;
-
- public UUID getId() {
- return id;
- }
-
- public void setId(UUID id) {
- this.id = id;
- }
-
- public String getGearCode() {
- return gearCode;
- }
-
- public void setGearCode(String gearCode) {
- this.gearCode = gearCode;
- }
-
- public CatchGearSettings getCatchGearSettings() {
- return catchGearSettings;
- }
-
- public void setCatchGearSettings(CatchGearSettings catchGearSettings) {
- this.catchGearSettings = catchGearSettings;
- }
-
- public boolean isEmptyCatch() {
- return emptyCatch;
- }
-
- public void setEmptyCatch(boolean emptyCatch) {
- this.emptyCatch = emptyCatch;
- }
-
- public List getSpecies() {
- return species;
- }
-
- public void setSpecies(List species) {
- this.species = species;
- }
-}
diff --git a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/FishingReport.java b/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/FishingReport.java
deleted file mode 100644
index afdb41bde..000000000
--- a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/FishingReport.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend;
-
-import javax.validation.constraints.NotBlank;
-import java.util.List;
-import java.util.UUID;
-
-/**
- * Copied from the EFR Backend project, these DTO classes are how it sends the
- * reports of completed fishing trips to this module.
- *
- * This is the root object in the JSON message.
- */
-public class FishingReport extends AbstractModelObject {
-
- private UUID fishingReportId;
-
- @NotBlank(message = "Ship CFR missing")
- private String shipCfr;
-
- @NotBlank(message = "Target species code missing")
- private String targetSpeciesCode;
-
- private PriorNotificationDto priorNotification;
-
- private List fishingCatches;
-
- public UUID getFishingReportId() {
- return fishingReportId;
- }
-
- public void setFishingReportId(UUID fishingReportId) {
- this.fishingReportId = fishingReportId;
- }
-
- public String getShipCfr() {
- return shipCfr;
- }
-
- public void setShipCfr(String shipCfr) {
- this.shipCfr = shipCfr;
- }
-
- public String getTargetSpeciesCode() {
- return targetSpeciesCode;
- }
-
- public void setTargetSpeciesCode(String targetSpeciesCode) {
- this.targetSpeciesCode = targetSpeciesCode;
- }
-
- public PriorNotificationDto getPriorNotification() {
- return priorNotification;
- }
-
- public void setPriorNotification(PriorNotificationDto priorNotification) {
- this.priorNotification = priorNotification;
- }
-
- public List getFishingCatches() {
- return fishingCatches;
- }
-
- public void setFishingCatches(List fishingCatches) {
- this.fishingCatches = fishingCatches;
- }
-
- @Override
- public String toString() {
- return "FishingReport{" +
- "fishingReportId=" + fishingReportId +
- ", shipCfr='" + shipCfr + '\'' +
- ", targetSpeciesCode='" + targetSpeciesCode + '\'' +
- ", priorNotification=" + priorNotification +
- ", fishingCatches=" + fishingCatches +
- '}';
- }
-}
diff --git a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/PriorNotificationDto.java b/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/PriorNotificationDto.java
deleted file mode 100644
index 790c7c2b9..000000000
--- a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/PriorNotificationDto.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend;
-
-import javax.validation.Valid;
-import javax.validation.constraints.NotNull;
-import java.time.Instant;
-import java.util.Collection;
-
-/**
- * Copied from the EFR Backend project, these DTO classes are how it sends the
- * reports of completed fishing trips to this module
- */
-public class PriorNotificationDto extends AbstractModelObject {
-
- @NotNull
- private Instant estimatedLandingTime;
-
- @Valid
- private ArrivalLocation arrivalLocation;
-
- @Valid
- private Collection estimatedCatches;
-
- public Instant getEstimatedLandingTime() {
- return estimatedLandingTime;
- }
-
- public void setEstimatedLandingTime(Instant estimatedLandingTime) {
- this.estimatedLandingTime = estimatedLandingTime;
- }
-
- public ArrivalLocation getArrivalLocation() {
- return arrivalLocation;
- }
-
- public void setArrivalLocation(ArrivalLocation arrivalLocation) {
- this.arrivalLocation = arrivalLocation;
- }
-
- public Collection getEstimatedCatches() {
- return estimatedCatches;
- }
-
- public void setEstimatedCatches(Collection estimatedCatches) {
- this.estimatedCatches = estimatedCatches;
- }
-}
diff --git a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/PriorNotificationEstimatedCatch.java b/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/PriorNotificationEstimatedCatch.java
deleted file mode 100644
index 8ac8f58d6..000000000
--- a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/PriorNotificationEstimatedCatch.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend;
-
-import javax.validation.constraints.NotNull;
-
-/**
- * Copied from the EFR Backend project, these DTO classes are how it sends the
- * reports of completed fishing trips to this module
- */
-public class PriorNotificationEstimatedCatch {
-
- @NotNull
- private String code;
-
- private Integer quantity;
- private Double weightInKilos;
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public Integer getQuantity() {
- return quantity;
- }
-
- public void setQuantity(Integer quantity) {
- this.quantity = quantity;
- }
-
- public Double getWeightInKilos() {
- return weightInKilos;
- }
-
- public void setWeightInKilos(Double weightInKilos) {
- this.weightInKilos = weightInKilos;
- }
-}
diff --git a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/UserSpecifiedLocation.java b/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/UserSpecifiedLocation.java
deleted file mode 100644
index 2f3f6dc88..000000000
--- a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/dto/efrbackend/UserSpecifiedLocation.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend;
-
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Pattern;
-
-/**
- * Copied from the EFR Backend project, these DTO classes are how it sends the
- * reports of completed fishing trips to this module
- */
-public class UserSpecifiedLocation {
- private static final String LATITUDE_VALIDATION_REGEXP = "-?\\d{1,2}\\s\\d{1,2}\\s\\d{1,2}";
- private static final String LONGITUDE_VALIDATION_REGEXP = "-?\\d{1,3}\\s\\d{1,2}\\s\\d{1,2}";
-
- private String name;
-
- @Pattern(regexp = LATITUDE_VALIDATION_REGEXP)
- @NotNull
- private String latitude;
-
- @Pattern(regexp = LONGITUDE_VALIDATION_REGEXP)
- @NotNull
- private String longitude;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getLatitude() {
- return latitude;
- }
-
- public void setLatitude(String latitude) {
- this.latitude = latitude;
- }
-
- public String getLongitude() {
- return longitude;
- }
-
- public void setLongitude(String longitude) {
- this.longitude = longitude;
- }
-}
diff --git a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/mapper/EfrToFluxMapper.java b/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/mapper/EfrToFluxMapper.java
index 86b9c5d40..9adc476a7 100644
--- a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/mapper/EfrToFluxMapper.java
+++ b/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/mapper/EfrToFluxMapper.java
@@ -14,14 +14,14 @@
import eu.europa.ec.fisheries.uvms.activity.fa.entities.VesselTransportMeansEntity;
import eu.europa.ec.fisheries.uvms.activity.fa.utils.LocationEnum;
import eu.europa.ec.fisheries.uvms.activity.fa.utils.UnitCodeEnum;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.ArrivalLocation;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.CatchGearSettings;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.CatchSpecies;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.FishingCatch;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.FishingReport;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.PriorNotificationEstimatedCatch;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.UserSpecifiedLocation;
import eu.europa.ec.fisheries.uvms.activity.service.util.Utils;
+import se.havochvatten.efr.efropenapi.model.ArrivalLocation;
+import se.havochvatten.efr.efropenapi.model.CatchGearSettings;
+import se.havochvatten.efr.efropenapi.model.CatchSpecies;
+import se.havochvatten.efr.efropenapi.model.FishingCatch;
+import se.havochvatten.efr.efropenapi.model.FishingReport;
+import se.havochvatten.efr.efropenapi.model.PriorNotificationEstimatedCatch;
+import se.havochvatten.efr.efropenapi.model.UserSpecifiedLocation;
import javax.ejb.Stateless;
import java.math.BigDecimal;
@@ -37,6 +37,7 @@
public class EfrToFluxMapper {
private static final String PURPOSE_ORIGINAL = "9"; // From MDR list MDR_FLUX_GP_Purpose
+ private static final BigDecimal ZERO_BIG_DECIMAL = new BigDecimal(0);
// TODO have one document for all fishing activities instead of each one in separate documents?
@@ -495,10 +496,10 @@ private Set getCatchesForPriorNotificationOfArrival(FishingReport
fluxCatch.setUnitQuantityCode("C62");
// fluxCatch.setCalculatedUnitQuantity(); TODO set this as well?
- Double lscWeightInKg = efrCatch.getWeightInKilos();
+ BigDecimal lscWeightInKg = efrCatch.getWeightInKilos();
if (lscWeightInKg != null) {
// Spec says to round to two decimals
- double roundedLscWeight = new BigDecimal(lscWeightInKg).setScale(2, RoundingMode.HALF_UP).doubleValue();
+ double roundedLscWeight = lscWeightInKg.setScale(2, RoundingMode.HALF_UP).doubleValue();
fluxCatch.setWeightMeasure(roundedLscWeight);
fluxCatch.setWeightMeasureUnitCode("KGM");
//fluxCatch.setCalculatedWeightMeasure(); TODO set this as well?
@@ -722,19 +723,19 @@ private static boolean hasFishSizeClass(CatchSpecies species, String fishSizeCla
switch (fishSizeClass) {
case "BMS":
return (species.getBmsQuantity() != null && species.getBmsQuantity() > 0) ||
- (species.getBmsWeightInKg() != null && species.getBmsWeightInKg() > 0.0);
+ (species.getBmsWeightInKg() != null && species.getBmsWeightInKg().compareTo(ZERO_BIG_DECIMAL) > 0);
case "DIM":
return (species.getDimQuantity() != null && species.getDimQuantity() > 0) ||
- (species.getDimWeightInKg() != null && species.getDimWeightInKg() > 0.0);
+ (species.getDimWeightInKg() != null && species.getDimWeightInKg().compareTo(ZERO_BIG_DECIMAL) > 0);
case "DIS":
return (species.getDisQuantity() != null && species.getDisQuantity() > 0) ||
- (species.getDisWeightInKg() != null && species.getDisWeightInKg() > 0.0);
+ (species.getDisWeightInKg() != null && species.getDisWeightInKg().compareTo(ZERO_BIG_DECIMAL) > 0);
case "LSC":
return (species.getLscQuantity() != null && species.getLscQuantity() > 0) ||
- (species.getLscWeightInKg() != null && species.getLscWeightInKg() > 0.0);
+ (species.getLscWeightInKg() != null && species.getLscWeightInKg().compareTo(ZERO_BIG_DECIMAL) > 0);
case "ROV":
return (species.getRovQuantity() != null && species.getRovQuantity() > 0) ||
- (species.getRovWeightInKg() != null && species.getRovWeightInKg() > 0.0);
+ (species.getRovWeightInKg() != null && species.getRovWeightInKg().compareTo(ZERO_BIG_DECIMAL) > 0);
default:
return false;
}
@@ -770,7 +771,7 @@ private static void setCatchQuantity(FaCatchEntity fluxCatch, CatchSpecies speci
}
private static void setCatchWeightInKg(FaCatchEntity fluxCatch, CatchSpecies species, String fishSizeClass) {
- Double efrWeight;
+ BigDecimal efrWeight;
switch (fishSizeClass) {
case "BMS":
@@ -793,7 +794,7 @@ private static void setCatchWeightInKg(FaCatchEntity fluxCatch, CatchSpecies spe
}
if (efrWeight != null) {
- double roundedWeight = BigDecimal.valueOf(efrWeight)
+ double roundedWeight = efrWeight
.setScale(2, RoundingMode.HALF_UP)
.doubleValue();
fluxCatch.setWeightMeasure(roundedWeight);
diff --git a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/mapper/FluxToEfrMapper.java b/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/mapper/FluxToEfrMapper.java
index 3d80506c3..704cc4c75 100644
--- a/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/mapper/FluxToEfrMapper.java
+++ b/application/src/main/java/eu/europa/ec/fisheries/uvms/activity/service/mapper/FluxToEfrMapper.java
@@ -10,21 +10,21 @@
import eu.europa.ec.fisheries.uvms.activity.fa.entities.LocationEntity;
import eu.europa.ec.fisheries.uvms.activity.fa.entities.VesselTransportMeansEntity;
import eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierSchemeIdEnum;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.ArrivalLocation;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.CatchGearSettings;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.CatchSpecies;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.FishingCatch;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.FishingReport;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.PriorNotificationDto;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.PriorNotificationEstimatedCatch;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.UserSpecifiedLocation;
import eu.europa.ec.fisheries.uvms.activity.service.util.Utils;
import eu.europa.ec.fisheries.uvms.commons.service.exception.ModelMapperException;
+import se.havochvatten.efr.efropenapi.model.ArrivalLocation;
+import se.havochvatten.efr.efropenapi.model.CatchGearSettings;
+import se.havochvatten.efr.efropenapi.model.CatchSpecies;
+import se.havochvatten.efr.efropenapi.model.FishingCatch;
+import se.havochvatten.efr.efropenapi.model.FishingReport;
+import se.havochvatten.efr.efropenapi.model.PriorNotification;
+import se.havochvatten.efr.efropenapi.model.PriorNotificationEstimatedCatch;
+import se.havochvatten.efr.efropenapi.model.UserSpecifiedLocation;
import javax.ejb.Stateless;
+import java.math.BigDecimal;
import java.time.Instant;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -120,7 +120,7 @@ private String getTargetSpeciesCode(FluxFaReportMessageEntity fluxMessage) {
return departureFishingActivity != null ? departureFishingActivity.getSpeciesTargetCode() : null;
}
- private PriorNotificationDto createPriorNotification(FluxFaReportMessageEntity fluxMessage) throws ModelMapperException {
+ private PriorNotification createPriorNotification(FluxFaReportMessageEntity fluxMessage) throws ModelMapperException {
// find prior notification of arrival fishing activity
// TODO note this could be an actual arrival, not just prior notification.
// As of writing we don't create an actual arrival fishing activity, but
@@ -132,7 +132,7 @@ private PriorNotificationDto createPriorNotification(FluxFaReportMessageEntity f
throw new ModelMapperException("Found no prior notification fishing activity");
}
- PriorNotificationDto result = new PriorNotificationDto();
+ PriorNotification result = new PriorNotification();
// TODO result.timestamps?
result.setEstimatedLandingTime(priorNotificationActivity.getOccurence());
@@ -166,13 +166,13 @@ private ArrivalLocation createArrivalLocation(FishingActivityEntity priorNotific
return result;
}
- private Collection createPriorNotificationCatches(FishingActivityEntity priorNotificationActivity) {
+ private List createPriorNotificationCatches(FishingActivityEntity priorNotificationActivity) {
Set fluxCatches = priorNotificationActivity.getFaCatchs();
if (fluxCatches == null || fluxCatches.isEmpty()) {
- return new HashSet<>();
+ return new ArrayList<>(0);
}
- Collection result = new ArrayList<>();
+ List result = new ArrayList<>();
for (FaCatchEntity fluxCatch : fluxCatches) {
if (fluxCatch.getSpeciesCode() == null) {
continue;
@@ -181,7 +181,7 @@ private Collection createPriorNotificationCatch
PriorNotificationEstimatedCatch efrCatch = new PriorNotificationEstimatedCatch();
efrCatch.setCode(fluxCatch.getSpeciesCode());
efrCatch.setQuantity(fluxCatch.getUnitQuantity() != null ? fluxCatch.getUnitQuantity().intValue() : null);
- efrCatch.setWeightInKilos(fluxCatch.getWeightMeasure());
+ efrCatch.setWeightInKilos(fluxCatch.getWeightMeasure() != null ? new BigDecimal(fluxCatch.getWeightMeasure()) : null);
result.add(efrCatch);
}
@@ -312,12 +312,12 @@ private List createCatchSpecies(Set sameOcc
private void addToCatchSpeciesWeights(FaCatchEntity fluxCatch, CatchSpecies efrCatchSpecies) {
Integer fluxQuantity = fluxCatch.getUnitQuantity() != null ? fluxCatch.getUnitQuantity().intValue() : null;
- Double fluxWeight = fluxCatch.getWeightMeasure();
+ BigDecimal fluxWeight = fluxCatch.getWeightMeasure() != null ? new BigDecimal(fluxCatch.getWeightMeasure()) : null;
String classCode = fluxCatch.getSizeDistributionClassCode();
// TODO assert that weight unit is "KGM"?
Integer oldQuantity = null;
- Double oldWeight = null;
+ BigDecimal oldWeight = null;
switch (classCode) {
case "BMS":
@@ -345,13 +345,17 @@ private void addToCatchSpeciesWeights(FaCatchEntity fluxCatch, CatchSpecies efrC
}
Integer newQuantity = oldQuantity;
- Double newWeight = oldWeight;
+ BigDecimal newWeight = oldWeight;
if (fluxQuantity != null) {
newQuantity = fluxQuantity + (oldQuantity != null ? oldQuantity : 0);
}
if (fluxWeight != null) {
- newWeight = fluxWeight + (oldWeight != null ? oldWeight : 0.0);
+ if (oldWeight != null) {
+ newWeight = fluxWeight.add(oldWeight);
+ } else {
+ newWeight = fluxWeight;
+ }
}
switch (classCode) {
diff --git a/application/src/test/java/eu/europa/ec/fisheries/uvms/activity/service/bean/EfrMessageSaverTest.java b/application/src/test/java/eu/europa/ec/fisheries/uvms/activity/service/bean/EfrMessageSaverTest.java
index 4cd61e501..007c5530b 100644
--- a/application/src/test/java/eu/europa/ec/fisheries/uvms/activity/service/bean/EfrMessageSaverTest.java
+++ b/application/src/test/java/eu/europa/ec/fisheries/uvms/activity/service/bean/EfrMessageSaverTest.java
@@ -3,7 +3,6 @@
import eu.europa.ec.fisheries.uvms.activity.fa.entities.FluxFaReportMessageEntity;
import eu.europa.ec.fisheries.uvms.activity.message.producer.ExchangeProducerBean;
import eu.europa.ec.fisheries.uvms.activity.service.FluxMessageService;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.FishingReport;
import eu.europa.ec.fisheries.uvms.activity.service.mapper.EfrToFluxMapper;
import org.junit.Before;
import org.junit.Test;
@@ -11,6 +10,7 @@
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import se.havochvatten.efr.efropenapi.model.FishingReport;
import javax.jms.JMSException;
import javax.json.bind.JsonbBuilder;
diff --git a/application/src/test/java/eu/europa/ec/fisheries/uvms/activity/service/mapper/EfrToFluxMapperIntegrationTest.java b/application/src/test/java/eu/europa/ec/fisheries/uvms/activity/service/mapper/EfrToFluxMapperIntegrationTest.java
index 284c6eaa5..7239fb624 100644
--- a/application/src/test/java/eu/europa/ec/fisheries/uvms/activity/service/mapper/EfrToFluxMapperIntegrationTest.java
+++ b/application/src/test/java/eu/europa/ec/fisheries/uvms/activity/service/mapper/EfrToFluxMapperIntegrationTest.java
@@ -2,21 +2,22 @@
import eu.europa.ec.fisheries.uvms.activity.TransactionalTests;
import eu.europa.ec.fisheries.uvms.activity.fa.entities.FluxFaReportMessageEntity;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.ArrivalLocation;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.CatchGearSettings;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.CatchSpecies;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.FishingCatch;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.FishingReport;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.PriorNotificationDto;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.PriorNotificationEstimatedCatch;
-import eu.europa.ec.fisheries.uvms.activity.service.dto.efrbackend.UserSpecifiedLocation;
import eu.europa.ec.fisheries.uvms.commons.service.exception.ModelMapperException;
import org.jboss.arquillian.junit.Arquillian;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import se.havochvatten.efr.efropenapi.model.ArrivalLocation;
+import se.havochvatten.efr.efropenapi.model.CatchGearSettings;
+import se.havochvatten.efr.efropenapi.model.CatchSpecies;
+import se.havochvatten.efr.efropenapi.model.FishingCatch;
+import se.havochvatten.efr.efropenapi.model.FishingReport;
+import se.havochvatten.efr.efropenapi.model.PriorNotification;
+import se.havochvatten.efr.efropenapi.model.PriorNotificationEstimatedCatch;
+import se.havochvatten.efr.efropenapi.model.UserSpecifiedLocation;
import javax.inject.Inject;
+import java.math.BigDecimal;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
@@ -72,8 +73,8 @@ public void shipCfr() {
@Test
public void priorNotification_estimatedLandingTime() {
- PriorNotificationDto originalPriorNotification = originalDefault.getPriorNotification();
- PriorNotificationDto mappedPriorNotification = mappedDefault.getPriorNotification();
+ PriorNotification originalPriorNotification = originalDefault.getPriorNotification();
+ PriorNotification mappedPriorNotification = mappedDefault.getPriorNotification();
assertEquals(originalPriorNotification.getEstimatedLandingTime(), mappedPriorNotification.getEstimatedLandingTime());
}
@@ -279,10 +280,10 @@ private static FishingReport createFishingReport() {
CatchSpecies cath2Species2 = new CatchSpecies();
cath2Species2.setCode("ROV");
cath2Species2.setVariant("DEFAULT");
- cath2Species2.setRovWeightInKg(10.12);
+ cath2Species2.setRovWeightInKg(new BigDecimal(10.12));
catch2species.add(cath2Species2);
- PriorNotificationDto priorNotification = new PriorNotificationDto();
+ PriorNotification priorNotification = new PriorNotification();
priorNotification.setEstimatedLandingTime(Instant.now());
ArrayList estimatedCatches = new ArrayList<>();
priorNotification.setEstimatedCatches(estimatedCatches);
@@ -294,7 +295,7 @@ private static FishingReport createFishingReport() {
PriorNotificationEstimatedCatch estimatedCatch1 = new PriorNotificationEstimatedCatch();
estimatedCatch1.setCode("ASF");
- estimatedCatch1.setWeightInKilos(11.11);
+ estimatedCatch1.setWeightInKilos(new BigDecimal(11.11));
estimatedCatches.add(estimatedCatch1);
ArrivalLocation arrivalLocation = new ArrivalLocation();
@@ -318,7 +319,7 @@ private static FishingReport createMinimalFishingReport() {
result.setServerCreatedAt(xMinutesAgo(60));
result.setServerUpdatedAt(xMinutesAgo(55));
- PriorNotificationDto priorNotification = new PriorNotificationDto();
+ PriorNotification priorNotification = new PriorNotification();
priorNotification.setEstimatedLandingTime(Instant.now());
ArrivalLocation arrivalLocation = new ArrivalLocation();
diff --git a/pom.xml b/pom.xml
index 0e8f9b661..aeca382a6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -57,6 +57,9 @@
1.0.18
6.7.20
+
+ 1.1.0
+
1.3.1.Final
2.7.0
@@ -237,6 +240,13 @@
pom
+
+
+ se.havochvatten.efr
+ efr-api-model-only
+ ${efr-api.version}
+
+
org.geotools