2013-03-25 07:13:53 +01:00
|
|
|
|
using System;
|
2013-04-01 01:40:19 +02:00
|
|
|
|
using System.Collections.Generic;
|
2013-04-01 02:20:01 +02:00
|
|
|
|
using System.Linq;
|
2013-03-25 07:13:53 +01:00
|
|
|
|
using Marr.Data;
|
|
|
|
|
using Marr.Data.Mapping;
|
2013-04-18 01:32:06 +02:00
|
|
|
|
using NzbDrone.Common;
|
2013-03-25 07:13:53 +01:00
|
|
|
|
using NzbDrone.Core.Configuration;
|
2013-04-01 04:43:58 +02:00
|
|
|
|
using NzbDrone.Core.DataAugmentation.Scene;
|
2013-03-25 07:13:53 +01:00
|
|
|
|
using NzbDrone.Core.Datastore.Converters;
|
|
|
|
|
using NzbDrone.Core.ExternalNotification;
|
|
|
|
|
using NzbDrone.Core.Indexers;
|
|
|
|
|
using NzbDrone.Core.Instrumentation;
|
|
|
|
|
using NzbDrone.Core.Jobs;
|
|
|
|
|
using NzbDrone.Core.MediaFiles;
|
2013-04-25 06:27:49 +02:00
|
|
|
|
using NzbDrone.Core.Organizer;
|
2013-03-25 07:13:53 +01:00
|
|
|
|
using NzbDrone.Core.Qualities;
|
|
|
|
|
using NzbDrone.Core.RootFolders;
|
2013-04-21 01:36:23 +02:00
|
|
|
|
using NzbDrone.Core.SeriesStats;
|
2013-03-25 07:13:53 +01:00
|
|
|
|
using NzbDrone.Core.Tv;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Datastore
|
|
|
|
|
{
|
|
|
|
|
public static class TableMapping
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private static readonly FluentMappings Mapper = new FluentMappings(true);
|
|
|
|
|
|
|
|
|
|
public static void Map()
|
|
|
|
|
{
|
|
|
|
|
RegisterMappers();
|
|
|
|
|
|
|
|
|
|
Mapper.Entity<Config>().RegisterModel("Config");
|
2013-03-27 01:48:07 +01:00
|
|
|
|
Mapper.Entity<RootFolder>().RegisterModel("RootFolders").Ignore(r => r.FreeSpace);
|
2013-03-25 07:13:53 +01:00
|
|
|
|
|
2013-04-07 09:30:37 +02:00
|
|
|
|
Mapper.Entity<IndexerDefinition>().RegisterModel("IndexerDefinitions");
|
2013-03-25 07:13:53 +01:00
|
|
|
|
Mapper.Entity<JobDefinition>().RegisterModel("JobDefinitions");
|
|
|
|
|
Mapper.Entity<ExternalNotificationDefinition>().RegisterModel("ExternalNotificationDefinitions");
|
|
|
|
|
|
|
|
|
|
Mapper.Entity<SceneMapping>().RegisterModel("SceneMappings");
|
|
|
|
|
|
2013-05-03 09:28:02 +02:00
|
|
|
|
Mapper.Entity<History.History>().RegisterModel("History")
|
|
|
|
|
.Relationship()
|
|
|
|
|
.HasOne(h => h.Episode, h => h.EpisodeId)
|
|
|
|
|
.HasOne(h => h.Series, h => h.SeriesId);
|
2013-03-26 06:51:56 +01:00
|
|
|
|
|
2013-04-11 06:30:51 +02:00
|
|
|
|
Mapper.Entity<Series>().RegisterModel("Series")
|
2013-04-11 09:52:38 +02:00
|
|
|
|
.Ignore(s => s.Path)
|
2013-04-29 03:47:06 +02:00
|
|
|
|
.Relationship()
|
|
|
|
|
.HasOne(s => s.RootFolder, s => s.RootFolderId)
|
|
|
|
|
.HasOne(s => s.QualityProfile, s => s.QualityProfileId);
|
2013-03-26 06:51:56 +01:00
|
|
|
|
|
2013-03-25 07:13:53 +01:00
|
|
|
|
Mapper.Entity<Season>().RegisterModel("Seasons");
|
2013-05-03 02:25:51 +02:00
|
|
|
|
|
|
|
|
|
Mapper.Entity<Episode>().RegisterModel("Episodes")
|
|
|
|
|
.Ignore(e => e.SeriesTitle);
|
|
|
|
|
|
2013-03-25 07:13:53 +01:00
|
|
|
|
Mapper.Entity<EpisodeFile>().RegisterModel("EpisodeFiles");
|
2013-04-06 03:03:14 +02:00
|
|
|
|
|
2013-04-29 03:47:06 +02:00
|
|
|
|
Mapper.Entity<QualityProfile>().RegisterModel("QualityProfiles");
|
2013-04-06 03:03:14 +02:00
|
|
|
|
|
2013-03-25 07:13:53 +01:00
|
|
|
|
Mapper.Entity<QualitySize>().RegisterModel("QualitySizes");
|
|
|
|
|
|
|
|
|
|
Mapper.Entity<Log>().RegisterModel("Logs");
|
2013-04-20 22:09:12 +02:00
|
|
|
|
|
2013-04-25 06:27:49 +02:00
|
|
|
|
Mapper.Entity<NamingConfig>().RegisterModel("NamingConfig");
|
|
|
|
|
|
2013-04-20 23:23:17 +02:00
|
|
|
|
Mapper.Entity<SeriesStatistics>().MapResultSet();
|
2013-03-25 07:13:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void RegisterMappers()
|
|
|
|
|
{
|
2013-04-01 02:20:01 +02:00
|
|
|
|
RegisterEmbeddedConverter();
|
|
|
|
|
|
2013-03-25 07:13:53 +01:00
|
|
|
|
MapRepository.Instance.RegisterTypeConverter(typeof(Int32), new Int32Converter());
|
|
|
|
|
MapRepository.Instance.RegisterTypeConverter(typeof(Boolean), new BooleanIntConverter());
|
2013-03-26 06:51:56 +01:00
|
|
|
|
MapRepository.Instance.RegisterTypeConverter(typeof(Enum), new EnumIntConverter());
|
2013-03-26 09:02:31 +01:00
|
|
|
|
MapRepository.Instance.RegisterTypeConverter(typeof(Quality), new QualityIntConverter());
|
2013-03-25 07:13:53 +01:00
|
|
|
|
}
|
2013-04-01 02:20:01 +02:00
|
|
|
|
|
|
|
|
|
private static void RegisterEmbeddedConverter()
|
|
|
|
|
{
|
|
|
|
|
var embeddedTypes = typeof(IEmbeddedDocument).Assembly.GetTypes()
|
|
|
|
|
.Where(c => c.GetInterfaces().Any(i => i == typeof(IEmbeddedDocument)));
|
|
|
|
|
|
|
|
|
|
|
2013-04-18 01:32:06 +02:00
|
|
|
|
var embeddedConvertor = new EmbeddedDocumentConverter(new JsonSerializer());
|
2013-04-01 02:20:01 +02:00
|
|
|
|
var genericListDefinition = typeof(List<>).GetGenericTypeDefinition();
|
|
|
|
|
foreach (var embeddedType in embeddedTypes)
|
|
|
|
|
{
|
|
|
|
|
var embeddedListType = genericListDefinition.MakeGenericType(embeddedType);
|
|
|
|
|
MapRepository.Instance.RegisterTypeConverter(embeddedType, embeddedConvertor);
|
|
|
|
|
MapRepository.Instance.RegisterTypeConverter(embeddedListType, embeddedConvertor);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-03-25 07:13:53 +01:00
|
|
|
|
}
|
|
|
|
|
}
|