Banner
Title: Semantic Grid practical
Subtitle: Create and Query Semantic Sticky Notes
Authors: Pinar Alper, Oscar Corcho
Tutor: Pinar Alper
manchester
OntoGrid
RSSGrid
globus

Student Exercises: Build a Semantically-Aware Grid Service Using GT4

This is the Unix version of the student notes. If you are using Windows, you should use the Windows version of the notes.

Document Style Conventions

For the exercises two command windows will be needed:

One window will be used to run the Globus Toolkit container and will be referred to as the GT window in these notes. Commands typed in the GT window will be bounded by a box of this colour

The second window will be used to modify and execute student code and will be referred to as the Exercise window in these notes. Exercise commands will be bounded by a box of this colour

If you can, you might want to just colour the backgrounds of your Terminal/Command/Xterm windows to match the colours that will be used in the tutorial.

  • Text in red can be cut and pasted into a command window
  • Text in black indicates intelligent replacement is required

Prerequisites

This tutorial is based on the tutorial "How to Build a Service Using GT4", also known as BAS GT4 Sticky Note tutorial, which is available here (the students have completed it on Friday 14th). In order to make sure every student starts today’s Semantic Grid tutorial with the same code base we will provide, amongst others, a code base of the sticky note tutorial with exercises 1 to 4 already completed. The instructions for getting the initial code base for this tutorial (referred to as the SG-tutorial from now on) are supplied in Chapter 1.

Top

Chapter 1. Download Globus Container and Base Sticky Note Code and Set Environment Variables

In this chapter we will setup the environment and obtain the tools and sources needed for the tutorial. Please download the files gt-install.zip and sg-tutorial-install.zip from here. The first zip file is the Globus container. The second zip file is the code base for this tutorial. The code base contains three 3 directories, these are:
· GT4 BAS Sticky Note tutorial with exercises 1 to 4 completed.
· The Semantic Binding Service: a service delivering storing and querying capabilities for RDF based metadata.
· The Semantics Operation Provider: a proxy to the Semantic Binding service that could be augmented to any WSRF web service deployed in the Globus container.

1.1 Unzip the gt install zip file in the GT window

$ mkdir /tmp/semGridTutorial/$USER
$ cd /tmp/semGridTutorial/$USER
$ wget http://www.gs.unina.it/~semanticgrid/software/gt-install.zip
$ unzip gt-install.zip

1.2 Set environment variables in the GT window

The following commands would allow you to set the GLOBUS_LOCATION variable so that it points to the newly downloaded container.

$ cd gt-install
$ export GLOBUS_LOCATION=$PWD
$ echo $GLOBUS_LOCATION
/tmp/semGridTutorial/$USER/gt-install

The SG tutorial makes use of Java 1.5 instead of an older version of Java that students have used for the previous courses in the summer school. In order to accommodate this change we need to set the environment variables JAVA_HOME and PATH accordingly. The commands for this are given below. Besides, we check that the Java version is correct.

$ export JAVA_HOME=/usr/java/jdk1.5.0_07
$ echo $JAVA_HOME
/usr/java/jdk1.5.0_07

$ export PATH=/usr/java/jdk1.5.0_07/bin:$PATH
$ echo $PATH
/usr/java/jdk1.5.0_07/bin: [... many other directories in the PATH variable...]

$ java -version
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode, sharing)

1.3 Unzip the tutorial zip file in the Exercise window

This installer contains demonstration code that has been written for today's tutorial. Please note that sg-tutorial-install.zip contains two other component directories in addition to the stickynote code. Deployment of these two components are explained in Chapter 2.

$ cd /tmp/semGridTutorial/$USER
$ wget http://www.gs.unina.it/~semanticgrid/software/sg-tutorial-install.zip
$ unzip sg-tutorial-install.zip
$ cd exercise-install/stickynote

1.4 Set environment variables in the Exercise window

$ export GLOBUS_LOCATION=[use the value that was echoed earlier in the GT window, not $PWD]
$ export JAVA_HOME=/usr/java/jdk1.5.0_07
$ export PATH=/usr/java/jdk1.5.0_07/bin:$PATH

1.5 Build and deploy the tutorial code in the Exercise window

$ ant deploy
Buildfile: build.xml

init:

bindings:

[... many more build messages...]

BUILD SUCCESSFUL
Total time: 27 seconds

1.6 Start a web service container without security in the GT window

