package org.kar.karideo.model;

import java.util.List;
import java.util.UUID;

import org.bson.types.ObjectId;
import org.kar.archidata.annotation.DataJson;
import org.kar.archidata.model.Data;
import org.kar.archidata.model.GenericDataSoftDelete;

import com.fasterxml.jackson.annotation.JsonInclude;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Nullable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;

@Entity
@Table(name = "media")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Media extends GenericDataSoftDelete {
	@Schema(description = "Name of the media (this represent the title)")
	@Column(nullable = false, length = 0)
	public String name;
	@Schema(description = "Description of the media")
	@Column(length = 0)
	public String description;
	@Schema(description = "Foreign Key Id of the data")
	@ManyToOne(fetch = FetchType.LAZY, targetEntity = Data.class)
	@Column(nullable = false)
	public ObjectId dataId;
	@ManyToOne(fetch = FetchType.LAZY, targetEntity = Data.class)
	@Column(nullable = false)
	@Nullable
	public UUID dataIdOld;
	@Schema(description = "Type of the media")
	@ManyToOne(fetch = FetchType.LAZY, targetEntity = Type.class)
	public Long typeId;
	@Schema(description = "Series reference of the media")
	@ManyToOne(fetch = FetchType.LAZY, targetEntity = Series.class)
	public Long seriesId;
	@Schema(description = "Season reference of the media")
	@ManyToOne(fetch = FetchType.LAZY, targetEntity = Season.class)
	public Long seasonId;
	@Schema(description = "Episode Id")
	public Integer episode;
	// ")
	public Integer date;
	@Schema(description = "Creation years of the media")
	public Integer time;
	@Schema(description = "Limitation Age of the media")
	public Integer ageLimit;
	@Schema(description = "List of Id of the specific covers")
	@DataJson(targetEntity = Data.class)
	@Nullable
	public List<ObjectId> covers = null;

	@Override
	public String toString() {
		return "Media [name=" + this.name + ", description=" + this.description + ", dataId=" + this.dataId + ", typeId=" + this.typeId + ", seriesId=" + this.seriesId + ", seasonId=" + this.seasonId
				+ ", episode=" + this.episode + ", date=" + this.date + ", time=" + this.time + ", ageLimit=" + this.ageLimit + ", covers=" + this.covers + "]";
	}

}
