using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces;
namespace Jellyfin.Data.Entities.Libraries
{
///
/// An abstract class that holds metadata.
///
public abstract class ItemMetadata : IHasArtwork, IHasConcurrencyToken
{
///
/// Initializes a new instance of the class.
///
/// The title or name of the object.
/// ISO-639-3 3-character language codes.
protected ItemMetadata(string title, string language)
{
if (string.IsNullOrEmpty(title))
{
throw new ArgumentNullException(nameof(title));
}
if (string.IsNullOrEmpty(language))
{
throw new ArgumentNullException(nameof(language));
}
Title = title;
Language = language;
DateAdded = DateTime.UtcNow;
DateModified = DateAdded;
PersonRoles = new HashSet();
Genres = new HashSet();
Artwork = new HashSet();
Ratings = new HashSet();
Sources = new HashSet();
}
///
/// Gets the id.
///
///
/// Identity, Indexed, Required.
///
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
///
/// Gets or sets the title.
///
///
/// Required, Max length = 1024.
///
[MaxLength(1024)]
[StringLength(1024)]
public string Title { get; set; }
///
/// Gets or sets the original title.
///
///
/// Max length = 1024.
///
[MaxLength(1024)]
[StringLength(1024)]
public string? OriginalTitle { get; set; }
///
/// Gets or sets the sort title.
///
///
/// Max length = 1024.
///
[MaxLength(1024)]
[StringLength(1024)]
public string? SortTitle { get; set; }
///
/// Gets or sets the language.
///
///
/// Required, Min length = 3, Max length = 3.
/// ISO-639-3 3-character language codes.
///
[MinLength(3)]
[MaxLength(3)]
[StringLength(3)]
public string Language { get; set; }
///
/// Gets or sets the release date.
///
public DateTimeOffset? ReleaseDate { get; set; }
///
/// Gets the date added.
///
///
/// Required.
///
public DateTime DateAdded { get; private set; }
///
/// Gets or sets the date modified.
///
///
/// Required.
///
public DateTime DateModified { get; set; }
///
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
///
/// Gets a collection containing the person roles for this item.
///
public virtual ICollection PersonRoles { get; private set; }
///
/// Gets a collection containing the genres for this item.
///
public virtual ICollection Genres { get; private set; }
///
public virtual ICollection Artwork { get; private set; }
///
/// Gets a collection containing the ratings for this item.
///
public virtual ICollection Ratings { get; private set; }
///
/// Gets a collection containing the metadata sources for this item.
///
public virtual ICollection Sources { get; private set; }
///
public void OnSavingChanges()
{
RowVersion++;
}
}
}