When you run the Globus container the cursor will not return to the command prompt. This container will stay running until you exit it with Control-C.

Note 2: If the command cannot be run it could be due to the fact that your user has no execution permissions to run globus-start-container. In that case, you can run chmod +x * in the bin directory.

Note 1: If you need to start up the container on an alternate port, use the "-p" command-line argument (e.g., "bin\globus-start-container -nosec -p 8888" will cause the container to listen on port 8888)

$ bin/globus-start-container -nosec
Starting SOAP server at: http://192.168.123.100:8080/wsrf/services/
With the following services:

[1]: http://192.168.123.100:8080/wsrf/services/InMemoryServiceGroupEntry
[2]: http://192.168.123.100:8080/wsrf/services/TriggerFactoryService
[3]: http://192.168.123.100:8080/wsrf/services/IndexFactoryService
[4]: http://192.168.123.100:8080/wsrf/services/Version
[5]: http://192.168.123.100:8080/wsrf/services/IndexService
[6]: http://192.168.123.100:8080/wsrf/services/NotificationConsumerService
[7]: http://192.168.123.100:8080/wsrf/services/DefaultTriggerServiceEntry
[8]: http://192.168.123.100:8080/wsrf/services/TriggerServiceEntry
[9]: http://192.168.123.100:8080/wsrf/services/IndexServiceEntry
[10]: http://192.168.123.100:8080/wsrf/services/StickyNoteService
[11]: http://192.168.123.100:8080/wsrf/services/AdminService
[12]: http://192.168.123.100:8080/wsrf/services/DefaultIndexService
[13]: http://192.168.123.100:8080/wsrf/services/DefaultIndexServiceEntry
[14]: http://192.168.123.100:8080/wsrf/services/DefaultTriggerService
[15]: http://192.168.123.100:8080/wsrf/services/ShutdownService
[16]: http://192.168.123.100:8080/wsrf/services/ContainerRegistryService
[17]: http://192.168.123.100:8080/wsrf/services/TriggerService
[18]: http://192.168.123.100:8080/wsrf/services/gsi/AuthenticationService
[19]: http://192.168.123.100:8080/wsrf/services/InMemoryServiceGroupFactory
[20]: http://192.168.123.100:8080/wsrf/services/InMemoryServiceGroup
[21]: http://192.168.123.100:8080/wsrf/services/ContainerRegistryEntryService
[22]: http://192.168.123.100:8080/wsrf/services/SubscriptionManagerService

From the container window check whether the StickyNoteService is correctly deployed.

1.7 In the exercise window, run the create-note client against your StickyNote service

$ $GLOBUS_LOCATION/bin/create-note -s http://localhost:8080/wsrf/services/StickyNoteService
new note created...
EPR written to file: note-18887662.epr

Also notice that a message is displayed by the container:

2006-07-07 12:23:00,234 INFO stickynote.ManyNoteHome [Thread-2,create:52] Creating a new StickyNote.

Top

Chapter 2. Deploy the Semantic Binding Service and the Semantics Operation Provider

In this chapter we will deploy in the Globus Toolkit container the service that will be in charge of managing the repository of semantic bindings and we will also deploy an operation provider that can act as a proxy to the Semantic Binding Service.

2.1 Check the source code files necessary for Semantic Binding Service and Semantic Operation Provider

The following directories contain files with the source code that will be compiled and deployed:

exercise-install/SemanticBindingService/src/:
Source files of the semantic binding service

exercise-install/SemanticsOperationProvider/src/:
Source files of the metadata provider

2.2 Deploy the Semantic Binding Service in the Globus Container

Using the command line in the exercise window execute a cd command to change to the directory that corresponds to the Semantic Binding Service. Command for this is given below:

$ cd /tmp/semGridTutorial/$USER/SemanticBindingService/

Once you’re in the SemanticBindingService directory do the deployment of the Semantic Binding Service. For this execute these commands from the /tmp/semGridTutorial/$USER/SemanticBindingService/ directory of the Exercise window.

$ ant clean
$ ant deploy

2.3 Deploy the metadata operation provider to the Web service container

Using the command line in the exercise window execute a cd command to change to the directory that corresponds to the Semantics OperationProvider:

$ cd /tmp/semGridTutorial/$USER/SemanticsOperationProvider/

Execute these commands from the /tmp/semGridTutorial/$USER/SemanticsOperationProvider/ directory of the Exercise window.

$ ant clean
$ ant deploy

