diff --git a/src/Umbraco.Core/Models/DictionaryItem.cs b/src/Umbraco.Core/Models/DictionaryItem.cs index 0ff3d0df35..169ac2505b 100644 --- a/src/Umbraco.Core/Models/DictionaryItem.cs +++ b/src/Umbraco.Core/Models/DictionaryItem.cs @@ -11,7 +11,7 @@ namespace Umbraco.Core.Models /// [Serializable] [DataContract(IsReference = true)] - public class DictionaryItem : Entity + public class DictionaryItem : Entity, IAggregateRoot { private Guid _parentId; private string _itemKey; diff --git a/src/Umbraco.Core/Models/Language.cs b/src/Umbraco.Core/Models/Language.cs index 6587711557..65246bcf63 100644 --- a/src/Umbraco.Core/Models/Language.cs +++ b/src/Umbraco.Core/Models/Language.cs @@ -11,7 +11,7 @@ namespace Umbraco.Core.Models /// [Serializable] [DataContract(IsReference = true)] - public class Language : Entity + public class Language : Entity, IAggregateRoot { private string _isoCode; private string _cultureName; diff --git a/src/Umbraco.Core/Models/Rdbms/DictionaryDto.cs b/src/Umbraco.Core/Models/Rdbms/DictionaryDto.cs index 21acfb5f16..8bf635df82 100644 --- a/src/Umbraco.Core/Models/Rdbms/DictionaryDto.cs +++ b/src/Umbraco.Core/Models/Rdbms/DictionaryDto.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using Umbraco.Core.Persistence; namespace Umbraco.Core.Models.Rdbms @@ -19,5 +20,8 @@ namespace Umbraco.Core.Models.Rdbms [Column("key")] public string Key { get; set; } + + [ResultColumn] + public List LanguageTextDtos { get; set; } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Factories/DictionaryItemFactory.cs b/src/Umbraco.Core/Persistence/Factories/DictionaryItemFactory.cs new file mode 100644 index 0000000000..b44a5ac514 --- /dev/null +++ b/src/Umbraco.Core/Persistence/Factories/DictionaryItemFactory.cs @@ -0,0 +1,22 @@ +using Umbraco.Core.Models; +using Umbraco.Core.Models.Rdbms; + +namespace Umbraco.Core.Persistence.Factories +{ + internal class DictionaryItemFactory : IEntityFactory + { + #region Implementation of IEntityFactory + + public DictionaryItem BuildEntity(DictionaryDto dto) + { + throw new System.NotImplementedException(); + } + + public DictionaryDto BuildDto(DictionaryItem entity) + { + throw new System.NotImplementedException(); + } + + #endregion + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Factories/DictionaryTranslationFactory.cs b/src/Umbraco.Core/Persistence/Factories/DictionaryTranslationFactory.cs new file mode 100644 index 0000000000..3cf4921634 --- /dev/null +++ b/src/Umbraco.Core/Persistence/Factories/DictionaryTranslationFactory.cs @@ -0,0 +1,22 @@ +using Umbraco.Core.Models; +using Umbraco.Core.Models.Rdbms; + +namespace Umbraco.Core.Persistence.Factories +{ + internal class DictionaryTranslationFactory : IEntityFactory + { + #region Implementation of IEntityFactory + + public DictionaryTranslation BuildEntity(LanguageTextDto dto) + { + throw new System.NotImplementedException(); + } + + public LanguageTextDto BuildDto(DictionaryTranslation entity) + { + throw new System.NotImplementedException(); + } + + #endregion + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Factories/LanguageFactory.cs b/src/Umbraco.Core/Persistence/Factories/LanguageFactory.cs new file mode 100644 index 0000000000..71a3d6ebc7 --- /dev/null +++ b/src/Umbraco.Core/Persistence/Factories/LanguageFactory.cs @@ -0,0 +1,22 @@ +using Umbraco.Core.Models; +using Umbraco.Core.Models.Rdbms; + +namespace Umbraco.Core.Persistence.Factories +{ + internal class LanguageFactory : IEntityFactory + { + #region Implementation of IEntityFactory + + public Language BuildEntity(LanguageDto dto) + { + throw new System.NotImplementedException(); + } + + public LanguageDto BuildDto(Language entity) + { + throw new System.NotImplementedException(); + } + + #endregion + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Repositories/DictionaryRepository.cs b/src/Umbraco.Core/Persistence/Repositories/DictionaryRepository.cs new file mode 100644 index 0000000000..badcda7f97 --- /dev/null +++ b/src/Umbraco.Core/Persistence/Repositories/DictionaryRepository.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using Umbraco.Core.Models; +using Umbraco.Core.Models.Rdbms; +using Umbraco.Core.Persistence.Caching; +using Umbraco.Core.Persistence.Querying; +using Umbraco.Core.Persistence.UnitOfWork; + +namespace Umbraco.Core.Persistence.Repositories +{ + internal class DictionaryRepository : PetaPocoRepositoryBase, IDictionaryRepository + { + public DictionaryRepository(IUnitOfWork work) : base(work) + { + } + + public DictionaryRepository(IUnitOfWork work, IRepositoryCacheProvider cache) : base(work, cache) + { + } + + #region Overrides of RepositoryBase + + protected override DictionaryItem PerformGet(int id) + { + throw new NotImplementedException(); + } + + protected override IEnumerable PerformGetAll(params int[] ids) + { + throw new NotImplementedException(); + } + + protected override IEnumerable PerformGetByQuery(IQuery query) + { + throw new NotImplementedException(); + } + + #endregion + + #region Overrides of PetaPocoRepositoryBase + + protected override Sql GetBaseQuery(bool isCount) + { + var sql = new Sql(); + sql.Select(isCount ? "COUNT(*)" : "*"); + sql.From("cmsDictionary"); + sql.InnerJoin("cmsLanguageText ON ([cmsDictionary].[id] = [cmsLanguageText].[UniqueId])"); + return sql; + } + + protected override Sql GetBaseWhereClause(object id) + { + var sql = new Sql(); + sql.Where("[cmsDictionary].[id] = @Id", new { Id = id }); + return sql; + } + + protected override IEnumerable GetDeleteClauses() + { + return new List(); + } + + /// + /// Returns the Top Level Parent Guid Id + /// + protected override Guid NodeObjectTypeId + { + get { return new Guid("41c7638d-f529-4bff-853e-59a0c2fb1bde"); } + } + + #endregion + + #region Unit of Work Implementation + + protected override void PersistNewItem(DictionaryItem entity) + { + throw new NotImplementedException(); + } + + protected override void PersistUpdatedItem(DictionaryItem entity) + { + throw new NotImplementedException(); + } + + protected override void PersistDeletedItem(DictionaryItem entity) + { + RecursiveDelete(entity.Key); + + Database.Delete("WHERE UniqueId = @Id", new { Id = entity.Key}); + + Database.Delete("WHERE id = @Id", new { Id = entity.Key }); + } + + private void RecursiveDelete(Guid parentId) + { + var list = Database.Fetch("WHERE parent = @ParentId", new {ParentId = parentId}); + foreach (var dto in list) + { + RecursiveDelete(dto.Id); + + Database.Delete("WHERE UniqueId = @Id", new { Id = dto.Id }); + Database.Delete("WHERE id = @Id", new { Id = dto.Id }); + } + } + + #endregion + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Repositories/IDictionaryRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IDictionaryRepository.cs new file mode 100644 index 0000000000..2db4046efc --- /dev/null +++ b/src/Umbraco.Core/Persistence/Repositories/IDictionaryRepository.cs @@ -0,0 +1,9 @@ +using Umbraco.Core.Models; + +namespace Umbraco.Core.Persistence.Repositories +{ + internal interface IDictionaryRepository : IRepository + { + + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Repositories/ILanguageRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ILanguageRepository.cs new file mode 100644 index 0000000000..3273df2d7a --- /dev/null +++ b/src/Umbraco.Core/Persistence/Repositories/ILanguageRepository.cs @@ -0,0 +1,9 @@ +using Umbraco.Core.Models; + +namespace Umbraco.Core.Persistence.Repositories +{ + public interface ILanguageRepository : IRepository + { + + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Repositories/LanguageRepository.cs b/src/Umbraco.Core/Persistence/Repositories/LanguageRepository.cs new file mode 100644 index 0000000000..b32385931a --- /dev/null +++ b/src/Umbraco.Core/Persistence/Repositories/LanguageRepository.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using Umbraco.Core.Models; +using Umbraco.Core.Persistence.Caching; +using Umbraco.Core.Persistence.Querying; +using Umbraco.Core.Persistence.UnitOfWork; + +namespace Umbraco.Core.Persistence.Repositories +{ + internal class LanguageRepository : PetaPocoRepositoryBase, ILanguageRepository + { + public LanguageRepository(IUnitOfWork work) : base(work) + { + } + + public LanguageRepository(IUnitOfWork work, IRepositoryCacheProvider cache) : base(work, cache) + { + } + + #region Overrides of RepositoryBase + + protected override Language PerformGet(int id) + { + throw new NotImplementedException(); + } + + protected override IEnumerable PerformGetAll(params int[] ids) + { + throw new NotImplementedException(); + } + + protected override IEnumerable PerformGetByQuery(IQuery query) + { + throw new NotImplementedException(); + } + + #endregion + + #region Overrides of PetaPocoRepositoryBase + + protected override Sql GetBaseQuery(bool isCount) + { + var sql = new Sql(); + sql.Select(isCount ? "COUNT(*)" : "*"); + sql.From("cmsLanguageText"); + return sql; + } + + protected override Sql GetBaseWhereClause(object id) + { + var sql = new Sql(); + sql.Where("[cmsLanguageText].[id] = @Id", new { Id = id }); + return sql; + } + + protected override IEnumerable GetDeleteClauses() + { + //NOTE: There is no constraint between the Language and cmsDictionary/cmsLanguageText tables (?) + var list = new List + { + string.Format("DELETE FROM umbracoLanguage WHERE id = @Id") + }; + return list; + } + + protected override Guid NodeObjectTypeId + { + get { throw new NotImplementedException(); } + } + + #endregion + + #region Unit of Work Implementation + + protected override void PersistNewItem(Language entity) + { + throw new NotImplementedException(); + } + + protected override void PersistUpdatedItem(Language entity) + { + throw new NotImplementedException(); + } + + #endregion + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index cc90a29413..e9ee43167c 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -101,7 +101,10 @@ + + + @@ -112,12 +115,16 @@ + + + +