2017-12-07 16:45:25 +01:00
using NPoco ;
2021-02-09 10:22:42 +01:00
using Umbraco.Cms.Core ;
using Umbraco.Cms.Core.Cache ;
using Umbraco.Cms.Core.Models ;
using Umbraco.Cms.Core.Models.Entities ;
using Umbraco.Cms.Core.Persistence.Querying ;
using Umbraco.Cms.Core.Services ;
2021-02-12 13:36:50 +01:00
using Umbraco.Cms.Infrastructure.Persistence.Dtos ;
using Umbraco.Cms.Infrastructure.Persistence.Querying ;
using Umbraco.Cms.Infrastructure.Persistence.SqlSyntax ;
2022-01-13 17:44:11 +00:00
using Umbraco.Cms.Infrastructure.Scoping ;
2021-02-09 11:26:22 +01:00
using Umbraco.Extensions ;
2021-02-09 10:22:42 +01:00
using static Umbraco . Cms . Core . Persistence . SqlExtensionsStatics ;
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement ;
/// <summary>
/// Represents the EntityRepository used to query entity objects.
/// </summary>
/// <remarks>
/// <para>Limited to objects that have a corresponding node (in umbracoNode table).</para>
/// <para>Returns <see cref="IEntitySlim" /> objects, i.e. lightweight representation of entities.</para>
/// </remarks>
internal class EntityRepository : RepositoryBase , IEntityRepositoryExtended
2017-12-07 16:45:25 +01:00
{
2022-06-02 08:18:31 +02:00
public EntityRepository ( IScopeAccessor scopeAccessor , AppCaches appCaches )
: base ( scopeAccessor , appCaches )
2017-12-07 16:45:25 +01:00
{
2022-06-02 08:18:31 +02:00
}
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
#region Repository
2020-12-09 22:43:49 +11:00
2024-04-04 11:27:13 +02:00
public int CountByQuery ( IQuery < IUmbracoEntity > query , IEnumerable < Guid > objectTypes , IQuery < IUmbracoEntity > ? filter )
2024-01-02 13:53:24 +01:00
{
Sql < ISqlContext > sql = Sql ( ) ;
sql . SelectCount ( ) ;
sql
. From < NodeDto > ( ) ;
Resolved more warnings, and marked more warning types as errors (#16991)
* Fix warnings SA1111, SA1028, SA1500, IDE1270 in Umbraco.Web.Website, and updated rules.
* Remove warnings: IDE0270: Null check can be simplified
* More SqlServer project warnings resolved
* CS0105 namespace appeared already
* Suppress warning until implementation:
#pragma warning disable CS0162 // Unreachable code detected
#pragma warning disable CS0618 // Type or member is obsolete
CS0162 remove unreachable code
SA1028 remove trailing whitespace
SA1106 no empty statements
CS1570 malformed XML
CS1572 corrected xml parameter
CS1573 param tag added
IDE0007 var not explicit
IDE0008 explicit not var
IDE0057 simplify substring
IDE0074 compound assignment
CA1825 array.empty
Down to 3479 warnings
* - SA1116, SA117 params on same line
- IDE0057 substring simplified
Specific warnings for Umbraco.Tests.Benchmarks
* Fixed IDE0074 compound assignment and added specific warnings for Umbraco.Tests.Common
* Specific warnings for Umbraco.Tests.Integration and Umbraco.Tests.Common
Fixed:
- SA1111, SA1116, SA117 params and line formatting (not all as there are many)
- SA1122 string.Empty
- IDE0057 simplify substring
- IDE0044,IDE0044 make field readonly
- IDE1006 naming rule violation (add _)
- SA1111 closing parenthesis on line of last parameter
- SA1649 filename match type name
- SA1312,SA1306 lowercase variable and field names
* Fixed various warnings where they are more straight-forward, including:
- SA1649 file name match type name
- SA111 parenthesis on line of last parameter
- IDE0028 simplify collection initializer
- SA1306 lower-case letter field
- IDE044 readonly field
- SA1122 string.Empty
- SA1116 params same line
- IDE1006 upper casing
- IDE0041 simplify null check
Updated the following projects to only list their remaining specific warning codes:
- Umbraco.Tests.UnitTests
Typo in `Umbraco.Web.Website` project
* Reverted test change
* Now 1556 warnings.
Fixed various warnings where they are more straight-forward, including:
- SA1111/SA1116/SA1119 parenthesis
- SA1117 params
- SA1312 lowercase variable
- SA1121 built-in type
- SA1500/SA1513/SA1503 formatting braces
- SA1400 declare access modifier
- SA1122 string.Empty
- SA1310 no underscore
- IDE0049 name simplified
- IDE0057 simplify substring
- IDE0074 compound assignment
- IDE0032 use auto-property
- IDE0037 simplify member name
- IDE0008 explicit type not var
- IDE0016/IDE0270/IDE0041 simplify null checks
- IDE0048/SA1407 clarity in arithmetic
- IDE1006 correct param names
- IDE0042 deconstruct variable
- IDE0044 readonly
- IDE0018 inline variable declarations
- IDE0074/IDE0054 compound assignment
- IDE1006 naming
- CS1573 param XML
- CS0168 unused variable
Comment formatting in project files for consistency.
Updated all projects to only list remaining specific warning codes as warnings instead of errors (errors is now default).
* Type not var, and more warning exceptions
* Tweaked merge issue, readded comment about rollback
* Readded comment re rollback.
* Readded comments
* Comment tweak
* Comment tweak
2024-09-24 12:56:28 +01:00
sql . WhereIn < NodeDto > ( x = > x . NodeObjectType , objectTypes ) ;
2024-01-02 13:53:24 +01:00
foreach ( Tuple < string , object [ ] > queryClause in query . GetWhereClauses ( ) )
{
sql . Where ( queryClause . Item1 , queryClause . Item2 ) ;
}
if ( filter is not null )
{
foreach ( Tuple < string , object [ ] > filterClause in filter . GetWhereClauses ( ) )
{
sql . Where ( filterClause . Item1 , filterClause . Item2 ) ;
}
}
return Database . ExecuteScalar < int > ( sql ) ;
}
2024-04-04 11:27:13 +02:00
public IEnumerable < IEntitySlim > GetPagedResultsByQuery ( IQuery < IUmbracoEntity > query , ISet < Guid > objectTypes ,
2022-06-02 08:18:31 +02:00
long pageIndex , int pageSize , out long totalRecords ,
IQuery < IUmbracoEntity > ? filter , Ordering ? ordering ) = >
2024-04-04 11:27:13 +02:00
GetPagedResultsByQuery ( query , objectTypes . ToArray ( ) , pageIndex , pageSize , out totalRecords , filter , ordering ) ;
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
// get a page of entities
public IEnumerable < IEntitySlim > GetPagedResultsByQuery ( IQuery < IUmbracoEntity > query , Guid [ ] objectTypes ,
long pageIndex , int pageSize , out long totalRecords ,
IQuery < IUmbracoEntity > ? filter , Ordering ? ordering , Action < Sql < ISqlContext > > ? sqlCustomization = null )
{
var isContent = objectTypes . Any ( objectType = >
objectType = = Constants . ObjectTypes . Document | | objectType = = Constants . ObjectTypes . DocumentBlueprint ) ;
var isMedia = objectTypes . Any ( objectType = > objectType = = Constants . ObjectTypes . Media ) ;
var isMember = objectTypes . Any ( objectType = > objectType = = Constants . ObjectTypes . Member ) ;
Sql < ISqlContext > sql = GetBaseWhere ( isContent , isMedia , isMember , false , s = >
2019-11-05 15:05:51 +11:00
{
2022-06-02 08:18:31 +02:00
sqlCustomization ? . Invoke ( s ) ;
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
if ( filter ! = null )
2017-12-07 16:45:25 +01:00
{
2022-06-02 08:18:31 +02:00
foreach ( Tuple < string , object [ ] > filterClause in filter . GetWhereClauses ( ) )
2019-11-06 12:43:10 +11:00
{
2022-06-02 08:18:31 +02:00
s . Where ( filterClause . Item1 , filterClause . Item2 ) ;
2019-11-06 12:43:10 +11:00
}
2018-12-21 13:15:46 +11:00
}
2022-06-02 08:18:31 +02:00
} , objectTypes ) ;
2018-12-21 13:15:46 +11:00
Resolved more warnings, and marked more warning types as errors (#16991)
* Fix warnings SA1111, SA1028, SA1500, IDE1270 in Umbraco.Web.Website, and updated rules.
* Remove warnings: IDE0270: Null check can be simplified
* More SqlServer project warnings resolved
* CS0105 namespace appeared already
* Suppress warning until implementation:
#pragma warning disable CS0162 // Unreachable code detected
#pragma warning disable CS0618 // Type or member is obsolete
CS0162 remove unreachable code
SA1028 remove trailing whitespace
SA1106 no empty statements
CS1570 malformed XML
CS1572 corrected xml parameter
CS1573 param tag added
IDE0007 var not explicit
IDE0008 explicit not var
IDE0057 simplify substring
IDE0074 compound assignment
CA1825 array.empty
Down to 3479 warnings
* - SA1116, SA117 params on same line
- IDE0057 substring simplified
Specific warnings for Umbraco.Tests.Benchmarks
* Fixed IDE0074 compound assignment and added specific warnings for Umbraco.Tests.Common
* Specific warnings for Umbraco.Tests.Integration and Umbraco.Tests.Common
Fixed:
- SA1111, SA1116, SA117 params and line formatting (not all as there are many)
- SA1122 string.Empty
- IDE0057 simplify substring
- IDE0044,IDE0044 make field readonly
- IDE1006 naming rule violation (add _)
- SA1111 closing parenthesis on line of last parameter
- SA1649 filename match type name
- SA1312,SA1306 lowercase variable and field names
* Fixed various warnings where they are more straight-forward, including:
- SA1649 file name match type name
- SA111 parenthesis on line of last parameter
- IDE0028 simplify collection initializer
- SA1306 lower-case letter field
- IDE044 readonly field
- SA1122 string.Empty
- SA1116 params same line
- IDE1006 upper casing
- IDE0041 simplify null check
Updated the following projects to only list their remaining specific warning codes:
- Umbraco.Tests.UnitTests
Typo in `Umbraco.Web.Website` project
* Reverted test change
* Now 1556 warnings.
Fixed various warnings where they are more straight-forward, including:
- SA1111/SA1116/SA1119 parenthesis
- SA1117 params
- SA1312 lowercase variable
- SA1121 built-in type
- SA1500/SA1513/SA1503 formatting braces
- SA1400 declare access modifier
- SA1122 string.Empty
- SA1310 no underscore
- IDE0049 name simplified
- IDE0057 simplify substring
- IDE0074 compound assignment
- IDE0032 use auto-property
- IDE0037 simplify member name
- IDE0008 explicit type not var
- IDE0016/IDE0270/IDE0041 simplify null checks
- IDE0048/SA1407 clarity in arithmetic
- IDE1006 correct param names
- IDE0042 deconstruct variable
- IDE0044 readonly
- IDE0018 inline variable declarations
- IDE0074/IDE0054 compound assignment
- IDE1006 naming
- CS1573 param XML
- CS0168 unused variable
Comment formatting in project files for consistency.
Updated all projects to only list remaining specific warning codes as warnings instead of errors (errors is now default).
* Type not var, and more warning exceptions
* Tweaked merge issue, readded comment about rollback
* Readded comment re rollback.
* Readded comments
* Comment tweak
* Comment tweak
2024-09-24 12:56:28 +01:00
ordering ? ? = Ordering . ByDefault ( ) ;
2019-02-09 15:41:30 +01:00
2022-06-02 08:18:31 +02:00
var translator = new SqlTranslator < IUmbracoEntity > ( sql , query ) ;
sql = translator . Translate ( ) ;
sql = AddGroupBy ( isContent , isMedia , isMember , sql , ordering . IsEmpty ) ;
2019-02-08 08:50:57 +01:00
2022-06-02 08:18:31 +02:00
if ( ! ordering . IsEmpty )
2017-12-07 16:45:25 +01:00
{
2022-06-02 08:18:31 +02:00
// apply ordering
ApplyOrdering ( ref sql , ordering ) ;
2017-12-07 16:45:25 +01:00
}
2022-06-02 08:18:31 +02:00
// TODO: we should be able to do sql = sql.OrderBy(x => Alias(x.NodeId, "NodeId")); but we can't because the OrderBy extension don't support Alias currently
// no matter what we always must have node id ordered at the end
sql = ordering . Direction = = Direction . Ascending ? sql . OrderBy ( "NodeId" ) : sql . OrderByDescending ( "NodeId" ) ;
2018-12-21 13:15:46 +11:00
2022-06-02 08:18:31 +02:00
// for content we must query for ContentEntityDto entities to produce the correct culture variant entity names
var pageIndexToFetch = pageIndex + 1 ;
IEnumerable < BaseDto > dtos ;
Page < GenericContentEntityDto > ? page = Database . Page < GenericContentEntityDto > ( pageIndexToFetch , pageSize , sql ) ;
dtos = page . Items ;
totalRecords = page . TotalItems ;
2018-09-25 10:55:33 +02:00
2022-06-02 08:18:31 +02:00
EntitySlim [ ] entities = dtos . Select ( BuildEntity ) . ToArray ( ) ;
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
BuildVariants ( entities . OfType < DocumentEntitySlim > ( ) ) ;
2019-06-13 23:39:36 +10:00
2022-06-02 08:18:31 +02:00
return entities ;
}
2018-04-20 16:07:34 +10:00
2022-06-02 08:18:31 +02:00
public IEntitySlim ? Get ( Guid key )
{
Sql < ISqlContext > sql = GetBaseWhere ( false , false , false , false , key ) ;
BaseDto ? dto = Database . FirstOrDefault < BaseDto > ( sql ) ;
return dto = = null ? null : BuildEntity ( dto ) ;
}
2017-12-07 16:45:25 +01:00
2018-04-24 17:59:26 +02:00
2022-06-02 08:18:31 +02:00
private IEntitySlim ? GetEntity ( Sql < ISqlContext > sql , bool isContent , bool isMedia , bool isMember )
{
// isContent is going to return a 1:M result now with the variants so we need to do different things
if ( isContent )
2018-04-24 17:59:26 +02:00
{
2022-06-02 08:18:31 +02:00
List < DocumentEntityDto > ? cdtos = Database . Fetch < DocumentEntityDto > ( sql ) ;
2018-04-24 17:59:26 +02:00
2022-06-02 08:18:31 +02:00
return cdtos . Count = = 0 ? null : BuildVariants ( BuildDocumentEntity ( cdtos [ 0 ] ) ) ;
2017-12-07 16:45:25 +01:00
}
2022-06-02 08:18:31 +02:00
BaseDto ? dto = isMedia
? Database . FirstOrDefault < MediaEntityDto > ( sql )
: Database . FirstOrDefault < BaseDto > ( sql ) ;
if ( dto = = null )
2017-12-07 16:45:25 +01:00
{
2022-06-02 08:18:31 +02:00
return null ;
2017-12-07 16:45:25 +01:00
}
2022-06-02 08:18:31 +02:00
EntitySlim entity = BuildEntity ( dto ) ;
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
return entity ;
}
2017-12-07 16:45:25 +01:00
2025-07-07 14:53:42 +02:00
/// <inheritdoc/>
public IEnumerable < IEntitySlim > GetSiblings ( Guid objectType , Guid targetKey , int before , int after , Ordering ordering )
{
// Ideally we don't want to have to do a second query for the parent ID, but the siblings query is already messy enough
// without us also having to do a nested query for the parent ID too.
Sql < ISqlContext > parentIdQuery = Sql ( )
. Select < NodeDto > ( x = > x . ParentId )
. From < NodeDto > ( )
. Where < NodeDto > ( x = > x . UniqueId = = targetKey ) ;
var parentId = Database . ExecuteScalar < int > ( parentIdQuery ) ;
Sql < ISqlContext > orderingSql = Sql ( ) ;
ApplyOrdering ( ref orderingSql , ordering ) ;
// Get all children of the parent node which is not trashed, ordered by SortOrder, and assign each a row number.
// These row numbers are important, we need them to select the "before" and "after" siblings of the target node.
Sql < ISqlContext > rowNumberSql = Sql ( )
. Select ( $"ROW_NUMBER() OVER ({orderingSql.SQL}) AS rn" )
. AndSelect < NodeDto > ( n = > n . UniqueId )
. From < NodeDto > ( )
. Where < NodeDto > ( x = > x . ParentId = = parentId & & x . Trashed = = false ) ;
// Find the specific row number of the target node.
// We need this to determine the bounds of the row numbers to select.
Sql < ISqlContext > targetRowSql = Sql ( )
. Select ( "rn" )
. From ( ) . AppendSubQuery ( rowNumberSql , "Target" )
. Where < NodeDto > ( x = > x . UniqueId = = targetKey , "Target" ) ;
// We have to reuse the target row sql arguments, however, we also need to add the "before" and "after" values to the arguments.
// If we try to do this directly in the params array it'll consider the initial argument array as a single argument.
IEnumerable < object > beforeArguments = targetRowSql . Arguments . Concat ( [ before ] ) ;
IEnumerable < object > afterArguments = targetRowSql . Arguments . Concat ( [ after ] ) ;
// Select the UniqueId of nodes which row number is within the specified range of the target node's row number.
Sql < ISqlContext > ? mainSql = Sql ( )
. Select ( "UniqueId" )
. From ( ) . AppendSubQuery ( rowNumberSql , "NumberedNodes" )
. Where ( $"rn >= ({targetRowSql.SQL}) - @3" , beforeArguments . ToArray ( ) )
. Where ( $"rn <= ({targetRowSql.SQL}) + @3" , afterArguments . ToArray ( ) )
. OrderBy ( "rn" ) ;
List < Guid > ? keys = Database . Fetch < Guid > ( mainSql ) ;
if ( keys is null | | keys . Count = = 0 )
{
return [ ] ;
}
return PerformGetAll ( objectType , ordering , sql = > sql . WhereIn < NodeDto > ( x = > x . UniqueId , keys ) ) ;
}
2022-06-02 08:18:31 +02:00
public IEntitySlim ? Get ( Guid key , Guid objectTypeId )
{
var isContent = objectTypeId = = Constants . ObjectTypes . Document | |
objectTypeId = = Constants . ObjectTypes . DocumentBlueprint ;
var isMedia = objectTypeId = = Constants . ObjectTypes . Media ;
var isMember = objectTypeId = = Constants . ObjectTypes . Member ;
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
Sql < ISqlContext > sql = GetFullSqlForEntityType ( isContent , isMedia , isMember , objectTypeId , key ) ;
return GetEntity ( sql , isContent , isMedia , isMember ) ;
}
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
public IEntitySlim ? Get ( int id )
{
Sql < ISqlContext > sql = GetBaseWhere ( false , false , false , false , id ) ;
BaseDto ? dto = Database . FirstOrDefault < BaseDto > ( sql ) ;
return dto = = null ? null : BuildEntity ( dto ) ;
}
2018-09-21 15:49:37 +10:00
2022-06-02 08:18:31 +02:00
public IEntitySlim ? Get ( int id , Guid objectTypeId )
{
var isContent = objectTypeId = = Constants . ObjectTypes . Document | |
objectTypeId = = Constants . ObjectTypes . DocumentBlueprint ;
var isMedia = objectTypeId = = Constants . ObjectTypes . Media ;
var isMember = objectTypeId = = Constants . ObjectTypes . Member ;
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
Sql < ISqlContext > sql = GetFullSqlForEntityType ( isContent , isMedia , isMember , objectTypeId , id ) ;
return GetEntity ( sql , isContent , isMedia , isMember ) ;
}
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
public IEnumerable < IEntitySlim > GetAll ( Guid objectType , params int [ ] ids ) = >
ids . Length > 0
? PerformGetAll ( objectType , sql = > sql . WhereIn < NodeDto > ( x = > x . NodeId , ids . Distinct ( ) ) )
: PerformGetAll ( objectType ) ;
2018-04-20 16:07:34 +10:00
2022-06-02 08:18:31 +02:00
public IEnumerable < IEntitySlim > GetAll ( Guid objectType , params Guid [ ] keys ) = >
keys . Length > 0
? PerformGetAll ( objectType , sql = > sql . WhereIn < NodeDto > ( x = > x . UniqueId , keys . Distinct ( ) ) )
: PerformGetAll ( objectType ) ;
2018-04-24 17:59:26 +02:00
2022-06-02 08:18:31 +02:00
private IEnumerable < IEntitySlim > GetEntities ( Sql < ISqlContext > sql , bool isContent , bool isMedia , bool isMember )
{
// isContent is going to return a 1:M result now with the variants so we need to do different things
if ( isContent )
2018-04-24 17:59:26 +02:00
{
2022-06-02 08:18:31 +02:00
List < DocumentEntityDto > ? cdtos = Database . Fetch < DocumentEntityDto > ( sql ) ;
2018-04-24 17:59:26 +02:00
2022-06-02 08:18:31 +02:00
return cdtos . Count = = 0
? Enumerable . Empty < IEntitySlim > ( )
: BuildVariants ( cdtos . Select ( BuildDocumentEntity ) ) . ToList ( ) ;
2017-12-07 16:45:25 +01:00
}
2022-06-02 08:18:31 +02:00
IEnumerable < BaseDto > ? dtos = isMedia
? ( IEnumerable < BaseDto > ) Database . Fetch < MediaEntityDto > ( sql )
: Database . Fetch < BaseDto > ( sql ) ;
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
EntitySlim [ ] entities = dtos . Select ( BuildEntity ) . ToArray ( ) ;
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
return entities ;
}
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
private IEnumerable < IEntitySlim > PerformGetAll ( Guid objectType , Action < Sql < ISqlContext > > ? filter = null )
{
var isContent = objectType = = Constants . ObjectTypes . Document | |
objectType = = Constants . ObjectTypes . DocumentBlueprint ;
var isMedia = objectType = = Constants . ObjectTypes . Media ;
var isMember = objectType = = Constants . ObjectTypes . Member ;
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
Sql < ISqlContext > sql = GetFullSqlForEntityType ( isContent , isMedia , isMember , objectType , filter ) ;
return GetEntities ( sql , isContent , isMedia , isMember ) ;
}
2017-12-07 16:45:25 +01:00
2025-07-07 14:53:42 +02:00
private IEnumerable < IEntitySlim > PerformGetAll (
Guid objectType ,
Ordering ordering ,
Action < Sql < ISqlContext > > ? filter = null )
{
var isContent = objectType = = Constants . ObjectTypes . Document | |
objectType = = Constants . ObjectTypes . DocumentBlueprint ;
var isMedia = objectType = = Constants . ObjectTypes . Media ;
var isMember = objectType = = Constants . ObjectTypes . Member ;
Sql < ISqlContext > sql = GetFullSqlForEntityType ( isContent , isMedia , isMember , objectType , ordering , filter ) ;
return GetEntities ( sql , isContent , isMedia , isMember ) ;
}
2022-06-02 08:18:31 +02:00
public IEnumerable < TreeEntityPath > GetAllPaths ( Guid objectType , params int [ ] ? ids ) = >
ids ? . Any ( ) ? ? false
? PerformGetAllPaths ( objectType , sql = > sql . WhereIn < NodeDto > ( x = > x . NodeId , ids . Distinct ( ) ) )
: PerformGetAllPaths ( objectType ) ;
2018-04-20 13:12:55 +10:00
2022-06-02 08:18:31 +02:00
public IEnumerable < TreeEntityPath > GetAllPaths ( Guid objectType , params Guid [ ] keys ) = >
keys . Any ( )
? PerformGetAllPaths ( objectType , sql = > sql . WhereIn < NodeDto > ( x = > x . UniqueId , keys . Distinct ( ) ) )
: PerformGetAllPaths ( objectType ) ;
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
private IEnumerable < TreeEntityPath > PerformGetAllPaths ( Guid objectType , Action < Sql < ISqlContext > > ? filter = null )
{
// NodeId is named Id on TreeEntityPath = use an alias
Sql < ISqlContext > sql = Sql ( ) . Select < NodeDto > ( x = > Alias ( x . NodeId , nameof ( TreeEntityPath . Id ) ) , x = > x . Path )
. From < NodeDto > ( ) . Where < NodeDto > ( x = > x . NodeObjectType = = objectType ) ;
filter ? . Invoke ( sql ) ;
return Database . Fetch < TreeEntityPath > ( sql ) ;
}
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
public IEnumerable < IEntitySlim > GetByQuery ( IQuery < IUmbracoEntity > query )
{
Sql < ISqlContext > sqlClause = GetBase ( false , false , false , null ) ;
var translator = new SqlTranslator < IUmbracoEntity > ( sqlClause , query ) ;
Sql < ISqlContext > sql = translator . Translate ( ) ;
sql = AddGroupBy ( false , false , false , sql , true ) ;
List < BaseDto > ? dtos = Database . Fetch < BaseDto > ( sql ) ;
return dtos . Select ( BuildEntity ) . ToList ( ) ;
}
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
public IEnumerable < IEntitySlim > GetByQuery ( IQuery < IUmbracoEntity > query , Guid objectType )
{
var isContent = objectType = = Constants . ObjectTypes . Document | |
objectType = = Constants . ObjectTypes . DocumentBlueprint ;
var isMedia = objectType = = Constants . ObjectTypes . Media ;
var isMember = objectType = = Constants . ObjectTypes . Member ;
2017-12-07 16:45:25 +01:00
Resolved more warnings, and marked more warning types as errors (#16991)
* Fix warnings SA1111, SA1028, SA1500, IDE1270 in Umbraco.Web.Website, and updated rules.
* Remove warnings: IDE0270: Null check can be simplified
* More SqlServer project warnings resolved
* CS0105 namespace appeared already
* Suppress warning until implementation:
#pragma warning disable CS0162 // Unreachable code detected
#pragma warning disable CS0618 // Type or member is obsolete
CS0162 remove unreachable code
SA1028 remove trailing whitespace
SA1106 no empty statements
CS1570 malformed XML
CS1572 corrected xml parameter
CS1573 param tag added
IDE0007 var not explicit
IDE0008 explicit not var
IDE0057 simplify substring
IDE0074 compound assignment
CA1825 array.empty
Down to 3479 warnings
* - SA1116, SA117 params on same line
- IDE0057 substring simplified
Specific warnings for Umbraco.Tests.Benchmarks
* Fixed IDE0074 compound assignment and added specific warnings for Umbraco.Tests.Common
* Specific warnings for Umbraco.Tests.Integration and Umbraco.Tests.Common
Fixed:
- SA1111, SA1116, SA117 params and line formatting (not all as there are many)
- SA1122 string.Empty
- IDE0057 simplify substring
- IDE0044,IDE0044 make field readonly
- IDE1006 naming rule violation (add _)
- SA1111 closing parenthesis on line of last parameter
- SA1649 filename match type name
- SA1312,SA1306 lowercase variable and field names
* Fixed various warnings where they are more straight-forward, including:
- SA1649 file name match type name
- SA111 parenthesis on line of last parameter
- IDE0028 simplify collection initializer
- SA1306 lower-case letter field
- IDE044 readonly field
- SA1122 string.Empty
- SA1116 params same line
- IDE1006 upper casing
- IDE0041 simplify null check
Updated the following projects to only list their remaining specific warning codes:
- Umbraco.Tests.UnitTests
Typo in `Umbraco.Web.Website` project
* Reverted test change
* Now 1556 warnings.
Fixed various warnings where they are more straight-forward, including:
- SA1111/SA1116/SA1119 parenthesis
- SA1117 params
- SA1312 lowercase variable
- SA1121 built-in type
- SA1500/SA1513/SA1503 formatting braces
- SA1400 declare access modifier
- SA1122 string.Empty
- SA1310 no underscore
- IDE0049 name simplified
- IDE0057 simplify substring
- IDE0074 compound assignment
- IDE0032 use auto-property
- IDE0037 simplify member name
- IDE0008 explicit type not var
- IDE0016/IDE0270/IDE0041 simplify null checks
- IDE0048/SA1407 clarity in arithmetic
- IDE1006 correct param names
- IDE0042 deconstruct variable
- IDE0044 readonly
- IDE0018 inline variable declarations
- IDE0074/IDE0054 compound assignment
- IDE1006 naming
- CS1573 param XML
- CS0168 unused variable
Comment formatting in project files for consistency.
Updated all projects to only list remaining specific warning codes as warnings instead of errors (errors is now default).
* Type not var, and more warning exceptions
* Tweaked merge issue, readded comment about rollback
* Readded comment re rollback.
* Readded comments
* Comment tweak
* Comment tweak
2024-09-24 12:56:28 +01:00
Sql < ISqlContext > sql = GetBaseWhere ( isContent , isMedia , isMember , false , null , new [ ] { objectType } ) ;
2022-01-13 17:44:39 +00:00
2022-06-02 08:18:31 +02:00
var translator = new SqlTranslator < IUmbracoEntity > ( sql , query ) ;
sql = translator . Translate ( ) ;
sql = AddGroupBy ( isContent , isMedia , isMember , sql , true ) ;
2022-01-13 17:44:39 +00:00
2022-06-02 08:18:31 +02:00
return GetEntities ( sql , isContent , isMedia , isMember ) ;
}
2022-01-13 17:44:39 +00:00
2022-06-02 08:18:31 +02:00
public UmbracoObjectTypes GetObjectType ( int id )
{
Sql < ISqlContext > sql = Sql ( ) . Select < NodeDto > ( x = > x . NodeObjectType ) . From < NodeDto > ( )
. Where < NodeDto > ( x = > x . NodeId = = id ) ;
return ObjectTypes . GetUmbracoObjectType ( Database . ExecuteScalar < Guid > ( sql ) ) ;
}
2022-01-13 17:44:39 +00:00
2022-06-02 08:18:31 +02:00
public UmbracoObjectTypes GetObjectType ( Guid key )
{
Sql < ISqlContext > sql = Sql ( ) . Select < NodeDto > ( x = > x . NodeObjectType ) . From < NodeDto > ( )
. Where < NodeDto > ( x = > x . UniqueId = = key ) ;
return ObjectTypes . GetUmbracoObjectType ( Database . ExecuteScalar < Guid > ( sql ) ) ;
}
public int ReserveId ( Guid key )
{
NodeDto node ;
Sql < ISqlContext > sql = SqlContext . Sql ( )
. Select < NodeDto > ( )
. From < NodeDto > ( )
. Where < NodeDto > ( x = > x . UniqueId = = key & & x . NodeObjectType = = Constants . ObjectTypes . IdReservation ) ;
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
node = Database . SingleOrDefault < NodeDto > ( sql ) ;
if ( node ! = null )
2017-12-07 16:45:25 +01:00
{
2022-06-02 08:18:31 +02:00
throw new InvalidOperationException ( "An identifier has already been reserved for this Udi." ) ;
2017-12-07 16:45:25 +01:00
}
2022-06-02 08:18:31 +02:00
node = new NodeDto
2018-09-21 15:49:37 +10:00
{
2022-06-02 08:18:31 +02:00
UniqueId = key ,
Text = "RESERVED.ID" ,
NodeObjectType = Constants . ObjectTypes . IdReservation ,
CreateDate = DateTime . Now ,
UserId = null ,
ParentId = - 1 ,
Level = 1 ,
Path = "-1" ,
SortOrder = 0 ,
Trashed = false
} ;
Database . Insert ( node ) ;
2018-09-21 15:49:37 +10:00
2022-06-02 08:18:31 +02:00
return node . NodeId ;
}
2018-09-21 15:49:37 +10:00
2022-06-02 08:18:31 +02:00
public bool Exists ( Guid key )
{
Sql < ISqlContext > sql = Sql ( ) . SelectCount ( ) . From < NodeDto > ( ) . Where < NodeDto > ( x = > x . UniqueId = = key ) ;
return Database . ExecuteScalar < int > ( sql ) > 0 ;
}
2018-09-25 10:55:33 +02:00
2024-02-27 20:57:02 +00:00
public bool Exists ( IEnumerable < Guid > keys )
{
Resolved more warnings, and marked more warning types as errors (#16991)
* Fix warnings SA1111, SA1028, SA1500, IDE1270 in Umbraco.Web.Website, and updated rules.
* Remove warnings: IDE0270: Null check can be simplified
* More SqlServer project warnings resolved
* CS0105 namespace appeared already
* Suppress warning until implementation:
#pragma warning disable CS0162 // Unreachable code detected
#pragma warning disable CS0618 // Type or member is obsolete
CS0162 remove unreachable code
SA1028 remove trailing whitespace
SA1106 no empty statements
CS1570 malformed XML
CS1572 corrected xml parameter
CS1573 param tag added
IDE0007 var not explicit
IDE0008 explicit not var
IDE0057 simplify substring
IDE0074 compound assignment
CA1825 array.empty
Down to 3479 warnings
* - SA1116, SA117 params on same line
- IDE0057 substring simplified
Specific warnings for Umbraco.Tests.Benchmarks
* Fixed IDE0074 compound assignment and added specific warnings for Umbraco.Tests.Common
* Specific warnings for Umbraco.Tests.Integration and Umbraco.Tests.Common
Fixed:
- SA1111, SA1116, SA117 params and line formatting (not all as there are many)
- SA1122 string.Empty
- IDE0057 simplify substring
- IDE0044,IDE0044 make field readonly
- IDE1006 naming rule violation (add _)
- SA1111 closing parenthesis on line of last parameter
- SA1649 filename match type name
- SA1312,SA1306 lowercase variable and field names
* Fixed various warnings where they are more straight-forward, including:
- SA1649 file name match type name
- SA111 parenthesis on line of last parameter
- IDE0028 simplify collection initializer
- SA1306 lower-case letter field
- IDE044 readonly field
- SA1122 string.Empty
- SA1116 params same line
- IDE1006 upper casing
- IDE0041 simplify null check
Updated the following projects to only list their remaining specific warning codes:
- Umbraco.Tests.UnitTests
Typo in `Umbraco.Web.Website` project
* Reverted test change
* Now 1556 warnings.
Fixed various warnings where they are more straight-forward, including:
- SA1111/SA1116/SA1119 parenthesis
- SA1117 params
- SA1312 lowercase variable
- SA1121 built-in type
- SA1500/SA1513/SA1503 formatting braces
- SA1400 declare access modifier
- SA1122 string.Empty
- SA1310 no underscore
- IDE0049 name simplified
- IDE0057 simplify substring
- IDE0074 compound assignment
- IDE0032 use auto-property
- IDE0037 simplify member name
- IDE0008 explicit type not var
- IDE0016/IDE0270/IDE0041 simplify null checks
- IDE0048/SA1407 clarity in arithmetic
- IDE1006 correct param names
- IDE0042 deconstruct variable
- IDE0044 readonly
- IDE0018 inline variable declarations
- IDE0074/IDE0054 compound assignment
- IDE1006 naming
- CS1573 param XML
- CS0168 unused variable
Comment formatting in project files for consistency.
Updated all projects to only list remaining specific warning codes as warnings instead of errors (errors is now default).
* Type not var, and more warning exceptions
* Tweaked merge issue, readded comment about rollback
* Readded comment re rollback.
* Readded comments
* Comment tweak
* Comment tweak
2024-09-24 12:56:28 +01:00
IEnumerable < Guid > distictKeys = keys . Distinct ( ) ;
2024-02-27 20:57:02 +00:00
Sql < ISqlContext > sql = Sql ( ) . SelectCount ( ) . From < NodeDto > ( ) . Where < NodeDto > ( x = > distictKeys . Contains ( x . UniqueId ) ) ;
return Database . ExecuteScalar < int > ( sql ) = = distictKeys . Count ( ) ;
}
2023-02-16 09:39:17 +01:00
/// <inheritdoc />
public bool Exists ( Guid key , Guid objectType )
{
Sql < ISqlContext > sql = Sql ( )
. SelectCount ( )
. From < NodeDto > ( )
. Where < NodeDto > ( x = > x . UniqueId = = key & & x . NodeObjectType = = objectType ) ;
return Database . ExecuteScalar < int > ( sql ) > 0 ;
}
public bool Exists ( int id , Guid objectType )
{
Sql < ISqlContext > sql = Sql ( )
. SelectCount ( )
. From < NodeDto > ( )
. Where < NodeDto > ( x = > x . NodeId = = id & & x . NodeObjectType = = objectType ) ;
return Database . ExecuteScalar < int > ( sql ) > 0 ;
}
2022-06-02 08:18:31 +02:00
public bool Exists ( int id )
{
Sql < ISqlContext > sql = Sql ( ) . SelectCount ( ) . From < NodeDto > ( ) . Where < NodeDto > ( x = > x . NodeId = = id ) ;
return Database . ExecuteScalar < int > ( sql ) > 0 ;
}
2018-09-25 10:55:33 +02:00
2022-06-02 08:18:31 +02:00
private DocumentEntitySlim BuildVariants ( DocumentEntitySlim entity )
Resolved more warnings, and marked more warning types as errors (#16991)
* Fix warnings SA1111, SA1028, SA1500, IDE1270 in Umbraco.Web.Website, and updated rules.
* Remove warnings: IDE0270: Null check can be simplified
* More SqlServer project warnings resolved
* CS0105 namespace appeared already
* Suppress warning until implementation:
#pragma warning disable CS0162 // Unreachable code detected
#pragma warning disable CS0618 // Type or member is obsolete
CS0162 remove unreachable code
SA1028 remove trailing whitespace
SA1106 no empty statements
CS1570 malformed XML
CS1572 corrected xml parameter
CS1573 param tag added
IDE0007 var not explicit
IDE0008 explicit not var
IDE0057 simplify substring
IDE0074 compound assignment
CA1825 array.empty
Down to 3479 warnings
* - SA1116, SA117 params on same line
- IDE0057 substring simplified
Specific warnings for Umbraco.Tests.Benchmarks
* Fixed IDE0074 compound assignment and added specific warnings for Umbraco.Tests.Common
* Specific warnings for Umbraco.Tests.Integration and Umbraco.Tests.Common
Fixed:
- SA1111, SA1116, SA117 params and line formatting (not all as there are many)
- SA1122 string.Empty
- IDE0057 simplify substring
- IDE0044,IDE0044 make field readonly
- IDE1006 naming rule violation (add _)
- SA1111 closing parenthesis on line of last parameter
- SA1649 filename match type name
- SA1312,SA1306 lowercase variable and field names
* Fixed various warnings where they are more straight-forward, including:
- SA1649 file name match type name
- SA111 parenthesis on line of last parameter
- IDE0028 simplify collection initializer
- SA1306 lower-case letter field
- IDE044 readonly field
- SA1122 string.Empty
- SA1116 params same line
- IDE1006 upper casing
- IDE0041 simplify null check
Updated the following projects to only list their remaining specific warning codes:
- Umbraco.Tests.UnitTests
Typo in `Umbraco.Web.Website` project
* Reverted test change
* Now 1556 warnings.
Fixed various warnings where they are more straight-forward, including:
- SA1111/SA1116/SA1119 parenthesis
- SA1117 params
- SA1312 lowercase variable
- SA1121 built-in type
- SA1500/SA1513/SA1503 formatting braces
- SA1400 declare access modifier
- SA1122 string.Empty
- SA1310 no underscore
- IDE0049 name simplified
- IDE0057 simplify substring
- IDE0074 compound assignment
- IDE0032 use auto-property
- IDE0037 simplify member name
- IDE0008 explicit type not var
- IDE0016/IDE0270/IDE0041 simplify null checks
- IDE0048/SA1407 clarity in arithmetic
- IDE1006 correct param names
- IDE0042 deconstruct variable
- IDE0044 readonly
- IDE0018 inline variable declarations
- IDE0074/IDE0054 compound assignment
- IDE1006 naming
- CS1573 param XML
- CS0168 unused variable
Comment formatting in project files for consistency.
Updated all projects to only list remaining specific warning codes as warnings instead of errors (errors is now default).
* Type not var, and more warning exceptions
* Tweaked merge issue, readded comment about rollback
* Readded comment re rollback.
* Readded comments
* Comment tweak
* Comment tweak
2024-09-24 12:56:28 +01:00
= > BuildVariants ( new [ ] { entity } ) . First ( ) ;
2018-09-25 10:55:33 +02:00
2022-06-02 08:18:31 +02:00
private IEnumerable < DocumentEntitySlim > BuildVariants ( IEnumerable < DocumentEntitySlim > entities )
{
List < DocumentEntitySlim > ? v = null ;
var entitiesList = entities . ToList ( ) ;
foreach ( DocumentEntitySlim e in entitiesList )
{
if ( e . Variations . VariesByCulture ( ) )
{
Resolved more warnings, and marked more warning types as errors (#16991)
* Fix warnings SA1111, SA1028, SA1500, IDE1270 in Umbraco.Web.Website, and updated rules.
* Remove warnings: IDE0270: Null check can be simplified
* More SqlServer project warnings resolved
* CS0105 namespace appeared already
* Suppress warning until implementation:
#pragma warning disable CS0162 // Unreachable code detected
#pragma warning disable CS0618 // Type or member is obsolete
CS0162 remove unreachable code
SA1028 remove trailing whitespace
SA1106 no empty statements
CS1570 malformed XML
CS1572 corrected xml parameter
CS1573 param tag added
IDE0007 var not explicit
IDE0008 explicit not var
IDE0057 simplify substring
IDE0074 compound assignment
CA1825 array.empty
Down to 3479 warnings
* - SA1116, SA117 params on same line
- IDE0057 substring simplified
Specific warnings for Umbraco.Tests.Benchmarks
* Fixed IDE0074 compound assignment and added specific warnings for Umbraco.Tests.Common
* Specific warnings for Umbraco.Tests.Integration and Umbraco.Tests.Common
Fixed:
- SA1111, SA1116, SA117 params and line formatting (not all as there are many)
- SA1122 string.Empty
- IDE0057 simplify substring
- IDE0044,IDE0044 make field readonly
- IDE1006 naming rule violation (add _)
- SA1111 closing parenthesis on line of last parameter
- SA1649 filename match type name
- SA1312,SA1306 lowercase variable and field names
* Fixed various warnings where they are more straight-forward, including:
- SA1649 file name match type name
- SA111 parenthesis on line of last parameter
- IDE0028 simplify collection initializer
- SA1306 lower-case letter field
- IDE044 readonly field
- SA1122 string.Empty
- SA1116 params same line
- IDE1006 upper casing
- IDE0041 simplify null check
Updated the following projects to only list their remaining specific warning codes:
- Umbraco.Tests.UnitTests
Typo in `Umbraco.Web.Website` project
* Reverted test change
* Now 1556 warnings.
Fixed various warnings where they are more straight-forward, including:
- SA1111/SA1116/SA1119 parenthesis
- SA1117 params
- SA1312 lowercase variable
- SA1121 built-in type
- SA1500/SA1513/SA1503 formatting braces
- SA1400 declare access modifier
- SA1122 string.Empty
- SA1310 no underscore
- IDE0049 name simplified
- IDE0057 simplify substring
- IDE0074 compound assignment
- IDE0032 use auto-property
- IDE0037 simplify member name
- IDE0008 explicit type not var
- IDE0016/IDE0270/IDE0041 simplify null checks
- IDE0048/SA1407 clarity in arithmetic
- IDE1006 correct param names
- IDE0042 deconstruct variable
- IDE0044 readonly
- IDE0018 inline variable declarations
- IDE0074/IDE0054 compound assignment
- IDE1006 naming
- CS1573 param XML
- CS0168 unused variable
Comment formatting in project files for consistency.
Updated all projects to only list remaining specific warning codes as warnings instead of errors (errors is now default).
* Type not var, and more warning exceptions
* Tweaked merge issue, readded comment about rollback
* Readded comment re rollback.
* Readded comments
* Comment tweak
* Comment tweak
2024-09-24 12:56:28 +01:00
( v ? ? = new List < DocumentEntitySlim > ( ) ) . Add ( e ) ;
2018-09-21 15:49:37 +10:00
}
2022-06-02 08:18:31 +02:00
}
2018-09-21 15:49:37 +10:00
2022-06-02 08:18:31 +02:00
if ( v = = null )
{
2018-09-25 10:55:33 +02:00
return entitiesList ;
2018-09-21 15:49:37 +10:00
}
2022-06-02 08:18:31 +02:00
// fetch all variant info dtos
Resolved more warnings, and marked more warning types as errors (#16991)
* Fix warnings SA1111, SA1028, SA1500, IDE1270 in Umbraco.Web.Website, and updated rules.
* Remove warnings: IDE0270: Null check can be simplified
* More SqlServer project warnings resolved
* CS0105 namespace appeared already
* Suppress warning until implementation:
#pragma warning disable CS0162 // Unreachable code detected
#pragma warning disable CS0618 // Type or member is obsolete
CS0162 remove unreachable code
SA1028 remove trailing whitespace
SA1106 no empty statements
CS1570 malformed XML
CS1572 corrected xml parameter
CS1573 param tag added
IDE0007 var not explicit
IDE0008 explicit not var
IDE0057 simplify substring
IDE0074 compound assignment
CA1825 array.empty
Down to 3479 warnings
* - SA1116, SA117 params on same line
- IDE0057 substring simplified
Specific warnings for Umbraco.Tests.Benchmarks
* Fixed IDE0074 compound assignment and added specific warnings for Umbraco.Tests.Common
* Specific warnings for Umbraco.Tests.Integration and Umbraco.Tests.Common
Fixed:
- SA1111, SA1116, SA117 params and line formatting (not all as there are many)
- SA1122 string.Empty
- IDE0057 simplify substring
- IDE0044,IDE0044 make field readonly
- IDE1006 naming rule violation (add _)
- SA1111 closing parenthesis on line of last parameter
- SA1649 filename match type name
- SA1312,SA1306 lowercase variable and field names
* Fixed various warnings where they are more straight-forward, including:
- SA1649 file name match type name
- SA111 parenthesis on line of last parameter
- IDE0028 simplify collection initializer
- SA1306 lower-case letter field
- IDE044 readonly field
- SA1122 string.Empty
- SA1116 params same line
- IDE1006 upper casing
- IDE0041 simplify null check
Updated the following projects to only list their remaining specific warning codes:
- Umbraco.Tests.UnitTests
Typo in `Umbraco.Web.Website` project
* Reverted test change
* Now 1556 warnings.
Fixed various warnings where they are more straight-forward, including:
- SA1111/SA1116/SA1119 parenthesis
- SA1117 params
- SA1312 lowercase variable
- SA1121 built-in type
- SA1500/SA1513/SA1503 formatting braces
- SA1400 declare access modifier
- SA1122 string.Empty
- SA1310 no underscore
- IDE0049 name simplified
- IDE0057 simplify substring
- IDE0074 compound assignment
- IDE0032 use auto-property
- IDE0037 simplify member name
- IDE0008 explicit type not var
- IDE0016/IDE0270/IDE0041 simplify null checks
- IDE0048/SA1407 clarity in arithmetic
- IDE1006 correct param names
- IDE0042 deconstruct variable
- IDE0044 readonly
- IDE0018 inline variable declarations
- IDE0074/IDE0054 compound assignment
- IDE1006 naming
- CS1573 param XML
- CS0168 unused variable
Comment formatting in project files for consistency.
Updated all projects to only list remaining specific warning codes as warnings instead of errors (errors is now default).
* Type not var, and more warning exceptions
* Tweaked merge issue, readded comment about rollback
* Readded comment re rollback.
* Readded comments
* Comment tweak
* Comment tweak
2024-09-24 12:56:28 +01:00
IEnumerable < VariantInfoDto > dtos = Database . FetchByGroups < VariantInfoDto , int > (
v . Select ( x = > x . Id ) ,
Constants . Sql . MaxParameterCount ,
GetVariantInfos ) ;
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
// group by node id (each group contains all languages)
var xdtos = dtos . GroupBy ( x = > x . NodeId ) . ToDictionary ( x = > x . Key , x = > x ) ;
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
foreach ( DocumentEntitySlim e in v )
2018-09-21 15:49:37 +10:00
{
2022-06-02 08:18:31 +02:00
// since we're only iterating on entities that vary, we must have something
IGrouping < int , VariantInfoDto > edtos = xdtos [ e . Id ] ;
2018-09-25 10:55:33 +02:00
2022-06-02 08:18:31 +02:00
e . CultureNames = edtos . Where ( x = > x . CultureAvailable ) . ToDictionary ( x = > x . IsoCode , x = > x . Name ) ;
e . PublishedCultures = edtos . Where ( x = > x . CulturePublished ) . Select ( x = > x . IsoCode ) ;
e . EditedCultures = edtos . Where ( x = > x . CultureAvailable & & x . CultureEdited ) . Select ( x = > x . IsoCode ) ;
}
2018-09-25 10:55:33 +02:00
2022-06-02 08:18:31 +02:00
return entitiesList ;
}
2018-09-25 10:55:33 +02:00
2022-06-02 08:18:31 +02:00
#endregion
#region Sql
protected Sql < ISqlContext > GetVariantInfos ( IEnumerable < int > ids ) = >
Sql ( )
. Select < NodeDto > ( x = > x . NodeId )
. AndSelect < LanguageDto > ( x = > x . IsoCode )
Resolved more warnings, and marked more warning types as errors (#16991)
* Fix warnings SA1111, SA1028, SA1500, IDE1270 in Umbraco.Web.Website, and updated rules.
* Remove warnings: IDE0270: Null check can be simplified
* More SqlServer project warnings resolved
* CS0105 namespace appeared already
* Suppress warning until implementation:
#pragma warning disable CS0162 // Unreachable code detected
#pragma warning disable CS0618 // Type or member is obsolete
CS0162 remove unreachable code
SA1028 remove trailing whitespace
SA1106 no empty statements
CS1570 malformed XML
CS1572 corrected xml parameter
CS1573 param tag added
IDE0007 var not explicit
IDE0008 explicit not var
IDE0057 simplify substring
IDE0074 compound assignment
CA1825 array.empty
Down to 3479 warnings
* - SA1116, SA117 params on same line
- IDE0057 substring simplified
Specific warnings for Umbraco.Tests.Benchmarks
* Fixed IDE0074 compound assignment and added specific warnings for Umbraco.Tests.Common
* Specific warnings for Umbraco.Tests.Integration and Umbraco.Tests.Common
Fixed:
- SA1111, SA1116, SA117 params and line formatting (not all as there are many)
- SA1122 string.Empty
- IDE0057 simplify substring
- IDE0044,IDE0044 make field readonly
- IDE1006 naming rule violation (add _)
- SA1111 closing parenthesis on line of last parameter
- SA1649 filename match type name
- SA1312,SA1306 lowercase variable and field names
* Fixed various warnings where they are more straight-forward, including:
- SA1649 file name match type name
- SA111 parenthesis on line of last parameter
- IDE0028 simplify collection initializer
- SA1306 lower-case letter field
- IDE044 readonly field
- SA1122 string.Empty
- SA1116 params same line
- IDE1006 upper casing
- IDE0041 simplify null check
Updated the following projects to only list their remaining specific warning codes:
- Umbraco.Tests.UnitTests
Typo in `Umbraco.Web.Website` project
* Reverted test change
* Now 1556 warnings.
Fixed various warnings where they are more straight-forward, including:
- SA1111/SA1116/SA1119 parenthesis
- SA1117 params
- SA1312 lowercase variable
- SA1121 built-in type
- SA1500/SA1513/SA1503 formatting braces
- SA1400 declare access modifier
- SA1122 string.Empty
- SA1310 no underscore
- IDE0049 name simplified
- IDE0057 simplify substring
- IDE0074 compound assignment
- IDE0032 use auto-property
- IDE0037 simplify member name
- IDE0008 explicit type not var
- IDE0016/IDE0270/IDE0041 simplify null checks
- IDE0048/SA1407 clarity in arithmetic
- IDE1006 correct param names
- IDE0042 deconstruct variable
- IDE0044 readonly
- IDE0018 inline variable declarations
- IDE0074/IDE0054 compound assignment
- IDE1006 naming
- CS1573 param XML
- CS0168 unused variable
Comment formatting in project files for consistency.
Updated all projects to only list remaining specific warning codes as warnings instead of errors (errors is now default).
* Type not var, and more warning exceptions
* Tweaked merge issue, readded comment about rollback
* Readded comment re rollback.
* Readded comments
* Comment tweak
* Comment tweak
2024-09-24 12:56:28 +01:00
. AndSelect < DocumentDto > (
"doc" ,
x = > Alias (
x . Published ,
"DocumentPublished" ) ,
2022-06-02 08:18:31 +02:00
x = > Alias ( x . Edited , "DocumentEdited" ) )
Resolved more warnings, and marked more warning types as errors (#16991)
* Fix warnings SA1111, SA1028, SA1500, IDE1270 in Umbraco.Web.Website, and updated rules.
* Remove warnings: IDE0270: Null check can be simplified
* More SqlServer project warnings resolved
* CS0105 namespace appeared already
* Suppress warning until implementation:
#pragma warning disable CS0162 // Unreachable code detected
#pragma warning disable CS0618 // Type or member is obsolete
CS0162 remove unreachable code
SA1028 remove trailing whitespace
SA1106 no empty statements
CS1570 malformed XML
CS1572 corrected xml parameter
CS1573 param tag added
IDE0007 var not explicit
IDE0008 explicit not var
IDE0057 simplify substring
IDE0074 compound assignment
CA1825 array.empty
Down to 3479 warnings
* - SA1116, SA117 params on same line
- IDE0057 substring simplified
Specific warnings for Umbraco.Tests.Benchmarks
* Fixed IDE0074 compound assignment and added specific warnings for Umbraco.Tests.Common
* Specific warnings for Umbraco.Tests.Integration and Umbraco.Tests.Common
Fixed:
- SA1111, SA1116, SA117 params and line formatting (not all as there are many)
- SA1122 string.Empty
- IDE0057 simplify substring
- IDE0044,IDE0044 make field readonly
- IDE1006 naming rule violation (add _)
- SA1111 closing parenthesis on line of last parameter
- SA1649 filename match type name
- SA1312,SA1306 lowercase variable and field names
* Fixed various warnings where they are more straight-forward, including:
- SA1649 file name match type name
- SA111 parenthesis on line of last parameter
- IDE0028 simplify collection initializer
- SA1306 lower-case letter field
- IDE044 readonly field
- SA1122 string.Empty
- SA1116 params same line
- IDE1006 upper casing
- IDE0041 simplify null check
Updated the following projects to only list their remaining specific warning codes:
- Umbraco.Tests.UnitTests
Typo in `Umbraco.Web.Website` project
* Reverted test change
* Now 1556 warnings.
Fixed various warnings where they are more straight-forward, including:
- SA1111/SA1116/SA1119 parenthesis
- SA1117 params
- SA1312 lowercase variable
- SA1121 built-in type
- SA1500/SA1513/SA1503 formatting braces
- SA1400 declare access modifier
- SA1122 string.Empty
- SA1310 no underscore
- IDE0049 name simplified
- IDE0057 simplify substring
- IDE0074 compound assignment
- IDE0032 use auto-property
- IDE0037 simplify member name
- IDE0008 explicit type not var
- IDE0016/IDE0270/IDE0041 simplify null checks
- IDE0048/SA1407 clarity in arithmetic
- IDE1006 correct param names
- IDE0042 deconstruct variable
- IDE0044 readonly
- IDE0018 inline variable declarations
- IDE0074/IDE0054 compound assignment
- IDE1006 naming
- CS1573 param XML
- CS0168 unused variable
Comment formatting in project files for consistency.
Updated all projects to only list remaining specific warning codes as warnings instead of errors (errors is now default).
* Type not var, and more warning exceptions
* Tweaked merge issue, readded comment about rollback
* Readded comment re rollback.
* Readded comments
* Comment tweak
* Comment tweak
2024-09-24 12:56:28 +01:00
. AndSelect < DocumentCultureVariationDto > (
"dcv" ,
x = > Alias ( x . Available , "CultureAvailable" ) ,
x = > Alias ( x . Published , "CulturePublished" ) ,
2022-06-02 08:18:31 +02:00
x = > Alias ( x . Edited , "CultureEdited" ) ,
x = > Alias ( x . Name , "Name" ) )
// from node x language
. From < NodeDto > ( )
. CrossJoin < LanguageDto > ( )
// join to document - always exists - indicates global document published/edited status
. InnerJoin < DocumentDto > ( "doc" )
. On < NodeDto , DocumentDto > ( ( node , doc ) = > node . NodeId = = doc . NodeId , aliasRight : "doc" )
// left-join do document variation - matches cultures that are *available* + indicates when *edited*
. LeftJoin < DocumentCultureVariationDto > ( "dcv" )
. On < NodeDto , DocumentCultureVariationDto , LanguageDto > (
( node , dcv , lang ) = > node . NodeId = = dcv . NodeId & & lang . Id = = dcv . LanguageId , aliasRight : "dcv" )
// for selected nodes
. WhereIn < NodeDto > ( x = > x . NodeId , ids )
. OrderBy < LanguageDto > ( x = > x . Id ) ;
// gets the full sql for a given object type and a given unique id
protected Sql < ISqlContext > GetFullSqlForEntityType ( bool isContent , bool isMedia , bool isMember , Guid objectType ,
Guid uniqueId )
{
Sql < ISqlContext > sql = GetBaseWhere ( isContent , isMedia , isMember , false , objectType , uniqueId ) ;
return AddGroupBy ( isContent , isMedia , isMember , sql , true ) ;
}
2018-09-25 10:55:33 +02:00
2022-06-02 08:18:31 +02:00
// gets the full sql for a given object type and a given node id
protected Sql < ISqlContext > GetFullSqlForEntityType ( bool isContent , bool isMedia , bool isMember , Guid objectType ,
int nodeId )
{
Sql < ISqlContext > sql = GetBaseWhere ( isContent , isMedia , isMember , false , objectType , nodeId ) ;
return AddGroupBy ( isContent , isMedia , isMember , sql , true ) ;
}
2018-09-25 10:55:33 +02:00
2022-06-02 08:18:31 +02:00
// gets the full sql for a given object type, with a given filter
protected Sql < ISqlContext > GetFullSqlForEntityType ( bool isContent , bool isMedia , bool isMember , Guid objectType ,
Action < Sql < ISqlContext > > ? filter )
{
Resolved more warnings, and marked more warning types as errors (#16991)
* Fix warnings SA1111, SA1028, SA1500, IDE1270 in Umbraco.Web.Website, and updated rules.
* Remove warnings: IDE0270: Null check can be simplified
* More SqlServer project warnings resolved
* CS0105 namespace appeared already
* Suppress warning until implementation:
#pragma warning disable CS0162 // Unreachable code detected
#pragma warning disable CS0618 // Type or member is obsolete
CS0162 remove unreachable code
SA1028 remove trailing whitespace
SA1106 no empty statements
CS1570 malformed XML
CS1572 corrected xml parameter
CS1573 param tag added
IDE0007 var not explicit
IDE0008 explicit not var
IDE0057 simplify substring
IDE0074 compound assignment
CA1825 array.empty
Down to 3479 warnings
* - SA1116, SA117 params on same line
- IDE0057 substring simplified
Specific warnings for Umbraco.Tests.Benchmarks
* Fixed IDE0074 compound assignment and added specific warnings for Umbraco.Tests.Common
* Specific warnings for Umbraco.Tests.Integration and Umbraco.Tests.Common
Fixed:
- SA1111, SA1116, SA117 params and line formatting (not all as there are many)
- SA1122 string.Empty
- IDE0057 simplify substring
- IDE0044,IDE0044 make field readonly
- IDE1006 naming rule violation (add _)
- SA1111 closing parenthesis on line of last parameter
- SA1649 filename match type name
- SA1312,SA1306 lowercase variable and field names
* Fixed various warnings where they are more straight-forward, including:
- SA1649 file name match type name
- SA111 parenthesis on line of last parameter
- IDE0028 simplify collection initializer
- SA1306 lower-case letter field
- IDE044 readonly field
- SA1122 string.Empty
- SA1116 params same line
- IDE1006 upper casing
- IDE0041 simplify null check
Updated the following projects to only list their remaining specific warning codes:
- Umbraco.Tests.UnitTests
Typo in `Umbraco.Web.Website` project
* Reverted test change
* Now 1556 warnings.
Fixed various warnings where they are more straight-forward, including:
- SA1111/SA1116/SA1119 parenthesis
- SA1117 params
- SA1312 lowercase variable
- SA1121 built-in type
- SA1500/SA1513/SA1503 formatting braces
- SA1400 declare access modifier
- SA1122 string.Empty
- SA1310 no underscore
- IDE0049 name simplified
- IDE0057 simplify substring
- IDE0074 compound assignment
- IDE0032 use auto-property
- IDE0037 simplify member name
- IDE0008 explicit type not var
- IDE0016/IDE0270/IDE0041 simplify null checks
- IDE0048/SA1407 clarity in arithmetic
- IDE1006 correct param names
- IDE0042 deconstruct variable
- IDE0044 readonly
- IDE0018 inline variable declarations
- IDE0074/IDE0054 compound assignment
- IDE1006 naming
- CS1573 param XML
- CS0168 unused variable
Comment formatting in project files for consistency.
Updated all projects to only list remaining specific warning codes as warnings instead of errors (errors is now default).
* Type not var, and more warning exceptions
* Tweaked merge issue, readded comment about rollback
* Readded comment re rollback.
* Readded comments
* Comment tweak
* Comment tweak
2024-09-24 12:56:28 +01:00
Sql < ISqlContext > sql = GetBaseWhere ( isContent , isMedia , isMember , false , filter , new [ ] { objectType } ) ;
2022-06-02 08:18:31 +02:00
return AddGroupBy ( isContent , isMedia , isMember , sql , true ) ;
}
2017-12-07 16:45:25 +01:00
2025-07-07 14:53:42 +02:00
protected Sql < ISqlContext > GetFullSqlForEntityType (
bool isContent ,
bool isMedia ,
bool isMember ,
Guid objectType ,
Ordering ordering ,
Action < Sql < ISqlContext > > ? filter )
{
Sql < ISqlContext > sql = GetBaseWhere ( isContent , isMedia , isMember , false , filter , new [ ] { objectType } ) ;
AddGroupBy ( isContent , isMedia , isMember , sql , false ) ;
ApplyOrdering ( ref sql , ordering ) ;
return sql ;
}
Merge branch 'v15/dev' into v16/dev (#18971)
* Only prevent the unpublish or delete of a related item when configured to do so if it is related as a child, not as a parent (#18886)
* Only prevent the unpubkish or delete of a related item when configured to do so if it is related as a child, not as a parent.
* Fixed incorect parameter names.
* Fixed failing integration tests.
* Use using variable instead to reduce nesting
* Applied suggestions from code review.
* Used simple using statement throughout RelationService for consistency.
* Applied XML header comments consistently.
---------
Co-authored-by: mole <nikolajlauridsen@protonmail.ch>
* Feature: highlight invariant doc with variant blocks is unsupported (#18806)
* mark variant blocks in invariant docs as invalid
* implement RTE Blocks
* Fix pagination for users restricted by start nodes (#18907)
* Fix pagination for users restricted by start nodes
* Default implementation to avoid breakage
* Review comments
* Fix failing test
* Add media start node tests
* Fix issue preventing blueprint derived values from being scaffolded (#18917)
* Fix issue preventing blueprint derived values from being scaffolded.
* fix manipulating frooen array
* compare with variantId as well
---------
Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com>
* ci: add Azure Static Web Apps workflow file
on-behalf-of: @Azure opensource@microsoft.com
* ci: add Azure Static Web Apps workflow file
on-behalf-of: @Azure opensource@microsoft.com
* ci: add Azure Static Web Apps workflow file
on-behalf-of: @Azure opensource@microsoft.com
* Remove admin permission on user configuration, allowing users with user section access only to manaage users and groups. (#18848)
* Tiptap RTE: Style Menu extension kind (#18918)
* Adds 'styleMenu' Tiptap toolbar extension kind
* Adds icons for `<h4>` and `<p>` tags
* Adds commands to HTML Global Attributes extension
for setting the `class` and `id` attributes.
* Renamed "default-tiptap-toolbar-element.api.ts" file
The "element" part was confusing.
* Toolbar Menu: uses correct `item` value
* Cascading Menu: adds localization for the label
* Adds `label` attribute to UUI components
for accessibility.
* Toolbar Menu: uses correct `appearance` value
* Removed unrequired `api` from Style Select
* Destructs the `item.data` object
* Ensure has children reflects only items with folder children when folders only are queried. (#18790)
* Ensure has children reflects only items with folder children when folders only are queried.
* Added supression for change to integration test public code.
---------
Co-authored-by: Migaroez <geusens@gmail.com>
* Only apply validation on content update to variant cultures where the editor has permission for the culture (#18778)
* Only apply validation on content update to variant cultures where the editor has permission for the culture.
* Remove inadvertent comment updates.
* Fixed failing integration test.
* Adds ancestor ID details on document tree and collection responses (#18909)
* Populate ancestor keys on document tree response items.
* Populate ancestor keys on document collection response items.
* Update OpenApi.json
* Use array of objects rather than Ids for the ancestor collection.
* Update OpenApi.json.
* Move publish with descendants to a background task with polling (#18497)
* Use background queue for database cache rebuild and track rebuilding status.
* Updated OpenApi.json and client-side types.
* Updated client to poll for completion of database rebuild.
* Move IBackgroundTaskQueue to core and prepare publish branch to run as background task.
* Endpoints for retrieval of status and result from branch publish operations.
* Poll and retrieve result for publish with descendants.
* Handled issues from testing.
* Rework to single controller for status and result.
* Updated client side sdk.
* OpenApi post dev merge gen
---------
Co-authored-by: Migaroez <geusens@gmail.com>
* Clear roots before rebuilding navigation dictionary (#18766)
* Clear roots before rebuilding navigation dictionary.
* Added tests to verify fix.
* Correct test implementation.
* Convert integration tests with method overloads into test cases.
* Integration test compatibility supressions.
* Fixes save of empty, invariant block list on variant content. (#18932)
* remove unnecessary code (#18927)
* V15/bugfix/fix route issue from 18859 (#18931)
* unique check
* unique for workspace empty path
* more unique routes
* Bump vite from 6.2.3 to 6.2.4 in /src/Umbraco.Web.UI.Client
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.2.3 to 6.2.4.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v6.2.4/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.2.4/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-version: 6.2.4
dependency-type: direct:development
...
Signed-off-by: dependabot[bot] <support@github.com>
* removes autogenerated workflows
* make getHasUnpersistedChanges public (#18929)
* Added management API endpoint, service and repository for retrieval of references from the recycle bin (#18882)
* Added management API endpoint, service and repository for retrieval of references from the recycle bin.
* Update src/Umbraco.Cms.Api.Management/Controllers/Document/RecycleBin/ReferencedByDocumentRecycleBinController.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Removed unused code.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Updated management API endpoint and model for data type references to align with that used for documents, media etc. (#18905)
* Updated management API endpoint and model for data type references to align with that used for documents, media etc.
* Refactoring.
* Update src/Umbraco.Core/Constants-ReferenceTypes.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Fixed typos.
* Added id to tracked reference content type response.
* Updated OpenApi.json.
* Added missing updates.
* Renamed model and constants from code review feedback.
* Fix typo
* Fix multiple enumeration
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: mole <nikolajlauridsen@protonmail.ch>
* Skip lock tests
* Look-up redirect in content finder for multi-lingual sites using path and legacy route prefixed with the integer ID of the node with domains defined (#18763)
* Look-up redirect in content finder for multi-lingual sites using path and legacy route prefixed with the integer ID of the node with domains defined.
* Added tests to verify functionality.
* Added reference to previous PR.
* Referenced second PR.
* Assemble URLs for all cultures, not just the default.
* Revert previous update.
* Display an original URL if we have one.
* Bump vite from 6.2.4 to 6.2.5 in /src/Umbraco.Web.UI.Client
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.2.4 to 6.2.5.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v6.2.5/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.2.5/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-version: 6.2.5
dependency-type: direct:development
...
Signed-off-by: dependabot[bot] <support@github.com>
* Add raw value validation to multiple text strings property editor (#18936)
* Add raw value validation to multiple text strings property editor
* Added additional assert on unit test and comment on validation logic.
* Don't remove items to obtain a valid value
---------
Co-authored-by: Andy Butland <abutland73@gmail.com>
* Integration tests for content publishing with ancestor unpublished (#18941)
* Resolved warnings in test class.
* Refactor regions into partial classes.
* Aligned test names.
* Variable name refactoring.
* Added tests for unpublished paths.
* Adjust tests to verify current behaviour.
* Cleaned up project file.
* fix circular icon import (#18952)
* remove segment toggle for elements (#18949)
* Fix modal route registration circular import (#18953)
* fix modal route registration circular import
* Update modal-route-registration.controller.ts
* V15/fix/18595 (#18925)
* fix for #18595
* updates the en.ts
* Avoid unneeded Dictionary operations (#18890)
* Avoid some heap allocations
* Remove unneeded double seek
* Avoid allocating new empty arrays, reuse existing empty array
* Avoid allocating strings for parsing comma separated int values (#18199)
* Data type References UI: Workspace + Delete (#18914)
* Updated management API endpoint and model for data type references to align with that used for documents, media etc.
* Refactoring.
* Update src/Umbraco.Core/Constants-ReferenceTypes.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Fixed typos.
* generate server models
* add extension slot
* register data type reference info app
* add reference data mappers
* Added id to tracked reference content type response.
* Updated OpenApi.json.
* Added missing updates.
* generate new models
* update models
* register ref item
* remove debugger
* render types
* register member type property type ref
* register media type property type ref
* Renamed model and constants from code review feedback.
* register reference workspace info app kind
* use kind for document references
* use kind for media references
* use kind for member references
* use deleteWithRelation kind when deleting data types
* fix manifest types
* fix types
* Update types.gen.ts
* update code to fit new server models
---------
Co-authored-by: Andy Butland <abutland73@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Feature: discard changes for block workspace (#18930)
* make getHasUnpersistedChanges public
* Discard changes impl for Block Workspace
* fix 18367 (#18956)
* Merge commit from fork
* Prevent path traveral vulnerability with upload of temporary files.
* Used BadRequest instead of NotFound for invalid file name response.
* V15 QA Fixing the failing media acceptance tests (#18881)
* Fixed the function name due to test helper changes
* Updated assertion steps due to UI changes
* Added more waits
* Bumped version
* Increase timeout
* Reverted
---------
Co-authored-by: Andreas Zerbst <73799582+andr317c@users.noreply.github.com>
* V15 QA added clipboard test for not being able to copy to root when block is not allowed at root (#18937)
* Added clipboard test
* Bumped version
* Updated to use the name
* Run all tests on the pipeline
* Reverted command
* build: adjusts circular ref number to 4
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Andy Butland <abutland73@gmail.com>
Co-authored-by: mole <nikolajlauridsen@protonmail.ch>
Co-authored-by: Niels Lyngsø <nsl@umbraco.dk>
Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com>
Co-authored-by: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com>
Co-authored-by: Lee Kelleher <leekelleher@users.noreply.github.com>
Co-authored-by: Migaroez <geusens@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
Co-authored-by: Mads Rasmussen <madsr@hey.com>
Co-authored-by: Jacob Welander Jensen <64834767+Welander1994@users.noreply.github.com>
Co-authored-by: Henrik <hg@impact.dk>
Co-authored-by: Sebastiaan Janssen <sebastiaan@umbraco.com>
Co-authored-by: Nhu Dinh <150406148+nhudinh0309@users.noreply.github.com>
Co-authored-by: Andreas Zerbst <73799582+andr317c@users.noreply.github.com>
2025-04-09 09:58:01 +02:00
protected Sql < ISqlContext > GetBase ( bool isContent , bool isMedia , bool isMember , Action < Sql < ISqlContext > > ? filter , bool isCount = false )
= > GetBase ( isContent , isMedia , isMember , filter , [ ] , isCount ) ;
2022-06-02 08:18:31 +02:00
// gets the base SELECT + FROM [+ filter] sql
// always from the 'current' content version
Merge branch 'v15/dev' into v16/dev (#18971)
* Only prevent the unpublish or delete of a related item when configured to do so if it is related as a child, not as a parent (#18886)
* Only prevent the unpubkish or delete of a related item when configured to do so if it is related as a child, not as a parent.
* Fixed incorect parameter names.
* Fixed failing integration tests.
* Use using variable instead to reduce nesting
* Applied suggestions from code review.
* Used simple using statement throughout RelationService for consistency.
* Applied XML header comments consistently.
---------
Co-authored-by: mole <nikolajlauridsen@protonmail.ch>
* Feature: highlight invariant doc with variant blocks is unsupported (#18806)
* mark variant blocks in invariant docs as invalid
* implement RTE Blocks
* Fix pagination for users restricted by start nodes (#18907)
* Fix pagination for users restricted by start nodes
* Default implementation to avoid breakage
* Review comments
* Fix failing test
* Add media start node tests
* Fix issue preventing blueprint derived values from being scaffolded (#18917)
* Fix issue preventing blueprint derived values from being scaffolded.
* fix manipulating frooen array
* compare with variantId as well
---------
Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com>
* ci: add Azure Static Web Apps workflow file
on-behalf-of: @Azure opensource@microsoft.com
* ci: add Azure Static Web Apps workflow file
on-behalf-of: @Azure opensource@microsoft.com
* ci: add Azure Static Web Apps workflow file
on-behalf-of: @Azure opensource@microsoft.com
* Remove admin permission on user configuration, allowing users with user section access only to manaage users and groups. (#18848)
* Tiptap RTE: Style Menu extension kind (#18918)
* Adds 'styleMenu' Tiptap toolbar extension kind
* Adds icons for `<h4>` and `<p>` tags
* Adds commands to HTML Global Attributes extension
for setting the `class` and `id` attributes.
* Renamed "default-tiptap-toolbar-element.api.ts" file
The "element" part was confusing.
* Toolbar Menu: uses correct `item` value
* Cascading Menu: adds localization for the label
* Adds `label` attribute to UUI components
for accessibility.
* Toolbar Menu: uses correct `appearance` value
* Removed unrequired `api` from Style Select
* Destructs the `item.data` object
* Ensure has children reflects only items with folder children when folders only are queried. (#18790)
* Ensure has children reflects only items with folder children when folders only are queried.
* Added supression for change to integration test public code.
---------
Co-authored-by: Migaroez <geusens@gmail.com>
* Only apply validation on content update to variant cultures where the editor has permission for the culture (#18778)
* Only apply validation on content update to variant cultures where the editor has permission for the culture.
* Remove inadvertent comment updates.
* Fixed failing integration test.
* Adds ancestor ID details on document tree and collection responses (#18909)
* Populate ancestor keys on document tree response items.
* Populate ancestor keys on document collection response items.
* Update OpenApi.json
* Use array of objects rather than Ids for the ancestor collection.
* Update OpenApi.json.
* Move publish with descendants to a background task with polling (#18497)
* Use background queue for database cache rebuild and track rebuilding status.
* Updated OpenApi.json and client-side types.
* Updated client to poll for completion of database rebuild.
* Move IBackgroundTaskQueue to core and prepare publish branch to run as background task.
* Endpoints for retrieval of status and result from branch publish operations.
* Poll and retrieve result for publish with descendants.
* Handled issues from testing.
* Rework to single controller for status and result.
* Updated client side sdk.
* OpenApi post dev merge gen
---------
Co-authored-by: Migaroez <geusens@gmail.com>
* Clear roots before rebuilding navigation dictionary (#18766)
* Clear roots before rebuilding navigation dictionary.
* Added tests to verify fix.
* Correct test implementation.
* Convert integration tests with method overloads into test cases.
* Integration test compatibility supressions.
* Fixes save of empty, invariant block list on variant content. (#18932)
* remove unnecessary code (#18927)
* V15/bugfix/fix route issue from 18859 (#18931)
* unique check
* unique for workspace empty path
* more unique routes
* Bump vite from 6.2.3 to 6.2.4 in /src/Umbraco.Web.UI.Client
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.2.3 to 6.2.4.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v6.2.4/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.2.4/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-version: 6.2.4
dependency-type: direct:development
...
Signed-off-by: dependabot[bot] <support@github.com>
* removes autogenerated workflows
* make getHasUnpersistedChanges public (#18929)
* Added management API endpoint, service and repository for retrieval of references from the recycle bin (#18882)
* Added management API endpoint, service and repository for retrieval of references from the recycle bin.
* Update src/Umbraco.Cms.Api.Management/Controllers/Document/RecycleBin/ReferencedByDocumentRecycleBinController.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Removed unused code.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Updated management API endpoint and model for data type references to align with that used for documents, media etc. (#18905)
* Updated management API endpoint and model for data type references to align with that used for documents, media etc.
* Refactoring.
* Update src/Umbraco.Core/Constants-ReferenceTypes.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Fixed typos.
* Added id to tracked reference content type response.
* Updated OpenApi.json.
* Added missing updates.
* Renamed model and constants from code review feedback.
* Fix typo
* Fix multiple enumeration
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: mole <nikolajlauridsen@protonmail.ch>
* Skip lock tests
* Look-up redirect in content finder for multi-lingual sites using path and legacy route prefixed with the integer ID of the node with domains defined (#18763)
* Look-up redirect in content finder for multi-lingual sites using path and legacy route prefixed with the integer ID of the node with domains defined.
* Added tests to verify functionality.
* Added reference to previous PR.
* Referenced second PR.
* Assemble URLs for all cultures, not just the default.
* Revert previous update.
* Display an original URL if we have one.
* Bump vite from 6.2.4 to 6.2.5 in /src/Umbraco.Web.UI.Client
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.2.4 to 6.2.5.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v6.2.5/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.2.5/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-version: 6.2.5
dependency-type: direct:development
...
Signed-off-by: dependabot[bot] <support@github.com>
* Add raw value validation to multiple text strings property editor (#18936)
* Add raw value validation to multiple text strings property editor
* Added additional assert on unit test and comment on validation logic.
* Don't remove items to obtain a valid value
---------
Co-authored-by: Andy Butland <abutland73@gmail.com>
* Integration tests for content publishing with ancestor unpublished (#18941)
* Resolved warnings in test class.
* Refactor regions into partial classes.
* Aligned test names.
* Variable name refactoring.
* Added tests for unpublished paths.
* Adjust tests to verify current behaviour.
* Cleaned up project file.
* fix circular icon import (#18952)
* remove segment toggle for elements (#18949)
* Fix modal route registration circular import (#18953)
* fix modal route registration circular import
* Update modal-route-registration.controller.ts
* V15/fix/18595 (#18925)
* fix for #18595
* updates the en.ts
* Avoid unneeded Dictionary operations (#18890)
* Avoid some heap allocations
* Remove unneeded double seek
* Avoid allocating new empty arrays, reuse existing empty array
* Avoid allocating strings for parsing comma separated int values (#18199)
* Data type References UI: Workspace + Delete (#18914)
* Updated management API endpoint and model for data type references to align with that used for documents, media etc.
* Refactoring.
* Update src/Umbraco.Core/Constants-ReferenceTypes.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Fixed typos.
* generate server models
* add extension slot
* register data type reference info app
* add reference data mappers
* Added id to tracked reference content type response.
* Updated OpenApi.json.
* Added missing updates.
* generate new models
* update models
* register ref item
* remove debugger
* render types
* register member type property type ref
* register media type property type ref
* Renamed model and constants from code review feedback.
* register reference workspace info app kind
* use kind for document references
* use kind for media references
* use kind for member references
* use deleteWithRelation kind when deleting data types
* fix manifest types
* fix types
* Update types.gen.ts
* update code to fit new server models
---------
Co-authored-by: Andy Butland <abutland73@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Feature: discard changes for block workspace (#18930)
* make getHasUnpersistedChanges public
* Discard changes impl for Block Workspace
* fix 18367 (#18956)
* Merge commit from fork
* Prevent path traveral vulnerability with upload of temporary files.
* Used BadRequest instead of NotFound for invalid file name response.
* V15 QA Fixing the failing media acceptance tests (#18881)
* Fixed the function name due to test helper changes
* Updated assertion steps due to UI changes
* Added more waits
* Bumped version
* Increase timeout
* Reverted
---------
Co-authored-by: Andreas Zerbst <73799582+andr317c@users.noreply.github.com>
* V15 QA added clipboard test for not being able to copy to root when block is not allowed at root (#18937)
* Added clipboard test
* Bumped version
* Updated to use the name
* Run all tests on the pipeline
* Reverted command
* build: adjusts circular ref number to 4
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Andy Butland <abutland73@gmail.com>
Co-authored-by: mole <nikolajlauridsen@protonmail.ch>
Co-authored-by: Niels Lyngsø <nsl@umbraco.dk>
Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com>
Co-authored-by: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com>
Co-authored-by: Lee Kelleher <leekelleher@users.noreply.github.com>
Co-authored-by: Migaroez <geusens@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
Co-authored-by: Mads Rasmussen <madsr@hey.com>
Co-authored-by: Jacob Welander Jensen <64834767+Welander1994@users.noreply.github.com>
Co-authored-by: Henrik <hg@impact.dk>
Co-authored-by: Sebastiaan Janssen <sebastiaan@umbraco.com>
Co-authored-by: Nhu Dinh <150406148+nhudinh0309@users.noreply.github.com>
Co-authored-by: Andreas Zerbst <73799582+andr317c@users.noreply.github.com>
2025-04-09 09:58:01 +02:00
protected Sql < ISqlContext > GetBase ( bool isContent , bool isMedia , bool isMember , Action < Sql < ISqlContext > > ? filter , Guid [ ] objectTypes , bool isCount = false )
2022-06-02 08:18:31 +02:00
{
Sql < ISqlContext > sql = Sql ( ) ;
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
if ( isCount )
2017-12-07 16:45:25 +01:00
{
2022-06-02 08:18:31 +02:00
sql . SelectCount ( ) ;
2017-12-07 16:45:25 +01:00
}
2022-06-02 08:18:31 +02:00
else
2019-11-05 15:05:51 +11:00
{
2017-12-07 16:45:25 +01:00
sql
2022-06-02 08:18:31 +02:00
. Select < NodeDto > ( x = > x . NodeId , x = > x . Trashed , x = > x . ParentId , x = > x . UserId , x = > x . Level ,
x = > x . Path )
. AndSelect < NodeDto > ( x = > x . SortOrder , x = > x . UniqueId , x = > x . Text , x = > x . NodeObjectType ,
Merge branch 'v15/dev' into v16/dev (#18971)
* Only prevent the unpublish or delete of a related item when configured to do so if it is related as a child, not as a parent (#18886)
* Only prevent the unpubkish or delete of a related item when configured to do so if it is related as a child, not as a parent.
* Fixed incorect parameter names.
* Fixed failing integration tests.
* Use using variable instead to reduce nesting
* Applied suggestions from code review.
* Used simple using statement throughout RelationService for consistency.
* Applied XML header comments consistently.
---------
Co-authored-by: mole <nikolajlauridsen@protonmail.ch>
* Feature: highlight invariant doc with variant blocks is unsupported (#18806)
* mark variant blocks in invariant docs as invalid
* implement RTE Blocks
* Fix pagination for users restricted by start nodes (#18907)
* Fix pagination for users restricted by start nodes
* Default implementation to avoid breakage
* Review comments
* Fix failing test
* Add media start node tests
* Fix issue preventing blueprint derived values from being scaffolded (#18917)
* Fix issue preventing blueprint derived values from being scaffolded.
* fix manipulating frooen array
* compare with variantId as well
---------
Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com>
* ci: add Azure Static Web Apps workflow file
on-behalf-of: @Azure opensource@microsoft.com
* ci: add Azure Static Web Apps workflow file
on-behalf-of: @Azure opensource@microsoft.com
* ci: add Azure Static Web Apps workflow file
on-behalf-of: @Azure opensource@microsoft.com
* Remove admin permission on user configuration, allowing users with user section access only to manaage users and groups. (#18848)
* Tiptap RTE: Style Menu extension kind (#18918)
* Adds 'styleMenu' Tiptap toolbar extension kind
* Adds icons for `<h4>` and `<p>` tags
* Adds commands to HTML Global Attributes extension
for setting the `class` and `id` attributes.
* Renamed "default-tiptap-toolbar-element.api.ts" file
The "element" part was confusing.
* Toolbar Menu: uses correct `item` value
* Cascading Menu: adds localization for the label
* Adds `label` attribute to UUI components
for accessibility.
* Toolbar Menu: uses correct `appearance` value
* Removed unrequired `api` from Style Select
* Destructs the `item.data` object
* Ensure has children reflects only items with folder children when folders only are queried. (#18790)
* Ensure has children reflects only items with folder children when folders only are queried.
* Added supression for change to integration test public code.
---------
Co-authored-by: Migaroez <geusens@gmail.com>
* Only apply validation on content update to variant cultures where the editor has permission for the culture (#18778)
* Only apply validation on content update to variant cultures where the editor has permission for the culture.
* Remove inadvertent comment updates.
* Fixed failing integration test.
* Adds ancestor ID details on document tree and collection responses (#18909)
* Populate ancestor keys on document tree response items.
* Populate ancestor keys on document collection response items.
* Update OpenApi.json
* Use array of objects rather than Ids for the ancestor collection.
* Update OpenApi.json.
* Move publish with descendants to a background task with polling (#18497)
* Use background queue for database cache rebuild and track rebuilding status.
* Updated OpenApi.json and client-side types.
* Updated client to poll for completion of database rebuild.
* Move IBackgroundTaskQueue to core and prepare publish branch to run as background task.
* Endpoints for retrieval of status and result from branch publish operations.
* Poll and retrieve result for publish with descendants.
* Handled issues from testing.
* Rework to single controller for status and result.
* Updated client side sdk.
* OpenApi post dev merge gen
---------
Co-authored-by: Migaroez <geusens@gmail.com>
* Clear roots before rebuilding navigation dictionary (#18766)
* Clear roots before rebuilding navigation dictionary.
* Added tests to verify fix.
* Correct test implementation.
* Convert integration tests with method overloads into test cases.
* Integration test compatibility supressions.
* Fixes save of empty, invariant block list on variant content. (#18932)
* remove unnecessary code (#18927)
* V15/bugfix/fix route issue from 18859 (#18931)
* unique check
* unique for workspace empty path
* more unique routes
* Bump vite from 6.2.3 to 6.2.4 in /src/Umbraco.Web.UI.Client
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.2.3 to 6.2.4.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v6.2.4/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.2.4/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-version: 6.2.4
dependency-type: direct:development
...
Signed-off-by: dependabot[bot] <support@github.com>
* removes autogenerated workflows
* make getHasUnpersistedChanges public (#18929)
* Added management API endpoint, service and repository for retrieval of references from the recycle bin (#18882)
* Added management API endpoint, service and repository for retrieval of references from the recycle bin.
* Update src/Umbraco.Cms.Api.Management/Controllers/Document/RecycleBin/ReferencedByDocumentRecycleBinController.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Removed unused code.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Updated management API endpoint and model for data type references to align with that used for documents, media etc. (#18905)
* Updated management API endpoint and model for data type references to align with that used for documents, media etc.
* Refactoring.
* Update src/Umbraco.Core/Constants-ReferenceTypes.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Fixed typos.
* Added id to tracked reference content type response.
* Updated OpenApi.json.
* Added missing updates.
* Renamed model and constants from code review feedback.
* Fix typo
* Fix multiple enumeration
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: mole <nikolajlauridsen@protonmail.ch>
* Skip lock tests
* Look-up redirect in content finder for multi-lingual sites using path and legacy route prefixed with the integer ID of the node with domains defined (#18763)
* Look-up redirect in content finder for multi-lingual sites using path and legacy route prefixed with the integer ID of the node with domains defined.
* Added tests to verify functionality.
* Added reference to previous PR.
* Referenced second PR.
* Assemble URLs for all cultures, not just the default.
* Revert previous update.
* Display an original URL if we have one.
* Bump vite from 6.2.4 to 6.2.5 in /src/Umbraco.Web.UI.Client
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.2.4 to 6.2.5.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v6.2.5/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.2.5/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-version: 6.2.5
dependency-type: direct:development
...
Signed-off-by: dependabot[bot] <support@github.com>
* Add raw value validation to multiple text strings property editor (#18936)
* Add raw value validation to multiple text strings property editor
* Added additional assert on unit test and comment on validation logic.
* Don't remove items to obtain a valid value
---------
Co-authored-by: Andy Butland <abutland73@gmail.com>
* Integration tests for content publishing with ancestor unpublished (#18941)
* Resolved warnings in test class.
* Refactor regions into partial classes.
* Aligned test names.
* Variable name refactoring.
* Added tests for unpublished paths.
* Adjust tests to verify current behaviour.
* Cleaned up project file.
* fix circular icon import (#18952)
* remove segment toggle for elements (#18949)
* Fix modal route registration circular import (#18953)
* fix modal route registration circular import
* Update modal-route-registration.controller.ts
* V15/fix/18595 (#18925)
* fix for #18595
* updates the en.ts
* Avoid unneeded Dictionary operations (#18890)
* Avoid some heap allocations
* Remove unneeded double seek
* Avoid allocating new empty arrays, reuse existing empty array
* Avoid allocating strings for parsing comma separated int values (#18199)
* Data type References UI: Workspace + Delete (#18914)
* Updated management API endpoint and model for data type references to align with that used for documents, media etc.
* Refactoring.
* Update src/Umbraco.Core/Constants-ReferenceTypes.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Fixed typos.
* generate server models
* add extension slot
* register data type reference info app
* add reference data mappers
* Added id to tracked reference content type response.
* Updated OpenApi.json.
* Added missing updates.
* generate new models
* update models
* register ref item
* remove debugger
* render types
* register member type property type ref
* register media type property type ref
* Renamed model and constants from code review feedback.
* register reference workspace info app kind
* use kind for document references
* use kind for media references
* use kind for member references
* use deleteWithRelation kind when deleting data types
* fix manifest types
* fix types
* Update types.gen.ts
* update code to fit new server models
---------
Co-authored-by: Andy Butland <abutland73@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Feature: discard changes for block workspace (#18930)
* make getHasUnpersistedChanges public
* Discard changes impl for Block Workspace
* fix 18367 (#18956)
* Merge commit from fork
* Prevent path traveral vulnerability with upload of temporary files.
* Used BadRequest instead of NotFound for invalid file name response.
* V15 QA Fixing the failing media acceptance tests (#18881)
* Fixed the function name due to test helper changes
* Updated assertion steps due to UI changes
* Added more waits
* Bumped version
* Increase timeout
* Reverted
---------
Co-authored-by: Andreas Zerbst <73799582+andr317c@users.noreply.github.com>
* V15 QA added clipboard test for not being able to copy to root when block is not allowed at root (#18937)
* Added clipboard test
* Bumped version
* Updated to use the name
* Run all tests on the pipeline
* Reverted command
* build: adjusts circular ref number to 4
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Andy Butland <abutland73@gmail.com>
Co-authored-by: mole <nikolajlauridsen@protonmail.ch>
Co-authored-by: Niels Lyngsø <nsl@umbraco.dk>
Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com>
Co-authored-by: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com>
Co-authored-by: Lee Kelleher <leekelleher@users.noreply.github.com>
Co-authored-by: Migaroez <geusens@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
Co-authored-by: Mads Rasmussen <madsr@hey.com>
Co-authored-by: Jacob Welander Jensen <64834767+Welander1994@users.noreply.github.com>
Co-authored-by: Henrik <hg@impact.dk>
Co-authored-by: Sebastiaan Janssen <sebastiaan@umbraco.com>
Co-authored-by: Nhu Dinh <150406148+nhudinh0309@users.noreply.github.com>
Co-authored-by: Andreas Zerbst <73799582+andr317c@users.noreply.github.com>
2025-04-09 09:58:01 +02:00
x = > x . CreateDate ) ;
if ( objectTypes . Length = = 0 )
{
sql . Append ( ", COUNT(child.id) AS children" ) ;
}
else
{
// The following is safe from SQL injection as we are dealing with GUIDs, not strings.
// Upper-case is necessary for SQLite, and also works for SQL Server.
var objectTypesForInClause = string . Join ( "','" , objectTypes . Select ( x = > x . ToString ( ) . ToUpperInvariant ( ) ) ) ;
sql . Append ( $", SUM(CASE WHEN child.nodeObjectType IN ('{objectTypesForInClause}') THEN 1 ELSE 0 END) AS children" ) ;
}
2017-12-07 16:45:25 +01:00
2019-10-14 14:34:33 +02:00
if ( isContent | | isMedia | | isMember )
2017-12-07 16:45:25 +01:00
{
sql
2022-06-02 08:18:31 +02:00
. AndSelect < ContentVersionDto > ( x = > Alias ( x . Id , "versionId" ) , x = > x . VersionDate )
2024-02-22 09:11:31 +01:00
. AndSelect < ContentTypeDto > (
x = > x . Alias ,
x = > x . Icon ,
x = > x . Thumbnail ,
x = > x . ListView ,
2024-03-18 10:46:03 +01:00
x = > x . Variations )
. AndSelect < NodeDto > ( "ContentTypeNode" , x = > Alias ( x . UniqueId , "ContentTypeKey" ) ) ;
2017-12-07 16:45:25 +01:00
}
if ( isContent )
{
sql
2022-06-02 08:18:31 +02:00
. AndSelect < DocumentDto > ( x = > x . Published , x = > x . Edited ) ;
2017-12-07 16:45:25 +01:00
}
2019-06-13 23:39:36 +10:00
if ( isMedia )
{
sql
2022-06-02 08:18:31 +02:00
. AndSelect < MediaVersionDto > ( x = > Alias ( x . Path , "MediaPath" ) ) ;
2018-04-20 13:12:55 +10:00
}
2017-12-07 16:45:25 +01:00
}
2022-06-02 08:18:31 +02:00
sql
. From < NodeDto > ( ) ;
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
if ( isContent | | isMedia | | isMember )
2017-12-07 16:45:25 +01:00
{
2022-06-02 08:18:31 +02:00
sql
. LeftJoin < ContentVersionDto > ( )
. On < NodeDto , ContentVersionDto > ( ( left , right ) = > left . NodeId = = right . NodeId & & right . Current )
. LeftJoin < ContentDto > ( ) . On < NodeDto , ContentDto > ( ( left , right ) = > left . NodeId = = right . NodeId )
. LeftJoin < ContentTypeDto > ( )
2024-03-18 10:46:03 +01:00
. On < ContentDto , ContentTypeDto > ( ( left , right ) = > left . ContentTypeId = = right . NodeId )
. LeftJoin < NodeDto > ( "ContentTypeNode" )
. On < NodeDto , ContentTypeDto > ( ( left , right ) = > left . NodeId = = right . NodeId , aliasLeft : "ContentTypeNode" ) ;
2017-12-07 16:45:25 +01:00
}
2022-06-02 08:18:31 +02:00
if ( isContent )
2017-12-07 16:45:25 +01:00
{
2022-06-02 08:18:31 +02:00
sql
. LeftJoin < DocumentDto > ( ) . On < NodeDto , DocumentDto > ( ( left , right ) = > left . NodeId = = right . NodeId ) ;
2017-12-07 16:45:25 +01:00
}
2022-06-02 08:18:31 +02:00
if ( isMedia )
2017-12-07 16:45:25 +01:00
{
2022-06-02 08:18:31 +02:00
sql
. LeftJoin < MediaVersionDto > ( )
. On < ContentVersionDto , MediaVersionDto > ( ( left , right ) = > left . Id = = right . Id ) ;
2017-12-07 16:45:25 +01:00
}
2022-06-02 08:18:31 +02:00
//Any LeftJoin statements need to come last
if ( isCount = = false )
2017-12-07 16:45:25 +01:00
{
2022-06-02 08:18:31 +02:00
sql
. LeftJoin < NodeDto > ( "child" )
. On < NodeDto , NodeDto > ( ( left , right ) = > left . NodeId = = right . ParentId , aliasRight : "child" ) ;
2017-12-07 16:45:25 +01:00
}
2022-06-02 08:18:31 +02:00
filter ? . Invoke ( sql ) ;
2018-04-20 13:12:55 +10:00
2022-06-02 08:18:31 +02:00
return sql ;
}
2019-06-13 23:39:36 +10:00
2022-06-02 08:18:31 +02:00
// gets the base SELECT + FROM [+ filter] + WHERE sql
// for a given object type, with a given filter
protected Sql < ISqlContext > GetBaseWhere ( bool isContent , bool isMedia , bool isMember , bool isCount ,
Action < Sql < ISqlContext > > ? filter , Guid [ ] objectTypes )
{
Merge branch 'v15/dev' into v16/dev (#18971)
* Only prevent the unpublish or delete of a related item when configured to do so if it is related as a child, not as a parent (#18886)
* Only prevent the unpubkish or delete of a related item when configured to do so if it is related as a child, not as a parent.
* Fixed incorect parameter names.
* Fixed failing integration tests.
* Use using variable instead to reduce nesting
* Applied suggestions from code review.
* Used simple using statement throughout RelationService for consistency.
* Applied XML header comments consistently.
---------
Co-authored-by: mole <nikolajlauridsen@protonmail.ch>
* Feature: highlight invariant doc with variant blocks is unsupported (#18806)
* mark variant blocks in invariant docs as invalid
* implement RTE Blocks
* Fix pagination for users restricted by start nodes (#18907)
* Fix pagination for users restricted by start nodes
* Default implementation to avoid breakage
* Review comments
* Fix failing test
* Add media start node tests
* Fix issue preventing blueprint derived values from being scaffolded (#18917)
* Fix issue preventing blueprint derived values from being scaffolded.
* fix manipulating frooen array
* compare with variantId as well
---------
Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com>
* ci: add Azure Static Web Apps workflow file
on-behalf-of: @Azure opensource@microsoft.com
* ci: add Azure Static Web Apps workflow file
on-behalf-of: @Azure opensource@microsoft.com
* ci: add Azure Static Web Apps workflow file
on-behalf-of: @Azure opensource@microsoft.com
* Remove admin permission on user configuration, allowing users with user section access only to manaage users and groups. (#18848)
* Tiptap RTE: Style Menu extension kind (#18918)
* Adds 'styleMenu' Tiptap toolbar extension kind
* Adds icons for `<h4>` and `<p>` tags
* Adds commands to HTML Global Attributes extension
for setting the `class` and `id` attributes.
* Renamed "default-tiptap-toolbar-element.api.ts" file
The "element" part was confusing.
* Toolbar Menu: uses correct `item` value
* Cascading Menu: adds localization for the label
* Adds `label` attribute to UUI components
for accessibility.
* Toolbar Menu: uses correct `appearance` value
* Removed unrequired `api` from Style Select
* Destructs the `item.data` object
* Ensure has children reflects only items with folder children when folders only are queried. (#18790)
* Ensure has children reflects only items with folder children when folders only are queried.
* Added supression for change to integration test public code.
---------
Co-authored-by: Migaroez <geusens@gmail.com>
* Only apply validation on content update to variant cultures where the editor has permission for the culture (#18778)
* Only apply validation on content update to variant cultures where the editor has permission for the culture.
* Remove inadvertent comment updates.
* Fixed failing integration test.
* Adds ancestor ID details on document tree and collection responses (#18909)
* Populate ancestor keys on document tree response items.
* Populate ancestor keys on document collection response items.
* Update OpenApi.json
* Use array of objects rather than Ids for the ancestor collection.
* Update OpenApi.json.
* Move publish with descendants to a background task with polling (#18497)
* Use background queue for database cache rebuild and track rebuilding status.
* Updated OpenApi.json and client-side types.
* Updated client to poll for completion of database rebuild.
* Move IBackgroundTaskQueue to core and prepare publish branch to run as background task.
* Endpoints for retrieval of status and result from branch publish operations.
* Poll and retrieve result for publish with descendants.
* Handled issues from testing.
* Rework to single controller for status and result.
* Updated client side sdk.
* OpenApi post dev merge gen
---------
Co-authored-by: Migaroez <geusens@gmail.com>
* Clear roots before rebuilding navigation dictionary (#18766)
* Clear roots before rebuilding navigation dictionary.
* Added tests to verify fix.
* Correct test implementation.
* Convert integration tests with method overloads into test cases.
* Integration test compatibility supressions.
* Fixes save of empty, invariant block list on variant content. (#18932)
* remove unnecessary code (#18927)
* V15/bugfix/fix route issue from 18859 (#18931)
* unique check
* unique for workspace empty path
* more unique routes
* Bump vite from 6.2.3 to 6.2.4 in /src/Umbraco.Web.UI.Client
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.2.3 to 6.2.4.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v6.2.4/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.2.4/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-version: 6.2.4
dependency-type: direct:development
...
Signed-off-by: dependabot[bot] <support@github.com>
* removes autogenerated workflows
* make getHasUnpersistedChanges public (#18929)
* Added management API endpoint, service and repository for retrieval of references from the recycle bin (#18882)
* Added management API endpoint, service and repository for retrieval of references from the recycle bin.
* Update src/Umbraco.Cms.Api.Management/Controllers/Document/RecycleBin/ReferencedByDocumentRecycleBinController.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Removed unused code.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Updated management API endpoint and model for data type references to align with that used for documents, media etc. (#18905)
* Updated management API endpoint and model for data type references to align with that used for documents, media etc.
* Refactoring.
* Update src/Umbraco.Core/Constants-ReferenceTypes.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Fixed typos.
* Added id to tracked reference content type response.
* Updated OpenApi.json.
* Added missing updates.
* Renamed model and constants from code review feedback.
* Fix typo
* Fix multiple enumeration
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: mole <nikolajlauridsen@protonmail.ch>
* Skip lock tests
* Look-up redirect in content finder for multi-lingual sites using path and legacy route prefixed with the integer ID of the node with domains defined (#18763)
* Look-up redirect in content finder for multi-lingual sites using path and legacy route prefixed with the integer ID of the node with domains defined.
* Added tests to verify functionality.
* Added reference to previous PR.
* Referenced second PR.
* Assemble URLs for all cultures, not just the default.
* Revert previous update.
* Display an original URL if we have one.
* Bump vite from 6.2.4 to 6.2.5 in /src/Umbraco.Web.UI.Client
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.2.4 to 6.2.5.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v6.2.5/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.2.5/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-version: 6.2.5
dependency-type: direct:development
...
Signed-off-by: dependabot[bot] <support@github.com>
* Add raw value validation to multiple text strings property editor (#18936)
* Add raw value validation to multiple text strings property editor
* Added additional assert on unit test and comment on validation logic.
* Don't remove items to obtain a valid value
---------
Co-authored-by: Andy Butland <abutland73@gmail.com>
* Integration tests for content publishing with ancestor unpublished (#18941)
* Resolved warnings in test class.
* Refactor regions into partial classes.
* Aligned test names.
* Variable name refactoring.
* Added tests for unpublished paths.
* Adjust tests to verify current behaviour.
* Cleaned up project file.
* fix circular icon import (#18952)
* remove segment toggle for elements (#18949)
* Fix modal route registration circular import (#18953)
* fix modal route registration circular import
* Update modal-route-registration.controller.ts
* V15/fix/18595 (#18925)
* fix for #18595
* updates the en.ts
* Avoid unneeded Dictionary operations (#18890)
* Avoid some heap allocations
* Remove unneeded double seek
* Avoid allocating new empty arrays, reuse existing empty array
* Avoid allocating strings for parsing comma separated int values (#18199)
* Data type References UI: Workspace + Delete (#18914)
* Updated management API endpoint and model for data type references to align with that used for documents, media etc.
* Refactoring.
* Update src/Umbraco.Core/Constants-ReferenceTypes.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Fixed typos.
* generate server models
* add extension slot
* register data type reference info app
* add reference data mappers
* Added id to tracked reference content type response.
* Updated OpenApi.json.
* Added missing updates.
* generate new models
* update models
* register ref item
* remove debugger
* render types
* register member type property type ref
* register media type property type ref
* Renamed model and constants from code review feedback.
* register reference workspace info app kind
* use kind for document references
* use kind for media references
* use kind for member references
* use deleteWithRelation kind when deleting data types
* fix manifest types
* fix types
* Update types.gen.ts
* update code to fit new server models
---------
Co-authored-by: Andy Butland <abutland73@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Feature: discard changes for block workspace (#18930)
* make getHasUnpersistedChanges public
* Discard changes impl for Block Workspace
* fix 18367 (#18956)
* Merge commit from fork
* Prevent path traveral vulnerability with upload of temporary files.
* Used BadRequest instead of NotFound for invalid file name response.
* V15 QA Fixing the failing media acceptance tests (#18881)
* Fixed the function name due to test helper changes
* Updated assertion steps due to UI changes
* Added more waits
* Bumped version
* Increase timeout
* Reverted
---------
Co-authored-by: Andreas Zerbst <73799582+andr317c@users.noreply.github.com>
* V15 QA added clipboard test for not being able to copy to root when block is not allowed at root (#18937)
* Added clipboard test
* Bumped version
* Updated to use the name
* Run all tests on the pipeline
* Reverted command
* build: adjusts circular ref number to 4
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Andy Butland <abutland73@gmail.com>
Co-authored-by: mole <nikolajlauridsen@protonmail.ch>
Co-authored-by: Niels Lyngsø <nsl@umbraco.dk>
Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com>
Co-authored-by: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com>
Co-authored-by: Lee Kelleher <leekelleher@users.noreply.github.com>
Co-authored-by: Migaroez <geusens@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
Co-authored-by: Mads Rasmussen <madsr@hey.com>
Co-authored-by: Jacob Welander Jensen <64834767+Welander1994@users.noreply.github.com>
Co-authored-by: Henrik <hg@impact.dk>
Co-authored-by: Sebastiaan Janssen <sebastiaan@umbraco.com>
Co-authored-by: Nhu Dinh <150406148+nhudinh0309@users.noreply.github.com>
Co-authored-by: Andreas Zerbst <73799582+andr317c@users.noreply.github.com>
2025-04-09 09:58:01 +02:00
Sql < ISqlContext > sql = GetBase ( isContent , isMedia , isMember , filter , objectTypes , isCount ) ;
2022-06-02 08:18:31 +02:00
if ( objectTypes . Length > 0 )
{
sql . WhereIn < NodeDto > ( x = > x . NodeObjectType , objectTypes ) ;
}
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
return sql ;
}
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
// gets the base SELECT + FROM + WHERE sql
// for a given node id
protected Sql < ISqlContext > GetBaseWhere ( bool isContent , bool isMedia , bool isMember , bool isCount , int id )
{
Sql < ISqlContext > sql = GetBase ( isContent , isMedia , isMember , null , isCount )
. Where < NodeDto > ( x = > x . NodeId = = id ) ;
return AddGroupBy ( isContent , isMedia , isMember , sql , true ) ;
}
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
// gets the base SELECT + FROM + WHERE sql
// for a given unique id
protected Sql < ISqlContext > GetBaseWhere ( bool isContent , bool isMedia , bool isMember , bool isCount , Guid uniqueId )
{
Sql < ISqlContext > sql = GetBase ( isContent , isMedia , isMember , null , isCount )
. Where < NodeDto > ( x = > x . UniqueId = = uniqueId ) ;
return AddGroupBy ( isContent , isMedia , isMember , sql , true ) ;
}
// gets the base SELECT + FROM + WHERE sql
// for a given object type and node id
protected Sql < ISqlContext > GetBaseWhere ( bool isContent , bool isMedia , bool isMember , bool isCount , Guid objectType ,
int nodeId ) = >
GetBase ( isContent , isMedia , isMember , null , isCount )
. Where < NodeDto > ( x = > x . NodeId = = nodeId & & x . NodeObjectType = = objectType ) ;
// gets the base SELECT + FROM + WHERE sql
// for a given object type and unique id
protected Sql < ISqlContext > GetBaseWhere ( bool isContent , bool isMedia , bool isMember , bool isCount , Guid objectType ,
Guid uniqueId ) = >
GetBase ( isContent , isMedia , isMember , null , isCount )
. Where < NodeDto > ( x = > x . UniqueId = = uniqueId & & x . NodeObjectType = = objectType ) ;
// gets the GROUP BY / ORDER BY sql
// required in order to count children
protected Sql < ISqlContext > AddGroupBy ( bool isContent , bool isMedia , bool isMember , Sql < ISqlContext > sql ,
bool defaultSort )
{
sql
. GroupBy < NodeDto > ( x = > x . NodeId , x = > x . Trashed , x = > x . ParentId , x = > x . UserId , x = > x . Level , x = > x . Path )
. AndBy < NodeDto > ( x = > x . SortOrder , x = > x . UniqueId , x = > x . Text , x = > x . NodeObjectType , x = > x . CreateDate ) ;
if ( isContent )
{
sql
. AndBy < DocumentDto > ( x = > x . Published , x = > x . Edited ) ;
2017-12-07 16:45:25 +01:00
}
2022-06-02 08:18:31 +02:00
if ( isMedia )
2018-12-21 13:15:46 +11:00
{
2022-06-02 08:18:31 +02:00
sql
. AndBy < MediaVersionDto > ( x = > Alias ( x . Path , "MediaPath" ) ) ;
}
2018-12-21 13:15:46 +11:00
2019-11-11 12:05:26 +00:00
2022-06-02 08:18:31 +02:00
if ( isContent | | isMedia | | isMember )
{
sql
. AndBy < ContentVersionDto > ( x = > x . Id , x = > x . VersionDate )
2024-02-22 09:11:31 +01:00
. AndBy < ContentTypeDto > (
x = > x . Alias ,
x = > x . Icon ,
x = > x . Thumbnail ,
x = > x . ListView ,
2024-03-18 10:46:03 +01:00
x = > x . Variations )
. AndBy < NodeDto > ( "ContentTypeNode" , x = > x . UniqueId ) ;
2022-06-02 08:18:31 +02:00
}
2018-12-21 13:15:46 +11:00
2022-06-02 08:18:31 +02:00
if ( defaultSort )
{
sql . OrderBy < NodeDto > ( x = > x . SortOrder ) ;
2018-12-21 13:15:46 +11:00
}
2022-06-02 08:18:31 +02:00
return sql ;
}
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
private void ApplyOrdering ( ref Sql < ISqlContext > sql , Ordering ordering )
{
if ( sql = = null )
{
throw new ArgumentNullException ( nameof ( sql ) ) ;
}
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
if ( ordering = = null )
2019-11-05 15:05:51 +11:00
{
2022-06-02 08:18:31 +02:00
throw new ArgumentNullException ( nameof ( ordering ) ) ;
2019-11-05 15:05:51 +11:00
}
2022-06-02 08:18:31 +02:00
// TODO: although the default ordering string works for name, it wont work for others without a table or an alias of some sort
// As more things are attempted to be sorted we'll prob have to add more expressions here
string orderBy ;
2018-09-21 15:49:37 +10:00
2024-04-04 11:27:13 +02:00
Ordering ? runner = ordering ;
2017-12-07 16:45:25 +01:00
2024-04-04 11:27:13 +02:00
do
2019-06-13 23:39:36 +10:00
{
2024-04-04 11:27:13 +02:00
switch ( runner . OrderBy ? . ToUpperInvariant ( ) )
{
case "NODEOBJECTTYPE" :
orderBy = $"UPPER({SqlSyntax.GetQuotedColumn(NodeDto.TableName, " nodeObjectType ")})" ;
break ;
case "PATH" :
orderBy = SqlSyntax . GetQuotedColumn ( NodeDto . TableName , "path" ) ;
break ;
default :
orderBy = runner . OrderBy ? ? string . Empty ;
break ;
}
if ( runner . Direction = = Direction . Ascending )
{
sql . OrderBy ( orderBy ) ;
}
else
{
sql . OrderByDescending ( orderBy ) ;
}
runner = runner . Next ;
2019-10-14 14:34:33 +02:00
}
2024-04-04 11:27:13 +02:00
while ( runner is not null ) ;
2022-06-02 08:18:31 +02:00
}
2019-10-14 14:34:33 +02:00
2022-06-02 08:18:31 +02:00
#endregion
2018-09-25 10:55:33 +02:00
2022-06-02 08:18:31 +02:00
#region Classes
2018-09-21 15:49:37 +10:00
2022-06-02 08:18:31 +02:00
/// <summary>
/// The DTO used to fetch results for a generic content item which could be either a document, media or a member
/// </summary>
private class GenericContentEntityDto : DocumentEntityDto
{
public string? MediaPath { get ; set ; }
}
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
/// <summary>
/// The DTO used to fetch results for a document item with its variation info
/// </summary>
private class DocumentEntityDto : BaseDto
{
public ContentVariation Variations { get ; set ; }
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
public bool Published { get ; set ; }
public bool Edited { get ; set ; }
}
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
/// <summary>
/// The DTO used to fetch results for a media item with its media path info
/// </summary>
private class MediaEntityDto : BaseDto
{
public string? MediaPath { get ; set ; }
}
/// <summary>
/// The DTO used to fetch results for a member item
/// </summary>
private class MemberEntityDto : BaseDto
{
}
public class VariantInfoDto
{
public int NodeId { get ; set ; }
public string IsoCode { get ; set ; } = null ! ;
public string Name { get ; set ; } = null ! ;
public bool DocumentPublished { get ; set ; }
public bool DocumentEdited { get ; set ; }
public bool CultureAvailable { get ; set ; }
public bool CulturePublished { get ; set ; }
public bool CultureEdited { get ; set ; }
}
// ReSharper disable once ClassNeverInstantiated.Local
/// <summary>
/// the DTO corresponding to fields selected by GetBase
/// </summary>
private class BaseDto
{
// ReSharper disable UnusedAutoPropertyAccessor.Local
// ReSharper disable UnusedMember.Local
public int NodeId { get ; set ; }
public bool Trashed { get ; set ; }
public int ParentId { get ; set ; }
public int? UserId { get ; set ; }
public int Level { get ; set ; }
public string Path { get ; } = null ! ;
public int SortOrder { get ; set ; }
public Guid UniqueId { get ; set ; }
public string? Text { get ; set ; }
public Guid NodeObjectType { get ; set ; }
public DateTime CreateDate { get ; set ; }
public DateTime VersionDate { get ; set ; }
public int Children { get ; set ; }
public int VersionId { get ; set ; }
public string Alias { get ; } = null ! ;
public string? Icon { get ; set ; }
public string? Thumbnail { get ; set ; }
public bool IsContainer { get ; set ; }
2024-03-18 10:46:03 +01:00
public Guid ContentTypeKey { get ; set ; }
public Guid ? ListView { get ; set ; }
2022-06-02 08:18:31 +02:00
// ReSharper restore UnusedAutoPropertyAccessor.Local
// ReSharper restore UnusedMember.Local
}
#endregion
#region Factory
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
private EntitySlim BuildEntity ( BaseDto dto )
{
2022-10-05 12:14:43 +02:00
if ( dto . NodeObjectType = = Constants . ObjectTypes . Document
| | dto . NodeObjectType = = Constants . ObjectTypes . DocumentBlueprint )
2022-06-02 08:18:31 +02:00
{
return BuildDocumentEntity ( dto ) ;
2018-01-12 10:48:36 +01:00
}
2022-06-02 08:18:31 +02:00
if ( dto . NodeObjectType = = Constants . ObjectTypes . Media )
2018-01-12 10:48:36 +01:00
{
2022-06-02 08:18:31 +02:00
return BuildMediaEntity ( dto ) ;
2018-01-12 10:48:36 +01:00
}
2022-06-02 08:18:31 +02:00
if ( dto . NodeObjectType = = Constants . ObjectTypes . Member )
2018-01-12 10:48:36 +01:00
{
2022-06-02 08:18:31 +02:00
return BuildMemberEntity ( dto ) ;
}
2019-06-13 23:39:36 +10:00
2022-06-02 08:18:31 +02:00
// EntitySlim does not track changes
var entity = new EntitySlim ( ) ;
BuildEntity ( entity , dto ) ;
return entity ;
}
2019-06-13 23:39:36 +10:00
2022-06-02 08:18:31 +02:00
private static void BuildEntity ( EntitySlim entity , BaseDto dto )
{
entity . Trashed = dto . Trashed ;
entity . CreateDate = dto . CreateDate ;
entity . UpdateDate = dto . VersionDate ;
entity . CreatorId = dto . UserId ? ? Constants . Security . UnknownUserId ;
entity . Id = dto . NodeId ;
entity . Key = dto . UniqueId ;
entity . Level = dto . Level ;
entity . Name = dto . Text ;
entity . NodeObjectType = dto . NodeObjectType ;
entity . ParentId = dto . ParentId ;
entity . Path = dto . Path ;
entity . SortOrder = dto . SortOrder ;
entity . HasChildren = dto . Children > 0 ;
entity . IsContainer = dto . IsContainer ;
}
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
private static void BuildContentEntity ( ContentEntitySlim entity , BaseDto dto )
{
BuildEntity ( entity , dto ) ;
entity . ContentTypeAlias = dto . Alias ;
entity . ContentTypeIcon = dto . Icon ;
entity . ContentTypeThumbnail = dto . Thumbnail ;
2024-03-18 10:46:03 +01:00
entity . ContentTypeKey = dto . ContentTypeKey ;
entity . ListViewKey = dto . ListView ;
2022-06-02 08:18:31 +02:00
}
2017-12-07 16:45:25 +01:00
2022-06-02 08:18:31 +02:00
private MediaEntitySlim BuildMediaEntity ( BaseDto dto )
{
// EntitySlim does not track changes
var entity = new MediaEntitySlim ( ) ;
BuildContentEntity ( entity , dto ) ;
2018-09-25 10:55:33 +02:00
2022-06-02 08:18:31 +02:00
// fill in the media info
if ( dto is MediaEntityDto mediaEntityDto )
{
entity . MediaPath = mediaEntityDto . MediaPath ;
2018-04-20 13:12:55 +10:00
}
2022-06-02 08:18:31 +02:00
else if ( dto is GenericContentEntityDto genericContentEntityDto )
2019-10-14 14:34:33 +02:00
{
2022-06-02 08:18:31 +02:00
entity . MediaPath = genericContentEntityDto . MediaPath ;
}
return entity ;
}
2019-10-14 14:34:33 +02:00
2022-06-02 08:18:31 +02:00
private DocumentEntitySlim BuildDocumentEntity ( BaseDto dto )
{
// EntitySlim does not track changes
var entity = new DocumentEntitySlim ( ) ;
BuildContentEntity ( entity , dto ) ;
2019-10-14 14:34:33 +02:00
2022-06-02 08:18:31 +02:00
if ( dto is DocumentEntityDto contentDto )
{
// fill in the invariant info
entity . Edited = contentDto . Edited ;
entity . Published = contentDto . Published ;
entity . Variations = contentDto . Variations ;
2019-10-14 14:34:33 +02:00
}
2022-06-02 08:18:31 +02:00
return entity ;
2017-12-07 16:45:25 +01:00
}
2022-06-02 08:18:31 +02:00
private MemberEntitySlim BuildMemberEntity ( BaseDto dto )
{
// EntitySlim does not track changes
var entity = new MemberEntitySlim ( ) ;
BuildEntity ( entity , dto ) ;
entity . ContentTypeAlias = dto . Alias ;
entity . ContentTypeIcon = dto . Icon ;
entity . ContentTypeThumbnail = dto . Thumbnail ;
return entity ;
}
#endregion
2017-12-07 16:45:25 +01:00
}