GetData() public method

Returns object data which is a transfer object.
public GetData ( ) : object
return object
Example #1
0
        public override IEnumerable <IndexFieldInfo> GetIndexFieldInfos(SnCR.Field snField, out string textExtract)
        {
            var data = snField.GetData() as string;

            textExtract = data == null ? String.Empty : data;
            return(CreateFieldInfo(snField.Name, textExtract));
        }
Example #2
0
        public override IEnumerable <string> GetParsableValues(SnCR.Field snField)
        {
            var value      = (string)snField.GetData() ?? String.Empty;
            var parentPath = RepositoryPath.GetParentPath(value.ToLower()) ?? "/";

            return(new[] { parentPath.ToLower() });
        }
Example #3
0
        public override IEnumerable <IndexFieldInfo> GetIndexFieldInfos(SnCR.Field snField, out string textExtract)
        {
            var data = snField.GetData() as SenseNet.ContentRepository.Storage.BinaryData;

            textExtract = data == null ? String.Empty : SenseNet.Search.TextExtractor.GetExtract(data, snField.Content.ContentHandler);
            return(CreateFieldInfo(snField.Name, textExtract));
        }
Example #4
0
        public override IEnumerable <string> GetParsableValues(SnCR.Field snField)
        {
            var data = snField.GetData() ?? string.Empty;

            var stringData = data as string;

            if (stringData != null)
            {
                return new[] { stringData.ToLower() }
            }
            ;

            var listData = data as IEnumerable <string>;

            if (listData != null)
            {
                return(listData.Select(s => s.ToLower()).ToArray());
            }

            var enumerableData = data as System.Collections.IEnumerable;

            if (enumerableData != null)
            {
                return((from object item in enumerableData select Convert.ToString(item, System.Globalization.CultureInfo.InvariantCulture).ToLower()).ToList());
            }

            return(new[] { string.Empty });
        }
    }
Example #5
0
        public override IEnumerable <IndexFieldInfo> GetIndexFieldInfos(SnCR.Field snField, out string textExtract)
        {
            textExtract = String.Empty;
            var value = (string)snField.GetData() ?? String.Empty;

            return(CreateFieldInfo(snField.Name, value));
        }
Example #6
0
        public override IEnumerable <string> GetParsableValues(SnCR.Field snField)
        {
            var value     = snField.GetData();
            var boolValue = value == null ? false : (bool)value;

            return(new[] { boolValue?YES : NO });
        }
Example #7
0
        public override IEnumerable <string> GetParsableValues(SenseNet.ContentRepository.Field snField)
        {
            var value    = snField.GetData();
            var intValue = value == null ? 0 : (int)value;

            return(new[] { intValue.ToString() });
        }
Example #8
0
        public override IEnumerable <string> GetParsableValues(SnCR.Field snField)
        {
            var value    = snField.GetData();
            var intValue = value == null ? 0 : (int)value;

            return(new[] { intValue.ToString() });
        }
Example #9
0
        public override IEnumerable <IndexFieldInfo> GetIndexFieldInfos(SnCR.Field snField, out string textExtract)
        {
            textExtract = String.Empty;
            var data  = snField.GetData();
            var ticks = data == null ? 0 : ((DateTime)data).Ticks;

            return(CreateFieldInfo(snField.Name, SetPrecision(snField, ticks)));
        }
Example #10
0
        public override IEnumerable <IndexFieldInfo> GetIndexFieldInfos(SnCR.Field snField, out string textExtract)
        {
            var value     = snField.GetData();
            var boolValue = value == null ? false : (bool)value;

            textExtract = String.Empty;
            return(CreateFieldInfo(snField.Name, boolValue ? YES : NO));
        }
Example #11
0
        public override IEnumerable <IndexFieldInfo> GetIndexFieldInfos(SenseNet.ContentRepository.Field snField, out string textExtract)
        {
            var data        = snField.GetData();
            var stringValue = data == null ? String.Empty : data.ToString().ToLower();

            textExtract = stringValue;
            return(CreateFieldInfo(snField.Name, stringValue));
        }
Example #12
0
        public override IEnumerable <string> GetParsableValues(SnCR.Field snField)
        {
            var value        = snField.GetData();
            var decimalValue = value == null ? (Decimal)0.0 : (Decimal)value;
            var doubleValue  = Convert.ToDouble(decimalValue);

            return(new[] { decimalValue.ToString(System.Globalization.CultureInfo.InvariantCulture) });
        }
