package de.avatic.taric.model;

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

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import de.avatic.taric.serializer.LegalBaseReferenceSerializer;
import de.avatic.taric.serializer.MeasureReferenceSerializer;
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 jakarta.validation.constraints.NotNull;
import org.springframework.data.relational.core.mapping.Table;

@Getter
@Setter
@Table("applied_measure")
public class AppliedMeasure {

	@Id
    @JsonIgnore
	private Integer id;

    @Column("start_date")
	private LocalDate startDate;

    @Column("end_date")
	private LocalDate endDate;

	private String amount;
	
	@Column("order_number")
	private Integer orderNumber;

	@MappedCollection(idColumn = "applied_measure_id")
	private Set<MeasureFootnote> measureFootnotes;

	@NotNull
	@Column("measure_id")
    @JsonSerialize(using = MeasureReferenceSerializer.class)
	private AggregateReference<Measure, Integer> measure;


	@Column("legal_base_id")
    @JsonSerialize(using = LegalBaseReferenceSerializer.class)
	private AggregateReference<LegalBase, Integer> legalBase;
	
	@Column("legal_base")
    @JsonIgnore
	private String additionalLegalBase;

	@MappedCollection(idColumn = "applied_measure_id")
	private Set<MeasureExclusion> exclusions;

	@MappedCollection(idColumn = "applied_measure_id")
	private Set<AppliedMeasureCondition> conditions;




}
