private static void ProcessParserTest(IEnumerable <FullTextParserTestData> testDataCollection) { foreach (var testData in testDataCollection) { try { var result = new ArticleFullTextSearchQueryParser(testData.SearchGrammarParser).Parse(testData.SearchQueryParams, out var hasError, out var fieldIdList, out var queryString, out var _); if (testData.ExpectedExceptionType != null) { Assert.Fail($"\"{testData.Description}\" test is failed. No thrown exception."); } Assert.AreEqual(testData.ExpectedResult, result, $"\"{testData.Description}\" test is failed."); Assert.AreEqual(testData.ExpectedHasError, hasError, $"\"{testData.Description}\" test is failed."); Assert.AreEqual(testData.ExpectedFieldIdList, fieldIdList, $"\"{testData.Description}\" test is failed."); Assert.AreEqual(testData.ExpectedQueryString, queryString, $"\"{testData.Description}\" test is failed."); } catch (Exception ex) { if (testData.ExpectedExceptionType == null) { Assert.Fail($"\"{testData.Description}\" test is failed. Unexpected exception."); } Assert.IsInstanceOf(testData.ExpectedExceptionType, ex, $"\"{testData.Description}\" test is failed. Unexpected exception type."); } } }
public static IList <EntityTreeItem> GetEntityTreeItems(string entityTypeCode, int?parentEntityId, int?entityId, bool returnSelf, string filter, string hostFilter, string selectItemIDs, IList <ArticleSearchQueryParam> searchQuery, IList <ArticleContextQueryParam> contextQuery, ArticleFullTextSearchQueryParser ftsParser) => ArticleTreeFactory.Create(entityTypeCode, parentEntityId, entityId, returnSelf, filter, hostFilter, selectItemIDs, searchQuery, contextQuery, ftsParser).Process();
public static ListResult <SimpleDataRow> List(int contentId, int[] selectedArticleIDs, ListCommand cmd, IList <ArticleSearchQueryParam> searchQueryParams, IList <ArticleContextQueryParam> contextQueryParams, string filter, ArticleFullTextSearchQueryParser ftsParser, bool?onlyIds = null, int[] filterIds = null) { var dt = ArticleRepository.GetList(contentId, selectedArticleIDs, cmd, searchQueryParams, contextQueryParams, filter, ftsParser, onlyIds, filterIds ?? new int[] { }, out var totalRecords).ToList(); var result = ArticleListHelper.GetResult(dt, FieldRepository.GetList(contentId, true), onlyIds).ToList(); return(new ListResult <SimpleDataRow> { Data = result, TotalRecords = totalRecords }); }
public EntityObjectController(ArticleFullTextSearchQueryParser parser) { _parser = parser; }
/// <summary> /// Фабрика для запроса на отображение дерева в QP /// </summary> internal static ITreeProcessor Create(string entityTypeCode, int?parentEntityId, int?entityId, bool returnSelf, string commonFilter, string hostFilter, string selectItemIDs, IList <ArticleSearchQueryParam> searchQuery, IList <ArticleContextQueryParam> contextQuery, ArticleFullTextSearchQueryParser ftsParser) { using (new QPConnectionScope()) { if (entityTypeCode == EntityTypeCode.Article || entityTypeCode == EntityTypeCode.VirtualArticle) { var contentId = parentEntityId.GetValueOrDefault(); commonFilter = ArticleRepository.FillFullTextSearchParams(contentId, commonFilter, searchQuery, ftsParser, out var ftsOptions, out var extensionContentIds, out var _); var filterSqlParams = new List <SqlParameter>(); var sourceQuery = new ArticleFilterSearchQueryParser().GetFilter(searchQuery, filterSqlParams); var linkedFilters = (ArticleRepository.GetLinkSearchParameter(searchQuery) ?? new ArticleLinkSearchParameter[0]).ToList(); var hasFtsSearchParams = !string.IsNullOrEmpty(ftsOptions.QueryString) && !(ftsOptions.HasError.HasValue && ftsOptions.HasError.Value); var hasFilterSearchParams = !string.IsNullOrEmpty(sourceQuery) || linkedFilters.Any(); var combinedFilter = string.IsNullOrWhiteSpace(sourceQuery) ? hostFilter : string.IsNullOrWhiteSpace(hostFilter) ? sourceQuery : $"({hostFilter} AND {sourceQuery})"; var filterForSmpl = string.IsNullOrWhiteSpace(combinedFilter) ? commonFilter : combinedFilter; return(hasFtsSearchParams || hasFilterSearchParams ? new ArticleFtsProcessor(contentId, commonFilter, combinedFilter, linkedFilters, contextQuery, filterSqlParams, extensionContentIds, ftsOptions) : new ArticleSimpleProcessor(contentId, entityId, filterForSmpl, entityTypeCode, selectItemIDs) as ITreeProcessor); } if (entityTypeCode == EntityTypeCode.SiteFolder || entityTypeCode == EntityTypeCode.ContentFolder) { return(new SiteFolderProcessor(parentEntityId, entityTypeCode, returnSelf, entityId)); } if (entityTypeCode == EntityTypeCode.UserGroup) { return(new UserGroupProcessor(entityTypeCode, entityId)); } } throw new NotImplementedException(entityTypeCode); }
public ArticleController(IArticleService dbArticleService, ArticleFullTextSearchQueryParser parser, QPublishingOptions options) : base(dbArticleService, options) { _parser = parser; }