1 package de.dlr.shepard.data.timeseries.model; 2 3 import com.fasterxml.jackson.annotation.JsonIgnore; 4 import de.dlr.shepard.data.timeseries.model.enums.DataPointValueType; 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 TimeseriesEntity { 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 DataPointValueType valueType; 43 44 public TimeseriesEntity() {} 45 46 public TimeseriesEntity( 47 long containerId, 48 String measurement, 49 String field, 50 String device, 51 String location, 52 String symbolicName, 53 DataPointValueType 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 TimeseriesEntity(long containerId, Timeseries timeseries, DataPointValueType valueType) { 65 this( 66 containerId, 67 timeseries.getMeasurement(), 68 timeseries.getField(), 69 timeseries.getDevice(), 70 timeseries.getLocation(), 71 timeseries.getSymbolicName(), 72 valueType 73 ); 74 } 75 76 public int getId() { 77 return id; 78 } 79 80 public String getMeasurement() { 81 return measurement; 82 } 83 84 public long getContainerId() { 85 return containerId; 86 } 87 88 public String getDevice() { 89 return device; 90 } 91 92 public String getLocation() { 93 return location; 94 } 95 96 public String getSymbolicName() { 97 return symbolicName; 98 } 99 100 public String getField() { 101 return field; 102 } 103 104 public DataPointValueType getValueType() { 105 return valueType; 106 } 107 108 @JsonIgnore 109 public String getUniqueId() { 110 return String.join("-", measurement, device, location, symbolicName, field, valueType.toString()); 111 } 112 }