minor fixes and common-library imported
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@157682 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
525341b878
commit
bd1cd054cc
|
@ -3,6 +3,9 @@
|
|||
<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="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<dependent-module archiveName="grsf-common-library-1-0-0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/grsf-common-library/grsf-common-library">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<property name="context-root" value="grsf-publisher-ws"/>
|
||||
<property name="java-output-path" value="/grsf-publisher-ws/target/classes"/>
|
||||
</wb-module>
|
||||
|
|
6
pom.xml
6
pom.xml
|
@ -48,6 +48,11 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.data-catalogue</groupId>
|
||||
<artifactId>grsf-common-library</artifactId>
|
||||
<version>1-0-0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- jsoup HTML parser library @ http://jsoup.org/ -->
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
|
@ -94,7 +99,6 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.containers</groupId>
|
||||
<!-- if your container implements Servlet API older than 3.0, use "jersey-container-servlet-core" -->
|
||||
<artifactId>jersey-container-servlet-core</artifactId>
|
||||
<version>${version.jersey}</version>
|
||||
</dependency>
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.slf4j.LoggerFactory;
|
|||
* Exception thrown when @Valid fail
|
||||
* @author Costantino Perciante at ISTI-CNR
|
||||
*/
|
||||
@Provider
|
||||
//@Provider
|
||||
public class ApplicationException implements ExceptionMapper<Exception> {
|
||||
|
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(ApplicationException.class);
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.gcube.data_catalogue.grsf_publish_ws.json.input.others;
|
|||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Sources;
|
||||
import org.gcube.datacatalogue.common.enums.Sources;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.Map;
|
|||
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.HelperMethods;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.shared.ResourceBean;
|
||||
import org.gcube.datacatalogue.common.Constants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -21,42 +22,40 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
public class Base {
|
||||
|
||||
private static final List<String> FIELDS_TO_IGNORE = Arrays.asList(
|
||||
"author", "author_contact", "stock_uri",
|
||||
"fishery_uri", "reference_year", "reporting_year", "water_area",
|
||||
"environment", "state_of_marine_resource", "system:type");
|
||||
Constants.AUTHOR, Constants.AUTHOR_CONTACT, Constants.SYSTEM_TYPE_CUSTOM_KEY);
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(Base.class);
|
||||
|
||||
@JsonProperty("catalog_id") //used on patch/update product call
|
||||
@JsonProperty(Constants.CATALOG_ID) //used on patch/update product call
|
||||
private String catalogId;
|
||||
|
||||
@JsonProperty("description")
|
||||
@JsonProperty(Constants.DESCRIPTION)
|
||||
private String description;
|
||||
|
||||
@JsonProperty("license_id")
|
||||
@JsonProperty(Constants.LICENSE_ID)
|
||||
private String license;
|
||||
|
||||
// filled automatically by the service
|
||||
@JsonProperty("author")
|
||||
@JsonProperty(Constants.AUTHOR)
|
||||
private String author;
|
||||
|
||||
// filled automatically by the service
|
||||
@JsonProperty("author_contact")
|
||||
@JsonProperty(Constants.AUTHOR_CONTACT)
|
||||
private String authorContact;
|
||||
|
||||
@JsonProperty("version")
|
||||
@JsonProperty(Constants.VERSION)
|
||||
private Long version;
|
||||
|
||||
@JsonProperty("maintainer")
|
||||
@JsonProperty(Constants.MAINTAINER)
|
||||
private String maintainer;
|
||||
|
||||
@JsonProperty("maintainer_contact")
|
||||
@JsonProperty(Constants.MAINTAINER_CONTACT)
|
||||
private String maintainerContact;
|
||||
|
||||
@JsonProperty("extras_fields")
|
||||
@JsonProperty(Constants.EXTRAS_FIELD)
|
||||
private Map<String, List<String>> extrasFields = new HashMap<>();
|
||||
|
||||
@JsonProperty("extras_resources")
|
||||
@JsonProperty(Constants.EXTRAS_RESOURCES)
|
||||
private List<ResourceBean> extrasResources = new ArrayList<ResourceBean>();
|
||||
|
||||
public Base() {
|
||||
|
|
|
@ -15,9 +15,9 @@ import org.gcube.data_catalogue.grsf_publish_ws.json.input.others.RefersToBean;
|
|||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.others.Resource;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.others.SimilarRecordBean;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.others.TimeSeriesBean;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.CommonServiceUtils;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Sources;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Status;
|
||||
import org.gcube.datacatalogue.common.Constants;
|
||||
import org.gcube.datacatalogue.common.enums.Sources;
|
||||
import org.gcube.datacatalogue.common.enums.Status;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
@ -26,83 +26,84 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
* Information that both Stock and Fishery records must contain.
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
@JsonIgnoreProperties(value = {"grsf_type", "source"})
|
||||
@JsonIgnoreProperties(value = {Constants.GRSF_TYPE_JSON_KEY})
|
||||
public class Common extends Base{
|
||||
|
||||
public static final String UUID_KB_KEY = "GRSF UUID";
|
||||
public static final String DOMAIN = "Domain";
|
||||
|
||||
// it is added in case of GRSF record
|
||||
@JsonProperty("data_owner")
|
||||
@CustomField(key="Data owner")
|
||||
@JsonProperty(Constants.DATA_OWNER_JSON_KEY)
|
||||
@CustomField(key=Constants.DATA_OWNER_CUSTOM_KEY)
|
||||
private List<String> dataOwner;
|
||||
|
||||
@JsonProperty("database_sources")
|
||||
@JsonProperty(Constants.DATABASE_SOURCES_JSON_KEY)
|
||||
@CkanResource
|
||||
@Valid
|
||||
private List<Resource<Sources>> databaseSources;
|
||||
|
||||
@JsonProperty("source_of_information")
|
||||
@JsonProperty(Constants.SOURCES_OF_INFORMATION_JSON_KEY)
|
||||
@CkanResource
|
||||
@Valid
|
||||
private List<Resource<String>> sourceOfInformation;
|
||||
|
||||
@JsonProperty("refers_to")
|
||||
@JsonProperty(Constants.REFERS_TO_JSON_KEY)
|
||||
@Valid
|
||||
private List<RefersToBean> refersTo;
|
||||
|
||||
@JsonProperty("short_name")
|
||||
@CustomField(key="Short Name")
|
||||
@JsonProperty(Constants.SHORT_NAME_JSON_KEY)
|
||||
@CustomField(key=Constants.SHORT_NAME_CUSTOM_KEY)
|
||||
private String shortName;
|
||||
|
||||
@JsonProperty("traceability_flag")
|
||||
@CustomField(key="Traceability Flag")
|
||||
@JsonProperty(Constants.TRACEABILITY_FLAG_JSON_KEY)
|
||||
@CustomField(key=Constants.TRACEABILITY_FLAG_CUSTOM_KEY)
|
||||
@Group(condition="true", groupNameOverValue="traceability-flag") // record is added to group traceability-flag if Traceability Flag is true
|
||||
private Boolean traceabilityFlag;
|
||||
|
||||
@JsonProperty("status_grsf_record")
|
||||
@CustomField(key="Status of the GRSF record")
|
||||
@JsonProperty(Constants.STATUS_OF_THE_GRSF_RECORD_JSON_KEY)
|
||||
@CustomField(key=Constants.STATUS_OF_THE_GRSF_RECORD_CUSTOM_KEY)
|
||||
@Tag
|
||||
private Status status;
|
||||
|
||||
// automatically compiled
|
||||
@CustomField(key=CommonServiceUtils.SYSTEM_TYPE)
|
||||
@CustomField(key=Constants.SYSTEM_TYPE_CUSTOM_KEY)
|
||||
private String systemType;
|
||||
|
||||
@JsonProperty("catches")
|
||||
@CustomField(key="Catches")
|
||||
@JsonProperty(Constants.CATCHES_JSON_KEY)
|
||||
@CustomField(key=Constants.CATCHES_CUSTOM_KEY)
|
||||
@TimeSeries
|
||||
@Valid
|
||||
private List<TimeSeriesBean<String, String>> catches;
|
||||
|
||||
@JsonProperty("landings")
|
||||
@CustomField(key="Landings")
|
||||
@JsonProperty(Constants.LANDINGS_JSON_KEY)
|
||||
@CustomField(key=Constants.LANDINGS_CUSTOM_KEY)
|
||||
@TimeSeries
|
||||
@Valid
|
||||
private List<TimeSeriesBean<String, String>> landings;
|
||||
|
||||
@JsonProperty("species")
|
||||
@CustomField(key="Species")
|
||||
@JsonProperty(Constants.SPECIES_JSON_KEY)
|
||||
@CustomField(key=Constants.SPECIES_CUSTOM_KEY)
|
||||
@Tag
|
||||
private List<String> species;
|
||||
|
||||
@JsonProperty("similar_grsf_records")
|
||||
@CustomField(key="Similar GRSF Records")
|
||||
@JsonProperty(Constants.SIMILAR_GRSF_RECORDS_JSON_KEY)
|
||||
@CustomField(key=Constants.SIMILAR_GRSF_RECORDS_CUSTOM_KEY)
|
||||
private List<SimilarRecordBean> similarGRSFRecords;
|
||||
|
||||
@JsonProperty("similar_source_records")
|
||||
@CustomField(key="Similar Source Records")
|
||||
@JsonProperty(Constants.SIMILAR_SOURCE_RECORDS_JSON_KEY)
|
||||
@CustomField(key=Constants.SIMILAR_SOURCE_RECORDS_CUSTOM_KEY)
|
||||
private List<SimilarRecordBean> similarSourceRecords;
|
||||
|
||||
// automatically set
|
||||
@CustomField(key=DOMAIN)
|
||||
@CustomField(key=Constants.DOMAIN_CUSTOM_KEY)
|
||||
private String domain;
|
||||
|
||||
@JsonProperty("grsf_uuid")
|
||||
@CustomField(key=UUID_KB_KEY)
|
||||
@JsonProperty(Constants.UUID_KB_JSON_KEY)
|
||||
@CustomField(key=Constants.UUID_KB_CUSTOM_KEY)
|
||||
@NotNull(message="grsf_uuid cannot be null")
|
||||
@Size(min=1, message="grsf_uuid cannot be empty")
|
||||
private String uuid;
|
||||
|
||||
@JsonProperty(Constants.MANAGEMENT_ENTITIES_JSON_KEY)
|
||||
@CustomField(key=Constants.MANAGEMENT_ENTITIES_CUSTOM_KEY)
|
||||
private List<String> managementBodyAuthorities;
|
||||
|
||||
public Common() {
|
||||
super();
|
||||
|
@ -124,6 +125,7 @@ public class Common extends Base{
|
|||
* @param similarSourceRecords
|
||||
* @param domain
|
||||
* @param uuid
|
||||
* @param managementBodyAuthorities
|
||||
*/
|
||||
public Common(List<String> dataOwner,
|
||||
List<Resource<Sources>> databaseSources,
|
||||
|
@ -134,7 +136,7 @@ public class Common extends Base{
|
|||
List<TimeSeriesBean<String, String>> landings,
|
||||
List<String> species, List<SimilarRecordBean> similarGRSFRecords,
|
||||
List<SimilarRecordBean> similarSourceRecords, String domain,
|
||||
String uuid) {
|
||||
String uuid, List<String> managementBodyAuthorities) {
|
||||
super();
|
||||
this.dataOwner = dataOwner;
|
||||
this.databaseSources = databaseSources;
|
||||
|
@ -151,6 +153,15 @@ public class Common extends Base{
|
|||
this.similarSourceRecords = similarSourceRecords;
|
||||
this.domain = domain;
|
||||
this.uuid = uuid;
|
||||
this.managementBodyAuthorities = managementBodyAuthorities;
|
||||
}
|
||||
|
||||
public List<String> getManagementBodyAuthorities() {
|
||||
return managementBodyAuthorities;
|
||||
}
|
||||
|
||||
public void setManagementBodyAuthorities(List<String> managementBodyAuthorities) {
|
||||
this.managementBodyAuthorities = managementBodyAuthorities;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
|
@ -304,6 +315,8 @@ public class Common extends Base{
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Common [dataOwner=" + dataOwner + ", databaseSources="
|
||||
|
@ -315,7 +328,8 @@ public class Common extends Base{
|
|||
+ landings + ", species=" + species + ", similarGRSFRecords="
|
||||
+ similarGRSFRecords + ", similarSourceRecords="
|
||||
+ similarSourceRecords + ", domain=" + domain + ", uuid="
|
||||
+ uuid + "]";
|
||||
+ uuid + ", managementBodyAuthorities="
|
||||
+ managementBodyAuthorities + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -8,8 +8,9 @@ import javax.validation.constraints.Size;
|
|||
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.CustomField;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.Group;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.Tag;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Fishery_Type;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Production_System_Type;
|
||||
import org.gcube.datacatalogue.common.Constants;
|
||||
import org.gcube.datacatalogue.common.enums.Fishery_Type;
|
||||
import org.gcube.datacatalogue.common.enums.Production_System_Type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
@ -21,46 +22,43 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class FisheryRecord extends Common{
|
||||
|
||||
@JsonProperty("fishery_name")
|
||||
@JsonProperty(Constants.FISHERY_NAME_JSON_KEY)
|
||||
@NotNull(message="fishery_name cannot be null")
|
||||
@Size(min=1, message="fishery_name cannot be empty")
|
||||
@CustomField(key="Fishery Name")
|
||||
@CustomField(key=Constants.FISHERY_NAME_CUSTOM_KEY)
|
||||
private String fisheryName;
|
||||
|
||||
@JsonProperty("grsf_semantic_identifier")
|
||||
@CustomField(key="GRSF Semantic identifier")
|
||||
@JsonProperty(Constants.GRSF_SEMANTIC_IDENTIFIER_JSON_KEY)
|
||||
@CustomField(key=Constants.GRSF_SEMANTIC_IDENTIFIER_CUSTOM_KEY)
|
||||
private String fisheryId;
|
||||
|
||||
@JsonProperty("fishing_area")
|
||||
@CustomField(key="Fishing area")
|
||||
@JsonProperty(Constants.FISHING_AREA_JSON_KEY)
|
||||
@CustomField(key=Constants.FISHING_AREA_CUSTOM_KEY)
|
||||
private List<String> fishingArea;
|
||||
|
||||
@JsonProperty("resources_exploited")
|
||||
@CustomField(key="Resources Exploited")
|
||||
@JsonProperty(Constants.RESOURCES_EXPLOITED_JSON_KEY)
|
||||
@CustomField(key=Constants.RESOURCES_EXPLOITED_CUSTOM_KEY)
|
||||
private List<String> resourcesExploited;
|
||||
|
||||
@JsonProperty("management_body_authorities")
|
||||
@CustomField(key="Management Body/Authority(ies)")
|
||||
private List<String> managementBodyAuthorities;
|
||||
|
||||
@JsonProperty("jurisdiction_area")
|
||||
@CustomField(key="Jurisdiction Area")
|
||||
@JsonProperty(Constants.JURISDICTION_AREA_JSON_KEY)
|
||||
@CustomField(key=Constants.JURISDICTION_AREA_CUSTOM_KEY)
|
||||
private List<String> jurisdictionArea;
|
||||
|
||||
@JsonProperty("production_system_type")
|
||||
@CustomField(key="Type of Production System")
|
||||
@JsonProperty(Constants.PRODUCTION_SYSTEM_TYPE_JSON_KEY)
|
||||
@CustomField(key=Constants.PRODUCTION_SYSTEM_TYPE_CUSTOM_KEY)
|
||||
private List<Production_System_Type> productionSystemType;
|
||||
|
||||
@JsonProperty("flag_state")
|
||||
@CustomField(key="Flag State")
|
||||
@JsonProperty(Constants.FLAG_STATE_JSON_KEY)
|
||||
@CustomField(key=Constants.FLAG_STATE_CUSTOM_KEY)
|
||||
private List<String> flagState;
|
||||
|
||||
@JsonProperty("fishing_gear")
|
||||
@CustomField(key="Fishing gear")
|
||||
@JsonProperty(Constants.FISHING_GEAR_JSON_KEY)
|
||||
@CustomField(key=Constants.FISHING_GEAR_CUSTOM_KEY)
|
||||
private List<String> fishingGear;
|
||||
|
||||
@JsonProperty("grsf_type")
|
||||
@CustomField(key="GRSF Type")
|
||||
@JsonProperty(Constants.GRSF_TYPE_JSON_KEY)
|
||||
@CustomField(key=Constants.GRSF_TYPE_CUSTOM_KEY)
|
||||
@Group
|
||||
@Tag
|
||||
private Fishery_Type type;
|
||||
|
@ -83,7 +81,6 @@ public class FisheryRecord extends Common{
|
|||
*/
|
||||
public FisheryRecord(String fisheryName, String fisheryId,
|
||||
List<String> fishingArea, List<String> resourcesExploited,
|
||||
List<String> managementBodyAuthorities,
|
||||
List<String> jurisdictionArea,
|
||||
List<Production_System_Type> productionSystemType,
|
||||
List<String> flagState, List<String> fishingGear, Fishery_Type type) {
|
||||
|
@ -92,7 +89,6 @@ public class FisheryRecord extends Common{
|
|||
this.fisheryId = fisheryId;
|
||||
this.fishingArea = fishingArea;
|
||||
this.resourcesExploited = resourcesExploited;
|
||||
this.managementBodyAuthorities = managementBodyAuthorities;
|
||||
this.jurisdictionArea = jurisdictionArea;
|
||||
this.productionSystemType = productionSystemType;
|
||||
this.flagState = flagState;
|
||||
|
@ -148,14 +144,6 @@ public class FisheryRecord extends Common{
|
|||
this.resourcesExploited = resourcesExploited;
|
||||
}
|
||||
|
||||
public List<String> getManagementBodyAuthorities() {
|
||||
return managementBodyAuthorities;
|
||||
}
|
||||
|
||||
public void setManagementBodyAuthorities(List<String> managementBodyAuthorities) {
|
||||
this.managementBodyAuthorities = managementBodyAuthorities;
|
||||
}
|
||||
|
||||
public List<Production_System_Type> getProductionSystemType() {
|
||||
return productionSystemType;
|
||||
}
|
||||
|
@ -186,7 +174,6 @@ public class FisheryRecord extends Common{
|
|||
return "FisheryRecord [fisheryName=" + fisheryName + ", fisheryId="
|
||||
+ fisheryId + ", fishingArea=" + fishingArea
|
||||
+ ", resourcesExploited=" + resourcesExploited
|
||||
+ ", managementBodyAuthorities=" + managementBodyAuthorities
|
||||
+ ", jurisdictionArea=" + jurisdictionArea
|
||||
+ ", productionSystemType=" + productionSystemType
|
||||
+ ", flagState=" + flagState + ", fishingGear=" + fishingGear
|
||||
|
|
|
@ -11,9 +11,10 @@ import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.Group;
|
|||
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.Tag;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.TimeSeries;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.others.TimeSeriesBean;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Abundance_Level;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Fishing_Pressure;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Stock_Type;
|
||||
import org.gcube.datacatalogue.common.Constants;
|
||||
import org.gcube.datacatalogue.common.enums.Abundance_Level;
|
||||
import org.gcube.datacatalogue.common.enums.Fishing_Pressure;
|
||||
import org.gcube.datacatalogue.common.enums.Stock_Type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
@ -25,78 +26,74 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class StockRecord extends Common{
|
||||
|
||||
@JsonProperty("stock_name")
|
||||
@JsonProperty(Constants.STOCK_NAME_JSON_KEY)
|
||||
@NotNull(message="stock_name cannot be null")
|
||||
@Size(min=2, message="stock_name cannot be empty")
|
||||
@CustomField(key="Stock Name")
|
||||
@CustomField(key=Constants.STOCK_NAME_CUSTOM_KEY)
|
||||
private String stockName;
|
||||
|
||||
@JsonProperty("grsf_semantic_identifier")
|
||||
@CustomField(key="GRSF Semantic identifier")
|
||||
@JsonProperty(Constants.GRSF_SEMANTIC_IDENTIFIER_JSON_KEY)
|
||||
@CustomField(key=Constants.GRSF_SEMANTIC_IDENTIFIER_CUSTOM_KEY)
|
||||
private String stockId;
|
||||
|
||||
@JsonProperty("assessment_area")
|
||||
@CustomField(key="Assessment Area")
|
||||
@JsonProperty(Constants.ASSESSMENT_AREA_JSON_KEY)
|
||||
@CustomField(key=Constants.ASSESSMENT_AREA_CUSTOM_KEY)
|
||||
private List<String> area;
|
||||
|
||||
@JsonProperty("exploiting_fishery")
|
||||
@CustomField(key="Exploiting Fishery")
|
||||
@JsonProperty(Constants.EXPLOITING_FISHERY_JSON_KEY)
|
||||
@CustomField(key=Constants.EXPLOITING_FISHERY_CUSTOM_KEY)
|
||||
private List<String> exploitingFishery;
|
||||
|
||||
@JsonProperty("management_body_authorities")
|
||||
@CustomField(key="Management Body/Authority(ies)")
|
||||
private String managementEntity;
|
||||
|
||||
@JsonProperty("assessment_methods")
|
||||
@CustomField(key="Assessment Methods")
|
||||
@JsonProperty(Constants.ASSESSMENT_METHODS_JSON_KEY)
|
||||
@CustomField(key=Constants.ASSESSMENT_METHODS_CUSTOM_KEY)
|
||||
private List<String> assessmentMethods;
|
||||
|
||||
@JsonProperty("firms_standard_abundance_level")
|
||||
@CustomField(key="Abundance Level (FIRMS Standard)")
|
||||
@JsonProperty(Constants.FIRMS_ABUNDANCE_LEVEL_JSON_KEY)
|
||||
@CustomField(key=Constants.FIRMS_ABUNDANCE_LEVEL_CUSTOM_KEY)
|
||||
@TimeSeries
|
||||
@Valid
|
||||
private List<TimeSeriesBean<Abundance_Level, Void>> abundanceLevelStandard;
|
||||
|
||||
@JsonProperty("abundance_level")
|
||||
@CustomField(key="Abundance Level")
|
||||
@JsonProperty(Constants.ABUNDANCE_LEVEL_JSON_KEY)
|
||||
@CustomField(key=Constants.ABUNDANCE_LEVEL_CUSTOM_KEY)
|
||||
@TimeSeries
|
||||
@Valid
|
||||
private List<TimeSeriesBean<String, String>> abundanceLevel;
|
||||
|
||||
@JsonProperty("firms_standard_fishing_pressure")
|
||||
@CustomField(key="Fishing Pressure (FIRMS Standard)")
|
||||
@JsonProperty(Constants.FISHING_PRESSURE_FIRMS_JSON_KEY)
|
||||
@CustomField(key=Constants.FISHING_PRESSURE_FIRMS_CUSTOM_KEY)
|
||||
@TimeSeries
|
||||
@Valid
|
||||
private List<TimeSeriesBean<Fishing_Pressure, Void>> fishingPressureStandard;
|
||||
|
||||
@JsonProperty("fishing_pressure")
|
||||
@CustomField(key="Fishing Pressure")
|
||||
@JsonProperty(Constants.FISHING_PRESSURE_JSON_KEY)
|
||||
@CustomField(key=Constants.FISHING_PRESSURE_CUSTOM_KEY)
|
||||
@TimeSeries
|
||||
@Valid
|
||||
private List<TimeSeriesBean<String, String>> fishingPressure;
|
||||
|
||||
@JsonProperty("state_and_trend_of_marine_resources")
|
||||
@CustomField(key="State and trend of Marine Resource")
|
||||
@JsonProperty(Constants.STATE_AND_TREND_MARINE_RESOURCE_JSON_KEY)
|
||||
@CustomField(key=Constants.STATE_AND_TREND_MARINE_RESOURCE_CUSTOM_KEY)
|
||||
@TimeSeries
|
||||
@Valid
|
||||
private List<TimeSeriesBean<String, Void>> narrativeState;
|
||||
|
||||
@JsonProperty("fao_categories")
|
||||
@CustomField(key="Fao Categories")
|
||||
@JsonProperty(Constants.FAO_CATEGORIES_JSON_KEY)
|
||||
@CustomField(key=Constants.FAO_CATEGORIES_CUSTOM_KEY)
|
||||
@TimeSeries
|
||||
@Valid
|
||||
private List<TimeSeriesBean<String, Void>> faoState;
|
||||
|
||||
@JsonProperty("scientific_advice")
|
||||
@CustomField(key="Scientific advice")
|
||||
@JsonProperty(Constants.SCIENTIFIC_ADVICE_JSON_KEY)
|
||||
@CustomField(key=Constants.SCIENTIFIC_ADVICE_CUSTOM_KEY)
|
||||
private List<String> scientificAdvice;
|
||||
|
||||
@JsonProperty("assessor")
|
||||
@CustomField(key="Assessor")
|
||||
@JsonProperty(Constants.ASSESSOR_JSON_KEY)
|
||||
@CustomField(key=Constants.ASSESSOR_CUSTOM_KEY)
|
||||
private String assessor;
|
||||
|
||||
@JsonProperty("grsf_type")
|
||||
@CustomField(key="GRSF Type")
|
||||
@JsonProperty(Constants.GRSF_TYPE_JSON_KEY)
|
||||
@CustomField(key=Constants.GRSF_TYPE_CUSTOM_KEY)
|
||||
@Group
|
||||
@Tag
|
||||
private Stock_Type type;
|
||||
|
@ -127,7 +124,6 @@ public class StockRecord extends Common{
|
|||
String stockId,
|
||||
List<String> area,
|
||||
List<String> exploitingFishery,
|
||||
String managementEntity,
|
||||
List<String> assessmentMethods,
|
||||
List<TimeSeriesBean<Abundance_Level, Void>> abundanceLevelStandard,
|
||||
List<TimeSeriesBean<String, String>> abundanceLevel,
|
||||
|
@ -141,7 +137,6 @@ public class StockRecord extends Common{
|
|||
this.stockId = stockId;
|
||||
this.area = area;
|
||||
this.exploitingFishery = exploitingFishery;
|
||||
this.managementEntity = managementEntity;
|
||||
this.assessmentMethods = assessmentMethods;
|
||||
this.abundanceLevelStandard = abundanceLevelStandard;
|
||||
this.abundanceLevel = abundanceLevel;
|
||||
|
@ -216,14 +211,6 @@ public class StockRecord extends Common{
|
|||
this.exploitingFishery = exploitingFishery;
|
||||
}
|
||||
|
||||
public String getManagementEntity() {
|
||||
return managementEntity;
|
||||
}
|
||||
|
||||
public void setManagementEntity(String managementEntity) {
|
||||
this.managementEntity = managementEntity;
|
||||
}
|
||||
|
||||
public List<TimeSeriesBean<Abundance_Level, Void>> getAbundanceLevelStandard() {
|
||||
return abundanceLevelStandard;
|
||||
}
|
||||
|
@ -282,7 +269,6 @@ public class StockRecord extends Common{
|
|||
public String toString() {
|
||||
return "StockRecord [stockName=" + stockName + ", stockId=" + stockId
|
||||
+ ", area=" + area + ", exploitingFishery=" + exploitingFishery
|
||||
+ ", managementEntity=" + managementEntity
|
||||
+ ", assessmentMethods=" + assessmentMethods
|
||||
+ ", abundanceLevelStandard=" + abundanceLevelStandard
|
||||
+ ", abundanceLevel=" + abundanceLevel
|
||||
|
|
|
@ -30,17 +30,17 @@ import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|||
import org.gcube.common.authorization.library.utils.Caller;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.others.DeleteRecord;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.Common;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.FisheryRecord;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.output.ResponseBean;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.output.ResponseCreationBean;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.CommonServiceUtils;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.HelperMethods;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Product_Type;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Sources;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.shared.ResourceBean;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
|
||||
import org.gcube.datacatalogue.common.Constants;
|
||||
import org.gcube.datacatalogue.common.enums.Product_Type;
|
||||
import org.gcube.datacatalogue.common.enums.Sources;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import eu.trentorise.opendata.jackan.model.CkanDataset;
|
||||
|
@ -141,7 +141,7 @@ public class GrsfPublisherFisheryService {
|
|||
// check the license id
|
||||
String license = null;
|
||||
if(record.getLicense() == null || record.getLicense().isEmpty())
|
||||
license = CommonServiceUtils.DEFAULT_LICENSE;
|
||||
license = Constants.DEFAULT_LICENSE;
|
||||
else
|
||||
if(HelperMethods.existsLicenseId(record.getLicense(), catalogue))
|
||||
license = record.getLicense();
|
||||
|
@ -248,7 +248,7 @@ public class GrsfPublisherFisheryService {
|
|||
}
|
||||
|
||||
// check it is in the right source and it is a fishery
|
||||
String type = fisheryInCkan.getExtrasAsHashMap().get(Common.DOMAIN);
|
||||
String type = fisheryInCkan.getExtrasAsHashMap().get(Constants.DOMAIN_CUSTOM_KEY);
|
||||
|
||||
if(fisheryInCkan.getOrganization().getName().equalsIgnoreCase(source) &&
|
||||
Product_Type.FISHERY.getOrigName().equals(type)){
|
||||
|
@ -312,7 +312,7 @@ public class GrsfPublisherFisheryService {
|
|||
for (String id : fullGroupListIds) {
|
||||
CkanDataset dataset = catalogue.getDataset(id, apiKey);
|
||||
if(dataset != null){
|
||||
String type = dataset.getExtrasAsHashMap().get(Common.DOMAIN);
|
||||
String type = dataset.getExtrasAsHashMap().get(Constants.DOMAIN_CUSTOM_KEY);
|
||||
if(Product_Type.FISHERY.getOrigName().equals(type))
|
||||
datasetsIds.add(id);
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ public class GrsfPublisherFisheryService {
|
|||
// check the license id
|
||||
String license = null;
|
||||
if(record.getLicense() == null || record.getLicense().isEmpty())
|
||||
license = CommonServiceUtils.DEFAULT_LICENSE;
|
||||
license = Constants.DEFAULT_LICENSE;
|
||||
else
|
||||
if(HelperMethods.existsLicenseId(record.getLicense(), catalogue))
|
||||
license = record.getLicense();
|
||||
|
@ -468,7 +468,7 @@ public class GrsfPublisherFisheryService {
|
|||
boolean publicDataset = context.equals((String)contextServlet.getInitParameter(HelperMethods.PUBLIC_CONTEX_KEY));
|
||||
|
||||
// add the SYSTEM_TYPE
|
||||
customFields.put(CommonServiceUtils.SYSTEM_TYPE, Arrays.asList(sourceInPath.getOrigName()));
|
||||
customFields.put(Constants.SYSTEM_TYPE_CUSTOM_KEY, Arrays.asList(sourceInPath.getOrigName()));
|
||||
|
||||
// convert extras' keys to keys with namespace
|
||||
Map<String, String> namespaces = HelperMethods.getFieldToFieldNameSpaceMapping(HelperMethods.GENERIC_RESOURCE_NAME_MAP_KEY_NAMESPACES_FISHERY);
|
||||
|
@ -477,9 +477,11 @@ public class GrsfPublisherFisheryService {
|
|||
throw new Exception("Failed to retrieve the namespaces for the key fields!");
|
||||
|
||||
// retrieve the url
|
||||
String modifiedUUIDKey = namespaces.containsKey(CommonServiceUtils.ITEM_URL_FIELD) ? namespaces.get(CommonServiceUtils.ITEM_URL_FIELD) : CommonServiceUtils.ITEM_URL_FIELD;
|
||||
String modifiedUUIDKey = namespaces.containsKey(Constants.ITEM_URL_FIELD) ?
|
||||
namespaces.get(Constants.ITEM_URL_FIELD) :
|
||||
Constants.ITEM_URL_FIELD;
|
||||
String itemUrl = recordPublished.getExtrasAsHashMap().get(modifiedUUIDKey);
|
||||
customFields.put(CommonServiceUtils.ITEM_URL_FIELD, Arrays.asList(itemUrl));
|
||||
customFields.put(Constants.ITEM_URL_FIELD, Arrays.asList(itemUrl));
|
||||
|
||||
// replace fields
|
||||
customFields = HelperMethods.replaceFieldsKey(customFields, namespaces, !sourceInPath.equals(Sources.GRSF));
|
||||
|
|
|
@ -30,17 +30,17 @@ import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|||
import org.gcube.common.authorization.library.utils.Caller;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.others.DeleteRecord;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.Common;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.StockRecord;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.output.ResponseBean;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.output.ResponseCreationBean;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.CommonServiceUtils;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.HelperMethods;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Product_Type;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Sources;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.shared.ResourceBean;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
|
||||
import org.gcube.datacatalogue.common.Constants;
|
||||
import org.gcube.datacatalogue.common.enums.Product_Type;
|
||||
import org.gcube.datacatalogue.common.enums.Sources;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import eu.trentorise.opendata.jackan.model.CkanDataset;
|
||||
|
@ -155,7 +155,7 @@ public class GrsfPublisherStockService {
|
|||
// check the license id
|
||||
String license = null;
|
||||
if(record.getLicense() == null || record.getLicense().isEmpty())
|
||||
license = CommonServiceUtils.DEFAULT_LICENSE;
|
||||
license = Constants.DEFAULT_LICENSE;
|
||||
else
|
||||
if(HelperMethods.existsLicenseId(record.getLicense(), catalogue))
|
||||
license = record.getLicense();
|
||||
|
@ -262,7 +262,7 @@ public class GrsfPublisherStockService {
|
|||
}
|
||||
|
||||
// check it is in the right source and it is a stock
|
||||
String type = stockInCkan.getExtrasAsHashMap().get(Common.DOMAIN);
|
||||
String type = stockInCkan.getExtrasAsHashMap().get(Constants.DOMAIN_CUSTOM_KEY);
|
||||
if(stockInCkan.getOrganization().getName().equalsIgnoreCase(source) &&
|
||||
Product_Type.STOCK.getOrigName().equals(type)){
|
||||
|
||||
|
@ -324,7 +324,7 @@ public class GrsfPublisherStockService {
|
|||
CkanDataset dataset = catalogue.getDataset(id, catalogue.getApiKeyFromUsername(username));
|
||||
if(dataset != null){
|
||||
|
||||
String type = dataset.getExtrasAsHashMap().get(Common.DOMAIN);
|
||||
String type = dataset.getExtrasAsHashMap().get(Constants.DOMAIN_CUSTOM_KEY);
|
||||
if(Product_Type.STOCK.getOrigName().equals(type))
|
||||
datasetsIds.add(id);
|
||||
}
|
||||
|
@ -463,7 +463,7 @@ public class GrsfPublisherStockService {
|
|||
// check the license id
|
||||
String license = null;
|
||||
if(record.getLicense() == null || record.getLicense().isEmpty())
|
||||
license = CommonServiceUtils.DEFAULT_LICENSE;
|
||||
license = Constants.DEFAULT_LICENSE;
|
||||
else
|
||||
if(HelperMethods.existsLicenseId(record.getLicense(), catalogue))
|
||||
license = record.getLicense();
|
||||
|
@ -475,7 +475,7 @@ public class GrsfPublisherStockService {
|
|||
boolean publicDataset = context.equals((String)contextServlet.getInitParameter(HelperMethods.PUBLIC_CONTEX_KEY));
|
||||
|
||||
// add the SYSTEM_TYPE
|
||||
customFields.put(CommonServiceUtils.SYSTEM_TYPE, Arrays.asList(sourceInPath.getOrigName()));
|
||||
customFields.put(Constants.SYSTEM_TYPE_CUSTOM_KEY, Arrays.asList(sourceInPath.getOrigName()));
|
||||
|
||||
// convert extras' keys to keys with namespace
|
||||
Map<String, String> namespaces = HelperMethods.getFieldToFieldNameSpaceMapping(HelperMethods.GENERIC_RESOURCE_NAME_MAP_KEY_NAMESPACES_STOCK);
|
||||
|
@ -484,9 +484,9 @@ public class GrsfPublisherStockService {
|
|||
throw new Exception("Failed to retrieve the namespaces for the key fields!");
|
||||
|
||||
// retrieve the url
|
||||
String modifiedUUIDKey = namespaces.containsKey(CommonServiceUtils.ITEM_URL_FIELD) ? namespaces.get(CommonServiceUtils.ITEM_URL_FIELD) : CommonServiceUtils.ITEM_URL_FIELD;
|
||||
String modifiedUUIDKey = namespaces.containsKey(Constants.ITEM_URL_FIELD) ? namespaces.get(Constants.ITEM_URL_FIELD) : Constants.ITEM_URL_FIELD;
|
||||
String itemUrl = recordPublished.getExtrasAsHashMap().get(modifiedUUIDKey);
|
||||
customFields.put(CommonServiceUtils.ITEM_URL_FIELD, Arrays.asList(itemUrl));
|
||||
customFields.put(Constants.ITEM_URL_FIELD, Arrays.asList(itemUrl));
|
||||
|
||||
// replace fields
|
||||
customFields = HelperMethods.replaceFieldsKey(customFields, namespaces,!sourceInPath.equals(Sources.GRSF));
|
||||
|
|
|
@ -26,15 +26,16 @@ import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.Common;
|
|||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.FisheryRecord;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.StockRecord;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.output.ResponseCreationBean;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Product_Type;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Sources;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Status;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.threads.AssociationToGroupThread;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.threads.ManageTimeSeriesThread;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.threads.WritePostCatalogueManagerThread;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.shared.ResourceBean;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
|
||||
import org.gcube.datacatalogue.common.Constants;
|
||||
import org.gcube.datacatalogue.common.enums.Product_Type;
|
||||
import org.gcube.datacatalogue.common.enums.Sources;
|
||||
import org.gcube.datacatalogue.common.enums.Status;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -48,16 +49,6 @@ import eu.trentorise.opendata.jackan.model.CkanDataset;
|
|||
public class CommonServiceUtils {
|
||||
|
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(CommonServiceUtils.class);
|
||||
public static final String DEFAULT_LICENSE = "CC-BY-SA-4.0";
|
||||
private static final int TIME_SERIES_TAKE_LAST_VALUES = 5;
|
||||
private static final String REGEX_TAGS = "[^\\s\\w-_.]";
|
||||
public static final String SYSTEM_TYPE = "system:type";
|
||||
private static final String SYSTEM_TYPE_FOR_SOURCES = "Legacy";
|
||||
private static final String GRSF_DATABASE_SOURCE = "Database Source";
|
||||
|
||||
// item url property
|
||||
public static final String ITEM_URL_FIELD = "GRSF Record URL";
|
||||
private static final String GRSF_ADMIN_ORGANIZATION_NAME = "grsf_admin";
|
||||
|
||||
/**
|
||||
* Retrieve the list of licenses for stocks and fisheries
|
||||
|
@ -190,22 +181,22 @@ public class CommonServiceUtils {
|
|||
|
||||
// check if it is a time series, in this take the last X elements
|
||||
if(asList.get(0).getClass().equals(TimeSeriesBean.class)){
|
||||
elementsToConsider = Math.min(elementsToConsider, TIME_SERIES_TAKE_LAST_VALUES);
|
||||
elementsToConsider = Math.min(elementsToConsider, Constants.TIME_SERIES_TAKE_LAST_VALUES);
|
||||
for (int i = (asList.size() - elementsToConsider); i < asList.size(); i++) {
|
||||
String finalTag = asList.get(i).toString().trim().replaceAll(REGEX_TAGS, "");
|
||||
String finalTag = asList.get(i).toString().trim().replaceAll(Constants.REGEX_TAGS, "");
|
||||
tags.add(finalTag);
|
||||
}
|
||||
}else{
|
||||
// else add all the available elements
|
||||
for (int i = 0; i < elementsToConsider; i++) {
|
||||
String finalTag = asList.get(i).toString().trim().replaceAll(REGEX_TAGS, "");
|
||||
String finalTag = asList.get(i).toString().trim().replaceAll(Constants.REGEX_TAGS, "");
|
||||
tags.add(finalTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
logger.debug("The object annotated with @Tag is a simple one. Adding ... ");
|
||||
String finalTag = f.toString().trim().replaceAll(REGEX_TAGS, "");
|
||||
String finalTag = f.toString().trim().replaceAll(Constants.REGEX_TAGS, "");
|
||||
logger.debug(finalTag);
|
||||
tags.add(finalTag);
|
||||
}
|
||||
|
@ -293,7 +284,7 @@ public class CommonServiceUtils {
|
|||
|
||||
// check if it is a time series, in this case take the last X elements
|
||||
if(asList.get(0).getClass().equals(TimeSeriesBean.class)){
|
||||
elementsToConsider = Math.min(elementsToConsider, TIME_SERIES_TAKE_LAST_VALUES);
|
||||
elementsToConsider = Math.min(elementsToConsider, Constants.TIME_SERIES_TAKE_LAST_VALUES);
|
||||
|
||||
for (int i = (asList.size() - elementsToConsider); i < asList.size(); i++) {
|
||||
// trim and remove html
|
||||
|
@ -301,21 +292,6 @@ public class CommonServiceUtils {
|
|||
valuesForKey.add(clean);
|
||||
}
|
||||
}
|
||||
// }else if(asList.get(0).getClass().equals(SimilarRecordBean.class)){
|
||||
//
|
||||
// for (int i = 0; i < asList.size(); i++) {
|
||||
// SimilarRecordBean similarRecord = (SimilarRecordBean) asList.get(i);
|
||||
// JSONObject obj = new JSONObject();
|
||||
// if(similarRecord.getId() != null)
|
||||
// obj.put("id", Common.cleanSemanticId(similarRecord.getId()));
|
||||
// if(similarRecord.getDescription() != null)
|
||||
// obj.put("description", similarRecord.getDescription());
|
||||
// if(similarRecord.getUrl() != null)
|
||||
// obj.put("url", similarRecord.getUrl() );
|
||||
// valuesForKey.add(obj.toJSONString());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
else
|
||||
for (int i = 0; i < elementsToConsider; i++) {
|
||||
String clean = HelperMethods.removeHTML(asList.get(i).toString().trim());
|
||||
|
@ -449,7 +425,7 @@ public class CommonServiceUtils {
|
|||
}
|
||||
|
||||
// create the Database Source information
|
||||
customFields.put(GRSF_DATABASE_SOURCE, Arrays.asList(databaseSource.trim()));
|
||||
customFields.put(Constants.GRSF_DATABASE_SOURCE, Arrays.asList(databaseSource.trim()));
|
||||
|
||||
// append to groups: we need to add this record to the correspondent group of the sources
|
||||
addRecordToGroupSources(groups, sourcesList, productType, sourceInPath);
|
||||
|
@ -470,7 +446,7 @@ public class CommonServiceUtils {
|
|||
// set system type (it is equal to the GRSF Type for GRSF records, "Source" for source records)
|
||||
record.setSystemType(sourceInPath.equals(Sources.GRSF) ?
|
||||
productType.equals(Product_Type.FISHERY) ? ((FisheryRecord)record).getType().getOrigName() : ((StockRecord)record).getType().getOrigName()
|
||||
: SYSTEM_TYPE_FOR_SOURCES);
|
||||
: Constants.SYSTEM_TYPE_FOR_SOURCES_VALUE);
|
||||
|
||||
}
|
||||
|
||||
|
@ -506,9 +482,9 @@ public class CommonServiceUtils {
|
|||
CkanDataset dataset = catalog.getDataset(itemIdOrName, apiKey);
|
||||
if(dataset == null)
|
||||
throw new Exception("Unable to find record with id or name " + itemIdOrName);
|
||||
String systemTypeValue = dataset.getExtrasAsHashMap().get(SYSTEM_TYPE);
|
||||
String systemTypeValue = dataset.getExtrasAsHashMap().get(Constants.SYSTEM_TYPE_CUSTOM_KEY);
|
||||
if(systemTypeValue == null || systemTypeValue.isEmpty())
|
||||
throw new Exception(SYSTEM_TYPE + " property not set in record " + itemIdOrName);
|
||||
throw new Exception(Constants.SYSTEM_TYPE_CUSTOM_KEY + " property not set in record " + itemIdOrName);
|
||||
else
|
||||
return systemTypeValue;
|
||||
|
||||
|
@ -538,7 +514,7 @@ public class CommonServiceUtils {
|
|||
if(!isUpdated){
|
||||
itemUrl = catalogue.getUnencryptedUrlFromDatasetIdOrName(futureName);
|
||||
Map<String, List<String>> addField = new HashMap<String, List<String>>();
|
||||
String modifiedUUIDKey = namespaces.containsKey(CommonServiceUtils.ITEM_URL_FIELD) ? namespaces.get(CommonServiceUtils.ITEM_URL_FIELD) : CommonServiceUtils.ITEM_URL_FIELD;
|
||||
String modifiedUUIDKey = namespaces.containsKey(Constants.ITEM_URL_FIELD) ? namespaces.get(Constants.ITEM_URL_FIELD) : Constants.ITEM_URL_FIELD;
|
||||
addField.put(modifiedUUIDKey, Arrays.asList(itemUrl));
|
||||
catalogue.patchProductCustomFields(datasetId, apiKey, addField);
|
||||
description += ", Record URL: " + itemUrl;
|
||||
|
@ -613,8 +589,8 @@ public class CommonServiceUtils {
|
|||
* @return
|
||||
*/
|
||||
public static String evaluateOrganization(String organization, Sources sourceInPath) {
|
||||
if(sourceInPath.equals(Sources.GRSF) && organization.equals(GRSF_ADMIN_ORGANIZATION_NAME))
|
||||
return GRSF_ADMIN_ORGANIZATION_NAME;
|
||||
if(sourceInPath.equals(Sources.GRSF) && organization.equals(Constants.GRSF_ADMIN_ORGANIZATION_NAME))
|
||||
return Constants.GRSF_ADMIN_ORGANIZATION_NAME;
|
||||
else
|
||||
return sourceInPath.getOrigName().toLowerCase();
|
||||
}
|
||||
|
|
|
@ -26,10 +26,10 @@ import org.gcube.common.homelibrary.home.workspace.exceptions.ItemAlreadyExistEx
|
|||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
||||
import org.gcube.common.resources.gcore.utils.XPathHelper;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.cache.CacheImpl;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.cache.CacheInterface;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueFactory;
|
||||
import org.gcube.datacatalogue.common.caches.CacheImpl;
|
||||
import org.gcube.datacatalogue.common.caches.CacheInterface;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.Query;
|
||||
import org.gcube.resources.discovery.client.queries.impl.QueryBox;
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.utils.cache;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Cache implementation.
|
||||
* @author Costantino Perciante at ISTI-CNR
|
||||
* (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public class CacheImpl <K, V> implements CacheInterface<K, V> {
|
||||
|
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(CacheImpl.class);
|
||||
|
||||
/**
|
||||
* The hashmap
|
||||
*/
|
||||
private Map<K, CacheValueBean<V>> cache;
|
||||
|
||||
/**
|
||||
* Cache entry expires after EXPIRED_AFTER ms
|
||||
*/
|
||||
private long ttl;
|
||||
|
||||
public CacheImpl(long timeout){
|
||||
ttl = timeout;
|
||||
cache = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get(K key) {
|
||||
|
||||
if(cache.containsKey(key)){
|
||||
CacheValueBean<V> bean = cache.get(key);
|
||||
if(CacheUtilities.expired(bean.getTTL(), ttl)){
|
||||
cache.remove(key);
|
||||
logger.debug("Amount of space in the infrastructure used expired for key " + key + ", returning null");
|
||||
}
|
||||
else
|
||||
return bean.getValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean insert(K key, V obj) {
|
||||
CacheValueBean<V> newBean = new CacheValueBean<V>(obj, System.currentTimeMillis());
|
||||
cache.put(key, newBean);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.utils.cache;
|
||||
|
||||
/**
|
||||
* Generic interface
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
* @param <K> the key type
|
||||
* @param <V> the value type
|
||||
*/
|
||||
public interface CacheInterface <K,V>{
|
||||
|
||||
/**
|
||||
* Retrieve a value V from the cache
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public V get(K key);
|
||||
|
||||
/**
|
||||
* Insert an object V with key K into the cache
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public boolean insert(K key, V value);
|
||||
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.utils.cache;
|
||||
|
||||
/**
|
||||
* Utility functions for caches
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public class CacheUtilities {
|
||||
/**
|
||||
* Check if the bean expired
|
||||
* @param beanTimestamp
|
||||
* @param ttl
|
||||
* @return <true> if expired, <false> otherwise
|
||||
*/
|
||||
public static boolean expired(long beanTimestamp, long ttl){
|
||||
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
if((beanTimestamp + ttl) <= currentTime)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.utils.cache;
|
||||
|
||||
/**
|
||||
* A bean object to be used as value within the cache. It contains a TTL value too.
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
* @param <V> the value type
|
||||
*/
|
||||
public class CacheValueBean <V>{
|
||||
|
||||
private V value;
|
||||
private long TTL;
|
||||
|
||||
/**
|
||||
* @param value
|
||||
* @param TTL
|
||||
*/
|
||||
public CacheValueBean(V value, long ttl) {
|
||||
super();
|
||||
this.value = value;
|
||||
this.TTL = ttl;
|
||||
}
|
||||
public V getValue() {
|
||||
return value;
|
||||
}
|
||||
public void setValue(V value) {
|
||||
this.value = value;
|
||||
}
|
||||
public long getTTL() {
|
||||
return TTL;
|
||||
}
|
||||
public void setTTL(long ttl) {
|
||||
this.TTL = ttl;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CacheValueBean [value=" + value + ", TTL=" + TTL + "]";
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.utils.groups;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Abundance_Level for Stock records
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public enum Abundance_Level {
|
||||
|
||||
Intermediate_Abundance("Intermediate abundance"),
|
||||
Low_Abundance("Low abundance"),
|
||||
Uncertain_Not_Assessed("Uncertain/Not assessed"),
|
||||
Not_applicable("Not applicable"),
|
||||
Pre_exploitation_Or_High_Abundance("Pre-exploitation biomass or high abundance"),
|
||||
Depleted("Depleted"),
|
||||
Virgin_Or_High_Abundance("Virgin or High abundance");
|
||||
|
||||
private String subGroupNameOrig;
|
||||
|
||||
private Abundance_Level(String origName) {
|
||||
this.subGroupNameOrig = origName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original name
|
||||
* @return
|
||||
*/
|
||||
public String getOrigName(){
|
||||
return subGroupNameOrig;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String onSerialize(){
|
||||
return subGroupNameOrig.replaceAll("[^A-Za-z]", " ").toLowerCase();
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static Abundance_Level onDeserialize(String abundanceString) {
|
||||
if(abundanceString != null) {
|
||||
for (Abundance_Level abundanceValue : Abundance_Level.values()) {
|
||||
if(abundanceValue.getOrigName().replaceAll("[^A-Za-z]", " ").equalsIgnoreCase(abundanceString.trim().replaceAll("[^A-Za-z]", " ")))
|
||||
return abundanceValue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getOrigName();
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.utils.groups;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
|
||||
/**
|
||||
* Exploitation_Rate for Stock records
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public enum Exploitation_Rate {
|
||||
|
||||
Not_Applicable("Not applicable"),
|
||||
Moderate_Fishing_Mortality("Moderate fishing mortality"),
|
||||
High_Fishing_Mortality("High fishing mortality"),
|
||||
No_Or_Low_Fishing_Mortality("No or low fishing mortality"),
|
||||
Uncertain_Not_assessed("Uncertain/Not assessed");
|
||||
|
||||
private String subGroupNameOrig;
|
||||
|
||||
private Exploitation_Rate(String origName) {
|
||||
this.subGroupNameOrig = origName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original name
|
||||
* @return
|
||||
*/
|
||||
public String getOrigName(){
|
||||
return subGroupNameOrig;
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static Exploitation_Rate onDeserialize(String exploitationString) {
|
||||
if(exploitationString != null) {
|
||||
for (Exploitation_Rate exploitationValue : Exploitation_Rate.values()) {
|
||||
if(exploitationValue.getOrigName().replaceAll("[^A-Za-z]", " ").equalsIgnoreCase(exploitationString.trim().replaceAll("[^A-Za-z]", " ")))
|
||||
return exploitationValue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getOrigName();
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.utils.groups;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
|
||||
/**
|
||||
* Type for Fishery records
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public enum Fishery_Type {
|
||||
|
||||
Fishing_Activity("Fishing Activity"), // for fishery
|
||||
Fishing_Description("Fishing Description"); // for fishery
|
||||
|
||||
private String subGroupNameOrig;
|
||||
|
||||
private Fishery_Type(String origName) {
|
||||
this.subGroupNameOrig = origName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original name
|
||||
* @return
|
||||
*/
|
||||
public String getOrigName(){
|
||||
return subGroupNameOrig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the json value
|
||||
* @return
|
||||
*/
|
||||
@JsonValue
|
||||
public String onSerialize(){
|
||||
return subGroupNameOrig.toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get back an enum from json string
|
||||
* @param typeString
|
||||
* @return
|
||||
*/
|
||||
@JsonCreator
|
||||
public static Fishery_Type onDeserialize(String typeString) {
|
||||
if(typeString != null) {
|
||||
for(Fishery_Type type : Fishery_Type.values()) {
|
||||
if(type.getOrigName().equalsIgnoreCase(typeString.trim()))
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by reflection
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getOrigName();
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.utils.groups;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
|
||||
|
||||
/**
|
||||
* Fishing_Pressure for Stock records
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public enum Fishing_Pressure {
|
||||
|
||||
Not_Applicable("Not applicable"),
|
||||
Moderate_Fishing_Mortality("Moderate fishing mortality"),
|
||||
High_Fishing_Mortality("High fishing mortality"),
|
||||
No_Or_Low_Fishing_Mortality("No or low fishing mortality"),
|
||||
Uncertain_Not_assessed("Uncertain/Not assessed");
|
||||
|
||||
private String subGroupNameOrig;
|
||||
|
||||
private Fishing_Pressure(String origName) {
|
||||
this.subGroupNameOrig = origName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original name
|
||||
* @return
|
||||
*/
|
||||
public String getOrigName(){
|
||||
return subGroupNameOrig;
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static Fishing_Pressure onDeserialize(String fishing_Pressure) {
|
||||
if(fishing_Pressure != null) {
|
||||
for (Fishing_Pressure fishingPressure : Fishing_Pressure.values()) {
|
||||
if(fishingPressure.getOrigName().replaceAll("[^A-Za-z]", " ").equalsIgnoreCase(fishing_Pressure.trim().replaceAll("[^A-Za-z]", " ")))
|
||||
return fishingPressure;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getOrigName();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.utils.groups;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* The type of product, i.e. Stock or Fishery
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public enum Product_Type {
|
||||
|
||||
FISHERY("Fishery"),
|
||||
STOCK("Stock");
|
||||
|
||||
private String subGroupNameOrig;
|
||||
|
||||
private Product_Type(String origName) {
|
||||
this.subGroupNameOrig = origName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original name
|
||||
* @return
|
||||
*/
|
||||
public String getOrigName(){
|
||||
return subGroupNameOrig;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String onSerialize(){
|
||||
return subGroupNameOrig.toLowerCase();
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static Product_Type onDeserialize(String recordTypeString) {
|
||||
if(recordTypeString != null) {
|
||||
for(Product_Type source : Product_Type.values()) {
|
||||
if (source.toString().equalsIgnoreCase(recordTypeString.trim()))
|
||||
return source;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getOrigName();
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.utils.groups;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Production_System_Type for Fishery records
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public enum Production_System_Type {
|
||||
|
||||
Subsistence("Subsistence"),
|
||||
Recreational("Recreational"),
|
||||
Commercial("Commercial"),
|
||||
Artisanal("Artisanal"),
|
||||
Semi_Industrial("Semi-industrial"),
|
||||
Industrial("Industrial"),
|
||||
Exploratory_fishery("Exploratory fishery"),
|
||||
Unspecified("Unspecified");
|
||||
|
||||
private String subGroupNameOrig;
|
||||
|
||||
private Production_System_Type(String origName) {
|
||||
this.subGroupNameOrig = origName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original name
|
||||
* @return
|
||||
*/
|
||||
public String getOrigName(){
|
||||
return subGroupNameOrig;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String onSerialize(){
|
||||
return subGroupNameOrig.replaceAll("[^A-Za-z]", " ").toLowerCase();
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static Production_System_Type onDeserialize(String productionString) {
|
||||
if(productionString != null) {
|
||||
for (Production_System_Type productionValue : Production_System_Type.values()) {
|
||||
if(productionValue.getOrigName().replaceAll("[^A-Za-z]", " ").equalsIgnoreCase(productionString.trim().replaceAll("[^A-Za-z]", " ")))
|
||||
return productionValue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getOrigName();
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.utils.groups;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Source Group and sub groups (for both Stock and Fishery) -> look at "Database Sources"
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public enum Sources {
|
||||
|
||||
FIRMS("FIRMS"),
|
||||
RAM("RAM"),
|
||||
FISHSOURCE("FishSource"),
|
||||
GRSF("GRSF");
|
||||
|
||||
private String subGroupNameOrig;
|
||||
|
||||
private Sources(String origName) {
|
||||
this.subGroupNameOrig = origName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original name
|
||||
* @return
|
||||
*/
|
||||
public String getOrigName(){
|
||||
return subGroupNameOrig;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String onSerialize(){
|
||||
return subGroupNameOrig.toLowerCase();
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static Sources onDeserialize(String sourceString) {
|
||||
if(sourceString != null) {
|
||||
for(Sources source : Sources.values()) {
|
||||
if (source.toString().equalsIgnoreCase(sourceString.trim()))
|
||||
return source;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getOrigName();
|
||||
}
|
||||
|
||||
public static String getAsList(){
|
||||
return "[" + Arrays.asList(
|
||||
FIRMS.toString().toLowerCase(),
|
||||
RAM.toString().toLowerCase(),
|
||||
FISHSOURCE.toString().toLowerCase(),
|
||||
GRSF.toString().toLowerCase()) + "]";
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.utils.groups;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Status Group and sub groups (for both Stock and Fishery, only Aggregated records)
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public enum Status {
|
||||
|
||||
Pending("Pending"),
|
||||
Approved("Approved"),
|
||||
Rejected("Rejected"),
|
||||
Archived("Archived"),
|
||||
Hidden("Hidden"),
|
||||
Merged("Merged");
|
||||
|
||||
private String origName;
|
||||
|
||||
private Status(String origName) {
|
||||
this.origName = origName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original name
|
||||
* @return
|
||||
*/
|
||||
public String getOrigName(){
|
||||
return origName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the json value
|
||||
* @return
|
||||
*/
|
||||
@JsonValue
|
||||
public String onSerialize(){
|
||||
return origName.toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get back an enum from json string
|
||||
* @param statusString
|
||||
* @return
|
||||
*/
|
||||
@JsonCreator
|
||||
public static Status onDeserialize(String statusString) {
|
||||
if(statusString != null) {
|
||||
for(Status status : Status.values()) {
|
||||
if (status.toString().equalsIgnoreCase(statusString.trim()))
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by reflection
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getOrigName();
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.utils.groups;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Stock types
|
||||
* @author Costantino Perciante at ISTI-CNR
|
||||
* (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public enum Stock_Type {
|
||||
|
||||
Assessment_Unit("Assessment Unit"),
|
||||
Marine_Resource("Marine Resource");
|
||||
|
||||
private String subGroupNameOrig;
|
||||
|
||||
private Stock_Type(String origName) {
|
||||
this.subGroupNameOrig = origName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original name
|
||||
* @return
|
||||
*/
|
||||
public String getOrigName(){
|
||||
return subGroupNameOrig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the json value
|
||||
* @return
|
||||
*/
|
||||
@JsonValue
|
||||
public String onSerialize(){
|
||||
return subGroupNameOrig.toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get back an enum from json string
|
||||
* @param typeString
|
||||
* @return
|
||||
*/
|
||||
@JsonCreator
|
||||
public static Stock_Type onDeserialize(String typeString) {
|
||||
if(typeString != null) {
|
||||
for(Stock_Type type : Stock_Type.values()) {
|
||||
if(type.getOrigName().equalsIgnoreCase(typeString.trim().toLowerCase()) || type.getOrigName().toLowerCase().contains(typeString.trim().toLowerCase()))
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by reflection
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getOrigName();
|
||||
}
|
||||
|
||||
}
|
|
@ -27,9 +27,9 @@ import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.FisheryRecord;
|
|||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.StockRecord;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.CSVUtils;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.HelperMethods;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.cache.CacheImpl;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.cache.CacheInterface;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
|
||||
import org.gcube.datacatalogue.common.caches.CacheImpl;
|
||||
import org.gcube.datacatalogue.common.caches.CacheInterface;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import eu.trentorise.opendata.jackan.model.CkanResourceBase;
|
||||
|
|
|
@ -13,10 +13,10 @@ import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.FisheryRecord;
|
|||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.StockRecord;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.services.GrsfPublisherFisheryService;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.services.GrsfPublisherStockService;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Fishery_Type;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Sources;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Status;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Stock_Type;
|
||||
import org.gcube.datacatalogue.common.enums.Fishery_Type;
|
||||
import org.gcube.datacatalogue.common.enums.Sources;
|
||||
import org.gcube.datacatalogue.common.enums.Status;
|
||||
import org.gcube.datacatalogue.common.enums.Stock_Type;
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
import org.glassfish.jersey.test.JerseyTest;
|
||||
import org.glassfish.jersey.test.TestProperties;
|
||||
|
|
|
@ -34,13 +34,13 @@ import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.FisheryRecord;
|
|||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.StockRecord;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.CSVUtils;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.HelperMethods;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Abundance_Level;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Fishery_Type;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Sources;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Status;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.threads.AssociationToGroupThread;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueFactory;
|
||||
import org.gcube.datacatalogue.common.enums.Abundance_Level;
|
||||
import org.gcube.datacatalogue.common.enums.Fishery_Type;
|
||||
import org.gcube.datacatalogue.common.enums.Sources;
|
||||
import org.gcube.datacatalogue.common.enums.Status;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
|
Loading…
Reference in New Issue