示例#1
0
        /// <summary>
        /// Exectues a certain List of InnerQuery objects
        /// </summary>
        /// <param name="input">the list of innerquery to be queried</param>
        /// <returns>a list of resultSet one for each innerquery.queryText</returns>
        public static List<ResSetToJSON.innerResult> ExecuteQueryWithInnerQuery(SPARQLQueryBuilder.InnerQuery input,string obj1,string obj2)
        {
            //list to hold the results
            List<ResSetToJSON.innerResult> resultsList = new List<ResSetToJSON.innerResult>();

            try
            {
                //temp result holder
                ResSetToJSON.innerResult temp;
                //fetching results and passing to the list

                temp = new ResSetToJSON.innerResult();
                temp.firstObj = obj1;
                temp.lastObj = obj2;
                temp.connectState = input.connectState;
                temp.resultSets = ExecuteQueryWithString(input.queryText);

                //if there's any results add it
                if (temp.resultSets.Count > 0)
                    resultsList.Add(temp);

            }
            catch { }
            return resultsList;
        }
        /// <summary>
        /// Builds and returns a set of queries to find relations between two object1 and object2.
        /// </summary>
        /// <param name="object1">object1</param>
        /// <param name="object2">object2</param>
        /// <param name="maxDistance">MaxiumDistance between the two objects</param>
        /// <param name="limit">Limit of results</param>
        /// <param name="ignoredObjects">List of strings of names of objects be ignored in the Queries</param>
        /// <param name="ignoredProperties">List of strings of names of properties to be ignored in the Queries</param>
        /// <param name="avoidCycles">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</param>
        /// <returns>false means an error happened, true means it's ok</returns>
        public bool generateQueries(string object1, string object2, int maxDistance=5, int limit=5, List<string> ignoredObjects = null, List<string> ignoredProperties = null, int avoidCycles = 0)
        {
            //resetting the bool
            isEndOfResults = false;

            //to make other methods see the two objects
            obj1 = object1;
            obj2 = object2;

            SPARQLQueryBuilder builder = new SPARQLQueryBuilder();
            generatedQueriesList=builder.buildQueries(object1, object2, maxDistance, limit, ignoredObjects, ignoredProperties, avoidCycles);

            //if an error happened
            if (generatedQueriesList.Count < 1)
                return false;

            return true;
        }