TimeseriesIO.java

package de.dlr.shepard.data.timeseries.io;

import de.dlr.shepard.data.timeseries.model.Timeseries;
import de.dlr.shepard.data.timeseries.model.enums.DataPointValueType;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.eclipse.microprofile.openapi.annotations.media.Schema;

/**
 * IO-Object relating to a client side Timeseries.
 * It encompasses the timeseries ID, the ID of the associated container, a value type aswell as the tuple identifying
 * a timeseries: measurement, device, location, symbolicName and field.
 *
 */
@Schema(name = "TimeseriesEntity")
@Data
@NoArgsConstructor(force = true) // needed for serialization
public class TimeseriesIO {

  @NotBlank
  private final long id;

  @NotBlank
  private final long containerId;

  @NotBlank
  private final DataPointValueType valueType;

  @NotBlank
  private final String measurement;

  @NotBlank
  private final String device;

  @NotBlank
  private final String location;

  @NotBlank
  private final String symbolicName;

  @NotBlank
  private final String field;

  public TimeseriesIO(Timeseries timeseries) {
    this.id = timeseries.getTimeseriesId();
    this.containerId = timeseries.getContainer().getId();
    this.valueType = timeseries.getValueType();
    this.measurement = timeseries.getTimeseriesTuple().getMeasurement();
    this.device = timeseries.getTimeseriesTuple().getDevice();
    this.location = timeseries.getTimeseriesTuple().getLocation();
    this.symbolicName = timeseries.getTimeseriesTuple().getSymbolicName();
    this.field = timeseries.getTimeseriesTuple().getField();
  }
}