Example #1
0
        private ResourceDescription GetDescriptionOf(Resource theResource, TripleStore store, Hashtable processedResources)
        {
            ConciseBoundedDescription cbd = new ConciseBoundedDescription(theResource);

            IList denotingNodes = store.GetNodesDenoting(theResource);

            processedResources[theResource] = denotingNodes;

            foreach (GraphMember member in  denotingNodes)
            {
                cbd.AddDenotation(member, theResource);
            }

            Query query = new Query();

            query.AddPattern(new Pattern(store.GetBestDenotingNode(theResource), new Variable("pred"), new Variable("obj")));

            IEnumerator solutions = store.Solve(query);

            while (solutions.MoveNext())
            {
                QuerySolution solution = (QuerySolution)solutions.Current;

                foreach (GraphMember member in store.GetNodesDenoting(solution["pred"]))
                {
                    cbd.AddDenotation(member, solution["pred"]);
                }

                foreach (GraphMember member in store.GetNodesDenoting(solution["obj"]))
                {
                    cbd.AddDenotation(member, solution["obj"]);
                }

                cbd.Add(new ResourceStatement(theResource, solution["pred"], solution["obj"]));

                if (store.GetBestDenotingNode(solution["obj"]) is BlankNode)
                {
                    if (!processedResources.ContainsKey(solution["obj"]))
                    {
                        cbd.Add((ConciseBoundedDescription)GetDescriptionOf(solution["obj"], store, processedResources));
                    }
                }
            }

            return(cbd);
        }