Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Migrating an Existing Application to the Semantic Web

Learn how to migrate to the semantic web.

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:

  • Information useful to the general building industry but previously hidden within the application becomes publicly available as Linked Data.
  • The existing domain model classes are mapped to RDF.
  • The security model is refactored to incorporate FOAF-based social networking information.

Publishing Selected Database Tables as Linked Data

Stored in a MySQL database within CDMS is a subset of information that you can share with the general building and construction industry to help promote a higher, uniform standard of quality. This subset is described in the article "Constructing an Ontology - Common Inspection and Test Plans." The central concept is an Inspection and Test Plan (ITP) that identifies when and what will be inspected and verified to meet acceptance criteria.

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.
Adding this definition to a building project example called Breaker Bay allows the published ITP to be applied to building projects. This is shown in Figure 1.

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.
Alternatively, you can start the server using the mapping file simple_mapping_common_itps.n3 from src/main/data. This mapping file hides audit fields such as created_by and updated_at.

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

Mapping Existing Domain Classes to RDF

Jenabean provides an easy way to map existing domain model classes to RDF using annotations. (See "Jenabean: Easily bind JavaBeans to RDF" for more details on Jenabean.)

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).

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.