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


public class Certificate {

	@Id
    private Integer id;

    @Size(max = 4)
    private String certificateCode;

    private LocalDate startDate;

    private LocalDate endDate;

    @NotNull
    @Column("certificate_type_id")
    private AggregateReference<CertificateType, Integer> certificateType;
    
    @MappedCollection(idColumn = "ref_id")
    private Set<CertificateDesc> certificateDesc;

    public Certificate(String certificateCode, LocalDate startDate, LocalDate endDate, AggregateReference<CertificateType, Integer> certificateType) {
		this.certificateCode = certificateCode;
		this.startDate = startDate;
		this.endDate = endDate;
		this.certificateType = certificateType;
		this.certificateDesc = new HashSet<>();
	}

	public Integer getId() {
        return id;
    }

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

    public String getCertificateCode() {
        return certificateCode;
    }

    public void setCertificateCode(final String certificateCode) {
        this.certificateCode = certificateCode;
    }

    public LocalDate getStartDate() {
        return startDate;
    }

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

    public LocalDate getEndDate() {
        return endDate;
    }

    public void setEndDate(final LocalDate endDate) {
        this.endDate = endDate;
    }

    public AggregateReference<CertificateType, Integer> getCertificateType() {
        return certificateType;
    }

    public void setCertificateType(final AggregateReference<CertificateType, Integer> certificateType) {
        this.certificateType = certificateType;
    }

	public void addCertificateDesc(CertificateDesc certificateDesc) {
		this.certificateDesc.add(certificateDesc);
		
	}

}
