private void continueSearch(bool forward) { if (TextSearch == null) { return; } int startPosition = 0; Control control = MostRecentFocusedDiscussionControl ?? ActiveControl; if (control is ITextControl textControl && textControl.HighlightState != null) { startPosition = forward ? textControl.HighlightState.HighlightStart + textControl.HighlightState.HighlightLength : textControl.HighlightState.HighlightStart; textControl.ClearHighlight(); } TextSearchResult?result = forward ? TextSearch.FindNext(control, startPosition) : TextSearch.FindPrev(control, startPosition); if (result != null) { highlightSearchResult(result); } }
static void Main(string[] args) { TextSearch search = new TextSearch(); search.Search(); search.OutputFragments(); }
public CollectionExplorerView() { InitializeComponent(); splitOrientationSelector.SelectionChanged += (sender, args) => { splitContainer.Orientation = splitOrientationSelector.SelectedIndex == 0 ? Orientation.Vertical : Orientation.Horizontal; }; DockSearch.IsVisibleChanged += (sender, args) => { if (DockSearch.Visibility == Visibility.Visible) { Dispatcher.Invoke(async() => { await Task.Delay(100); TextSearch.Focus(); TextSearch.SelectAll(); }); } }; CollectionListView.Loaded += CollectionListViewOnLoaded; }
protected SelectionList([NotNull] BaseAcManager <TObject> manager, bool isCacheable) { if (manager == null) { throw new ArgumentNullException(nameof(manager)); } TextSearch.SetTextPath(this, nameof(SelectCategoryBase.DisplayName)); ScrollViewer.SetHorizontalScrollBarVisibility(this, ScrollBarVisibility.Disabled); ScrollViewer.SetCanContentScroll(this, true); var baseLey = $@".SelectionList:{typeof(TObject).FullName}:{typeof(TItem).FullName}"; _scrollKey = $@"{baseLey}:Scroll"; _cacheKey = isCacheable ? $@"{baseLey}:Items" : null; _manager = manager; _baseCollection = manager.WrappersList; _items = new BetterObservableCollection <TItem>(Rebuild()); if (!manager.IsLoaded) { EnsureLoaded(isCacheable).Forget(); } Loaded += OnLoaded; Unloaded += OnUnloaded; PreviewKeyDown += OnPreviewKeyDown; }
public IEnumerable <SearchResult> Search(TextSearch search) { using (OpenCache()) { var parser = _provider.CreateQueryParser <TextDocument>("SearchText"); parser.AllowLeadingWildcard = true; var query = new StringBuilder(); var flexSearch = search.QueryLanguage == FlexhSearch; if (flexSearch || search.QueryLanguage == FullSearch) { var actual = flexSearch ? LuceneQuerySanitizer.Sanitize(search.Content) : search.Content; foreach (var match in _provider.AsQueryable <TextDocument>().Where(parser.Parse(actual))) { var tmp = new SearchResult { FriendlyName = match.FriendlyName, HostName = Environment.MachineName, LocalSourceIdentity = match.Id, OriginalRemoteSourceIdentity = match.RemoteIdentity }; tmp.AddStatistic(actual, "1"); tmp.AddStatistic(match.Id, match.SearchText); yield return(tmp); } } else { foreach (var searchResult in SimpleSearch(search, query, parser)) { yield return(searchResult); } } } }
private IEnumerable <SearchResult> SimpleSearch(TextSearch search, StringBuilder query, FieldMappingQueryParser <TextDocument> parser) { var args = search.Content.Split(' ').Distinct().ToArray(); foreach (var arg in args) { if (query.Length > 0) { query.Append(" AND "); } query.AppendFormat("{0}", QueryParser.Escape(arg)); } foreach (var match in _provider.AsQueryable <TextDocument>().Where(parser.Parse(query.ToString()))) { var tmp = new SearchResult { FriendlyName = match.FriendlyName, HostName = Environment.MachineName, LocalSourceIdentity = match.Id, OriginalRemoteSourceIdentity = match.RemoteIdentity }; foreach (var arg in args) { tmp.AddStatistic(arg, args.Count(verb => match.SearchText.Contains(verb)).ToString()); } tmp.AddStatistic(match.Id, match.SearchText); yield return(tmp); } }
public CustomerGroupsFilteredComboBox() { TextSearch.SetTextPath(this, "Name"); SelectedValuePath = "GlobalId"; ItemTemplate = (DataTemplate)Application.Current.Resources["GroupsComboBoxItem"]; ItemContainerStyle = (Style)Application.Current.Resources["StretchedComboBoxItemStyle"]; }
public ActionResult Search(SearchFormViewModel searchParameters) { if (ModelState.IsValid == false) { this.Flash(Toastr.ERROR, "Error", "Enter search pattern!"); return(RedirectToAction("SearchForm", "Search")); } string[] phrases = searchParameters.SearchPattern.Split('"'); //svaki neparni index u phrases je razmak, pa ga mičemo IEnumerable <string[]> removeBlank = phrases.Select((item, index) => index % 2 == 0 ? item.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) : new[] { item }); List <string> pattern = removeBlank.SelectMany(element => element).ToList(); string tsPattern = ConvertTo.LogicalPattern(pattern, searchParameters.LogicalOperator == (int)Operator.Or ? Operator.Or : Operator.And); string queryString; List <MovieViewModel> movies = TextSearch.MorphologySemantic(tsPattern, out queryString); var viewModel = new SearchFormViewModel() { SearchPattern = searchParameters.SearchPattern, LogicalOperator = searchParameters.LogicalOperator, QueryString = queryString, Movies = movies }; UpdateSearchHistory(tsPattern); ModelState.Clear(); //bez ovoga ne bi se mijenjao QueryString return(View("SearchForm", viewModel)); }
private AbstractSearch BuildAbstractProperty <T>(string property, string value, string comparatorValue, string value2 = null) { AbstractSearch abstractSearch; var propertyType = typeof(T).GetProperty(property).PropertyType; //var ts = new TypeSwitch() // .Case((string s) => abstractSearch = BuildPropertyText<Customer>(property, value, comparatorValue)) // .Case((DateTime d) => abstractSearch = BuildPropertyDate<Customer>(property, value, value2, comparatorValue)); //ts.Switch(propertyType); if (propertyType == typeof(string)) { abstractSearch = BuildPropertyText <Customer>(property, value, comparatorValue); } else if (propertyType == typeof(DateTime)) { abstractSearch = BuildPropertyDate <Customer>(property, value, value2, comparatorValue); } else { abstractSearch = new TextSearch(); } return(abstractSearch); }
public List <PdfString> RegexSearch(PDFDoc doc, string pattern, bool ifWholeWord, int startPage, int endPage, bool ignoreCase) { List <PdfString> result = new List <PdfString>(); Int32 page_num = 0; string result_str = ""; string ambient_string = ""; Highlights hlts = new Highlights(); Int32 mode = (Int32)(TextSearch.SearchMode.e_reg_expression | TextSearch.SearchMode.e_highlight); if (ifWholeWord) { mode |= (Int32)TextSearch.SearchMode.e_whole_word; } if (ignoreCase) { mode |= (Int32)TextSearch.SearchMode.e_case_sensitive; } int pageCount = doc.GetPageCount(); if (endPage > pageCount) { endPage = pageCount; } TextSearch txt_search = new TextSearch(); txt_search.Begin(doc, pattern, mode, startPage, endPage); while (true) { TextSearch.ResultCode code = txt_search.Run(ref page_num, ref result_str, ref ambient_string, hlts); if (code == TextSearch.ResultCode.e_found) { hlts.Begin(doc); double[] box = null; string temp = result_str; while (hlts.HasNext()) { box = hlts.GetCurrentQuads(); if (box.Length != 8) { hlts.Next(); continue; } result.Add(new PdfString(result_str, new Rect(box[0], box[1], box[4], box[5]), page_num)); hlts.Next(); } } else if (code == TextSearch.ResultCode.e_done) { break; } } return(result); }
public MainWindow() { InitializeComponent(); textSearch = new TextSearch(); button1.IsEnabled = false; button2.IsEnabled = false; }
private void OnLoaded(object sender, object e) { string[] pictures = Helpers.GetPicturePaths(); PropertyInfo[] props = typeof(Brushes).GetProperties(); List <object> data = new List <object>(17); data.Add(new UI()); for (int i = 0; i < Math.Min(pictures.Length, 8); i++) { data.Add(new Picture(pictures[i])); } for (int i = 0; i < Math.Min(props.Length, 8); i++) { if (props[i].Name != "Transparent") { data.Add(new Swatch(props[i].Name)); } } this.DataContext = _data.ItemsSource = data; // Setup 2 way transitions Transition[] transitions = (Transition[])FindResource("ForwardBackTransitions"); for (int i = 0; i < transitions.Length; i += 2) { ListTransitionSelector selector = new ListTransitionSelector(transitions[i], transitions[i + 1], data); TextSearch.SetText(selector, TextSearch.GetText(transitions[i])); _selectors.Items.Add(selector); } }
public void WrongResultIsExpected() { TextSearch s = new TextSearch("я иду гулять с я иду гулять в я иду гулять на я иду гулять с"); Assert.NotEqual("", s.GetPattern(0, 0)); Assert.NotEqual("иду", s.GetPattern(5, 0)); }
private void LabelSearch_Click(object sender, EventArgs e) { if (sender.Equals(LabelSearch)) { TextSearch.Focus(); } }
public static string GetMapUrl(TextSearch result) { string url = ViewUrl; string param = "key=" + ApiKey; param += "&q=place_id:" + result.Results[0].PlaceId; return(url + param); }
public ActivitiesFilteredComboBox() { //TextSearch.TextPath="Name" TextSearch.SetTextPath(this, "Name"); SelectedValuePath = "GlobalId"; ItemTemplate = (DataTemplate)Application.Current.Resources["ActivitiesComboBoxItem"]; ItemContainerStyle = (Style)Application.Current.Resources["StretchedComboBoxItemStyle"]; }
public void Multiple_Succeeds() { var search = new TextSearch(nameof(Baz.Value1), nameof(Baz.Value2)); var result = search.ApplyToQuery(Bazes().AsQueryable()).ToArray(); result.Length.Should().Be(3); }
public void Succeeds() { var search = new TextSearch(nameof(Item.Value)); var result = search.ApplyToQuery(Items().AsQueryable()).ToArray(); result.Length.Should().Be(3); }
private void init_all() { CollectionView collectionView = (CollectionView)CollectionViewSource.GetDefaultView(items); this.multibox1.ItemsSource = collectionView; multibox1.SelectedValuePath = "nummer"; TextSearch.SetTextPath(this.multibox1, "naam"); }
public ActionResult Index(int?page, string searchStr) { ViewBag.Search = searchStr; var blogList = TextSearch.IndexSearch(searchStr); int pageSize = 3; int pageNumber = (page ?? 1); return(View(blogList.Where(b => b.Published).OrderByDescending(b => b.Created).ToPagedList(pageNumber, pageSize))); }
private void Add2015AndOlder(IDirectoryNameSearch search, IApplicationCollection applications) { IEnumerable <IDirectory> directories = search.FindDirectories(TextSearch.CreatePrefixed("Microsoft Visual Studio")); foreach (IDirectory directory in directories) { TryAdd(applications, directory); } }
public static string GetStreeViewUrl(TextSearch result) { string url = StreeViewUrl; string param = "key=" + ApiKey; param += "&location=" + result.Results[0].Geometry.Location.ToString(); param += "&heading=34&pitch=10"; return(url + param); }
public void RightResultIsExpected() { TextSearch s = new TextSearch("я иду гулять с я иду гулять в я иду гулять на я иду гулять с"); Assert.Equal("я", s.GetPattern(0, 0)); Assert.Equal("я иду", s.GetPattern(0, 1)); Assert.Equal("я иду гулять", s.GetPattern(0, 2)); Assert.Equal("в я", s.GetPattern(7, 8)); }
public void ReturnedStringIsEmpty() { Assert.Equal(String.Empty, _search.GetPattern(1, 0)); Assert.Equal(String.Empty, _search.GetPattern(5, 2)); Assert.Equal(String.Empty, _search.GetPattern(10, 4)); TextSearch s = new TextSearch(""); Assert.Equal(String.Empty, s.GetPattern(0, 0)); }
public void ExpectedOutOfRangeException() { TextSearch s = new TextSearch("я иду гулять с я иду гулять в я иду гулять на я иду гулять с"); Assert.Throws <ArgumentOutOfRangeException>(() => s.GetPattern(-1, 0)); Assert.Throws <ArgumentOutOfRangeException>(() => s.GetPattern(5, 16)); s = new TextSearch(""); Assert.Throws <ArgumentOutOfRangeException>(() => s.GetPattern(0, 1)); }
/// <summary> /// Handles the Closed event of the History popup menu. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="ea">The <see cref="System.EventArgs"/> instance containing the event data.</param> void ClosedHistory(object sender, EventArgs ea) { if (_tabbing == null && IsParentActive()) { if (_intellisense.SelectedValue != null) { // TODO: _console.CurrentCommand = TextSearch.GetText((ListBoxItem)_intellisense.SelectedValue); } } }
public ComplexComponentValueImpl(string value, TextSearch textOperator, SdmxStructureEnumType componentType) { if(componentType.Equals(SdmxStructureEnumType.Dimension) || componentType.Equals(SdmxStructureEnumType.TimeDimension)) throw new SdmxSemmanticException(ExceptionCode.QuerySelectionIllegalOperator); this._value = value; if (textOperator != null) this._textOperator = textOperator; else this._textOperator = TextSearch.GetFromEnum(TextSearchEnumType.Equal); }
protected void btnSearch_ServerClick(object sender, EventArgs e) { string key = this.autocomplete.Value; GooglePlaceService service = new GooglePlaceService(); TextSearch data = service.DoTextSearch(key); if (data.Status.Equals("OK")) { SetViewUrl(data); } }
private void InitializeVariable() { TextSearch = new TextSearch(); SampleTextList = new List <string>(); var samples = File.ReadAllLines(@"./Sample/Sample.txt"); SampleTextList.AddRange(samples); lbSearchBox.Items.Clear(); lbSearchBox.Items.AddRange(samples); }
private TextSearch BuildPropertyText <T>(string property, string inputSearch, string typeComparator) { var criteria = new TextSearch(); criteria.Property = property; criteria.TargetTypeName = typeof(T).AssemblyQualifiedName; criteria.SearchTerm = inputSearch; criteria.Comparator = (TextComparators)Enum.Parse(typeof(TextComparators), typeComparator);; return(criteria); }
public void Child_Succeeds() { Expression <Func <Foo, object> > expression = foo => foo.Bar.Value; var property = expression.ToString(); var search = new TextSearch(property); var result = search.ApplyToQuery(Foos().AsQueryable()).ToArray(); result.Length.Should().Be(2); result[0].Id.Should().Be(4); result[1].Id.Should().Be(5); }
public void Is_Succeeds() { var search = new TextSearch(nameof(Item.Value)) { Term = "Bar" }; var result = search.ApplyToQuery(Items().AsQueryable()).ToArray(); result.Length.Should().Be(1); result[0].Id.Should().Be(2); }
/// <summary> /// Initializes a new instance of the <see cref="ComplexTextReferenceCore"/> class. /// </summary> /// <param name="lang"> /// The lang. /// </param> /// <param name="_operator"> /// The operator. /// </param> /// <param name="searchParam"> /// The search param. /// </param> public ComplexTextReferenceCore(string lang, TextSearch _operator, string searchParam) { this._lang = lang; if (_operator == null) { this._operator = TextSearch.GetFromEnum(TextSearchEnumType.Equal); } else { this._operator = _operator; } if (string.IsNullOrEmpty(searchParam)) { throw new SdmxSemmanticException("Not provided text to search for. It should not be null or empty."); } this._searchParam = searchParam; }
public ComplexDataQueryImpl(string datasetId, TextSearch datasetIdOperator, ISet<IDataProvider> dataProviders, IDataStructureObject dataStructure, IDataflowObject dataFlow, IProvisionAgreementObject provisionAgreement, IList<ITimeRange> lastUpdatedDate, int? firstNObs, int? lastNObs, int? defaultLimit, ObservationAction obsAction, string dimensionAtObservation, bool hasExplicitMeasures, DataQueryDetail queryDetail, ISet<IComplexDataQuerySelection> complexSelections, DateTime dateFrom, OrderedOperator dateFromOperator, DateTime dateTo, OrderedOperator dateToOperator, ISet<IComplexComponentValue> primaryMeasureValues) { this._datasetId = datasetId; if (datasetIdOperator != null) this._datasetIdOperator = datasetIdOperator; else this._datasetIdOperator = TextSearch.GetFromEnum(TextSearchEnumType.Equal); this._dataProviders = dataProviders; base.DataStructure = dataStructure; base.Dataflow = dataFlow; this._provisionAgreement = provisionAgreement; this._lastUpdatedDate = lastUpdatedDate; base.FirstNObservations = firstNObs; base.LastNObservations = lastNObs; this._defaultLimit = defaultLimit; if (obsAction != null) this._obsAction = obsAction; else this._obsAction = ObservationAction.GetFromEnum(ObservationActionEnumType.Active); this.DimensionAtObservation = dimensionAtObservation; if (dimensionAtObservation != null) { //the values: 'AllDimensions' and 'TIME_PERIOD' are valid values. if (dimensionAtObservation.Equals(_allDimensions) || dimensionAtObservation.Equals(DimensionAtObservationEnumType.Time.ToString())) this.DimensionAtObservation = dimensionAtObservation; else//check if the value is a dimension Value CheckDimensionExistence(dimensionAtObservation, dataStructure); } else { this.DimensionAtObservation = GetDimensionAtObservationLevel(dataStructure); } this._hasExplicitMeasures = hasExplicitMeasures; if (queryDetail != null) this._queryDetail = queryDetail; else this._queryDetail = DataQueryDetail.GetFromEnum(DataQueryDetailEnumType.Full); if(ObjectUtil.ValidCollection(complexSelections) || dateFrom != null || dateTo != null) { ISdmxDate sdmxDateFrom = null; if(dateFrom != null) { sdmxDateFrom = new SdmxDateCore(dateFrom, TimeFormatEnumType.Date); } ISdmxDate sdmxDateTo = null; if(dateFrom != null) { sdmxDateTo = new SdmxDateCore(dateTo, TimeFormatEnumType.Date); } this._complexDataQuerySelectionGroups.Add(new ComplexDataQuerySelectionGroupImpl(complexSelections, sdmxDateFrom, dateFromOperator, sdmxDateTo, dateToOperator, primaryMeasureValues)); } //perform validation ValidateQuery(); ValidateProvisionAgreement(); }
/// <summary> /// Parse a text match/search or text/number literal /// </summary> private Element PELiteral(Block Parent) { if (_caret.WS().Match(@"(?<begin>(?<_skw>(?<find>Find|F)|(?<findrev>FindReverse|FR)|(?<regex>RegEx|RE)|(?<fregex>FindRegEx|FRE))?"")")) { var ts = new TextSearch(); ts.Annotation.SourcePosition.Begin = _caret.LastMatch.Groups["begin"].Index; //Get the type bool regex_find = false; if (_caret.LastMatch.Groups["find"].Value != "") ts.Type = TextSearch.eType.Find; else if (_caret.LastMatch.Groups["findrev"].Value != "") ts.Type = TextSearch.eType.FindReverse; else if (_caret.LastMatch.Groups["regex"].Value != "") ts.Type = TextSearch.eType.RegularExpression; else if (_caret.LastMatch.Groups["fregex"].Value != "") { ts.Type = TextSearch.eType.RegularExpression; regex_find = true; } else ts.Type = TextSearch.eType.Normal; //Escape "" => " _caret.Match(@"(?<_tm>(""""|[^""])*)(?<close>""|$)"); if (_caret.LastMatch.Groups["close"].Length == 0) ThrowParseError("Expecting trailing \"", 10); string pattern = _caret.LastMatch.Groups["_tm"].Value.Replace(@"""""", @""""), display_pattern = pattern; TextPortion tp = _caret.LastMatch.Groups["_tm"]; tp.Text = _caret.Source; ts.Annotation.SourcePosition.End = _caret.LastMatch.Index + _caret.LastMatch.Length; if (ts.Type == TextSearch.eType.RegularExpression) { //We prepend with \G to enforce to match at current position if (!regex_find) pattern = string.Format(@"\G(?:{0})", pattern); //Try to compile the regex string regex_error = null; if (CompiledRegExErrors.ContainsKey(pattern)) regex_error = CompiledRegExErrors[pattern]; else try { new Regex(pattern); } catch (Exception ex) { regex_error = ex.Message; } finally { CompiledRegExErrors.Add(pattern, regex_error); } if (regex_error != null) ThrowParseError("Could not parse regular expression: " + regex_error, ts.Annotation.SourcePosition); } else //Escape characters pattern = PELEscape(tp, '"'); ts.Pattern = new Literal(pattern, display_pattern); //See if we request only for a sub tree if (_caret.Match(@"\.")) { PESubTree(Parent, ts.Tree); ts.Annotation.SourcePosition.End = _caret.LastMatch.Index + _caret.LastMatch.Length; switch (ts.Type) { case TextSearch.eType.RegularExpression: if (ts.Tree.Count != 0) { var nKey = ts.Tree[0]; var lKey = nKey.Key as Literal; if ((ts.Tree.Count > 1) || (lKey == null) || (lKey.Type != Literal.eType.Text) || (StringComparer.OrdinalIgnoreCase.Compare(lKey.Text, "Group") != 0)) ThrowParseError("'Group' is the only valid sub tree", ts.Annotation.SourcePosition); else if (nKey.Type == TreeNode.eType.New) ThrowParseError("No point in creating a new subtree"); } break; default: ThrowParseError("Only regular expressionys return trees", ts.Annotation.SourcePosition); break; } } return ts; } //A text literal else if (_caret.WS().Match(@"'")) { var tl = new Literal(); tl.Type = Literal.eType.Text; tl.Annotation.SourcePosition.Begin = _caret.LastMatch.Index; //Escape '' => ' _caret.Match(@"(?<_lit>(''|[^'])*)(?<close>'|$)"); if (_caret.LastMatch.Groups["close"].Length == 0) ThrowParseError("Expecting trailing '", 10); tl.AssemblyDisplayText = _caret.LastMatch.Groups["_lit"].Value.Replace("''", "'"); tl.Annotation.SourcePosition.End = _caret.LastMatch.Index + _caret.LastMatch.Length; //Escape characters TextPortion tp = _caret.LastMatch.Groups["_lit"]; tp.Text = _caret.Source; tl.Text = PELEscape(tp, '\''); return tl; } //A number literal else if (_caret.WS().Match(@"(?<_lit>-?\d+)")) { var tl = new Literal(); tl.Type = Literal.eType.Number; tl.Annotation.SourcePosition = _caret.LastMatch; if (!int.TryParse(_caret.LastMatch.Value, out tl.Number)) ThrowParseError("Expected an integer"); return tl; } else return null; }
/// <summary> /// Resolve undefined function calls by looking in the imported and predefined functions /// </summary> private void ResolveUndefinedFunctionCalls() { //Update ChangeParentInfo foreach (var fun in Functions) fun.Block.UpdateChildrenParentInfo(); foreach (var ufc in UndefinedFunctionCalls) if (ImportedFunctions.ContainsKey(ufc.Key)) //Look in the Imported Functions { ufc.Value.Update(ImportedFunctions[ufc.Key]); Functions.Add(ImportedFunctions[ufc.Key]); } else if (PredefinedFunctions.ContainsKey(ufc.Key)) //Look in the Predefined Functions { var fn = PredefinedFunctions[ufc.Key]; foreach (var fc in ufc.Value.Items) if (fc.Arguments.Count != fn.ArgumentsCount) //The signatures must match ThrowParseError("Function " + fn.Name + " takes " + fn.ArgumentsCount + " arguments, not " + fc.Arguments.Count, fc.Annotation.SourcePosition); else //Update valid calls { if (fn == PredefinedFunctions["Match"]) { var ts = new TextSearch(); ts.Pattern = fc.Arguments[0]; ts.Type = TextSearch.eType.Normal; ts.Annotation.CopyFrom(fc.Annotation); ts.Quantifier = fc.Quantifier; AddSourceCodeAnnotation(ts); fc.ChangeInParent(ts); } else if (fn == PredefinedFunctions["Find"]) { var ts = new TextSearch(); ts.Pattern = fc.Arguments[0]; ts.Type = TextSearch.eType.Find; ts.Annotation.CopyFrom(fc.Annotation); ts.Quantifier = fc.Quantifier; AddSourceCodeAnnotation(ts); fc.ChangeInParent(ts); } else if (fn == PredefinedFunctions["FindReverse"]) { var ts = new TextSearch(); ts.Pattern = fc.Arguments[0]; ts.Type = TextSearch.eType.FindReverse; ts.Annotation.CopyFrom(fc.Annotation); ts.Quantifier = fc.Quantifier; AddSourceCodeAnnotation(ts); fc.ChangeInParent(ts); } else if (fn == PredefinedFunctions["Line"]) { //Convert to {F"\r\n" Skipped, Source != '' FRE"$" Skipped} var blp = new Block(); blp.Annotation.IDE = IDE; blp.Type = Block.eType.Multi; var bl = new Block(); bl.Annotation.IDE = IDE; blp.Elements.Add(bl); var ts = new TextSearch(); ts.Annotation.IDE = IDE; ts.Pattern = new Literal("\r\n"); ts.Type = TextSearch.eType.Find; bl.Elements.Add(ts); var vr = new Variable(); vr.Annotation.IDE = IDE; vr.Type = Variable.eType.Skipped; bl.Elements.Add(vr); bl = new Block(); bl.Annotation.IDE = IDE; blp.Elements.Add(bl); var op = new BinaryOperator(); op.Annotation.IDE = IDE; op.Type = BinaryOperator.eType.NotEqual; bl.Elements.Add(op); vr = new Variable(); vr.Annotation.IDE = IDE; vr.Type = Variable.eType.Source; op.lhs = vr; var lt = new Literal(""); lt.Annotation.IDE = IDE; op.rhs = lt; ts = new TextSearch(); ts.Annotation.IDE = IDE; ts.Pattern = new Literal("$"); ts.Type = TextSearch.eType.RegularExpression; bl.Elements.Add(ts); vr = new Variable(); vr.Annotation.IDE = IDE; vr.Type = Variable.eType.Skipped; bl.Elements.Add(vr); blp.UpdateChildrenParentInfo(); blp.Annotation.CopyFrom(fc.Annotation); blp.Quantifier = fc.Quantifier; AddSourceCodeAnnotation(blp); fc.ChangeInParent(blp); } else if (fn == PredefinedFunctions["Paragraph"]) { //Convert to {"\r\n"* F"\r\n\r\n" Skipped & {"\r\n"* ''}, "\r\n"* Source != '' FRE"$" Skipped} var blp = new Block(); blp.Annotation.IDE = IDE; blp.Type = Block.eType.Multi; var bl = new Block(); bl.Annotation.IDE = IDE; blp.Elements.Add(bl); var ts = new TextSearch(); ts.Annotation.IDE = IDE; ts.Pattern = new Literal("\r\n"); ts.Type = TextSearch.eType.Normal; ts.Quantifier.Min = 0; ts.Quantifier.Max = -1; bl.Elements.Add(ts); ts = new TextSearch(); ts.Annotation.IDE = IDE; ts.Pattern = new Literal("\r\n\r\n"); ts.Type = TextSearch.eType.Find; bl.Elements.Add(ts); var op = new BinaryOperator(); op.Annotation.IDE = IDE; op.Type = BinaryOperator.eType.TextAppend; bl.Elements.Add(op); var vr = new Variable(); vr.Annotation.IDE = IDE; vr.Type = Variable.eType.Skipped; op.lhs = vr; var bl2 = new Block(); bl2.Annotation.IDE = IDE; op.rhs = bl2; ts = new TextSearch(); ts.Annotation.IDE = IDE; ts.Pattern = new Literal("\r\n"); ts.Type = TextSearch.eType.Normal; ts.Quantifier.Min = 0; ts.Quantifier.Max = -1; bl2.Elements.Add(ts); var lt = new Literal(""); lt.Annotation.IDE = IDE; bl2.Elements.Add(lt); bl = new Block(); bl.Annotation.IDE = IDE; blp.Elements.Add(bl); ts = new TextSearch(); ts.Annotation.IDE = IDE; ts.Pattern = new Literal("\r\n"); ts.Type = TextSearch.eType.Normal; ts.Quantifier.Min = 0; ts.Quantifier.Max = -1; bl.Elements.Add(ts); op = new BinaryOperator(); op.Annotation.IDE = IDE; op.Type = BinaryOperator.eType.NotEqual; bl.Elements.Add(op); vr = new Variable(); vr.Annotation.IDE = IDE; vr.Type = Variable.eType.Source; op.lhs = vr; lt = new Literal(""); lt.Annotation.IDE = IDE; op.rhs = lt; ts = new TextSearch(); ts.Annotation.IDE = IDE; ts.Pattern = new Literal("$"); ts.Type = TextSearch.eType.RegularExpression; bl.Elements.Add(ts); vr = new Variable(); vr.Annotation.IDE = IDE; vr.Type = Variable.eType.Skipped; bl.Elements.Add(vr); blp.UpdateChildrenParentInfo(); blp.Annotation.CopyFrom(fc.Annotation); blp.Quantifier = fc.Quantifier; AddSourceCodeAnnotation(blp); fc.ChangeInParent(blp); } } } else //It is not defined foreach (var fc in ufc.Value.Items) ThrowParseError("'" + fc.Name + "' function not defined", fc.Annotation.SourcePosition); }
/// <summary> /// Gets SQL operator from the given SDMX OrderedOperator /// </summary> /// <param name="ord"> /// The OrderedOperator /// </param> /// <returns> /// An string containing the sql query ordered operator /// </returns> private static string GetSqlTextSearchOperator(TextSearch ord) { switch (ord.EnumType) { case TextSearchEnumType.Contains: return "LIKE %value%"; case TextSearchEnumType.DoesNotContain: return "NOT LIKE %value%"; case TextSearchEnumType.DoesNotEndWith: return "NOT LIKE %value"; case TextSearchEnumType.DoesNotStartWith: return "NOT LIKE value%"; case TextSearchEnumType.EndsWith: return "LIKE %value"; case TextSearchEnumType.Equal: return "="; case TextSearchEnumType.NotEqual: return "!="; case TextSearchEnumType.StartsWith: return "LIKE value%"; default: break; } return "="; }
public ComplexDataQueryImpl(string datasetId, TextSearch datasetIdOperator, ISet<IDataProvider> dataProviders, IDataStructureObject dataStructure, IDataflowObject dataFlow, IProvisionAgreementObject provisionAgreement, IList<ITimeRange> lastUpdatedDate, int? maxObs, int? defaultLimit, bool orderAsc, ObservationAction obsAction, string dimensionAtObservation, bool hasExplicitMeasures, DataQueryDetail queryDetail, ICollection<IComplexDataQuerySelectionGroup> complexDataQuerySelectionGroup) { this._datasetId = datasetId; if (datasetIdOperator != null) this._datasetIdOperator = datasetIdOperator; else this._datasetIdOperator = TextSearch.GetFromEnum(TextSearchEnumType.Equal); if (dataProviders != null) { this._dataProviders = new HashSet<IDataProvider>(dataProviders); } base.DataStructure = dataStructure; base.Dataflow = dataFlow; this._provisionAgreement = provisionAgreement; if(lastUpdatedDate != null) { this._lastUpdatedDate = new List<ITimeRange>(lastUpdatedDate); } if (orderAsc) base.FirstNObservations = maxObs; else base.LastNObservations = maxObs; this._defaultLimit = defaultLimit; if (obsAction!=null) this._obsAction = obsAction; else this._obsAction = ObservationAction.GetFromEnum(ObservationActionEnumType.Active); this.DimensionAtObservation = dimensionAtObservation; if (dimensionAtObservation != null) { //the values: 'AllDimensions' and 'TIME_PERIOD' are valid values. if (dimensionAtObservation.Equals(_allDimensions) || dimensionAtObservation.Equals(DimensionAtObservationEnumType.Time.ToString())) this.DimensionAtObservation = dimensionAtObservation; else //check if the value is a dimension Value CheckDimensionExistence(dimensionAtObservation, dataStructure); } else { this.DimensionAtObservation = GetDimensionAtObservationLevel(dataStructure); } this._hasExplicitMeasures = hasExplicitMeasures; if (queryDetail != null) this._queryDetail = queryDetail; else this._queryDetail = DataQueryDetail.GetFromEnum(DataQueryDetailEnumType.Full); if (complexDataQuerySelectionGroup != null) { foreach (IComplexDataQuerySelectionGroup cdqsg in complexDataQuerySelectionGroup) { if (cdqsg != null) { this._complexDataQuerySelectionGroups.Add(cdqsg); } } } //perform validation ValidateQuery(); ValidateProvisionAgreement(); }