package studycave.studycaverestservice.model.studyGroup;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import studycave.studycaverestservice.model.flashcardset.Set;
import studycave.studycaverestservice.model.studyGroupMember.StudyGroupMember;
import studycave.studycaverestservice.model.test.Test;
import studycave.studycaverestservice.model.userActivity.UserActivity;
import studycave.studycaverestservice.model.material.Material;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class StudyGroup {

    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id;

    private String usosGroupId;

    private String name;

    private String description;

    @Column(unique = true)
    private String groupKey;

    @OneToMany(mappedBy = "group", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    List<StudyGroupMember> members = new ArrayList<>();

    @OneToMany(mappedBy = "group", cascade = CascadeType.ALL)
    List<Set> flashcardSets = new ArrayList<>();

    @OneToMany(mappedBy = "group", cascade = CascadeType.ALL)
    List<Material> materials = new ArrayList<>();

    @OneToMany(mappedBy = "group", cascade = CascadeType.ALL)
    List<Test> tests = new ArrayList<>();

    @OneToMany(mappedBy = "group", cascade = CascadeType.ALL)
    private List<UserActivity> activity = new ArrayList<>();

}
