package com.oguerreiro.resilient.service.dto;

import java.time.Instant;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

import com.oguerreiro.resilient.domain.enumeration.PeriodStatus;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;

/**
 * A DTO for the {@link com.oguerreiro.resilient.domain.Period} entity.
 */
@Schema(description = "Period")
public class PeriodDTO extends ActivityDomainDTO<Long> {
  private static final long serialVersionUID = 1L;

  @NotNull
  @Schema(description = "Name of the period", requiredMode = Schema.RequiredMode.REQUIRED)
  private String name;

  @Schema(description = "Description for the period")
  private String description;

  @NotNull
  @Schema(description = "Period start date", requiredMode = Schema.RequiredMode.REQUIRED)
  private LocalDate beginDate;

  @NotNull
  @Schema(description = "Period end date", requiredMode = Schema.RequiredMode.REQUIRED)
  private LocalDate endDate;

  @Schema(description = "State of the Period", requiredMode = Schema.RequiredMode.REQUIRED)
  private PeriodStatus state;

  @Schema(description = "The creation date (insert). When the data was inserted into the system.", requiredMode = Schema.RequiredMode.REQUIRED)
  private Instant creationDate;

  @Schema(description = "The actual username logged into the system, that inserted the data. NOT a reference to the user, but the login username.", requiredMode = Schema.RequiredMode.REQUIRED)
  private String creationUsername;

  private List<PeriodVersionDTO> periodVersions = new ArrayList<>();

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getDescription() {
    return description;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public LocalDate getBeginDate() {
    return beginDate;
  }

  public void setBeginDate(LocalDate beginDate) {
    this.beginDate = beginDate;
  }

  public LocalDate getEndDate() {
    return endDate;
  }

  public void setEndDate(LocalDate endDate) {
    this.endDate = endDate;
  }

  public PeriodStatus getState() {
    return state;
  }

  public void setState(PeriodStatus state) {
    this.state = state;
  }

  public Instant getCreationDate() {
    return creationDate;
  }

  public void setCreationDate(Instant creationDate) {
    this.creationDate = creationDate;
  }

  public String getCreationUsername() {
    return creationUsername;
  }

  public void setCreationUsername(String creationUsername) {
    this.creationUsername = creationUsername;
  }

  public List<PeriodVersionDTO> getPeriodVersions() {
    return periodVersions;
  }

  public void setPeriodVersions(List<PeriodVersionDTO> periodVersions) {
    this.periodVersions = periodVersions;
  }

  //@formatter:off
  @Override
  public String toString() {
    return "PeriodDTO{" +
        "id=" + getId() +
        ", name='" + getName() + "'" +
        ", description='" + getDescription() + "'" +
        ", beginDate='" + getBeginDate() + "'" +
        ", endDate='" + getEndDate() + "'" +
        ", state='" + getState() + "'" +
        ", creationDate='" + getCreationDate() + "'" +
        ", creationUsername='" + getCreationUsername() + "'" +
        ", periodVersions=" + getPeriodVersions() +
        ", version=" + getVersion() +
        "}";
    }
  //@formatter:on
}
