diff --git a/src/WebPages/ContentStore/ContentStoreApi.cs b/src/WebPages/ContentStore/ContentStoreApi.cs index f1e38ae..b2769b5 100644 --- a/src/WebPages/ContentStore/ContentStoreApi.cs +++ b/src/WebPages/ContentStore/ContentStoreApi.cs @@ -12,6 +12,8 @@ using SenseNet.ContentRepository.Storage.Schema; using SenseNet.ApplicationModel; using SenseNet.Configuration; +using SenseNet.ContentRepository.Search; +using SenseNet.Search.Querying; namespace SenseNet.Portal.ContentStore { @@ -129,7 +131,7 @@ private static object[] GetChildrenByNodeInternal(Node node, bool includeLeafNod // add content type filter if needed if (!string.IsNullOrEmpty(filter)) - content.ChildrenDefinition.ContentQuery = ContentQuery.AddClause(content.ChildrenDefinition.ContentQuery, filter, ChainOperator.And); + content.ChildrenDefinition.ContentQuery = ContentQuery.AddClause(content.ChildrenDefinition.ContentQuery, filter, LogicalOperator.And); // in case of SmartFolder: do not override the settings given on the content if (!(folderParent is SmartFolder)) @@ -143,7 +145,7 @@ private static object[] GetChildrenByNodeInternal(Node node, bool includeLeafNod } [ODataFunction] - public static bool IsLuceneQuery(Content content, string rnd) + public static bool IsLuceneQuery(Content content, string rnd) //UNDONE: Do not use "Lucene" { AssertPermission(PlaceholderPath); @@ -152,7 +154,7 @@ public static bool IsLuceneQuery(Content content, string rnd) private static bool IsLuceneQueryInternal() { - return StorageContext.Search.SearchEngine.GetType() == typeof(LuceneSearchEngine); + return SearchManager.IsOuterEngineEnabled; } [ODataFunction] @@ -164,10 +166,7 @@ public static object[] Search(Content content, string searchStr, string searchRo { return SearchLucene(searchStr, searchRoot, contentTypes, simpleContent); } - else - { - return SearchNodeQuery(searchStr, searchRoot, contentTypes, simpleContent); - } + throw new SnNotSupportedException("ContemtQuery is disabled."); } private static object[] SearchLucene(string searchStr, string searchRoot, string contentTypes, bool simpleContent = false) @@ -175,7 +174,7 @@ private static object[] SearchLucene(string searchStr, string searchRoot, string var queryStr = CreateLuceneQueryString(searchStr, searchRoot, contentTypes); var query = ContentQuery.CreateQuery(queryStr, new QuerySettings { - Sort = new List { new SortInfo { FieldName = "DisplayName" } }, + Sort = new List { new SortInfo("DisplayName") }, EnableAutofilters = FilterStatus.Disabled, EnableLifespanFilter = FilterStatus.Disabled }); @@ -194,76 +193,76 @@ private static object[] SearchLucene(string searchStr, string searchRoot, string } } - private static object[] SearchNodeQuery(string searchStr, string searchRoot, string contentTypes, bool simpleContent = false) - { - if (!string.IsNullOrEmpty(searchStr)) - { - // simple nodequery - var query = new NodeQuery(); - query.Add(new SearchExpression(searchStr)); - var nodes = query.Execute().Nodes; - - // filter with path - if (!string.IsNullOrEmpty(searchRoot)) - nodes = nodes.Where(n => n.Path.StartsWith(searchRoot)); - - // filter with contenttypes - if (!string.IsNullOrEmpty(contentTypes)) - { - var contentTypesArr = GetContentTypes(contentTypes); - nodes = nodes.Where(n => contentTypesArr.Contains(n.NodeType.Name)); - } - - if (simpleContent) - { - var contents = nodes.Where(n => n != null).Select(n => new cs.SimpleServiceContent(n)); - return contents.ToArray(); - } - else - { - var contents = nodes.Where(n => n != null).Select(n => new cs.Content(n, true, false, false, false, 0, 0)); - return contents.ToArray(); - } - } - else - { - if (string.IsNullOrEmpty(searchRoot) && string.IsNullOrEmpty(contentTypes)) - return null; - - var query = new NodeQuery(); - var andExpression = new ExpressionList(ChainOperator.And); - query.Add(andExpression); - - // filter with path - if (!string.IsNullOrEmpty(searchRoot)) - andExpression.Add(new StringExpression(StringAttribute.Path, StringOperator.StartsWith, searchRoot)); - - // filter with contenttypes - if (!string.IsNullOrEmpty(contentTypes)) - { - var contentTypesArr = GetContentTypes(contentTypes); - var orExpression = new ExpressionList(ChainOperator.Or); - foreach (var contentType in contentTypesArr) - { - orExpression.Add(new TypeExpression(NodeType.GetByName(contentType), true)); - } - andExpression.Add(orExpression); - } - - var nodes = query.Execute().Nodes; - - if (simpleContent) - { - var contents = nodes.Select(n => new cs.SimpleServiceContent(n)); - return contents.ToArray(); - } - else - { - var contents = nodes.Select(n => new cs.Content(n, true, false, false, false, 0, 0)); - return contents.ToArray(); - } - } - } + /**///private static object[] SearchNodeQuery(string searchStr, string searchRoot, string contentTypes, bool simpleContent = false) + //{ + // if (!string.IsNullOrEmpty(searchStr)) + // { + // // simple nodequery + // var query = new NodeQuery(); + // query.Add(new SearchExpression(searchStr)); + // var nodes = query.Execute().Nodes; + + // // filter with path + // if (!string.IsNullOrEmpty(searchRoot)) + // nodes = nodes.Where(n => n.Path.StartsWith(searchRoot)); + + // // filter with contenttypes + // if (!string.IsNullOrEmpty(contentTypes)) + // { + // var contentTypesArr = GetContentTypes(contentTypes); + // nodes = nodes.Where(n => contentTypesArr.Contains(n.NodeType.Name)); + // } + + // if (simpleContent) + // { + // var contents = nodes.Where(n => n != null).Select(n => new cs.SimpleServiceContent(n)); + // return contents.ToArray(); + // } + // else + // { + // var contents = nodes.Where(n => n != null).Select(n => new cs.Content(n, true, false, false, false, 0, 0)); + // return contents.ToArray(); + // } + // } + // else + // { + // if (string.IsNullOrEmpty(searchRoot) && string.IsNullOrEmpty(contentTypes)) + // return null; + + // var query = new NodeQuery(); + // var andExpression = new ExpressionList(ChainOperator.And); + // query.Add(andExpression); + + // // filter with path + // if (!string.IsNullOrEmpty(searchRoot)) + // andExpression.Add(new StringExpression(StringAttribute.Path, StringOperator.StartsWith, searchRoot)); + + // // filter with contenttypes + // if (!string.IsNullOrEmpty(contentTypes)) + // { + // var contentTypesArr = GetContentTypes(contentTypes); + // var orExpression = new ExpressionList(ChainOperator.Or); + // foreach (var contentType in contentTypesArr) + // { + // orExpression.Add(new TypeExpression(NodeType.GetByName(contentType), true)); + // } + // andExpression.Add(orExpression); + // } + + // var nodes = query.Execute().Nodes; + + // if (simpleContent) + // { + // var contents = nodes.Select(n => new cs.SimpleServiceContent(n)); + // return contents.ToArray(); + // } + // else + // { + // var contents = nodes.Select(n => new cs.Content(n, true, false, false, false, 0, 0)); + // return contents.ToArray(); + // } + // } + //} private static bool IsLuceneSyntax(string s) { diff --git a/src/WebPages/PageTemplateManager.cs b/src/WebPages/PageTemplateManager.cs index 7280a98..c7bca62 100644 --- a/src/WebPages/PageTemplateManager.cs +++ b/src/WebPages/PageTemplateManager.cs @@ -9,6 +9,8 @@ using SenseNet.ContentRepository.Storage.Search; using SenseNet.Portal.UI; using SenseNet.ContentRepository; +using SenseNet.ContentRepository.Search; +using SenseNet.Search; namespace SenseNet.Portal { @@ -307,13 +309,10 @@ private static int GetSmallest(string pageTmp, int pos, out string posType) private IEnumerable LoadPageList() { - if (RepositoryInstance.ContentQueryIsAllowed) + if (SearchManager.ContentQueryIsAllowed) { - // this NodeQuery will be compiled to LucQuery because the outer engine is enabled - NodeQuery query = new NodeQuery(); - query.Add(new TypeExpression(ActiveSchema.NodeTypes[typeof(Page).Name], false)); - query.Add(new ReferenceExpression(ActiveSchema.PropertyTypes["PageTemplateNode"], _pageTemplate)); - return query.Execute().Nodes; + var cql = $"+TypeIs:{typeof(Page).Name} + PageTemplateNode:{_pageTemplate.Id}"; + return ContentQuery.Query(cql, QuerySettings.Default).Nodes; } // we need to execute a direct database query because the outer engine is disabled return NodeQuery.QueryNodesByReferenceAndType("PageTemplateNode", this.PageTemplateNode.Id, ActiveSchema.NodeTypes[typeof(Page).Name], false).Nodes; diff --git a/src/WebPages/PortletFramework/PortletInventory.cs b/src/WebPages/PortletFramework/PortletInventory.cs index 3e43b78..1936bde 100644 --- a/src/WebPages/PortletFramework/PortletInventory.cs +++ b/src/WebPages/PortletFramework/PortletInventory.cs @@ -12,6 +12,7 @@ using SenseNet.ContentRepository.Storage.Schema; using System.Text.RegularExpressions; using SenseNet.Configuration; +using SenseNet.Search; using SenseNet.Tools; namespace SenseNet.Portal.UI.PortletFramework @@ -78,12 +79,8 @@ public static List GetCategories(List por } public static IEnumerable GetPortletsFromRepo() { - var query = new NodeQuery(); - var expression = new ExpressionList(ChainOperator.And); - expression.Add(new StringExpression(StringAttribute.Path, StringOperator.StartsWith, PortletsFolderPath)); - expression.Add(new TypeExpression(NodeType.GetByName("Portlet"))); - query.Add(expression); - return query.Execute().Nodes; + var cql = $"+TypeIs:{NodeType.GetByName("Portlet").Name} +InTree:{PortletsFolderPath}"; + return ContentQuery.Query(cql, QuerySettings.Default).Nodes; } public static IEnumerable GetCategoriesFromRepo() { diff --git a/src/WebPages/Portlets/ContentCollection/ContentCollectionPortlet.cs b/src/WebPages/Portlets/ContentCollection/ContentCollectionPortlet.cs index 833d816..e2b48fe 100644 --- a/src/WebPages/Portlets/ContentCollection/ContentCollectionPortlet.cs +++ b/src/WebPages/Portlets/ContentCollection/ContentCollectionPortlet.cs @@ -20,6 +20,7 @@ using System.Xml.XPath; using SenseNet.Portal.Virtualization; using SenseNet.ContentRepository.Storage.Search; +using SenseNet.Search.Querying; namespace SenseNet.Portal.Portlets { @@ -336,7 +337,7 @@ protected override object GetModel() if (State.Skip > 0) cdef.Skip = State.Skip; if (!string.IsNullOrEmpty(State.SortColumn)) - cdef.Sort = new[] { new SortInfo { FieldName = State.SortColumn, Reverse = State.SortDescending } }; + cdef.Sort = new[] { new SortInfo ( State.SortColumn, State.SortDescending ) }; var filter = GetQueryFilter(); @@ -344,7 +345,7 @@ protected override object GetModel() { // combine the two queries (e.g. in case of a Smart Folder or a container with a custom children query) if (!string.IsNullOrEmpty(filter)) - content.ChildrenDefinition.ContentQuery = ContentQuery.AddClause(content.ChildrenDefinition.ContentQuery, filter, ChainOperator.And); + content.ChildrenDefinition.ContentQuery = ContentQuery.AddClause(content.ChildrenDefinition.ContentQuery, filter, LogicalOperator.And); } else { diff --git a/src/WebPages/Portlets/ContextSearch.cs b/src/WebPages/Portlets/ContextSearch.cs index efb6a0d..0c8af28 100644 --- a/src/WebPages/Portlets/ContextSearch.cs +++ b/src/WebPages/Portlets/ContextSearch.cs @@ -20,6 +20,7 @@ using SenseNet.ApplicationModel; using SenseNet.ContentRepository.Workspaces; using SenseNet.Search; +using SenseNet.Search.Querying; namespace SenseNet.Portal.Portlets { @@ -312,13 +313,13 @@ protected override object GetModel() var escapedPath = ctx.Path.Replace("(", "\\(").Replace(")", "\\)"); model.ChildrenDefinition.ContentQuery = ContentQuery.AddClause(model.ChildrenDefinition.ContentQuery, - ContentQuery.AddClause(sf.Query, string.Format("InTree:\"{0}\"", escapedPath), ChainOperator.And), ChainOperator.And); + ContentQuery.AddClause(sf.Query, string.Format("InTree:\"{0}\"", escapedPath), LogicalOperator.And), LogicalOperator.And); } } else { if (!string.IsNullOrEmpty(sf.Query)) - model.ChildrenDefinition.ContentQuery = ContentQuery.AddClause(model.ChildrenDefinition.ContentQuery, sf.Query, ChainOperator.And); + model.ChildrenDefinition.ContentQuery = ContentQuery.AddClause(model.ChildrenDefinition.ContentQuery, sf.Query, LogicalOperator.And); } } diff --git a/src/WebPages/Portlets/SiteMenu/SiteMenuNodeEnumerator.cs b/src/WebPages/Portlets/SiteMenu/SiteMenuNodeEnumerator.cs index dd585dc..91ecd5c 100644 --- a/src/WebPages/Portlets/SiteMenu/SiteMenuNodeEnumerator.cs +++ b/src/WebPages/Portlets/SiteMenu/SiteMenuNodeEnumerator.cs @@ -33,24 +33,24 @@ protected SiteMenuNodeEnumerator(string path, ExecutionHint executionHint, _childrenFilter = filter; } - protected override NodeQueryResult QueryChildrenFromLucene(int thisId) - { - if (string.IsNullOrEmpty(_childrenFilter)) - { - return base.QueryChildrenFromLucene(thisId); - } - else - { - // We need to apply a query filter. Execute a content - // query and create a node query result on-the-fly. - var query = ContentQuery.CreateQuery("+ParentId:@0", null, thisId); + /**///protected override NodeQueryResult QueryChildrenFromLucene(int thisId) + //{ + // if (string.IsNullOrEmpty(_childrenFilter)) + // { + // return base.QueryChildrenFromLucene(thisId); + // } + // else + // { + // // We need to apply a query filter. Execute a content + // // query and create a node query result on-the-fly. + // var query = ContentQuery.CreateQuery("+ParentId:@0", null, thisId); - if (!string.IsNullOrEmpty(_childrenFilter)) - query.AddClause(_childrenFilter); + // if (!string.IsNullOrEmpty(_childrenFilter)) + // query.AddClause(_childrenFilter); - return new NodeQueryResult(query.ExecuteToIds(ExecutionHint.ForceIndexedEngine)); - } - } + // return new NodeQueryResult(query.ExecuteToIds(ExecutionHint.ForceIndexedEngine)); + // } + //} protected override bool MoveToFirstChild() { diff --git a/src/WebPages/Portlets/UserGroupManagerPortlet.cs b/src/WebPages/Portlets/UserGroupManagerPortlet.cs index b343a77..0794f8f 100644 --- a/src/WebPages/Portlets/UserGroupManagerPortlet.cs +++ b/src/WebPages/Portlets/UserGroupManagerPortlet.cs @@ -50,7 +50,7 @@ private List GetGroups() var groups = new List(); if (!String.IsNullOrEmpty(GroupQuery)) { - var sort = new[] { new SortInfo { FieldName = "Name" } }; + var sort = new[] {new SortInfo("Name")}; var settings = new QuerySettings { EnableAutofilters = FilterStatus.Disabled, EnableLifespanFilter = FilterStatus.Disabled, Sort = sort }; var query = new ContentQuery { Text = GroupQuery, Settings = settings}; query.AddClause(string.Format("-Path:({0})", string.Join(" ", Identifiers.SpecialGroupPaths))); diff --git a/src/WebPages/UI/ContentListViews/ViewBase.cs b/src/WebPages/UI/ContentListViews/ViewBase.cs index da59bf9..cab81c8 100644 --- a/src/WebPages/UI/ContentListViews/ViewBase.cs +++ b/src/WebPages/UI/ContentListViews/ViewBase.cs @@ -57,23 +57,23 @@ public Node ContextNode #endregion - #region view_queries - - protected virtual NodeQuery GetFilter() - { - NodeQuery filter = null; - if (!string.IsNullOrEmpty(ViewDefinition.FilterXml)) - { - if (ViewDefinition.FilterIsContentQuery) - return null; + /**///#region view_queries + + //protected virtual NodeQuery GetFilter() + //{ + // NodeQuery filter = null; + // if (!string.IsNullOrEmpty(ViewDefinition.FilterXml)) + // { + // if (ViewDefinition.FilterIsContentQuery) + // return null; - filter = NodeQuery.Parse(Query.GetNodeQueryXml(ViewDefinition.FilterXml)); - } + // filter = NodeQuery.Parse(Query.GetNodeQueryXml(ViewDefinition.FilterXml)); + // } - return filter; - } + // return filter; + //} - #endregion + //#endregion #region aspnet_members @@ -83,18 +83,10 @@ protected override void OnLoad(EventArgs e) if (ViewDefinition != null) { - if (ViewDefinition.FilterIsContentQuery) - { - if (this.OwnerFrame == null || this.OwnerFrame.OwnerPortlet == null) - ViewDataSource.Query = ViewDefinition.FilterXml; - else - ViewDataSource.Query = this.OwnerFrame.OwnerPortlet.ReplaceTemplates(ViewDefinition.FilterXml); - - } + if (this.OwnerFrame == null || this.OwnerFrame.OwnerPortlet == null) + ViewDataSource.Query = ViewDefinition.FilterXml; else - { - ViewDataSource.QueryFilter = GetFilter(); - } + ViewDataSource.Query = this.OwnerFrame.OwnerPortlet.ReplaceTemplates(ViewDefinition.FilterXml); } if (ViewDataSource.Settings == null) diff --git a/src/WebPages/UI/Controls/PermissionEditor.cs b/src/WebPages/UI/Controls/PermissionEditor.cs index a771404..11a8349 100644 --- a/src/WebPages/UI/Controls/PermissionEditor.cs +++ b/src/WebPages/UI/Controls/PermissionEditor.cs @@ -19,6 +19,7 @@ using SenseNet.Search; using System.Text; using SenseNet.Configuration; +using SenseNet.Search.Querying; using SenseNet.Services; namespace SenseNet.Portal.UI.Controls @@ -549,7 +550,7 @@ private void RefreshIdentityResults() var ws = Workspace.GetWorkspaceForNode(ContextNode); var permQuery = ContentQuery.CreateQuery("InTree:@0", null, RepositoryStructure.ImsFolderPath); if (ws != null) - permQuery.AddClause(string.Format("InTree:\"{0}/{1}\"", ws.Path, Repository.LocalGroupsFolderName), ChainOperator.Or); + permQuery.AddClause(string.Format("InTree:\"{0}/{1}\"", ws.Path, Repository.LocalGroupsFolderName), LogicalOperator.Or); switch (this.Isi.IdentityKind) { @@ -574,12 +575,12 @@ private void RefreshIdentityResults() if (!st.EndsWith("*")) st = st + "*"; - permQuery.AddClause(string.Format("Name:{0}", st)); + permQuery.AddClause($"Name:{st}"); } permQuery.Settings.EnableAutofilters = FilterStatus.Disabled; permQuery.Settings.Top = 500; - permQuery.Settings.Sort = new List() {new SortInfo {FieldName = "Name"}}; + permQuery.Settings.Sort = new List {new SortInfo("Name")}; ListEntries.Items.AddRange((from node in permQuery.Execute().Nodes select GetListItem(node)).ToArray()); diff --git a/src/WebPages/UI/Controls/SenseNetDataSource.cs b/src/WebPages/UI/Controls/SenseNetDataSource.cs index ebd9f8c..26426d8 100644 --- a/src/WebPages/UI/Controls/SenseNetDataSource.cs +++ b/src/WebPages/UI/Controls/SenseNetDataSource.cs @@ -8,6 +8,7 @@ using SenseNet.Portal.Virtualization; using SenseNet.ContentRepository.Storage; using SenseNet.ContentRepository.Schema; +using SenseNet.ContentRepository.Search; using SenseNet.ContentRepository.Storage.Schema; using SenseNet.Portal.UI.PortletFramework; using SenseNet.Search; @@ -22,7 +23,7 @@ public class SenseNetDataSource : DataSourceControl public string ContextInfoID { get; set; } - public Expression QueryFilter { get; set; } + /**///public Expression QueryFilter { get; set; } private string _query; public string Query @@ -76,7 +77,7 @@ public bool ShowSystem { get { - return LucQuery.IsAutofilterEnabled(Settings.EnableAutofilters); + return SearchManager.IsAutofilterEnabled(Settings.EnableAutofilters); } set { @@ -130,7 +131,7 @@ protected override DataSourceView GetView(string viewName) Content = this.Content, MemberName = this.MemberName, FieldNames = this.FieldNames, - QueryFilter = this.QueryFilter, + /**///QueryFilter = this.QueryFilter, QueryText = this.Query, ShowHidden = this.ShowHidden, Settings = this.Settings, diff --git a/src/WebPages/UI/Controls/SenseNetDataSourceView.cs b/src/WebPages/UI/Controls/SenseNetDataSourceView.cs index a13475c..6080b74 100644 --- a/src/WebPages/UI/Controls/SenseNetDataSourceView.cs +++ b/src/WebPages/UI/Controls/SenseNetDataSourceView.cs @@ -39,7 +39,7 @@ public SenseNetDataSourceView(IDataSource owner) internal string GroupBy { get; set; } - internal Expression QueryFilter { get; set; } + /**///internal Expression QueryFilter { get; set; } internal string QueryText { get; set; } @@ -53,8 +53,8 @@ private ContentQuery ContentQuery return null; var cq = ContentQuery.CreateQuery(QueryText); - if (cq.IsNodeQuery) - return null; + /**///if (cq.IsNodeQuery) + // return null; var clauses = string.Empty; @@ -80,7 +80,7 @@ private ContentQuery ContentQuery } if (!string.IsNullOrEmpty(clauses)) - cq.AddClause(clauses, ChainOperator.And); + cq.AddClause(clauses, SenseNet.Search.Querying.LogicalOperator.And); if (this.Settings != null) cq.Settings = this.Settings; @@ -89,69 +89,69 @@ private ContentQuery ContentQuery } } - internal NodeQuery Query - { - get - { - NodeQuery query; - - if (!string.IsNullOrEmpty(QueryText)) - { - try - { - query = NodeQuery.Parse(QueryText); - } - catch - { - //TODO handle wrong query syntax - query = new NodeQuery(); - } - } - else - { - query = new NodeQuery(); - } - - if (!this.ShowHidden) - query.Add(new IntExpression(ActiveSchema.PropertyTypes["Hidden"], ValueOperator.NotEqual, 1)); - - if (this.Content != null) - { - // constructing query for a reference property is not possible - if (!string.IsNullOrEmpty(this.MemberName) && this.Content.Fields.ContainsKey(this.MemberName)) - return null; - - if (this.FlattenResults) - { - // path query - query.Add(new StringExpression(StringAttribute.Path, StringOperator.StartsWith, - RepositoryPath.Combine(this.Content.Path, RepositoryPath.PathSeparator))); - - } - else - { - // children query - query.Add(new IntExpression(IntAttribute.ParentId, ValueOperator.Equal, this.Content.Id)); - } - - if (this.QueryFilter != null) - { - query.Add(this.QueryFilter); - } - } - else if (this.QueryFilter != null) - { - query.Add(this.QueryFilter); - } - - if (query != null && this.Settings != null && this.Settings.Top > 0) - query.Top = this.Settings.Top; - - return query; - } - } - - // ======================================================== Execute select + /**///internal NodeQuery Query + //{ + // get + // { + // NodeQuery query; + + // if (!string.IsNullOrEmpty(QueryText)) + // { + // try + // { + // query = NodeQuery.Parse(QueryText); + // } + // catch + // { + // //TODO handle wrong query syntax + // query = new NodeQuery(); + // } + // } + // else + // { + // query = new NodeQuery(); + // } + + // if (!this.ShowHidden) + // query.Add(new IntExpression(ActiveSchema.PropertyTypes["Hidden"], ValueOperator.NotEqual, 1)); + + // if (this.Content != null) + // { + // // constructing query for a reference property is not possible + // if (!string.IsNullOrEmpty(this.MemberName) && this.Content.Fields.ContainsKey(this.MemberName)) + // return null; + + // if (this.FlattenResults) + // { + // // path query + // query.Add(new StringExpression(StringAttribute.Path, StringOperator.StartsWith, + // RepositoryPath.Combine(this.Content.Path, RepositoryPath.PathSeparator))); + + // } + // else + // { + // // children query + // query.Add(new IntExpression(IntAttribute.ParentId, ValueOperator.Equal, this.Content.Id)); + // } + + // if (this.QueryFilter != null) + // { + // query.Add(this.QueryFilter); + // } + // } + // else if (this.QueryFilter != null) + // { + // query.Add(this.QueryFilter); + // } + + // if (query != null && this.Settings != null && this.Settings.Top > 0) + // query.Top = this.Settings.Top; + + // return query; + // } + //} + + /* ======================================================== Execute select */ public IEnumerable Select(DataSourceSelectArguments selectArgs) { @@ -236,41 +236,41 @@ protected override IEnumerable ExecuteSelect(DataSourceSelectArguments selectArg return dataList; } - var query = dataList == null ? this.Query : null; - if (query != null) - { - if (sortExp.HasValue) - { - var fieldName = string.Empty; - var pt = GetPropertyTypeFromFullName(sortExp.Value.PropertyName, out fieldName); - - if (pt != null) - { - query.Orders.Add(new SearchOrder(pt, sortExp.Value.Direction)); - } - else - { - // no real property, try the Node attributes - if (Enum.GetNames(typeof(StringAttribute)).Contains(fieldName)) - { - var sa = (StringAttribute)Enum.Parse(typeof(StringAttribute), fieldName); - query.Orders.Add(new SearchOrder(sa, sortExp.Value.Direction)); - } - else if (Enum.GetNames(typeof(IntAttribute)).Contains(fieldName)) - { - var sa = (IntAttribute)Enum.Parse(typeof(IntAttribute), fieldName); - query.Orders.Add(new SearchOrder(sa, sortExp.Value.Direction)); - } - else if (Enum.GetNames(typeof(DateTimeAttribute)).Contains(fieldName)) - { - var sa = (DateTimeAttribute)Enum.Parse(typeof(DateTimeAttribute), fieldName); - query.Orders.Add(new SearchOrder(sa, sortExp.Value.Direction)); - } - } - } - - dataList = Content.Query(query, GetFieldNames()); - } + /**///var query = dataList == null ? this.Query : null; + //if (query != null) + //{ + // if (sortExp.HasValue) + // { + // var fieldName = string.Empty; + // var pt = GetPropertyTypeFromFullName(sortExp.Value.PropertyName, out fieldName); + + // if (pt != null) + // { + // query.Orders.Add(new SearchOrder(pt, sortExp.Value.Direction)); + // } + // else + // { + // // no real property, try the Node attributes + // if (Enum.GetNames(typeof(StringAttribute)).Contains(fieldName)) + // { + // var sa = (StringAttribute)Enum.Parse(typeof(StringAttribute), fieldName); + // query.Orders.Add(new SearchOrder(sa, sortExp.Value.Direction)); + // } + // else if (Enum.GetNames(typeof(IntAttribute)).Contains(fieldName)) + // { + // var sa = (IntAttribute)Enum.Parse(typeof(IntAttribute), fieldName); + // query.Orders.Add(new SearchOrder(sa, sortExp.Value.Direction)); + // } + // else if (Enum.GetNames(typeof(DateTimeAttribute)).Contains(fieldName)) + // { + // var sa = (DateTimeAttribute)Enum.Parse(typeof(DateTimeAttribute), fieldName); + // query.Orders.Add(new SearchOrder(sa, sortExp.Value.Direction)); + // } + // } + // } + + // dataList = Content.Query(query, GetFieldNames()); + //} //TODO: check Count mechanism if (dataList != null) @@ -402,16 +402,13 @@ private IEnumerable GetSortInfoList(SortOrderInfo? sortOrderInfo) var sortInfos = new List(); if (!string.IsNullOrEmpty(this.GroupBy)) - sortInfos.Add(new SortInfo{ FieldName = this.GroupBy }); + sortInfos.Add(new SortInfo(this.GroupBy)); if (!sortOrderInfo.HasValue) return sortInfos; - sortInfos.Add(new SortInfo - { - FieldName = sortOrderInfo.Value.PropertyName, - Reverse = sortOrderInfo.Value.Direction == OrderDirection.Desc - }); + sortInfos.Add(new SortInfo(sortOrderInfo.Value.PropertyName, + sortOrderInfo.Value.Direction == OrderDirection.Desc)); return sortInfos; } @@ -473,7 +470,7 @@ private IEnumerable GetChildren() this.Content.ChildrenDefinition.AllChildren = this.FlattenResults; // must exclude the current content from the results (in case of an InTree query) - this.Content.ChildrenDefinition.ContentQuery = ContentQuery.AddClause(this.Content.ChildrenDefinition.ContentQuery, string.Format("-Id:{0}", this.Content.Id), ChainOperator.And); + this.Content.ChildrenDefinition.ContentQuery = ContentQuery.AddClause(this.Content.ChildrenDefinition.ContentQuery, string.Format("-Id:{0}", this.Content.Id), SenseNet.Search.Querying.LogicalOperator.And); var children = this.Content.Children.AsEnumerable().Where(c => c != null).ToList(); diff --git a/src/WebPages/UI/Controls/TagList.cs b/src/WebPages/UI/Controls/TagList.cs index f0a1205..70cb09a 100644 --- a/src/WebPages/UI/Controls/TagList.cs +++ b/src/WebPages/UI/Controls/TagList.cs @@ -8,6 +8,7 @@ using System.Drawing; using System.Web; using SenseNet.Portal.UI.Controls; +using SenseNet.Search; [assembly: WebResource(TagList.ClientResourceName, "application/x-javascript")] namespace SenseNet.Portal.UI.Controls @@ -352,10 +353,8 @@ private void RenderBrowse(HtmlTextWriter output) /// True if the tag is on blacklist, false if it isn't. private static bool IsBlacklisted(string tag) { - var query = SenseNet.Search.LucQuery.Parse("+TypePath:genericcontent/tag +IsBlacklisted:true +DisplayName:" + tag.ToLower()); - var result = query.Execute(); - - return (result.Count() > 0); + var result = ContentQuery.Query("+TypePath:genericcontent/tag +IsBlacklisted:true +DisplayName:" + tag.ToLower()); + return result.Count > 0; } /// /// Initializes the TagElement list from the given string array diff --git a/src/WebPages/WarmUp.cs b/src/WebPages/WarmUp.cs index 23523ca..1eaba98 100644 --- a/src/WebPages/WarmUp.cs +++ b/src/WebPages/WarmUp.cs @@ -143,7 +143,7 @@ public static void Preload() // template replacers and resolvers ThreadPool.QueueUserWorkItem(delegate { TemplateManager.Init(); }); - ThreadPool.QueueUserWorkItem(delegate { NodeQuery.InitTemplateResolvers(); }); + /**///ThreadPool.QueueUserWorkItem(delegate { NodeQuery.InitTemplateResolvers(); }); // jscript evaluator ThreadPool.QueueUserWorkItem(delegate { JscriptEvaluator.Init(); });