package de.avatic.taric.model;

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

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import de.avatic.taric.serializer.CertificateTypeReferenceSerializer;
import de.avatic.taric.serializer.DescSetSerializer;
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 jakarta.validation.constraints.Size;

@Getter
@Setter
public class Certificate {

	@Id
    @JsonIgnore
    private Integer id;

    @Size(max = 4)
    private String certificateCode;

    private LocalDate startDate;

    private LocalDate endDate;

    @NotNull
    @Column("certificate_type_id")
    @JsonSerialize(using = CertificateTypeReferenceSerializer.class)
    private AggregateReference<CertificateType, Integer> certificateType;
    
    @MappedCollection(idColumn = "ref_id")
    @JsonSerialize(using = DescSetSerializer.class)
    private Set<CertificateDesc> certificateDesc;



}
