You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
168 lines
4.9 KiB
168 lines
4.9 KiB
4 years ago
|
#pragma warning disable CA2227
|
||
|
|
||
6 years ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.ComponentModel.DataAnnotations;
|
||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||
4 years ago
|
using Jellyfin.Data.Interfaces;
|
||
6 years ago
|
|
||
4 years ago
|
namespace Jellyfin.Data.Entities.Libraries
|
||
6 years ago
|
{
|
||
4 years ago
|
/// <summary>
|
||
|
/// An abstract class that holds metadata.
|
||
|
/// </summary>
|
||
4 years ago
|
public abstract class ItemMetadata : IHasArtwork, IHasConcurrencyToken
|
||
5 years ago
|
{
|
||
|
/// <summary>
|
||
4 years ago
|
/// Initializes a new instance of the <see cref="ItemMetadata"/> class.
|
||
5 years ago
|
/// </summary>
|
||
4 years ago
|
/// <param name="title">The title or name of the object.</param>
|
||
|
/// <param name="language">ISO-639-3 3-character language codes.</param>
|
||
4 years ago
|
protected ItemMetadata(string title, string language)
|
||
5 years ago
|
{
|
||
4 years ago
|
if (string.IsNullOrEmpty(title))
|
||
|
{
|
||
|
throw new ArgumentNullException(nameof(title));
|
||
|
}
|
||
|
|
||
|
if (string.IsNullOrEmpty(language))
|
||
|
{
|
||
|
throw new ArgumentNullException(nameof(language));
|
||
|
}
|
||
|
|
||
4 years ago
|
Title = title;
|
||
|
Language = language;
|
||
|
DateAdded = DateTime.UtcNow;
|
||
|
DateModified = DateAdded;
|
||
5 years ago
|
|
||
4 years ago
|
PersonRoles = new HashSet<PersonRole>();
|
||
|
Genres = new HashSet<Genre>();
|
||
|
Artwork = new HashSet<Artwork>();
|
||
|
Ratings = new HashSet<Rating>();
|
||
|
Sources = new HashSet<MetadataProviderId>();
|
||
5 years ago
|
}
|
||
|
|
||
|
/// <summary>
|
||
4 years ago
|
/// Initializes a new instance of the <see cref="ItemMetadata"/> class.
|
||
5 years ago
|
/// </summary>
|
||
4 years ago
|
/// <remarks>
|
||
|
/// Default constructor. Protected due to being abstract.
|
||
|
/// </remarks>
|
||
4 years ago
|
protected ItemMetadata()
|
||
5 years ago
|
{
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
4 years ago
|
/// Gets or sets the id.
|
||
5 years ago
|
/// </summary>
|
||
4 years ago
|
/// <remarks>
|
||
|
/// Identity, Indexed, Required.
|
||
|
/// </remarks>
|
||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||
|
public int Id { get; protected set; }
|
||
5 years ago
|
|
||
|
/// <summary>
|
||
4 years ago
|
/// Gets or sets the title.
|
||
5 years ago
|
/// </summary>
|
||
4 years ago
|
/// <remarks>
|
||
|
/// Required, Max length = 1024.
|
||
|
/// </remarks>
|
||
5 years ago
|
[Required]
|
||
|
[MaxLength(1024)]
|
||
|
[StringLength(1024)]
|
||
4 years ago
|
public string Title { get; set; }
|
||
4 years ago
|
|
||
5 years ago
|
/// <summary>
|
||
4 years ago
|
/// Gets or sets the original title.
|
||
5 years ago
|
/// </summary>
|
||
4 years ago
|
/// <remarks>
|
||
|
/// Max length = 1024.
|
||
|
/// </remarks>
|
||
5 years ago
|
[MaxLength(1024)]
|
||
|
[StringLength(1024)]
|
||
4 years ago
|
public string OriginalTitle { get; set; }
|
||
5 years ago
|
|
||
|
/// <summary>
|
||
4 years ago
|
/// Gets or sets the sort title.
|
||
5 years ago
|
/// </summary>
|
||
4 years ago
|
/// <remarks>
|
||
|
/// Max length = 1024.
|
||
|
/// </remarks>
|
||
5 years ago
|
[MaxLength(1024)]
|
||
|
[StringLength(1024)]
|
||
4 years ago
|
public string SortTitle { get; set; }
|
||
5 years ago
|
|
||
|
/// <summary>
|
||
4 years ago
|
/// Gets or sets the language.
|
||
5 years ago
|
/// </summary>
|
||
4 years ago
|
/// <remarks>
|
||
|
/// Required, Min length = 3, Max length = 3.
|
||
4 years ago
|
/// ISO-639-3 3-character language codes.
|
||
4 years ago
|
/// </remarks>
|
||
5 years ago
|
[Required]
|
||
|
[MinLength(3)]
|
||
|
[MaxLength(3)]
|
||
|
[StringLength(3)]
|
||
4 years ago
|
public string Language { get; set; }
|
||
5 years ago
|
|
||
|
/// <summary>
|
||
4 years ago
|
/// Gets or sets the release date.
|
||
5 years ago
|
/// </summary>
|
||
4 years ago
|
public DateTimeOffset? ReleaseDate { get; set; }
|
||
5 years ago
|
|
||
|
/// <summary>
|
||
4 years ago
|
/// Gets or sets the date added.
|
||
5 years ago
|
/// </summary>
|
||
4 years ago
|
/// <remarks>
|
||
|
/// Required.
|
||
|
/// </remarks>
|
||
|
public DateTime DateAdded { get; protected set; }
|
||
5 years ago
|
|
||
|
/// <summary>
|
||
4 years ago
|
/// Gets or sets the date modified.
|
||
5 years ago
|
/// </summary>
|
||
4 years ago
|
/// <remarks>
|
||
|
/// Required.
|
||
|
/// </remarks>
|
||
|
public DateTime DateModified { get; set; }
|
||
5 years ago
|
|
||
|
/// <summary>
|
||
4 years ago
|
/// Gets or sets the row version.
|
||
5 years ago
|
/// </summary>
|
||
4 years ago
|
/// <remarks>
|
||
|
/// Required, ConcurrencyToken.
|
||
|
/// </remarks>
|
||
|
[ConcurrencyCheck]
|
||
|
public uint RowVersion { get; set; }
|
||
|
|
||
5 years ago
|
/// <summary>
|
||
4 years ago
|
/// Gets or sets a collection containing the person roles for this item.
|
||
5 years ago
|
/// </summary>
|
||
4 years ago
|
public virtual ICollection<PersonRole> PersonRoles { get; protected set; }
|
||
|
|
||
5 years ago
|
/// <summary>
|
||
4 years ago
|
/// Gets or sets a collection containing the generes for this item.
|
||
5 years ago
|
/// </summary>
|
||
4 years ago
|
public virtual ICollection<Genre> Genres { get; protected set; }
|
||
|
|
||
|
/// <inheritdoc />
|
||
|
public virtual ICollection<Artwork> Artwork { get; protected set; }
|
||
5 years ago
|
|
||
|
/// <summary>
|
||
4 years ago
|
/// Gets or sets a collection containing the ratings for this item.
|
||
5 years ago
|
/// </summary>
|
||
4 years ago
|
public virtual ICollection<Rating> Ratings { get; protected set; }
|
||
5 years ago
|
|
||
|
/// <summary>
|
||
4 years ago
|
/// Gets or sets a collection containing the metadata sources for this item.
|
||
5 years ago
|
/// </summary>
|
||
4 years ago
|
public virtual ICollection<MetadataProviderId> Sources { get; protected set; }
|
||
6 years ago
|
|
||
4 years ago
|
/// <inheritdoc />
|
||
5 years ago
|
public void OnSavingChanges()
|
||
|
{
|
||
|
RowVersion++;
|
||
|
}
|
||
|
}
|
||
6 years ago
|
}
|