package com.ikon.projectmanagement.entity;

import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.type.SqlTypes;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

@Entity
@Table(name = "project_schedule_group")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ProjectScheduleGroup {

    @Id
    @GeneratedValue
    @JdbcTypeCode(SqlTypes.UUID)
    @Column(name = "id")
    private UUID id;

    @Column(name = "group_key", nullable = false)
    private String groupKey;

    @Column(name = "group_name")
    private String groupName;

    @Column(name = "color")
    private String color;

    @ElementCollection
    @CollectionTable(
            name = "project_schedule_group_task",
            joinColumns = @JoinColumn(name = "group_id")
    )
    @Column(name = "task_id")
    @Builder.Default
    private List<Long> taskIds = new ArrayList<>();

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "schedule_identifier", nullable = false)
    private ProjectSchedule schedule;
}
