RootDirs moved to PetaPoco. Removed SubSonic references from EpisodeFile & SceneMapping.

pull/3113/head
Mark McDowall 14 years ago
parent 2a32770b69
commit f7ee16dbba

@ -18,20 +18,20 @@ namespace NzbDrone.Core.Test
public class RootDirProviderTest : TestBase public class RootDirProviderTest : TestBase
{ {
[Test] [Test]
public void GetRootDirs() public void GetRootDirs()
{ {
//Setup //Setup
var sonicRepo = MockLib.GetEmptyRepository();
sonicRepo.Add(new RootDir { Path = @"C:\TV" });
sonicRepo.Add(new RootDir { Path = @"C:\TV2" });
var mocker = new AutoMoqer(); var mocker = new AutoMoqer();
mocker.GetMock<IRepository>() var emptyDatabase = MockLib.GetEmptyDatabase();
.Setup(f => f.All<RootDir>()) mocker.SetConstant(emptyDatabase);
.Returns(sonicRepo.All<RootDir>); emptyDatabase.Insert(new RootDir { Path = @"C:\TV" });
emptyDatabase.Insert(new RootDir { Path = @"C:\TV2" });
//mocker.GetMock<IRepository>()
// .Setup(f => f.All<RootDir>())
// .Returns(sonicRepo.All<RootDir>);
//Act //Act
var result = mocker.Resolve<RootDirProvider>().GetAll(); var result = mocker.Resolve<RootDirProvider>().GetAll();
@ -46,7 +46,7 @@ namespace NzbDrone.Core.Test
{ {
//Setup //Setup
var mocker = new AutoMoqer(); var mocker = new AutoMoqer();
mocker.SetConstant(MockLib.GetEmptyRepository()); mocker.SetConstant(MockLib.GetEmptyDatabase());
//Act //Act
var rootDirProvider = mocker.Resolve<RootDirProvider>(); var rootDirProvider = mocker.Resolve<RootDirProvider>();
@ -68,7 +68,7 @@ namespace NzbDrone.Core.Test
{ {
//Setup //Setup
var mocker = new AutoMoqer(); var mocker = new AutoMoqer();
mocker.SetConstant(MockLib.GetEmptyRepository()); mocker.SetConstant(MockLib.GetEmptyDatabase());
//Act //Act
@ -88,7 +88,7 @@ namespace NzbDrone.Core.Test
{ {
//Setup //Setup
var mocker = new AutoMoqer(); var mocker = new AutoMoqer();
mocker.SetConstant(MockLib.GetEmptyRepository()); mocker.SetConstant(MockLib.GetEmptyDatabase());
//Act //Act
var rootDirProvider = mocker.Resolve<RootDirProvider>(); var rootDirProvider = mocker.Resolve<RootDirProvider>();
@ -105,7 +105,7 @@ namespace NzbDrone.Core.Test
{ {
//Setup //Setup
var mocker = new AutoMoqer(); var mocker = new AutoMoqer();
mocker.SetConstant(MockLib.GetEmptyRepository()); mocker.SetConstant(MockLib.GetEmptyDatabase());
const int id = 1; const int id = 1;
const string path = @"C:\TV"; const string path = @"C:\TV";

@ -91,7 +91,7 @@ namespace NzbDrone.Core.Datastore.Migrations
new Column("Value", DbType.String, ColumnProperty.NotNull), new Column("Value", DbType.String, ColumnProperty.NotNull),
}); });
Database.AddTable("EpisodeFiles", "SQLite", new[] Database.AddTable("History", "SQLite", new[]
{ {
new Column("HistoryId", DbType.Int64, ColumnProperty.NotNull), new Column("HistoryId", DbType.Int64, ColumnProperty.NotNull),
new Column("EpisodeId", DbType.Int32, ColumnProperty.NotNull), new Column("EpisodeId", DbType.Int32, ColumnProperty.NotNull),
@ -102,6 +102,12 @@ namespace NzbDrone.Core.Datastore.Migrations
new Column("IsProper", DbType.Boolean, ColumnProperty.NotNull), new Column("IsProper", DbType.Boolean, ColumnProperty.NotNull),
new Column("Indexer", DbType.String, ColumnProperty.NotNull) new Column("Indexer", DbType.String, ColumnProperty.NotNull)
}); });
Database.AddTable("RootDirs", "SQLite", new[]
{
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKey),
new Column("Path", DbType.String, ColumnProperty.NotNull),
});
} }
public override void Down() public override void Down()

@ -6,21 +6,22 @@ using Ninject;
using NLog; using NLog;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using PetaPoco;
using SubSonic.Repository; using SubSonic.Repository;
namespace NzbDrone.Core.Providers namespace NzbDrone.Core.Providers
{ {
public class RootDirProvider public class RootDirProvider
{ {
private readonly IRepository _repository; private readonly IDatabase _database;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly DiskProvider _diskProvider; private readonly DiskProvider _diskProvider;
private readonly SeriesProvider _seriesProvider; private readonly SeriesProvider _seriesProvider;
[Inject] [Inject]
public RootDirProvider(IRepository repository, SeriesProvider seriesProvider, DiskProvider diskProvider) public RootDirProvider(IDatabase database, SeriesProvider seriesProvider, DiskProvider diskProvider)
{ {
_repository = repository; _database = database;
_diskProvider = diskProvider; _diskProvider = diskProvider;
_seriesProvider = seriesProvider; _seriesProvider = seriesProvider;
} }
@ -29,26 +30,25 @@ namespace NzbDrone.Core.Providers
public virtual List<RootDir> GetAll() public virtual List<RootDir> GetAll()
{ {
return _repository.All<RootDir>().ToList(); return _database.Fetch<RootDir>();
} }
public virtual int Add(RootDir rootDir) public virtual int Add(RootDir rootDir)
{ {
ValidatePath(rootDir); ValidatePath(rootDir);
return Convert.ToInt32(_database.Insert(rootDir));
return (int)_repository.Add(rootDir);
} }
public virtual void Remove(int rootDirId) public virtual void Remove(int rootDirId)
{ {
_repository.Delete<RootDir>(rootDirId); _database.Delete<RootDir>(rootDirId);
} }
public virtual void Update(RootDir rootDir) public virtual void Update(RootDir rootDir)
{ {
ValidatePath(rootDir); ValidatePath(rootDir);
_repository.Update(rootDir); _database.Update(rootDir);
} }
private static void ValidatePath(RootDir rootDir) private static void ValidatePath(RootDir rootDir)
@ -61,7 +61,7 @@ namespace NzbDrone.Core.Providers
public virtual RootDir GetRootDir(int rootDirId) public virtual RootDir GetRootDir(int rootDirId)
{ {
return _repository.Single<RootDir>(rootDirId); return _database.SingleOrDefault<RootDir>(rootDirId);
} }
public List<String> GetUnmappedFolders(string path) public List<String> GetUnmappedFolders(string path)
@ -78,7 +78,6 @@ namespace NzbDrone.Core.Providers
return results; return results;
} }
foreach (string seriesFolder in _diskProvider.GetDirectories(path)) foreach (string seriesFolder in _diskProvider.GetDirectories(path))
{ {
var cleanPath = Parser.NormalizePath(new DirectoryInfo(seriesFolder).FullName); var cleanPath = Parser.NormalizePath(new DirectoryInfo(seriesFolder).FullName);

@ -2,7 +2,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Repository.Quality;
using PetaPoco; using PetaPoco;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository namespace NzbDrone.Core.Repository
{ {
@ -10,7 +9,6 @@ namespace NzbDrone.Core.Repository
[PrimaryKey("EpisodeFileId", autoIncrement = true)] [PrimaryKey("EpisodeFileId", autoIncrement = true)]
public class EpisodeFile public class EpisodeFile
{ {
[SubSonicPrimaryKey]
public virtual int EpisodeFileId { get; set; } public virtual int EpisodeFileId { get; set; }
public virtual int SeriesId { get; set; } public virtual int SeriesId { get; set; }
@ -21,11 +19,9 @@ namespace NzbDrone.Core.Repository
public long Size { get; set; } public long Size { get; set; }
public DateTime DateAdded { get; set; } public DateTime DateAdded { get; set; }
[SubSonicToManyRelation]
[Ignore] [Ignore]
public virtual IList<Episode> Episodes { get; set; } public virtual IList<Episode> Episodes { get; set; }
[SubSonicToOneRelation(ThisClassContainsJoinKey = true)]
[Ignore] [Ignore]
public virtual Series Series { get; set; } public virtual Series Series { get; set; }
} }

@ -1,10 +1,11 @@
using SubSonic.SqlGeneration.Schema; using PetaPoco;
namespace NzbDrone.Core.Repository namespace NzbDrone.Core.Repository
{ {
[TableName("RootDirs")]
[PrimaryKey("Id", autoIncrement = true)]
public class RootDir public class RootDir
{ {
[SubSonicPrimaryKey]
public virtual int Id { get; set; } public virtual int Id { get; set; }
public string Path { get; set; } public string Path { get; set; }

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using PetaPoco; using PetaPoco;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository namespace NzbDrone.Core.Repository
{ {
@ -11,7 +10,6 @@ namespace NzbDrone.Core.Repository
[PrimaryKey("CleanTitle", autoIncrement = false)] [PrimaryKey("CleanTitle", autoIncrement = false)]
public class SceneMapping public class SceneMapping
{ {
[SubSonicPrimaryKey]
public virtual string CleanTitle { get; set; } public virtual string CleanTitle { get; set; }
public virtual int SeriesId { get; set; } public virtual int SeriesId { get; set; }

Loading…
Cancel
Save