renames methods on ITagsRepository to make it clear that the tags repo/db table ONLY deals with published tags.
This commit is contained in:
@@ -574,7 +574,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
if (tagProp.TagSupport.Behavior == PropertyTagBehavior.Remove)
|
||||
{
|
||||
//remove the specific tags
|
||||
_tagRepository.RemoveTagsFromProperty(
|
||||
_tagRepository.RemovePublishedTagsFromProperty(
|
||||
entity.Id,
|
||||
tagProp.Alias,
|
||||
tagProp.TagSupport.Tags.Select(x => new Tag { Text = x.Item1, Group = x.Item2 }));
|
||||
@@ -582,7 +582,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
else
|
||||
{
|
||||
//assign the tags
|
||||
_tagRepository.AssignTagsToProperty(
|
||||
_tagRepository.AssignPublishedTagsToProperty(
|
||||
entity.Id,
|
||||
tagProp.Alias,
|
||||
tagProp.TagSupport.Tags.Select(x => new Tag { Text = x.Item1, Group = x.Item2 }),
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
/// </summary>
|
||||
/// <param name="contentId">The content item id to get tags for</param>
|
||||
/// <returns></returns>
|
||||
IEnumerable<ITag> GetTagsForContent(int contentId);
|
||||
IEnumerable<ITag> GetPublishedTagsForContent(int contentId);
|
||||
|
||||
/// <summary>
|
||||
/// Returns all tags that exist on the content item for the property specified - Content/Media/Member
|
||||
@@ -19,7 +19,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
/// <param name="contentId">The content item id to get tags for</param>
|
||||
/// <param name="propertyAlias">The property alias to get tags for</param>
|
||||
/// <returns></returns>
|
||||
IEnumerable<ITag> GetTagsForProperty(int contentId, string propertyAlias);
|
||||
IEnumerable<ITag> GetPublishedTagsForProperty(int contentId, string propertyAlias);
|
||||
|
||||
/// <summary>
|
||||
/// Assigns the given tags to a content item's property
|
||||
@@ -35,7 +35,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
/// <remarks>
|
||||
/// This can also be used to remove all tags from a property by specifying replaceTags = true and an empty tag list.
|
||||
/// </remarks>
|
||||
void AssignTagsToProperty(int contentId, string propertyAlias, IEnumerable<ITag> tags, bool replaceTags);
|
||||
void AssignPublishedTagsToProperty(int contentId, string propertyAlias, IEnumerable<ITag> tags, bool replaceTags);
|
||||
|
||||
/// <summary>
|
||||
/// Removes any of the given tags from the property association
|
||||
@@ -43,6 +43,6 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
/// <param name="contentId"></param>
|
||||
/// <param name="propertyAlias"></param>
|
||||
/// <param name="tags">The tags to remove from the property</param>
|
||||
void RemoveTagsFromProperty(int contentId, string propertyAlias, IEnumerable<ITag> tags);
|
||||
void RemovePublishedTagsFromProperty(int contentId, string propertyAlias, IEnumerable<ITag> tags);
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
//TODO: Consider caching implications.
|
||||
|
||||
public IEnumerable<ITag> GetTagsForContent(int contentId)
|
||||
public IEnumerable<ITag> GetPublishedTagsForContent(int contentId)
|
||||
{
|
||||
var sql = new Sql()
|
||||
.Select("DISTINCT cmsTags.*")
|
||||
@@ -174,7 +174,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
return Database.Fetch<TagDto>(sql).Select(factory.BuildEntity);
|
||||
}
|
||||
|
||||
public IEnumerable<ITag> GetTagsForProperty(int contentId, string propertyAlias)
|
||||
public IEnumerable<ITag> GetPublishedTagsForProperty(int contentId, string propertyAlias)
|
||||
{
|
||||
var sql = new Sql()
|
||||
.Select("DISTINCT cmsTags.*")
|
||||
@@ -205,7 +205,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
/// <remarks>
|
||||
/// This can also be used to remove all tags from a property by specifying replaceTags = true and an empty tag list.
|
||||
/// </remarks>
|
||||
public void AssignTagsToProperty(int contentId, string propertyAlias, IEnumerable<ITag> tags, bool replaceTags)
|
||||
public void AssignPublishedTagsToProperty(int contentId, string propertyAlias, IEnumerable<ITag> tags, bool replaceTags)
|
||||
{
|
||||
//First we need to ensure there are no duplicates
|
||||
var asArray = tags.Distinct(new TagComparer()).ToArray();
|
||||
@@ -294,7 +294,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
/// <param name="contentId"></param>
|
||||
/// <param name="propertyAlias"></param>
|
||||
/// <param name="tags">The tags to remove from the property</param>
|
||||
public void RemoveTagsFromProperty(int contentId, string propertyAlias, IEnumerable<ITag> tags)
|
||||
public void RemovePublishedTagsFromProperty(int contentId, string propertyAlias, IEnumerable<ITag> tags)
|
||||
{
|
||||
var propertyTypeId = EnsureContentProperty(contentId, propertyAlias);
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
using (var repository = CreateRepository(unitOfWork))
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => repository.AssignTagsToProperty(1234, "hello", Enumerable.Empty<ITag>(), true));
|
||||
Assert.Throws<InvalidOperationException>(() => repository.AssignPublishedTagsToProperty(1234, "hello", Enumerable.Empty<ITag>(), true));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -134,7 +134,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
using (var repository = CreateRepository(unitOfWork))
|
||||
{
|
||||
repository.AssignTagsToProperty(
|
||||
repository.AssignPublishedTagsToProperty(
|
||||
content.Id,
|
||||
contentType.PropertyTypes.First().Alias,
|
||||
new[]
|
||||
@@ -143,7 +143,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
new Tag {Text = "tag2", Group = "test"},
|
||||
}, false);
|
||||
|
||||
Assert.AreEqual(2, repository.GetTagsForContent(content.Id).Count());
|
||||
Assert.AreEqual(2, repository.GetPublishedTagsForContent(content.Id).Count());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,7 +166,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
using (var repository = CreateRepository(unitOfWork))
|
||||
{
|
||||
repository.AssignTagsToProperty(
|
||||
repository.AssignPublishedTagsToProperty(
|
||||
content.Id,
|
||||
contentType.PropertyTypes.First().Alias,
|
||||
new[]
|
||||
@@ -175,7 +175,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
new Tag {Text = "tag2", Group = "test"},
|
||||
}, false);
|
||||
|
||||
repository.AssignTagsToProperty(
|
||||
repository.AssignPublishedTagsToProperty(
|
||||
content.Id,
|
||||
contentType.PropertyTypes.First().Alias,
|
||||
new[]
|
||||
@@ -184,7 +184,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
new Tag {Text = "tag4", Group = "test"},
|
||||
}, false);
|
||||
|
||||
Assert.AreEqual(4, repository.GetTagsForContent(content.Id).Count());
|
||||
Assert.AreEqual(4, repository.GetPublishedTagsForContent(content.Id).Count());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,7 +207,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
using (var repository = CreateRepository(unitOfWork))
|
||||
{
|
||||
repository.AssignTagsToProperty(
|
||||
repository.AssignPublishedTagsToProperty(
|
||||
content.Id,
|
||||
contentType.PropertyTypes.First().Alias,
|
||||
new[]
|
||||
@@ -216,7 +216,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
new Tag {Text = "tag2", Group = "test"},
|
||||
}, false);
|
||||
|
||||
repository.AssignTagsToProperty(
|
||||
repository.AssignPublishedTagsToProperty(
|
||||
content.Id,
|
||||
contentType.PropertyTypes.First().Alias,
|
||||
new[]
|
||||
@@ -225,7 +225,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
new Tag {Text = "tag4", Group = "test"},
|
||||
}, true);
|
||||
|
||||
var result = repository.GetTagsForContent(content.Id);
|
||||
var result = repository.GetPublishedTagsForContent(content.Id);
|
||||
Assert.AreEqual(2, result.Count());
|
||||
Assert.AreEqual("tag3", result.ElementAt(0).Text);
|
||||
Assert.AreEqual("tag4", result.ElementAt(1).Text);
|
||||
@@ -251,7 +251,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
using (var repository = CreateRepository(unitOfWork))
|
||||
{
|
||||
repository.AssignTagsToProperty(
|
||||
repository.AssignPublishedTagsToProperty(
|
||||
content.Id,
|
||||
contentType.PropertyTypes.First().Alias,
|
||||
new[]
|
||||
@@ -260,7 +260,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
new Tag {Text = "tag2", Group = "test"},
|
||||
}, false);
|
||||
|
||||
repository.AssignTagsToProperty(
|
||||
repository.AssignPublishedTagsToProperty(
|
||||
content.Id,
|
||||
contentType.PropertyTypes.First().Alias,
|
||||
new[]
|
||||
@@ -269,7 +269,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
new Tag {Text = "tag3", Group = "test"},
|
||||
}, false);
|
||||
|
||||
var result = repository.GetTagsForContent(content.Id);
|
||||
var result = repository.GetPublishedTagsForContent(content.Id);
|
||||
Assert.AreEqual(3, result.Count());
|
||||
}
|
||||
}
|
||||
@@ -293,7 +293,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
using (var repository = CreateRepository(unitOfWork))
|
||||
{
|
||||
repository.AssignTagsToProperty(
|
||||
repository.AssignPublishedTagsToProperty(
|
||||
content.Id,
|
||||
contentType.PropertyTypes.First().Alias,
|
||||
new[]
|
||||
@@ -302,12 +302,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
new Tag {Text = "tag2", Group = "test"},
|
||||
}, false);
|
||||
|
||||
repository.AssignTagsToProperty(
|
||||
repository.AssignPublishedTagsToProperty(
|
||||
content.Id,
|
||||
contentType.PropertyTypes.First().Alias,
|
||||
Enumerable.Empty<ITag>(), true);
|
||||
|
||||
var result = repository.GetTagsForContent(content.Id);
|
||||
var result = repository.GetPublishedTagsForContent(content.Id);
|
||||
Assert.AreEqual(0, result.Count());
|
||||
}
|
||||
}
|
||||
@@ -331,7 +331,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
using (var repository = CreateRepository(unitOfWork))
|
||||
{
|
||||
repository.AssignTagsToProperty(
|
||||
repository.AssignPublishedTagsToProperty(
|
||||
content.Id,
|
||||
contentType.PropertyTypes.First().Alias,
|
||||
new[]
|
||||
@@ -342,7 +342,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
new Tag {Text = "tag4", Group = "test"}
|
||||
}, false);
|
||||
|
||||
repository.RemoveTagsFromProperty(
|
||||
repository.RemovePublishedTagsFromProperty(
|
||||
content.Id,
|
||||
contentType.PropertyTypes.First().Alias,
|
||||
new[]
|
||||
@@ -351,7 +351,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
new Tag {Text = "tag3", Group = "test"}
|
||||
});
|
||||
|
||||
var result = repository.GetTagsForContent(content.Id);
|
||||
var result = repository.GetPublishedTagsForContent(content.Id);
|
||||
Assert.AreEqual(2, result.Count());
|
||||
Assert.AreEqual("tag1", result.ElementAt(0).Text);
|
||||
Assert.AreEqual("tag4", result.ElementAt(1).Text);
|
||||
@@ -379,7 +379,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
using (var repository = CreateRepository(unitOfWork))
|
||||
{
|
||||
repository.AssignTagsToProperty(
|
||||
repository.AssignPublishedTagsToProperty(
|
||||
content1.Id,
|
||||
contentType.PropertyTypes.First().Alias,
|
||||
new[]
|
||||
@@ -390,7 +390,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
new Tag {Text = "tag4", Group = "test"}
|
||||
}, false);
|
||||
|
||||
repository.AssignTagsToProperty(
|
||||
repository.AssignPublishedTagsToProperty(
|
||||
content2.Id,
|
||||
contentType.PropertyTypes.First().Alias,
|
||||
new[]
|
||||
@@ -399,7 +399,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
new Tag {Text = "tag2", Group = "test"}
|
||||
}, false);
|
||||
|
||||
var result = repository.GetTagsForContent(content2.Id);
|
||||
var result = repository.GetPublishedTagsForContent(content2.Id);
|
||||
Assert.AreEqual(2, result.Count());
|
||||
}
|
||||
}
|
||||
@@ -423,7 +423,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
using (var repository = CreateRepository(unitOfWork))
|
||||
{
|
||||
repository.AssignTagsToProperty(
|
||||
repository.AssignPublishedTagsToProperty(
|
||||
content1.Id,
|
||||
contentType.PropertyTypes.First().Alias,
|
||||
new[]
|
||||
@@ -434,7 +434,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
new Tag {Text = "tag4", Group = "test"}
|
||||
}, false);
|
||||
|
||||
repository.AssignTagsToProperty(
|
||||
repository.AssignPublishedTagsToProperty(
|
||||
content1.Id,
|
||||
contentType.PropertyTypes.Last().Alias,
|
||||
new[]
|
||||
@@ -443,8 +443,8 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
new Tag {Text = "tag2", Group = "test"}
|
||||
}, false);
|
||||
|
||||
var result1 = repository.GetTagsForProperty(content1.Id, contentType.PropertyTypes.First().Alias).ToArray();
|
||||
var result2 = repository.GetTagsForProperty(content1.Id, contentType.PropertyTypes.Last().Alias).ToArray();
|
||||
var result1 = repository.GetPublishedTagsForProperty(content1.Id, contentType.PropertyTypes.First().Alias).ToArray();
|
||||
var result2 = repository.GetPublishedTagsForProperty(content1.Id, contentType.PropertyTypes.Last().Alias).ToArray();
|
||||
Assert.AreEqual(2, result2.Count());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user