protected override RuleResult processQueryPart(SplittingQuery.Part part) { if (part == null) { return(null); } if (string.IsNullOrWhiteSpace(this.ReplaceWith)) { return(null); // new RuleResult(SplittingQuery.SplitQuery(" "), this.NextStep); } if ( //this.ReplaceWith.Contains("${q}") && part.Prefix.Equals(_prefix, StringComparison.InvariantCultureIgnoreCase) && ( string.IsNullOrWhiteSpace(_valueConstrain) || Regex.IsMatch(part.Value, _valueConstrain, HlidacStatu.Util.Consts.DefaultRegexQueryOption) ) ) { string rq = " " + ReplaceWith.Replace("${q}", part.Value); return(new RuleResult(SplittingQuery.SplitQuery($" {rq} "), this.NextStep)); } return(null); }
protected override RuleResult processQueryPart(SplittingQuery.Part part) { if (part == null) { return(null); } if ( ( (!string.IsNullOrWhiteSpace(_specificPrefix) && part.Prefix.Equals(_specificPrefix, StringComparison.InvariantCultureIgnoreCase)) || (part.Prefix.Equals("osobaid:", StringComparison.InvariantCultureIgnoreCase) || part.Prefix.Equals("osobaidprijemce:", StringComparison.InvariantCultureIgnoreCase) || part.Prefix.Equals("osobaidplatce:", StringComparison.InvariantCultureIgnoreCase) || part.Prefix.Equals("osobaidveritel:", StringComparison.InvariantCultureIgnoreCase) || part.Prefix.Equals("osobaidveritel:", StringComparison.InvariantCultureIgnoreCase) || part.Prefix.Equals("osobaidspravce:", StringComparison.InvariantCultureIgnoreCase) || part.Prefix.Equals("osobaidzadavatel:", StringComparison.InvariantCultureIgnoreCase) || part.Prefix.Equals("osobaiddodavatel:", StringComparison.InvariantCultureIgnoreCase) ) ) && (Regex.IsMatch(part.Value, @"(?<q>((\w{1,} [-]{1} \w{1,})([-]{1} \d{1,3})?))", HlidacStatu.Util.Consts.DefaultRegexQueryOption)) ) { if (!string.IsNullOrWhiteSpace(this.ReplaceWith)) { //list of ICO connected to this person string nameId = part.Value; Data.Osoba p = Data.Osoby.GetByNameId.Get(nameId); string icosQuery = ""; //string icoprefix = replaceWith; var templ = $" ( {ReplaceWith}{{0}} ) "; if (ReplaceWith.Contains("${q}")) { templ = $" ( {ReplaceWith.Replace("${q}", "{0}")} )"; } if (p != null) { var icos = p .AktualniVazby(Data.Relation.AktualnostType.Nedavny) .Where(w => !string.IsNullOrEmpty(w.To.Id)) //.Where(w => Analysis.ACore.GetBasicStatisticForICO(w.To.Id).Summary.Pocet > 0) .Select(w => w.To.Id) .Distinct().ToArray(); if (icos != null && icos.Length > 0) { icosQuery = " ( " + icos .Select(t => string.Format(templ, t)) .Aggregate((f, s) => f + " OR " + s) + " ) "; } else { icosQuery = string.Format(templ, "noOne"); //$" ( {icoprefix}:noOne ) "; } bool lastCondAdded = false; if (!string.IsNullOrEmpty(this.AddLastCondition)) { if (this.AddLastCondition.Contains("${q}")) { icosQuery = Tools.ModifyQueryOR(icosQuery, this.AddLastCondition.Replace("${q}", part.Value)); } else { icosQuery = Tools.ModifyQueryOR(icosQuery, this.AddLastCondition); } lastCondAdded = true; //this.AddLastCondition = null; //done, don't do it anywhere } return(new RuleResult(SplittingQuery.SplitQuery($"{icosQuery}"), this.NextStep, lastCondAdded)); } } // if (!string.IsNullOrWhiteSpace(this.ReplaceWith)) else if (!string.IsNullOrWhiteSpace(this.AddLastCondition)) { if (this.AddLastCondition.Contains("${q}")) { var q = this.AddLastCondition.Replace("${q}", part.Value); return(new RuleResult(SplittingQuery.SplitQuery(q), this.NextStep, true)); } else { var q = this.AddLastCondition; return(new RuleResult(SplittingQuery.SplitQuery(q), this.NextStep, true)); } } } return(null); }