aligned reference year and report year to time series model plus other minor fixes
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@151051 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
cc276c9862
commit
dec17269ab
|
@ -29,7 +29,7 @@ public class Common extends Base{
|
||||||
@JsonProperty("data_owner")
|
@JsonProperty("data_owner")
|
||||||
@CustomField(key="Data owner")
|
@CustomField(key="Data owner")
|
||||||
@Tag
|
@Tag
|
||||||
private String dataOwner;
|
private List<String> dataOwner;
|
||||||
|
|
||||||
@JsonProperty("database_sources")
|
@JsonProperty("database_sources")
|
||||||
@CkanResource
|
@CkanResource
|
||||||
|
@ -61,11 +61,15 @@ public class Common extends Base{
|
||||||
|
|
||||||
@JsonProperty("reporting_year")
|
@JsonProperty("reporting_year")
|
||||||
@CustomField(key="Reporting year")
|
@CustomField(key="Reporting year")
|
||||||
private List<Long> reportingYear;
|
@TimeSeries
|
||||||
|
@Valid
|
||||||
|
private List<TimeSeriesBean<Void, Void>> reportingYear;
|
||||||
|
|
||||||
@JsonProperty("reference_year")
|
@JsonProperty("reference_year")
|
||||||
@CustomField(key="Reference year")
|
@CustomField(key="Reference year")
|
||||||
private List<Long> referenceYear;
|
@TimeSeries
|
||||||
|
@Valid
|
||||||
|
private List<TimeSeriesBean<Void, Void>> referenceYear;
|
||||||
|
|
||||||
// automatically compiled
|
// automatically compiled
|
||||||
@JsonProperty("grsf_type")
|
@JsonProperty("grsf_type")
|
||||||
|
@ -112,16 +116,16 @@ public class Common extends Base{
|
||||||
* @param catches
|
* @param catches
|
||||||
* @param landings
|
* @param landings
|
||||||
* @param species
|
* @param species
|
||||||
* @param faoState
|
|
||||||
*/
|
*/
|
||||||
public Common(String dataOwner, List<Resource<Sources>> databaseSources,
|
public Common(List<String> dataOwner,
|
||||||
|
List<Resource<Sources>> databaseSources,
|
||||||
List<Resource<String>> sourceOfInformation,
|
List<Resource<String>> sourceOfInformation,
|
||||||
List<RefersToBean> refersTo, String shortTitle,
|
List<RefersToBean> refersTo, String shortTitle,
|
||||||
Boolean traceabilityFlag, Status status, List<Long> reportingYear,
|
Boolean traceabilityFlag, Status status,
|
||||||
List<Long> referenceYear, String grsfType, String sourceType,
|
List<TimeSeriesBean<Void, Void>> reportingYear,
|
||||||
List<TimeSeriesBean<String, String>> catches,
|
List<TimeSeriesBean<Void, Void>> referenceYear, String grsfType,
|
||||||
List<TimeSeriesBean<String, String>> landings,
|
String sourceType, List<TimeSeriesBean<String, String>> catches,
|
||||||
List<String> species, List<TimeSeriesBean<String, Void>> faoState) {
|
List<TimeSeriesBean<String, String>> landings, List<String> species) {
|
||||||
super();
|
super();
|
||||||
this.dataOwner = dataOwner;
|
this.dataOwner = dataOwner;
|
||||||
this.databaseSources = databaseSources;
|
this.databaseSources = databaseSources;
|
||||||
|
@ -143,22 +147,18 @@ public class Common extends Base{
|
||||||
return grsfType;
|
return grsfType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setGrsfType(String grsfType) {
|
public void setGrsfType(String grsfType) {
|
||||||
this.grsfType = grsfType;
|
this.grsfType = grsfType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getSourceType() {
|
public String getSourceType() {
|
||||||
return sourceType;
|
return sourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setSourceType(String sourceType) {
|
public void setSourceType(String sourceType) {
|
||||||
this.sourceType = sourceType;
|
this.sourceType = sourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Boolean getTraceabilityFlag() {
|
public Boolean getTraceabilityFlag() {
|
||||||
return traceabilityFlag;
|
return traceabilityFlag;
|
||||||
}
|
}
|
||||||
|
@ -171,14 +171,18 @@ public class Common extends Base{
|
||||||
this.refersTo = refersTo;
|
this.refersTo = refersTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Long> getReportingYear() {
|
public List<TimeSeriesBean<Void, Void>> getReportingYear() {
|
||||||
return reportingYear;
|
return reportingYear;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReportingYear(List<Long> reportingYear) {
|
public void setReportingYear(List<TimeSeriesBean<Void, Void>> reportingYear) {
|
||||||
this.reportingYear = reportingYear;
|
this.reportingYear = reportingYear;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setReferenceYear(List<TimeSeriesBean<Void, Void>> referenceYear) {
|
||||||
|
this.referenceYear = referenceYear;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Resource<Sources>> getDatabaseSources() {
|
public List<Resource<Sources>> getDatabaseSources() {
|
||||||
return databaseSources;
|
return databaseSources;
|
||||||
}
|
}
|
||||||
|
@ -195,14 +199,6 @@ public class Common extends Base{
|
||||||
this.sourceOfInformation = sourceOfInformation;
|
this.sourceOfInformation = sourceOfInformation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDataOwner() {
|
|
||||||
return dataOwner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDataOwner(String dataOwner) {
|
|
||||||
this.dataOwner = dataOwner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getShortTitle() {
|
public String getShortTitle() {
|
||||||
return shortTitle;
|
return shortTitle;
|
||||||
}
|
}
|
||||||
|
@ -251,12 +247,12 @@ public class Common extends Base{
|
||||||
this.landings = landings;
|
this.landings = landings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Long> getReferenceYear() {
|
public List<String> getDataOwner() {
|
||||||
return referenceYear;
|
return dataOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReferenceYear(List<Long> referenceYear) {
|
public void setDataOwner(List<String> dataOwner) {
|
||||||
this.referenceYear = referenceYear;
|
this.dataOwner = dataOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -11,7 +11,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.custom_annotations.TimeSeries;
|
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.TimeSeries;
|
||||||
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.Fishing_Pressure;
|
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.data_catalogue.grsf_publish_ws.utils.groups.Stock_Type;
|
||||||
|
|
||||||
|
@ -56,19 +55,6 @@ public class StockRecord extends Common{
|
||||||
@CustomField(key="State of marine resources")
|
@CustomField(key="State of marine resources")
|
||||||
private String stateOfMarineResource;
|
private String stateOfMarineResource;
|
||||||
|
|
||||||
@JsonProperty("standard_exploitation_rate")
|
|
||||||
@CustomField(key="Standard Exploitation Rate")
|
|
||||||
//@Tag
|
|
||||||
@TimeSeries
|
|
||||||
@Valid
|
|
||||||
private List<TimeSeriesBean<Exploitation_Rate, Void>> exploitationRateStandard;
|
|
||||||
|
|
||||||
@JsonProperty("exploitation_rate")
|
|
||||||
@CustomField(key="Exploitation Rate")
|
|
||||||
@TimeSeries
|
|
||||||
@Valid
|
|
||||||
private List<TimeSeriesBean<String, String>> exploitationRate;
|
|
||||||
|
|
||||||
@JsonProperty("standard_abundance_level")
|
@JsonProperty("standard_abundance_level")
|
||||||
@CustomField(key="Standard Abundance Level")
|
@CustomField(key="Standard Abundance Level")
|
||||||
@TimeSeries
|
@TimeSeries
|
||||||
|
@ -95,11 +81,19 @@ public class StockRecord extends Common{
|
||||||
|
|
||||||
@JsonProperty("narrative_state")
|
@JsonProperty("narrative_state")
|
||||||
@CustomField(key="Narrative state")
|
@CustomField(key="Narrative state")
|
||||||
|
@TimeSeries
|
||||||
|
@Valid
|
||||||
private List<TimeSeriesBean<String, Void>> narrativeState;
|
private List<TimeSeriesBean<String, Void>> narrativeState;
|
||||||
|
|
||||||
|
@JsonProperty("fao_state")
|
||||||
|
@CustomField(key="Fao State")
|
||||||
|
@TimeSeries
|
||||||
|
@Valid
|
||||||
|
private List<TimeSeriesBean<String, Void>> faoState;
|
||||||
|
|
||||||
@JsonProperty("scientific_advice")
|
@JsonProperty("scientific_advice")
|
||||||
@CustomField(key="Scientific advice")
|
@CustomField(key="Scientific advice")
|
||||||
private String scientificAdvice;
|
private List<String> scientificAdvice;
|
||||||
|
|
||||||
@JsonProperty("assessor")
|
@JsonProperty("assessor")
|
||||||
@CustomField(key="Assessor")
|
@CustomField(key="Assessor")
|
||||||
|
@ -120,12 +114,6 @@ public class StockRecord extends Common{
|
||||||
@Group
|
@Group
|
||||||
private Stock_Type type;
|
private Stock_Type type;
|
||||||
|
|
||||||
@JsonProperty("fao_state")
|
|
||||||
@CustomField(key="Fao State")
|
|
||||||
@TimeSeries
|
|
||||||
@Valid
|
|
||||||
private List<TimeSeriesBean<String, Void>> faoState;
|
|
||||||
|
|
||||||
public StockRecord() {
|
public StockRecord() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -138,19 +126,17 @@ public class StockRecord extends Common{
|
||||||
* @param managementEntity
|
* @param managementEntity
|
||||||
* @param assessmentMethods
|
* @param assessmentMethods
|
||||||
* @param stateOfMarineResource
|
* @param stateOfMarineResource
|
||||||
* @param exploitationRateStandard
|
|
||||||
* @param exploitationRate
|
|
||||||
* @param abundanceLevelStandard
|
* @param abundanceLevelStandard
|
||||||
* @param abundanceLevel
|
* @param abundanceLevel
|
||||||
* @param fishingPressureStandard
|
* @param fishingPressureStandard
|
||||||
* @param fishingPressure
|
* @param fishingPressure
|
||||||
* @param narrativeState
|
* @param narrativeState
|
||||||
|
* @param faoState
|
||||||
* @param scientificAdvice
|
* @param scientificAdvice
|
||||||
* @param assessor
|
* @param assessor
|
||||||
* @param stockUri
|
* @param stockUri
|
||||||
* @param waterArea
|
* @param waterArea
|
||||||
* @param type
|
* @param type
|
||||||
* @param faoState
|
|
||||||
*/
|
*/
|
||||||
public StockRecord(
|
public StockRecord(
|
||||||
String stockName,
|
String stockName,
|
||||||
|
@ -160,16 +146,14 @@ public class StockRecord extends Common{
|
||||||
String managementEntity,
|
String managementEntity,
|
||||||
List<String> assessmentMethods,
|
List<String> assessmentMethods,
|
||||||
String stateOfMarineResource,
|
String stateOfMarineResource,
|
||||||
List<TimeSeriesBean<Exploitation_Rate, Void>> exploitationRateStandard,
|
|
||||||
List<TimeSeriesBean<String, String>> exploitationRate,
|
|
||||||
List<TimeSeriesBean<Abundance_Level, Void>> abundanceLevelStandard,
|
List<TimeSeriesBean<Abundance_Level, Void>> abundanceLevelStandard,
|
||||||
List<TimeSeriesBean<String, String>> abundanceLevel,
|
List<TimeSeriesBean<String, String>> abundanceLevel,
|
||||||
List<TimeSeriesBean<Fishing_Pressure, Void>> fishingPressureStandard,
|
List<TimeSeriesBean<Fishing_Pressure, Void>> fishingPressureStandard,
|
||||||
List<TimeSeriesBean<String, String>> fishingPressure,
|
List<TimeSeriesBean<String, String>> fishingPressure,
|
||||||
List<TimeSeriesBean<String, Void>> narrativeState,
|
List<TimeSeriesBean<String, Void>> narrativeState,
|
||||||
String scientificAdvice, String assessor, String stockUri,
|
List<TimeSeriesBean<String, Void>> faoState,
|
||||||
List<String> waterArea, Stock_Type type,
|
List<String> scientificAdvice, String assessor, String stockUri,
|
||||||
List<TimeSeriesBean<String, Void>> faoState) {
|
List<String> waterArea, Stock_Type type) {
|
||||||
super();
|
super();
|
||||||
this.stockName = stockName;
|
this.stockName = stockName;
|
||||||
this.stockId = stockId;
|
this.stockId = stockId;
|
||||||
|
@ -178,23 +162,19 @@ public class StockRecord extends Common{
|
||||||
this.managementEntity = managementEntity;
|
this.managementEntity = managementEntity;
|
||||||
this.assessmentMethods = assessmentMethods;
|
this.assessmentMethods = assessmentMethods;
|
||||||
this.stateOfMarineResource = stateOfMarineResource;
|
this.stateOfMarineResource = stateOfMarineResource;
|
||||||
this.exploitationRateStandard = exploitationRateStandard;
|
|
||||||
this.exploitationRate = exploitationRate;
|
|
||||||
this.abundanceLevelStandard = abundanceLevelStandard;
|
this.abundanceLevelStandard = abundanceLevelStandard;
|
||||||
this.abundanceLevel = abundanceLevel;
|
this.abundanceLevel = abundanceLevel;
|
||||||
this.fishingPressureStandard = fishingPressureStandard;
|
this.fishingPressureStandard = fishingPressureStandard;
|
||||||
this.fishingPressure = fishingPressure;
|
this.fishingPressure = fishingPressure;
|
||||||
this.narrativeState = narrativeState;
|
this.narrativeState = narrativeState;
|
||||||
|
this.faoState = faoState;
|
||||||
this.scientificAdvice = scientificAdvice;
|
this.scientificAdvice = scientificAdvice;
|
||||||
this.assessor = assessor;
|
this.assessor = assessor;
|
||||||
this.stockUri = stockUri;
|
this.stockUri = stockUri;
|
||||||
this.waterArea = waterArea;
|
this.waterArea = waterArea;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.faoState = faoState;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void setAssessmentMethods(List<String> assessmentMethods) {
|
public void setAssessmentMethods(List<String> assessmentMethods) {
|
||||||
this.assessmentMethods = assessmentMethods;
|
this.assessmentMethods = assessmentMethods;
|
||||||
}
|
}
|
||||||
|
@ -289,15 +269,6 @@ public class StockRecord extends Common{
|
||||||
this.stateOfMarineResource = stateOfMarineResource;
|
this.stateOfMarineResource = stateOfMarineResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TimeSeriesBean<Exploitation_Rate, Void>> getExploitationRateStandard() {
|
|
||||||
return exploitationRateStandard;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExploitationRateStandard(
|
|
||||||
List<TimeSeriesBean<Exploitation_Rate, Void>> exploitationRateStandard) {
|
|
||||||
this.exploitationRateStandard = exploitationRateStandard;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<TimeSeriesBean<Abundance_Level, Void>> getAbundanceLevelStandard() {
|
public List<TimeSeriesBean<Abundance_Level, Void>> getAbundanceLevelStandard() {
|
||||||
return abundanceLevelStandard;
|
return abundanceLevelStandard;
|
||||||
}
|
}
|
||||||
|
@ -324,11 +295,11 @@ public class StockRecord extends Common{
|
||||||
this.narrativeState = narrativeState;
|
this.narrativeState = narrativeState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getScientificAdvice() {
|
public List<String> getScientificAdvice() {
|
||||||
return scientificAdvice;
|
return scientificAdvice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScientificAdvice(String scientificAdvice) {
|
public void setScientificAdvice(List<String> scientificAdvice) {
|
||||||
this.scientificAdvice = scientificAdvice;
|
this.scientificAdvice = scientificAdvice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,15 +311,6 @@ public class StockRecord extends Common{
|
||||||
this.assessor = assessor;
|
this.assessor = assessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TimeSeriesBean<String, String>> getExploitationRate() {
|
|
||||||
return exploitationRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExploitationRate(
|
|
||||||
List<TimeSeriesBean<String, String>> exploitationRate) {
|
|
||||||
this.exploitationRate = exploitationRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<TimeSeriesBean<String, Void>> getFaoState() {
|
public List<TimeSeriesBean<String, Void>> getFaoState() {
|
||||||
return faoState;
|
return faoState;
|
||||||
}
|
}
|
||||||
|
@ -368,8 +330,6 @@ public class StockRecord extends Common{
|
||||||
+ ", managementEntity=" + managementEntity
|
+ ", managementEntity=" + managementEntity
|
||||||
+ ", assessmentMethods=" + assessmentMethods
|
+ ", assessmentMethods=" + assessmentMethods
|
||||||
+ ", stateOfMarineResource=" + stateOfMarineResource
|
+ ", stateOfMarineResource=" + stateOfMarineResource
|
||||||
+ ", exploitationRateStandard=" + exploitationRateStandard
|
|
||||||
+ ", exploitationRate=" + exploitationRate
|
|
||||||
+ ", abundanceLevelStandard=" + abundanceLevelStandard
|
+ ", abundanceLevelStandard=" + abundanceLevelStandard
|
||||||
+ ", abundanceLevel=" + abundanceLevel
|
+ ", abundanceLevel=" + abundanceLevel
|
||||||
+ ", fishingPressureStandard=" + fishingPressureStandard
|
+ ", fishingPressureStandard=" + fishingPressureStandard
|
||||||
|
|
|
@ -6,8 +6,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A time series bean that contains elements < year, T, T1 >.
|
* A time series bean that contains elements < year, T, T1 , source >.
|
||||||
* Unit can be contained too.
|
* Year is the only required element.
|
||||||
* @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 (optional)
|
* @param <T1> the second type value of the series (optional)
|
||||||
|
@ -15,26 +15,40 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
@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>>{
|
||||||
|
|
||||||
@JsonProperty("year")
|
public static final String YEAR_FIELD = "year";
|
||||||
|
public static final String VALUE_FIELD = "value";
|
||||||
|
public static final String UNIT_FIELD = "unit";
|
||||||
|
public static final String SOURCE_FIELD = "source";
|
||||||
|
|
||||||
|
@JsonProperty(YEAR_FIELD)
|
||||||
@NotNull(message="year of a time series cannot be null")
|
@NotNull(message="year of a time series cannot be null")
|
||||||
private Long year;
|
private Long year;
|
||||||
|
|
||||||
@JsonProperty("value")
|
@JsonProperty(SOURCE_FIELD)
|
||||||
@NotNull(message="value of a time series cannot be null")
|
private String source;
|
||||||
|
|
||||||
|
@JsonProperty(VALUE_FIELD)
|
||||||
private T value;
|
private T value;
|
||||||
|
|
||||||
@JsonProperty("unit")
|
@JsonProperty(UNIT_FIELD)
|
||||||
private T1 unit;
|
private T1 unit;
|
||||||
|
|
||||||
public TimeSeriesBean() {
|
public TimeSeriesBean() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeSeriesBean(T value, Long year, T1 unit) {
|
/**
|
||||||
|
* @param year
|
||||||
|
* @param value
|
||||||
|
* @param unit
|
||||||
|
* @param source
|
||||||
|
*/
|
||||||
|
public TimeSeriesBean(Long year, T value, T1 unit, String source) {
|
||||||
super();
|
super();
|
||||||
this.value = value;
|
|
||||||
this.year = year;
|
this.year = year;
|
||||||
|
this.value = value;
|
||||||
this.unit = unit;
|
this.unit = unit;
|
||||||
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T getValue() {
|
public T getValue() {
|
||||||
|
@ -61,19 +75,40 @@ public class TimeSeriesBean<T, T1> implements Comparable<TimeSeriesBean<T, T1>>{
|
||||||
this.unit = unit;
|
this.unit = unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSource(String source) {
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
||||||
if(this.unit != null && !this.unit.getClass().equals(Void.class)
|
String firstPart = "" + year;
|
||||||
&& !this.unit.toString().isEmpty()) // e.g., catches and landings
|
String secondPart = (value != null ? " - " + value : "")
|
||||||
return year + "-" + value + "-" + unit;
|
+ (unit != null ? " - " + unit : "")
|
||||||
else
|
+ (source != null ? " (" + source + ")" : "");
|
||||||
return year + "-" + value;
|
return firstPart + (secondPart != null && !secondPart.isEmpty() ? secondPart : "");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSourcePresent(){
|
||||||
|
return source != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUnitPresent(){
|
||||||
|
return unit != null && !unit.getClass().equals(Void.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValuePresent(){
|
||||||
|
return value != null ;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(TimeSeriesBean<T, T1> o) {
|
public int compareTo(TimeSeriesBean<T, T1> o) {
|
||||||
return (int) (this.year - o.year); // ascending.. low to highest
|
return (int) (this.year - o.year); // ascending.. low to highest
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,7 +195,6 @@ public class CommonServiceUtils {
|
||||||
// check if it is a time series, in this take the last X elements
|
// check if it is a time series, in this take the last X elements
|
||||||
if(asList.get(0).getClass().equals(TimeSeriesBean.class)){
|
if(asList.get(0).getClass().equals(TimeSeriesBean.class)){
|
||||||
elementsToConsider = Math.min(elementsToConsider, TIME_SERIES_TAKE_LAST_VALUES);
|
elementsToConsider = Math.min(elementsToConsider, TIME_SERIES_TAKE_LAST_VALUES);
|
||||||
|
|
||||||
for (int i = (asList.size() - elementsToConsider); i < asList.size(); i++) {
|
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(REGEX_TAGS, "");
|
||||||
tags.add(finalTag);
|
tags.add(finalTag);
|
||||||
|
@ -271,7 +270,7 @@ public class CommonServiceUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the record among the source group (check for grsf-group)
|
// add the record among the source group (check for grsf-group)
|
||||||
groups.add(source.equals(Sources.GRSF) ? "grsf-group" : source.getOrigName().toLowerCase());
|
groups.add(source.equals(Sources.GRSF) ? CommonServiceUtils.GRSF_GROUP_NAME : source.getOrigName().toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -505,12 +505,12 @@ public class GrsfPublisherFisheryService {
|
||||||
contextServlet, false);
|
contextServlet, false);
|
||||||
status = Status.OK;
|
status = Status.OK;
|
||||||
}else{
|
}else{
|
||||||
status = Status.INTERNAL_SERVER_ERROR;
|
|
||||||
throw new Exception("There was an error during the item updated, sorry");
|
throw new Exception("There was an error during the item updated, sorry");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("Failed to create fishery record" + e);
|
logger.error("Failed to create fishery record" + e);
|
||||||
|
status = Status.INTERNAL_SERVER_ERROR;
|
||||||
responseBean.setError(e.getMessage());
|
responseBean.setError(e.getMessage());
|
||||||
}
|
}
|
||||||
return Response.status(status).entity(responseBean).build();
|
return Response.status(status).entity(responseBean).build();
|
||||||
|
|
|
@ -513,12 +513,12 @@ public class GrsfPublisherStockService {
|
||||||
status = Status.OK;
|
status = Status.OK;
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
status = Status.INTERNAL_SERVER_ERROR;
|
|
||||||
throw new Exception("There was an error during the item updated, sorry");
|
throw new Exception("There was an error during the item updated, sorry");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("Failed to create fishery record" + e);
|
logger.error("Failed to create fishery record" + e);
|
||||||
|
status = Status.INTERNAL_SERVER_ERROR;
|
||||||
responseBean.setError(e.getMessage());
|
responseBean.setError(e.getMessage());
|
||||||
}
|
}
|
||||||
return Response.status(status).entity(responseBean).build();
|
return Response.status(status).entity(responseBean).build();
|
||||||
|
|
|
@ -21,9 +21,6 @@ public class CSVHelpers {
|
||||||
private static final String UPLOAD_LOCATION_LOCAL = System.getProperty("java.io.tmpdir");
|
private static final String UPLOAD_LOCATION_LOCAL = System.getProperty("java.io.tmpdir");
|
||||||
private static final String GRSF_SUB_PATH = "GRSF_TIME_SERIES";
|
private static final String GRSF_SUB_PATH = "GRSF_TIME_SERIES";
|
||||||
public static final String CSV_EXTENSION = ".csv";
|
public static final String CSV_EXTENSION = ".csv";
|
||||||
private static final String YEAR_FIELD = "year";
|
|
||||||
private static final String VALUE_FIELD = "value";
|
|
||||||
private static final String UNIT_FIELD = "unit";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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>
|
||||||
|
@ -47,23 +44,30 @@ public class CSVHelpers {
|
||||||
FileOutputStream fo = new FileOutputStream(file);
|
FileOutputStream fo = new FileOutputStream(file);
|
||||||
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fo, "UTF-8"));
|
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fo, "UTF-8"));
|
||||||
|
|
||||||
boolean isUnitPresent = false;
|
// discover how the header will look like
|
||||||
|
boolean isUnitPresent = timeSeries.get(0).isUnitPresent();
|
||||||
|
boolean isValuePresent = timeSeries.get(0).isValuePresent();
|
||||||
|
boolean isSourcePresent = timeSeries.get(0).isSourcePresent();
|
||||||
|
|
||||||
StringBuffer headerLine = new StringBuffer();
|
StringBuffer headerLine = new StringBuffer();
|
||||||
|
headerLine.append(TimeSeriesBean.YEAR_FIELD);
|
||||||
|
|
||||||
headerLine.append(YEAR_FIELD);
|
if(isValuePresent){
|
||||||
headerLine.append(CSV_SEPARATOR);
|
|
||||||
headerLine.append(VALUE_FIELD);
|
|
||||||
|
|
||||||
// first line is csv header, check the type of object
|
|
||||||
if(timeSeries.get(0).getUnit() != null && !timeSeries.get(0).getUnit().getClass().equals(Void.class)){
|
|
||||||
|
|
||||||
isUnitPresent = true;
|
|
||||||
headerLine.append(CSV_SEPARATOR);
|
headerLine.append(CSV_SEPARATOR);
|
||||||
headerLine.append(UNIT_FIELD);
|
headerLine.append(TimeSeriesBean.VALUE_FIELD);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isUnitPresent){
|
||||||
|
headerLine.append(CSV_SEPARATOR);
|
||||||
|
headerLine.append(TimeSeriesBean.UNIT_FIELD);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isSourcePresent){
|
||||||
|
headerLine.append(CSV_SEPARATOR);
|
||||||
|
headerLine.append(TimeSeriesBean.SOURCE_FIELD);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bw.write(headerLine.toString());
|
bw.write(headerLine.toString());
|
||||||
bw.newLine();
|
bw.newLine();
|
||||||
bw.flush();
|
bw.flush();
|
||||||
|
@ -73,21 +77,29 @@ public class CSVHelpers {
|
||||||
{
|
{
|
||||||
StringBuffer oneLine = new StringBuffer();
|
StringBuffer oneLine = new StringBuffer();
|
||||||
oneLine.append(bean.getYear());
|
oneLine.append(bean.getYear());
|
||||||
oneLine.append(CSV_SEPARATOR);
|
|
||||||
oneLine.append(bean.getValue());
|
if(isValuePresent){
|
||||||
|
oneLine.append(CSV_SEPARATOR);
|
||||||
|
oneLine.append(bean.getValue() != null? bean.getValue() : "");
|
||||||
|
}
|
||||||
|
|
||||||
if(isUnitPresent){
|
if(isUnitPresent){
|
||||||
oneLine.append(CSV_SEPARATOR);
|
oneLine.append(CSV_SEPARATOR);
|
||||||
oneLine.append(bean.getUnit() != null? bean.getUnit() : "");
|
oneLine.append(bean.getUnit() != null? bean.getUnit() : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isSourcePresent){
|
||||||
|
oneLine.append(CSV_SEPARATOR);
|
||||||
|
oneLine.append(bean.getSource() != null? bean.getSource() : "");
|
||||||
|
}
|
||||||
|
|
||||||
bw.write(oneLine.toString());
|
bw.write(oneLine.toString());
|
||||||
bw.newLine();
|
bw.newLine();
|
||||||
|
bw.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
bw.flush();
|
|
||||||
bw.close();
|
bw.close();
|
||||||
|
|
||||||
// file created
|
// file created
|
||||||
logger.debug("CSV file created correctly on this machine!");
|
logger.debug("CSV file created correctly on this machine!");
|
||||||
|
|
||||||
|
@ -100,4 +112,5 @@ public class CSVHelpers {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.data_catalogue.grsf_publish_ws;
|
package org.gcube.data_catalogue.grsf_publish_ws;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import javax.ws.rs.client.Entity;
|
import javax.ws.rs.client.Entity;
|
||||||
import javax.ws.rs.core.Application;
|
import javax.ws.rs.core.Application;
|
||||||
|
@ -34,7 +35,7 @@ public class JJerseyTest extends JerseyTest{
|
||||||
recordFishery.setAuthor("Costantino Perciante");
|
recordFishery.setAuthor("Costantino Perciante");
|
||||||
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(Arrays.asList("data owner"));
|
||||||
recordFishery.setType(Fishery_Type.Fishing_Description);
|
recordFishery.setType(Fishery_Type.Fishing_Description);
|
||||||
recordFishery.setDatabaseSources(new ArrayList<Resource<Sources>>(1));
|
recordFishery.setDatabaseSources(new ArrayList<Resource<Sources>>(1));
|
||||||
recordFishery.setSourceOfInformation(new ArrayList<Resource<String>>(1));
|
recordFishery.setSourceOfInformation(new ArrayList<Resource<String>>(1));
|
||||||
|
|
|
@ -225,60 +225,11 @@ public class JTests {
|
||||||
|
|
||||||
// time series
|
// time series
|
||||||
List<TimeSeriesBean<String, Void>> timeSeries = new ArrayList<TimeSeriesBean<String,Void>>();
|
List<TimeSeriesBean<String, Void>> timeSeries = new ArrayList<TimeSeriesBean<String,Void>>();
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value A", 2001L, null));
|
timeSeries.add(new TimeSeriesBean<String, Void>(2001L, "Value A", null, null));
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value B", 2231L, null));
|
timeSeries.add(new TimeSeriesBean<String, Void>(2231L, "Value B", null, null));
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value C", 1943L, null));
|
timeSeries.add(new TimeSeriesBean<String, Void>(1943L, "Value C", null, null));
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value D", 1054L, null));
|
timeSeries.add(new TimeSeriesBean<String, Void>(1054L, "Value D", null, null));
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value E", 3422L, null));
|
timeSeries.add(new TimeSeriesBean<String, Void>(3422L, "Value E", null, null));
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value F", 2121L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value G", 2454L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value H", 1213L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value I", 2213L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value A", 2001L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value B", 2231L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value C", 1943L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value D", 1054L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value E", 3422L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value F", 2121L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value G", 2454L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value H", 1213L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value I", 2213L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value A", 2001L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value B", 2231L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value C", 1943L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value D", 1054L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value E", 3422L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value F", 2121L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value G", 2454L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value H", 1213L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value I", 2213L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value A", 2001L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value B", 2231L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value C", 1943L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value D", 1054L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value E", 3422L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value F", 2121L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value G", 2454L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value H", 1213L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value I", 2213L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value A", 2001L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value B", 2231L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value C", 1943L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value D", 1054L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value E", 3422L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value F", 2121L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value G", 2454L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value H", 1213L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value I", 2213L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value A", 2001L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value B", 2231L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value C", 1943L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value D", 1054L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value E", 3422L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value F", 2121L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value G", 2454L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value H", 1213L, null));
|
|
||||||
timeSeries.add(new TimeSeriesBean<String, Void>("Value I", 2213L, null));
|
|
||||||
|
|
||||||
Collections.sort(timeSeries);
|
Collections.sort(timeSeries);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue