Esempio n. 1
0
 public void AddExpansionDataset(ExpansionDataset d)
 {
     if (!this._datasets.ContainsKey(d.Subject))
     {
         this._datasets.Add(d.Subject, d);
     }
 }
Esempio n. 2
0
        protected override void Initialise(IGraph g)
        {
            if (g.BaseUri != null) this._node = g.CreateUriNode();

            //First ensure all the correct namespace prefixes are set to the correct URIs
            g.NamespaceMap.AddNamespace("rdf", new Uri(NamespaceMapper.RDF));
            g.NamespaceMap.AddNamespace("void", new Uri(VoIDNamespace));
            g.NamespaceMap.AddNamespace("foaf", new Uri(FoafNamespace));
            g.NamespaceMap.AddNamespace("dcterms", new Uri(DublinCoreTermsNamespace));
            g.NamespaceMap.AddNamespace("aat", new Uri(AATNamespace));

            //First look for an Expansion Profile description
            Triple profileDescriptor = new Triple(g.CreateUriNode(), g.CreateUriNode("rdf:type"), g.CreateUriNode("aat:ExpansionProfile"));
            if (g.ContainsTriple(profileDescriptor))
            {
                //Does it specify a Max Expansion Depth?
                Triple maxDepthSpecifier = g.GetTriplesWithSubjectPredicate(g.CreateUriNode(), g.CreateUriNode("aat:maxExpansionDepth")).FirstOrDefault();
                if (maxDepthSpecifier != null)
                {
                    if (maxDepthSpecifier.Object.NodeType == NodeType.Literal)
                    {
                        ILiteralNode l = (ILiteralNode)maxDepthSpecifier.Object;
                        if (l.DataType != null && l.DataType.ToString().Equals(XmlSpecsHelper.XmlSchemaDataTypeInteger))
                        {
                            this._maxDepth = Int32.Parse(l.Value);
                        }
                    }
                }
            }

            //Find Datasets
            foreach (Triple t in g.GetTriplesWithPredicateObject(g.CreateUriNode("rdf:type"), g.CreateUriNode("void:Dataset")))
            {
                ExpansionDataset dataset = new ExpansionDataset(g, t.Subject);
                if (this._datasets.ContainsKey(t.Subject))
                {
                    throw new NotImplementedException("Merging Expansion Datasets is not yet implemented");
                }
                else
                {
                    this._datasets.Add(t.Subject, dataset);
                }
            }

            //Find Linksets
            foreach (Triple t in g.GetTriplesWithPredicateObject(g.CreateUriNode("rdf:type"), g.CreateUriNode("void:Linkset")))
            {
                ExpansionLinkset linkset = new ExpansionLinkset(g, t.Subject);
                if (this._linksets.ContainsKey(t.Subject))
                {
                    throw new NotImplementedException("Merging Expansion Linksets is not yet implemented");
                }
                else
                {
                    this._linksets.Add(t.Subject, linkset);
                }
            }

        }
Esempio n. 3
0
 public void AddExpansionDataset(ExpansionDataset d)
 {
     if (!this._datasets.ContainsKey(d.Subject))
     {
         this._datasets.Add(d.Subject, d);
     }
 }
Esempio n. 4
0
        private void ExpandByDataset(UriToExpand u, ExpansionContext context, ExpansionDataset dataset)
        {
            if (u.Depth == context.Profile.MaxExpansionDepth) return;
            if (dataset.Ignore) return;

            foreach (Uri endpoint in dataset.SparqlEndpoints)
            {
                Thread.Sleep(HttpRequestInterval);
                SparqlRemoteEndpoint sparqlEndpoint = new SparqlRemoteEndpoint(endpoint);
                try
                {
                    SparqlParameterizedString queryString = new SparqlParameterizedString("DESCRIBE @uri");
                    queryString.SetUri("uri", u.Uri);
                    Object temp = sparqlEndpoint.QueryWithResultGraph(queryString.ToString());
                    if (temp is Graph)
                    {
                        Graph g = (Graph)temp;
                        this.ExpandGraph(u, g, context);
                    }
                }
                catch (RdfException rdfEx)
                {
                    this.DebugErrors("Error: Tried to DESCRIBE <" + u.Uri.ToString() + "> against the SPARQL Endpoint <" + endpoint.ToString() + "> but an error occurred:", rdfEx);
                }
                catch (WebException webEx)
                {
                    this.DebugErrors("Error: Tried to DESCRIBE <" + u.Uri.ToString() + "> against the SPARQL Endpoint <" + endpoint.ToString() + "> but an error occurred:", webEx);
                }
            }

            foreach (Uri endpoint in dataset.UriLookupEndpoints)
            {
                this.ExpandByUriLookup(u, context, endpoint);
            }

            foreach (Uri endpoint in dataset.UriDiscoveryEndpoints)
            {
                this.ExpandByUriDiscovery(u, context, endpoint);
            }
        }
Esempio n. 5
0
        protected override void Initialise(IGraph g)
        {
            if (g.BaseUri != null)
            {
                this._node = g.CreateUriNode();
            }

            //First ensure all the correct namespace prefixes are set to the correct URIs
            g.NamespaceMap.AddNamespace("rdf", new Uri(NamespaceMapper.RDF));
            g.NamespaceMap.AddNamespace("void", new Uri(VoIDNamespace));
            g.NamespaceMap.AddNamespace("foaf", new Uri(FoafNamespace));
            g.NamespaceMap.AddNamespace("dcterms", new Uri(DublinCoreTermsNamespace));
            g.NamespaceMap.AddNamespace("aat", new Uri(AATNamespace));

            //First look for an Expansion Profile description
            Triple profileDescriptor = new Triple(g.CreateUriNode(), g.CreateUriNode("rdf:type"), g.CreateUriNode("aat:ExpansionProfile"));

            if (g.ContainsTriple(profileDescriptor))
            {
                //Does it specify a Max Expansion Depth?
                Triple maxDepthSpecifier = g.GetTriplesWithSubjectPredicate(g.CreateUriNode(), g.CreateUriNode("aat:maxExpansionDepth")).FirstOrDefault();
                if (maxDepthSpecifier != null)
                {
                    if (maxDepthSpecifier.Object.NodeType == NodeType.Literal)
                    {
                        ILiteralNode l = (ILiteralNode)maxDepthSpecifier.Object;
                        if (l.DataType != null && l.DataType.ToString().Equals(XmlSpecsHelper.XmlSchemaDataTypeInteger))
                        {
                            this._maxDepth = Int32.Parse(l.Value);
                        }
                    }
                }
            }

            //Find Datasets
            foreach (Triple t in g.GetTriplesWithPredicateObject(g.CreateUriNode("rdf:type"), g.CreateUriNode("void:Dataset")))
            {
                ExpansionDataset dataset = new ExpansionDataset(g, t.Subject);
                if (this._datasets.ContainsKey(t.Subject))
                {
                    throw new NotImplementedException("Merging Expansion Datasets is not yet implemented");
                }
                else
                {
                    this._datasets.Add(t.Subject, dataset);
                }
            }

            //Find Linksets
            foreach (Triple t in g.GetTriplesWithPredicateObject(g.CreateUriNode("rdf:type"), g.CreateUriNode("void:Linkset")))
            {
                ExpansionLinkset linkset = new ExpansionLinkset(g, t.Subject);
                if (this._linksets.ContainsKey(t.Subject))
                {
                    throw new NotImplementedException("Merging Expansion Linksets is not yet implemented");
                }
                else
                {
                    this._linksets.Add(t.Subject, linkset);
                }
            }
        }