From ff62f341bccb8b50dc453bbd75a5e70dc524a97e Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Wed, 4 Mar 2020 14:22:38 +0100 Subject: [PATCH] Traceability flag must be assigned only to Fishery records refs #18293 --- pom.xml | 2 +- .../json/input/record/Common.java | 23 ++----------------- .../json/input/record/FisheryRecord.java | 22 +++++++++++++++++- .../utils/CommonServiceUtils.java | 8 ++++--- 4 files changed, 29 insertions(+), 26 deletions(-) diff --git a/pom.xml b/pom.xml index a2660ed..d4b240a 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.gcube.data-catalogue grsf-publisher-ws - 1.10.0 + 1.11.0-SNAPSHOT war grsf-publisher-ws Utility library to publish GRSF products on GRSF catalogue. diff --git a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/json/input/record/Common.java b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/json/input/record/Common.java index a694ed9..50d81b4 100644 --- a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/json/input/record/Common.java +++ b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/json/input/record/Common.java @@ -52,11 +52,6 @@ public abstract class Common extends Base{ @CustomField(key=Constants.SHORT_NAME_CUSTOM_KEY) private String shortName; - @JsonProperty(Constants.TRACEABILITY_FLAG_JSON_KEY) - @CustomField(key=Constants.TRACEABILITY_FLAG_CUSTOM_KEY) - @Group(condition="true", groupNameOverValue=Constants.TRACEABILITY_FLAG_GROUP_NAME) // record is added to group grsf-traceability-flag if Traceability Flag is true - private Boolean traceabilityFlag; - @JsonProperty(Constants.SDG_FLAG_JSON_KEY) @CustomField(key=Constants.SDG_FLAG_CUSTOM_KEY) @Group(condition="true", groupNameOverValue=Constants.SDG_FLAG_GROUP_NAME) // record is added to group grsf-sdg-flag if sdg Flag is true @@ -165,7 +160,7 @@ public abstract class Common extends Base{ List> databaseSources, List> sourceOfInformation, List refersTo, String shortName, - Boolean traceabilityFlag, Status status, String systemType, + Status status, String systemType, List> catches, List> landings, List species, List similarGRSFRecords, @@ -179,7 +174,6 @@ public abstract class Common extends Base{ this.sourceOfInformation = sourceOfInformation; this.refersTo = refersTo; this.shortName = shortName; - this.traceabilityFlag = traceabilityFlag; this.status = status; this.systemType = systemType; this.catches = catches; @@ -227,10 +221,6 @@ public abstract class Common extends Base{ this.systemType = systemType; } - public Boolean getTraceabilityFlag() { - return traceabilityFlag; - } - public List getRefersTo() { return refersTo; } @@ -262,14 +252,6 @@ public abstract class Common extends Base{ this.shortName = shortName; } - public Boolean isTraceabilityFlag() { - return traceabilityFlag; - } - - public void setTraceabilityFlag(Boolean traceabilityFlag) { - this.traceabilityFlag = traceabilityFlag; - } - public Status getStatus() { return status; } @@ -388,8 +370,7 @@ public abstract class Common extends Base{ return "Common [dataOwner=" + dataOwner + ", databaseSources=" + databaseSources + ", sourceOfInformation=" + sourceOfInformation + ", refersTo=" + refersTo - + ", shortName=" + shortName + ", traceabilityFlag=" - + traceabilityFlag + ", sdgFlag=" + sdgFlag + ", status=" + + ", shortName=" + shortName + ", sdgFlag=" + sdgFlag + ", status=" + status + ", systemType=" + systemType + ", catches=" + catches + ", landings=" + landings + ", species=" + species + ", similarGRSFRecords=" + similarGRSFRecords diff --git a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/json/input/record/FisheryRecord.java b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/json/input/record/FisheryRecord.java index 17369a2..0845022 100644 --- a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/json/input/record/FisheryRecord.java +++ b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/json/input/record/FisheryRecord.java @@ -21,6 +21,10 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ public class FisheryRecord extends Common { + @JsonProperty(Constants.TRACEABILITY_FLAG_JSON_KEY) + @CustomField(key=Constants.TRACEABILITY_FLAG_CUSTOM_KEY) + @Group(condition="true", groupNameOverValue=Constants.TRACEABILITY_FLAG_GROUP_NAME) // record is added to group grsf-traceability-flag if Traceability Flag is true + private Boolean traceabilityFlag; @JsonProperty(Constants.FISHERY_NAME_JSON_KEY) @NotNull(message="fishery_name cannot be null") @@ -81,12 +85,13 @@ public class FisheryRecord extends Common { * @param fishingGear * @param type */ - public FisheryRecord(String fisheryName, String fisheryId, + public FisheryRecord(Boolean traceabilityFlag, String fisheryName, String fisheryId, List fishingArea, List resourcesExploited, List jurisdictionArea, List productionSystemType, List flagState, List fishingGear, Fishery_Type type) { super(); + this.traceabilityFlag = traceabilityFlag; this.fisheryName = fisheryName; this.fisheryId = fisheryId; this.fishingArea = fishingArea; @@ -97,6 +102,20 @@ public class FisheryRecord extends Common { this.fishingGear = fishingGear; this.type = type; } + + /* + public Boolean getTraceabilityFlag() { + return traceabilityFlag; + } + */ + + public Boolean isTraceabilityFlag() { + return traceabilityFlag; + } + + public void setTraceabilityFlag(Boolean traceabilityFlag) { + this.traceabilityFlag = traceabilityFlag; + } public String getFisheryName() { return fisheryName; @@ -175,6 +194,7 @@ public class FisheryRecord extends Common { public String toString() { return super.toString() + " - FisheryRecord [fisheryName=" + fisheryName + ", fisheryId=" + fisheryId + ", fishingArea=" + fishingArea + + ", traceabilityFlag=" + traceabilityFlag + ", resourcesExploited=" + resourcesExploited + ", jurisdictionArea=" + jurisdictionArea + ", productionSystemType=" + productionSystemType diff --git a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/CommonServiceUtils.java b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/CommonServiceUtils.java index 9298a32..5c46f86 100644 --- a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/CommonServiceUtils.java +++ b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/CommonServiceUtils.java @@ -81,9 +81,11 @@ public class CommonServiceUtils { if(refersToList == null || refersToList.isEmpty()) throw new Exception("refers_to cannot be null/empty"); - Boolean traceabilityFlag = record.isTraceabilityFlag(); - if(traceabilityFlag == null) - throw new Exception("traceability_flag cannot be null"); + if(record.getClass().equals(FisheryRecord.class)) { + Boolean traceabilityFlag = ((FisheryRecord) record).isTraceabilityFlag(); + if(traceabilityFlag == null) + throw new Exception("traceability_flag cannot be null"); + } Status status = record.getStatus(); if(status == null)