-
Notifications
You must be signed in to change notification settings - Fork 15
Example: How to set up a class
In Example: How to set up a service, we showed how to create a new service. The example displayed a list of epochs. When clicking on one, we want to recognize that the URI requested is a datafaqs:Epoch and show specific aspects about the epoch that the generic type.rdfs:Resource model/view will do. So let's fire up utils/lodspk.sh again:
/var/www/datafaqs/DataFAQs-lodspeakr$ utils/lodspk.sh
Usage: utils/lodspk.sh create|delete uri|type|service foo
Here, we want to make a type handler called for datafaqs:Epoch, and we only want an html template (the machine formats come for free):
/var/www/datafaqs/DataFAQs-lodspeakr$ utils/lodspk.sh create type datafaqs:Epoch
...
class.datafaqs:Epoch created/modified successfully!
Note that window users need to use datafaqs__Epoch
instead of datafaqs:Epoch
, both will work in LODSPeaKr version >= 20130612, se more info below
Although lodspk.sh made the models/class.datafaqs\:Epoch/html.queries/main.query
model query for us, we anticipate a variety of queries to select different characteristics about the epoch. Se we'll rename main.query
to subsets.query
.
We'll want to modify the model query and the view template that lodspk.sh made for us:
/var/www/datafaqs/DataFAQs-lodspeakr$ vi models/class.datafaqs\:Epoch/html.queries/subsets.query
/var/www/datafaqs/DataFAQs-lodspeakr$ vi views/class.datafaqs\:Epoch/html.template
Usually, you want to develop the SPARQL query that you want using the endpoint's UI. Once you have the essential structure, plop it into the subsets.query:
PREFIX void: <http://rdfs.org/ns/void#>
PREFIX sd: <http://www.w3.org/ns/sparql-service-description#>
PREFIX datafaqs: <http://purl.org/twc/vocab/datafaqs#>
SELECT ?subset
WHERE {
GRAPH ?name {
{{uri}} void:subset ?subset
}
}
Then, visit an Epoch with a web browser: http://aquarius.tw.rpi.edu/datafaqs/epochs
Windows does not allow users to create directories with colons in their names. Since version 20130612, LODSPeaKr supports the creation of CURIEs where the colon is replaced by a double underscore (__
). Thus, it is possible to run
utils/lodspk.sh create type foaf__Person
This should be understandable for any LODSPeaKr instance after version 20120612, independent of the platform (linux, windows, osx, freebsd)