his is the third article in a series that describes the why, what, and how to migrate an existing application to the
semantic web. The first article, "Why Migrate to
the Semantic Web," outlined the reasons for migrating an existing web application to the semantic web. The second article,
"Laying the Foundation of a Semantic Web
Application," focused on selecting a suitable semantic web framework
(Jena plus SDB).
This article focuses on migrating a CDMS web application that supports quality assurance and compliance checking in the Australian building and construction industries to the semantic web. As a part of this process:
The D2R Server provides an easy way to publish the ITP and related tables to the semantic web as Linked Data. After the content is published as Linked Data, other building applications can use the ITP. For example, you can create an owl:ObjectProperty, such as the following appliesInspectionTestPlan:
building:appliesInspectionTestPlan
a owl:ObjectProperty ;
rdfs:domain building:BuildingProject ;
rdfs:label "applies inspection test plan"^^xsd:string .
![]() |
|
| Figure 1. Building Project: An extract from the updated building project is shown here. |
The process for publishing the database tables to the semantic web is as follows. First, create a MySQL database common_itps by logging into mysql and running the command:
mysql> create database common_itps character set utf8 ;
Unzip the attached source code and open a command prompt in the top directory, which contains the file
common_itps.sql. This is a mysql dump of the ITP, which you can load into the database by running the command:
mysql --user=richard_rap --password=fender common_itps < common_itps.sql
Install the D2R Server by following the Quick Start instructions and adding the
MySQL driver JAR file to the D2R Server installation /lib directory.
Generate a mapping file (mapping_common_itps.n3) for the common_itps database by opening a command prompt in the D2R Server directory and running:
generate-mapping -o mapping_common_itps.n3 -u db-user -p db-password jdbc:mysql://localhost/common_itps
After the mapping file is generated, start the server by running the command:
d2r-server mapping_common_itps.n3
![]() |
|
| Figure 2. SPARQL Query: You can see the initial project set up here. |
You can now browse the ITP data online by opening http://localhost:2020/ in a web browser, ideally Firefox with the Tabulator extension installed.
Open the ITP directly in the browser using URLs such as http://localhost:2020/resource/inspection_test_plan/1.
You can run SPARQL queries using the AJAX-based SPARQL explorer http://localhost:2020/snorql/. For example, run the following SPARQL query (see Figure 2):
PREFIX itp: <http://localhost:2020/resource/vocab/>
CONSTRUCT { ?s itp:inspection_test_plan_name ?name }
WHERE {?s a itp:inspection_test_plan . ?s itp:inspection_test_plan_name ?name } ORDER BY ASC(?name) LIMIT 5
Jersey and implicit MVC also provide an easy way to create a simple RESTful web application based on Jena SDB (installed in the previous article "Laying the Foundation of a Semantic Web Application").
You can use a combination of Jenabean and Jersey annotations to map a domain class to RDF and also a RESTful resource that receives HTTP requests.
The Jenabean annotation @Namespace defines the namespace for the BuildingProject class, @RdfProperty defines the RDF property, and @Uri specifies the URI of the instance. This allows you to add the builder and ITP to the building project.
The Jersey JAX-RS annotations @POST, @Path, @Consumes, and @Produces allow the BuildingProject class to receive the POST requests from the JSP page, which is part of the implicit MVC implementation (see Listing 1).
User and Role classes map to the user and role tables using Hibernate JPA and implement the Spring Security framework interfaces UserDetails and GrantedAuthority respectively. The UserServiceImpl implements the UserDetailsService.
In the semantic web version of the application, a building project is stored as an RDF Named Graph in SDB. The URI of this graph contains the user name of the project owner. Also, as shown in this example project, roles are now defined by an owl:ObjectProperty such as foaf:fundedBy, building: builtBy, and building:designedBy. People are represented as foaf:Person. A URI to the foaf:Person definition for a person, such as contained in their personal FOAF page, links the person to the project.
To bridge the existing user table to the RDF project, the column person_uri is added to the user table, linking a CDMS user to their foaf:Person definition.
Access to a project can be controlled based on a person:
![]() |
|
| Figure 3. Access: An example of who has access to the project. |
A user is still authenticated using the user name and password held in the user table, but the Spring Security authorization now includes an additional AccessDecisionVoter, called ProjectMemberVoter, which implements the access rules above.
When a user who is not the project owner requests project access, the result of the SPARQL query below is used to check the projects they are associated with:
'SELECT DISTINCT ?s
{ GRAPH ?g
{ ?s a <http://3kbo.com/examples/building4.rdf#BuildingProject> .
?s ?p < person_uri > }
} '
where < person_uri > is the person's FOAF URI.
For the project example above, the query grants Alex access to the BreakerBay project.
The next steps include:
| DevX is a division of Internet.com. © Copyright 2010 Internet.com. All Rights Reserved. Legal Notices |