package com.iqser.red.service.persistence.management.v1.processor.entity;

import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.List;

import org.hibernate.annotations.Fetch;
import org.springframework.data.annotation.LastModifiedDate;

import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.DossierTemplateEntity;

import jakarta.persistence.CollectionTable;
import jakarta.persistence.Column;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;

@Data
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "component_mappings")
public class ComponentMappingEntity {

    @Id
    @Column(name = "id")
    String id;

    @NonNull
    @ManyToOne(fetch = FetchType.LAZY)
    private DossierTemplateEntity dossierTemplate;

    @NonNull
    @Builder.Default
    String storageId = "";

    @NonNull
    @Builder.Default
    String name = "";

    @NonNull
    @Builder.Default
    String fileName = "";

    @NonNull
    @Builder.Default
    Integer version = -1;

    @LastModifiedDate
    OffsetDateTime changedDate;

    @NonNull
    @Builder.Default
    @ElementCollection(fetch = FetchType.EAGER)
    @CollectionTable(name = "component_mapping_column_labels")
    List<String> columnLabels = new ArrayList<>();

    @NonNull
    @Builder.Default
    Integer numberOfLines = 0;

    @NonNull
    @Builder.Default
    String encoding = "UTF-8";

    @Builder.Default
    char delimiter = ',';

    @Builder.Default
    char quoteChar = '"';

}
