You are on page 1of 24

Hng dn: TS Hong Hu Hnh Hc vin : Nguyn Mu Quc Hon Mai Vn Mi

CONTENTS
Gii thiu Eclipse Java Editor
Kin trc Eclipse Ci t Eclipse Vit chng trnh Java bng Eclipse Thm cc th vin ca Jena vo Eclipse Tng quan v Jena Cu trc Jena 2 Cc lp chnh To mt RDF Graph Read/Write RDF File

ECLIPSE?
Eclipse l phn mm min ph, c cc nh pht

trin s dng xy dng nhng ng dng J2EE.


Eclipse SDK bao gm 3 phn chnh:

Platform,
Java Development Toolkit (JDT), Plug-in Development Environment (PDE)

Vi JDT, Eclipse c xem nh l mt mi trng h

tr pht trin Java mnh m.


PDE h tr vic m rng Eclipse, tch hp cc Plug-in

vo Eclipse Platform

ECLIPSE?
Eclipse Platform l nn tng ca ton b phn mm

Eclipse, mc ch ca n l cung cp nhng dch v cn thit cho vic tch hp nhng b cng c pht trin phn mm khch di dng Plug-in . JDT cng c th c coi nh l mt Plug-in lm cho Eclipse nh l mt Java IDE (Integrated Development Enviroment).

KiN TRC ECLIPSE

The Platform runtime


Cng vic chnh ca Platform runtime l pht xem lug-

in no ang c trong th mc plug-in ca Eclipse.


Mi Plug-in u c 1 tp tin Manifest lit k nhng kt

ni m plug-in cn.
Pug-in ch c ti vo Eclipse mi khi thc s cn

thit gim lng ti nguyn yu cu v thi gian khi to.

The Workspace
Workspace chu trch nhim qun l ti nguyn ngi

dng c t chc di dng Project. Mi Project l mt th mc con trong th mc Workspace.


Workspace bo qun cp thp lch s nhng s thay

i ti nguyn, trnh tht thot ti nguyn ngi dng.


Workspace ng thi chu trch nhim thng bo

nhng cng c cn thit cho vic thay i ti nguyn.

The Workbench
Workbench l giao din ha ngi dng ca

Eclipse, gm c Standard Widget Toolkit (SWT) v JFace.


Eclipse khng hon ton bt buc phi s dng SWT

hay Jface lp trnh giao din, c th s dng AWT hay SWING ca Java thng qua vic ci t cc Plugins

Team support
Trang b h thng qun tr qun l d n ca ngi

dng : Concurrent Versions System (CVS)

Team support
Cung cp h thng ti liu m rng, c th l nh

dng HTML hay XML

CI T ECLIPSE
Trc ht bn ti Eclipse (Classic) v t a ch :

http://www.eclipse.org/downloads/
Gii nn tp tin Eclipse SDK vo th mc m bn

mun ci t (V d : C:\Eclipse).
Chp th mc JRE ca JDK vo th mc con ca th

mc Eclipse
Sau , chy tp tin eclipse.exe hon thnh ci t

TNG QUAN V JENA


L mt Java framework cho vic xy dng cc ng

dng web ng ngha Website: http://jena.sf.net Cung cp mt mi trng lp trnh cho RDF, RDFS and OWL, SPARQL Bao gm cc cng c suy din t cc lut c s (rulebased inference engine) Open source Phin bn u tin ra i 2000 do HP Lab xy dng Jena 2 ra i vo 2003 phin bn hin ti l Jena 2.5.6

TNG QUAN V JENA


Jena Framework bao gm: RDF API: Giao din lp trnh cho RDF OWL API: Giao din lp trnh cho OWL Xut v c cc file RDF theo dng RDF/XML, N3 v NTriples Cho php lu tr trong b nh, lu tr c nh trong cc tp tin n hay trong cc h qun tr c s d liu (MySQL, HSQLDB, PostgreSQL, Oracle, Microsoft SQL Server) H truy vn SPARQL

KiN TRC JENA2