Example #13
0
        public override IEnumerable <IndexFieldInfo> GetIndexFieldInfos(SnCR.Field snField, out string textExtract)
        {
            var value        = snField.GetData();
            var decimalValue = value == null ? (Decimal)0.0 : (Decimal)value;
            var doubleValue  = Convert.ToDouble(decimalValue);

            textExtract = decimalValue.ToString(System.Globalization.CultureInfo.InvariantCulture);
            return(CreateFieldInfo(snField.Name, doubleValue));
        }
Example #14
0
        public override IEnumerable <IndexFieldInfo> GetIndexFieldInfos(SnCR.Field snField, out string textExtract)
        {
            var value = (string)snField.GetData() ?? String.Empty;

            textExtract = value.ToLower();
            var parentPath = RepositoryPath.GetParentPath(textExtract) ?? "/";

            return(CreateFieldInfo(snField.Name, parentPath));
        }
Example #15
0
        public override IEnumerable <string> GetParsableValues(SnCR.Field snField)
        {
            var path      = (string)snField.GetData() ?? String.Empty;
            var separator = "/";

            string[] fragments = path.ToLower().Split(separator.ToCharArray(), StringSplitOptions.None);
            string[] pathSteps = new string[fragments.Length];
            for (int i = 0; i < fragments.Length; i++)
            {
                pathSteps[i] = string.Join(separator, fragments, 0, i + 1);
            }
            return(pathSteps);
        }
Example #16
0
        public override IEnumerable <string> GetParsableValues(SnCR.Field snField)
        {
            var snFieldValue = (string)snField.GetData();

            if (String.IsNullOrEmpty(snFieldValue))
            {
                return(null);
            }
            snFieldValue = snFieldValue.ToLower();
            var terms = snFieldValue.Split(",;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Select(w => w.Trim()).ToArray();

            return(terms);
        }
Example #17
0
        public override IEnumerable <IndexFieldInfo> GetIndexFieldInfos(SnCR.Field snField, out string textExtract)
        {
            textExtract = String.Empty;

            var snFieldValue = (string[])snField.GetData();

            if (snFieldValue == null || snFieldValue.Length == 0)
            {
                return(CreateFieldInfo(snField.Name, string.Empty));
            }

            var terms = snFieldValue.Select(x => x.ToLowerInvariant()).ToArray();

            return(CreateFieldInfo(snField.Name, terms));
        }
Example #18
0
        public override IEnumerable <IndexFieldInfo> GetIndexFieldInfos(SnCR.Field snField, out string textExtract)
        {
            var value    = snField.GetData();
            var intValue = 0;

            try
            {
                intValue = value == null ? 0 : (int)value;
            }
            catch (Exception e)
            {
                Logger.WriteVerbose(String.Format("IntegerIndexHandler ERROR: content: {0} field: {1}, value: {2}", snField.Content.Path, snField.Name, value));
                throw;
            }
            textExtract = intValue.ToString();
            return(CreateFieldInfo(snField.Name, intValue));
        }
Example #19
0
        public override IEnumerable <IndexFieldInfo> GetIndexFieldInfos(SnCR.Field snField, out string textExtract)
        {
            string className, name;

            if (SenseNetResourceManager.Running && snField.LocalizationEnabled && snField.IsLocalized && SenseNetResourceManager.ParseResourceKey(snField.GetStoredValue(), out className, out name))
            {
                var strings = SenseNetResourceManager.Current.GetStrings(className, name);
                textExtract = string.Join(" ", strings);
                return(CreateFieldInfo(snField.Name, strings));
            }
            var data        = snField.GetData();
            var stringValue = data == null ? String.Empty : data.ToString().ToLower();

            textExtract = stringValue;

            return(CreateFieldInfo(snField.Name, stringValue));
        }
Example #20
0
        public override IEnumerable <IndexFieldInfo> GetIndexFieldInfos(SenseNet.ContentRepository.Field snField, out string textExtract)
        {
            textExtract = String.Empty;
            var data = snField.GetData();
            var node = data as Node;

            if (node != null)
            {
                return(CreateFieldInfo(snField.Name, node.Id.ToString()));
            }
            var nodes = data as System.Collections.IEnumerable;

            if (nodes != null)
            {
                return(CreateFieldInfo(snField.Name, nodes.Cast <Node>().Select(n => n.Id.ToString())));
            }
            return(null);
        }
Example #21
0
        public override IEnumerable <IndexFieldInfo> GetIndexFieldInfos(SnCR.Field snField, out string textExtract)
        {
            textExtract = String.Empty;
            var data = snField.GetData();
            var node = data as Node;

            if (node != null)
            {
                return(CreateFieldInfo(snField.Name, node.Id.ToString()));
            }
            var nodes = data as System.Collections.IEnumerable;

            if (nodes != null)
            {
                return(CreateFieldInfo(snField.Name, nodes.Cast <Node>().Select(n => n.Id.ToString())));
            }
            return(CreateFieldInfo(snField.Name, LucQuery.NullReferenceValue));
        }
Example #22
0
        public override IEnumerable <string> GetParsableValues(SenseNet.ContentRepository.Field snField)
        {
            var data = snField.GetData();

            try
            {
                var dateData = Convert.ToDateTime(data);
                if (dateData != DateTime.MinValue)
                {
                    return new[] { "'" + dateData.ToString("yyyy.MM.dd hh:mm:ss") + "'" }
                }
                ;
            }
            catch (Exception ex)
            {
                Logger.WriteInformation(ex);
            }
            return(new[] { string.Empty });
        }
Example #23
0
        public override IEnumerable <string> GetParsableValues(SnCR.Field snField)
        {
            var data = snField.GetData();
            var node = data as Node;

            if (node != null)
            {
                return new[] { node.Id.ToString() }
            }
            ;
            var nodes = data as System.Collections.IEnumerable;

            if (nodes != null)
            {
                return(nodes.Cast <Node>().Select(n => n.Id.ToString()));
            }
            return(null);
        }
    }