2.4 Kill and restart the Web service container in the GT window

$ [ctrl-c]
$ bin/globus-start-container -nosec
Starting SOAP server at: http://192.168.123.100:8080/wsrf/services/
With the following services:
[1]: http://192.168.123.100:8080/wsrf/services/InMemoryServiceGroupEntry
[2]: http://192.168.123.100:8080/wsrf/services/TriggerFactoryService
[3]: http://192.168.123.100:8080/wsrf/services/IndexFactoryService
[4]: http://192.168.123.100:8080/wsrf/services/Version
[5]: http://192.168.123.100:8080/wsrf/services/IndexService
[6]: http://192.168.123.100:8080/wsrf/services/NotificationConsumerService
[7]: http://192.168.123.100:8080/wsrf/services/DefaultTriggerServiceEntry
[8]: http://192.168.123.100:8080/wsrf/services/TriggerServiceEntry
[9]: http://192.168.123.100:8080/wsrf/services/IndexServiceEntry
[10]: http://192.168.123.100:8080/wsrf/services/StickyNoteService
[11]: http://192.168.123.100:8080/wsrf/services/AdminService
[12]: http://192.168.123.100:8080/wsrf/services/DefaultIndexService
[13]: http://192.168.123.100:8080/wsrf/services/DefaultIndexServiceEntry
[14]: http://192.168.123.100:8080/wsrf/services/DefaultTriggerService
[15]: http://192.168.123.100:8080/wsrf/services/ShutdownService
[16]: http://192.168.123.100:8080/wsrf/services/ContainerRegistryService
[17]: http://192.168.123.100:8080/wsrf/services/TriggerService
[18]: http://192.168.123.100:8080/wsrf/services/gsi/AuthenticationService
[19]: http://192.168.123.100:8080/wsrf/services/InMemoryServiceGroupFactory
[20]: http://192.168.123.100:8080/wsrf/services/InMemoryServiceGroup
[21]: http://192.168.123.100:8080/wsrf/services/ContainerRegistryEntryService
[22]: http://192.168.123.100:8080/wsrf/services/SubscriptionManagerService
[23]: http://192.168.123.100:8080/wsrf/services/SemanticBindingService
[24]: http://192.168.123.100:8080/wsrf/services/SemanticBindingFactoryService
[25]: http://192.168.123.100:8080/wsrf/services/MetadataQueryService

Please note that three new services are now available in the Web service container: SemanticBindingService, SemanticBindingFactoryService and MetadataQueryService. We will use these services in the following Chapters.

Top

Chapter 3. Augment the Sticky Note Service with the Semantics Operation Provider and attach Semantics to a Sticky Note

In this exercise we will extend the StickyNoteService with an operation from the Semantics Operation Provider so that we can attach semantic bindings to sticky notes.

3.1 Preliminar work

Starting with this exercise we will be editing source files. In this section we give general guidelines for source editing throughout the tutorial.

3.1.1 How to modify files

Take care not to edit the files in the build/ subdirectory, as files in the build/ tree are overwritten by the "ant deploy" command. You should run ant clean first to make sure the temporary build files are cleaned up. Also, make sure you are editing the files in the TUTORIAL location, not in the GLOBUS_LOCATION.

If you are not familiar with commenting out XML or WSDL, the comment characters are <!-- and -->. For instance:

This is not commented out
<!-- This line is commented out -->
<!--
These lines
are both commented out
-->

All modifications you need to make to source files begin with a comment tag of "EXERCISE SEMANTIC GRID n: <type of modification needed>" and end with "END OF EXERCISE SEMANTIC GRID n <type of modification>". Some files contain more than one set of changes to be made for a given file.

3.1.2 Files necessary for this chapter and files that will be edited

The files to modify are:

exercise-install/stickynote/schema/tutorial/stickynote_port_type.wsdl:
Add a writeSemanticBinding operation

exercise-install/stickynote/deploy-server.wsdd:
Add the eu.ist.ontogrid.providers.metadata.MetadataOperationProvider operation provider

exercise-install/stickynote/deploy-jndi-config.xml:
Add the configuration parameters that inform the operation provider on the location of the Semantic Binding Service

exercise-install/stickynote/etc/post-deploy.xml:
Uncomment describe-note launch script generation

exercise-install/stickynote/src/org/globus/tutorial/stickynote/client/DescribeNote.java:
Source file of the client that will be used to attach a semantic binding to an existing note

