package de.avatic.taric.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import de.avatic.taric.serializer.DescSetSerializer;
import de.avatic.taric.serializer.MeasureSeriesReferenceSerializer;
import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.jdbc.core.mapping.AggregateReference;
import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.MappedCollection;
import org.springframework.data.relational.core.mapping.Table;

import java.time.LocalDate;
import java.util.Set;


@Setter
@Getter
@Table("measure")
public class Measure {

	@Id
    @JsonIgnore
    private Integer id;

    @Size(max = 3)
    private String measureCode;

    private String shortDesc;

    private Integer tmCode;

    @Column("start_date")
    private LocalDate startDate;

    @MappedCollection(idColumn = "ref_id")
    @JsonSerialize(using = DescSetSerializer.class)
    private Set<MeasureDesc> measureDesc;

    @Column("measure_series_id")
    @JsonSerialize(using = MeasureSeriesReferenceSerializer.class)
    AggregateReference<MeasureSeries, Integer> measureSeries;

}
