package org.gcube.data_catalogue.grsf_publish_ws.json.input.others; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; /** * A time series bean that contains elements < year, T, T1 , source >. * Year is the only required element. * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) * @param the first type value of the series * @param the second type value of the series (optional) */ @JsonIgnoreProperties(ignoreUnknown = true) public class TimeSeriesBean implements Comparable>{ public static final String YEAR_FIELD = "reference_year"; public static final String VALUE_FIELD = "value"; public static final String UNIT_FIELD = "unit"; public static final String DB_SOURCE_FIELD = "db_source"; public static final String DATA_OWNER_FIELD = "data_owner"; public static final String ASSESSMENT_FIELD = "reporting_year_or_assessment_id"; @JsonProperty(YEAR_FIELD) private Long year; @JsonProperty(DB_SOURCE_FIELD) private String databaseSource; @JsonProperty(ASSESSMENT_FIELD) private String assessment; @JsonProperty(DATA_OWNER_FIELD) private String dataOwner; @JsonProperty(VALUE_FIELD) private T value; @JsonProperty(UNIT_FIELD) private T1 unit; public TimeSeriesBean() { super(); } /** * @param year * @param databaseSource * @param assessment * @param dataOwner * @param value * @param unit */ public TimeSeriesBean(Long year, String databaseSource, String assessment, String dataOwner, T value, T1 unit) { super(); this.year = year; this.databaseSource = databaseSource; this.assessment = assessment; this.dataOwner = dataOwner; this.value = value; this.unit = unit; } public String getDataOwner() { return dataOwner; } public void setDataOwner(String dataOwner) { this.dataOwner = dataOwner; } public T getValue() { return value; } public void setValue(T value) { this.value = value; } public Long getYear() { return year; } public void setYear(Long year) { this.year = year == null? -1 : year; } public T1 getUnit() { return unit; } public void setUnit(T1 unit) { this.unit = unit; } public String getDatabaseSource() { return databaseSource; } public void setDatabaseSource(String databaseSource) { this.databaseSource = databaseSource; } public String getAssessment() { return assessment; } public void setAssessment(String assessment) { this.assessment = assessment; } public boolean isUnitPresent(){ return unit != null && !unit.getClass().equals(Void.class); } public boolean isSourcePresent(){ return databaseSource != null && !databaseSource.isEmpty(); } public boolean isAssessmentPresent(){ return assessment != null && !assessment.isEmpty(); } public boolean isValuePresent(){ return value != null && !value.getClass().equals(Void.class); } public boolean isDataOwnerPresent(){ return dataOwner != null && !dataOwner.isEmpty(); } @Override public int compareTo(TimeSeriesBean o) { return Long.compare(this.year, o.year); } @Override public String toString() { String value = "" + this.value; String unit = (this.unit != null ? " " + this.unit : ""); String databaseSource = (this.databaseSource != null ? " (" + this.databaseSource + ")" : ""); String dataOwner = (this.dataOwner != null ? " " + this.dataOwner : ""); String referenceYear = year >= 0 ? " Ref. Year " + year : ""; String reportingYearOrAssessment = (assessment != null ? " and Rep. Year or Assessment Id " + assessment + "" : ""); return value + unit + databaseSource + dataOwner + referenceYear + reportingYearOrAssessment; } }