The following files are the ones that will be used in this exercise. Make sure the following files exist.

exercise-install/stickynote/etc/StickyNote.rdf:
Content (in RDF format) of the semantic binding that will be attached to an existing note

3.2 Clean, rebuild and redeploy the StickyNote code

In the previous chapter we used the exercise window to deploy the semantic related components so now we need to come back to the sticky note directory. We can do this by running the following command in the exercise window.

$ cd /tmp/semGridTutorial/$USER/exercise-install/stickynote

Execute these commands from the /tmp/semGridTutorial/$USER/exercise-install/stickynote/ directory of the Exercise window.

$ ant clean
$ ant deploy

3.3 Kill and restart the Web service container in the GT window

$ [ctrl-c]
$ bin/globus-start-container -nosec

We will obtain the same output as before, since we have just redeployed the StickyNoteService.

3.4 From the exercise window, create a new note

$ $GLOBUS_LOCATION/bin/create-note -s http://localhost:8080/wsrf/services/StickyNoteService
new note created...
EPR written to file: note-1107777.epr

Note that the sticky note serial number will be probably different to the one shown in the previous box. It will be used in the subsequent exercises, so the serial number must be replaced by the one obtained during the execution.

3.5 Now attach a Semantic Binding to the note

$ $GLOBUS_LOCATION/bin/describe-note -e note-1107777.epr etc/StickyNote.rdf
Semantic Description added to Sticky Note:
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xml:base="http://www.ontogrid.net/StickyNote#"
xmlns="http://www.ontogrid.net/StickyNote#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<rdf:Description rdf:about="#event1">
<rdf:type rdf:resource="http://www.ontogrid.net/StickyNote#Event"/>
</rdf:Description>
<rdf:Description rdf:about="#event2">
<rdf:type rdf:resource="http://www.ontogrid.net/StickyNote#Local_Event"/>
</rdf:Description>
<rdf:Description rdf:about="#event3">
<rdf:type rdf:resource="http://www.ontogrid.net/StickyNote#Personal_Event"/>
<involves rdf:resource="#PinarAlper"/>
<involves rdf:resource="#CaroleGoble"/>
<eventDate rdf:datatype="http://www.w3.org/2001/XMLSchema#date">15/05/2006</eventDate>
</rdf:Description>
<rdf:Description rdf:about="#event4">
<rdf:type rdf:resource="http://www.ontogrid.net/StickyNote#Personal_Event"/>
<involves rdf:resource="#OscarCorcho"/>
<eventDate rdf:datatype="http://www.w3.org/2001/XMLSchema#date">16/05/2006</eventDate>
</rdf:Description>
<rdf:Description rdf:about="#event5">
<rdf:type rdf:resource="http://www.ontogrid.net/StickyNote#Personal_Event"/>
<involves rdf:resource="#CaroleGoble"/>
<eventDate rdf:datatype="http://www.w3.org/2001/XMLSchema#date">15/05/2006</eventDate>
</rdf:Description>
<rdf:Description rdf:about="#OscarCorcho">
<rdf:type rdf:resource="http://www.ontogrid.net/StickyNote#Researcher"/>
</rdf:Description>
<rdf:Description rdf:about="#PinarAlper">
<rdf:type rdf:resource="http://www.ontogrid.net/StickyNote#Researcher"/>
</rdf:Description>
<rdf:Description rdf:about="#CaroleGoble">
<rdf:type rdf:resource="http://www.ontogrid.net/StickyNote#Professor"/>
</rdf:Description>
</rdf:RDF>

The file etc/StickyNote.rdf contains RDF code that describes the content of the note, giving information about a set of events that the note contains, about the persons involved in those events (in the case of personal events) and about the dates of some of them. That code is now attached to the sticky note as a semantic binding.

Top

Chapter 4. Query the Semantic Binding associated with a StickyNote

In this chapter we will include one more operation from the Semantics Operation Provider which will allow us to query the content of semantic bindings associated with sticky notes. As seen in the previous chapter the content of Semantic Bindings in our tutorial is RDF. Within this chapter we will use an RDF query language namely SeRQL to query these semantic bindings.

4.1 Preliminar work. Files that will be edited

exercise-install/stickynote/schema/tutorial/stickynote_port_type.wsdl:
Add a querySemanticBinding operation

exercise-install/stickynote/etc/post-deploy.xml:
Uncomment query-note launch script generation

