Programming with JenaBean Sources for examples can be Taylor Cowan Travelocity 8982.

Slides:



Advertisements
Similar presentations
Dr. Leo Obrst MITRE Information Semantics Information Discovery & Understanding Command & Control Center February 6, 2014February 6, 2014February 6, 2014.
Advertisements

Introduction to linked data Gordon Dunsire Presented at the Cataloguing and Indexing Group Scotland seminar Linked data and the Semantic Web: what have.
CH-4 Ontologies, Querying and Data Integration. Introduction to RDF(S) RDF stands for Resource Description Framework. RDF is a standard for describing.
GridVine: Building Internet-Scale Semantic Overlay Networks By Lan Tian.
Jena a introduction Semantic Web Tools. Originally devised by HP Labs in Bristol, it was developed by Brian McBride of Hewlett-Packard and was derived.
ESDSWG2011 – Semantic Web session Semantic Web Sub-group Session ESDSWG 2011 Meeting – Semantic Web sub-group session Wednesday, November 2, 2011 Norfolk,
RDF Tutorial.
JENA –A SEMANTIC WEB TOOL by Ranjani Sankaran & krishna Priyanka Chebrolu.
© Copyright IBM Corporation 2014 Getting started with Rational Engineering Lifecycle Manager queries Andy Lapping – Technical sales and solutions Joanne.
 Copyright 2004 Digital Enterprise Research Institute. All rights reserved. SPARQL Query Language for RDF presented by Cristina Feier.
