package de.avatic.taric.model;

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

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


@Getter
@Setter
@Table("nomenclature")
public class Nomenclature {

	@Id
    @JsonIgnore
    private Integer id;

    @Size(max = 10)
    private String hscode;

    @Size(max = 2)
    private String suffix;

    private Integer hierachy;

    private Integer indent;

    private LocalDate startDate;

    private LocalDate endDate;

    @JsonProperty("isLeaf")
    private Boolean isLeaf;

    private LocalDate isLeafStartDate;

    private Integer parentId;
    
    @MappedCollection(idColumn = "ref_id")
    @JsonSerialize(using = DescSetSerializer.class)
    @JsonProperty("desc")
    private Set<NomenclatureDesc> nomenclatureDescs;
    
    @MappedCollection(idColumn = "nomenclature_id")
    private Set<NomenclatureFootnote> footnotes;

}
