#pragma warning disable CA2227
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();
}
///
/// Initializes a new instance of the class.
///
///
/// Default constructor. Protected due to being abstract.
///
protected ItemMetadata()
{
}
///
/// Gets or sets the id.
///
///
/// Identity, Indexed, Required.
///
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; protected set; }
///
/// Gets or sets the title.
///
///
/// Required, Max length = 1024.
///
[Required]
[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.
///
[Required]
[MinLength(3)]
[MaxLength(3)]
[StringLength(3)]
public string Language { get; set; }
///
/// Gets or sets the release date.
///
public DateTimeOffset? ReleaseDate { get; set; }
///
/// Gets or sets the date added.
///
///
/// Required.
///
public DateTime DateAdded { get; protected set; }
///
/// Gets or sets the date modified.
///
///
/// Required.
///
public DateTime DateModified { get; set; }
///
/// Gets or sets the row version.
///
///
/// Required, ConcurrencyToken.
///
[ConcurrencyCheck]
public uint RowVersion { get; set; }
///
/// Gets or sets a collection containing the person roles for this item.
///
public virtual ICollection PersonRoles { get; protected set; }
///
/// Gets or sets a collection containing the generes for this item.
///
public virtual ICollection Genres { get; protected set; }
///
public virtual ICollection Artwork { get; protected set; }
///
/// Gets or sets a collection containing the ratings for this item.
///
public virtual ICollection Ratings { get; protected set; }
///
/// Gets or sets a collection containing the metadata sources for this item.
///
public virtual ICollection Sources { get; protected set; }
///
public void OnSavingChanges()
{
RowVersion++;
}
}
}