示例#1
0
        protected override RuleResult processQueryPart(SplittingQuery.Part part)
        {
            if (part == null)
            {
                return(null);
            }

            if (part.Prefix.Equals("chyby:", StringComparison.InvariantCultureIgnoreCase))
            {
                string levelVal = part.Value;
                string levelQ   = "";
                if (levelVal == "fatal" || levelVal == "zasadni")
                {
                    levelQ = Lib.Issues.Util.IssuesByLevelQuery(Lib.Issues.ImportanceLevel.Fatal);
                }
                else if (levelVal == "major" || levelVal == "vazne")
                {
                    levelQ = Lib.Issues.Util.IssuesByLevelQuery(Lib.Issues.ImportanceLevel.Major);
                }


                return(new RuleResult(SplittingQuery.SplitQuery($" {levelQ} "), this.NextStep));
            }
            return(null);//new RuleResult(part, this.NextStep);
        }
示例#2
0
        protected override RuleResult processQueryPart(SplittingQuery.Part part)
        {
            if (part == null)
            {
                return(null);
            }

            if (part.Prefix.Equals("form:", StringComparison.InvariantCultureIgnoreCase))
            {
                string form = part.Value;

                if (!string.IsNullOrEmpty(form))
                {
                    string[] forms  = form.Split(new char[] { ',', ';', '|' }, StringSplitOptions.RemoveEmptyEntries);
                    string   q_form = "";
                    if (forms.Length > 0)
                    {
                        q_form = "formulare.druh:(" + forms.Select(s => s + "*").Aggregate((f, s) => f + " OR " + s) + ")";
                    }

                    return(new RuleResult(SplittingQuery.SplitQuery($" ( {q_form} ) "), this.NextStep));
                }
            }


            return(null);
        }
        protected override RuleResult processQueryPart(SplittingQuery.Part part)
        {
            if (part == null)
            {
                return(null);
            }

            if (!string.IsNullOrEmpty(part.Prefix))
            {
                return(new RuleResult(SplittingQuery.SplitQuery($""), this.NextStep));
            }
            else
            {
                if (
                    part.ExactValue == false &&
                    Searching.Tools.DefaultQueryOperators.Contains(part.Value.Trim().ToUpper())
                    )
                {
                    return(new RuleResult(SplittingQuery.SplitQuery($""), this.NextStep));
                }
            }


            return(null);
        }
示例#4
0
        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);
        }
示例#5
0
        protected override RuleResult processQueryPart(SplittingQuery.Part part)
        {
            if (part == null)
            {
                return(null);
            }

            if (part.Prefix.Equals("kategorieid:", StringComparison.InvariantCultureIgnoreCase))
            {
                var katId = part.Value;
                foreach (var key in AllValues.Keys)
                {
                    if (katId.Equals(key.ToString(), StringComparison.InvariantCultureIgnoreCase))
                    {
                        string icosQuery = " ( " + AllValues[key]
                                           .Select(t => $"ico:{t}")
                                           .Aggregate((f, s) => f + " OR " + s) + " ) ";
                        return(new RuleResult(SplittingQuery.SplitQuery($"{icosQuery}"), this.NextStep));
                    }
                }
            }


            return(null);
        }
示例#6
0
        protected override RuleResult processQueryPart(SplittingQuery.Part part)
        {
            if (!string.IsNullOrEmpty(ReplaceWith) &&
                (
                    string.IsNullOrWhiteSpace(_valueConstrain) ||
                    Regex.IsMatch(part.Value, part.ToQueryString, HlidacStatu.Util.Consts.DefaultRegexQueryOption)
                )
                )
            {
                string rq = Regex.Replace(part.ToQueryString, this.ReplaceWith, ruleEvalMatch, HlidacStatu.Util.Consts.DefaultRegexQueryOption);
                return(new RuleResult(SplittingQuery.SplitQuery($" {rq} "), this.NextStep));
            }

            return(null);
        }
示例#7
0
        protected override RuleResult processQueryPart(SplittingQuery.Part part)
        {
            if (part == null)
            {
                return(null);
            }

            if (part.Prefix.Equals("cpv:", StringComparison.InvariantCultureIgnoreCase))
            {
                string cpv = "";
                //Match m = Regex.Match(modifiedQ, lookFor, regexQueryOption);
                //string cpv = "";
                //if (m.Success)
                //    cpv = m.Groups["q"].Value;
                cpv = part.Value;
                if (!string.IsNullOrEmpty(cpv))
                {
                    string[] cpvs  = cpv.Split(new char[] { ',', ';', '|' }, StringSplitOptions.RemoveEmptyEntries);
                    string   q_cpv = "";

                    if (cpvs.Length == 0)
                    {
                        return(null);
                    }
                    if (cpvs.Length == 1)
                    {
                        if (cpvs[0].EndsWith("*"))
                        {
                            return(null);
                        }
                        else
                        {
                            q_cpv = " cPV:" + cpvs[0] + "* ";
                        }
                    }
                    else if (cpvs.Length > 1)
                    {
                        q_cpv = " ( " + cpvs.Select(s => "cPV:" + s + "*").Aggregate((f, s) => f + " OR " + s) + " ) ";
                    }

                    return(new RuleResult(SplittingQuery.SplitQuery($" {q_cpv} "), this.NextStep));
                }
            }


            return(null);// new RuleResult(part, this.NextStep);
        }