exercise-install/stickynote/src/org/globus/tutorial/stickynote/client/QueryNote.java:
Uncomment the source code block that will be used to query semantic bindings of a sticky note

Note that while we extend the StickyNote we do not provide implementation for the newly added querySemanticBinding operation. The implementation for this operation comes from the Semantic Operation provider.

4.2 Clean, rebuild and redeploy the stickynote code

Execute these commands from the /tmp/semGridTutorial/$USER/exercise-install/stickynote/ directory of the Exercise window.

$ ant clean
$ ant deploy

4.3 Kill and restart the Web service container in the GT window

$ [ctrl-c]
$ bin/globus-start-container -nosec

4.4 From the exercise window, create a new note

$ $GLOBUS_LOCATION/bin/create-note -s http://localhost:8080/wsrf/services/StickyNoteService
new note created...
EPR written to file: note-1108432.epr

4.5 Now attach a Semantic Binding to the note

$ $GLOBUS_LOCATION/bin/describe-note -e note-1101108432.epr etc/StickyNote.rdf
Semantic Description added to Sticky Note:
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xml:base="http://www.ontogrid.net/StickyNote#"
xmlns="http://www.ontogrid.net/StickyNote#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">

...

</rdf:RDF>

4.6 Query about the Semantic Binding attached to the note

First we will ask for the URIs of all the events inside the semantic binding attached to the note. The query contained in the etc/Query1.serql file is the following: "SELECT N FROM {N} rdf:type {sti:Event} USING NAMESPACE sti=<http://www.ontogrid.net/StickyNote#>"

$ $GLOBUS_LOCATION/bin/query-note -e note-1101108432.epr etc/Query1.serql
Semantic Binding Query Result is : <?xml version='1.0'?>
<sparql xmlns='http://www.w3.org/2005/sparql-results#'>
<head>
<variable name='N'/>
</head>
<results ordered='false' distinct='false'>
<result>
<binding name='N'>
<uri>http://www.ontogrid.net/StickyNote#event1</uri>
</binding>
</result>
</results>
</sparql>

Then we will ask for all the personal events that involve Oscar Corcho. The query contained in the etc/Query2.serql file is the following: "SELECT N FROM {N} rdf:type {sti:Event}; sti:involves {sti:OscarCorcho} USING NAMESPACE sti=<http://www.ontogrid.net/StickyNote#>". This query should not return any results.

$ $GLOBUS_LOCATION/bin/query-note -e note-1101108432.epr etc/Query2.serql
Semantic Binding Query Result is : <?xml version='1.0'?>
<sparql xmlns='http://www.w3.org/2005/sparql-results#'>
<head><variable name='N'/></head>
<results ordered='false' distinct='false'></results>
</sparql>

Finally we will ask for all the events that involve a professor. The query contained in the etc/Query3.serql file is the following: "SELECT N FROM {N} rdf:type {sti:Event}; sti:involves {M} rdf:type {sti:Professor} USING NAMESPACE sti=<http://www.ontogrid.net/StickyNote#>". This query should not return any results.

$ $GLOBUS_LOCATION/bin/query-note -e note-1101108432.epr etc/Query3.serql
Semantic Binding Query Result is : <?xml version='1.0'?>
<sparql xmlns='http://www.w3.org/2005/sparql-results#'>
<head><variable name='N'/></head>
<results ordered='false' distinct='false'></results>
</sparql>

The first query has returned as a result the event that has been explicitly specified as an instance of the class Event. The other types of events are not returned. The second and third queries do not return any results, even if it seems that they should return event 4, for the second query, and events 3 and 5, for the third query. We will see how to return these results in the next chapter.

Top

Chapter 5. Make inferences about the Semantic Binding associated to a StickyNote

In this chapter we will include in the operation provider the code necessary to make queries to the content of sticky notes using a query language such as SeRQL and performing inferences with the code, so that queries are not simply executed over the basic RDF graph of a Semantic Binding. Instead they are run taking into account the RDFS semantics and the resulting inferred statements.

5.1 Preliminar work. Files necessary for this chapter and files that will be edited

The files to modify are:

exercise-install/stickynote/schema/tutorial/stickynote_port_type.wsdl:
Add a querySemanticBindingInference operation

exercise-install/stickynote/etc/post-deploy.xml:
Uncomment query-note-inference launch script generation

exercise-install/stickynote/src/org/globus/tutorial/stickynote/client/QueryNoteInference.java:
Source file that will be used to query about the semantic binding attached to an existing note, using inferences

