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.relational.core.mapping.MappedCollection;

import com.fasterxml.jackson.annotation.JsonProperty;

import jakarta.validation.constraints.Size;


public class Nomenclature {

	@Id
    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")
    private Set<NomenclatureDesc> nomenclatureDescs;
    
    @MappedCollection(idColumn = "nomenclature_id")
    private Set<NomenclatureFootnote> footnotes;
    
	public Nomenclature(String hsCode, String suffix, Integer hierachy, Integer indent, LocalDate startDate,
			LocalDate endDate, Boolean isLeaf, LocalDate isLeafStartDate, Integer parentId, Set<NomenclatureFootnote> footnotes) {
		this.hscode = hsCode;
		this.suffix = suffix;
		this.hierachy = hierachy;
		this.indent = indent;
		this.startDate = startDate;
		this.endDate = endDate;
		this.isLeaf = isLeaf;
		this.isLeafStartDate = isLeafStartDate;
		this.parentId = parentId;
		this.footnotes = footnotes;
		this.nomenclatureDescs = new HashSet<>();
	}

    public Integer getId() {
        return id;
    }

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

    public String getHscode() {
        return hscode;
    }

    public void setHscode(final String hscode) {
        this.hscode = hscode;
    }

    public String getSuffix() {
        return suffix;
    }

    public void setSuffix(final String suffix) {
        this.suffix = suffix;
    }

    public Integer getHierachy() {
        return hierachy;
    }

    public void setHierachy(final Integer hierachy) {
        this.hierachy = hierachy;
    }

    public Integer getIndent() {
        return indent;
    }

    public void setIndent(final Integer indent) {
        this.indent = indent;
    }

    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 Boolean getIsLeaf() {
        return isLeaf;
    }

    public void setIsLeaf(final Boolean isLeaf) {
        this.isLeaf = isLeaf;
    }

    public LocalDate getIsLeafStartDate() {
        return isLeafStartDate;
    }

    public void setIsLeafStartDate(final LocalDate isLeafStartDate) {
        this.isLeafStartDate = isLeafStartDate;
    }

    public Integer getParentId() {
        return parentId;
    }

    public void setParentId(final Integer parentId) {
        this.parentId = parentId;
    }

	public void addNomenclatureDesc(NomenclatureDesc nomenclatureDesc) {
		this.nomenclatureDescs.add(nomenclatureDesc);		
	}

}
