mergedServices.SPARQLQueryBuilder.connectedViaAMiddleObject C# (CSharp) Méthode

connectedViaAMiddleObject() private méthode

Return a set of queries to find relations between two objects which are connected via a middle objects $dist1 and $dist2 give the distance between the first and second object to the middle they have ti be greater that 1
private connectedViaAMiddleObject ( string first, string second, int dist1, int dist2, bool toObject, Dictionary options ) : string
first string 1stobject
second string 2ndobject
dist1 int distance between 1obj and the middle object
dist2 int distance between 2obj and the middle object
toObject bool if $toObject is true then: /// PATTERN DIST1 DIST2 /// first-->?middle<--second 1 1 /// first-->?of1-->?middle<--second 2 1 /// first-->?middle<--?os1<--second 1 2 /// first-->?of1-->middle<--?os1<--second 2 2 /// first-->?of1-->?of2-->middle<--second 3 1 /// /// if $toObject is false then (reverse arrows) /// first<--?middle-->second
options Dictionary options All options like ignoredProperties, etc. are passed via this array (needed for filters)
Résultat string
        private string connectedViaAMiddleObject(string first, string second, int dist1, int dist2, bool toObject, Dictionary<string, List<string>> options)
        {
            Dictionary<string, List<string>> vars = new Dictionary<string, List<string>>();
            vars["pred"] = new List<string>();
            vars["obj"] = new List<string>();
            vars["obj"].Add("?middle");

            string fs = "f";
            int tmpdist = dist1;
            int twice = 0;
            string coreQuery = "";
            string oobject = first;

            while (twice < 2)
            {

                if (tmpdist == 1)
                {
                    coreQuery += toPattern(uri(oobject), "?p" + fs + "1", "?middle", toObject);
                    vars["pred"].Add("?p" + fs + "1");
                }
                else
                {
                    coreQuery += toPattern(uri(oobject), "?p" + fs + "1", "?o" + fs + "1", toObject);
                    vars["pred"].Add("?p" + fs + "1");

                    for (int x = 1; x < tmpdist; x++)
                    {
                        string s = "?o" + fs + "" + x;
                        string p = "?p" + fs + "" + (x + 1);
                        vars["obj"].Add(s);
                        vars["pred"].Add(p);
                        if ((x + 1) == tmpdist)
                        {
                            coreQuery += toPattern(s, p, "?middle", toObject);
                        }
                        else
                        {
                            coreQuery += toPattern(s, p, "?o" + fs + "" + (x + 1), toObject);
                        }
                    }
                }
                twice++;
                fs = "s";
                tmpdist = dist2;
                oobject = second;

            }//end while

            return completeQuery(coreQuery, options, vars);
        }