The following files are the ones that will be used in this exercise. Make sure the following files exist.

exercise-install/stickynote/etc/StickyNote.rdfs:
Model (in RDFS format) that will be used to provide semantics for the Semantic Bindings generated

Note that similar to the case in the previous chapter, we do not provide implementation for the newly added querySemanticBindingInference operation. The actual implementation for this operation comes from the Semantic Operation provider.

5.2 Clean, rebuild and redeploy the stickynote code

Execute these commands from the /tmp/semGridTutorial/$USER/exercise-install/stickynote/ directory of the Exercise window.

$ ant clean
$ ant deploy

5.3 Kill and restart the Web service container in the GT window

$ [ctrl-c]
$ bin/globus-start-container -nosec

5.4 From the exercise window, create a new note

$ $GLOBUS_LOCATION/bin/create-note -s http://localhost:8080/wsrf/services/StickyNoteService
new note created...
EPR written to file: note-1108522.epr

5.5 Now attach a Semantic Binding to the note

$ $GLOBUS_LOCATION/bin/describe-note -e note-1101108522.epr etc/StickyNote.rdf
Semantic Description added to Sticky Note:
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xml:base="http://www.ontogrid.net/StickyNote#"
xmlns="http://www.ontogrid.net/StickyNote#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">

...

</rdf:RDF>

5.6 Query about the Semantic Binding attached to the note

First we will ask for the URIs of all the events inside the semantic binding attached to the note. Please note that now all the command lines contain as well a reference to the model that will be used to infer information in the queries.

$ $GLOBUS_LOCATION/bin/query-note-inference -e note-1101108522.epr etc/StickyNote.rdfs etc/Query1.serql

[The result will be anXML-formatted SPARQL result set that contains the following URIs as results...]

http://www.ontogrid.net/StickyNote#event1
http://www.ontogrid.net/StickyNote#event3
http://www.ontogrid.net/StickyNote#event4
http://www.ontogrid.net/StickyNote#event2
http://www.ontogrid.net/StickyNote#event5

Then we will ask for all the personal events that involve Oscar Corcho.

$ $GLOBUS_LOCATION/bin/query-note-inference -e note-1101108522.epr etc/StickyNote.rdfs etc/Query2.serql

[The result will be anXML-formatted SPARQL result set that contains the following URIs as results...]

http://www.ontogrid.net/StickyNote#event4

Finally we will ask for all the events that involve a professor.

$ $GLOBUS_LOCATION/bin/query-note-inference -e note-1101108522.epr etc/StickyNote.rdfs etc/Query3.serql

[The result will be anXML-formatted SPARQL result set that contains the following URIs as results...]

http://www.ontogrid.net/StickyNote#event3
http://www.ontogrid.net/StickyNote#event5

The first query has returned as a result all the events (which are instances of the class Event or of any of its subclasses). The second query returns event 4, since it is a type of event (Personal_Event) that involves Oscar Corcho. Finally, the third query returns events 3 and 5.

Note that if the model used, currently stored in etc/StickyNote.rdfs, is changed (for instance, a Personal_Event is not defined as a type of Event) then the query results could be different.

Top

Chapter 6. Query about all the semantic bindings associated to a set of Sticky Notes

In this chapter we will make queries to the content of the semantic bindings of several sticky notes using a query language such as SeRQL. For this an operation provider attached to the sticky note service will not be necessary, but a repository of semantic bindings. That is, we will not deal directly with the sticky notes but with a metadata service that is in charge of storing all the semantic bindings attached to sticky notes.

6.1 Preliminar work. Files necessary for this chapter and files that will be edited

The files to modify are:

exercise-install/stickynote/etc/post-deploy.xml:
Uncomment query-all-notes launch script generation

exercise-install/stickynote/src/org/globus/tutorial/stickynote/client/QueryAllNotes.java:
Uncomment the source code block that will be used to query semantic bindings of all semantically described sticky notes.

The following files are the ones that will be used in this exercise. Make sure the following files exist.

exercise-install/stickynote/etc/StickyNote2.rdf:
Content (in RDF format) of the semantic binding that will be attached to the second note

exercise-install/SemanticBindingService/schema/metadata_query_port_type.wsdl:
Service that will be used as a common repository for all the semantic bindings generated for sticky notes

6.2 Clean, rebuild and redeploy the stickynote code

