%META:TOPICPARENT{name="VirtSPASQLWinFormApp"}%
---+Extending RDFDemo to Allow Dereferencing of External IRIs
This document will guide you through extending the application created in [[VirtSPASQLWinFormApp][Creating a Windows Forms Application To Access RDF Data Using The Virtuoso ADO.Net Provider]] so that it will dereference external [[http://docs.openlinksw.com/virtuoso/rdfdatarepresentation.html#rdfiriidtype][IRIs]].
---+++Pre-requisites
1. A working copy of the RDFDemo application created in [[SPASQLStepByStep][Creating a Windows Forms Application To Access RDF Data Using The Virtuoso ADO.Net Provider]].
---++Extending the Application.
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
* The singleDescribeCommandSimple = 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 }");
---+++Step 2 - Build and Run the Application You will see the same starting form: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.
---+++Step 3 - Changing the Form Title
Notice that in displayData method that we look for a * Remove the existing foreach block that sets the form title and replace with the following lines: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 }"); } }
---++Next Steps
The application now allows you to explore data and follow links from your locally held data into the external web of data. Looking at the data displayed in the form it would be nice to make the labels for the properties more compact. The label