mergedServices.SPARQLQueryBuilder.generateFilter C# (CSharp) Method

generateFilter() private method

generates the necessary Filters
private generateFilter ( Dictionary options, Dictionary vars ) : string
options Dictionary The options Dictionary
vars Dictionary The vars Dictionary
return string
        private string generateFilter(Dictionary<string, List<string>> options, Dictionary<string, List<string>> vars)
        {
            //var filterterms:ArrayCollection = new ArrayCollection();
            var filterterms = new List<string>();
            foreach (string pred in vars["pred"])
            {
                // ignore properties

                if ((options != null) && (options.Keys.Contains("ignoredProperties")) && options["ignoredProperties"] != null && (options["ignoredProperties"] != null) && (options["ignoredProperties"].Count > 0))
                {
                    foreach (string ignored in (options["ignoredProperties"]))
                    {
                        filterterms.Add(pred + " != " + uri(ignored) + " ");
                    }
                }

            }
            foreach (string obj in (vars["obj"]))
            {
                // ignore literals
                filterterms.Add("!isLiteral(" + obj + ")");
                // ignore objects
                if ((options != null) && (options.Keys.Contains("ignoredObjects")) && options["ignoredObjects"] != null && (options["ignoredObjects"] != null) && (options["ignoredObjects"].Count > 0))
                {
                    foreach (string ignored2 in (options["ignoredObjects"]))
                    {
                        filterterms.Add(obj + " != " + uri(ignored2) + " ");
                    }
                }

                if ((options != null) && options.Keys.Contains("avoidCycles") && (options["avoidCycles"] != null))
                {
                    // object variables should not be the same as object1 or object2
                    if (options["avoidCycles"].Count > 0)
                    {
                        filterterms.Add(obj + " != " + uri(listToString(options["object1"])) + " ");
                        filterterms.Add(obj + " != " + uri(listToString(options["object2"])) + " ");
                    }
                    // object variables should not be the same as any other object variables
                    if (options["avoidCycles"].Count > 1)
                    {
                        foreach (string otherObj in (vars["obj"]))
                        {
                            if (obj != otherObj)
                            {
                                filterterms.Add(obj + " != " + otherObj + " ");
                            }
                        }
                    }
                }
            }

            if (filterterms.Count == 0)
            {
                return "";
            }

            return "FILTER " + expandTerms(filterterms, "&&") + ". ";
        }