Model-Driven Architecture with Protege and OWL
Download
Report
Transcript Model-Driven Architecture with Protege and OWL
Ontology-Driven Software Development
with Protégé and OWL
Holger Knublauch
Stanford Medical Informatics
[email protected]
Model-Driven Semantic Web Workshop
21.09.2004
Protégé
Core System (since 1990s)
• Generic metamodel (OKBC)
• Configurable
• Open platform with “Plugins”
OWL Plugin (since 2003)
• OWL Full metamodel
• Optimized user interface
• Built-in reasoning access
• Several thousand users
Protégé / OWL Plugin
Protégé / OWL Plugin
Overview
• How to develop Semantic Web
applications?
– Example
– Architecture and OWL-Java mapping
– Tool support
• Can we apply this to general purpose MDA?
– OWL is often more suitable than UML
– Major benefit: Semantics at edit-time & run-time
Example Scenario
Traditional Web Architecture
Submission Forms
Cruise Operator
Query Interfaces
Travel Planning
Portal
Database
Boat Rental
Accommodation
Portal
Database
Hotel
End User
Manual actions
Automated actions
Semantic Web Architecture
Service Metadata
OWL
Query Interface
OWL
Boat Rental
Crawler
Agent
Travel Services
Database
and Agent
Web Service
Cruise Operator
OWL
User Profile
End User
OWL
Hotel
Manual actions
Automated actions
Ontologies
Travel Ontology
ActivityProvider
providesActivity
hasContact
Activity
Geography Ontology
ContactAddress
hasLocation
GeographicArea
AdventureActivity
City
BungeeJumping
Caving
HeliBungeeJumping
Travel Extension Ontologies
Country
HeliBungee.owl
Core Ontologies
Internal Layer
Semantic Web Layer
Software Architecture (1)
Travel.owl
...
ActivityX.owl
Customer.owl
Web Service
Interface
(WSDL)
End-User
Interface
(JSP)
Ontology representation
as Java objects
Web Service, Control Logic
(Java Code)
Reasoners (OWL DL, SWRL, ...)
Ontology Code in Java
Typical approach with a generic API (Jena):
OntModel model = ...;
OntProperty nameProperty = model.getOntProperty(baseURI + “name”);
Individual myActivity = model.getIndividual(baseURI + “test”);
String name = myActivity.getPropertyValue(nameProperty);
Bookings.book(myActivity);
...
Nicer approach with a customized API:
XYModel model = ...;
Activity myActivity = model.getActivity(baseURI + “test”);
String name = myActivity.getName();
myActivity.book();
...
UML to Java (conventional)
Activity
public class Activity {
private String name;
- name : String
0..*
private Collection providers;
providedBy
public String getName()
0..*
public void setName(String name)
ActivityProvider
public Iterator listProviders()
public void addProvider(ActivityProvider p)
public void removeProvider(ActivityProvider p)
}
OWL to Java (Jena)
Activity
public class Activity extends OntClassImpl {
- name : String
0..*
public String getName()
providedBy
public void setName(String name)
0..*
ActivityProvider
public Iterator listProviders()
public void addProvider(ActivityProvider p)
public void removeProvider(ActivityProvider p)
}
Working with Jena Classes
Generic Level
Resource
RDF
Triple Store
OntProperty
OntClass
Customer
Activity
Application Level
Bungee
HeliBungee.owl
Core Ontologies
Internal Layer
Semantic Web Layer
Software Architecture (2)
...
ActivityX.owl
Travel.owl
Customer.owl
Activity.java
...
Customer.java
...
Dynamic Object Model (Jena)
Reasoners (OWL DL, SWRL, ...)
Web Service
Interface
(WSDL)
End-User
Interface
(JSP)
Web Service, Control Logic
(Java Code)
Dynamic Object Model
• Model is accessible at run-time:
– Generic algorithms/reasoners can be executed
– Generic test cases available at run-time
– Generic serialization, database storage etc.
– Generic user interfaces can be generated
– Classes can be handled as individuals
(Metaclasses are supported)
– Instances can have multiple types
(dynamic polymorphism using Jena API)
– Instances can be classified & change types
Other OWL to Java Benefits
Traditional Code:
Collection patients = model.getPatients();
for(Iterator it = patients.iterator(); it.hasNext(); ) {
Patient patient = (Patient) it.next();
if(patient.isMale()) {
patient.doSomething();
}
}
Code based on generated Jena classes:
for(Iterator it = model.listIndividuals(MALE, true); it.hasNext(); ) {
Patient patient = (Patient) it.next();
patient.doSomething();
}
Generalizing This Approach
• Every program has a “domain model”
– Customers, Accounts, Products
– Patients, Diseases, Treatments
• Domain model is potentially most reusable
• No real need for UML
Model
• Paradigm shift to a
new dialect of OO
View
Control
Dynamic Object Models and MDA
• MDA taken to extremes
• Design not only to generate code
• Design is part of the deployed system
– Open ontologies to share between applications
– Machine-accessible semantics at run-time
– Built-in reflection across metalevels
• However: Limited expressivity of OWL;
Coding needed (procedural attachment).
Advantages of OWL over UML
• Explicit, sharable modeling artifacts
• Open architecture of Semantic Web
• OWL has rich semantics
– closer to domain than UML
– built-in reasoning support (DL, SWRL)
• A single language across metalevels
Strengths of tools like Protégé
•
•
•
•
•
•
•
Can be used by domain experts
Better scalable than visual UML modeling
Reasoning support at edit-time
Rapid prototyping of models
Individuals can be acquired using forms
Open architecture / adaptability
Start your application as a plugin
Ontology-Driven Development
Incremental Code
Generation
Agile Modeling
Model
Agile Programming
View
Control
Future Work with Protégé (1)
•
•
Embrace UML, encourage use of OWL
Incremental OWL-Java code generation
1. Determine optimal mapping OWL to Java,
(using an example application)
2. Define rules for updating code in response to
changes in the ontology (create, rename, etc).
3. Write Eclipse plugin to perform the updating
(either directly or in batch mode)
Future Work with Protégé (2)
•
•
Use Protégé as an ODM editor
Map core Protégé metamodel to RDF(S)
ODM Bridge
Collaborations?