Gets all tests passing and updates content/media svc/repos with filters
The content/media services & repos are now consistent with their filter, filterargs parameters and tests have been updated to support this, we can now pass in more robust filters to these methods which is required by Examine to get published content from the db.
This commit is contained in:
@@ -89,7 +89,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
/// <param name="filterArgs"></param>
|
||||
/// <returns>An Enumerable list of <see cref="IContent"/> objects</returns>
|
||||
IEnumerable<IContent> GetPagedResultsByQuery(IQuery<IContent> query, long pageIndex, int pageSize, out long totalRecords,
|
||||
string orderBy, Direction orderDirection, bool orderBySystemField, string filter, object[] filterArgs);
|
||||
string orderBy, Direction orderDirection, bool orderBySystemField, string filter = null, object[] filterArgs = null);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the persisted content's preview XML structure
|
||||
|
||||
@@ -35,9 +35,10 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
/// <param name="orderBy">Field to order by</param>
|
||||
/// <param name="orderDirection">Direction to order by</param>
|
||||
/// <param name="orderBySystemField">Flag to indicate when ordering by system field</param>
|
||||
/// <param name="filter">Search text filter</param>
|
||||
/// <param name="filter"></param>
|
||||
/// <param name="filterArgs"></param>
|
||||
/// <returns>An Enumerable list of <see cref="IMedia"/> objects</returns>
|
||||
IEnumerable<IMedia> GetPagedResultsByQuery(IQuery<IMedia> query, long pageIndex, int pageSize, out long totalRecords,
|
||||
string orderBy, Direction orderDirection, bool orderBySystemField, string filter = "");
|
||||
string orderBy, Direction orderDirection, bool orderBySystemField, string filter = null, object[] filterArgs = null);
|
||||
}
|
||||
}
|
||||
@@ -489,15 +489,18 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
/// <param name="orderBy">Field to order by</param>
|
||||
/// <param name="orderDirection">Direction to order by</param>
|
||||
/// <param name="orderBySystemField">Flag to indicate when ordering by system field</param>
|
||||
/// <param name="filter">Search text filter</param>
|
||||
/// <param name="filter"></param>
|
||||
/// <param name="filterArgs"></param>
|
||||
/// <returns>An Enumerable list of <see cref="IMedia"/> objects</returns>
|
||||
public IEnumerable<IMedia> GetPagedResultsByQuery(IQuery<IMedia> query, long pageIndex, int pageSize, out long totalRecords,
|
||||
string orderBy, Direction orderDirection, bool orderBySystemField, string filter = "")
|
||||
string orderBy, Direction orderDirection, bool orderBySystemField, string filter = null, object[] filterArgs = null)
|
||||
{
|
||||
var filterSql = filter.IsNullOrWhiteSpace()
|
||||
? null
|
||||
: Sql().Append("AND (umbracoNode." + SqlSyntax.GetQuotedColumnName("text") + " LIKE @0)", "%" + filter + "%");
|
||||
|
||||
Sql<SqlContext> filterSql = null;
|
||||
if (filter.IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
filterSql = Sql().Append($"AND ({filter})", filterArgs);
|
||||
}
|
||||
|
||||
return GetPagedResultsByQuery<ContentVersionDto>(query, pageIndex, pageSize, out totalRecords,
|
||||
MapQueryDtos, orderBy, orderDirection, orderBySystemField,
|
||||
filterSql);
|
||||
|
||||
@@ -506,7 +506,7 @@ namespace Umbraco.Core.Services
|
||||
if (filter.IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
//add the default text filter
|
||||
f = $"cmsDocument.{RepositoryFactory.SqlSyntax.GetQuotedColumnName("text")}=@0";
|
||||
f = $"cmsDocument.{RepositoryFactory.SqlSyntax.GetQuotedColumnName("text")} LIKE @0";
|
||||
fa = new object[] { $"%{filter}%" };
|
||||
}
|
||||
return GetPagedChildren(id, pageIndex, pageSize, out totalChildren, orderBy, orderDirection, true, f, fa);
|
||||
@@ -564,7 +564,7 @@ namespace Umbraco.Core.Services
|
||||
if (filter.IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
//add the default text filter
|
||||
f = $"cmsDocument.{RepositoryFactory.SqlSyntax.GetQuotedColumnName("text")}=@0";
|
||||
f = $"cmsDocument.{RepositoryFactory.SqlSyntax.GetQuotedColumnName("text")} LIKE @0";
|
||||
fa = new object[] { $"%{filter}%" };
|
||||
}
|
||||
return GetPagedDescendants(id, pageIndex, pageSize, out totalChildren, orderBy, orderDirection, true, f, fa);
|
||||
|
||||
@@ -142,10 +142,11 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="orderBy">Field to order by</param>
|
||||
/// <param name="orderDirection">Direction to order by</param>
|
||||
/// <param name="orderBySystemField">Flag to indicate when ordering by system field</param>
|
||||
/// <param name="filter">Search text filter</param>
|
||||
/// <param name="filter"></param>
|
||||
/// <param name="filterArgs"></param>
|
||||
/// <returns>An Enumerable list of <see cref="IContent"/> objects</returns>
|
||||
IEnumerable<IMedia> GetPagedChildren(int id, long pageIndex, int pageSize, out long totalRecords,
|
||||
string orderBy, Direction orderDirection, bool orderBySystemField, string filter);
|
||||
string orderBy, Direction orderDirection, bool orderBySystemField, string filter, object[] filterArgs);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of <see cref="IMedia"/> objects by Parent Id
|
||||
@@ -171,10 +172,11 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="orderBy">Field to order by</param>
|
||||
/// <param name="orderDirection">Direction to order by</param>
|
||||
/// <param name="orderBySystemField">Flag to indicate when ordering by system field</param>
|
||||
/// <param name="filter">Search text filter</param>
|
||||
/// <param name="filter"></param>
|
||||
/// <param name="filterArgs"></param>
|
||||
/// <returns>An Enumerable list of <see cref="IContent"/> objects</returns>
|
||||
IEnumerable<IMedia> GetPagedDescendants(int id, long pageIndex, int pageSize, out long totalRecords,
|
||||
string orderBy, Direction orderDirection, bool orderBySystemField, string filter);
|
||||
string orderBy, Direction orderDirection, bool orderBySystemField, string filter, object[] filterArgs);
|
||||
|
||||
/// <summary>
|
||||
/// Gets descendants of a <see cref="IMedia"/> object by its Id
|
||||
|
||||
@@ -409,7 +409,15 @@ namespace Umbraco.Core.Services
|
||||
public IEnumerable<IMedia> GetPagedChildren(int id, long pageIndex, int pageSize, out long totalChildren,
|
||||
string orderBy, Direction orderDirection, string filter = "")
|
||||
{
|
||||
return GetPagedChildren(id, pageIndex, pageSize, out totalChildren, orderBy, orderDirection, true, filter);
|
||||
string f = filter;
|
||||
object[] fa = null;
|
||||
if (filter.IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
//add the default text filter
|
||||
f = $"umbracoNode.{RepositoryFactory.SqlSyntax.GetQuotedColumnName("text")} LIKE @0";
|
||||
fa = new object[] { $"%{filter}%" };
|
||||
}
|
||||
return GetPagedChildren(id, pageIndex, pageSize, out totalChildren, orderBy, orderDirection, true, f, fa);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -422,10 +430,11 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="orderBy">Field to order by</param>
|
||||
/// <param name="orderDirection">Direction to order by</param>
|
||||
/// <param name="orderBySystemField">Flag to indicate when ordering by system field</param>
|
||||
/// <param name="filter">Search text filter</param>
|
||||
/// <param name="filter"></param>
|
||||
/// <param name="filterArgs"></param>
|
||||
/// <returns>An Enumerable list of <see cref="IContent"/> objects</returns>
|
||||
public IEnumerable<IMedia> GetPagedChildren(int id, long pageIndex, int pageSize, out long totalChildren,
|
||||
string orderBy, Direction orderDirection, bool orderBySystemField, string filter)
|
||||
string orderBy, Direction orderDirection, bool orderBySystemField, string filter, object[] filterArgs)
|
||||
{
|
||||
Mandate.ParameterCondition(pageIndex >= 0, "pageIndex");
|
||||
Mandate.ParameterCondition(pageSize > 0, "pageSize");
|
||||
@@ -453,7 +462,15 @@ namespace Umbraco.Core.Services
|
||||
/// <returns>An Enumerable list of <see cref="IContent"/> objects</returns>
|
||||
public IEnumerable<IMedia> GetPagedDescendants(int id, long pageIndex, int pageSize, out long totalChildren, string orderBy = "Path", Direction orderDirection = Direction.Ascending, string filter = "")
|
||||
{
|
||||
return GetPagedDescendants(id, pageIndex, pageSize, out totalChildren, orderBy, orderDirection, true, filter);
|
||||
string f = filter;
|
||||
object[] fa = null;
|
||||
if (filter.IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
//add the default text filter
|
||||
f = $"umbracoNode.{RepositoryFactory.SqlSyntax.GetQuotedColumnName("text")} LIKE @0";
|
||||
fa = new object[] { $"%{filter}%" };
|
||||
}
|
||||
return GetPagedDescendants(id, pageIndex, pageSize, out totalChildren, orderBy, orderDirection, true, f, fa);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -466,9 +483,10 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="orderBy">Field to order by</param>
|
||||
/// <param name="orderDirection">Direction to order by</param>
|
||||
/// <param name="orderBySystemField">Flag to indicate when ordering by system field</param>
|
||||
/// <param name="filter">Search text filter</param>
|
||||
/// <param name="filter"></param>
|
||||
/// <param name="filterArgs"></param>
|
||||
/// <returns>An Enumerable list of <see cref="IContent"/> objects</returns>
|
||||
public IEnumerable<IMedia> GetPagedDescendants(int id, long pageIndex, int pageSize, out long totalChildren, string orderBy, Direction orderDirection, bool orderBySystemField, string filter)
|
||||
public IEnumerable<IMedia> GetPagedDescendants(int id, long pageIndex, int pageSize, out long totalChildren, string orderBy, Direction orderDirection, bool orderBySystemField, string filter, object[] filterArgs)
|
||||
{
|
||||
Mandate.ParameterCondition(pageIndex >= 0, "pageIndex");
|
||||
Mandate.ParameterCondition(pageSize > 0, "pageSize");
|
||||
|
||||
Reference in New Issue
Block a user