Example #24
0
        public override IEnumerable <string> GetParsableValues(SnCR.Field snField)
        {
            var data = snField.GetData();

            try
            {
                var dateData = Convert.ToDateTime(data);
                if (dateData != DateTime.MinValue)
                {
                    return new[] { "'" + dateData.ToString("yyyy.MM.dd HH:mm:ss") + "'" }
                }
                ;
            }
            catch (Exception ex)
            {
                Logger.WriteInformation(Logger.EventId.NotDefined, ex);
            }
            return(new[] { string.Empty });
        }
Example #25
0
        public override IEnumerable <IndexFieldInfo> GetIndexFieldInfos(SenseNet.ContentRepository.Field snField, out string textExtract)
        {
            var data = snField.GetData() ?? string.Empty;

            var stringData = data as string;

            if (stringData != null)
            {
                textExtract = stringData.ToLower();
                return(CreateFieldInfo(snField.Name, textExtract));
            }

            var listData = data as IEnumerable <string>;

            if (listData != null)
            {
                var wordArray = listData.Select(s => s.ToLower()).ToArray();
                textExtract = String.Join(" ", wordArray);
                return(CreateFieldInfo(snField.Name, wordArray));
            }

            var enumerableData = data as System.Collections.IEnumerable;

            if (enumerableData != null)
            {
                var words = new List <string>();
                foreach (var item in enumerableData)
                {
                    words.Add(Convert.ToString(item, System.Globalization.CultureInfo.InvariantCulture).ToLower());
                }
                var wordArray = words.ToArray();
                textExtract = String.Join(" ", wordArray);
                return(CreateFieldInfo(snField.Name, words));
            }

            throw new NotSupportedException(String.Concat("Cannot create index from this type: ", data.GetType().FullName,
                                                          ". Indexable data can be string, IEnumerable<string> or IEnumerable."));
        }