示例#8
0
        protected override RuleResult processQueryPart(SplittingQuery.Part part)
        {
            if (part == null)
            {
                return(null);
            }

            if (part.Prefix.Equals("oblast:", StringComparison.InvariantCultureIgnoreCase))
            {
                var oblastVal = part.Value;
                var cpvs      = Lib.Data.VZ.VerejnaZakazka.Searching.CPVOblastToCPV(oblastVal);
                if (cpvs != null)
                {
                    //var q_cpv = "cPV:(" + cpvs.Select(s => s + "*").Aggregate((f, s) => f + " OR " + s) + ")";
                    var q_cpv = " ( " + cpvs.Select(s => "cPV:" + s + "*").Aggregate((f, s) => f + " OR " + s) + " ) ";
                    return(new RuleResult(SplittingQuery.SplitQuery($" {q_cpv} "), this.NextStep));
                }
            }


            return(null);
        }
示例#9
0
        protected override RuleResult processQueryPart(SplittingQuery.Part part)
        {
            if (part == null)
            {
                return(null);
            }

            if (part.Prefix.Equals("oblast:", StringComparison.InvariantCultureIgnoreCase))
            {
                var oblastVal = part.Value;
                foreach (var key in AllValues.Keys)
                {
                    if (oblastVal.Equals(key, StringComparison.InvariantCultureIgnoreCase))
                    {
                        var q_obl = "classification.types.typeValue:" + AllValues[key];
                        return(new RuleResult(SplittingQuery.SplitQuery($" {q_obl} "), this.NextStep));
                    }
                }
            }


            return(null);
        }
示例#10
0
        public virtual RuleResult Process(SplittingQuery.Part queryPart)
        {
            var res = processQueryPart(queryPart);

            if (res != null && res.LastConditionAdded == false && !string.IsNullOrEmpty(this.AddLastCondition))
            {
                string rq = this.AddLastCondition;
                if (this.AddLastCondition.Contains("${q}"))
                {
                    rq = this.AddLastCondition.Replace("${q}", queryPart.Value);
                }
                if (res != null)
                {
                    rq = Query.ModifyQueryOR(res.Query.FullQuery(), rq);
                }

                return(new RuleResult(SplittingQuery.SplitQuery($" {rq} "), this.NextStep));
            }



            return(res);
        }
示例#11
0
        protected override RuleResult processQueryPart(SplittingQuery.Part part)
        {
            if (part == null)
            {
                return(null);
            }

            if (
                (!string.IsNullOrWhiteSpace(_specificPrefix) && part.Prefix.Equals(_specificPrefix, StringComparison.InvariantCultureIgnoreCase))
                ||
                (string.IsNullOrWhiteSpace(_specificPrefix) &&
                 (part.Prefix.Equals("holding:", StringComparison.InvariantCultureIgnoreCase)
                  //RS
                  || part.Prefix.Equals("holdingprijemce:", StringComparison.InvariantCultureIgnoreCase) ||
                  part.Prefix.Equals("holdingplatce:", StringComparison.InvariantCultureIgnoreCase)
                  //insolvence
                  || part.Prefix.Equals("holdingdluznik:", StringComparison.InvariantCultureIgnoreCase) ||
                  part.Prefix.Equals("holdingveritel:", StringComparison.InvariantCultureIgnoreCase) ||
                  part.Prefix.Equals("holdingspravce:", StringComparison.InvariantCultureIgnoreCase)
                  //VZ
                  || part.Prefix.Equals("holdingdodavatel:", StringComparison.InvariantCultureIgnoreCase) ||
                  part.Prefix.Equals("holdingzadavatel:", StringComparison.InvariantCultureIgnoreCase)
                 )
                )
                )
            {
                //list of ICO connected to this holding
                string holdingIco = part.Value;
                HlidacStatu.Lib.Data.Relation.AktualnostType aktualnost = HlidacStatu.Lib.Data.Relation.AktualnostType.Nedavny;
                Data.Firma f = Data.Firmy.Get(holdingIco);
                if (f != null && f.Valid)
                {
                    var icos = new string[] { f.ICO }
                    .Union(
                        f.AktualniVazby(aktualnost)
                        .Select(s => s.To.Id)
                        )
                    .Distinct();

                    string icosQuery    = "";
                    var    icosPresLidi = f.AktualniVazby(aktualnost)
                                          .Where(o => o.To.Type == Data.Graph.Node.NodeType.Person)
                                          .Select(o => Data.Osoby.GetById.Get(Convert.ToInt32(o.To.Id)))
                                          .Where(o => o != null)
                                          .SelectMany(o => o.AktualniVazby(aktualnost))
                                          .Select(v => v.To.Id)
                                          .Distinct();
                    icos = icos.Union(icosPresLidi).Distinct();

                    var templ = $" ( {this.ReplaceWith}{{0}} ) ";
                    if (this.ReplaceWith.Contains("${q}"))
                    {
                        templ = $" ( {this.ReplaceWith.Replace("${q}", "{0}")} )";
                    }

                    if (icos != null && icos.Count() > 0)
                    {
                        icosQuery = " ( " + icos
                                    .Select(t => string.Format(templ, t))
                                    .Aggregate((fi, s) => fi + " OR " + s) + " ) ";
                    }
                    else
                    {
                        icosQuery = string.Format(templ, "noOne"); //$" ( {icoprefix}:noOne ) ";
                    }

                    return(new RuleResult(SplittingQuery.SplitQuery($"{icosQuery}"), this.NextStep));
                }
            }

            return(null);
        }
示例#12
0
        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);
        }
示例#13
0
 protected abstract RuleResult processQueryPart(SplittingQuery.Part queryPart);
示例#14
0
 public RuleResult(SplittingQuery.Part queryPart, NextStepEnum nextStep, bool lastConditionAdded = false)
 {
     this.Query              = new SplittingQuery(new[] { queryPart });
     this.NextStep           = nextStep;
     this.LastConditionAdded = lastConditionAdded;
 }