Author Archive for steve

Construct on tour

Spurred by my belief in the Construct Infrastructure I took my official t-shirt with me in my backpack. In my role as Construct evangalist I’ll document the far reaching effects we’re having through a few photos. First is Rio de Janero in Brazil:

Provided my bag doesn’t get stolen there will be more to follow.

Part 2

And here it is. On Monday (8/9) I deployed Construct 0.8a to Machu Picchu in Peru. The Inkas love it. When I left the Inka chief was in deep discussion about named graph support and php-based web mashups over a hot cup of coca tea:

Construct at Machu Picchu

HTTP Port - Part 2

In part 1 of this post I described the new HTTP Port in Construct. In this part of the post I’ll explain how to write a web form and style the return values.

SPARQL Query

You can send a query to Construct with GET or POST. Here is how we do it in HTML with GET:

  1. <form method=“GET” action=“http://duvel.ucd.ie:8888/”>
  2. <textarea name=“q” cols=“64″ rows=“10″>SELECT ?subject ?predicate ?object WHERE {?subject ?predicate ?object}</textarea><br/>URL of XSLT to apply (optional):<br/><input type=“text” name=“xsl” size=“56″ value=“http://www.construct-infrastructure.org/stylesheets/default.xsl type=”submit” value=”Submit Query“>
  3. </form>

the only thing the HTTP Port wants is the query field to be called either “q” or “query”. The returned XML will be sent back to your browser. Something like this:

  1. <?xml version=“1.0″?>
  2. <?xml-stylesheet type=“text/xsl” href=“http://duvel.ucd.ie:8888/xsl/www.construct-infrastructure.org/stylesheets/default.xsl”?>
  3. <sparql
  4. xmlns:rdf=“http://www.w3.org/1999/02/22-rdf-syntax-ns#”
  5. xmlns:xs=“http://www.w3.org/2001/XMLSchema#”
  6. xmlns=“http://www.w3.org/2005/sparql-results#”>
  7. <head>
  8. <variable name=“subject”/>
  9. <variable name=“predicate”/>
  10. <variable name=“object”/>
  11. </head>
  12. <results>
  13. <result>
  14. <binding name=“subject”> <uri>http://www.pervasive-ontologies.org/ontologies/sensors/bluetooth#reading00:19:63:96:56:01@00:80:98:94:AE:4B@1201631502</uri>
  15. </binding>
  16. <binding name=“predicate”>
  17. <uri>http://www.pervasive-ontologies.org/ontologies/sensors/bluetooth#spotted</uri>
  18. </binding>
  19. <binding name=“object”>
  20. <literal>00:19:63:96:56:01</literal>
  21. </binding>
  22. </result>
  23. </results>
  24. </sparql>

To make the results look neater you can apply and XSL stylesheet. Send the URL for the XSL stylesheet as a field “xsl” in the form. This stylesheet must be web accessible. We’ve made a default example stylesheet you can use to get started.

Inserting N-3 RDF Data

You can insert new data into Construct using a form like this (we’re using POST this time for variety but GET works too):

  1. <form method=“POST” action=“http://duvel.ucd.ie:8888/”>
  2. <textarea name=“i” cols=“64″ rows=“10″><http://www.pervasive-ontologies.org/ontologies/sensors/bluetooth#reading00:19:63:96:56:01@00:80:98:94:AE:4B@1201631502><http://www.pervasive-ontologies.org/ontologies/sensors/bluetooth#spotted>“00:19:63:96:56:01″.</textarea><br/>Expiry time for data (optional):<br/><input type=“text” name=“expiry” size=“15″ value=“20000″><br/><input type=“submit” value=“Submit Data”>
  3. </form>

in this form you send the data to be inserted as a field “i” or “insert”.

The returned data from an insert is an XML document with a status code and any messages given back from Construct. It looks something like this:

  1. <response>
  2. <status>OK</status>
  3. <description>The data <http://www.pervasive-ontologies.org/ontologies/sensors/bluetooth#reading00:19:63:96:56:01@00:80:98:94:AE:4B@1201631502><http://www.pervasive-ontologies.org/ontologies/sensors/bluetooth#spotted>“00:19:63:96:56:01″. with given expiry 20000 was passed to the Construct data store without error.
  4. </description>
  5. </response>

Well, that is about it. You can make calls to Construct over HTTP from browsers or web applications using the HTTP Port. Have fun.

HTTP Port - Part 1

The latest release of Construct has the new HTTP Port enabled by default. The HTTP Port has similar functionality to the data port — you can use it to insert and query for data in Construct. The difference is that the data port works over raw TCP sockets, whereas the HTTP Port works over HTTP.

Now we can query Construct through a web browser and web apps… neat, huh?

First off, the construct.properties file now contains:

  1. <!– http port –>
  2. <component interface=“org.construct_infrastructure.component.httpport.HttpPort” implementation=“org.construct_infrastructure.component.httpport.HttpPortImpl”>
  3. <property name=“port” value=“8888″ />
  4. </component>

these lines activate the HTTP Port on port 8888. When you have Construct running, open your web browser and go to http://localhost:8888/ and you should a simple set of forms for querying and inserting data using HTTP GET and HTTP POST. It looks something like this:

Screenshot of the HTTP Port

From this page you can send RDF data in N-3 format or SPARQL queries to Construct. Try clicking on one of the buttons to test it out.

This is the end of Part 1 on the HTTP Port. Part 2 of this post will explain how to build your own web forms and use of XSL stylesheets for your results.