1 package de.dlr.shepard.data.spatialdata.model;
2
3 import de.dlr.shepard.data.spatialdata.repositories.SpatialDataPointRepository;
4 import jakarta.persistence.Column;
5 import jakarta.persistence.Entity;
6 import jakarta.persistence.GeneratedValue;
7 import jakarta.persistence.GenerationType;
8 import jakarta.persistence.Id;
9 import jakarta.persistence.Table;
10 import java.util.Map;
11 import lombok.EqualsAndHashCode;
12 import lombok.Getter;
13 import lombok.Setter;
14 import org.hibernate.annotations.JdbcTypeCode;
15 import org.hibernate.type.SqlTypes;
16 import org.locationtech.jts.geom.Geometry;
17
18 @Getter
19 @Setter
20 @EqualsAndHashCode(exclude = "id")
21 @Entity
22 @Table(name = SpatialDataPointRepository.SPATIAL_TABLE_NAME)
23 public class SpatialDataPoint {
24
25 @Id
26 @GeneratedValue(strategy = GenerationType.IDENTITY)
27 private Long id;
28
29 @Column(name = SpatialDataPointRepository.SPATIAL_COLUMN_CONTAINER_ID)
30 private Long containerId;
31
32
33 private Long time;
34
35
36
37
38
39
40
41
42 private Geometry position;
43
44
45
46
47
48
49 @Column(columnDefinition = "jsonb")
50 @JdbcTypeCode(SqlTypes.JSON)
51 private Map<String, Object> metadata;
52
53
54
55
56
57
58
59 @Column(columnDefinition = "jsonb")
60 @JdbcTypeCode(SqlTypes.JSON)
61 private Map<String, Object> measurements;
62
63 public SpatialDataPoint() {}
64
65 public SpatialDataPoint(
66 Long id,
67 Long containerId,
68 Long time,
69 Geometry position,
70 Map<String, Object> metadata,
71 Map<String, Object> measurements
72 ) {
73 this.id = id;
74 this.containerId = containerId;
75 this.time = time;
76 this.position = position;
77 this.metadata = metadata;
78 this.measurements = measurements;
79 }
80
81 public SpatialDataPoint(
82 Long containerId,
83 Long time,
84 Geometry position,
85 Map<String, Object> metadata,
86 Map<String, Object> measurements
87 ) {
88 this(null, containerId, time, position, metadata, measurements);
89 }
90 }