separated types for stock and fishery. The main thread will wait for the groups association thread to finish before starting the one of the files
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@134895 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
00b2442632
commit
2c394704a5
|
@ -14,7 +14,6 @@ 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.Tag;
|
||||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Source;
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Source;
|
||||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Status;
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Status;
|
||||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Type;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
@ -67,12 +66,6 @@ public class Common {
|
||||||
@Valid
|
@Valid
|
||||||
private List<Resource<String>> sourceOfInformation;
|
private List<Resource<String>> sourceOfInformation;
|
||||||
|
|
||||||
@JsonProperty("type")
|
|
||||||
@CustomField(key="Type")
|
|
||||||
@Tag
|
|
||||||
@Group
|
|
||||||
private Type type;
|
|
||||||
|
|
||||||
@JsonProperty("short_title")
|
@JsonProperty("short_title")
|
||||||
@CustomField(key="Short Title")
|
@CustomField(key="Short Title")
|
||||||
@NotNull(message="short_title cannot be null")
|
@NotNull(message="short_title cannot be null")
|
||||||
|
@ -137,7 +130,7 @@ public class Common {
|
||||||
String maintainerContact,
|
String maintainerContact,
|
||||||
List<Resource<Source>> databaseSources,
|
List<Resource<Source>> databaseSources,
|
||||||
List<Resource<String>> sourceOfInformation, String dataOwner,
|
List<Resource<String>> sourceOfInformation, String dataOwner,
|
||||||
Type type, String shortTitle, String uuid,
|
String shortTitle, String uuid,
|
||||||
boolean traceabilityFlag, Map<String, List<String>> extras,
|
boolean traceabilityFlag, Map<String, List<String>> extras,
|
||||||
Status status, String productType) {
|
Status status, String productType) {
|
||||||
super();
|
super();
|
||||||
|
@ -151,7 +144,6 @@ public class Common {
|
||||||
this.databaseSources = databaseSources;
|
this.databaseSources = databaseSources;
|
||||||
this.sourceOfInformation = sourceOfInformation;
|
this.sourceOfInformation = sourceOfInformation;
|
||||||
this.dataOwner = dataOwner;
|
this.dataOwner = dataOwner;
|
||||||
this.type = type;
|
|
||||||
this.shortTitle = shortTitle;
|
this.shortTitle = shortTitle;
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.traceabilityFlag = traceabilityFlag;
|
this.traceabilityFlag = traceabilityFlag;
|
||||||
|
@ -248,14 +240,6 @@ public class Common {
|
||||||
this.dataOwner = dataOwner;
|
this.dataOwner = dataOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(Type type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExtras(Map<String, List<String>> extras) {
|
public void setExtras(Map<String, List<String>> extras) {
|
||||||
this.extras = extras;
|
this.extras = extras;
|
||||||
}
|
}
|
||||||
|
@ -304,7 +288,7 @@ public class Common {
|
||||||
+ maintainer + ", maintainerContact=" + maintainerContact
|
+ maintainer + ", maintainerContact=" + maintainerContact
|
||||||
+ ", dataOwner=" + dataOwner + ", databaseSources="
|
+ ", dataOwner=" + dataOwner + ", databaseSources="
|
||||||
+ databaseSources + ", sourceOfInformation="
|
+ databaseSources + ", sourceOfInformation="
|
||||||
+ sourceOfInformation + ", type=" + type + ", shortTitle="
|
+ sourceOfInformation + ", shortTitle="
|
||||||
+ shortTitle + ", uuid=" + uuid + ", traceabilityFlag="
|
+ shortTitle + ", uuid=" + uuid + ", traceabilityFlag="
|
||||||
+ traceabilityFlag + ", extras=" + extras + ", status="
|
+ traceabilityFlag + ", extras=" + extras + ", status="
|
||||||
+ status + ", productType=" + productType + "]";
|
+ status + ", productType=" + productType + "]";
|
||||||
|
|
|
@ -11,6 +11,7 @@ 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.Group;
|
||||||
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.Tag;
|
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.Tag;
|
||||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Production_System_Type;
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Production_System_Type;
|
||||||
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Type_Fishery;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
@ -80,6 +81,12 @@ public class FisheryRecord extends Common{
|
||||||
@Valid
|
@Valid
|
||||||
private List<TimeSeriesBean<String, String>> catchesOrLandings;
|
private List<TimeSeriesBean<String, String>> catchesOrLandings;
|
||||||
|
|
||||||
|
@JsonProperty("type")
|
||||||
|
@CustomField(key="Type")
|
||||||
|
@Tag
|
||||||
|
@Group
|
||||||
|
private Type_Fishery type;
|
||||||
|
|
||||||
public FisheryRecord() {
|
public FisheryRecord() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -98,13 +105,15 @@ public class FisheryRecord extends Common{
|
||||||
* @param fishingGear
|
* @param fishingGear
|
||||||
* @param environment
|
* @param environment
|
||||||
* @param catchesOrLandings
|
* @param catchesOrLandings
|
||||||
|
* @param type
|
||||||
*/
|
*/
|
||||||
public FisheryRecord(String fisheryName, String fisheryId,
|
public FisheryRecord(String fisheryName, String fisheryId,
|
||||||
String scientificName, String fishingArea, String exploitingStocks,
|
String scientificName, String fishingArea, String exploitingStocks,
|
||||||
String managementEntity, String jurisdictionArea,
|
String managementEntity, String jurisdictionArea,
|
||||||
Production_System_Type productionSystemType, String flagState,
|
Production_System_Type productionSystemType, String flagState,
|
||||||
String fishingGear, String environment,
|
String fishingGear, String environment,
|
||||||
List<TimeSeriesBean<String, String>> catchesOrLandings) {
|
List<TimeSeriesBean<String, String>> catchesOrLandings,
|
||||||
|
Type_Fishery type) {
|
||||||
super();
|
super();
|
||||||
this.fisheryName = fisheryName;
|
this.fisheryName = fisheryName;
|
||||||
this.fisheryId = fisheryId;
|
this.fisheryId = fisheryId;
|
||||||
|
@ -118,6 +127,7 @@ public class FisheryRecord extends Common{
|
||||||
this.fishingGear = fishingGear;
|
this.fishingGear = fishingGear;
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
this.catchesOrLandings = catchesOrLandings;
|
this.catchesOrLandings = catchesOrLandings;
|
||||||
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFisheryName() {
|
public String getFisheryName() {
|
||||||
|
@ -220,6 +230,14 @@ public class FisheryRecord extends Common{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Type_Fishery getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Type_Fishery type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "FisheryRecord [fisheryName=" + fisheryName + ", fisheryId="
|
return "FisheryRecord [fisheryName=" + fisheryName + ", fisheryId="
|
||||||
|
@ -230,6 +248,6 @@ public class FisheryRecord extends Common{
|
||||||
+ ", productionSystemType=" + productionSystemType
|
+ ", productionSystemType=" + productionSystemType
|
||||||
+ ", flagState=" + flagState + ", fishingGear=" + fishingGear
|
+ ", flagState=" + flagState + ", fishingGear=" + fishingGear
|
||||||
+ ", environment=" + environment + ", catchesOrLandings="
|
+ ", environment=" + environment + ", catchesOrLandings="
|
||||||
+ catchesOrLandings + "]";
|
+ catchesOrLandings + ", type=" + type + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,9 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A resource object bean. The generic argument applies to the resource's name.
|
* A resource object bean. The generic argument T applies to the resource's name.
|
||||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||||
|
* @param <T> the resource's name type
|
||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true) // ignore in serialization/deserialization
|
@JsonIgnoreProperties(ignoreUnknown = true) // ignore in serialization/deserialization
|
||||||
public class Resource<T> {
|
public class Resource<T> {
|
||||||
|
|
|
@ -12,6 +12,7 @@ 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.Tag;
|
||||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Abundance_Level;
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Abundance_Level;
|
||||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Exploitation_Rate;
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Exploitation_Rate;
|
||||||
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Type_Stock;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
@ -106,6 +107,12 @@ public class StockRecord extends Common{
|
||||||
@CustomField(key="Water Area")
|
@CustomField(key="Water Area")
|
||||||
private List<String> waterArea;
|
private List<String> waterArea;
|
||||||
|
|
||||||
|
@JsonProperty("type")
|
||||||
|
@CustomField(key="Type")
|
||||||
|
@Tag
|
||||||
|
@Group
|
||||||
|
private Type_Stock type;
|
||||||
|
|
||||||
public StockRecord() {
|
public StockRecord() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -130,6 +137,7 @@ public class StockRecord extends Common{
|
||||||
* @param reportingYear
|
* @param reportingYear
|
||||||
* @param stockUri
|
* @param stockUri
|
||||||
* @param waterArea
|
* @param waterArea
|
||||||
|
* @param type
|
||||||
*/
|
*/
|
||||||
public StockRecord(String stockName, String stockID,
|
public StockRecord(String stockName, String stockID,
|
||||||
String speciesScientificName, String area,
|
String speciesScientificName, String area,
|
||||||
|
@ -141,7 +149,7 @@ public class StockRecord extends Common{
|
||||||
Abundance_Level abundanceLevelForGrouping,
|
Abundance_Level abundanceLevelForGrouping,
|
||||||
String narrativeStateAndTrend, String scientificAdvice,
|
String narrativeStateAndTrend, String scientificAdvice,
|
||||||
String reportingEntity, Long reportingYear, String stockUri,
|
String reportingEntity, Long reportingYear, String stockUri,
|
||||||
List<String> waterArea) {
|
List<String> waterArea, Type_Stock type) {
|
||||||
super();
|
super();
|
||||||
this.stockName = stockName;
|
this.stockName = stockName;
|
||||||
this.stockID = stockID;
|
this.stockID = stockID;
|
||||||
|
@ -161,6 +169,15 @@ public class StockRecord extends Common{
|
||||||
this.reportingYear = reportingYear;
|
this.reportingYear = reportingYear;
|
||||||
this.stockUri = stockUri;
|
this.stockUri = stockUri;
|
||||||
this.waterArea = waterArea;
|
this.waterArea = waterArea;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type_Stock getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Type_Stock type) {
|
||||||
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Exploitation_Rate getExploitationRateForGrouping() {
|
public Exploitation_Rate getExploitationRateForGrouping() {
|
||||||
|
@ -319,7 +336,7 @@ public class StockRecord extends Common{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "StockRecord [" + super.toString() + "stockName=" + stockName + ", stockID=" + stockID
|
return "StockRecord [stockName=" + stockName + ", stockID=" + stockID
|
||||||
+ ", speciesScientificName=" + speciesScientificName
|
+ ", speciesScientificName=" + speciesScientificName
|
||||||
+ ", area=" + area + ", exploitingFishery=" + exploitingFishery
|
+ ", area=" + area + ", exploitingFishery=" + exploitingFishery
|
||||||
+ ", managementEntity=" + managementEntity
|
+ ", managementEntity=" + managementEntity
|
||||||
|
@ -333,6 +350,7 @@ public class StockRecord extends Common{
|
||||||
+ narrativeStateAndTrend + ", scientificAdvice="
|
+ narrativeStateAndTrend + ", scientificAdvice="
|
||||||
+ scientificAdvice + ", reportingEntity=" + reportingEntity
|
+ scientificAdvice + ", reportingEntity=" + reportingEntity
|
||||||
+ ", reportingYear=" + reportingYear + ", stockUri=" + stockUri
|
+ ", reportingYear=" + reportingYear + ", stockUri=" + stockUri
|
||||||
+ ", waterArea=" + waterArea + "]";
|
+ ", waterArea=" + waterArea + ", type=" + type + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,11 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A time series bean that contains couple <year, value>
|
* A time series bean that contains elements < year, T, T1 >
|
||||||
* Catches_and_landings contains also Unit
|
* Catches_and_landings contains also Unit
|
||||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||||
* @param T the first type value of the series
|
* @param <T> the first type value of the series
|
||||||
* @param T1 the second type value of the series
|
* @param <T1> the second type value of the series (optional)
|
||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public class TimeSeriesBean<T, T1> implements Comparable<TimeSeriesBean<T, T1>>{
|
public class TimeSeriesBean<T, T1> implements Comparable<TimeSeriesBean<T, T1>>{
|
||||||
|
@ -72,7 +72,7 @@ public class TimeSeriesBean<T, T1> implements Comparable<TimeSeriesBean<T, T1>>{
|
||||||
// when the value belongs to these classes annotated with @Tag..
|
// when the value belongs to these classes annotated with @Tag..
|
||||||
if(valueClass.equals(Abundance_Level.class) || valueClass.equals(Exploitation_Rate.class))
|
if(valueClass.equals(Abundance_Level.class) || valueClass.equals(Exploitation_Rate.class))
|
||||||
return year + "-" + value;
|
return year + "-" + value;
|
||||||
else if(this.unit != null && this.unit.getClass().equals(String.class)) // catches and landings
|
else if(this.unit != null && !this.unit.getClass().equals(Void.class)) // e.g., catches and landings
|
||||||
return year + "-" + value + "-" + unit;
|
return year + "-" + value + "-" + unit;
|
||||||
else
|
else
|
||||||
return "TimeSeriesBean [value=" + value + ", unit=" + unit + ", year="
|
return "TimeSeriesBean [value=" + value + ", unit=" + unit + ", year="
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
package org.gcube.data_catalogue.grsf_publish_ws.json.output;
|
package org.gcube.data_catalogue.grsf_publish_ws.json.output;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Response bean.
|
* Response bean to be used by the service.
|
||||||
* @author Costantino Perciante at ISTI-CNR
|
* @author Costantino Perciante at ISTI-CNR
|
||||||
* (costantino.perciante@isti.cnr.it)
|
* (costantino.perciante@isti.cnr.it)
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ResponseBean{
|
public class ResponseBean{
|
||||||
|
|
||||||
|
|
|
@ -237,21 +237,19 @@ public class GrsfPublisherFisheryService {
|
||||||
responseBean.setProductUrl(catalogue.getPortletUrl() + "?" + URLEncoder.encode("path=/dataset/" + futureName, "UTF-8"));
|
responseBean.setProductUrl(catalogue.getPortletUrl() + "?" + URLEncoder.encode("path=/dataset/" + futureName, "UTF-8"));
|
||||||
responseBean.setKbUuid(record.getUuid());
|
responseBean.setKbUuid(record.getUuid());
|
||||||
|
|
||||||
// manage time series
|
|
||||||
logger.info("Launching thread for time series handling");
|
|
||||||
ManageTimeSeriesThread threadFiles = new ManageTimeSeriesThread(record, futureName, username, catalogue, ScopeProvider.instance.get());
|
|
||||||
|
|
||||||
// wait this one to finish
|
|
||||||
threadFiles.start();
|
|
||||||
|
|
||||||
logger.info("Waiting time series thread to die..");
|
|
||||||
threadFiles.join();
|
|
||||||
logger.debug("Ok, it died");
|
|
||||||
|
|
||||||
if(!groups.isEmpty()){
|
if(!groups.isEmpty()){
|
||||||
logger.info("Launching thread for association to the list of groups " + groups);
|
logger.info("Launching thread for association to the list of groups " + groups);
|
||||||
new AssociationToGroupThread(groups, id, organization, username, catalogue).start();
|
AssociationToGroupThread threadGroups = new AssociationToGroupThread(groups, id, organization, username, catalogue);
|
||||||
|
threadGroups.start();
|
||||||
|
logger.info("Waiting association thread to die..");
|
||||||
|
threadGroups.join();
|
||||||
|
logger.debug("Ok, it died");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// manage time series
|
||||||
|
logger.info("Launching thread for time series handling");
|
||||||
|
new ManageTimeSeriesThread(record, futureName, username, catalogue, ScopeProvider.instance.get()).start();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,21 +226,18 @@ public class GrsfPublisherStockService {
|
||||||
responseBean.setProductUrl(catalogue.getPortletUrl() + "?" + URLEncoder.encode("path=/dataset/" + futureName, "UTF-8"));
|
responseBean.setProductUrl(catalogue.getPortletUrl() + "?" + URLEncoder.encode("path=/dataset/" + futureName, "UTF-8"));
|
||||||
responseBean.setKbUuid(record.getUuid());
|
responseBean.setKbUuid(record.getUuid());
|
||||||
|
|
||||||
// manage time series
|
|
||||||
logger.info("Launching thread for time series handling");
|
|
||||||
ManageTimeSeriesThread threadFiles = new ManageTimeSeriesThread(record, futureName, username, catalogue, ScopeProvider.instance.get());
|
|
||||||
|
|
||||||
// wait this one to finish
|
|
||||||
threadFiles.start();
|
|
||||||
|
|
||||||
logger.info("Waiting time series thread to die..");
|
|
||||||
threadFiles.join();
|
|
||||||
logger.debug("Ok, it died");
|
|
||||||
|
|
||||||
if(!groups.isEmpty()){
|
if(!groups.isEmpty()){
|
||||||
logger.info("Launching thread for association to the list of groups " + groups);
|
logger.info("Launching thread for association to the list of groups " + groups);
|
||||||
new AssociationToGroupThread(groups, id, organization, username, catalogue).start();
|
AssociationToGroupThread threadGroups = new AssociationToGroupThread(groups, id, organization, username, catalogue);
|
||||||
|
threadGroups.start();
|
||||||
|
logger.info("Waiting association thread to die..");
|
||||||
|
threadGroups.join();
|
||||||
|
logger.debug("Ok, it died");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// manage time series
|
||||||
|
logger.info("Launching thread for time series handling");
|
||||||
|
new ManageTimeSeriesThread(record, futureName, username, catalogue, ScopeProvider.instance.get()).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,8 @@ public class CSVHelpers {
|
||||||
* Write a time series to a csv file, and returns the file reference.<br>
|
* Write a time series to a csv file, and returns the file reference.<br>
|
||||||
* Please give the timeSeries already sorted per year
|
* Please give the timeSeries already sorted per year
|
||||||
* @param timeSeries
|
* @param timeSeries
|
||||||
|
* @param <T>
|
||||||
|
* @param <T1>
|
||||||
*/
|
*/
|
||||||
public static <T, T1> File listToCSV(List<TimeSeriesBean<T, T1>> timeSeries){
|
public static <T, T1> File listToCSV(List<TimeSeriesBean<T, T1>> timeSeries){
|
||||||
|
|
||||||
|
|
|
@ -5,19 +5,17 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type for Stock/Fishery records
|
* Type for Fishery records
|
||||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||||
*/
|
*/
|
||||||
public enum Type {
|
public enum Type_Fishery {
|
||||||
|
|
||||||
Assessment_Unit("Assessment Unit"),// for stock
|
|
||||||
Resource("Resource"), // for stock
|
|
||||||
Fishery_Activity("Fishery Activity"), // for fishery
|
Fishery_Activity("Fishery Activity"), // for fishery
|
||||||
Fishing_Description("Fishing Description"); // for fishery
|
Fishing_Description("Fishing Description"); // for fishery
|
||||||
|
|
||||||
private String subGroupNameOrig;
|
private String subGroupNameOrig;
|
||||||
|
|
||||||
private Type(String origName) {
|
private Type_Fishery(String origName) {
|
||||||
this.subGroupNameOrig = origName;
|
this.subGroupNameOrig = origName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,9 +42,9 @@ public enum Type {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@JsonCreator
|
@JsonCreator
|
||||||
public static Type onDeserialize(String typeString) {
|
public static Type_Fishery onDeserialize(String typeString) {
|
||||||
if(typeString != null) {
|
if(typeString != null) {
|
||||||
for(Type type : Type.values()) {
|
for(Type_Fishery type : Type_Fishery.values()) {
|
||||||
if(type.getOrigName().equalsIgnoreCase(typeString.trim()))
|
if(type.getOrigName().equalsIgnoreCase(typeString.trim()))
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
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 Type_Stock {
|
||||||
|
|
||||||
|
Assessment_Unit("Assessment Unit"),// for stock
|
||||||
|
Resource("Resource"); // for stock
|
||||||
|
|
||||||
|
private String subGroupNameOrig;
|
||||||
|
|
||||||
|
private Type_Stock(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 Type_Stock onDeserialize(String typeString) {
|
||||||
|
if(typeString != null) {
|
||||||
|
for(Type_Stock type : Type_Stock.values()) {
|
||||||
|
if(type.getOrigName().equalsIgnoreCase(typeString.trim()))
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used by reflection
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getOrigName();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -14,7 +14,8 @@ import org.gcube.data_catalogue.grsf_publish_ws.services.GrsfPublisherFisherySer
|
||||||
import org.gcube.data_catalogue.grsf_publish_ws.services.GrsfPublisherStockService;
|
import org.gcube.data_catalogue.grsf_publish_ws.services.GrsfPublisherStockService;
|
||||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Source;
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Source;
|
||||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Status;
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Status;
|
||||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Type;
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Type_Fishery;
|
||||||
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Type_Stock;
|
||||||
import org.glassfish.jersey.server.ResourceConfig;
|
import org.glassfish.jersey.server.ResourceConfig;
|
||||||
import org.glassfish.jersey.test.JerseyTest;
|
import org.glassfish.jersey.test.JerseyTest;
|
||||||
import org.glassfish.jersey.test.TestProperties;
|
import org.glassfish.jersey.test.TestProperties;
|
||||||
|
@ -34,7 +35,7 @@ public class JJerseyTest extends JerseyTest{
|
||||||
recordFishery.setAuthorContact("costantino.perciante@isti.cnr.it");
|
recordFishery.setAuthorContact("costantino.perciante@isti.cnr.it");
|
||||||
recordFishery.setLicense("a caso una lincense");
|
recordFishery.setLicense("a caso una lincense");
|
||||||
recordFishery.setDataOwner("data owner");
|
recordFishery.setDataOwner("data owner");
|
||||||
recordFishery.setType(Type.Fishing_Description);
|
recordFishery.setType(Type_Fishery.Fishing_Description);
|
||||||
recordFishery.setDatabaseSources(new ArrayList<Resource<Source>>(1));
|
recordFishery.setDatabaseSources(new ArrayList<Resource<Source>>(1));
|
||||||
recordFishery.setSourceOfInformation(new ArrayList<Resource<String>>(1));
|
recordFishery.setSourceOfInformation(new ArrayList<Resource<String>>(1));
|
||||||
recordFishery.setStatus(Status.Pending);
|
recordFishery.setStatus(Status.Pending);
|
||||||
|
@ -47,7 +48,7 @@ public class JJerseyTest extends JerseyTest{
|
||||||
StockRecord stock = new StockRecord();
|
StockRecord stock = new StockRecord();
|
||||||
stock.setAuthor("Costantino Perciante");
|
stock.setAuthor("Costantino Perciante");
|
||||||
stock.setAuthorContact("costantino.perciante@isti.cnr.it");
|
stock.setAuthorContact("costantino.perciante@isti.cnr.it");
|
||||||
stock.setType(Type.Fishing_Description);
|
stock.setType(Type_Stock.Assessment_Unit);
|
||||||
stock.setDatabaseSources(null);
|
stock.setDatabaseSources(null);
|
||||||
stock.setStatus(Status.Pending);
|
stock.setStatus(Status.Pending);
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ 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.Abundance_Level;
|
||||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Source;
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Source;
|
||||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Status;
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Status;
|
||||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Type;
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Type_Fishery;
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue;
|
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue;
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogueFactory;
|
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogueFactory;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -51,7 +51,7 @@ public class JTests {
|
||||||
public void test() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, IntrospectionException {
|
public void test() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, IntrospectionException {
|
||||||
|
|
||||||
FisheryRecord recordFishery = new FisheryRecord();
|
FisheryRecord recordFishery = new FisheryRecord();
|
||||||
recordFishery.setType(Type.Fishing_Description);
|
recordFishery.setType(Type_Fishery.Fishing_Description);
|
||||||
recordFishery.setDatabaseSources(new ArrayList<Resource<Source>>());
|
recordFishery.setDatabaseSources(new ArrayList<Resource<Source>>());
|
||||||
recordFishery.setStatus(Status.Pending);
|
recordFishery.setStatus(Status.Pending);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue