init commit of removing code for entity service that loads in any property data
This commit is contained in:
@@ -87,9 +87,9 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
if (isContent)
|
||||
BuildVariants(entities.Cast<DocumentEntitySlim>());
|
||||
|
||||
// TODO: see https://github.com/umbraco/Umbraco-CMS/pull/3460#issuecomment-434903930 we need to not load any property data at all for media
|
||||
if (isMedia)
|
||||
BuildProperties(entities, dtos.ToList());
|
||||
//// TODO: see https://github.com/umbraco/Umbraco-CMS/pull/3460#issuecomment-434903930 we need to not load any property data at all for media
|
||||
//if (isMedia)
|
||||
// BuildProperties(entities, dtos.ToList());
|
||||
|
||||
return entities;
|
||||
}
|
||||
@@ -117,8 +117,8 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
|
||||
var entity = BuildEntity(false, isMedia, dto);
|
||||
|
||||
if (isMedia)
|
||||
BuildProperties(entity, dto);
|
||||
//if (isMedia)
|
||||
// BuildProperties(entity, dto);
|
||||
|
||||
return entity;
|
||||
}
|
||||
@@ -162,7 +162,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
: PerformGetAll(objectType);
|
||||
}
|
||||
|
||||
private IEnumerable<IEntitySlim> GetEntities(Sql<ISqlContext> sql, bool isContent, bool isMedia, bool loadMediaProperties)
|
||||
private IEnumerable<IEntitySlim> GetEntities(Sql<ISqlContext> sql, bool isContent, bool isMedia)
|
||||
{
|
||||
//isContent is going to return a 1:M result now with the variants so we need to do different things
|
||||
if (isContent)
|
||||
@@ -179,9 +179,9 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
|
||||
var entities = dtos.Select(x => BuildEntity(false, isMedia, x)).ToArray();
|
||||
|
||||
// TODO: See https://github.com/umbraco/Umbraco-CMS/pull/3460#issuecomment-434903930 we need to not load any property data at all for media
|
||||
if (isMedia && loadMediaProperties)
|
||||
BuildProperties(entities, dtos);
|
||||
//// TODO: See https://github.com/umbraco/Umbraco-CMS/pull/3460#issuecomment-434903930 we need to not load any property data at all for media
|
||||
//if (isMedia && loadMediaProperties)
|
||||
// BuildProperties(entities, dtos);
|
||||
|
||||
return entities;
|
||||
}
|
||||
@@ -192,7 +192,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
var isMedia = objectType == Constants.ObjectTypes.Media;
|
||||
|
||||
var sql = GetFullSqlForEntityType(isContent, isMedia, objectType, filter);
|
||||
return GetEntities(sql, isContent, isMedia, true);
|
||||
return GetEntities(sql, isContent, isMedia);
|
||||
}
|
||||
|
||||
public IEnumerable<TreeEntityPath> GetAllPaths(Guid objectType, params int[] ids)
|
||||
@@ -238,23 +238,23 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
sql = translator.Translate();
|
||||
sql = AddGroupBy(isContent, isMedia, sql, true);
|
||||
|
||||
return GetEntities(sql, isContent, isMedia, true);
|
||||
return GetEntities(sql, isContent, isMedia);
|
||||
}
|
||||
|
||||
// TODO: See https://github.com/umbraco/Umbraco-CMS/pull/3460#issuecomment-434903930 we need to not load any property data at all for media
|
||||
internal IEnumerable<IEntitySlim> GetMediaByQueryWithoutPropertyData(IQuery<IUmbracoEntity> query)
|
||||
{
|
||||
var isContent = false;
|
||||
var isMedia = true;
|
||||
//// TODO: See https://github.com/umbraco/Umbraco-CMS/pull/3460#issuecomment-434903930 we need to not load any property data at all for media
|
||||
//internal IEnumerable<IEntitySlim> GetMediaByQueryWithoutPropertyData(IQuery<IUmbracoEntity> query)
|
||||
//{
|
||||
// var isContent = false;
|
||||
// var isMedia = true;
|
||||
|
||||
var sql = GetBaseWhere(isContent, isMedia, false, null, Constants.ObjectTypes.Media);
|
||||
// var sql = GetBaseWhere(isContent, isMedia, false, null, Constants.ObjectTypes.Media);
|
||||
|
||||
var translator = new SqlTranslator<IUmbracoEntity>(sql, query);
|
||||
sql = translator.Translate();
|
||||
sql = AddGroupBy(isContent, isMedia, sql, true);
|
||||
// var translator = new SqlTranslator<IUmbracoEntity>(sql, query);
|
||||
// sql = translator.Translate();
|
||||
// sql = AddGroupBy(isContent, isMedia, sql, true);
|
||||
|
||||
return GetEntities(sql, isContent, isMedia, false);
|
||||
}
|
||||
// return GetEntities(sql, isContent, isMedia, false);
|
||||
//}
|
||||
|
||||
public UmbracoObjectTypes GetObjectType(int id)
|
||||
{
|
||||
@@ -280,40 +280,40 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
return Database.ExecuteScalar<int>(sql) > 0;
|
||||
}
|
||||
|
||||
// TODO: see https://github.com/umbraco/Umbraco-CMS/pull/3460#issuecomment-434903930 we need to not load any property data at all for media
|
||||
private void BuildProperties(EntitySlim entity, BaseDto dto)
|
||||
{
|
||||
var pdtos = Database.Fetch<PropertyDataDto>(GetPropertyData(dto.VersionId));
|
||||
foreach (var pdto in pdtos)
|
||||
BuildProperty(entity, pdto);
|
||||
}
|
||||
//// TODO: see https://github.com/umbraco/Umbraco-CMS/pull/3460#issuecomment-434903930 we need to not load any property data at all for media
|
||||
//private void BuildProperties(EntitySlim entity, BaseDto dto)
|
||||
//{
|
||||
// var pdtos = Database.Fetch<PropertyDataDto>(GetPropertyData(dto.VersionId));
|
||||
// foreach (var pdto in pdtos)
|
||||
// BuildProperty(entity, pdto);
|
||||
//}
|
||||
|
||||
// TODO: see https://github.com/umbraco/Umbraco-CMS/pull/3460#issuecomment-434903930 we need to not load any property data at all for media
|
||||
private void BuildProperties(EntitySlim[] entities, List<BaseDto> dtos)
|
||||
{
|
||||
var versionIds = dtos.Select(x => x.VersionId).Distinct().ToList();
|
||||
var pdtos = Database.FetchByGroups<PropertyDataDto, int>(versionIds, 2000, GetPropertyData);
|
||||
//// TODO: see https://github.com/umbraco/Umbraco-CMS/pull/3460#issuecomment-434903930 we need to not load any property data at all for media
|
||||
//private void BuildProperties(EntitySlim[] entities, List<BaseDto> dtos)
|
||||
//{
|
||||
// var versionIds = dtos.Select(x => x.VersionId).Distinct().ToList();
|
||||
// var pdtos = Database.FetchByGroups<PropertyDataDto, int>(versionIds, 2000, GetPropertyData);
|
||||
|
||||
var xentity = entities.ToDictionary(x => x.Id, x => x); // nodeId -> entity
|
||||
var xdto = dtos.ToDictionary(x => x.VersionId, x => x.NodeId); // versionId -> nodeId
|
||||
foreach (var pdto in pdtos)
|
||||
{
|
||||
var nodeId = xdto[pdto.VersionId];
|
||||
var entity = xentity[nodeId];
|
||||
BuildProperty(entity, pdto);
|
||||
}
|
||||
}
|
||||
// var xentity = entities.ToDictionary(x => x.Id, x => x); // nodeId -> entity
|
||||
// var xdto = dtos.ToDictionary(x => x.VersionId, x => x.NodeId); // versionId -> nodeId
|
||||
// foreach (var pdto in pdtos)
|
||||
// {
|
||||
// var nodeId = xdto[pdto.VersionId];
|
||||
// var entity = xentity[nodeId];
|
||||
// BuildProperty(entity, pdto);
|
||||
// }
|
||||
//}
|
||||
|
||||
// TODO: see https://github.com/umbraco/Umbraco-CMS/pull/3460#issuecomment-434903930 we need to not load any property data at all for media
|
||||
private void BuildProperty(EntitySlim entity, PropertyDataDto pdto)
|
||||
{
|
||||
// explain ?!
|
||||
var value = string.IsNullOrWhiteSpace(pdto.TextValue)
|
||||
? pdto.VarcharValue
|
||||
: pdto.TextValue.ConvertToJsonIfPossible();
|
||||
//// TODO: see https://github.com/umbraco/Umbraco-CMS/pull/3460#issuecomment-434903930 we need to not load any property data at all for media
|
||||
//private void BuildProperty(EntitySlim entity, PropertyDataDto pdto)
|
||||
//{
|
||||
// // explain ?!
|
||||
// var value = string.IsNullOrWhiteSpace(pdto.TextValue)
|
||||
// ? pdto.VarcharValue
|
||||
// : pdto.TextValue.ConvertToJsonIfPossible();
|
||||
|
||||
entity.AdditionalData[pdto.PropertyTypeDto.Alias] = new EntitySlim.PropertySlim(pdto.PropertyTypeDto.DataTypeDto.EditorAlias, value);
|
||||
}
|
||||
// entity.AdditionalData[pdto.PropertyTypeDto.Alias] = new EntitySlim.PropertySlim(pdto.PropertyTypeDto.DataTypeDto.EditorAlias, value);
|
||||
//}
|
||||
|
||||
private DocumentEntitySlim BuildVariants(DocumentEntitySlim entity)
|
||||
=> BuildVariants(new[] { entity }).First();
|
||||
@@ -400,26 +400,26 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
return AddGroupBy(isContent, isMedia, sql, true);
|
||||
}
|
||||
|
||||
private Sql<ISqlContext> GetPropertyData(int versionId)
|
||||
{
|
||||
return Sql()
|
||||
.Select<PropertyDataDto>(r => r.Select(x => x.PropertyTypeDto, r1 => r1.Select(x => x.DataTypeDto)))
|
||||
.From<PropertyDataDto>()
|
||||
.InnerJoin<PropertyTypeDto>().On<PropertyDataDto, PropertyTypeDto>((left, right) => left.PropertyTypeId == right.Id)
|
||||
.InnerJoin<DataTypeDto>().On<PropertyTypeDto, DataTypeDto>((left, right) => left.DataTypeId == right.NodeId)
|
||||
.Where<PropertyDataDto>(x => x.VersionId == versionId);
|
||||
}
|
||||
//private Sql<ISqlContext> GetPropertyData(int versionId)
|
||||
//{
|
||||
// return Sql()
|
||||
// .Select<PropertyDataDto>(r => r.Select(x => x.PropertyTypeDto, r1 => r1.Select(x => x.DataTypeDto)))
|
||||
// .From<PropertyDataDto>()
|
||||
// .InnerJoin<PropertyTypeDto>().On<PropertyDataDto, PropertyTypeDto>((left, right) => left.PropertyTypeId == right.Id)
|
||||
// .InnerJoin<DataTypeDto>().On<PropertyTypeDto, DataTypeDto>((left, right) => left.DataTypeId == right.NodeId)
|
||||
// .Where<PropertyDataDto>(x => x.VersionId == versionId);
|
||||
//}
|
||||
|
||||
private Sql<ISqlContext> GetPropertyData(IEnumerable<int> versionIds)
|
||||
{
|
||||
return Sql()
|
||||
.Select<PropertyDataDto>(r => r.Select(x => x.PropertyTypeDto, r1 => r1.Select(x => x.DataTypeDto)))
|
||||
.From<PropertyDataDto>()
|
||||
.InnerJoin<PropertyTypeDto>().On<PropertyDataDto, PropertyTypeDto>((left, right) => left.PropertyTypeId == right.Id)
|
||||
.InnerJoin<DataTypeDto>().On<PropertyTypeDto, DataTypeDto>((left, right) => left.DataTypeId == right.NodeId)
|
||||
.WhereIn<PropertyDataDto>(x => x.VersionId, versionIds)
|
||||
.OrderBy<PropertyDataDto>(x => x.VersionId);
|
||||
}
|
||||
//private Sql<ISqlContext> GetPropertyData(IEnumerable<int> versionIds)
|
||||
//{
|
||||
// return Sql()
|
||||
// .Select<PropertyDataDto>(r => r.Select(x => x.PropertyTypeDto, r1 => r1.Select(x => x.DataTypeDto)))
|
||||
// .From<PropertyDataDto>()
|
||||
// .InnerJoin<PropertyTypeDto>().On<PropertyDataDto, PropertyTypeDto>((left, right) => left.PropertyTypeId == right.Id)
|
||||
// .InnerJoin<DataTypeDto>().On<PropertyTypeDto, DataTypeDto>((left, right) => left.DataTypeId == right.NodeId)
|
||||
// .WhereIn<PropertyDataDto>(x => x.VersionId, versionIds)
|
||||
// .OrderBy<PropertyDataDto>(x => x.VersionId);
|
||||
//}
|
||||
|
||||
// gets the base SELECT + FROM [+ filter] sql
|
||||
// always from the 'current' content version
|
||||
@@ -566,21 +566,21 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
|
||||
#region Classes
|
||||
|
||||
[ExplicitColumns]
|
||||
internal class UmbracoPropertyDto
|
||||
{
|
||||
[Column("propertyEditorAlias")]
|
||||
public string PropertyEditorAlias { get; set; }
|
||||
//[ExplicitColumns]
|
||||
//internal class UmbracoPropertyDto
|
||||
//{
|
||||
// [Column("propertyEditorAlias")]
|
||||
// public string PropertyEditorAlias { get; set; }
|
||||
|
||||
[Column("propertyTypeAlias")]
|
||||
public string PropertyAlias { get; set; }
|
||||
// [Column("propertyTypeAlias")]
|
||||
// public string PropertyAlias { get; set; }
|
||||
|
||||
[Column("varcharValue")]
|
||||
public string VarcharValue { get; set; }
|
||||
// [Column("varcharValue")]
|
||||
// public string VarcharValue { get; set; }
|
||||
|
||||
[Column("textValue")]
|
||||
public string TextValue { get; set; }
|
||||
}
|
||||
// [Column("textValue")]
|
||||
// public string TextValue { get; set; }
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -15,92 +15,40 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="id">The identifier of the entity.</param>
|
||||
IEntitySlim Get(int id);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an entity.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier of the entity.</param>
|
||||
/// <param name="full">A value indicating whether to load a light entity, or the full entity.</param>
|
||||
/// <remarks>Returns either a <see cref="IEntitySlim"/>, or an actual entity, depending on <paramref name="full"/>.</remarks>
|
||||
IUmbracoEntity Get(int id, bool full);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an entity.
|
||||
/// </summary>
|
||||
/// <param name="key">The unique key of the entity.</param>
|
||||
IEntitySlim Get(Guid key);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an entity.
|
||||
/// </summary>
|
||||
/// <param name="key">The unique key of the entity.</param>
|
||||
/// <param name="full">A value indicating whether to load a light entity, or the full entity.</param>
|
||||
/// <remarks>Returns either a <see cref="IEntitySlim"/>, or an actual entity, depending on <paramref name="full"/>.</remarks>
|
||||
IUmbracoEntity Get(Guid key, bool full);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an entity.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier of the entity.</param>
|
||||
/// <param name="objectType">The object type of the entity.</param>
|
||||
IEntitySlim Get(int id, UmbracoObjectTypes objectType);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an entity.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier of the entity.</param>
|
||||
/// <param name="objectType">The object type of the entity.</param>
|
||||
/// <param name="full">A value indicating whether to load a light entity, or the full entity.</param>
|
||||
/// <remarks>Returns either a <see cref="IEntitySlim"/>, or an actual entity, depending on <paramref name="full"/>.</remarks>
|
||||
IUmbracoEntity Get(int id, UmbracoObjectTypes objectType, bool full);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets an entity.
|
||||
/// </summary>
|
||||
/// <param name="key">The unique key of the entity.</param>
|
||||
/// <param name="objectType">The object type of the entity.</param>
|
||||
IEntitySlim Get(Guid key, UmbracoObjectTypes objectType);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an entity.
|
||||
/// </summary>
|
||||
/// <param name="key">The unique key of the entity.</param>
|
||||
/// <param name="objectType">The object type of the entity.</param>
|
||||
/// <param name="full">A value indicating whether to load a light entity, or the full entity.</param>
|
||||
/// <remarks>Returns either a <see cref="IEntitySlim"/>, or an actual entity, depending on <paramref name="full"/>.</remarks>
|
||||
IUmbracoEntity Get(Guid key, UmbracoObjectTypes objectType, bool full);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets an entity.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type used to determine the object type of the entity.</typeparam>
|
||||
/// <param name="id">The identifier of the entity.</param>
|
||||
IEntitySlim Get<T>(int id) where T : IUmbracoEntity;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an entity.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type used to determine the object type of the entity.</typeparam>
|
||||
/// <param name="id">The identifier of the entity.</param>
|
||||
/// <param name="full">A value indicating whether to load a light entity, or the full entity.</param>
|
||||
/// <remarks>Returns either a <see cref="IEntitySlim"/>, or an actual entity, depending on <paramref name="full"/>.</remarks>
|
||||
IUmbracoEntity Get<T>(int id, bool full) where T : IUmbracoEntity;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets an entity.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type used to determine the object type of the entity.</typeparam>
|
||||
/// <param name="key">The unique key of the entity.</param>
|
||||
IEntitySlim Get<T>(Guid key) where T : IUmbracoEntity;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an entity.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type used to determine the object type of the entity.</typeparam>
|
||||
/// <param name="key">The unique key of the entity.</param>
|
||||
/// <param name="full">A value indicating whether to load a light entity, or the full entity.</param>
|
||||
/// <remarks>Returns either a <see cref="IEntitySlim"/>, or an actual entity, depending on <paramref name="full"/>.</remarks>
|
||||
IUmbracoEntity Get<T>(Guid key, bool full) where T : IUmbracoEntity;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether an entity exists.
|
||||
/// </summary>
|
||||
|
||||
@@ -142,52 +142,43 @@ namespace Umbraco.Core.Services
|
||||
/// Gets the Child object from a Relation as an <see cref="IUmbracoEntity"/>
|
||||
/// </summary>
|
||||
/// <param name="relation">Relation to retrieve child object from</param>
|
||||
/// <param name="loadBaseType">Optional bool to load the complete object graph when set to <c>False</c></param>
|
||||
/// <returns>An <see cref="IUmbracoEntity"/></returns>
|
||||
IUmbracoEntity GetChildEntityFromRelation(IRelation relation, bool loadBaseType = false);
|
||||
IUmbracoEntity GetChildEntityFromRelation(IRelation relation);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Parent object from a Relation as an <see cref="IUmbracoEntity"/>
|
||||
/// </summary>
|
||||
/// <param name="relation">Relation to retrieve parent object from</param>
|
||||
/// <param name="loadBaseType">Optional bool to load the complete object graph when set to <c>False</c></param>
|
||||
/// <returns>An <see cref="IUmbracoEntity"/></returns>
|
||||
IUmbracoEntity GetParentEntityFromRelation(IRelation relation, bool loadBaseType = false);
|
||||
IUmbracoEntity GetParentEntityFromRelation(IRelation relation);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Parent and Child objects from a Relation as a <see cref="Tuple"/>"/> with <see cref="IUmbracoEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="relation">Relation to retrieve parent and child object from</param>
|
||||
/// <param name="loadBaseType">Optional bool to load the complete object graph when set to <c>False</c></param>
|
||||
/// <returns>Returns a Tuple with Parent (item1) and Child (item2)</returns>
|
||||
Tuple<IUmbracoEntity, IUmbracoEntity> GetEntitiesFromRelation(IRelation relation, bool loadBaseType = false);
|
||||
Tuple<IUmbracoEntity, IUmbracoEntity> GetEntitiesFromRelation(IRelation relation);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Child objects from a list of Relations as a list of <see cref="IUmbracoEntity"/> objects.
|
||||
/// </summary>
|
||||
/// <param name="relations">List of relations to retrieve child objects from</param>
|
||||
/// <param name="loadBaseType">Optional bool to load the complete object graph when set to <c>False</c></param>
|
||||
/// <returns>An enumerable list of <see cref="IUmbracoEntity"/></returns>
|
||||
IEnumerable<IUmbracoEntity> GetChildEntitiesFromRelations(IEnumerable<IRelation> relations, bool loadBaseType = false);
|
||||
IEnumerable<IUmbracoEntity> GetChildEntitiesFromRelations(IEnumerable<IRelation> relations);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Parent objects from a list of Relations as a list of <see cref="IUmbracoEntity"/> objects.
|
||||
/// </summary>
|
||||
/// <param name="relations">List of relations to retrieve parent objects from</param>
|
||||
/// <param name="loadBaseType">Optional bool to load the complete object graph when set to <c>False</c></param>
|
||||
/// <returns>An enumerable list of <see cref="IUmbracoEntity"/></returns>
|
||||
IEnumerable<IUmbracoEntity> GetParentEntitiesFromRelations(IEnumerable<IRelation> relations,
|
||||
bool loadBaseType = false);
|
||||
IEnumerable<IUmbracoEntity> GetParentEntitiesFromRelations(IEnumerable<IRelation> relations);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Parent and Child objects from a list of Relations as a list of <see cref="IUmbracoEntity"/> objects.
|
||||
/// </summary>
|
||||
/// <param name="relations">List of relations to retrieve parent and child objects from</param>
|
||||
/// <param name="loadBaseType">Optional bool to load the complete object graph when set to <c>False</c></param>
|
||||
/// <returns>An enumerable list of <see cref="Tuple"/> with <see cref="IUmbracoEntity"/></returns>
|
||||
IEnumerable<Tuple<IUmbracoEntity, IUmbracoEntity>> GetEntitiesFromRelations(
|
||||
IEnumerable<IRelation> relations,
|
||||
bool loadBaseType = false);
|
||||
IEnumerable<Tuple<IUmbracoEntity, IUmbracoEntity>> GetEntitiesFromRelations(IEnumerable<IRelation> relations);
|
||||
|
||||
/// <summary>
|
||||
/// Relates two objects by their entity Ids.
|
||||
|
||||
@@ -19,30 +19,25 @@ namespace Umbraco.Core.Services.Implement
|
||||
public class EntityService : ScopeRepositoryService, IEntityService
|
||||
{
|
||||
private readonly IEntityRepository _entityRepository;
|
||||
private readonly Dictionary<string, (UmbracoObjectTypes ObjectType, Func<int, IUmbracoEntity> GetById, Func<Guid, IUmbracoEntity> GetByKey)> _objectTypes;
|
||||
private readonly Dictionary<string, UmbracoObjectTypes> _objectTypes;
|
||||
private IQuery<IUmbracoEntity> _queryRootEntity;
|
||||
private readonly IdkMap _idkMap;
|
||||
|
||||
public EntityService(IScopeProvider provider, ILogger logger, IEventMessagesFactory eventMessagesFactory,
|
||||
IContentService contentService, IContentTypeService contentTypeService,
|
||||
IMediaService mediaService, IMediaTypeService mediaTypeService,
|
||||
IDataTypeService dataTypeService,
|
||||
IMemberService memberService, IMemberTypeService memberTypeService, IdkMap idkMap,
|
||||
IEntityRepository entityRepository)
|
||||
public EntityService(IScopeProvider provider, ILogger logger, IEventMessagesFactory eventMessagesFactory, IdkMap idkMap, IEntityRepository entityRepository)
|
||||
: base(provider, logger, eventMessagesFactory)
|
||||
{
|
||||
_idkMap = idkMap;
|
||||
_entityRepository = entityRepository;
|
||||
|
||||
_objectTypes = new Dictionary<string, (UmbracoObjectTypes, Func<int, IUmbracoEntity>, Func<Guid, IUmbracoEntity>)>
|
||||
_objectTypes = new Dictionary<string, UmbracoObjectTypes>
|
||||
{
|
||||
{ typeof (IDataType).FullName, (UmbracoObjectTypes.DataType, dataTypeService.GetDataType, dataTypeService.GetDataType) },
|
||||
{ typeof (IContent).FullName, (UmbracoObjectTypes.Document, contentService.GetById, contentService.GetById) },
|
||||
{ typeof (IContentType).FullName, (UmbracoObjectTypes.DocumentType, contentTypeService.Get, contentTypeService.Get) },
|
||||
{ typeof (IMedia).FullName, (UmbracoObjectTypes.Media, mediaService.GetById, mediaService.GetById) },
|
||||
{ typeof (IMediaType).FullName, (UmbracoObjectTypes.MediaType, mediaTypeService.Get, mediaTypeService.Get) },
|
||||
{ typeof (IMember).FullName, (UmbracoObjectTypes.Member, memberService.GetById, memberService.GetByKey) },
|
||||
{ typeof (IMemberType).FullName, (UmbracoObjectTypes.MemberType, memberTypeService.Get, memberTypeService.Get) },
|
||||
{ typeof (IDataType).FullName, UmbracoObjectTypes.DataType },
|
||||
{ typeof (IContent).FullName, UmbracoObjectTypes.Document },
|
||||
{ typeof (IContentType).FullName, UmbracoObjectTypes.DocumentType },
|
||||
{ typeof (IMedia).FullName, UmbracoObjectTypes.Media },
|
||||
{ typeof (IMediaType).FullName, UmbracoObjectTypes.MediaType },
|
||||
{ typeof (IMember).FullName, UmbracoObjectTypes.Member },
|
||||
{ typeof (IMemberType).FullName, UmbracoObjectTypes.MemberType },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -54,162 +49,68 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
#endregion
|
||||
|
||||
// gets the getters, throws if not supported
|
||||
private (UmbracoObjectTypes ObjectType, Func<int, IUmbracoEntity> GetById, Func<Guid, IUmbracoEntity> GetByKey) GetGetters(Type type)
|
||||
// gets the object type, throws if not supported
|
||||
private UmbracoObjectTypes GetObjectType(Type type)
|
||||
{
|
||||
if (type?.FullName == null || !_objectTypes.TryGetValue(type.FullName, out var getters))
|
||||
if (type?.FullName == null || !_objectTypes.TryGetValue(type.FullName, out var objType))
|
||||
throw new NotSupportedException($"Type \"{type?.FullName ?? "<null>"}\" is not supported here.");
|
||||
return getters;
|
||||
return objType;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEntitySlim Get(int id)
|
||||
{
|
||||
return (IEntitySlim) Get(id, false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IUmbracoEntity Get(int id, bool full)
|
||||
{
|
||||
if (!full)
|
||||
using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
// get the light entity
|
||||
using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
return _entityRepository.Get(id);
|
||||
}
|
||||
return _entityRepository.Get(id);
|
||||
}
|
||||
|
||||
// get the full entity
|
||||
var objectType = GetObjectType(id);
|
||||
var entityType = objectType.GetClrType();
|
||||
var getters = GetGetters(entityType);
|
||||
return getters.GetById(id);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEntitySlim Get(Guid key)
|
||||
{
|
||||
return (IEntitySlim) Get(key, false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IUmbracoEntity Get(Guid key, bool full)
|
||||
{
|
||||
if (!full)
|
||||
using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
// get the light entity
|
||||
using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
return _entityRepository.Get(key);
|
||||
}
|
||||
return _entityRepository.Get(key);
|
||||
}
|
||||
|
||||
// get the full entity
|
||||
var objectType = GetObjectType(key);
|
||||
var entityType = objectType.GetClrType();
|
||||
var getters = GetGetters(entityType);
|
||||
return getters.GetByKey(key);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual IEntitySlim Get(int id, UmbracoObjectTypes objectType)
|
||||
{
|
||||
return (IEntitySlim) Get(id, objectType, false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual IUmbracoEntity Get(int id, UmbracoObjectTypes objectType, bool full)
|
||||
{
|
||||
if (!full)
|
||||
using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
// get the light entity
|
||||
using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
return _entityRepository.Get(id, objectType.GetGuid());
|
||||
}
|
||||
return _entityRepository.Get(id, objectType.GetGuid());
|
||||
}
|
||||
|
||||
// get the full entity
|
||||
var entityType = objectType.GetClrType();
|
||||
var getters = GetGetters(entityType);
|
||||
return getters.GetById(id);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEntitySlim Get(Guid key, UmbracoObjectTypes objectType)
|
||||
{
|
||||
return (IEntitySlim) Get(key, objectType, false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IUmbracoEntity Get(Guid key, UmbracoObjectTypes objectType, bool full)
|
||||
{
|
||||
if (!full)
|
||||
using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
// get the light entity
|
||||
using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
return _entityRepository.Get(key, objectType.GetGuid());
|
||||
}
|
||||
return _entityRepository.Get(key, objectType.GetGuid());
|
||||
}
|
||||
|
||||
// get the full entity
|
||||
var entityType = objectType.GetClrType();
|
||||
var getters = GetGetters(entityType);
|
||||
return getters.GetByKey(key);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual IEntitySlim Get<T>(int id)
|
||||
where T : IUmbracoEntity
|
||||
{
|
||||
return (IEntitySlim) Get<T>(id, false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual IUmbracoEntity Get<T>(int id, bool full)
|
||||
where T : IUmbracoEntity
|
||||
{
|
||||
if (!full)
|
||||
using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
// get the light entity
|
||||
using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
return _entityRepository.Get(id);
|
||||
}
|
||||
return _entityRepository.Get(id);
|
||||
}
|
||||
|
||||
// get the full entity
|
||||
var entityType = typeof (T);
|
||||
var getters = GetGetters(entityType);
|
||||
return getters.GetById(id);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual IEntitySlim Get<T>(Guid key)
|
||||
where T : IUmbracoEntity
|
||||
{
|
||||
return (IEntitySlim) Get<T>(key, false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IUmbracoEntity Get<T>(Guid key, bool full)
|
||||
where T : IUmbracoEntity
|
||||
{
|
||||
if (!full)
|
||||
using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
// get the light entity
|
||||
using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
return _entityRepository.Get(key);
|
||||
}
|
||||
return _entityRepository.Get(key);
|
||||
}
|
||||
|
||||
// get the full entity
|
||||
var entityType = typeof (T);
|
||||
var getters = GetGetters(entityType);
|
||||
return getters.GetByKey(key);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -240,8 +141,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
where T : IUmbracoEntity
|
||||
{
|
||||
var entityType = typeof (T);
|
||||
var getters = GetGetters(entityType);
|
||||
var objectType = getters.ObjectType;
|
||||
var objectType = GetObjectType(entityType);
|
||||
var objectTypeId = objectType.GetGuid();
|
||||
|
||||
using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
@@ -261,7 +161,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
if (entityType == null)
|
||||
throw new NotSupportedException($"Type \"{objectType}\" is not supported here.");
|
||||
|
||||
GetGetters(entityType);
|
||||
GetObjectType(entityType);
|
||||
|
||||
using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
@@ -277,7 +177,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
public virtual IEnumerable<IEntitySlim> GetAll(Guid objectType, params int[] ids)
|
||||
{
|
||||
var entityType = ObjectTypes.GetClrType(objectType);
|
||||
GetGetters(entityType);
|
||||
GetObjectType(entityType);
|
||||
|
||||
using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
@@ -290,8 +190,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
where T : IUmbracoEntity
|
||||
{
|
||||
var entityType = typeof (T);
|
||||
var getters = GetGetters(entityType);
|
||||
var objectType = getters.ObjectType;
|
||||
var objectType = GetObjectType(entityType);
|
||||
var objectTypeId = objectType.GetGuid();
|
||||
|
||||
using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
@@ -304,7 +203,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
public IEnumerable<IEntitySlim> GetAll(UmbracoObjectTypes objectType, Guid[] keys)
|
||||
{
|
||||
var entityType = objectType.GetClrType();
|
||||
GetGetters(entityType);
|
||||
GetObjectType(entityType);
|
||||
|
||||
using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
@@ -316,7 +215,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
public virtual IEnumerable<IEntitySlim> GetAll(Guid objectType, params Guid[] keys)
|
||||
{
|
||||
var entityType = ObjectTypes.GetClrType(objectType);
|
||||
GetGetters(entityType);
|
||||
GetObjectType(entityType);
|
||||
|
||||
using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
@@ -377,21 +276,21 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of children by the parent's Id and UmbracoObjectType without adding property data
|
||||
/// </summary>
|
||||
/// <param name="parentId">Id of the parent to retrieve children for</param>
|
||||
/// <returns>An enumerable list of <see cref="IUmbracoEntity"/> objects</returns>
|
||||
internal IEnumerable<IEntitySlim> GetMediaChildrenWithoutPropertyData(int parentId)
|
||||
{
|
||||
using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
var query = Query<IUmbracoEntity>().Where(x => x.ParentId == parentId);
|
||||
///// <summary>
|
||||
///// Gets a collection of children by the parent's Id and UmbracoObjectType without adding property data
|
||||
///// </summary>
|
||||
///// <param name="parentId">Id of the parent to retrieve children for</param>
|
||||
///// <returns>An enumerable list of <see cref="IUmbracoEntity"/> objects</returns>
|
||||
//internal IEnumerable<IEntitySlim> GetMediaChildrenWithoutPropertyData(int parentId)
|
||||
//{
|
||||
// using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
// {
|
||||
// var query = Query<IUmbracoEntity>().Where(x => x.ParentId == parentId);
|
||||
|
||||
// TODO: see https://github.com/umbraco/Umbraco-CMS/pull/3460#issuecomment-434903930 we need to not load any property data at all for media
|
||||
return ((EntityRepository)_entityRepository).GetMediaByQueryWithoutPropertyData(query);
|
||||
}
|
||||
}
|
||||
// // TODO: see https://github.com/umbraco/Umbraco-CMS/pull/3460#issuecomment-434903930 we need to not load any property data at all for media
|
||||
// return ((EntityRepository)_entityRepository).GetMediaByQueryWithoutPropertyData(query);
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual IEnumerable<IEntitySlim> GetDescendants(int id)
|
||||
@@ -578,7 +477,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
public virtual IEnumerable<TreeEntityPath> GetAllPaths(UmbracoObjectTypes objectType, params int[] ids)
|
||||
{
|
||||
var entityType = objectType.GetClrType();
|
||||
GetGetters(entityType);
|
||||
GetObjectType(entityType);
|
||||
|
||||
using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
@@ -590,7 +489,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
public virtual IEnumerable<TreeEntityPath> GetAllPaths(UmbracoObjectTypes objectType, params Guid[] keys)
|
||||
{
|
||||
var entityType = objectType.GetClrType();
|
||||
GetGetters(entityType);
|
||||
GetObjectType(entityType);
|
||||
|
||||
using (ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
|
||||
@@ -285,39 +285,36 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// Gets the Child object from a Relation as an <see cref="IUmbracoEntity"/>
|
||||
/// </summary>
|
||||
/// <param name="relation">Relation to retrieve child object from</param>
|
||||
/// <param name="loadBaseType">Optional bool to load the complete object graph when set to <c>False</c></param>
|
||||
/// <returns>An <see cref="IUmbracoEntity"/></returns>
|
||||
public IUmbracoEntity GetChildEntityFromRelation(IRelation relation, bool loadBaseType = false)
|
||||
public IUmbracoEntity GetChildEntityFromRelation(IRelation relation)
|
||||
{
|
||||
var objectType = ObjectTypes.GetUmbracoObjectType(relation.RelationType.ChildObjectType);
|
||||
return _entityService.Get(relation.ChildId, objectType, loadBaseType);
|
||||
return _entityService.Get(relation.ChildId, objectType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Parent object from a Relation as an <see cref="IUmbracoEntity"/>
|
||||
/// </summary>
|
||||
/// <param name="relation">Relation to retrieve parent object from</param>
|
||||
/// <param name="loadBaseType">Optional bool to load the complete object graph when set to <c>False</c></param>
|
||||
/// <returns>An <see cref="IUmbracoEntity"/></returns>
|
||||
public IUmbracoEntity GetParentEntityFromRelation(IRelation relation, bool loadBaseType = false)
|
||||
public IUmbracoEntity GetParentEntityFromRelation(IRelation relation)
|
||||
{
|
||||
var objectType = ObjectTypes.GetUmbracoObjectType(relation.RelationType.ParentObjectType);
|
||||
return _entityService.Get(relation.ParentId, objectType, loadBaseType);
|
||||
return _entityService.Get(relation.ParentId, objectType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Parent and Child objects from a Relation as a <see cref="Tuple"/>"/> with <see cref="IUmbracoEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="relation">Relation to retrieve parent and child object from</param>
|
||||
/// <param name="loadBaseType">Optional bool to load the complete object graph when set to <c>False</c></param>
|
||||
/// <returns>Returns a Tuple with Parent (item1) and Child (item2)</returns>
|
||||
public Tuple<IUmbracoEntity, IUmbracoEntity> GetEntitiesFromRelation(IRelation relation, bool loadBaseType = false)
|
||||
public Tuple<IUmbracoEntity, IUmbracoEntity> GetEntitiesFromRelation(IRelation relation)
|
||||
{
|
||||
var childObjectType = ObjectTypes.GetUmbracoObjectType(relation.RelationType.ChildObjectType);
|
||||
var parentObjectType = ObjectTypes.GetUmbracoObjectType(relation.RelationType.ParentObjectType);
|
||||
|
||||
var child = _entityService.Get(relation.ChildId, childObjectType, loadBaseType);
|
||||
var parent = _entityService.Get(relation.ParentId, parentObjectType, loadBaseType);
|
||||
var child = _entityService.Get(relation.ChildId, childObjectType);
|
||||
var parent = _entityService.Get(relation.ParentId, parentObjectType);
|
||||
|
||||
return new Tuple<IUmbracoEntity, IUmbracoEntity>(parent, child);
|
||||
}
|
||||
@@ -326,14 +323,13 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// Gets the Child objects from a list of Relations as a list of <see cref="IUmbracoEntity"/> objects.
|
||||
/// </summary>
|
||||
/// <param name="relations">List of relations to retrieve child objects from</param>
|
||||
/// <param name="loadBaseType">Optional bool to load the complete object graph when set to <c>False</c></param>
|
||||
/// <returns>An enumerable list of <see cref="IUmbracoEntity"/></returns>
|
||||
public IEnumerable<IUmbracoEntity> GetChildEntitiesFromRelations(IEnumerable<IRelation> relations, bool loadBaseType = false)
|
||||
public IEnumerable<IUmbracoEntity> GetChildEntitiesFromRelations(IEnumerable<IRelation> relations)
|
||||
{
|
||||
foreach (var relation in relations)
|
||||
{
|
||||
var objectType = ObjectTypes.GetUmbracoObjectType(relation.RelationType.ChildObjectType);
|
||||
yield return _entityService.Get(relation.ChildId, objectType, loadBaseType);
|
||||
yield return _entityService.Get(relation.ChildId, objectType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,14 +337,13 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// Gets the Parent objects from a list of Relations as a list of <see cref="IUmbracoEntity"/> objects.
|
||||
/// </summary>
|
||||
/// <param name="relations">List of relations to retrieve parent objects from</param>
|
||||
/// <param name="loadBaseType">Optional bool to load the complete object graph when set to <c>False</c></param>
|
||||
/// <returns>An enumerable list of <see cref="IUmbracoEntity"/></returns>
|
||||
public IEnumerable<IUmbracoEntity> GetParentEntitiesFromRelations(IEnumerable<IRelation> relations, bool loadBaseType = false)
|
||||
public IEnumerable<IUmbracoEntity> GetParentEntitiesFromRelations(IEnumerable<IRelation> relations)
|
||||
{
|
||||
foreach (var relation in relations)
|
||||
{
|
||||
var objectType = ObjectTypes.GetUmbracoObjectType(relation.RelationType.ParentObjectType);
|
||||
yield return _entityService.Get(relation.ParentId, objectType, loadBaseType);
|
||||
yield return _entityService.Get(relation.ParentId, objectType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,17 +351,16 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// Gets the Parent and Child objects from a list of Relations as a list of <see cref="IUmbracoEntity"/> objects.
|
||||
/// </summary>
|
||||
/// <param name="relations">List of relations to retrieve parent and child objects from</param>
|
||||
/// <param name="loadBaseType">Optional bool to load the complete object graph when set to <c>False</c></param>
|
||||
/// <returns>An enumerable list of <see cref="Tuple"/> with <see cref="IUmbracoEntity"/></returns>
|
||||
public IEnumerable<Tuple<IUmbracoEntity, IUmbracoEntity>> GetEntitiesFromRelations(IEnumerable<IRelation> relations, bool loadBaseType = false)
|
||||
public IEnumerable<Tuple<IUmbracoEntity, IUmbracoEntity>> GetEntitiesFromRelations(IEnumerable<IRelation> relations)
|
||||
{
|
||||
foreach (var relation in relations)
|
||||
{
|
||||
var childObjectType = ObjectTypes.GetUmbracoObjectType(relation.RelationType.ChildObjectType);
|
||||
var parentObjectType = ObjectTypes.GetUmbracoObjectType(relation.RelationType.ParentObjectType);
|
||||
|
||||
var child = _entityService.Get(relation.ChildId, childObjectType, loadBaseType);
|
||||
var parent = _entityService.Get(relation.ParentId, parentObjectType, loadBaseType);
|
||||
var child = _entityService.Get(relation.ChildId, childObjectType);
|
||||
var parent = _entityService.Get(relation.ParentId, parentObjectType);
|
||||
|
||||
yield return new Tuple<IUmbracoEntity, IUmbracoEntity>(parent, child);
|
||||
}
|
||||
|
||||
@@ -164,11 +164,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
var fileService = GetLazyService<IFileService>(factory, c => new FileService(scopeProvider, logger, eventMessagesFactory, GetRepo<IStylesheetRepository>(c), GetRepo<IScriptRepository>(c), GetRepo<ITemplateRepository>(c), GetRepo<IPartialViewRepository>(c), GetRepo<IPartialViewMacroRepository>(c), GetRepo<IAuditRepository>(c)));
|
||||
|
||||
var memberTypeService = GetLazyService<IMemberTypeService>(factory, c => new MemberTypeService(scopeProvider, logger, eventMessagesFactory, memberService.Value, GetRepo<IMemberTypeRepository>(c), GetRepo<IAuditRepository>(c), GetRepo<IEntityRepository>(c)));
|
||||
var entityService = GetLazyService<IEntityService>(factory, c => new EntityService(
|
||||
scopeProvider, logger, eventMessagesFactory,
|
||||
contentService.Value, contentTypeService.Value, mediaService.Value, mediaTypeService.Value, dataTypeService.Value, memberService.Value, memberTypeService.Value,
|
||||
idkMap,
|
||||
GetRepo<IEntityRepository>(c)));
|
||||
var entityService = GetLazyService<IEntityService>(factory, c => new EntityService(scopeProvider, logger, eventMessagesFactory, idkMap, GetRepo<IEntityRepository>(c)));
|
||||
|
||||
var macroService = GetLazyService<IMacroService>(factory, c => new MacroService(scopeProvider, logger, eventMessagesFactory, GetRepo<IMacroRepository>(c), GetRepo<IAuditRepository>(c)));
|
||||
var packagingService = GetLazyService<IPackagingService>(factory, c =>
|
||||
|
||||
@@ -201,8 +201,8 @@ namespace Umbraco.Web.Trees
|
||||
return HasPathAccess(entity, queryStrings);
|
||||
}
|
||||
|
||||
internal override IEnumerable<IEntitySlim> GetChildrenFromEntityService(int entityId)
|
||||
=> Services.EntityService.GetChildren(entityId, UmbracoObjectType).ToList();
|
||||
//internal override IEnumerable<IEntitySlim> GetChildrenFromEntityService(int entityId)
|
||||
// => Services.EntityService.GetChildren(entityId, UmbracoObjectType).ToList();
|
||||
|
||||
protected override IEnumerable<IEntitySlim> GetChildEntities(string id, FormDataCollection queryStrings)
|
||||
{
|
||||
@@ -327,7 +327,7 @@ namespace Umbraco.Web.Trees
|
||||
|
||||
public IEnumerable<SearchResultEntity> Search(string query, int pageSize, long pageIndex, out long totalFound, string searchFrom = null)
|
||||
{
|
||||
return _treeSearcher.ExamineSearch(query, UmbracoEntityTypes.Document, pageSize, pageIndex, out totalFound, searchFrom);
|
||||
return _treeSearcher.ExamineSearch(query, UmbracoEntityTypes.Document, pageSize, pageIndex, out totalFound, false, searchFrom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,12 +214,8 @@ namespace Umbraco.Web.Trees
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Abstract method to fetch the entities from the entity service
|
||||
/// </summary>
|
||||
/// <param name="entityId"></param>
|
||||
/// <returns></returns>
|
||||
internal abstract IEnumerable<IEntitySlim> GetChildrenFromEntityService(int entityId);
|
||||
internal virtual IEnumerable<IEntitySlim> GetChildrenFromEntityService(int entityId)
|
||||
=> Services.EntityService.GetChildren(entityId, UmbracoObjectType).ToList();
|
||||
|
||||
/// <summary>
|
||||
/// Returns true or false if the current user has access to the node based on the user's allowed start node (path) access
|
||||
|
||||
@@ -164,14 +164,17 @@ namespace Umbraco.Web.Trees
|
||||
|
||||
public IEnumerable<SearchResultEntity> Search(string query, int pageSize, long pageIndex, out long totalFound, string searchFrom = null)
|
||||
{
|
||||
return _treeSearcher.ExamineSearch(query, UmbracoEntityTypes.Media, pageSize, pageIndex, out totalFound, searchFrom);
|
||||
return _treeSearcher.ExamineSearch(query, UmbracoEntityTypes.Media, pageSize, pageIndex, out totalFound, false, searchFrom);
|
||||
}
|
||||
|
||||
internal override IEnumerable<IEntitySlim> GetChildrenFromEntityService(int entityId)
|
||||
// Not pretty having to cast the service, but it is the only way to get to use an internal method that we
|
||||
// do not want to make public on the interface. Unfortunately also prevents this from being unit tested.
|
||||
// See this issue for details on why we need this:
|
||||
// https://github.com/umbraco/Umbraco-CMS/issues/3457
|
||||
=> ((EntityService)Services.EntityService).GetMediaChildrenWithoutPropertyData(entityId).ToList();
|
||||
//internal override IEnumerable<IEntitySlim> GetChildrenFromEntityService(int entityId)
|
||||
// => Services.EntityService.GetChildren(entityId, UmbracoObjectType).ToList();
|
||||
|
||||
//internal override IEnumerable<IEntitySlim> GetChildrenFromEntityService(int entityId)
|
||||
// // Not pretty having to cast the service, but it is the only way to get to use an internal method that we
|
||||
// // do not want to make public on the interface. Unfortunately also prevents this from being unit tested.
|
||||
// // See this issue for details on why we need this:
|
||||
// // https://github.com/umbraco/Umbraco-CMS/issues/3457
|
||||
// => ((EntityService)Services.EntityService).GetMediaChildrenWithoutPropertyData(entityId).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user