| | | 1 | | using System; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | using System.ComponentModel.DataAnnotations; |
| | | 4 | | using System.ComponentModel.DataAnnotations.Schema; |
| | | 5 | | using Jellyfin.Database.Implementations.Interfaces; |
| | | 6 | | |
| | | 7 | | namespace Jellyfin.Database.Implementations.Entities.Libraries |
| | | 8 | | { |
| | | 9 | | /// <summary> |
| | | 10 | | /// An abstract class that holds metadata. |
| | | 11 | | /// </summary> |
| | | 12 | | public abstract class ItemMetadata : IHasArtwork, IHasConcurrencyToken |
| | | 13 | | { |
| | | 14 | | /// <summary> |
| | | 15 | | /// Initializes a new instance of the <see cref="ItemMetadata"/> class. |
| | | 16 | | /// </summary> |
| | | 17 | | /// <param name="title">The title or name of the object.</param> |
| | | 18 | | /// <param name="language">ISO-639-3 3-character language codes.</param> |
| | | 19 | | protected ItemMetadata(string title, string language) |
| | | 20 | | { |
| | 0 | 21 | | ArgumentException.ThrowIfNullOrEmpty(title); |
| | 0 | 22 | | ArgumentException.ThrowIfNullOrEmpty(language); |
| | | 23 | | |
| | 0 | 24 | | Title = title; |
| | 0 | 25 | | Language = language; |
| | 0 | 26 | | DateAdded = DateTime.UtcNow; |
| | 0 | 27 | | DateModified = DateAdded; |
| | | 28 | | |
| | 0 | 29 | | PersonRoles = new HashSet<PersonRole>(); |
| | 0 | 30 | | Genres = new HashSet<Genre>(); |
| | 0 | 31 | | Artwork = new HashSet<Artwork>(); |
| | 0 | 32 | | Ratings = new HashSet<Rating>(); |
| | 0 | 33 | | Sources = new HashSet<MetadataProviderId>(); |
| | 0 | 34 | | } |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// Gets the id. |
| | | 38 | | /// </summary> |
| | | 39 | | /// <remarks> |
| | | 40 | | /// Identity, Indexed, Required. |
| | | 41 | | /// </remarks> |
| | | 42 | | [DatabaseGenerated(DatabaseGeneratedOption.Identity)] |
| | | 43 | | public int Id { get; private set; } |
| | | 44 | | |
| | | 45 | | /// <summary> |
| | | 46 | | /// Gets or sets the title. |
| | | 47 | | /// </summary> |
| | | 48 | | /// <remarks> |
| | | 49 | | /// Required, Max length = 1024. |
| | | 50 | | /// </remarks> |
| | | 51 | | [MaxLength(1024)] |
| | | 52 | | [StringLength(1024)] |
| | | 53 | | public string Title { get; set; } |
| | | 54 | | |
| | | 55 | | /// <summary> |
| | | 56 | | /// Gets or sets the original title. |
| | | 57 | | /// </summary> |
| | | 58 | | /// <remarks> |
| | | 59 | | /// Max length = 1024. |
| | | 60 | | /// </remarks> |
| | | 61 | | [MaxLength(1024)] |
| | | 62 | | [StringLength(1024)] |
| | | 63 | | public string? OriginalTitle { get; set; } |
| | | 64 | | |
| | | 65 | | /// <summary> |
| | | 66 | | /// Gets or sets the sort title. |
| | | 67 | | /// </summary> |
| | | 68 | | /// <remarks> |
| | | 69 | | /// Max length = 1024. |
| | | 70 | | /// </remarks> |
| | | 71 | | [MaxLength(1024)] |
| | | 72 | | [StringLength(1024)] |
| | | 73 | | public string? SortTitle { get; set; } |
| | | 74 | | |
| | | 75 | | /// <summary> |
| | | 76 | | /// Gets or sets the language. |
| | | 77 | | /// </summary> |
| | | 78 | | /// <remarks> |
| | | 79 | | /// Required, Min length = 3, Max length = 3. |
| | | 80 | | /// ISO-639-3 3-character language codes. |
| | | 81 | | /// </remarks> |
| | | 82 | | [MinLength(3)] |
| | | 83 | | [MaxLength(3)] |
| | | 84 | | [StringLength(3)] |
| | | 85 | | public string Language { get; set; } |
| | | 86 | | |
| | | 87 | | /// <summary> |
| | | 88 | | /// Gets or sets the release date. |
| | | 89 | | /// </summary> |
| | | 90 | | public DateTimeOffset? ReleaseDate { get; set; } |
| | | 91 | | |
| | | 92 | | /// <summary> |
| | | 93 | | /// Gets the date added. |
| | | 94 | | /// </summary> |
| | | 95 | | /// <remarks> |
| | | 96 | | /// Required. |
| | | 97 | | /// </remarks> |
| | | 98 | | public DateTime DateAdded { get; private set; } |
| | | 99 | | |
| | | 100 | | /// <summary> |
| | | 101 | | /// Gets or sets the date modified. |
| | | 102 | | /// </summary> |
| | | 103 | | /// <remarks> |
| | | 104 | | /// Required. |
| | | 105 | | /// </remarks> |
| | | 106 | | public DateTime DateModified { get; set; } |
| | | 107 | | |
| | | 108 | | /// <inheritdoc /> |
| | | 109 | | [ConcurrencyCheck] |
| | | 110 | | public uint RowVersion { get; private set; } |
| | | 111 | | |
| | | 112 | | /// <summary> |
| | | 113 | | /// Gets a collection containing the person roles for this item. |
| | | 114 | | /// </summary> |
| | | 115 | | public virtual ICollection<PersonRole> PersonRoles { get; private set; } |
| | | 116 | | |
| | | 117 | | /// <summary> |
| | | 118 | | /// Gets a collection containing the genres for this item. |
| | | 119 | | /// </summary> |
| | | 120 | | public virtual ICollection<Genre> Genres { get; private set; } |
| | | 121 | | |
| | | 122 | | /// <inheritdoc /> |
| | | 123 | | public virtual ICollection<Artwork> Artwork { get; private set; } |
| | | 124 | | |
| | | 125 | | /// <summary> |
| | | 126 | | /// Gets a collection containing the ratings for this item. |
| | | 127 | | /// </summary> |
| | | 128 | | public virtual ICollection<Rating> Ratings { get; private set; } |
| | | 129 | | |
| | | 130 | | /// <summary> |
| | | 131 | | /// Gets a collection containing the metadata sources for this item. |
| | | 132 | | /// </summary> |
| | | 133 | | public virtual ICollection<MetadataProviderId> Sources { get; private set; } |
| | | 134 | | |
| | | 135 | | /// <inheritdoc /> |
| | | 136 | | public void OnSavingChanges() |
| | | 137 | | { |
| | 0 | 138 | | RowVersion++; |
| | 0 | 139 | | } |
| | | 140 | | } |
| | | 141 | | } |