package com.oguerreiro.resilient.service.dto;

import java.util.HashSet;
import java.util.Set;

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

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

/**
 * A DTO for the {@link com.oguerreiro.resilient.domain.OrganizationType} entity.
 */
@Schema(description = "Organization Type\nThe organization type is a setup that defines the usage of the Organization level and other configurations.")
public class OrganizationTypeDTO extends AbstractResilientDTO<Long> {
  private static final long serialVersionUID = 1L;

  @NotNull
  @Size(min = 1)
  @Schema(description = "User defined code. Must be unique in the OrganizationType", requiredMode = Schema.RequiredMode.REQUIRED)
  private String code;

  @NotNull
  @Size(min = 3)
  @Schema(description = "The name of the type. Must be unique in the system", requiredMode = Schema.RequiredMode.REQUIRED)
  private String name;

  @NotNull
  @Size(min = 3)
  @Schema(description = "A more complete description of the type. Whats the meaning of this type?", requiredMode = Schema.RequiredMode.REQUIRED)
  private String description;

  @NotNull
  @Schema(description = "The nature of the type", requiredMode = Schema.RequiredMode.REQUIRED)
  private OrganizationNature nature;

  @Schema(description = "Icon image associated with this organization type. Will be used in user interface.")
  @Lob
  private byte[] icon;

  private String iconContentType;

  private Set<MetadataPropertyDTO> metadataProperties = new HashSet<>();

  public String getCode() {
    return code;
  }

  public void setCode(String code) {
    this.code = code;
  }

  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 OrganizationNature getNature() {
    return nature;
  }

  public void setNature(OrganizationNature nature) {
    this.nature = nature;
  }

  public byte[] getIcon() {
    return icon;
  }

  public void setIcon(byte[] icon) {
    this.icon = icon;
  }

  public String getIconContentType() {
    return iconContentType;
  }

  public void setIconContentType(String iconContentType) {
    this.iconContentType = iconContentType;
  }

  public Set<MetadataPropertyDTO> getMetadataProperties() {
    return metadataProperties;
  }

  public void setMetadataProperties(Set<MetadataPropertyDTO> metadataProperties) {
    this.metadataProperties = metadataProperties;
  }

  //@formatter:off
  @Override
  public String toString() {
    return "OrganizationTypeDTO{" +
              "id=" + getId() +
              ", code='" + getCode() + "'" +
              ", name='" + getName() + "'" +
              ", description='" + getDescription() + "'" +
              ", nature='" + getNature() + "'" +
              ", icon='" + getIcon() + "'" +
              ", metadataProperties=" + getMetadataProperties() +
              ", version=" + getVersion() +
           "}";
  }
  //@formatter:on
}
