improvements for #9412
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@151390 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
76207370e9
commit
05de8af64f
|
@ -3,6 +3,9 @@
|
||||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||||
|
<dependent-module archiveName="ckan-util-library-2.3.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ckan-util-library/ckan-util-library">
|
||||||
|
<dependency-type>uses</dependency-type>
|
||||||
|
</dependent-module>
|
||||||
<property name="context-root" value="grsf-publisher-ws"/>
|
<property name="context-root" value="grsf-publisher-ws"/>
|
||||||
<property name="java-output-path" value="/grsf-publisher-ws/target/classes"/>
|
<property name="java-output-path" value="/grsf-publisher-ws/target/classes"/>
|
||||||
</wb-module>
|
</wb-module>
|
||||||
|
|
|
@ -26,7 +26,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
public class Base {
|
public class Base {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(Base.class);
|
private static Logger logger = LoggerFactory.getLogger(Base.class);
|
||||||
public static final String UUID_KB_KEY = "UUID Knowledge Base";
|
public static final String UUID_KB_KEY = "GRSF UUID";
|
||||||
|
|
||||||
@JsonProperty("catalog_id") //used on patch/update product call
|
@JsonProperty("catalog_id") //used on patch/update product call
|
||||||
private String catalogId;
|
private String catalogId;
|
||||||
|
|
|
@ -22,7 +22,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
@JsonIgnoreProperties(value = {"grsf_type", "source"})
|
@JsonIgnoreProperties(value = {"grsf_type", "source"})
|
||||||
public class Common extends Base{
|
public class Common extends Base{
|
||||||
|
|
||||||
public static final String GRSF_TYPE_KEY = "GRSF type"; // stock, fishery
|
public static final String GRSF_DOMAIN_KEY = "GRSF Domain"; // stock, fishery
|
||||||
public static final String SOURCE_KEY = "Source"; // in case it is a RAM/FIRMS/FishSource record it is not added
|
public static final String SOURCE_KEY = "Source"; // in case it is a RAM/FIRMS/FishSource record it is not added
|
||||||
|
|
||||||
// it is added in case of GRSF record
|
// it is added in case of GRSF record
|
||||||
|
@ -46,7 +46,7 @@ public class Common extends Base{
|
||||||
private List<RefersToBean> refersTo;
|
private List<RefersToBean> refersTo;
|
||||||
|
|
||||||
@JsonProperty("short_title")
|
@JsonProperty("short_title")
|
||||||
@CustomField(key="Short Title")
|
@CustomField(key="Short Name")
|
||||||
private String shortTitle;
|
private String shortTitle;
|
||||||
|
|
||||||
@JsonProperty("traceability_flag")
|
@JsonProperty("traceability_flag")
|
||||||
|
@ -55,25 +55,13 @@ public class Common extends Base{
|
||||||
private Boolean traceabilityFlag;
|
private Boolean traceabilityFlag;
|
||||||
|
|
||||||
@JsonProperty("status")
|
@JsonProperty("status")
|
||||||
@CustomField(key="Status")
|
@CustomField(key="Status of the GRSF record")
|
||||||
@Group
|
@Group
|
||||||
private Status status;
|
private Status status;
|
||||||
|
|
||||||
@JsonProperty("reporting_year")
|
|
||||||
@CustomField(key="Reporting year")
|
|
||||||
@TimeSeries
|
|
||||||
@Valid
|
|
||||||
private List<TimeSeriesBean<Void, Void>> reportingYear;
|
|
||||||
|
|
||||||
@JsonProperty("reference_year")
|
|
||||||
@CustomField(key="Reference year")
|
|
||||||
@TimeSeries
|
|
||||||
@Valid
|
|
||||||
private List<TimeSeriesBean<Void, Void>> referenceYear;
|
|
||||||
|
|
||||||
// automatically compiled
|
// automatically compiled
|
||||||
@JsonProperty("grsf_type")
|
@JsonProperty("grsf_type")
|
||||||
@CustomField(key=GRSF_TYPE_KEY)
|
@CustomField(key=GRSF_DOMAIN_KEY)
|
||||||
private String grsfType;
|
private String grsfType;
|
||||||
|
|
||||||
// automatically compiled
|
// automatically compiled
|
||||||
|
@ -98,7 +86,7 @@ public class Common extends Base{
|
||||||
private List<String> species;
|
private List<String> species;
|
||||||
|
|
||||||
@JsonProperty("similar_records")
|
@JsonProperty("similar_records")
|
||||||
@CustomField(key="Similar Records")
|
@CustomField(key="Similar GRSF Records")
|
||||||
private List<SimilarRecordBean> similarRecords;
|
private List<SimilarRecordBean> similarRecords;
|
||||||
|
|
||||||
public Common() {
|
public Common() {
|
||||||
|
@ -113,8 +101,6 @@ public class Common extends Base{
|
||||||
* @param shortTitle
|
* @param shortTitle
|
||||||
* @param traceabilityFlag
|
* @param traceabilityFlag
|
||||||
* @param status
|
* @param status
|
||||||
* @param reportingYear
|
|
||||||
* @param referenceYear
|
|
||||||
* @param grsfType
|
* @param grsfType
|
||||||
* @param sourceType
|
* @param sourceType
|
||||||
* @param catches
|
* @param catches
|
||||||
|
@ -126,9 +112,7 @@ public class Common extends Base{
|
||||||
List<Resource<Sources>> databaseSources,
|
List<Resource<Sources>> databaseSources,
|
||||||
List<Resource<String>> sourceOfInformation,
|
List<Resource<String>> sourceOfInformation,
|
||||||
List<RefersToBean> refersTo, String shortTitle,
|
List<RefersToBean> refersTo, String shortTitle,
|
||||||
Boolean traceabilityFlag, Status status,
|
Boolean traceabilityFlag, Status status, String grsfType,
|
||||||
List<TimeSeriesBean<Void, Void>> reportingYear,
|
|
||||||
List<TimeSeriesBean<Void, Void>> referenceYear, String grsfType,
|
|
||||||
String sourceType, List<TimeSeriesBean<String, String>> catches,
|
String sourceType, List<TimeSeriesBean<String, String>> catches,
|
||||||
List<TimeSeriesBean<String, String>> landings,
|
List<TimeSeriesBean<String, String>> landings,
|
||||||
List<String> species, List<SimilarRecordBean> similarRecords) {
|
List<String> species, List<SimilarRecordBean> similarRecords) {
|
||||||
|
@ -140,8 +124,6 @@ public class Common extends Base{
|
||||||
this.shortTitle = shortTitle;
|
this.shortTitle = shortTitle;
|
||||||
this.traceabilityFlag = traceabilityFlag;
|
this.traceabilityFlag = traceabilityFlag;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
this.reportingYear = reportingYear;
|
|
||||||
this.referenceYear = referenceYear;
|
|
||||||
this.grsfType = grsfType;
|
this.grsfType = grsfType;
|
||||||
this.sourceType = sourceType;
|
this.sourceType = sourceType;
|
||||||
this.catches = catches;
|
this.catches = catches;
|
||||||
|
@ -177,19 +159,6 @@ public class Common extends Base{
|
||||||
public void setRefersTo(List<RefersToBean> refersTo) {
|
public void setRefersTo(List<RefersToBean> refersTo) {
|
||||||
this.refersTo = refersTo;
|
this.refersTo = refersTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TimeSeriesBean<Void, Void>> getReportingYear() {
|
|
||||||
return reportingYear;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReportingYear(List<TimeSeriesBean<Void, Void>> reportingYear) {
|
|
||||||
this.reportingYear = reportingYear;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReferenceYear(List<TimeSeriesBean<Void, Void>> referenceYear) {
|
|
||||||
this.referenceYear = referenceYear;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Resource<Sources>> getDatabaseSources() {
|
public List<Resource<Sources>> getDatabaseSources() {
|
||||||
return databaseSources;
|
return databaseSources;
|
||||||
}
|
}
|
||||||
|
@ -262,10 +231,6 @@ public class Common extends Base{
|
||||||
this.dataOwner = dataOwner;
|
this.dataOwner = dataOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TimeSeriesBean<Void, Void>> getReferenceYear() {
|
|
||||||
return referenceYear;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SimilarRecordBean> getSimilarRecords() {
|
public List<SimilarRecordBean> getSimilarRecords() {
|
||||||
return similarRecords;
|
return similarRecords;
|
||||||
}
|
}
|
||||||
|
@ -276,28 +241,14 @@ public class Common extends Base{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Common ["
|
return "Common [dataOwner=" + dataOwner + ", databaseSources="
|
||||||
+ (dataOwner != null ? "dataOwner=" + dataOwner + ", " : "")
|
+ databaseSources + ", sourceOfInformation="
|
||||||
+ (databaseSources != null ? "databaseSources="
|
+ sourceOfInformation + ", refersTo=" + refersTo
|
||||||
+ databaseSources + ", " : "")
|
+ ", shortTitle=" + shortTitle + ", traceabilityFlag="
|
||||||
+ (sourceOfInformation != null ? "sourceOfInformation="
|
+ traceabilityFlag + ", status=" + status + ", grsfType="
|
||||||
+ sourceOfInformation + ", " : "")
|
+ grsfType + ", sourceType=" + sourceType + ", catches="
|
||||||
+ (refersTo != null ? "refersTo=" + refersTo + ", " : "")
|
+ catches + ", landings=" + landings + ", species=" + species
|
||||||
+ (shortTitle != null ? "shortTitle=" + shortTitle + ", " : "")
|
+ ", similarRecords=" + similarRecords + "]";
|
||||||
+ (traceabilityFlag != null ? "traceabilityFlag="
|
|
||||||
+ traceabilityFlag + ", " : "")
|
|
||||||
+ (status != null ? "status=" + status + ", " : "")
|
|
||||||
+ (reportingYear != null ? "reportingYear=" + reportingYear
|
|
||||||
+ ", " : "")
|
|
||||||
+ (referenceYear != null ? "referenceYear=" + referenceYear
|
|
||||||
+ ", " : "")
|
|
||||||
+ (grsfType != null ? "grsfType=" + grsfType + ", " : "")
|
|
||||||
+ (sourceType != null ? "sourceType=" + sourceType + ", " : "")
|
|
||||||
+ (catches != null ? "catches=" + catches + ", " : "")
|
|
||||||
+ (landings != null ? "landings=" + landings + ", " : "")
|
|
||||||
+ (species != null ? "species=" + species + ", " : "")
|
|
||||||
+ (similarRecords != null ? "similarRecords=" + similarRecords
|
|
||||||
: "") + "]";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -24,11 +24,11 @@ public class FisheryRecord extends Common{
|
||||||
@JsonProperty("fishery_name")
|
@JsonProperty("fishery_name")
|
||||||
@NotNull(message="fishery_name cannot be null")
|
@NotNull(message="fishery_name cannot be null")
|
||||||
@Size(min=1, message="fishery_name cannot be empty")
|
@Size(min=1, message="fishery_name cannot be empty")
|
||||||
@CustomField(key="Fishery Name")
|
@CustomField(key="GRSF Name")
|
||||||
private String fisheryName;
|
private String fisheryName;
|
||||||
|
|
||||||
@JsonProperty("fishery_id")
|
@JsonProperty("fishery_id")
|
||||||
@CustomField(key="Fishery id")
|
@CustomField(key="GRSF Semantic identifier")
|
||||||
private String fisheryId;
|
private String fisheryId;
|
||||||
|
|
||||||
@JsonProperty("fishing_area")
|
@JsonProperty("fishing_area")
|
||||||
|
@ -36,11 +36,11 @@ public class FisheryRecord extends Common{
|
||||||
private List<String> fishingArea;
|
private List<String> fishingArea;
|
||||||
|
|
||||||
@JsonProperty("exploited_stocks")
|
@JsonProperty("exploited_stocks")
|
||||||
@CustomField(key="Exploited stocks")
|
@CustomField(key="Resources Exploited")
|
||||||
private List<String> exploitingStocks;
|
private List<String> exploitingStocks;
|
||||||
|
|
||||||
@JsonProperty("management_entity")
|
@JsonProperty("management_entity")
|
||||||
@CustomField(key="Management entity")
|
@CustomField(key="Management Body/Authority(ies)")
|
||||||
private List<String> managementEntity;
|
private List<String> managementEntity;
|
||||||
|
|
||||||
@JsonProperty("jurisdiction_area")
|
@JsonProperty("jurisdiction_area")
|
||||||
|
@ -49,29 +49,21 @@ public class FisheryRecord extends Common{
|
||||||
private List<String> jurisdictionArea;
|
private List<String> jurisdictionArea;
|
||||||
|
|
||||||
@JsonProperty("production_system_type")
|
@JsonProperty("production_system_type")
|
||||||
|
@CustomField(key="Type of Production System")
|
||||||
@Tag
|
@Tag
|
||||||
@CustomField(key="Production system type")
|
|
||||||
private List<Production_System_Type> productionSystemType;
|
private List<Production_System_Type> productionSystemType;
|
||||||
|
|
||||||
@JsonProperty("flag_state")
|
@JsonProperty("flag_state")
|
||||||
|
@CustomField(key="Flag State")
|
||||||
@Tag
|
@Tag
|
||||||
@CustomField(key="Flag state")
|
|
||||||
private List<String> flagState;
|
private List<String> flagState;
|
||||||
|
|
||||||
@JsonProperty("fishing_gear")
|
@JsonProperty("fishing_gear")
|
||||||
@CustomField(key="Fishing gear")
|
@CustomField(key="Fishing gear")
|
||||||
private List<String> fishingGear;
|
private List<String> fishingGear;
|
||||||
|
|
||||||
@JsonProperty("environment")
|
|
||||||
@CustomField(key="Environment")
|
|
||||||
private String environment;
|
|
||||||
|
|
||||||
@JsonProperty("fishery_uri")
|
|
||||||
@CustomField(key="Fishery Uri")
|
|
||||||
private String fisheryUri;
|
|
||||||
|
|
||||||
@JsonProperty("type")
|
@JsonProperty("type")
|
||||||
@CustomField(key="Type")
|
@CustomField(key="GRSF Type")
|
||||||
@Group
|
@Group
|
||||||
private Fishery_Type type;
|
private Fishery_Type type;
|
||||||
|
|
||||||
|
@ -89,16 +81,13 @@ public class FisheryRecord extends Common{
|
||||||
* @param productionSystemType
|
* @param productionSystemType
|
||||||
* @param flagState
|
* @param flagState
|
||||||
* @param fishingGear
|
* @param fishingGear
|
||||||
* @param environment
|
|
||||||
* @param fisheryUri
|
|
||||||
* @param type
|
* @param type
|
||||||
*/
|
*/
|
||||||
public FisheryRecord(String fisheryName, String fisheryId,
|
public FisheryRecord(String fisheryName, String fisheryId,
|
||||||
List<String> fishingArea, List<String> exploitingStocks,
|
List<String> fishingArea, List<String> exploitingStocks,
|
||||||
List<String> managementEntity, List<String> jurisdictionArea,
|
List<String> managementEntity, List<String> jurisdictionArea,
|
||||||
List<Production_System_Type> productionSystemType,
|
List<Production_System_Type> productionSystemType,
|
||||||
List<String> flagState, List<String> fishingGear,
|
List<String> flagState, List<String> fishingGear, Fishery_Type type) {
|
||||||
String environment, String fisheryUri, Fishery_Type type) {
|
|
||||||
super();
|
super();
|
||||||
this.fisheryName = fisheryName;
|
this.fisheryName = fisheryName;
|
||||||
this.fisheryId = fisheryId;
|
this.fisheryId = fisheryId;
|
||||||
|
@ -109,19 +98,9 @@ public class FisheryRecord extends Common{
|
||||||
this.productionSystemType = productionSystemType;
|
this.productionSystemType = productionSystemType;
|
||||||
this.flagState = flagState;
|
this.flagState = flagState;
|
||||||
this.fishingGear = fishingGear;
|
this.fishingGear = fishingGear;
|
||||||
this.environment = environment;
|
|
||||||
this.fisheryUri = fisheryUri;
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFisheryUri() {
|
|
||||||
return fisheryUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFisheryUri(String fisheryUri) {
|
|
||||||
this.fisheryUri = fisheryUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFisheryName() {
|
public String getFisheryName() {
|
||||||
return fisheryName;
|
return fisheryName;
|
||||||
}
|
}
|
||||||
|
@ -154,14 +133,6 @@ public class FisheryRecord extends Common{
|
||||||
this.jurisdictionArea = jurisdictionArea;
|
this.jurisdictionArea = jurisdictionArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEnvironment() {
|
|
||||||
return environment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnvironment(String environment) {
|
|
||||||
this.environment = environment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Fishery_Type getType() {
|
public Fishery_Type getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
@ -220,7 +191,6 @@ public class FisheryRecord extends Common{
|
||||||
+ ", jurisdictionArea=" + jurisdictionArea
|
+ ", jurisdictionArea=" + jurisdictionArea
|
||||||
+ ", productionSystemType=" + productionSystemType
|
+ ", productionSystemType=" + productionSystemType
|
||||||
+ ", flagState=" + flagState + ", fishingGear=" + fishingGear
|
+ ", flagState=" + flagState + ", fishingGear=" + fishingGear
|
||||||
+ ", environment=" + environment + ", fisheryUri=" + fisheryUri
|
|
||||||
+ ", type=" + type + "]";
|
+ ", type=" + type + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,36 +27,32 @@ public class StockRecord extends Common{
|
||||||
@JsonProperty("stock_name")
|
@JsonProperty("stock_name")
|
||||||
@NotNull(message="stock_name cannot be null")
|
@NotNull(message="stock_name cannot be null")
|
||||||
@Size(min=2, message="stock_name cannot be empty")
|
@Size(min=2, message="stock_name cannot be empty")
|
||||||
@CustomField(key="Stock Name")
|
@CustomField(key="GRSF Name")
|
||||||
private String stockName;
|
private String stockName;
|
||||||
|
|
||||||
@JsonProperty("stock_id")
|
@JsonProperty("stock_id")
|
||||||
@CustomField(key="Stock id")
|
@CustomField(key="GRSF Semantic identifier")
|
||||||
private String stockId;
|
private String stockId;
|
||||||
|
|
||||||
@JsonProperty("assessment_distribution_area")
|
@JsonProperty("assessment_distribution_area")
|
||||||
@CustomField(key="Assessment distribution area")
|
@CustomField(key="Assessment Area")
|
||||||
private List<String> area;
|
private List<String> area;
|
||||||
|
|
||||||
@JsonProperty("exploiting_fishery")
|
@JsonProperty("exploiting_fishery")
|
||||||
@CustomField(key="Exploiting fishery")
|
@CustomField(key="Exploiting Fishery")
|
||||||
private List<String> exploitingFishery;
|
private List<String> exploitingFishery;
|
||||||
|
|
||||||
@JsonProperty("management_entity")
|
@JsonProperty("management_entity")
|
||||||
@CustomField(key="Management entity")
|
@CustomField(key="Management Body/Authority(ies)")
|
||||||
@Tag
|
@Tag
|
||||||
private String managementEntity;
|
private String managementEntity;
|
||||||
|
|
||||||
@JsonProperty("assessment_methods")
|
@JsonProperty("assessment_methods")
|
||||||
@CustomField(key="Assessment methods")
|
@CustomField(key="Assessment Methods")
|
||||||
private List<String> assessmentMethods;
|
private List<String> assessmentMethods;
|
||||||
|
|
||||||
@JsonProperty("state_of_marine_resource")
|
|
||||||
@CustomField(key="State of marine resources")
|
|
||||||
private String stateOfMarineResource;
|
|
||||||
|
|
||||||
@JsonProperty("standard_abundance_level")
|
@JsonProperty("standard_abundance_level")
|
||||||
@CustomField(key="Standard Abundance Level")
|
@CustomField(key="Abundance Level (FIRMS Standard)")
|
||||||
@TimeSeries
|
@TimeSeries
|
||||||
@Valid
|
@Valid
|
||||||
private List<TimeSeriesBean<Abundance_Level, Void>> abundanceLevelStandard;
|
private List<TimeSeriesBean<Abundance_Level, Void>> abundanceLevelStandard;
|
||||||
|
@ -68,7 +64,7 @@ public class StockRecord extends Common{
|
||||||
private List<TimeSeriesBean<String, String>> abundanceLevel;
|
private List<TimeSeriesBean<String, String>> abundanceLevel;
|
||||||
|
|
||||||
@JsonProperty("standard_fishing_pressure")
|
@JsonProperty("standard_fishing_pressure")
|
||||||
@CustomField(key="Standard Fishing Pressure")
|
@CustomField(key="Fishing Pressure (FIRMS Standard)")
|
||||||
@TimeSeries
|
@TimeSeries
|
||||||
@Valid
|
@Valid
|
||||||
private List<TimeSeriesBean<Fishing_Pressure, Void>> fishingPressureStandard;
|
private List<TimeSeriesBean<Fishing_Pressure, Void>> fishingPressureStandard;
|
||||||
|
@ -80,13 +76,13 @@ public class StockRecord extends Common{
|
||||||
private List<TimeSeriesBean<String, String>> fishingPressure;
|
private List<TimeSeriesBean<String, String>> fishingPressure;
|
||||||
|
|
||||||
@JsonProperty("narrative_state")
|
@JsonProperty("narrative_state")
|
||||||
@CustomField(key="Narrative state")
|
@CustomField(key="State and trend of Marine Resource")
|
||||||
@TimeSeries
|
@TimeSeries
|
||||||
@Valid
|
@Valid
|
||||||
private List<TimeSeriesBean<String, Void>> narrativeState;
|
private List<TimeSeriesBean<String, Void>> narrativeState;
|
||||||
|
|
||||||
@JsonProperty("fao_state")
|
@JsonProperty("fao_state")
|
||||||
@CustomField(key="Fao State")
|
@CustomField(key="Fao Categories")
|
||||||
@TimeSeries
|
@TimeSeries
|
||||||
@Valid
|
@Valid
|
||||||
private List<TimeSeriesBean<String, Void>> faoState;
|
private List<TimeSeriesBean<String, Void>> faoState;
|
||||||
|
@ -100,17 +96,8 @@ public class StockRecord extends Common{
|
||||||
@Tag
|
@Tag
|
||||||
private String assessor;
|
private String assessor;
|
||||||
|
|
||||||
@JsonProperty("stock_uri")
|
|
||||||
@CustomField(key="Stock Uri")
|
|
||||||
private String stockUri;
|
|
||||||
|
|
||||||
@JsonProperty("water_area")
|
|
||||||
@CustomField(key="Water Area")
|
|
||||||
@Tag
|
|
||||||
private List<String> waterArea;
|
|
||||||
|
|
||||||
@JsonProperty("type")
|
@JsonProperty("type")
|
||||||
@CustomField(key="Type")
|
@CustomField(key="GRSF Type")
|
||||||
@Group
|
@Group
|
||||||
private Stock_Type type;
|
private Stock_Type type;
|
||||||
|
|
||||||
|
@ -125,7 +112,6 @@ public class StockRecord extends Common{
|
||||||
* @param exploitingFishery
|
* @param exploitingFishery
|
||||||
* @param managementEntity
|
* @param managementEntity
|
||||||
* @param assessmentMethods
|
* @param assessmentMethods
|
||||||
* @param stateOfMarineResource
|
|
||||||
* @param abundanceLevelStandard
|
* @param abundanceLevelStandard
|
||||||
* @param abundanceLevel
|
* @param abundanceLevel
|
||||||
* @param fishingPressureStandard
|
* @param fishingPressureStandard
|
||||||
|
@ -134,8 +120,6 @@ public class StockRecord extends Common{
|
||||||
* @param faoState
|
* @param faoState
|
||||||
* @param scientificAdvice
|
* @param scientificAdvice
|
||||||
* @param assessor
|
* @param assessor
|
||||||
* @param stockUri
|
|
||||||
* @param waterArea
|
|
||||||
* @param type
|
* @param type
|
||||||
*/
|
*/
|
||||||
public StockRecord(
|
public StockRecord(
|
||||||
|
@ -145,15 +129,13 @@ public class StockRecord extends Common{
|
||||||
List<String> exploitingFishery,
|
List<String> exploitingFishery,
|
||||||
String managementEntity,
|
String managementEntity,
|
||||||
List<String> assessmentMethods,
|
List<String> assessmentMethods,
|
||||||
String stateOfMarineResource,
|
|
||||||
List<TimeSeriesBean<Abundance_Level, Void>> abundanceLevelStandard,
|
List<TimeSeriesBean<Abundance_Level, Void>> abundanceLevelStandard,
|
||||||
List<TimeSeriesBean<String, String>> abundanceLevel,
|
List<TimeSeriesBean<String, String>> abundanceLevel,
|
||||||
List<TimeSeriesBean<Fishing_Pressure, Void>> fishingPressureStandard,
|
List<TimeSeriesBean<Fishing_Pressure, Void>> fishingPressureStandard,
|
||||||
List<TimeSeriesBean<String, String>> fishingPressure,
|
List<TimeSeriesBean<String, String>> fishingPressure,
|
||||||
List<TimeSeriesBean<String, Void>> narrativeState,
|
List<TimeSeriesBean<String, Void>> narrativeState,
|
||||||
List<TimeSeriesBean<String, Void>> faoState,
|
List<TimeSeriesBean<String, Void>> faoState,
|
||||||
List<String> scientificAdvice, String assessor, String stockUri,
|
List<String> scientificAdvice, String assessor, Stock_Type type) {
|
||||||
List<String> waterArea, Stock_Type type) {
|
|
||||||
super();
|
super();
|
||||||
this.stockName = stockName;
|
this.stockName = stockName;
|
||||||
this.stockId = stockId;
|
this.stockId = stockId;
|
||||||
|
@ -161,7 +143,6 @@ public class StockRecord extends Common{
|
||||||
this.exploitingFishery = exploitingFishery;
|
this.exploitingFishery = exploitingFishery;
|
||||||
this.managementEntity = managementEntity;
|
this.managementEntity = managementEntity;
|
||||||
this.assessmentMethods = assessmentMethods;
|
this.assessmentMethods = assessmentMethods;
|
||||||
this.stateOfMarineResource = stateOfMarineResource;
|
|
||||||
this.abundanceLevelStandard = abundanceLevelStandard;
|
this.abundanceLevelStandard = abundanceLevelStandard;
|
||||||
this.abundanceLevel = abundanceLevel;
|
this.abundanceLevel = abundanceLevel;
|
||||||
this.fishingPressureStandard = fishingPressureStandard;
|
this.fishingPressureStandard = fishingPressureStandard;
|
||||||
|
@ -170,8 +151,6 @@ public class StockRecord extends Common{
|
||||||
this.faoState = faoState;
|
this.faoState = faoState;
|
||||||
this.scientificAdvice = scientificAdvice;
|
this.scientificAdvice = scientificAdvice;
|
||||||
this.assessor = assessor;
|
this.assessor = assessor;
|
||||||
this.stockUri = stockUri;
|
|
||||||
this.waterArea = waterArea;
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,22 +166,6 @@ public class StockRecord extends Common{
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStockUri() {
|
|
||||||
return stockUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStockUri(String stockUri) {
|
|
||||||
this.stockUri = stockUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getWaterArea() {
|
|
||||||
return waterArea;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWaterArea(List<String> waterArea) {
|
|
||||||
this.waterArea = waterArea;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStockName() {
|
public String getStockName() {
|
||||||
return stockName;
|
return stockName;
|
||||||
}
|
}
|
||||||
|
@ -261,14 +224,6 @@ public class StockRecord extends Common{
|
||||||
this.managementEntity = managementEntity;
|
this.managementEntity = managementEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStateOfMarineResource() {
|
|
||||||
return stateOfMarineResource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStateOfMarineResource(String stateOfMarineResource) {
|
|
||||||
this.stateOfMarineResource = stateOfMarineResource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<TimeSeriesBean<Abundance_Level, Void>> getAbundanceLevelStandard() {
|
public List<TimeSeriesBean<Abundance_Level, Void>> getAbundanceLevelStandard() {
|
||||||
return abundanceLevelStandard;
|
return abundanceLevelStandard;
|
||||||
}
|
}
|
||||||
|
@ -329,15 +284,13 @@ public class StockRecord extends Common{
|
||||||
+ ", area=" + area + ", exploitingFishery=" + exploitingFishery
|
+ ", area=" + area + ", exploitingFishery=" + exploitingFishery
|
||||||
+ ", managementEntity=" + managementEntity
|
+ ", managementEntity=" + managementEntity
|
||||||
+ ", assessmentMethods=" + assessmentMethods
|
+ ", assessmentMethods=" + assessmentMethods
|
||||||
+ ", stateOfMarineResource=" + stateOfMarineResource
|
|
||||||
+ ", abundanceLevelStandard=" + abundanceLevelStandard
|
+ ", abundanceLevelStandard=" + abundanceLevelStandard
|
||||||
+ ", abundanceLevel=" + abundanceLevel
|
+ ", abundanceLevel=" + abundanceLevel
|
||||||
+ ", fishingPressureStandard=" + fishingPressureStandard
|
+ ", fishingPressureStandard=" + fishingPressureStandard
|
||||||
+ ", fishingPressure=" + fishingPressure + ", narrativeState="
|
+ ", fishingPressure=" + fishingPressure + ", narrativeState="
|
||||||
+ narrativeState + ", scientificAdvice=" + scientificAdvice
|
+ narrativeState + ", faoState=" + faoState
|
||||||
+ ", assessor=" + assessor + ", stockUri=" + stockUri
|
+ ", scientificAdvice=" + scientificAdvice + ", assessor="
|
||||||
+ ", waterArea=" + waterArea + ", type=" + type + ", faoState="
|
+ assessor + ", type=" + type + "]";
|
||||||
+ faoState + "]";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class TimeSeriesBean<T, T1> implements Comparable<TimeSeriesBean<T, T1>>{
|
||||||
|
|
||||||
@JsonProperty(SOURCE_FIELD)
|
@JsonProperty(SOURCE_FIELD)
|
||||||
private String source;
|
private String source;
|
||||||
|
|
||||||
@JsonProperty(ASSESSMENT_FIELD)
|
@JsonProperty(ASSESSMENT_FIELD)
|
||||||
private String assessment;
|
private String assessment;
|
||||||
|
|
||||||
|
@ -90,18 +90,6 @@ public class TimeSeriesBean<T, T1> implements Comparable<TimeSeriesBean<T, T1>>{
|
||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
|
|
||||||
String firstPart = "" + year;
|
|
||||||
String secondPart = (value != null ? " - " + value : "")
|
|
||||||
+ (unit != null ? " - " + unit : "")
|
|
||||||
+ (source != null ? " (" + source + ")" : "")
|
|
||||||
+ (assessment != null ? " (" + assessment + ")" : "");
|
|
||||||
return firstPart + (secondPart != null && !secondPart.isEmpty() ? secondPart : "");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAssessment() {
|
public String getAssessment() {
|
||||||
return assessment;
|
return assessment;
|
||||||
}
|
}
|
||||||
|
@ -114,9 +102,33 @@ public class TimeSeriesBean<T, T1> implements Comparable<TimeSeriesBean<T, T1>>{
|
||||||
return unit != null && !unit.getClass().equals(Void.class);
|
return unit != null && !unit.getClass().equals(Void.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSourcePresent(){
|
||||||
|
return source != null && !source.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAssessmentPresent(){
|
||||||
|
return assessment != null && !assessment.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValuePresent(){
|
||||||
|
return value != null && !value.getClass().equals(Void.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(TimeSeriesBean<T, T1> o) {
|
public int compareTo(TimeSeriesBean<T, T1> o) {
|
||||||
return (int) (this.year - o.year); // ascending.. low to highest
|
return (int) (this.year - o.year); // ascending.. low to highest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
|
||||||
|
String firstPart = "" + year;
|
||||||
|
String secondPart = (value != null ? " - " + value : "")
|
||||||
|
+ (unit != null ? " - " + unit : "")
|
||||||
|
+ (source != null ? " (" + source + ")" : "")
|
||||||
|
+ (assessment != null ? " (Ref. year " + assessment + ")" : "");
|
||||||
|
return firstPart + (secondPart != null && !secondPart.isEmpty() ? secondPart : "");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,13 +46,13 @@ public class CommonServiceUtils {
|
||||||
|
|
||||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(CommonServiceUtils.class);
|
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(CommonServiceUtils.class);
|
||||||
public static final String DEFAULT_LICENSE = "CC-BY-SA-4.0";
|
public static final String DEFAULT_LICENSE = "CC-BY-SA-4.0";
|
||||||
public static final String GRSF_GROUP_NAME = "grsf-group";
|
//public static final String GRSF_GROUP_NAME = "grsf-group";
|
||||||
private static final int TIME_SERIES_TAKE_LAST_VALUES = 5;
|
private static final int TIME_SERIES_TAKE_LAST_VALUES = 5;
|
||||||
private static final String REGEX_TAGS = "[^\\s\\w-_.]";
|
private static final String REGEX_TAGS = "[^\\s\\w-_.]";
|
||||||
public static final String SYSTEM_TYPE = "system:type";
|
public static final String SYSTEM_TYPE = "system:type";
|
||||||
|
|
||||||
// item url property
|
// item url property
|
||||||
public static final String ITEM_URL_FIELD = "UUID";
|
public static final String ITEM_URL_FIELD = "GRSF Record URL";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the list of licenses for stocks and fisheries
|
* Retrieve the list of licenses for stocks and fisheries
|
||||||
|
@ -76,15 +76,11 @@ public class CommonServiceUtils {
|
||||||
*/
|
*/
|
||||||
public static void validateAggregatedRecord(Common record) throws Exception {
|
public static void validateAggregatedRecord(Common record) throws Exception {
|
||||||
|
|
||||||
List<Resource<Sources>> databaseSources = record.getDatabaseSources();
|
|
||||||
List<RefersToBean> refersToList = record.getRefersTo();
|
List<RefersToBean> refersToList = record.getRefersTo();
|
||||||
String shortTitle = record.getShortTitle();
|
String shortTitle = record.getShortTitle();
|
||||||
Boolean traceabilityFlag = record.isTraceabilityFlag();
|
Boolean traceabilityFlag = record.isTraceabilityFlag();
|
||||||
Status status = record.getStatus();
|
Status status = record.getStatus();
|
||||||
|
|
||||||
if(databaseSources == null || databaseSources.isEmpty())
|
|
||||||
throw new Exception("database_sources cannot be null/empty");
|
|
||||||
|
|
||||||
if(refersToList == null || refersToList.isEmpty())
|
if(refersToList == null || refersToList.isEmpty())
|
||||||
throw new Exception("refers_to cannot be null/empty");
|
throw new Exception("refers_to cannot be null/empty");
|
||||||
|
|
||||||
|
@ -267,7 +263,7 @@ public class CommonServiceUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the record among the source group (check for grsf-group)
|
// add the record among the source group (check for grsf-group)
|
||||||
groups.add(source.equals(Sources.GRSF) ? CommonServiceUtils.GRSF_GROUP_NAME : source.getOrigName().toLowerCase());
|
//groups.add(source.equals(Sources.GRSF) ? CommonServiceUtils.GRSF_GROUP_NAME : source.getOrigName().toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -408,6 +404,7 @@ public class CommonServiceUtils {
|
||||||
/**
|
/**
|
||||||
* Validate and check sources
|
* Validate and check sources
|
||||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||||
|
* @param apiKey
|
||||||
* @param context
|
* @param context
|
||||||
* @param contextServlet
|
* @param contextServlet
|
||||||
* @param sourceInPath
|
* @param sourceInPath
|
||||||
|
@ -420,8 +417,9 @@ public class CommonServiceUtils {
|
||||||
* @param username
|
* @param username
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static void validateRecordAndMapFields(String context, ServletContext contextServlet,
|
public static void validateRecordAndMapFields(String apiKey, String context, ServletContext contextServlet,
|
||||||
Sources sourceInPath, Common record, Product_Type productType, Set<String> tags, Map<String, List<String>> customFields, Set<String> groups, List<ResourceBean> resources, String username, String futureTitle) throws Exception {
|
Sources sourceInPath, Common record, Product_Type productType, Set<String> tags, Map<String, List<String>> customFields,
|
||||||
|
Set<String> groups, List<ResourceBean> resources, String username, String futureTitle) throws Exception {
|
||||||
|
|
||||||
// validate the record if it is a GRSF one and set the record type and in manage context
|
// validate the record if it is a GRSF one and set the record type and in manage context
|
||||||
// Status field is needed only in the Manage context for GRSF records
|
// Status field is needed only in the Manage context for GRSF records
|
||||||
|
@ -452,10 +450,11 @@ public class CommonServiceUtils {
|
||||||
if(sourceInPath.equals(Sources.GRSF)){
|
if(sourceInPath.equals(Sources.GRSF)){
|
||||||
List<RefersToBean> refersTo = record.getRefersTo();
|
List<RefersToBean> refersTo = record.getRefersTo();
|
||||||
if(refersTo == null || refersTo.isEmpty())
|
if(refersTo == null || refersTo.isEmpty())
|
||||||
throw new Exception("refers_to is empty");
|
throw new Exception("refers_to is empty for a GRSF record");
|
||||||
|
|
||||||
|
// we have the id within the catalog of this record. This means that we can retrieve the record and its system:type
|
||||||
for (RefersToBean refersToBean : refersTo) {
|
for (RefersToBean refersToBean : refersTo) {
|
||||||
resources.add(new ResourceBean(refersToBean.getUrl(), "Source of item " + futureTitle + " in the catalogue has id: "
|
resources.add(new ResourceBean(refersToBean.getUrl(), getSystemTypeValue(refersToBean.getId(), apiKey, context) , "The source record has id " + refersToBean.getId() + " in the catalog", null, username, null, null));
|
||||||
+ refersToBean.getId(), "Information of a source of the item " + futureTitle, null, username, null, null));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,6 +462,24 @@ public class CommonServiceUtils {
|
||||||
customFields.put(CommonServiceUtils.SYSTEM_TYPE, Arrays.asList(sourceInPath.getOrigName()));
|
customFields.put(CommonServiceUtils.SYSTEM_TYPE, Arrays.asList(sourceInPath.getOrigName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the system:type property from a record
|
||||||
|
* @param itemIdOrName
|
||||||
|
* @param apiKey
|
||||||
|
* @return null on error
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static String getSystemTypeValue(String itemIdOrName, String apiKey, String context) throws Exception{
|
||||||
|
|
||||||
|
DataCatalogue catalog = HelperMethods.getDataCatalogueRunningInstance(context);
|
||||||
|
String systemTypeValue = catalog.getDataset(itemIdOrName, apiKey).getExtrasAsHashMap().get(SYSTEM_TYPE);
|
||||||
|
if(systemTypeValue == null || systemTypeValue.isEmpty())
|
||||||
|
throw new Exception(SYSTEM_TYPE + " property not set in record " + itemIdOrName);
|
||||||
|
else
|
||||||
|
return systemTypeValue;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Actions to execute once the dataset has been updated or created.
|
* Actions to execute once the dataset has been updated or created.
|
||||||
* @param responseBean
|
* @param responseBean
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class GrsfPublisherFisheryService {
|
||||||
List<ResourceBean> resources = record.getExtrasResources();
|
List<ResourceBean> resources = record.getExtrasResources();
|
||||||
|
|
||||||
// validate end set sources
|
// validate end set sources
|
||||||
CommonServiceUtils.validateRecordAndMapFields(context, contextServlet, sourceInPath, record, Product_Type.FISHERY, tags, customFields, groups, resources, username, futureTitle);
|
CommonServiceUtils.validateRecordAndMapFields(apiKey, context, contextServlet, sourceInPath, record, Product_Type.FISHERY, tags, customFields, groups, resources, username, futureTitle);
|
||||||
|
|
||||||
// check the license id
|
// check the license id
|
||||||
String license = null;
|
String license = null;
|
||||||
|
@ -166,14 +166,14 @@ public class GrsfPublisherFisheryService {
|
||||||
authorFullname,
|
authorFullname,
|
||||||
authorMail,
|
authorMail,
|
||||||
record.getMaintainer() == null? authorFullname : record.getMaintainer(),
|
record.getMaintainer() == null? authorFullname : record.getMaintainer(),
|
||||||
record.getMaintainerContact() == null? authorMail : record.getMaintainerContact(),
|
record.getMaintainerContact() == null? authorMail : record.getMaintainerContact(),
|
||||||
version,
|
version,
|
||||||
HelperMethods.removeHTML(record.getDescription()),
|
HelperMethods.removeHTML(record.getDescription()),
|
||||||
license,
|
license,
|
||||||
new ArrayList<String>(tags),
|
new ArrayList<String>(tags),
|
||||||
customFields,
|
customFields,
|
||||||
resources,
|
resources,
|
||||||
publicDataset);
|
publicDataset);
|
||||||
|
|
||||||
// post actions
|
// post actions
|
||||||
if(id != null){
|
if(id != null){
|
||||||
|
@ -184,7 +184,7 @@ public class GrsfPublisherFisheryService {
|
||||||
null, responseBean, catalogue, namespaces, groups, context, token, futureTitle, authorFullname,
|
null, responseBean, catalogue, namespaces, groups, context, token, futureTitle, authorFullname,
|
||||||
contextServlet, false);
|
contextServlet, false);
|
||||||
status = Status.CREATED;
|
status = Status.CREATED;
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
throw new Exception("There was an error during the product generation, sorry");
|
throw new Exception("There was an error during the product generation, sorry");
|
||||||
}
|
}
|
||||||
|
@ -220,9 +220,6 @@ public class GrsfPublisherFisheryService {
|
||||||
try{
|
try{
|
||||||
|
|
||||||
DataCatalogue catalogue = HelperMethods.getDataCatalogueRunningInstance(context);
|
DataCatalogue catalogue = HelperMethods.getDataCatalogueRunningInstance(context);
|
||||||
if(catalogue == null){
|
|
||||||
throw new Exception("There was a problem while serving your request");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cast the source to the accepted ones
|
// Cast the source to the accepted ones
|
||||||
Sources sourceInPath = Sources.onDeserialize(source);
|
Sources sourceInPath = Sources.onDeserialize(source);
|
||||||
|
@ -238,10 +235,10 @@ public class GrsfPublisherFisheryService {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check it is in the right source and it is a fishery
|
// check it is in the right source and it is a fishery
|
||||||
String grsfType = fisheryInCkan.getExtrasAsHashMap().get(Common.GRSF_TYPE_KEY);
|
String grsfTypeValue = fisheryInCkan.getExtrasAsHashMap().get(Common.GRSF_DOMAIN_KEY);
|
||||||
String groupToCheck = sourceInPath.equals(Sources.GRSF) ? CommonServiceUtils.GRSF_GROUP_NAME : sourceInPath.getOrigName().toLowerCase();
|
String systemTypeValue = fisheryInCkan.getExtrasAsHashMap().get(CommonServiceUtils.SYSTEM_TYPE);
|
||||||
|
|
||||||
if(catalogue.isDatasetInGroup(groupToCheck, recordToDelete.getId()) && Product_Type.FISHERY.getOrigName().equals(grsfType)){
|
if(systemTypeValue.equalsIgnoreCase(source) && Product_Type.FISHERY.getOrigName().equals(grsfTypeValue)){
|
||||||
|
|
||||||
logger.debug("Ok, this is a fishery of the right source, removing it");
|
logger.debug("Ok, this is a fishery of the right source, removing it");
|
||||||
boolean deleted = catalogue.deleteProduct(fisheryInCkan.getId(), apiKey, true);
|
boolean deleted = catalogue.deleteProduct(fisheryInCkan.getId(), apiKey, true);
|
||||||
|
@ -302,7 +299,7 @@ public class GrsfPublisherFisheryService {
|
||||||
for (String id : fullGroupListIds) {
|
for (String id : fullGroupListIds) {
|
||||||
CkanDataset dataset = catalogue.getDataset(id, apiKey);
|
CkanDataset dataset = catalogue.getDataset(id, apiKey);
|
||||||
if(dataset != null){
|
if(dataset != null){
|
||||||
String grsfType = dataset.getExtrasAsHashMap().get(Common.GRSF_TYPE_KEY);
|
String grsfType = dataset.getExtrasAsHashMap().get(Common.GRSF_DOMAIN_KEY);
|
||||||
if(grsfType.equals(Product_Type.FISHERY.getOrigName()))
|
if(grsfType.equals(Product_Type.FISHERY.getOrigName()))
|
||||||
datasetsIds.add(id);
|
datasetsIds.add(id);
|
||||||
}
|
}
|
||||||
|
@ -392,7 +389,7 @@ public class GrsfPublisherFisheryService {
|
||||||
if(catalogue == null){
|
if(catalogue == null){
|
||||||
throw new Exception("There was a problem while serving your request. No catalogue instance was found in this context!");
|
throw new Exception("There was a problem while serving your request. No catalogue instance was found in this context!");
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
// get already published record and modify it
|
// get already published record and modify it
|
||||||
String apiKey = catalogue.getApiKeyFromUsername(username);
|
String apiKey = catalogue.getApiKeyFromUsername(username);
|
||||||
CkanDataset recordPublished = catalogue.getDataset(catalogId, apiKey);
|
CkanDataset recordPublished = catalogue.getDataset(catalogId, apiKey);
|
||||||
|
@ -409,7 +406,7 @@ public class GrsfPublisherFisheryService {
|
||||||
throw new Exception("Sorry but there was not possible to retrieve your fullname/email!");
|
throw new Exception("Sorry but there was not possible to retrieve your fullname/email!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String organization = HelperMethods.retrieveOrgNameFromScope(context); //"grsf_admin";
|
String organization = HelperMethods.retrieveOrgNameFromScope(context); //"grsf_admin";
|
||||||
|
|
||||||
// check he/she has admin role
|
// check he/she has admin role
|
||||||
|
@ -430,6 +427,7 @@ public class GrsfPublisherFisheryService {
|
||||||
|
|
||||||
// validate end set sources
|
// validate end set sources
|
||||||
CommonServiceUtils.validateRecordAndMapFields(
|
CommonServiceUtils.validateRecordAndMapFields(
|
||||||
|
apiKey,
|
||||||
context,
|
context,
|
||||||
contextServlet,
|
contextServlet,
|
||||||
sourceInPath,
|
sourceInPath,
|
||||||
|
|
|
@ -134,6 +134,7 @@ public class GrsfPublisherStockService {
|
||||||
|
|
||||||
// validate end set sources, tags, etc
|
// validate end set sources, tags, etc
|
||||||
CommonServiceUtils.validateRecordAndMapFields(
|
CommonServiceUtils.validateRecordAndMapFields(
|
||||||
|
apiKey,
|
||||||
context,
|
context,
|
||||||
contextServlet,
|
contextServlet,
|
||||||
sourceInPath,
|
sourceInPath,
|
||||||
|
@ -248,11 +249,12 @@ public class GrsfPublisherStockService {
|
||||||
throw new Exception("There was a problem while serving your request. This product was not found");
|
throw new Exception("There was a problem while serving your request. This product was not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
// check it is in the right source and it is a fishery
|
// check it is in the right source and it is a stock
|
||||||
String grsfType = stockInCkan.getExtrasAsHashMap().get(Common.GRSF_TYPE_KEY);
|
String grsfTypeValue = stockInCkan.getExtrasAsHashMap().get(Common.GRSF_DOMAIN_KEY);
|
||||||
String groupToCheck = sourceInPath.equals(Sources.GRSF) ? CommonServiceUtils.GRSF_GROUP_NAME : sourceInPath.getOrigName().toLowerCase();
|
String systemTypeValue = stockInCkan.getExtrasAsHashMap().get(CommonServiceUtils.SYSTEM_TYPE);
|
||||||
|
|
||||||
|
if(systemTypeValue.equalsIgnoreCase(source) && Product_Type.STOCK.getOrigName().equals(grsfTypeValue)){
|
||||||
|
|
||||||
if(catalogue.isDatasetInGroup(groupToCheck, recordToDelete.getId()) && Product_Type.STOCK.getOrigName().equals(grsfType)){
|
|
||||||
logger.debug("Ok, this is a stock of the right type, removing it");
|
logger.debug("Ok, this is a stock of the right type, removing it");
|
||||||
boolean deleted = catalogue.deleteProduct(stockInCkan.getId(), apiKey, true);
|
boolean deleted = catalogue.deleteProduct(stockInCkan.getId(), apiKey, true);
|
||||||
if(deleted){
|
if(deleted){
|
||||||
|
@ -310,7 +312,7 @@ public class GrsfPublisherStockService {
|
||||||
for (String id : fullGroupListIds) {
|
for (String id : fullGroupListIds) {
|
||||||
CkanDataset dataset = catalogue.getDataset(id, catalogue.getApiKeyFromUsername(username));
|
CkanDataset dataset = catalogue.getDataset(id, catalogue.getApiKeyFromUsername(username));
|
||||||
if(dataset != null){
|
if(dataset != null){
|
||||||
String grsfType = dataset.getExtrasAsHashMap().get(Common.GRSF_TYPE_KEY);
|
String grsfType = dataset.getExtrasAsHashMap().get(Common.GRSF_DOMAIN_KEY);
|
||||||
if(grsfType.equals(Product_Type.STOCK.getOrigName()))
|
if(grsfType.equals(Product_Type.STOCK.getOrigName()))
|
||||||
datasetsIds.add(id);
|
datasetsIds.add(id);
|
||||||
}
|
}
|
||||||
|
@ -433,6 +435,7 @@ public class GrsfPublisherStockService {
|
||||||
|
|
||||||
// validate end set sources
|
// validate end set sources
|
||||||
CommonServiceUtils.validateRecordAndMapFields(
|
CommonServiceUtils.validateRecordAndMapFields(
|
||||||
|
apiKey,
|
||||||
context,
|
context,
|
||||||
contextServlet,
|
contextServlet,
|
||||||
sourceInPath,
|
sourceInPath,
|
||||||
|
|
|
@ -45,10 +45,21 @@ public class CSVHelpers {
|
||||||
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fo, "UTF-8"));
|
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fo, "UTF-8"));
|
||||||
|
|
||||||
// discover how the header will look like
|
// discover how the header will look like
|
||||||
boolean isUnitPresent = timeSeries.get(0).isUnitPresent();
|
boolean isUnitPresent = false;
|
||||||
boolean isValuePresent = true;
|
boolean isValuePresent = false;
|
||||||
boolean isSourcePresent = true;
|
boolean isSourcePresent = false;
|
||||||
boolean isAssessmentPresent = true;
|
boolean isAssessmentPresent = false;
|
||||||
|
|
||||||
|
for (TimeSeriesBean<T, T1> timeSeriesBean : timeSeries) {
|
||||||
|
if(timeSeriesBean.isSourcePresent())
|
||||||
|
isSourcePresent = true;
|
||||||
|
if(timeSeriesBean.isAssessmentPresent())
|
||||||
|
isAssessmentPresent = true;
|
||||||
|
if(timeSeriesBean.isValuePresent())
|
||||||
|
isValuePresent = true;
|
||||||
|
if(timeSeriesBean.isUnitPresent())
|
||||||
|
isUnitPresent = true;
|
||||||
|
}
|
||||||
|
|
||||||
StringBuffer headerLine = new StringBuffer();
|
StringBuffer headerLine = new StringBuffer();
|
||||||
headerLine.append(TimeSeriesBean.YEAR_FIELD);
|
headerLine.append(TimeSeriesBean.YEAR_FIELD);
|
||||||
|
@ -122,5 +133,6 @@ public class CSVHelpers {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -108,7 +108,7 @@ public abstract class HelperMethods {
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static DataCatalogue getDataCatalogueRunningInstance(String scope){
|
public static DataCatalogue getDataCatalogueRunningInstance(String scope) throws Exception{
|
||||||
|
|
||||||
if(catalogueCache.get(scope) != null)
|
if(catalogueCache.get(scope) != null)
|
||||||
return catalogueCache.get(scope);
|
return catalogueCache.get(scope);
|
||||||
|
@ -119,7 +119,7 @@ public abstract class HelperMethods {
|
||||||
return instance;
|
return instance;
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("Failed to instanciate data catalogue lib", e);
|
logger.error("Failed to instanciate data catalogue lib", e);
|
||||||
return null;
|
throw new Exception("Failed to retrieve catalogue information");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,14 +160,17 @@ public class ManageTimeSeriesThread extends Thread{
|
||||||
|
|
||||||
String recordTypeFolderName = record.getGrsfType().toLowerCase();
|
String recordTypeFolderName = record.getGrsfType().toLowerCase();
|
||||||
String productName = record.getClass().equals(StockRecord.class) ? ((StockRecord)record).getStockName() : ((FisheryRecord)record).getFisheryName();
|
String productName = record.getClass().equals(StockRecord.class) ? ((StockRecord)record).getStockName() : ((FisheryRecord)record).getFisheryName();
|
||||||
|
String semanticIdentifier = record.getClass().equals(StockRecord.class) ? ((StockRecord)record).getStockId() : ((FisheryRecord)record).getFisheryId();
|
||||||
char firstLetter = uuidKB.charAt(0);
|
char firstLetter = uuidKB.charAt(0);
|
||||||
|
|
||||||
// the whole path of the directory is going to be...
|
// the whole path of the directory is going to be...
|
||||||
String csvDirectoryForThisProduct = recordTypeFolderName + PATH_SEPARATOR + firstLetter + PATH_SEPARATOR + replaceIllegalChars(uuidKB) + PATH_SEPARATOR + CSVHelpers.CSV_EXTENSION.replace(".", "");
|
String csvDirectoryForThisProduct = recordTypeFolderName + PATH_SEPARATOR + firstLetter + PATH_SEPARATOR + replaceIllegalChars(uuidKB, "_") + PATH_SEPARATOR + CSVHelpers.CSV_EXTENSION.replace(".", "");
|
||||||
logger.debug("The path under which the time series are going to be saved is " + csvDirectoryForThisProduct);
|
logger.debug("The path under which the time series are going to be saved is " + csvDirectoryForThisProduct);
|
||||||
WorkspaceFolder csvFolder = HelperMethods.createOrGetSubFoldersByPath(catalogueFolder, csvDirectoryForThisProduct);
|
WorkspaceFolder csvFolder = HelperMethods.createOrGetSubFoldersByPath(catalogueFolder, csvDirectoryForThisProduct);
|
||||||
|
|
||||||
if(csvFolder != null){
|
if(csvFolder == null)
|
||||||
|
logger.error("Failed to create directory where csv files will be deployed in the workspace!!");
|
||||||
|
else{
|
||||||
|
|
||||||
String apiKeyUser = catalogue.getApiKeyFromUsername(username);
|
String apiKeyUser = catalogue.getApiKeyFromUsername(username);
|
||||||
|
|
||||||
|
@ -179,20 +182,17 @@ public class ManageTimeSeriesThread extends Thread{
|
||||||
try{
|
try{
|
||||||
Object f = new PropertyDescriptor(field.getName(), current).getReadMethod().invoke(record);
|
Object f = new PropertyDescriptor(field.getName(), current).getReadMethod().invoke(record);
|
||||||
if(f != null){
|
if(f != null){
|
||||||
|
|
||||||
List asList = (List)f;
|
List asList = (List)f;
|
||||||
|
|
||||||
if(!asList.isEmpty()){
|
if(!asList.isEmpty()){
|
||||||
|
|
||||||
CustomField customAnnotation = field.getAnnotation(CustomField.class);
|
CustomField customAnnotation = field.getAnnotation(CustomField.class);
|
||||||
logger.debug("A time series has been just found (from field " + customAnnotation.key() + ")");
|
logger.debug("A time series has been just found (from field " + customAnnotation.key() + ")");
|
||||||
String resourceToAttachOnCkanName = (replaceIllegalChars(productName) + "_" + customAnnotation.key()).replaceAll("\\s", "_").replaceAll("[_]+", "_") + CSVHelpers.CSV_EXTENSION;
|
String resourceToAttachOnCkanName = customAnnotation.key();
|
||||||
String resourceToAttachOnCkanDescription = productName + " - " + customAnnotation.key() + " time series";
|
String resourceToAttachOnCkanDescription = productName + " - " + resourceToAttachOnCkanName + " time series";
|
||||||
|
|
||||||
File csvFile = CSVHelpers.listToCSV(asList);
|
|
||||||
|
|
||||||
CkanResourceBase ckanResource = null;
|
CkanResourceBase ckanResource = null;
|
||||||
ExternalFile createdFileOnWorkspace = null;
|
ExternalFile createdFileOnWorkspace = null;
|
||||||
|
File csvFile = CSVHelpers.listToCSV(asList);
|
||||||
if(csvFile != null){
|
if(csvFile != null){
|
||||||
|
|
||||||
for (int i = 0; i < CHANCES; i++) {
|
for (int i = 0; i < CHANCES; i++) {
|
||||||
|
@ -205,7 +205,7 @@ public class ManageTimeSeriesThread extends Thread{
|
||||||
if(ckanResource != null){
|
if(ckanResource != null){
|
||||||
|
|
||||||
if(createdFileOnWorkspace == null)
|
if(createdFileOnWorkspace == null)
|
||||||
createdFileOnWorkspace = HelperMethods.uploadExternalFile(csvFolder, uuidKB + "_" + customAnnotation.key() + CSVHelpers.CSV_EXTENSION, resourceToAttachOnCkanDescription, csvFile);
|
createdFileOnWorkspace = HelperMethods.uploadExternalFile(csvFolder, replaceIllegalChars(semanticIdentifier, " ") + " " + customAnnotation.key() + CSVHelpers.CSV_EXTENSION, resourceToAttachOnCkanDescription, csvFile);
|
||||||
|
|
||||||
if(createdFileOnWorkspace != null){
|
if(createdFileOnWorkspace != null){
|
||||||
String publicUrlToSetOnCkan = createdFileOnWorkspace.getPublicLink(true);
|
String publicUrlToSetOnCkan = createdFileOnWorkspace.getPublicLink(true);
|
||||||
|
@ -245,8 +245,8 @@ public class ManageTimeSeriesThread extends Thread{
|
||||||
* @param productName
|
* @param productName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static String replaceIllegalChars(String productName) {
|
private static String replaceIllegalChars(String value, String replacement) {
|
||||||
return productName.replaceAll("[/\\[\\],|:*.+]", "_");
|
return value.replaceAll("[/\\[\\],|:*.+]", replacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -412,7 +412,7 @@ public class JTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
//@Test
|
||||||
public void testHierarchy(){
|
public void testHierarchy() throws Exception{
|
||||||
String name = "low-abundance";
|
String name = "low-abundance";
|
||||||
DataCatalogue catalogue = HelperMethods.getDataCatalogueRunningInstance("/gcube/devNext/NextNext");
|
DataCatalogue catalogue = HelperMethods.getDataCatalogueRunningInstance("/gcube/devNext/NextNext");
|
||||||
List<String> uniqueGroups = new ArrayList<String>();
|
List<String> uniqueGroups = new ArrayList<String>();
|
||||||
|
@ -423,7 +423,7 @@ public class JTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
//@Test
|
||||||
public void testAssociationThread() throws InterruptedException{
|
public void testAssociationThread() throws Exception{
|
||||||
String name = "low-abundance";
|
String name = "low-abundance";
|
||||||
DataCatalogue catalogue = HelperMethods.getDataCatalogueRunningInstance("/gcube/devNext/NextNext");
|
DataCatalogue catalogue = HelperMethods.getDataCatalogueRunningInstance("/gcube/devNext/NextNext");
|
||||||
AssociationToGroupThread threadGroups = new AssociationToGroupThread(Arrays.asList(name), "another-test-test-please-ignore", "grsf", "costantino_perciante", catalogue, "apiKey");
|
AssociationToGroupThread threadGroups = new AssociationToGroupThread(Arrays.asList(name), "another-test-test-please-ignore", "grsf", "costantino_perciante", catalogue, "apiKey");
|
||||||
|
|
Loading…
Reference in New Issue