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

getQueries() private méthode

Return a set of queries to find relations between two objects.
private getQueries ( string object1, string object2, int distance, int limit, List ignoredObjects = null, List ignoredProperties = null, int avoidCycles ) : List>.Dictionary
object1 string First object
object2 string Second object
distance int maxDistance The maximum distance up to which we want to search
limit int limit The maximum number of results per SPARQL query (=LIMIT).
ignoredObjects List Objects which should not be part of the returned connections between the first and second object
ignoredProperties List Properties which should not be part of the returned connections between the first and second object
avoidCycles int Integer value which indicates whether we want to suppress cycles , 0 = no cycle avoidance , 1 = no intermediate object can be object1 or object2 , 2 = like 1 + an object can not occur more than once in a connection
Résultat List>.Dictionary
        private Dictionary<int, List<InnerQuery>> getQueries(string object1, string object2, int distance, int limit, List<string> ignoredObjects = null, List<string> ignoredProperties = null, int avoidCycles = 0)
        {
            Dictionary<int, List<InnerQuery>> queries = new Dictionary<int, List<InnerQuery>>();
            Dictionary<string, List<string>> options = new Dictionary<string, List<string>>();

            //May generate null
            options["object1"] = stringToLoist(object1);
            options["object2"] = stringToLoist(object2);
            options["limit"] = stringToLoist(limit.ToString());
            options["ignoredObjects"] = ignoredObjects;
            options["ignoredProperties"] = ignoredProperties;
            options["avoidCycles"] = stringToLoist(avoidCycles.ToString());

            // get direct connection in both directions
            //queries[distance] = new ArrayCollection();
            //(queries[distance] as ArrayCollection).addItem(new Array(direct(object1, object2, distance, options), connectedDirectly));
            //(queries[distance] as ArrayCollection).addItem(new Array(direct(object2, object1, distance, options), connectedDirectlyInverted));
            //we substitiued ArrayCollection with a list and passed the list to the dictionary
            var tempList = new List<InnerQuery>();
            var tempInnerQuery = new InnerQuery();
            tempInnerQuery.queryText = direct(object1, object2, distance, options);
            tempInnerQuery.connectState = connectionType.connectedDirectly;
            tempInnerQuery.object1 = object1;
            tempInnerQuery.object2 = object2;
            tempList.Add(tempInnerQuery);

            tempInnerQuery = new InnerQuery();
            tempInnerQuery.queryText = direct(object2, object1, distance, options);
            tempInnerQuery.connectState = connectionType.connectedDirectlyInverted;
            tempInnerQuery.object1 = object2;
            tempInnerQuery.object2 = object1;
            tempList.Add(tempInnerQuery);

            //queries.Add(distance, tempList);
            //ended substitution

            for (int a = 1; a <= distance; a++)
            {
                for (int b = 1; b <= distance; b++)
                {
                    if ((a + b) == distance)
                    {

                        //(queries[distance] as ArrayCollection).addItem(new Array(connectedViaAMiddleObject(object1, object2, a, b, true,  options), connectedViaMiddle));
                        //tempList = new List<InnerQuery>();
                        tempInnerQuery = new InnerQuery();
                        tempInnerQuery.queryText = connectedViaAMiddleObject(object1, object2, a, b, true, options);
                        tempInnerQuery.connectState = connectionType.connectedViaMiddle;
                        tempInnerQuery.object1 = object1;
                        tempInnerQuery.object2 = object2;
                        tempList.Add(tempInnerQuery);

                        tempInnerQuery = new InnerQuery();
                        tempInnerQuery.queryText = connectedViaAMiddleObject(object1, object2, a, b, false, options);
                        tempInnerQuery.connectState = connectionType.connectedViaMiddleInverted;
                        tempInnerQuery.object1 = object1;
                        tempInnerQuery.object2 = object2;
                        tempList.Add(tempInnerQuery);

                        //(queries[distance] as ArrayCollection).addItem(new Array(connectedViaAMiddleObject(object1, object2, a, b, false, options), connectedViaMiddleInverted));
                    }
                }
            }
            queries.Add(distance, tempList);
            //substitution of the above code:

            return queries;
        }