From feeb1c56cfac74d00110875624f4a0bcf55706b7 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 20 Sep 2018 14:58:15 +1000 Subject: [PATCH] wip for IDocumentEntitySlim changes --- .../Models/Entities/DocumentEntitySlim.cs | 21 +++++++++++++ .../Models/Entities/IContentEntitySlim.cs | 2 +- .../Models/Entities/IDocumentEntitySlim.cs | 31 ++++++++++++------- .../Implement/EntityRepository.cs | 3 +- 4 files changed, 44 insertions(+), 13 deletions(-) diff --git a/src/Umbraco.Core/Models/Entities/DocumentEntitySlim.cs b/src/Umbraco.Core/Models/Entities/DocumentEntitySlim.cs index 5b63ad81c5..39ece5fa10 100644 --- a/src/Umbraco.Core/Models/Entities/DocumentEntitySlim.cs +++ b/src/Umbraco.Core/Models/Entities/DocumentEntitySlim.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; namespace Umbraco.Core.Models.Entities { @@ -8,13 +9,32 @@ namespace Umbraco.Core.Models.Entities public class DocumentEntitySlim : ContentEntitySlim, IDocumentEntitySlim { private static readonly IReadOnlyDictionary Empty = new Dictionary(); + private IReadOnlyDictionary _cultureNames; + private IEnumerable _publishedCultures; + private IEnumerable _editedCultures; + + /// public IReadOnlyDictionary CultureNames { get => _cultureNames ?? Empty; set => _cultureNames = value; } + /// + public IEnumerable PublishedCultures + { + get => _publishedCultures ?? Enumerable.Empty(); + set => _publishedCultures = value; + } + + /// + public IEnumerable EditedCultures + { + get => _editedCultures ?? Enumerable.Empty(); + set => _editedCultures = value; + } + public ContentVariation Variations { get; set; } /// @@ -22,5 +42,6 @@ namespace Umbraco.Core.Models.Entities /// public bool Edited { get; set; } + } } diff --git a/src/Umbraco.Core/Models/Entities/IContentEntitySlim.cs b/src/Umbraco.Core/Models/Entities/IContentEntitySlim.cs index dc986a4cd9..9ab557b02c 100644 --- a/src/Umbraco.Core/Models/Entities/IContentEntitySlim.cs +++ b/src/Umbraco.Core/Models/Entities/IContentEntitySlim.cs @@ -20,4 +20,4 @@ /// string ContentTypeThumbnail { get; } } -} \ No newline at end of file +} diff --git a/src/Umbraco.Core/Models/Entities/IDocumentEntitySlim.cs b/src/Umbraco.Core/Models/Entities/IDocumentEntitySlim.cs index 6b72fd4a2b..38fd9a02f1 100644 --- a/src/Umbraco.Core/Models/Entities/IDocumentEntitySlim.cs +++ b/src/Umbraco.Core/Models/Entities/IDocumentEntitySlim.cs @@ -7,26 +7,35 @@ namespace Umbraco.Core.Models.Entities /// public interface IDocumentEntitySlim : IContentEntitySlim { - //fixme we need to supply more information than this and change this property name. This will need to include Published/Editor per variation since we need this information for the tree + /// + /// Gets the variant name for each culture + /// IReadOnlyDictionary CultureNames { get; } + /// + /// Gets the published cultures. + /// + IEnumerable PublishedCultures { get; } + + /// + /// Gets the edited cultures. + /// + IEnumerable EditedCultures { get; } + + /// + /// Gets the content variation of the content type. + /// ContentVariation Variations { get; } /// - /// At least one variation is published + /// Gets a value indicating whether the content is published. /// - /// - /// If the document is invariant, this simply means there is a published version - /// - bool Published { get; set; } + bool Published { get; } /// - /// At least one variation has pending changes + /// Gets a value indicating whether the content has been edited. /// - /// - /// If the document is invariant, this simply means there is pending changes - /// - bool Edited { get; set; } + bool Edited { get; } } } diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/EntityRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/EntityRepository.cs index 340eecb538..7dd2b7ff27 100644 --- a/src/Umbraco.Core/Persistence/Repositories/Implement/EntityRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/Implement/EntityRepository.cs @@ -901,10 +901,11 @@ namespace Umbraco.Core.Persistence.Repositories.Implement var entity = new DocumentEntitySlim(); BuildContentEntity(entity, dto); - //fixme we need to set these statuses for each variant, see notes in IDocumentEntitySlim + //fill in the invariant info entity.Edited = dto.Edited; entity.Published = dto.Published; + //fill in the variant info if (dto.Variations.VariesByCulture() && dto.VariationInfo != null && dto.VariationInfo.Count > 0) { var variantInfo = new Dictionary(StringComparer.InvariantCultureIgnoreCase);