RDF Graph c xem l tri tim ca kin trc Jena 2 tp cc b

ba cc node
Kin trc ca Jena c thit k

cho php tch hp mt cch d dng cc thnh phn x l c th thay th nh b phn tch d liu (parser), xut bn (writer), lu tr v truy vn
Jena API bao gm mt tp cc giao din Java m t cc ngun

ti nguyn (resources), cc thuc tnh (properties), cc pht biu (statements) v cc m hnh (model) di dng khung m t ti nguyn RDF (Resource Description Framework)

KiN TRC JENA2

Cc interfaces ca Jena2

KiN TRC JENA2


RDFNode interface: Cung cp cc thnh phn ca cc

b ba RDF {predicate, subject, object} Literal interface : Dng m t cc chui v chuyn i mt s kiu ca Java nh String, Int, v Double Cc i tng hin thc giao din Property c th l mt predicate trong b ba {predicate, subject, object} Statement interface: m t b ba {predicate, subject, object}. ng thi n cng c th c dng nh mt i tng Cc i tng hin thc cc giao din Container, Alt, Bag, hoc Seq c th l i tng

TO RDF GRAPH
Kin trc Jena tp trung vo m hnh RDF (RDF

model). Trong Jena mt lc RDF c gi l mt Model v c m t bi giao din Model. ModelFactory cung cp cc method to mt dng Model chun V d:

TO RDF GRAPH
S dng createDefaultModel() to mt RDF Model
Model model = ModelFactory.createDefaultModel();

to mt Resource:
Resource johnSmith = model.createResource(personURI);

Mt RDF Model c xem nh l mt tp cc pht

biu (statement). Mi pht biu ny c thm vo RDF Model bng phng thc addProperty:
johnSmith.addProperty(VCARD.FN, fullName);

Xut Model c to nh lp PrinterWriter ca Jena:


model.write(new PrintWriter(System.out)); (xut ra console)

TO RDF GRAPH
Kt qu xut ra console:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntaxns#" xmlns:vcard="http://www.w3.org/2001/vcard-rdf/3.0#" > <rdf:Description rdf:about="http://somewhere/JohnSmith"> <vcard:FN>John Smith</vcard:FN> </rdf:Description> </rdf:RDF>

TO RDF GRAPH
V d 2:
Blank node

TO RDF GRAPH
Kt qu xut ra dng RDF/XML:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:vcard="http://www.w3.org/2001/vcard-rdf/3.0#" > <rdf:Description rdf:about="http://somewhree/JohnSmith"> <vcard:N rdf:nodeID="A0"/> <vcard:FN>JohnSmith</vcard:FN> </rdf:Description> <rdf:Description rdf:nodeID="A0"> <vcard:Given>John</vcard:Given> <vcard:Family>Smith</vcard:Family> </rdf:Description> </rdf:RDF>

TO RDF GRAPH
Statements Mt statement gm 3 phn

Subject: resource Predicate: property Objects: resource hay literal

Thng thng mt statement c gi l triple (b

ba) Mt model l mt tp cc statement Jena model cung cp phng thc listStatement() vi gi tr tr v l StmIterator ( mt danh sch cc statement trong model )

TO RDF GRAPH
V d 3
Kt qu :
http://somewhree/JohnSmith http://www.w3.org/2001/vcard-rdf/3.0#N 207df7e5:11d4b6fc7da:-8000 http://somewhree/JohnSmith http://www.w3.org/2001/vcard-rdf/3.0#FN JohnSmith -207df7e5:11d4b6fc7da:-8000 http://www.w3.org/2001/vcard-rdf/3.0#Given John -207df7e5:11d4b6fc7da:-8000 http://www.w3.org/2001/vcard-rdf/3.0#Family Smith

READ/WRITE RDF FILE


Writing RDF model.write(System.out); Reading RDF
String inputFileName = "input.rdf";
InputStream in = FileManager.get().open(inputFileName); model.read(in,"");

Thanks for your attention

You might also like