package de.fete.adapter.out.persistence;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.UUID;

/** JPA entity mapping to the events table. */
@Entity
@Table(name = "events")
public class EventJpaEntity {

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Long id;

  @Column(name = "event_token", nullable = false, unique = true)
  private UUID eventToken;

  @Column(name = "organizer_token", nullable = false, unique = true)
  private UUID organizerToken;

  @Column(nullable = false, length = 200)
  private String title;

  @Column(length = 2000)
  private String description;

  @Column(name = "date_time", nullable = false)
  private OffsetDateTime dateTime;

  @Column(nullable = false, length = 64)
  private String timezone;

  @Column(length = 500)
  private String location;

  @Column(name = "expiry_date", nullable = false)
  private LocalDate expiryDate;

  @Column(name = "created_at", nullable = false)
  private OffsetDateTime createdAt;

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

  @Column(name = "cancellation_reason", length = 2000)
  private String cancellationReason;

  /** Returns the internal database ID. */
  public Long getId() {
    return id;
  }

  /** Sets the internal database ID. */
  public void setId(Long id) {
    this.id = id;
  }

  /** Returns the public event token. */
  public UUID getEventToken() {
    return eventToken;
  }

  /** Sets the public event token. */
  public void setEventToken(UUID eventToken) {
    this.eventToken = eventToken;
  }

  /** Returns the secret organizer token. */
  public UUID getOrganizerToken() {
    return organizerToken;
  }

  /** Sets the secret organizer token. */
  public void setOrganizerToken(UUID organizerToken) {
    this.organizerToken = organizerToken;
  }

  /** Returns the event title. */
  public String getTitle() {
    return title;
  }

  /** Sets the event title. */
  public void setTitle(String title) {
    this.title = title;
  }

  /** Returns the event description. */
  public String getDescription() {
    return description;
  }

  /** Sets the event description. */
  public void setDescription(String description) {
    this.description = description;
  }

  /** Returns the event date and time. */
  public OffsetDateTime getDateTime() {
    return dateTime;
  }

  /** Sets the event date and time. */
  public void setDateTime(OffsetDateTime dateTime) {
    this.dateTime = dateTime;
  }

  /** Returns the IANA timezone name. */
  public String getTimezone() {
    return timezone;
  }

  /** Sets the IANA timezone name. */
  public void setTimezone(String timezone) {
    this.timezone = timezone;
  }

  /** Returns the event location. */
  public String getLocation() {
    return location;
  }

  /** Sets the event location. */
  public void setLocation(String location) {
    this.location = location;
  }

  /** Returns the expiry date. */
  public LocalDate getExpiryDate() {
    return expiryDate;
  }

  /** Sets the expiry date. */
  public void setExpiryDate(LocalDate expiryDate) {
    this.expiryDate = expiryDate;
  }

  /** Returns the creation timestamp. */
  public OffsetDateTime getCreatedAt() {
    return createdAt;
  }

  /** Sets the creation timestamp. */
  public void setCreatedAt(OffsetDateTime createdAt) {
    this.createdAt = createdAt;
  }

  /** Returns whether the event is cancelled. */
  public boolean isCancelled() {
    return cancelled;
  }

  /** Sets the cancelled flag. */
  public void setCancelled(boolean cancelled) {
    this.cancelled = cancelled;
  }

  /** Returns the cancellation reason. */
  public String getCancellationReason() {
    return cancellationReason;
  }

  /** Sets the cancellation reason. */
  public void setCancellationReason(String cancellationReason) {
    this.cancellationReason = cancellationReason;
  }
}
