87 lines
1.9 KiB
Java
87 lines
1.9 KiB
Java
package de.ph87.data.plot;
|
|
|
|
import de.ph87.data.plot.axis.Axis;
|
|
import de.ph87.data.series.data.Interval;
|
|
import jakarta.persistence.Column;
|
|
import jakarta.persistence.Entity;
|
|
import jakarta.persistence.EnumType;
|
|
import jakarta.persistence.Enumerated;
|
|
import jakarta.persistence.FetchType;
|
|
import jakarta.persistence.GeneratedValue;
|
|
import jakarta.persistence.GenerationType;
|
|
import jakarta.persistence.Id;
|
|
import jakarta.persistence.OneToMany;
|
|
import jakarta.persistence.Version;
|
|
import lombok.Getter;
|
|
import lombok.NoArgsConstructor;
|
|
import lombok.NonNull;
|
|
import lombok.Setter;
|
|
import lombok.ToString;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
@Entity
|
|
@Getter
|
|
@ToString
|
|
@NoArgsConstructor
|
|
public class Plot {
|
|
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
private long id;
|
|
|
|
@Version
|
|
private long version;
|
|
|
|
@Setter
|
|
@NonNull
|
|
@Column(nullable = false)
|
|
private String name = "";
|
|
|
|
@Setter
|
|
@NonNull
|
|
@Enumerated(EnumType.STRING)
|
|
@Column(nullable = false, name = "`interval`")
|
|
private Interval interval = Interval.FIVE;
|
|
|
|
@Setter
|
|
@Column(nullable = false, name = "`offset`")
|
|
private long offset = 0;
|
|
|
|
@Setter
|
|
@Column(nullable = false)
|
|
private long duration = 1;
|
|
|
|
@Setter
|
|
@Column(nullable = false)
|
|
private boolean dashboard = false;
|
|
|
|
@Setter
|
|
@Column(nullable = false)
|
|
private long position;
|
|
|
|
@NonNull
|
|
@ToString.Exclude
|
|
@OneToMany(mappedBy = "plot", orphanRemoval = true, fetch = FetchType.EAGER)
|
|
private List<Axis> axes = new ArrayList<>();
|
|
|
|
public Plot(final long position) {
|
|
this.position = position;
|
|
}
|
|
|
|
public Plot(@NonNull final Plot plot, final long position) {
|
|
this.name = plot.getName();
|
|
this.interval = plot.getInterval();
|
|
this.offset = plot.getOffset();
|
|
this.duration = plot.getDuration();
|
|
this.dashboard = plot.isDashboard();
|
|
this.position = position;
|
|
}
|
|
|
|
public void addAxis(@NonNull final Axis axis) {
|
|
axes.add(axis);
|
|
}
|
|
|
|
}
|