package de.avatic.taricdb.model;

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

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 jakarta.validation.constraints.Size;

@Table("measure")
public class Measure {

	@Id
    private Integer id;

    @Size(max = 3)
    private String measureCode;

    private String shortDesc;

    private Integer tmCode;

    private LocalDate startDate;
    
    @MappedCollection(idColumn = "ref_id")
    private Set<MeasureDesc> measureDesc;
    

    @Column("measure_series_id")
    AggregateReference<MeasureSeries, Integer> measureSeries;   

    public Measure(String code, String shortDesc, Integer tmCode, LocalDate startDate, AggregateReference<MeasureSeries, Integer> measureSeries) {
		this.measureCode = code;
		this.shortDesc = shortDesc;
		this.tmCode = tmCode;
		this.startDate = startDate;	
		this.measureSeries = measureSeries;
		this.measureDesc = new HashSet<>();
	}

	public Integer getId() {
        return id;
    }

    public void setId(final Integer id) {
        this.id = id;
    }

    public String getMeasureCode() {
        return measureCode;
    }

    public void setMeasureCode(final String measureCode) {
        this.measureCode = measureCode;
    }

    public String getShortDesc() {
        return shortDesc;
    }

    public void setShortDesc(final String shortDesc) {
        this.shortDesc = shortDesc;
    }

    public Integer getTmCode() {
        return tmCode;
    }

    public void setTmCode(final Integer tmCode) {
        this.tmCode = tmCode;
    }

    public LocalDate getStartDate() {
        return startDate;
    }

    public void setStartDate(final LocalDate startDate) {
        this.startDate = startDate;
    }

	public void addMeasureDesc(MeasureDesc measureDesc) {
		this.measureDesc.add(measureDesc);
	}

	public AggregateReference<MeasureSeries, Integer> getMeasureSeries() {
		return measureSeries;
	}



}