Execute these commands from the /tmp/semGridTutorial/$USER/exercise-install/stickynote/ directory of the Exercise window.

$ ant clean
$ ant deploy

6.3 Kill and restart the Web service container in the GT window

$ [ctrl-c]
$ bin/globus-start-container -nosec

6.4 From the exercise window, create two notes

$ $GLOBUS_LOCATION/bin/create-note -s http://localhost:8080/wsrf/services/StickyNoteService
new note created...
EPR written to file: note-2034287.epr

$ $GLOBUS_LOCATION/bin/create-note -s http://localhost:8080/wsrf/services/StickyNoteService
new note created...
EPR written to file: note-4839103.epr

6.5 Now attach Semantic Bindings to the notes

$ $GLOBUS_LOCATION/bin/describe-note -e note-2034287.epr etc/StickyNote.rdf
Semantic Description added to Sticky Note:
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xml:base="http://www.ontogrid.net/StickyNote#"
xmlns="http://www.ontogrid.net/StickyNote#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">

...

</rdf:RDF>

$ $GLOBUS_LOCATION/bin/describe-note -e note-4839103.epr etc/StickyNote2.rdf
Semantic Description added to Sticky Note:
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xml:base="http://www.ontogrid.net/StickyNote#"
xmlns="http://www.ontogrid.net/StickyNote#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">

...

</rdf:RDF>

6.6 Query about both Semantic Bindings

First we will ask for the URIs of all the events inside the semantic bindings attached to the note.

$ $GLOBUS_LOCATION/bin/query-all-notes -s http://localhost:8080/wsrf/services/MetadataQueryService etc/Query1.serql

[The result will be anXML-formatted SPARQL result set that contains the following URIs as results...]

http://www.ontogrid.net/StickyNote#event1
http://www.ontogrid.net/StickyNote#event10

We are not performing any inferences in this query, so only the instances that are direct instances of events have been selected. The result contains events from the first semantic binding and from the second semantic binding.

Now we will ask for all the personal events that involve Oscar Corcho, which returns events from both semantic bindings as well. The query contained in the etc/Query4.serql file is the following: "SELECT N FROM {N} rdf:type {sti:Personal_Event}; sti:involves {sti:OscarCorcho} USING NAMESPACE sti=<http://www.ontogrid.net/StickyNote#>"

$ $GLOBUS_LOCATION/bin/query-all-notes -s http://localhost:8080/wsrf/services/MetadataQueryService etc/Query4.serql

[The result will be anXML-formatted SPARQL result set that contains the following URIs as results...]

http://www.ontogrid.net/StickyNote#event4
http://www.ontogrid.net/StickyNote#event12

Finally we will ask for all the personal events that are to be held on May 15th, 2006, together with the persons involved in them. This will allow us to determine whether there are any clashes in the agenda of those people. The query contained in the etc/Query5.serql file is the following: "SELECT N, M FROM {N} rdf:type {sti:Personal_Event}; sti:involves {M}; sti:eventDate {D} WHERE D LIKE \"15/05/2006\" USING NAMESPACE sti=<http://www.ontogrid.net/StickyNote#>"

$ $GLOBUS_LOCATION/bin/query-all-notes -s http://localhost:8080/wsrf/services/MetadataQueryService etc/Query5.serql

[The result will be anXML-formatted SPARQL result set that contains the following URIs as results...]

http://www.ontogrid.net/StickyNote#event3 http://www.ontogrid.net/StickyNote#PinarAlper
http://www.ontogrid.net/StickyNote#event3 http://www.ontogrid.net/StickyNote#CaroleGoble
http://www.ontogrid.net/StickyNote#event5 http://www.ontogrid.net/StickyNote#CaroleGoble
http://www.ontogrid.net/StickyNote#event13 http://www.ontogrid.net/StickyNote#CaroleGoble

Top

(Optional) Chapter 7. Use a remote Semantic Binding Service

In the previous examples we have used a local deployment of both the StickyNoteService and of the SemanticBindingService, SemanticBindingFactoryService and MetadataQueryService. In this exercise we will use a remote Semantic Binding service. This will act as a common repository for all the Semantic Bindings attached to notes generated by all students.

Try all the steps in chapter 6 by replacing the existing service URI (which points to the localhost server) in the deploy_jndi_config.xml file with the service URI that will be given to you by the instructors during the tutorial, and try to find out to which events you have been invited by the other students in the classroom.

Top

Top