View Javadoc
1   package de.dlr.shepard.timeseries.model;
2   
3   import com.fasterxml.jackson.annotation.JsonIgnore;
4   import de.dlr.shepard.timeseries.model.enums.ExperimentalDataPointValueType;
5   import jakarta.persistence.Column;
6   import jakarta.persistence.Entity;
7   import jakarta.persistence.EnumType;
8   import jakarta.persistence.Enumerated;
9   import jakarta.persistence.GeneratedValue;
10  import jakarta.persistence.GenerationType;
11  import jakarta.persistence.Id;
12  import jakarta.persistence.Table;
13  
14  @Entity
15  @Table(name = "timeseries")
16  public class ExperimentalTimeseriesEntity {
17  
18    @Id
19    @GeneratedValue(strategy = GenerationType.IDENTITY)
20    private int id;
21  
22    @Column(name = "container_id", nullable = false)
23    private long containerId;
24  
25    @Column(columnDefinition = "TEXT", nullable = false)
26    private String measurement;
27  
28    @Column(columnDefinition = "TEXT", nullable = false)
29    private String field;
30  
31    @Column(columnDefinition = "TEXT", nullable = false)
32    private String device;
33  
34    @Column(columnDefinition = "TEXT", nullable = false)
35    private String location;
36  
37    @Column(name = "symbolic_name", columnDefinition = "TEXT", nullable = false)
38    private String symbolicName;
39  
40    @Enumerated(EnumType.STRING)
41    @Column(name = "value_type", columnDefinition = "TEXT", nullable = false)
42    private ExperimentalDataPointValueType valueType;
43  
44    public ExperimentalTimeseriesEntity() {}
45  
46    public ExperimentalTimeseriesEntity(
47      long containerId,
48      String measurement,
49      String field,
50      String device,
51      String location,
52      String symbolicName,
53      ExperimentalDataPointValueType valueType
54    ) {
55      this.containerId = containerId;
56      this.measurement = measurement;
57      this.field = field;
58      this.device = device;
59      this.location = location;
60      this.symbolicName = symbolicName;
61      this.valueType = valueType;
62    }
63  
64    public ExperimentalTimeseriesEntity(
65      long containerId,
66      ExperimentalTimeseries timeseries,
67      ExperimentalDataPointValueType valueType
68    ) {
69      this(
70        containerId,
71        timeseries.getMeasurement(),
72        timeseries.getField(),
73        timeseries.getDevice(),
74        timeseries.getLocation(),
75        timeseries.getSymbolicName(),
76        valueType
77      );
78    }
79  
80    public int getId() {
81      return id;
82    }
83  
84    public String getMeasurement() {
85      return measurement;
86    }
87  
88    public long getContainerId() {
89      return containerId;
90    }
91  
92    public String getDevice() {
93      return device;
94    }
95  
96    public String getLocation() {
97      return location;
98    }
99  
100   public String getSymbolicName() {
101     return symbolicName;
102   }
103 
104   public String getField() {
105     return field;
106   }
107 
108   public ExperimentalDataPointValueType getValueType() {
109     return valueType;
110   }
111 
112   @JsonIgnore
113   public String getUniqueId() {
114     return String.join("-", measurement, device, location, symbolicName, field, valueType.toString());
115   }
116 }