private string GetColumnValue(ESHit esHit, EntitySchemaColumn column) { var columnAlias = GlobalSearchColumnUtils.GetAlias(column, _entitySchema); return(esHit.Source.FirstOrDefault(x => string.Equals(x.Key, columnAlias, StringComparison.InvariantCultureIgnoreCase)).Value); }
private void AddLookupColumnValue(ESHit esHit, EntitySchemaColumn column, Dictionary <string, object> columnValues) { var lookupValue = GetLookupColumnValue(esHit, column); if (lookupValue != null) { columnValues.Add(column.Name, lookupValue); } }
private void AddColumnValue(ESHit esHit, EntitySchemaColumn column, Dictionary <string, object> columnValues) { var value = GetColumnValue(esHit, column); if (!string.IsNullOrEmpty(value)) { columnValues.Add(column.Name, value); } }
private string[] GetColumnHighlight(ESHit esHit, EntitySchemaColumn column) { string[] result = new string[0]; if (esHit.Highlight != null) { var columnAlias = GlobalSearchColumnUtils.GetAlias(column, _entitySchema); var columnHighlightValue = esHit.Highlight.FirstOrDefault(x => string.Equals(x.Key, columnAlias)).Value; if (columnHighlightValue == null) { return(result); } result = GetHighLightMathces(columnHighlightValue); } return(result); }
private void AddHighlights(ESHit esHit, EntitySchemaColumn column, Dictionary <string, string[]> foundColumns, Dictionary <string, object> columnValues) { var columnName = column.Name; var highlight = GetColumnHighlight(esHit, column); if (highlight != null && highlight.Length > 0) { foundColumns.Add(columnName, highlight); if (!columnValues.ContainsKey(columnName)) { AppendAdditionalHighLightColumn(columnValues, esHit, column); } } }
private BpmSearchResponseEntity FillBpmResponseEntity(ESHit esHit) { _entityName = esHit.Type; _entitySchema = _userConnection.EntitySchemaManager.GetInstanceByName(_entityName); var responseEntity = new BpmSearchResponseEntity { Id = esHit.Id, EntityName = _entityName, ColumnValues = new Dictionary <string, object>(), FoundColumns = new Dictionary <string, string[]>() }; var columnValues = responseEntity.ColumnValues; var foundColumns = responseEntity.FoundColumns; var availableColumns = _entitySchema.Columns .Where(x => _userConnection.DBSecurityEngine .GetIsEntitySchemaColumnReadingAllowed(_entitySchema.Name, x.IsLookupType ? $"{x.Name}{x.ReferenceSchema.PrimaryColumn.Name}" : x.Name)); if (UseLocalizableGlobalSearchResult) { var entityValues = GetLocalizableEntityValues(_entitySchema, Guid.Parse(esHit.Id), availableColumns); foreach (var column in availableColumns) { columnValues.Add(column.Name, entityValues[column.Name]); AddHighlights(esHit, column, foundColumns, columnValues); } } else { foreach (var column in availableColumns) { if (column.IsLookupType) { AddLookupColumnValue(esHit, column, columnValues); } else { AddColumnValue(esHit, column, columnValues); } AddHighlights(esHit, column, foundColumns, columnValues); } } AddDetailsHighlight(responseEntity, esHit); return(responseEntity); }
private void AddDetailsHighlight(BpmSearchResponseEntity responseEntity, ESHit esHit) { var highlights = esHit.Highlight; if (highlights != null) { var detailsHighlights = esHit.Highlight.Where(s => s.Key.StartsWith(ESConstants.DetailsPrefix) && !s.Key.EndsWith("id")); IEnumerable <IGrouping <string, string[]> > groupedDetailsHighlights = detailsHighlights.GroupBy(x => GetDetailNameByKey(x.Key), x => x.Value); foreach (var detailsHighlight in groupedDetailsHighlights) { var detailEntityName = detailsHighlight.Key.Replace(string.Format("{0}.", ESConstants.DetailsPrefix), ""); var highlightValues = detailsHighlight.Select(x => string.Join(" ... ", x)).ToArray(); var detailCaption = GetDetailCaption(detailEntityName); responseEntity.FoundColumns.Add(detailEntityName, GetHighLightMathces(highlightValues)); responseEntity.ColumnValues.Add(detailEntityName, new { caption = detailCaption, displayValue = _replaceHighlightRegex.Replace(string.Join(" ... ", highlightValues), "") }); } } }
private LookupColumnValue GetLookupColumnValue(ESHit esHit, EntitySchemaColumn column) { LookupColumnValue resultValue = null; var columnAlias = GlobalSearchColumnUtils.GetAlias(column, _entitySchema); string displayValue = esHit.Source.FirstOrDefault(x => string.Equals(x.Key, columnAlias)).Value; if (!string.IsNullOrEmpty(displayValue) || GlobalSearchColumnUtils.GetIsSysImageLookupColumn(column)) { var displayColumnAlias = GlobalSearchColumnUtils.GetPrimaryColumnAlias(column, _entityName); resultValue = new LookupColumnValue { Value = esHit.Source.FirstOrDefault(x => string.Equals(x.Key, displayColumnAlias)).Value, DisplayValue = displayValue }; var imageColumn = column.ReferenceSchema.PrimaryImageColumn; if (imageColumn != null && imageColumn.DataValueType is ImageLookupDataValueType) { var priamaryImageColumnAlias = GlobalSearchColumnUtils.GetPrimaryImageColumnAlias(column, _entityName); resultValue.PrimaryImageValue = esHit.Source .FirstOrDefault(x => string.Equals(x.Key, priamaryImageColumnAlias)).Value; } } return(resultValue); }
private void AppendAdditionalHighLightColumn(Dictionary <string, object> columnValues, ESHit esHit, EntitySchemaColumn column) { var columnAlias = GlobalSearchColumnUtils.GetAlias(column, _entitySchema); var columnHighlightValue = esHit.Highlight.FirstOrDefault(x => string.Equals(x.Key, columnAlias)).Value; if (columnHighlightValue != null) { columnValues.Add(column.Name, _replaceHighlightRegex.Replace(string.Join("...", columnHighlightValue), "")); } }