package de.ph87.isabell_und_timo.picture;

import jakarta.annotation.Nullable;
import jakarta.persistence.Id;
import lombok.Data;
import lombok.NonNull;

import java.nio.file.Path;
import java.time.ZonedDateTime;

@Data
public class PictureInternal {

  @Id
  public final String uuid;

  @NonNull
  public final String originalFilename;

  @Nullable
  public final ZonedDateTime originalDate;

  public final long size;

  public final int height;

  public final int width;

  @Nullable
  public final String make;

  @Nullable
  public final String model;

  @NonNull
  public final String uploadFilename;

  @NonNull
  public final ZonedDateTime uploadDate;

  @NonNull
  public final String uploadAddress;

  @Nullable
  public final String uploadAgent;

  public final boolean visible;

  public PictureInternal(@NonNull final Picture picture) {
    this.uuid = picture.getUuid();
    this.originalFilename = picture.getOriginalFilename();
    this.originalDate = picture.getOriginalDate();
    this.size = picture.getSize();
    this.height = picture.getHeight();
    this.width = picture.getWidth();
    this.make = picture.getMake();
    this.model = picture.getModel();
    this.uploadFilename = picture.getUploadFilename();
    this.uploadDate = picture.getUploadDate();
    this.uploadAddress = picture.getUploadAddress();
    this.uploadAgent = picture.getUploadAgent();
    this.visible = picture.isVisible();
  }

  @NonNull
  public Path getOriginalPath() {
    return CONFIG.ORIGINAL.resolve(uploadFilename);
  }

  @NonNull
  public Path getPreviewPath() {
    return CONFIG.RESIZED.resolve(uploadFilename);
  }

}
