package com.davos.assessment.assessment;

import com.davos.assessment.user.AppUser;
import com.davos.assessment.project.Project;
import jakarta.persistence.*;
import java.time.Instant;

@Entity
@Table(name = "user_assessment_access")
public class UserAssessmentAccess {
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Long id;

  @ManyToOne(optional = false, fetch = FetchType.LAZY)
  @JoinColumn(name = "user_id", nullable = false)
  private AppUser user;

  @ManyToOne(optional = false, fetch = FetchType.LAZY)
  @JoinColumn(name = "project_id", nullable = false)
  private Project project;

  @ManyToOne(optional = false, fetch = FetchType.LAZY)
  @JoinColumn(name = "assessment_id", nullable = false)
  private Assessment assessment;

  @Column(name = "can_retake", nullable = false)
  private boolean canRetake = false;

  @Column(name = "reopened_at")
  private Instant reopenedAt;

  @Column(name = "reopen_note")
  private String reopenNote = "";

  public Long getId() { return id; }
  public Project getProject() { return project; }
  public void setProject(Project project) { this.project = project; }
  public AppUser getUser() { return user; }
  public void setUser(AppUser user) { this.user = user; }
  public Assessment getAssessment() { return assessment; }
  public void setAssessment(Assessment assessment) { this.assessment = assessment; }
  public boolean isCanRetake() { return canRetake; }
  public void setCanRetake(boolean canRetake) { this.canRetake = canRetake; }
  public Instant getReopenedAt() { return reopenedAt; }
  public void setReopenedAt(Instant reopenedAt) { this.reopenedAt = reopenedAt; }
  public String getReopenNote() { return reopenNote; }
  public void setReopenNote(String reopenNote) { this.reopenNote = reopenNote; }
}
