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

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

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

@ -91,7 +91,7 @@ namespace NzbDrone.Core.Datastore.Migrations
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("EpisodeId", DbType.Int32, ColumnProperty.NotNull),
@ -102,6 +102,12 @@ namespace NzbDrone.Core.Datastore.Migrations
new Column("IsProper", DbType.Boolean, 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()

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

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

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

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

Loading…
Cancel
Save