Programming with Jena Sources for examples can be
Chapter 3 Querying RDF stores with SPARQL. TL;DR We will want to query large RDF datasets, e.g. LOD SPARQL is the SQL of RDF SPARQL is a language to query.
Building and Analyzing Social Networks Web Data and Semantics in Social Network Applications Dr. Bhavani Thuraisingham February 15, 2013.
A division of Publishing Technology Facet Building Web Pages With SPARQL SWIG-UK Event, HP Labs November 23 rd 2007 Leigh Dodds Chief Technology Officer,
Terms and Rules Professor Evan Korth New York University (All rights reserved)
Semantic Web Presented by: Edward Cheng Wayne Choi Tony Deng Peter Kuc-Pittet Anita Yong.
Ontologies aka: your metadata elements. “ontology” / “vocabulary” / “term” / “element” “…vocabularies define the concepts and relationships (also referred.
Using Java in Linked Data Applications Fuming Shih Oct 12.
UNIT-V The MVC architecture and Struts Framework.
Semantic Web Bootcamp Dominic DiFranzo PhD Student/Research Assistant Rensselaer Polytechnic Institute Tetherless World Constellation.
CSE446 S OFTWARE Q UALITY M ANAGEMENT Spring 2014 Yazılım ve Uyguluma Geliştirme Yöneticisi Orhan Başar Evren.
© 2006 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice Publishing data on the Web (with.
RDF: Concepts and Abstract Syntax W3C Recommendation 10 February Michael Felderer Digital Enterprise.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
CSE 331 Software Design & Implementation Hal Perkins Autumn 2012 Java Classes, Interfaces, and Types 1.
Chapter 6 Class Inheritance F Superclasses and Subclasses F Keywords: super F Overriding methods F The Object Class F Modifiers: protected, final and abstract.
Practical RDF Chapter 1. RDF: An Introduction
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Logics for Data and Knowledge Representation
The Semantic Web Web Science Systems Development Spring 2015.
Chapter 3 Querying RDF stores with SPARQL. Why an RDF Query Language? Why not use an XML query language? XML at a lower level of abstraction than RDF.
Database Support for Semantic Web Masoud Taghinezhad Omran Sharif University of Technology Computer Engineering Department Fall.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
The Jena RDF Framework Konstantinos Tzonas. Contents What is Jena Capabilities of Jena Basic notions RDF concepts in Jena Persistence Ontology management.
Introduction to Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
Presentation : Konstantinos Kanaris.  What is Jena?  Usage of Jena  Main Concepts  Main Components  Storage Models  OWL API  RDF API  Reasoning.
RDF and XML 인공지능 연구실 한기덕. 2 개요  1. Basic of RDF  2. Example of RDF  3. How XML Namespaces Work  4. The Abbreviated RDF Syntax  5. RDF Resource Collections.
10-Nov-15 Java Object Oriented Programming What is it?
Efficient RDF Storage and Retrieval in Jena2 Written by: Kevin Wilkinson, Craig Sayers, Harumi Kuno, Dave Reynolds Presented by: Umer Fareed 파리드.
Semantic Web Exam 1 Review.
1 SPARQL A. Emrah Sanön. 2 RDF RDF is quite committed to Semantic Web. Data model Serialization by means of XML Formal semantics Still something is missing!
RELATORS, ROLES AND DATA… … similarities and differences.
Semantic Technologies and Application to Climate Data M. Benno Blumenthal IRI/Columbia University CDW /04-01.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
The Semantic Logger: Supporting Service Building from Personal Context Mischa M Tuffield et al. Intelligence, Agents, Multimedia Group University of Southampton.
Introduction to the Semantic Web and Linked Data Module 1 - Unit 2 The Semantic Web and Linked Data Concepts 1-1 Library of Congress BIBFRAME Pilot Training.
User Profiling using Semantic Web Group members: Ashwin Somaiah Asha Stephen Charlie Sudharshan Reddy.
COP INTERMEDIATE JAVA Designing Classes. Class Template or blueprint for creating objects. Their definition includes the list of properties (fields)
ESIP Semantic Web Products and Services ‘triples’ “tutorial” aka sausage making ESIP SW Cluster, Jan ed.
Ontology based e-Real Estate Agency Information System By Moein Mehrolhasani Bijan Zamanian cmpe 588.
Doc.: IEEE /0169r0 Submission Joe Kwak (InterDigital) Slide 1 November 2010 Slide 1 Overview of Resource Description Framework (RFD/XML) Date:
THE SEMANTIC WEB By Conrad Williams. Contents  What is the Semantic Web?  Technologies  XML  RDF  OWL  Implementations  Social Networking  Scholarly.
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Applying Semantic Technologies to Asset and Configuration Management in the Enterprise Taylor Cowan Brian Boyd Travelocity.com.
Applying Semantic Technologies to Asset and Configuration Management in the Enterprise Taylor Cowan Brian Boyd Travelocity.com.
OWL Web Ontology Language Summary IHan HSIAO (Sharon)
Semantic Interoperability in GIS N. L. Sarda Suman Somavarapu.
Kyung Hee University Class Diagramming Notation OOSD 담당조교 석사과정 이정환.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
Google Code Libraries Dima Ionut Daniel. Contents What is Google Code? LDAPBeans Object-ldap-mapping Ldap-ODM Bug4j jOOR Rapa jongo Conclusion Bibliography.
1 Analysis on the performance of graph query languages: Comparative study of Cypher, Gremlin and native access in Neo4j Athiq Ahamed, ITIS, TU-Braunschweig.
Setting the stage: linked data concepts Moving-Away-From-MARC-a-thon.
Unit 4 Representing Web Data: XML
Introduction to the Semantic Web (tutorial) 2009 Semantic Technology Conference San Jose, California, USA June 15, 2009 Ivan Herman, W3C
Data Modeling II XML Schema & JAXB Marc Dumontier May 4, 2004
Creating and Using Classes
Chapter 7 Representing Web Data: XML
Chapter 9 Web Services: JAX-RPC, WSDL, XML Schema, and SOAP
Session 2: Metadata and Catalogues
Presentation transcript:

Programming with JenaBean Sources for examples can be Taylor Cowan Travelocity 8982

2 [] a foaf:Person; foaf:name Taylor Cowan; foaf:weblog ; foaf:workplaceHomepage ; foaf:holdsAccount ; foaf:currentProject ;

3 Model m = ModelFactory.createDefaultModel(); Thing todaysTopic = new Thing(" m); new Thing(m).isa(Foaf.Person.class).name("Taylor Card.java in package example.fluentwriter

4 AGENDA >Semantic Web Introduction >RDF basics >Coding Towards Jena’s Semantic Web Framework API >Java to Model Binding with JenaBean >Java to Model Binding with Fluent Interfaces

Why Not Microformats? 5

6 Some example foaf: a dc:Article ; dc:creator "Philip McCarthy"^^xsd:string ; dc:subject "jena, rdf, java, semantic web"^^xsd:string ; dc:title "Introduction to Jena"^^xsd:string.

7 Equivalent Raw Jena API Client Code String NS = " OntModel m = ModelFactory.createOntologyModel(); OntClass articleCls = m.createClass(NS +"Article"); Individual i = articleCls.createIndividual( " Property title = m.getProperty(NS + "title"); Literal l = m.createTypedLiteral("Introduction to Jena"); i.setPropertyValue(title,l); Property creator = m.getProperty(NS + "creator"); l = m.createTypedLiteral("Philip McCarthy"); i.setPropertyValue(creator,l); Property subject = m.getProperty(NS + "subject"); l = m.createTypedLiteral("jena, rdf, java, semantic web"); i.setPropertyValue(subject,l); m.write(System.out, "N3");

8 Pain Points of Raw Jena API Programming >You need to create unique URI’s for every entity. >You must specify the type of each primitive value. >Properties must be created for each bean property. >The impedance mismatch is similar to what we had with RDBMS

9 Creating The Same Assertions with JenaBean Model m = ModelFactory.createDefaultModel(); Bean2RDF writer = new Bean2RDF(m); Article article = new Article( " article.setCreator("Philip McCarthy"); article.setTitle("Introduction to Jena"); article.setSubject("jena, rdf, java, semantic web"); writer.save(article); m.write(System.out, "N3");

10 The JenaBean Project >Hosted at Google code >Bean binding, not code generation >Doesn’t use byte code interweaving >Doesn’t require implementing an interface >

11 Programming with JenaBean is Simple >Bean2RDF writes objects >RDF2Bean reads objects >3 Annotations specifies unique field provides a domain maps java properties to RDF properties

The Simplest Possible Example package examples.model; import thewebsemantic.Id; public class Person private String ; public String get () { return ;} public void set (String ) { this. = ;} } 12 a ; "examples.model.Person". a ;

Saving an Instance of Person Model m = ModelFactory.createOntologyModel(); Bean2RDF writer = new Bean2RDF(m); Person p = new Person(); writer.save(p); m.write(System.out, "N3"); … a owl:Class ; "example.Person". a ; 13

Overriding the Default Namespace package examples.model; import thewebsemantic.Id; import public class Person { … } 14 a ; "examples.model.Person". a ;

Overriding the Default Property public class Person { private String + "name") private String name; 15 a ; "examples.model.Person". a ; "Taylor Cowan"^^xsd:string.

Extending Person to Support Friendship public Collection friends = new LinkedList public Collection getFriends() { return friends;} 16

Loading Beans from a Model RDF2Bean reader = new RDF2Bean(m); Person p = Collection allPeople = reader.load(Person.class); 17

JenaBean Support for OWL Entailments 18 public class Location public String id; public String public Collection public Collection contains; … a rdf:Property, owl:TransitiveProperty. a rdf:Property ; owl:inverseOf.

Reading Existing RDF/OWL 19 >Up till this point we were generating the triples >JenaBean + annotations controlled the URI’s >The model knew the provenance of all data (the originating java class)

Example Geonames “feature” entry 20 London Borough of Islington Islington Jenabean will bind to existing URI’s

Crafting beans for existing RDF requires care public class Feature private URI public double lat; Namespace must accurately match 2.Your java’s classname must match the Ontology class must be of type java.net.URI 4.All property URI’s must match the Ontology property

JenaBean can auto discover JenaBeans, provided it knows the package(s) 22 1: Model m = ModelFactory.createDefaultModel(); 2: m.read(" 3: RDF2Bean reader = new RDF2Bean(m); 4: reader.bindAll("com.foo", "com.bar"); // type safe binding by class reader.bind(Feature.class); // or package reader.bind(Feature.class.getPackage());

JenaBean tip: handling lang encoded strings If your data has something like this: Londres Then use JenaBean‘s special type “LocalizedString“ 23 public Collection alternateName; example.geonames

Query Support 24 // load using a Jena Resource reader.load(Human.class, jenaResource); // load any node using it’s URI reader.load(Human.class, " >Most most practical purposes there’s no need to utilize anything other than Jena’s ARQ api to query. JenaBean’s reader (RDF2Bean) can transform a node given it’s URI or it’s representation as a jena Resource…

thewebsemantic.Sparql Util 25 String query = "prefix ntn: \n" + "SELECT ?s WHERE { ?s a ntn:Woman }"; Model m = ModelFactory.createOntologyModel(); m.read("file:NTNames.owl"); m.read("file:NTN-individuals.owl"); RDF2Bean reader = new RDF2Bean(m); reader.bindAll("example.query"); Collection women = Sparql.exec(m, Woman.class, query); for (Human human : women) System.out.println(human.label + ":" + human.comment); example.query

Applies to class Applies to field or getter method Should be a String or primitive type, or wrapper type type java.net.URI is Applies to field or getter method Remember: by definition, JavaBeans must have a default constructor. 26

Summary writer.save(mybean) writer.saveDeep(mybean) Save this and all related objects reader.load(Class.class, key); reader.loadDeep(…); take care, could place entire graph into memory. reader.bindAll(package, package, …); Makes jenabean aware of your beans 27

JenaBean Fluent Programming API 28 >AKA method chaining, foo.this().that().bar(); >A “Fluent Interface” aims to provide more readable code >A significant departure from JavaBeans >Is always connected to the jena graph >Entirely interface (not class) driven >Allows Individuals to morph into their various classes >Allows use of vocabulary terms against any Individual regardless of classification.

Example: wgs84 geo vocabulary 29 import thewebsemantic.As; import thewebsemantic.Functional; import public interface Geo extends As { interface Point extends Geo lat(float l); Float Geo long_(float l); Float long_(); }

A fluent api + good IDE makes things fun 30

Create a new anonymous iCal event. 31 Ical t = new Thing(m).isa(Ical.Vevent.class); Create a new iCal event with URI Ical t = new Thing(“ m). isa(Ical.Vevent.class);

Full Example: Creating an iCal event for the meetup 32 1: Ical.Vevent t = new Thing(m).isa(Ical.Vevent.class); 2: 3: dtstart(" T200000Z"). 4: dtend(" T220000Z"). 5: summary("Jena Semantic Web…"). 6: location("Parisoma - …") 7:.as(Geo.class). 8: lat(37.77f). 9: long_( f); [] a ical:Vevent ; ical:dtend " T220000Z" ; ical:dtstart " T200000Z" ; ical:location "Parisoma - " ; ical:summary "Jena Semantic Web…" ; ical:uid ; geo:lat "37.77"^^xsd:float ; geo:long " "^^xsd:float.

JenaBean comes with a few common vocabulary interfaces 33 >thewebsemantic.vocabulary.Foaf >Geo >Ical >DCTerms >Sioc >Skos >Rdfs >ReviewVocab >You may want to copy and modify in some cases.

Fluent API summary: 34 >Your interface should extend thewebsemantic.As >Provides polymorphic “as(Class)” to other vocabs. >Provides easy type declaration with “isa(Class)” >Use annotation to bind to the vocabulary >Name setters according to vocab, taking either an Object (literal) or anther Thing (relationship to other Individuals) >Name getters according to vocab, returning the same vocabulary type and taking no arguments. >If the vocabulary term collides with reserved term (as with long), append a dash. >Plural properties should return a Collection.

35 Project Ideas >Create your own foaf document using the fluent interface. >Integrate Jena/JenaBean with restlets –restlets.org >Use your favorite framework (struts, stripes, spring mvc) and create a user registration screen. >Write JenaBeans that bind to jamendo or other music ontology at >Write a foaf crawler beginning with Berners-Lee that traverses his social graph. cc nickjohnson

Taylor Cowan Travelocity