initial project setup

This commit is contained in:
glenn schrooyen
2025-09-11 22:08:12 +02:00
parent 8cc588dc92
commit 21e4972ab1
46 changed files with 2755 additions and 1 deletions

View File

@@ -0,0 +1,64 @@
package com.labfusion.model;
import jakarta.persistence.*;
import java.time.LocalDateTime;
@Entity
@Table(name = "device_states")
public class DeviceState {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "timestamp", nullable = false)
private LocalDateTime timestamp;
@Column(name = "entity_id", nullable = false)
private String entityId;
@Column(name = "value", columnDefinition = "TEXT")
private String value;
@Column(name = "service", nullable = false)
private String service;
@Column(name = "created_at")
private LocalDateTime createdAt;
@PrePersist
protected void onCreate() {
createdAt = LocalDateTime.now();
if (timestamp == null) {
timestamp = LocalDateTime.now();
}
}
// Constructors
public DeviceState() {}
public DeviceState(String entityId, String value, String service) {
this.entityId = entityId;
this.value = value;
this.service = service;
this.timestamp = LocalDateTime.now();
}
// Getters and Setters
public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
public LocalDateTime getTimestamp() { return timestamp; }
public void setTimestamp(LocalDateTime timestamp) { this.timestamp = timestamp; }
public String getEntityId() { return entityId; }
public void setEntityId(String entityId) { this.entityId = entityId; }
public String getValue() { return value; }
public void setValue(String value) { this.value = value; }
public String getService() { return service; }
public void setService(String service) { this.service = service; }
public LocalDateTime getCreatedAt() { return createdAt; }
public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; }
}