Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        private void AddLookupColumnValue(ESHit esHit, EntitySchemaColumn column, Dictionary <string, object> columnValues)
        {
            var lookupValue = GetLookupColumnValue(esHit, column);

            if (lookupValue != null)
            {
                columnValues.Add(column.Name, lookupValue);
            }
        }
Esempio n. 3
0
        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);
            }
        }
Esempio n. 4
0
 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);
 }
Esempio n. 5
0
        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);
                }
            }
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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), "")
                    });
                }
            }
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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), ""));
            }
        }