From 52ec939c73e020c1eca80a175922e22f20816f61 Mon Sep 17 00:00:00 2001 From: lewa <lene.wasskog@nibio.no> Date: Thu, 4 Apr 2024 12:27:00 +0200 Subject: [PATCH] feat: Add year to ObservationTimeSeries --- .../logic/entity/ObservationTimeSeries.java | 28 +++++++++++++------ .../service/ObservationTimeSeriesService.java | 3 ++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/main/java/no/nibio/vips/logic/entity/ObservationTimeSeries.java b/src/main/java/no/nibio/vips/logic/entity/ObservationTimeSeries.java index 3dae29a0..5bcef892 100644 --- a/src/main/java/no/nibio/vips/logic/entity/ObservationTimeSeries.java +++ b/src/main/java/no/nibio/vips/logic/entity/ObservationTimeSeries.java @@ -46,6 +46,7 @@ public class ObservationTimeSeries implements Serializable, no.nibio.vips.observ private Integer observationTimeSeriesId; private Organism cropOrganism; private Organism organism; + private Integer year; private String name; private String description; private Date created; @@ -139,6 +140,21 @@ public class ObservationTimeSeries implements Serializable, no.nibio.vips.observ return this.getOrganism() != null ? this.getOrganism().getOrganismId() : null; } + /** + * @return the year of the observation time series + */ + @Column(name = "year") + public Integer getYear() { + return year; + } + + /** + * @param year the observation time series year to set + */ + public void setYear(Integer year) { + this.year = year; + } + /** * @return the name of the observation time series */ @@ -351,13 +367,6 @@ public class ObservationTimeSeries implements Serializable, no.nibio.vips.observ this.polygonService = polygonService; } - @Override - @Transient - public Date getTimeOfLastObservation() { - // TODO Find date of latest observation within series - return new Date(); - } - @Override public int hashCode() { int hash = 0; @@ -379,6 +388,7 @@ public class ObservationTimeSeries implements Serializable, no.nibio.vips.observ "observationTimeSeriesId=" + observationTimeSeriesId + ", cropOrganism=" + cropOrganism + ", organism=" + organism + + ", year=" + year + ", name='" + name + '\'' + ", description='" + description + '\'' + ", created=" + created + @@ -399,8 +409,8 @@ public class ObservationTimeSeries implements Serializable, no.nibio.vips.observ @Override public int compareTo(no.nibio.vips.observation.ObservationTimeSeries other) { - if (this.getTimeOfLastObservation() != null && other.getTimeOfLastObservation() != null) { - return other.getTimeOfLastObservation().compareTo(this.getTimeOfLastObservation()); + if (this.getYear() != null && other.getYear() != null) { + return other.getYear().compareTo(this.getYear()); } return this.getName().compareTo(other.getName()); } diff --git a/src/main/java/no/nibio/vips/logic/service/ObservationTimeSeriesService.java b/src/main/java/no/nibio/vips/logic/service/ObservationTimeSeriesService.java index 07e7e455..e074ee6f 100644 --- a/src/main/java/no/nibio/vips/logic/service/ObservationTimeSeriesService.java +++ b/src/main/java/no/nibio/vips/logic/service/ObservationTimeSeriesService.java @@ -13,6 +13,7 @@ import no.nibio.vips.logic.entity.VipsLogicUser; import no.nibio.vips.logic.entity.rest.PointMappingResponse; import no.nibio.vips.logic.entity.rest.ReferencedPoint; import no.nibio.vips.logic.util.GISEntityUtil; +import no.nibio.vips.logic.util.SystemTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.wololo.geojson.Feature; @@ -43,6 +44,7 @@ public class ObservationTimeSeriesService { private static final String CROP_ORGANISM_ID = "cropOrganismId"; private static final String USER_ID = "userId"; private static final String LOCATION_POINT_OF_INTEREST_ID = "locationPointOfInterestId"; + private static final String YEAR = "year"; private static final String NAME = "name"; private static final String DESCRIPTION = "description"; private static final String LOCATION_IS_PRIVATE = "locationIsPrivate"; @@ -221,6 +223,7 @@ public class ObservationTimeSeriesService { otsToSave.setOrganism(organismBean.getOrganism(getValueFromMap(mapFromApp, ORGANISM_ID, Integer.class))); otsToSave.setGeoInfoList(getValueFromMap(mapFromApp, GEO_INFO, String.class)); otsToSave.setLocationPointOfInterestId(getValueFromMap(mapFromApp, LOCATION_POINT_OF_INTEREST_ID, Integer.class)); + otsToSave.setYear(getValueFromMap(mapFromApp, YEAR, Integer.class)); otsToSave.setName(getValueFromMap(mapFromApp, NAME, String.class)); otsToSave.setDescription(getValueFromMap(mapFromApp, DESCRIPTION, String.class)); otsToSave.setLocationIsPrivate(getValueFromMap(mapFromApp, LOCATION_IS_PRIVATE, Boolean.class)); -- GitLab