package com.oguerreiro.resilient.service.dto;

import java.time.Instant;

import com.oguerreiro.resilient.domain.enumeration.UploadStatus;
import com.oguerreiro.resilient.domain.enumeration.UploadType;

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

/**
 * A DTO for the {@link com.oguerreiro.resilient.domain.InputDataUpload} entity.
 */
@Schema(description = "Input data upload file\nUsers can upload an Excel file with InputData that will automatically insert values in the table InputData")
public class InputDataUploadDTO extends ActivityDomainDTO<Long> {
  private static final long serialVersionUID = 1L;

  @NotNull
  @Schema(description = "A simple text with a title, for human reference and better relation", requiredMode = Schema.RequiredMode.REQUIRED)
  private String title;

  @Schema(description = "An Excel file, that must match a template for input", requiredMode = Schema.RequiredMode.REQUIRED)
  @Lob
  private byte[] dataFile;

  private String dataFileContentType;

  @Schema(description = "The name of the uploaded Excel file")
  private String uploadFileName;

  @Schema(description = "The generated name of the Excel file, used to save to disk")
  private String diskFileName;

  @NotNull
  @Schema(description = "Type of the Upload", requiredMode = Schema.RequiredMode.REQUIRED)
  private UploadType type;

  @Schema(description = "State of the Upload")
  private UploadStatus state;

  @Schema(description = "Optional comments")
  private String comments;

  @Schema(description = "The creation date (insert). When the data was inserted into the system.")
  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.")
  private String creationUsername;

  private PeriodDTO period;

  private PeriodVersionDTO periodVersion;

  private OrganizationDTO owner;

  public String getTitle() {
    return title;
  }

  public void setTitle(String title) {
    this.title = title;
  }

  public byte[] getDataFile() {
    return dataFile;
  }

  public void setDataFile(byte[] dataFile) {
    this.dataFile = dataFile;
  }

  public String getDataFileContentType() {
    return dataFileContentType;
  }

  public void setDataFileContentType(String dataFileContentType) {
    this.dataFileContentType = dataFileContentType;
  }

  public String getUploadFileName() {
    return uploadFileName;
  }

  public void setUploadFileName(String uploadFileName) {
    this.uploadFileName = uploadFileName;
  }

  public String getDiskFileName() {
    return diskFileName;
  }

  public void setDiskFileName(String diskFileName) {
    this.diskFileName = diskFileName;
  }

  public UploadType getType() {
    return type;
  }

  public void setType(UploadType type) {
    this.type = type;
  }

  public UploadStatus getState() {
    return state;
  }

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

  public String getComments() {
    return comments;
  }

  public void setComments(String comments) {
    this.comments = comments;
  }

  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 PeriodDTO getPeriod() {
    return period;
  }

  public void setPeriod(PeriodDTO period) {
    this.period = period;
  }

  public PeriodVersionDTO getPeriodVersion() {
    return periodVersion;
  }

  public void setPeriodVersion(PeriodVersionDTO periodVersion) {
    this.periodVersion = periodVersion;
  }

  public OrganizationDTO getOwner() {
    return owner;
  }

  public void setOwner(OrganizationDTO owner) {
    this.owner = owner;
  }

//@formatter:off
  @Override
  public String toString() {
    return "InputDataUploadDTO{" + 
              "id=" + getId() + 
              ", title='" + getTitle() + "'" + 
              ", dataFile='" + getDataFile() + "'" + 
              ", uploadFileName='" + getUploadFileName() + "'" + 
              ", diskFileName='" + getDiskFileName() + "'" + 
              ", type='" + getType() + "'" + 
              ", state='" + getState() + "'" + 
              ", comments='" + getComments() + "'" + 
              ", creationDate='" + getCreationDate() + "'" + 
              ", creationUsername='" + getCreationUsername() + "'" +  
              ", period=" + getPeriod() + 
              ", periodVersion=" + getPeriodVersion() + 
              ", owner=" + getOwner() + 
              ", version=" + getVersion() + 
           "}";
  }
//@formatter:on
}
