In RDFDemo when the sparql endpoint is queried to get the description of the selected item it executes a query that is restricted to the local Northwind dataset. The query is something like
SPARQL PREFIX nwind: <http://demo.openlinksw.com/schemas/northwind#> SELECT DISTINCT ?s FROM <http://demo.openlinksw.com/Northwind> WHERE {?s a nwind:Customer}
If you examine the ExtendedStringHandler class you will see that the dataset clause, from <http://localhost:8890/Northwind>, is hard coded. This means that when when the selected IRI is a link to an external data store, such as dbpedia, there is no matching data and an error is displayed. If the application is to be able to dereference external IRIs then the hard coded dataset clause needs to be removed and then we can use a Virtuoso extension to SPARQL, get:soft, that tells Virtuoso that it needs to go and look elsewhere for the graph. However, this will result in a loss of performance when exploring the local Northwind dataset. To minimize the impact on performance we will first query the local Northwind dataset and if there are no matching triples returned then we will use a more generic query that will look elsewhere for matching data.
StringBuilder DescribeCommand;
StringBuilder DescribeCommandSimple, DescribeCommandGeneral;
DescribeCommandSimple = new StringBuilder("sparql select * from <http://demo.openlinksw.com/Northwind> where {<" + iri.ToString() + "> ?p ?o}"); // Replace demo.openlinksw.com with your URIQA DefaultHost setting
DescribeCommandGeneral = new StringBuilder("sparql define get:soft " + '"'.ToString() + "soft" + '"'.ToString() + " select * from <" + iri.ToString() + "> where { <" + iri.ToString() + "> ?p ?o }");
public string describeCommandSimpleText { get { return DescribeCommandSimple.ToString(); } } public string describeCommandGeneralText { get { return DescribeCommandGeneral.ToString(); } }
public void getDescribeData()
{
VirtuosoCommand myCommand = new VirtuosoCommand(this.describeCommandSimpleText, this.ParentConnection);
VirtuosoDataAdapter myAdapter = new VirtuosoDataAdapter();
myAdapter.SelectCommand = myCommand;
myAdapter.Fill(describeDataSet.DataTable1);
// Tried the simple version if fails to get the data try
// to look elsewhere.
if (describeDataSet.DataTable1.Rows.Count == 0)
{
myCommand.CommandText = describeCommandGeneralText;
myAdapter.Fill(describeDataSet.DataTable1);
}
}
Select a Customer and then select the link to the City in dbpedia. This will now open up another window displaying information about the city from dbpedia. Be patient as it may take a little while to open.
foreach (DataRow row in table1.Rows) if (row[0].ToString() == "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") { StringBuilder title = new StringBuilder(row[1].ToString() + " details"); label1.Text = title.ToString(); break; }
This worked well for the Northwind subjects but less well now we are getting data from other graphs. To change the title of the forms used to display the data:
StringBuilder DescribeCommandSimple, DescribeCommandGeneral; VirtuosoConnection ParentConnection; List<Label> labelList = new List<Label>(); List<TextBox> textBoxList = new List<TextBox>(); DescribeDataSet describeDataSet = new DescribeDataSet(); Boolean isIRI = false; SqlExtendedString ParentIRI;
public ExtendedStringHandler(SqlExtendedString iri, VirtuosoConnection parentConnetion)
{
ParentConnection = parentConnetion;
if (iri.IriType == SqlExtendedStringType.IRI)
{
ParentIRI = iri;
isIRI = true;
DescribeCommandSimple = new StringBuilder("sparql select * from <http://demo.openlinksw.com/Northwind> where {<" + iri.ToString() + "> ?p ?o}"); // Replace demo.openlinksw.com with your URIQA DefaultHost setting
DescribeCommandGeneral = new StringBuilder("sparql define get:soft " + '"'.ToString() + "soft" + '"'.ToString() + " select * from <" + iri.ToString() + "> where { <" + iri.ToString() + "> ?p ?o }");
}
}
StringBuilder title = new StringBuilder(ParentIRI.ToString() + " details"); label1.Text = title.ToString();