package com.oguerreiro.resilient.service.dto;

import java.math.BigDecimal;
import java.time.Instant;
import java.time.LocalDate;

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

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

/**
 * A DTO for the {@link com.oguerreiro.resilient.domain.InputData} entity.
 */
@Schema(description = "Input data Values\nThe values inserted from:\n- Each Organic Unit\n- Variable\n- PeriodVersion")
public class InputDataDTO extends AbstractResilientDTO<Long> {
  private static final long serialVersionUID = 1L;

  private String stringValue;

  @Schema(description = "The value of the data in the source Unit. This might be different from the Variable baseUnit. @see variableValue and variableUnit", requiredMode = Schema.RequiredMode.REQUIRED)
  private BigDecimal sourceValue;

  @Schema(description = "The value of the data converted to the variable baseUnit.", requiredMode = Schema.RequiredMode.REQUIRED)
  private BigDecimal variableValue;

  @Schema(description = "The value that the InputData.owner is accounted for.\nIn case a variableValue is distributed to other Organization's (InputData.source==DataSources.DISTRIB)\n, this will have the value to consider when calculating the final inventory value for the variable", requiredMode = Schema.RequiredMode.REQUIRED)
  private BigDecimal imputedValue;

  @NotNull
  @Schema(description = "What was the source of this data ?", requiredMode = Schema.RequiredMode.REQUIRED)
  private DataSourceType sourceType;

  @Schema(description = "The date that this data relates to.\nEg. energy consumptium happens every month, this should be the date of invoice\n[optional]")
  private LocalDate dataDate;

  @NotNull
  @Schema(description = "Last change date", requiredMode = Schema.RequiredMode.REQUIRED)
  private Instant changeDate;

  @NotNull
  @Schema(description = "The actual username logged into the system, that last changed the data", requiredMode = Schema.RequiredMode.REQUIRED)
  private String changeUsername;

  @Schema(description = "Where this data originates from? Where were the data collected ?")
  private String dataSource;

  @Schema(description = "Who collected the data ?")
  private String dataUser;

  @Schema(description = "Comments added by the user")
  private String dataComments;

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

  @NotNull
  @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 String variableClassCode;
  private String variableClassName;

  private VariableDTO variable;

  private PeriodDTO period;

  private PeriodVersionDTO periodVersion;

  private UnitDTO sourceUnit;

  private UnitDTO unit;

  private OrganizationDTO owner;

  private InputDataDTO sourceInputData;

  private InputDataUploadDTO sourceInputDataUpload;

  public String getStringValue() {
    return stringValue;
  }

  public void setStringValue(String stringValue) {
    this.stringValue = stringValue;
  }

  public BigDecimal getSourceValue() {
    return sourceValue;
  }

  public void setSourceValue(BigDecimal sourceValue) {
    this.sourceValue = sourceValue;
  }

  public BigDecimal getVariableValue() {
    return variableValue;
  }

  public void setVariableValue(BigDecimal variableValue) {
    this.variableValue = variableValue;
  }

  public BigDecimal getImputedValue() {
    return imputedValue;
  }

  public void setImputedValue(BigDecimal imputedValue) {
    this.imputedValue = imputedValue;
  }

  public DataSourceType getSourceType() {
    return sourceType;
  }

  public void setSourceType(DataSourceType sourceType) {
    this.sourceType = sourceType;
  }

  public LocalDate getDataDate() {
    return dataDate;
  }

  public void setDataDate(LocalDate dataDate) {
    this.dataDate = dataDate;
  }

  public Instant getChangeDate() {
    return changeDate;
  }

  public void setChangeDate(Instant changeDate) {
    this.changeDate = changeDate;
  }

  public String getChangeUsername() {
    return changeUsername;
  }

  public void setChangeUsername(String changeUsername) {
    this.changeUsername = changeUsername;
  }

  public String getDataSource() {
    return dataSource;
  }

  public void setDataSource(String dataSource) {
    this.dataSource = dataSource;
  }

  public String getDataUser() {
    return dataUser;
  }

  public void setDataUser(String dataUser) {
    this.dataUser = dataUser;
  }

  public String getDataComments() {
    return dataComments;
  }

  public void setDataComments(String dataComments) {
    this.dataComments = dataComments;
  }

  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 String getVariableClassCode() {
    return variableClassCode;
  }

  public void setVariableClassCode(String variableClassCode) {
    this.variableClassCode = variableClassCode;
  }

  public String getVariableClassName() {
    return variableClassName;
  }

  public void setVariableClassName(String variableClassName) {
    this.variableClassName = variableClassName;
  }

  public VariableDTO getVariable() {
    return variable;
  }

  public void setVariable(VariableDTO variable) {
    this.variable = variable;
  }

  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 UnitDTO getSourceUnit() {
    return sourceUnit;
  }

  public void setSourceUnit(UnitDTO sourceUnit) {
    this.sourceUnit = sourceUnit;
  }

  public UnitDTO getUnit() {
    return unit;
  }

  public void setUnit(UnitDTO unit) {
    this.unit = unit;
  }

  public OrganizationDTO getOwner() {
    return owner;
  }

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

  public InputDataDTO getSourceInputData() {
    return sourceInputData;
  }

  public void setSourceInputData(InputDataDTO sourceInputData) {
    this.sourceInputData = sourceInputData;
  }

  public InputDataUploadDTO getSourceInputDataUpload() {
    return sourceInputDataUpload;
  }

  public void setSourceInputDataUpload(InputDataUploadDTO sourceInputDataUpload) {
    this.sourceInputDataUpload = sourceInputDataUpload;
  }

//@formatter:off
  @Override
  public String toString() {
    return "InputDataDTO{" + 
              "id=" + getId() + 
              ", sourceValue=" + getSourceValue() + 
              ", variableValue=" + getVariableValue() + 
              ", imputedValue=" + getImputedValue() + 
              ", sourceType='" + getSourceType() + "'" + 
              ", dataDate='" + getDataDate() + "'" + 
              ", changeDate='" + getChangeDate() + "'" + 
              ", changeUsername='" + getChangeUsername() + "'" + 
              ", dataSource='" + getDataSource() + "'" + 
              ", dataUser='" + getDataUser() + "'" + 
              ", dataComments='" + getDataComments() + "'" + 
              ", creationDate='" + getCreationDate() + "'" + 
              ", creationUsername='" + getCreationUsername() + "'" + 
              ", version=" + getVersion() + 
              ", variable=" + getVariable() + 
              ", period=" + getPeriod() + 
              ", periodVersion=" + getPeriodVersion() + 
              ", sourceUnit=" + getSourceUnit() + 
              ", unit=" + getUnit() + 
              ", owner=" + getOwner() + 
              ", sourceInputData=" + getSourceInputData() + 
              ", sourceInputDataUpload=" + getSourceInputDataUpload() + 
           "}";
  }
//@formatter:on
}