Example #26
0
        // IndexHandler for comma or semicolon separated strings (e.g. Red,Green,Blue) used in tagging fields
        public override IEnumerable <IndexFieldInfo> GetIndexFieldInfos(SnCR.Field snField, out string textExtract)
        {
            // Ensure initial textExtract for out parameter. It is used if the field value is null or empty.
            textExtract = String.Empty;
            // Get the value. A field type is indexable with this handler that provides a string value
            // but ShortText and LongText are recommended.
            var snFieldValue = (string)snField.GetData();

            // Return null if the value is not indexable. Lucene field and text extract won't be created.
            if (String.IsNullOrEmpty(snFieldValue))
            {
                return(null);
            }
            // Convert to lowercase for case insensitive index handling
            snFieldValue = snFieldValue.ToLower();
            // Create an array of words. Words can be separated by comma or semicolon. Whitespaces will be removed.
            var terms = snFieldValue.Split(",;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
                        .Select(w => w.Trim()).ToArray();

            // Concatenate the words with space separator for text extract.
            textExtract = String.Join(" ", terms);
            // Produce the lucene multiterm field with a base's tool and return with it.
            return(CreateFieldInfo(snField.Name, terms));
        }
Example #27
0
        public override IEnumerable <IndexFieldInfo> GetIndexFieldInfos(SnCR.Field snField, out string textExtract)
        {
            var data = snField.GetData() ?? string.Empty;

            var stringData = data as string;

            if (stringData != null)
            {
                textExtract = stringData.ToLower();
                return(CreateFieldInfo(snField.Name, textExtract));
            }

            var listData = data as IEnumerable <string>;

            if (listData != null)
            {
                // words to choice field
                var wordList = new List <string>();
                // words to sort field
                var sortList = new List <string>();
                // words to full text field
                var localizedWords = new List <string>();
                foreach (var inputWord in listData)
                {
                    // process every word
                    var cfs = snField.FieldSetting as SnCR.Fields.ChoiceFieldSetting;
                    if (cfs != null)
                    {
                        // field with ChoiceFieldSetting
                        var optionKey = cfs.Options.Where(x => x.Value == inputWord).Select(x => x.StoredText).FirstOrDefault();
                        if (optionKey != null)
                        {
                            // identified option
                            var optionTerm = "$" + inputWord.ToLower();
                            wordList.Add(optionTerm);
                            sortList.Add(optionTerm);
                            string className;
                            string name;
                            var    localized = SenseNetResourceManager.ParseResourceKey(optionKey, out className, out name);
                            if (localized && className != null && name != null)
                            {
                                // localized texts: add all known mutations
                                var lw = SenseNetResourceManager.Current.GetStrings(className, name);
                                localizedWords.AddRange(lw.Select(x => x.ToLower()));
                            }
                            else
                            {
                                // not localized: add the word
                                localizedWords.Add(optionKey.ToLower());
                            }
                        }
                        else
                        {
                            // unidentified option: extra value
                            if (inputWord.StartsWith(SnCR.Fields.ChoiceField.EXTRAVALUEPREFIX))
                            {
                                // drives ordering (additional '~' hides this information)
                                sortList.Add("~" + inputWord);
                                // add
                                var splitted = inputWord.Split('.');
                                wordList.Add(splitted[0]);
                                localizedWords.Add(splitted[1].ToLower());
                            }
                            else
                            {
                                // add as a lowercase word
                                wordList.Add(inputWord.ToLower());
                                localizedWords.Add(inputWord.ToLower());
                            }
                        }
                    }
                    else
                    {
                        // field with another field setting
                        wordList.Add(inputWord.ToLower());
                    }
                }
                sortList.Sort();
                var sortTerm = String.Join("-", sortList);
                textExtract = String.Join(" ", localizedWords);
                wordList.AddRange(localizedWords);
                return(CreateFieldInfo(snField.Name, wordList, sortTerm));
            }

            var enumerableData = data as System.Collections.IEnumerable;

            if (enumerableData != null)
            {
                var words = new List <string>();
                foreach (var item in enumerableData)
                {
                    words.Add(Convert.ToString(item, System.Globalization.CultureInfo.InvariantCulture).ToLower());
                }
                var wordArray = words.ToArray();
                textExtract = String.Join(" ", wordArray);
                return(CreateFieldInfo(snField.Name, words));
            }

            throw new NotSupportedException(String.Concat("Cannot create index from this type: ", data.GetType().FullName,
                                                          ". Indexable data can be string, IEnumerable<string> or IEnumerable."));
        }
Example #28
0
        public override IEnumerable <string> GetParsableValues(SnCR.Field snField)
        {
            var data = snField.GetData() as string;

            return(new[] { data == null ? String.Empty : data.ToString() });
        }
Example #29
0
        public override IEnumerable <IndexFieldInfo> GetIndexFieldInfos(SnCR.Field snField, out string textExtract)
        {
            var data = (SenseNet.ContentRepository.Fields.HyperLinkField.HyperlinkData)snField.GetData();

            if (data == null)
            {
                textExtract = String.Empty;
                return(null);
            }
            var strings = new List <string>();

            if (data.Href != null)
            {
                strings.Add(data.Href.ToLower());
            }
            if (data.Target != null)
            {
                strings.Add(data.Target.ToLower());
            }
            if (data.Text != null)
            {
                strings.Add(data.Text.ToLower());
            }
            if (data.Title != null)
            {
                strings.Add(data.Title.ToLower());
            }
            textExtract = String.Join(" ", strings.ToArray());
            return(CreateFieldInfo(snField.Name, strings));
        }
Example #30
0
        public override IEnumerable <string> GetParsableValues(SnCR.Field snField)
        {
            var data = (SenseNet.ContentRepository.Fields.HyperLinkField.HyperlinkData)snField.GetData();

            if (data == null)
            {
                return(null);
            }
            var strings = new List <string>();

            if (data.Href != null)
            {
                strings.Add(data.Href.ToLower());
            }
            if (data.Target != null)
            {
                strings.Add(data.Target.ToLower());
            }
            if (data.Text != null)
            {
                strings.Add(data.Text.ToLower());
            }
            if (data.Title != null)
            {
                strings.Add(data.Title.ToLower());
            }
            return(strings);
        }