Archive for the 'Advanced' Category

Querying Named Graphs in Construct (Some Examples)

The next release of Construct contains named graphs. These allow you to store information that describes your RDF statements. I’ll give a simple run through of how to query Construct using named graphs (if you want more detail check out the w3c recommendation ).

When querying named graphs in Construct using SPARQL and the QueryService you need to add the GRAPH keyword to pattern match against graphs in the dataset. Lets start with the easiest example, selecting all the graphs and all the statements…

  1. SELECT * WHERE { GRAPH ?graph { ?s ?p ?o } }

So now your resultset is going to be able to return four pieces of info for every statement.

Graphs in Construct probably don’t confer too much useful information on their own however, as they are just unique ids, created by the data store.

It is useful though to know what graph(s) a statement or set of statements appears in. You could use something like this…

  1. SELECT DISTINCT ?graph WHERE { GRAPH ?graph { <http://construct-infrastructure.org/subject> ?p ?o } }

Now you’ve got the graph(s) that your statement(s) appears in, suppose you wanted to find all the metadata associated with those statements. All you have to do is add the following query…

  1. SELECT ?p ?o FROM NAMED <$GRAPH_URI> WHERE { GRAPH ?graph { ?graph ?p ?o } }

where $GRAPH_URI corresponds to the name of the graph(s) returned by the previous query. Now you’ve got all the metadata associated with your statement(s). This is only a small example of what kind of SPARQL queries can get the most out of the new data storage technique - all that’s left is to have a go!

Installing Bonjour for *nix Users

Every time Ubuntu’s Synaptic Package Manager updates the Avahi layer for Bonjour support it stomps on my Apple Bonjour install and breaks my Construct install. My guess is that the update puts Avahi first in the list of Bonjours to run when Construct starts. So I get this error:

*** WARNING *** The programme ‘java’ uses the Apple Bonjour compatiblity layer of Avahi.

*** WARNING *** Please fix your application to use the native API of Avahi!

*** WARNING *** For more information see

*** WARNING *** The programme ‘java’ called ‘DNSServiceQueryRecord()’ which is not supported (or only supported partially) in the Apple Bonjour compatiblity layer of Avahi.

*** WARNING *** Please fix your application to use the native API of Avahi!

*** WARNING *** For more information see

One way to address this is just to turn off the Avahi warning. Set an environmental variable list this export AVAHI_COMPAT_NOWARN=1 This isn’t a fix though it is just hiding the warning.

The best I have figured out so far is just to reinstall Bonjour:

Instructions for Installing Apple’s Bonjour on *nix

  1. Download the latest version of the Bonjour source code here.
  2. Decompress the downloaded archive
  3. cd to the mDNSPosix directory below the mDNSResponder-xxx directory (where xxx is the Bonjour version number).
  4. Edit Makefile and change line JDK = /usr/jdk to make it point at your Java installation (e.g., /usr/lib/jvm/java-6-sun)
  5. Type sudo make os=linux Java
  6. Type sudo make os=linux install — if you have problems with this, see below. Most likely you will need to install a specific version of gcc
  7. Copy the java specific files to your jre lib’s ext directory (cp build/prod/* /path/to/jre/lib/ext/)
  8. Open up /etc/nsswitch.conf and ensure that the ‘mdns’ switch appears on the “hosts:” line. My “hosts:” line looks like this:
hosts:          files dns mdns

Remember, whenever you use a new jre, make sure to include dns_sd.jar (Bonjour JAR file) in your jre/lib/ext directory

Problems with the install

Problems with stdlib.h

Lorcan had some problems with this install on Ubuntu (Edgy). He says: when running sudo make os=linux Java I got a lot of errors, starting with ../mDNSShared/dnssd_clientlib.c:71:20: error: stdlib.h: No such file or directory.

I installed the libc6-dev package. When I tried again everything worked fine

Problems with __stack_chk_fail_local

I had some major problems with this install on Ubuntu (Edgy), specifically when using gcc4.1 (to find out which version of gcc you are using type gcc --version).

lorcan@comp:~/Desktop/mDNSResponder-107.6/mDNSPosix$ sudo make os=linux install
Stopping Apple Darwin Multicast DNS / DNS Service Discovery daemon: mdnsd.
cp build/prod/mdnsd /usr/sbin/mdnsd
/usr/sbin/mdnsd installed
cp mdnsd.sh /etc/init.d/mdns
chmod ugo+x /etc/init.d/mdns
/etc/init.d/mdns start
Starting Apple Darwin Multicast DNS / DNS Service Discovery daemon: mdnsd.
ln -s -f /etc/init.d/mdns /etc/rc2.d/S52mdns
ln -s -f /etc/init.d/mdns /etc/rc3.d/S52mdns
ln -s -f /etc/init.d/mdns /etc/rc4.d/S52mdns
ln -s -f /etc/init.d/mdns /etc/rc5.d/S52mdns
ln -s -f /etc/init.d/mdns /etc/rc0.d/K16mdns
ln -s -f /etc/init.d/mdns /etc/rc6.d/K16mdns
/etc/init.d/mdns installed
cp build/prod/libdns_sd.so /usr/lib/libdns_sd.so.1
ln -s -f /usr/lib/libdns_sd.so.1 /usr/lib/libdns_sd.so
/usr/lib/libdns_sd.so.1 /usr/include/dns_sd.h installed
/usr/share/man/man8/mdnsd.8 installed
make[1]: Entering directory `/home/lorcan/Desktop/mDNSResponder-107.6/Clients’
mkdir build
cc dns-sd.c -L../mDNSPosix/build/prod/ -ldns_sd -I../mDNSShared -o build/dns-sd
/usr/bin/ld: build/dns-sd: hidden symbol `__stack_chk_fail_local’ in /usr/lib/libc_nonshared.a(stack_chk_fail_local.oS) is referenced by DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
make[1]: *** [build/dns-sd] Error 1
make[1]: Leaving directory `/home/lorcan/Desktop/mDNSResponder-107.6/Clients’

make: *** [../Clients/build/dns-sd] Error 2

Solution:
If the version of gcc is not 4.0.x Follow these instructions (EXACTLY!!!) to correct the problem:

  1. Ensure that gcc version 4.0.x is installed. This is a little tricky as the synaptic package manager stopped supporting this version of gcc since edgy. You’ll have to download the following packages:  gcc-4.0-base, cpp-4.0 , gcc-4.0
  2. Open the terminal and cd to where you saved the package.
  3. Do the following for each of the three packages: dpkg -i PACKAGE.deb Install them in the same order the are above. gcc base first, then cpp, then gccThis should put gcc-4.0 into your /usr/bin directory.
  4. cd /usr/bin
  5. sudo mv gcc gcc-backup
  6. sudo ln -s gcc-4.0 gcc

Now completely rerun the instructions above (at the top of this page) to install Bonjour (you must completely rerun them from step 2). When installation is complete continue these instructions.

  1. sudo cd /usr/bin
  2. sudo rm gcc
  3. sudo mv gcc-backup gcc

Now gcc should point to the original version of gcc (i.e. that version that you were using before you installed Bonjour).

Adding Construct to your Ubuntu start menu.

In this post, I show you how to add construct to your ubuntu start menu. The assumption I am making is that you have the most recent version of construct (currently 0.74) downloaded and installed.

Step 1

This step allows you to run construct without being in the construct directory.

Open the ‘construct.sh’ file and change the line:

CONSTRUCT_HOME=.

to

CONSTRUCT_HOME=YOUR CONSTRUCT DIRECTORY

For me it is: $HOME/construct

Save the file and exit.

Step 2

Create a symbolic link to the executable shell script.

This allows you to just type ‘construct’ in the terminal, much the same way you would write ‘emacs’ etc.

Open a terminal and type:

cd /usr/bin/

now type:

ln -s LOCATION_OF_CONSTRUCT_DIRECTORY/construct.sh construct

Now type cd

Type ‘construct’. Construct should start running.

It will tell you, however that it could not find the properties file.

Step 3

Copy the construct.properties file to your home directory.

Exit construct if you have it open.

Open a terminal.

cd to your construct directory (in my case cd ~/construct)

Copy the file to your home directory:

cp construct.properties ~/ (~/ is a shorthand notation for your home directory)

Step 4

In your ubuntu status bar, double click on the ’start menu’ — the orange circular icon on the left.

Click on ‘Edit Menus’

Click on the ‘New Item’ button on the right

For ‘Name’, type ‘Construct’

For ‘Command’, type ‘construct’

Click OK.

That’s it!

Construct is now in your start menu!